x-ui-design 1.0.23 → 1.0.24
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.
- package/dist/esm/types/components/Input/Input.d.ts +1 -7
- package/dist/esm/types/index.d.ts +1 -7
- package/dist/index.d.ts +1 -7
- package/dist/index.esm.js +13 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/lib/components/Input/Input.tsx +15 -6
- package/package.json +1 -1
|
@@ -18,7 +18,7 @@ import { ErrorIcon } from '../Icons/Icons';
|
|
|
18
18
|
import { applyMask, MASK_CHAR, MASK_REGEX, stripMask } from '../../helpers/mask';
|
|
19
19
|
import './style.css';
|
|
20
20
|
|
|
21
|
-
const InputComponent = forwardRef
|
|
21
|
+
const InputComponent = forwardRef(({
|
|
22
22
|
size = 'large',
|
|
23
23
|
error,
|
|
24
24
|
suffix,
|
|
@@ -42,10 +42,12 @@ const InputComponent = forwardRef<HTMLInputElement | { focus: () => void; blur:
|
|
|
42
42
|
// @ts-expect-error
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
44
|
__injected,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
46
|
defaultValue,
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
48
|
child,
|
|
47
49
|
...props
|
|
48
|
-
}, ref) => {
|
|
50
|
+
}: InputProps, ref) => {
|
|
49
51
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
50
52
|
const lastKeyPressed = useRef<string | null>(null);
|
|
51
53
|
const internalValue = mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : value ?? '';
|
|
@@ -54,14 +56,21 @@ const InputComponent = forwardRef<HTMLInputElement | { focus: () => void; blur:
|
|
|
54
56
|
const animationRef = useRef<number | null>(null);
|
|
55
57
|
|
|
56
58
|
useImperativeHandle(ref, () => ({
|
|
57
|
-
focus: () =>
|
|
58
|
-
|
|
59
|
+
focus: () => {
|
|
60
|
+
console.info('focusing');
|
|
61
|
+
inputRef.current?.focus()
|
|
62
|
+
},
|
|
63
|
+
blur: () => {
|
|
64
|
+
inputRef.current?.blur()
|
|
65
|
+
},
|
|
59
66
|
input: inputRef.current,
|
|
60
67
|
nativeElement: inputRef.current,
|
|
61
68
|
setSelectionRange: (start: number, end: number) => {
|
|
62
|
-
inputRef.current
|
|
69
|
+
if (inputRef.current) {
|
|
70
|
+
inputRef.current.setSelectionRange(start, end);
|
|
71
|
+
}
|
|
63
72
|
}
|
|
64
|
-
}), [
|
|
73
|
+
}), [ref]);
|
|
65
74
|
|
|
66
75
|
useEffect(() => {
|
|
67
76
|
setMaskValue(mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : (value ?? ''));
|