@xanui/ui 1.1.60 → 1.1.61

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.
@@ -14,7 +14,8 @@ const InputNumber = React.forwardRef((props, ref) => {
14
14
  const mergeRef = core.useMergeRefs(inputRef, ref);
15
15
  React.useEffect(() => {
16
16
  if (inputRef.current && (props === null || props === void 0 ? void 0 : props.onChange)) {
17
- inputRef.current.value = _val.includes(".") ? parseFloat(_val) : parseInt(_val);
17
+ let valstr = String(_val);
18
+ inputRef.current.value = valstr.includes(".") ? parseFloat(_val) : parseInt(_val);
18
19
  const syntheticEvent = {
19
20
  target: inputRef.current,
20
21
  currentTarget: inputRef.current,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../src/InputNumber/index.tsx"],"sourcesContent":["\"use client\"\nimport React, { useEffect, useRef, useState } from 'react'\nimport Input, { InputProps } from '../Input'\nimport UnfoldMore from '@xanui/icons/UnfoldMore'\nimport { useMergeRefs } from '@xanui/core'\n\nexport type InputNumberProps = Omit<InputProps, \"value\"> & {\n value?: number; // allow string so typing \".\" works\n}\n\nconst InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props, ref) => {\n const [_val, setVal] = useState<string>(props.value as any ?? \"\")\n const inputRef = useRef<any>(null)\n const mergeRef = useMergeRefs(inputRef, ref)\n useEffect(() => {\n if (inputRef.current && props?.onChange) {\n inputRef.current.value = _val.includes(\".\") ? parseFloat(_val) : parseInt(_val)\n const syntheticEvent = {\n target: inputRef.current,\n currentTarget: inputRef.current,\n } as unknown as React.ChangeEvent<HTMLInputElement>;\n props?.onChange(syntheticEvent)\n }\n }, [_val])\n\n const isNumeric = _val === undefined || _val === '' || !isNaN(Number(_val));\n const errorProps: Partial<InputProps> = {};\n if (!isNumeric) {\n errorProps.error = true;\n errorProps.helperText = \"Value must be numeric\";\n }\n\n return (\n <Input\n {...props}\n {...errorProps}\n ref={mergeRef}\n endIcon={<UnfoldMore />}\n value={_val ?? \"\" as any}\n onKeyDown={(e: any) => {\n props.onKeyDown?.(e);\n\n if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;\n\n e.preventDefault();\n const current = parseFloat(_val as any) || 0;\n setVal(e.key === 'ArrowUp' ? current + 1 : current - 1 as any);\n }}\n onChange={(e) => {\n let val: any = e.target.value.replace(/[^0-9.]/g, '')\n const parts = val.split('.');\n if (parts.length > 2) {\n val = parts[0] + '.' + parts.slice(1).join('')\n }\n setVal(val === \".\" ? `0.` : val);\n }}\n />\n );\n});\n\nexport default InputNumber;\n"],"names":[],"mappings":";;;;;;;;;AAUA;;AACG;AACA;;;AAGG;;AAEG;;;;;;AAMN;AAEA;;;AAGG;AACA;;AAGH;;AAQS;;;;;AAMA;AACH;AAEG;;AAEA;AACG;;AAEH;;AAIZ;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../src/InputNumber/index.tsx"],"sourcesContent":["\"use client\"\nimport React, { useEffect, useRef, useState } from 'react'\nimport Input, { InputProps } from '../Input'\nimport UnfoldMore from '@xanui/icons/UnfoldMore'\nimport { useMergeRefs } from '@xanui/core'\n\nexport type InputNumberProps = Omit<InputProps, \"value\"> & {\n value?: number; // allow string so typing \".\" works\n}\n\nconst InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props, ref) => {\n const [_val, setVal] = useState<string>(props.value as any ?? \"\")\n const inputRef = useRef<any>(null)\n const mergeRef = useMergeRefs(inputRef, ref)\n useEffect(() => {\n if (inputRef.current && props?.onChange) {\n let valstr = String(_val)\n inputRef.current.value = valstr.includes(\".\") ? parseFloat(_val) : parseInt(_val)\n const syntheticEvent = {\n target: inputRef.current,\n currentTarget: inputRef.current,\n } as unknown as React.ChangeEvent<HTMLInputElement>;\n props?.onChange(syntheticEvent)\n }\n }, [_val])\n\n const isNumeric = _val === undefined || _val === '' || !isNaN(Number(_val));\n const errorProps: Partial<InputProps> = {};\n if (!isNumeric) {\n errorProps.error = true;\n errorProps.helperText = \"Value must be numeric\";\n }\n\n return (\n <Input\n {...props}\n {...errorProps}\n ref={mergeRef}\n endIcon={<UnfoldMore />}\n value={_val ?? \"\" as any}\n onKeyDown={(e: any) => {\n props.onKeyDown?.(e);\n\n if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;\n\n e.preventDefault();\n const current = parseFloat(_val as any) || 0;\n setVal(e.key === 'ArrowUp' ? current + 1 : current - 1 as any);\n }}\n onChange={(e) => {\n let val: any = e.target.value.replace(/[^0-9.]/g, '')\n const parts = val.split('.');\n if (parts.length > 2) {\n val = parts[0] + '.' + parts.slice(1).join('')\n }\n setVal(val === \".\" ? `0.` : val);\n }}\n />\n );\n});\n\nexport default InputNumber;\n"],"names":[],"mappings":";;;;;;;;;AAUA;;AACG;AACA;;;AAGG;AACG;;AAEA;;;;;;AAMN;AAEA;;;AAGG;AACA;;AAGH;;AAQS;;;;;AAMA;AACH;AAEG;;AAEA;AACG;;AAEH;;AAIZ;;"}
@@ -12,7 +12,8 @@ const InputNumber = React.forwardRef((props, ref) => {
12
12
  const mergeRef = useMergeRefs(inputRef, ref);
13
13
  useEffect(() => {
14
14
  if (inputRef.current && (props === null || props === void 0 ? void 0 : props.onChange)) {
15
- inputRef.current.value = _val.includes(".") ? parseFloat(_val) : parseInt(_val);
15
+ let valstr = String(_val);
16
+ inputRef.current.value = valstr.includes(".") ? parseFloat(_val) : parseInt(_val);
16
17
  const syntheticEvent = {
17
18
  target: inputRef.current,
18
19
  currentTarget: inputRef.current,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/InputNumber/index.tsx"],"sourcesContent":["\"use client\"\nimport React, { useEffect, useRef, useState } from 'react'\nimport Input, { InputProps } from '../Input'\nimport UnfoldMore from '@xanui/icons/UnfoldMore'\nimport { useMergeRefs } from '@xanui/core'\n\nexport type InputNumberProps = Omit<InputProps, \"value\"> & {\n value?: number; // allow string so typing \".\" works\n}\n\nconst InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props, ref) => {\n const [_val, setVal] = useState<string>(props.value as any ?? \"\")\n const inputRef = useRef<any>(null)\n const mergeRef = useMergeRefs(inputRef, ref)\n useEffect(() => {\n if (inputRef.current && props?.onChange) {\n inputRef.current.value = _val.includes(\".\") ? parseFloat(_val) : parseInt(_val)\n const syntheticEvent = {\n target: inputRef.current,\n currentTarget: inputRef.current,\n } as unknown as React.ChangeEvent<HTMLInputElement>;\n props?.onChange(syntheticEvent)\n }\n }, [_val])\n\n const isNumeric = _val === undefined || _val === '' || !isNaN(Number(_val));\n const errorProps: Partial<InputProps> = {};\n if (!isNumeric) {\n errorProps.error = true;\n errorProps.helperText = \"Value must be numeric\";\n }\n\n return (\n <Input\n {...props}\n {...errorProps}\n ref={mergeRef}\n endIcon={<UnfoldMore />}\n value={_val ?? \"\" as any}\n onKeyDown={(e: any) => {\n props.onKeyDown?.(e);\n\n if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;\n\n e.preventDefault();\n const current = parseFloat(_val as any) || 0;\n setVal(e.key === 'ArrowUp' ? current + 1 : current - 1 as any);\n }}\n onChange={(e) => {\n let val: any = e.target.value.replace(/[^0-9.]/g, '')\n const parts = val.split('.');\n if (parts.length > 2) {\n val = parts[0] + '.' + parts.slice(1).join('')\n }\n setVal(val === \".\" ? `0.` : val);\n }}\n />\n );\n});\n\nexport default InputNumber;\n"],"names":[],"mappings":";;;;;;;AAUA;;AACG;AACA;;;AAGG;;AAEG;;;;;;AAMN;AAEA;;;AAGG;AACA;;AAGH;;AAQS;;;;;AAMA;AACH;AAEG;;AAEA;AACG;;AAEH;;AAIZ;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/InputNumber/index.tsx"],"sourcesContent":["\"use client\"\nimport React, { useEffect, useRef, useState } from 'react'\nimport Input, { InputProps } from '../Input'\nimport UnfoldMore from '@xanui/icons/UnfoldMore'\nimport { useMergeRefs } from '@xanui/core'\n\nexport type InputNumberProps = Omit<InputProps, \"value\"> & {\n value?: number; // allow string so typing \".\" works\n}\n\nconst InputNumber = React.forwardRef<HTMLInputElement, InputNumberProps>((props, ref) => {\n const [_val, setVal] = useState<string>(props.value as any ?? \"\")\n const inputRef = useRef<any>(null)\n const mergeRef = useMergeRefs(inputRef, ref)\n useEffect(() => {\n if (inputRef.current && props?.onChange) {\n let valstr = String(_val)\n inputRef.current.value = valstr.includes(\".\") ? parseFloat(_val) : parseInt(_val)\n const syntheticEvent = {\n target: inputRef.current,\n currentTarget: inputRef.current,\n } as unknown as React.ChangeEvent<HTMLInputElement>;\n props?.onChange(syntheticEvent)\n }\n }, [_val])\n\n const isNumeric = _val === undefined || _val === '' || !isNaN(Number(_val));\n const errorProps: Partial<InputProps> = {};\n if (!isNumeric) {\n errorProps.error = true;\n errorProps.helperText = \"Value must be numeric\";\n }\n\n return (\n <Input\n {...props}\n {...errorProps}\n ref={mergeRef}\n endIcon={<UnfoldMore />}\n value={_val ?? \"\" as any}\n onKeyDown={(e: any) => {\n props.onKeyDown?.(e);\n\n if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;\n\n e.preventDefault();\n const current = parseFloat(_val as any) || 0;\n setVal(e.key === 'ArrowUp' ? current + 1 : current - 1 as any);\n }}\n onChange={(e) => {\n let val: any = e.target.value.replace(/[^0-9.]/g, '')\n const parts = val.split('.');\n if (parts.length > 2) {\n val = parts[0] + '.' + parts.slice(1).join('')\n }\n setVal(val === \".\" ? `0.` : val);\n }}\n />\n );\n});\n\nexport default InputNumber;\n"],"names":[],"mappings":";;;;;;;AAUA;;AACG;AACA;;;AAGG;AACG;;AAEA;;;;;;AAMN;AAEA;;;AAGG;AACA;;AAGH;;AAQS;;;;;AAMA;AACH;AAEG;;AAEA;AACG;;AAEH;;AAIZ;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xanui/ui",
3
- "version": "1.1.60",
3
+ "version": "1.1.61",
4
4
  "description": "Xanui - A React Component Library",
5
5
  "private": false,
6
6
  "dependencies": {