x-ui-design 1.0.23 → 1.0.25
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 +4 -7
- package/dist/esm/types/index.d.ts +1 -7
- package/dist/index.d.ts +1 -7
- package/dist/index.esm.js +11 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/lib/components/Input/Input.tsx +10 -6
- package/package.json +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, {
|
|
4
|
-
forwardRef,
|
|
5
4
|
KeyboardEvent,
|
|
6
5
|
MouseEvent,
|
|
7
6
|
useEffect,
|
|
@@ -18,7 +17,7 @@ import { ErrorIcon } from '../Icons/Icons';
|
|
|
18
17
|
import { applyMask, MASK_CHAR, MASK_REGEX, stripMask } from '../../helpers/mask';
|
|
19
18
|
import './style.css';
|
|
20
19
|
|
|
21
|
-
const InputComponent =
|
|
20
|
+
const InputComponent = ({
|
|
22
21
|
size = 'large',
|
|
23
22
|
error,
|
|
24
23
|
suffix,
|
|
@@ -42,10 +41,13 @@ const InputComponent = forwardRef<HTMLInputElement | { focus: () => void; blur:
|
|
|
42
41
|
// @ts-expect-error
|
|
43
42
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
43
|
__injected,
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
45
|
defaultValue,
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
47
|
child,
|
|
48
|
+
ref,
|
|
47
49
|
...props
|
|
48
|
-
}
|
|
50
|
+
}: InputProps) => {
|
|
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 ?? '';
|
|
@@ -59,9 +61,11 @@ const InputComponent = forwardRef<HTMLInputElement | { focus: () => void; blur:
|
|
|
59
61
|
input: inputRef.current,
|
|
60
62
|
nativeElement: inputRef.current,
|
|
61
63
|
setSelectionRange: (start: number, end: number) => {
|
|
62
|
-
inputRef.current
|
|
64
|
+
if (inputRef.current) {
|
|
65
|
+
inputRef.current.setSelectionRange(start, end);
|
|
66
|
+
}
|
|
63
67
|
}
|
|
64
|
-
})
|
|
68
|
+
}));
|
|
65
69
|
|
|
66
70
|
useEffect(() => {
|
|
67
71
|
setMaskValue(mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : (value ?? ''));
|
|
@@ -199,7 +203,7 @@ const InputComponent = forwardRef<HTMLInputElement | { focus: () => void; blur:
|
|
|
199
203
|
) : null}
|
|
200
204
|
</div>
|
|
201
205
|
);
|
|
202
|
-
}
|
|
206
|
+
};
|
|
203
207
|
|
|
204
208
|
InputComponent.displayName = 'Input';
|
|
205
209
|
|