x-ui-design 1.0.24 → 1.0.26
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 +26 -3
- package/dist/esm/types/index.d.ts +24 -1
- package/dist/esm/types/types/input.d.ts +1 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.esm.js +4 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +4 -14
- package/dist/index.js.map +1 -1
- package/lib/components/Input/Input.tsx +6 -16
- package/lib/types/input.ts +1 -2
- package/package.json +1 -1
- package/src/app/page.tsx +1 -6
|
@@ -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<RuleType, InputProps>(({
|
|
22
22
|
size = 'large',
|
|
23
23
|
error,
|
|
24
24
|
suffix,
|
|
@@ -38,16 +38,13 @@ const InputComponent = forwardRef(({
|
|
|
38
38
|
mask,
|
|
39
39
|
maskChar = MASK_CHAR,
|
|
40
40
|
maskRegex = MASK_REGEX,
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
41
|
// @ts-expect-error
|
|
43
42
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
43
|
__injected,
|
|
45
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
44
|
defaultValue,
|
|
47
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
48
45
|
child,
|
|
49
46
|
...props
|
|
50
|
-
}
|
|
47
|
+
}, ref) => {
|
|
51
48
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
52
49
|
const lastKeyPressed = useRef<string | null>(null);
|
|
53
50
|
const internalValue = mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : value ?? '';
|
|
@@ -56,21 +53,14 @@ const InputComponent = forwardRef(({
|
|
|
56
53
|
const animationRef = useRef<number | null>(null);
|
|
57
54
|
|
|
58
55
|
useImperativeHandle(ref, () => ({
|
|
59
|
-
focus: () =>
|
|
60
|
-
|
|
61
|
-
inputRef.current?.focus()
|
|
62
|
-
},
|
|
63
|
-
blur: () => {
|
|
64
|
-
inputRef.current?.blur()
|
|
65
|
-
},
|
|
56
|
+
focus: () => inputRef.current?.focus(),
|
|
57
|
+
blur: () => inputRef.current?.blur(),
|
|
66
58
|
input: inputRef.current,
|
|
67
59
|
nativeElement: inputRef.current,
|
|
68
60
|
setSelectionRange: (start: number, end: number) => {
|
|
69
|
-
|
|
70
|
-
inputRef.current.setSelectionRange(start, end);
|
|
71
|
-
}
|
|
61
|
+
inputRef.current?.setSelectionRange(start, end);
|
|
72
62
|
}
|
|
73
|
-
})
|
|
63
|
+
}));
|
|
74
64
|
|
|
75
65
|
useEffect(() => {
|
|
76
66
|
setMaskValue(mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : (value ?? ''));
|
package/lib/types/input.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
ReactNode,
|
|
10
10
|
TextareaHTMLAttributes
|
|
11
11
|
} from 'react';
|
|
12
|
-
import { DefaultProps,
|
|
12
|
+
import { DefaultProps, SizeType, SyntheticBaseEvent } from '.';
|
|
13
13
|
|
|
14
14
|
export type InputProps = Omit<
|
|
15
15
|
InputHTMLAttributes<HTMLInputElement>,
|
|
@@ -38,7 +38,6 @@ export type InputProps = Omit<
|
|
|
38
38
|
mask?: string;
|
|
39
39
|
maskChar?: string;
|
|
40
40
|
maskRegex?: RegExp;
|
|
41
|
-
ref?: RuleType;
|
|
42
41
|
};
|
|
43
42
|
|
|
44
43
|
export type TextareaProps = Omit<
|
package/package.json
CHANGED
package/src/app/page.tsx
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import { Result } from "../../lib/components/Result";
|
|
4
|
-
import { Button } from '../../lib/components/Button';
|
|
5
|
-
import { Popover } from '../../lib/components/Popover';
|
|
6
|
-
import { Select } from "../../lib/components/Select";
|
|
7
|
-
import Option from "../../lib/components/Select/Option/Option";
|
|
8
3
|
import Input from "../../lib/components/Input/Input";
|
|
9
4
|
import { useEffect, useRef } from "react";
|
|
10
5
|
|
|
@@ -14,7 +9,7 @@ export default function Home() {
|
|
|
14
9
|
useEffect(() => {
|
|
15
10
|
if (ref.current) {
|
|
16
11
|
console.log(ref.current);
|
|
17
|
-
|
|
12
|
+
|
|
18
13
|
ref.current.focus();
|
|
19
14
|
}
|
|
20
15
|
}, [])
|