@worknice/whiteboard 0.16.2 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,11 +3,12 @@ type Props = {
|
|
|
3
3
|
autoFocus?: boolean;
|
|
4
4
|
disabled?: boolean;
|
|
5
5
|
id?: string;
|
|
6
|
+
maxLength?: number;
|
|
6
7
|
onChange: Dispatch<number | null>;
|
|
7
8
|
placeholder?: string;
|
|
8
9
|
value: number | null;
|
|
9
10
|
prefix?: string;
|
|
10
11
|
suffix?: string;
|
|
11
12
|
};
|
|
12
|
-
declare const NumberInput: ({ autoFocus, disabled, id, onChange, placeholder, value, prefix, suffix, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare const NumberInput: ({ autoFocus, disabled, id, maxLength, onChange, placeholder, value, prefix, suffix, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export default NumberInput;
|
|
@@ -2,8 +2,11 @@ import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__ from "react/j
|
|
|
2
2
|
import * as __WEBPACK_EXTERNAL_MODULE_clsx__ from "clsx";
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE__NumberInput_module_js_5606faf2__ from "./NumberInput.module.js";
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_MAX_LENGTH = 10;
|
|
6
|
+
const MAXIMUM_MAX_LENGTH = 15;
|
|
7
|
+
const NumberInput = ({ autoFocus = false, disabled, id, maxLength = DEFAULT_MAX_LENGTH, onChange, placeholder, value, prefix, suffix })=>{
|
|
6
8
|
const ref = (0, __WEBPACK_EXTERNAL_MODULE_react__.useRef)(null);
|
|
9
|
+
const actualMaxLength = Math.min(maxLength, MAXIMUM_MAX_LENGTH);
|
|
7
10
|
(0, __WEBPACK_EXTERNAL_MODULE_react__.useEffect)(()=>{
|
|
8
11
|
if (autoFocus && ref.current) ref.current.focus();
|
|
9
12
|
}, [
|
|
@@ -25,8 +28,9 @@ const NumberInput = ({ autoFocus = false, disabled, id, onChange, placeholder, v
|
|
|
25
28
|
}),
|
|
26
29
|
disabled: disabled,
|
|
27
30
|
id: id,
|
|
31
|
+
maxLength: actualMaxLength,
|
|
28
32
|
onChange: (event)=>{
|
|
29
|
-
onChange(event.target.value ?
|
|
33
|
+
onChange(event.target.value ? isValidInteger(event.target.value) ? parseInt(event.target.value) : null : null);
|
|
30
34
|
},
|
|
31
35
|
placeholder: placeholder,
|
|
32
36
|
type: "text",
|
|
@@ -40,5 +44,10 @@ const NumberInput = ({ autoFocus = false, disabled, id, onChange, placeholder, v
|
|
|
40
44
|
]
|
|
41
45
|
});
|
|
42
46
|
};
|
|
47
|
+
const isValidInteger = (str)=>{
|
|
48
|
+
if (!/^\d+$/.test(str)) return false;
|
|
49
|
+
const num = Number(str);
|
|
50
|
+
return Number.isSafeInteger(num) && num >= 0;
|
|
51
|
+
};
|
|
43
52
|
const NumberInput_rslib_entry_ = NumberInput;
|
|
44
53
|
export { NumberInput_rslib_entry_ as default };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/whiteboard",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-markdown": "^10.1.0",
|
|
39
39
|
"utf8": "^3.0.0",
|
|
40
40
|
"zod": "^3.22.3",
|
|
41
|
-
"@worknice/utils": "^0.6.
|
|
41
|
+
"@worknice/utils": "^0.6.44"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@anolilab/semantic-release-pnpm": "^1.1.10",
|