diff --git a/apps/web/src/dialogs/settings/index.tsx b/apps/web/src/dialogs/settings/index.tsx
index 1ef2d1cb3..5c01ac5df 100644
--- a/apps/web/src/dialogs/settings/index.tsx
+++ b/apps/web/src/dialogs/settings/index.tsx
@@ -580,23 +580,12 @@ function SettingItem(props: { item: Setting }) {
);
case "input":
return component.inputType === "number" ? (
- {
- let value = e.target.valueAsNumber;
- value =
- Number.isNaN(value) || value < component.min
- ? component.min
- : value > component.max
- ? component.max
- : value;
- component.onChange(value);
- }, 500)}
+ onChange={(value) => component.onChange(value)}
/>
) : (
) {
);
}
+
+type NumberInputProps = {
+ min: number;
+ max: number;
+ step?: number;
+ defaultValue: number;
+ onChange: (value: number) => void;
+};
+
+function NumberInput({
+ min,
+ max,
+ step,
+ defaultValue,
+ onChange
+}: NumberInputProps) {
+ const [isInputValid, setIsInputValid] = useState(true);
+
+ return (
+
+ {
+ let value = e.target.valueAsNumber;
+ const isValid = !Number.isNaN(value) && value >= min && value <= max;
+ setIsInputValid(isValid);
+ value =
+ Number.isNaN(value) || value < min
+ ? min
+ : value > max
+ ? max
+ : value;
+ onChange(value);
+ }, 500)}
+ />
+ {!isInputValid && (
+
+ {strings.valueMustBeBetween(min, max)}
+
+ )}
+
+ );
+}
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index c235422d4..37ea002a6 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -6988,6 +6988,10 @@ msgstr "Using official Notesnook instance"
msgid "v{version} available"
msgstr "v{version} available"
+#: src/strings.ts:2627
+msgid "Value must be between {min} and {max}"
+msgstr "Value must be between {min} and {max}"
+
#: src/strings.ts:1171
msgid "Vault"
msgstr "Vault"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index f1606a666..f6343a331 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -6938,6 +6938,10 @@ msgstr ""
msgid "v{version} available"
msgstr ""
+#: src/strings.ts:2627
+msgid "Value must be between {min} and {max}"
+msgstr ""
+
#: src/strings.ts:1171
msgid "Vault"
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 860107803..de7c89b3d 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2622,5 +2622,7 @@ Use this if changes from other devices are not appearing on this device. This wi
t`Your free trial is on-going. Your subscription will start on ${trialExpiryDate}`,
weekFormat: () => t`Week format`,
weekFormatDesc: () =>
- t`Choose what day to display as the first day of the week`
+ t`Choose what day to display as the first day of the week`,
+ valueMustBeBetween: (min: number, max: number) =>
+ t`Value must be between ${min} and ${max}`
};