x-ui-design 1.0.25 → 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.
@@ -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,7 +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
- const InputComponent = ({
21
+ const InputComponent = forwardRef<RuleType, InputProps>(({
21
22
  size = 'large',
22
23
  error,
23
24
  suffix,
@@ -37,17 +38,13 @@ const InputComponent = ({
37
38
  mask,
38
39
  maskChar = MASK_CHAR,
39
40
  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
45
44
  defaultValue,
46
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
45
  child,
48
- ref,
49
46
  ...props
50
- }: InputProps) => {
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 ?? '';
@@ -61,9 +58,7 @@ const InputComponent = ({
61
58
  input: inputRef.current,
62
59
  nativeElement: inputRef.current,
63
60
  setSelectionRange: (start: number, end: number) => {
64
- if (inputRef.current) {
65
- inputRef.current.setSelectionRange(start, end);
66
- }
61
+ inputRef.current?.setSelectionRange(start, end);
67
62
  }
68
63
  }));
69
64
 
@@ -203,7 +198,7 @@ const InputComponent = ({
203
198
  ) : null}
204
199
  </div>
205
200
  );
206
- };
201
+ });
207
202
 
208
203
  InputComponent.displayName = 'Input';
209
204
 
@@ -9,7 +9,7 @@ import {
9
9
  ReactNode,
10
10
  TextareaHTMLAttributes
11
11
  } from 'react';
12
- import { DefaultProps, RuleType, SizeType, SyntheticBaseEvent } from '.';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x-ui-design",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "license": "ISC",
5
5
  "author": "Gabriel Boyajyan",
6
6
  "main": "dist/index.js",
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
  }, [])