@npm_leadtech/legal-lib-components 5.43.4 → 5.43.6

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.
@@ -3,7 +3,7 @@ interface InputProps {
3
3
  name: string;
4
4
  placeholder: string;
5
5
  maxLength: number;
6
- value: any;
6
+ value: string;
7
7
  type: 'password' | 'text' | 'number' | 'tel';
8
8
  disabled: boolean;
9
9
  className: string;
@@ -1,8 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
4
- /* eslint-disable jsx-a11y/click-events-have-key-events */
5
- import React, { useState } from 'react';
2
+ import React, { useCallback, useState } from 'react';
6
3
  import eyeCloseIcon from '../../../../images/svg/eye-close.svg';
7
4
  import eyeIcon from '../../../../images/svg/eye-24-px.svg';
8
5
  export const Input = React.forwardRef(({ value, name, placeholder, className, onChange, onClick, onBlur, onKeyDown, onKeyUp, disabled, type = 'text', maxLength }, ref) => {
@@ -12,10 +9,13 @@ export const Input = React.forwardRef(({ value, name, placeholder, className, on
12
9
  if (value !== null)
13
10
  setHidden(!hidden);
14
11
  };
15
- const handleChange = (event) => {
12
+ const handleChange = useCallback((event) => {
16
13
  setCurrentValue(event.target.value);
17
14
  onChange(event);
18
- };
19
- return (_jsxs(_Fragment, { children: [_jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: className, maxLength: maxLength, placeholder: placeholder, onChange: handleChange, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onBlur: onBlur, value: currentValue, "data-qa": name, disabled: disabled, ref: ref }), type === 'password' && (_jsx("img", { className: 'input-icon-password', src: hidden ? eyeIcon : eyeCloseIcon, onClick: showPassword, alt: '' }))] }));
15
+ }, [currentValue]);
16
+ return (_jsxs(_Fragment, { children: [_jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: className, maxLength: maxLength, placeholder: placeholder, onChange: handleChange, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onBlur: onBlur, value: currentValue, "data-qa": name, disabled: disabled, ref: ref }), type === 'password' && (_jsx("button", { className: 'input-icon-password', onClick: showPassword, onKeyDown: (e) => {
17
+ if (e.key === 'Enter')
18
+ showPassword();
19
+ }, children: _jsx("img", { src: hidden ? eyeIcon : eyeCloseIcon, alt: '' }) }))] }));
20
20
  });
21
21
  Input.displayName = 'Input';
@@ -1,8 +1,4 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
-
3
- /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
4
- /* eslint-disable jsx-a11y/click-events-have-key-events */
5
- import React, { useState } from 'react'
1
+ import React, { useCallback, useState } from 'react'
6
2
 
7
3
  import eyeCloseIcon from '../../../../images/svg/eye-close.svg'
8
4
  import eyeIcon from '../../../../images/svg/eye-24-px.svg'
@@ -11,7 +7,7 @@ interface InputProps {
11
7
  name: string
12
8
  placeholder: string
13
9
  maxLength: number
14
- value: any
10
+ value: string
15
11
  type: 'password' | 'text' | 'number' | 'tel'
16
12
  disabled: boolean
17
13
  className: string
@@ -43,14 +39,17 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
43
39
  const [currentValue, setCurrentValue] = useState(value)
44
40
  const [hidden, setHidden] = useState(true)
45
41
 
46
- const showPassword = (): any => {
42
+ const showPassword = (): void => {
47
43
  if (value !== null) setHidden(!hidden)
48
44
  }
49
45
 
50
- const handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
51
- setCurrentValue(event.target.value)
52
- onChange(event)
53
- }
46
+ const handleChange = useCallback(
47
+ (event: React.ChangeEvent<HTMLInputElement>) => {
48
+ setCurrentValue(event.target.value)
49
+ onChange(event)
50
+ },
51
+ [currentValue]
52
+ )
54
53
 
55
54
  return (
56
55
  <>
@@ -72,7 +71,15 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
72
71
  ref={ref}
73
72
  />
74
73
  {type === 'password' && (
75
- <img className='input-icon-password' src={hidden ? eyeIcon : eyeCloseIcon} onClick={showPassword} alt='' />
74
+ <button
75
+ className='input-icon-password'
76
+ onClick={showPassword}
77
+ onKeyDown={(e) => {
78
+ if (e.key === 'Enter') showPassword()
79
+ }}
80
+ >
81
+ <img src={hidden ? eyeIcon : eyeCloseIcon} alt='' />
82
+ </button>
76
83
  )}
77
84
  </>
78
85
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npm_leadtech/legal-lib-components",
3
- "version": "5.43.4",
3
+ "version": "5.43.6",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",