x-ui-design 1.0.22 → 1.0.23
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 +2 -6
- package/dist/esm/types/index.d.ts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +13 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -21
- package/dist/index.js.map +1 -1
- package/lib/components/Input/Input.tsx +12 -32
- package/package.json +1 -1
- package/src/app/page.tsx +2 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import React, {
|
|
4
|
+
forwardRef,
|
|
4
5
|
KeyboardEvent,
|
|
5
6
|
MouseEvent,
|
|
6
7
|
useEffect,
|
|
@@ -17,15 +18,7 @@ import { ErrorIcon } from '../Icons/Icons';
|
|
|
17
18
|
import { applyMask, MASK_CHAR, MASK_REGEX, stripMask } from '../../helpers/mask';
|
|
18
19
|
import './style.css';
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
focus: () => void;
|
|
22
|
-
blur: () => void;
|
|
23
|
-
input: HTMLInputElement | null;
|
|
24
|
-
nativeElement: HTMLInputElement | null;
|
|
25
|
-
setSelectionRange: (start: number, end: number) => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const InputComponent = ({
|
|
21
|
+
const InputComponent = forwardRef<HTMLInputElement | { focus: () => void; blur: () => void; input: HTMLInputElement | null; nativeElement: HTMLInputElement | null; setSelectionRange: (start: number, end: number) => void; }, InputProps>(({
|
|
29
22
|
size = 'large',
|
|
30
23
|
error,
|
|
31
24
|
suffix,
|
|
@@ -49,13 +42,10 @@ const InputComponent = ({
|
|
|
49
42
|
// @ts-expect-error
|
|
50
43
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
51
44
|
__injected,
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
45
|
defaultValue,
|
|
54
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
55
46
|
child,
|
|
56
|
-
ref,
|
|
57
47
|
...props
|
|
58
|
-
}
|
|
48
|
+
}, ref) => {
|
|
59
49
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
60
50
|
const lastKeyPressed = useRef<string | null>(null);
|
|
61
51
|
const internalValue = mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : value ?? '';
|
|
@@ -63,25 +53,15 @@ const InputComponent = ({
|
|
|
63
53
|
const [iconRenderVisible, setIconRenderVisible] = useState(false);
|
|
64
54
|
const animationRef = useRef<number | null>(null);
|
|
65
55
|
|
|
66
|
-
useImperativeHandle
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(input as any).nativeElement = input;
|
|
75
|
-
|
|
76
|
-
return input;
|
|
56
|
+
useImperativeHandle(ref, () => ({
|
|
57
|
+
focus: () => inputRef.current?.focus(),
|
|
58
|
+
blur: () => inputRef.current?.blur(),
|
|
59
|
+
input: inputRef.current,
|
|
60
|
+
nativeElement: inputRef.current,
|
|
61
|
+
setSelectionRange: (start: number, end: number) => {
|
|
62
|
+
inputRef.current?.setSelectionRange(start, end);
|
|
77
63
|
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
focus: () => inputRef.current?.focus(),
|
|
81
|
-
blur: () => inputRef.current?.blur(),
|
|
82
|
-
setSelectionRange: () => {},
|
|
83
|
-
} as any;
|
|
84
|
-
}, [inputRef]);
|
|
64
|
+
}), [inputRef]);
|
|
85
65
|
|
|
86
66
|
useEffect(() => {
|
|
87
67
|
setMaskValue(mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : (value ?? ''));
|
|
@@ -219,7 +199,7 @@ const InputComponent = ({
|
|
|
219
199
|
) : null}
|
|
220
200
|
</div>
|
|
221
201
|
);
|
|
222
|
-
};
|
|
202
|
+
});
|
|
223
203
|
|
|
224
204
|
InputComponent.displayName = 'Input';
|
|
225
205
|
|
package/package.json
CHANGED