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.
@@ -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<HTMLInputElement | { focus: () => void; blur: () => void; input: HTMLInputElement | null; nativeElement: HTMLInputElement | null; setSelectionRange: (start: number, end: number) => void; }, InputProps>(({
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: () => inputRef.current?.focus(),
58
- blur: () => inputRef.current?.blur(),
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?.setSelectionRange(start, end);
69
+ if (inputRef.current) {
70
+ inputRef.current.setSelectionRange(start, end);
71
+ }
63
72
  }
64
- }), [inputRef]);
73
+ }), [ref]);
65
74
 
66
75
  useEffect(() => {
67
76
  setMaskValue(mask ? applyMask(stripMask(`${value ?? ''}`, mask, maskChar), mask, maskChar).masked : (value ?? ''));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-ui-design",
3
- "version": "1.0.23",
3
+ "version": "1.0.24",
4
4
  "license": "ISC",
5
5
  "author": "Gabriel Boyajyan",
6
6
  "main": "dist/index.js",