x-ui-design 1.0.26 → 1.0.27
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 +6 -26
- package/dist/esm/types/index.d.ts +1 -24
- package/dist/esm/types/types/input.d.ts +2 -1
- package/dist/index.d.ts +2 -26
- package/dist/index.esm.js +11 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/lib/components/Input/Input.tsx +10 -5
- package/lib/types/input.ts +2 -1
- 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,
|
|
@@ -38,13 +37,17 @@ const InputComponent = forwardRef<RuleType, InputProps>(({
|
|
|
38
37
|
mask,
|
|
39
38
|
maskChar = MASK_CHAR,
|
|
40
39
|
maskRegex = MASK_REGEX,
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
41
41
|
// @ts-expect-error
|
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
43
43
|
__injected,
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
45
|
defaultValue,
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
45
47
|
child,
|
|
48
|
+
ref,
|
|
46
49
|
...props
|
|
47
|
-
}
|
|
50
|
+
}: InputProps) => {
|
|
48
51
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
49
52
|
const lastKeyPressed = useRef<string | null>(null);
|
|
50
53
|
const internalValue = mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : value ?? '';
|
|
@@ -58,7 +61,9 @@ const InputComponent = forwardRef<RuleType, InputProps>(({
|
|
|
58
61
|
input: inputRef.current,
|
|
59
62
|
nativeElement: inputRef.current,
|
|
60
63
|
setSelectionRange: (start: number, end: number) => {
|
|
61
|
-
inputRef.current
|
|
64
|
+
if (inputRef.current) {
|
|
65
|
+
inputRef.current.setSelectionRange(start, end);
|
|
66
|
+
}
|
|
62
67
|
}
|
|
63
68
|
}));
|
|
64
69
|
|
|
@@ -198,7 +203,7 @@ const InputComponent = forwardRef<RuleType, InputProps>(({
|
|
|
198
203
|
) : null}
|
|
199
204
|
</div>
|
|
200
205
|
);
|
|
201
|
-
}
|
|
206
|
+
};
|
|
202
207
|
|
|
203
208
|
InputComponent.displayName = 'Input';
|
|
204
209
|
|
package/lib/types/input.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ReactNode,
|
|
10
10
|
TextareaHTMLAttributes
|
|
11
11
|
} from 'react';
|
|
12
|
-
import { DefaultProps, SizeType, SyntheticBaseEvent } from '.';
|
|
12
|
+
import { DefaultProps, RuleType, SizeType, SyntheticBaseEvent } from '.';
|
|
13
13
|
|
|
14
14
|
export type InputProps = Omit<
|
|
15
15
|
InputHTMLAttributes<HTMLInputElement>,
|
|
@@ -38,6 +38,7 @@ export type InputProps = Omit<
|
|
|
38
38
|
mask?: string;
|
|
39
39
|
maskChar?: string;
|
|
40
40
|
maskRegex?: RegExp;
|
|
41
|
+
ref?: RuleType;
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
export type TextareaProps = Omit<
|