@npm_leadtech/legal-lib-components 5.43.8 → 5.43.10

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.
@@ -2242,12 +2242,13 @@ h2.react-datepicker__current-month {
2242
2242
  right: 0;
2243
2243
  bottom: 0;
2244
2244
  }
2245
- .e-text .input-icon-password {
2245
+ .e-text .input-icon-password-button {
2246
2246
  cursor: pointer;
2247
2247
  position: absolute;
2248
- transform: translate(-40%, -65%);
2249
- right: 0;
2250
- bottom: 0;
2248
+ right: 0px;
2249
+ bottom: 6px;
2250
+ background: none;
2251
+ border: none;
2251
2252
  }
2252
2253
  .e-text .formgroup--input__button {
2253
2254
  align-self: flex-start;
@@ -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,16 +1,21 @@
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) => {
6
+ const [currentValue, setCurrentValue] = useState(value);
9
7
  const [hidden, setHidden] = useState(true);
10
8
  const showPassword = () => {
11
9
  if (value !== null)
12
10
  setHidden(!hidden);
13
11
  };
14
- return (_jsxs(_Fragment, { children: [_jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: className, maxLength: maxLength, placeholder: placeholder, onChange: onChange, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onBlur: onBlur, value: value, "data-qa": name, disabled: disabled, ref: ref }), type === 'password' && (_jsx("img", { className: 'input-icon-password', src: hidden ? eyeIcon : eyeCloseIcon, onClick: showPassword, alt: '' }))] }));
12
+ const handleChange = useCallback((event) => {
13
+ setCurrentValue(event.target.value);
14
+ onChange(event);
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-button', onClick: showPassword, onKeyDown: (e) => {
17
+ if (e.key === 'Enter')
18
+ showPassword();
19
+ }, children: _jsx("img", { src: hidden ? eyeIcon : eyeCloseIcon, alt: '' }) }))] }));
15
20
  });
16
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
@@ -40,12 +36,21 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
40
36
  }: InputProps,
41
37
  ref
42
38
  ) => {
39
+ const [currentValue, setCurrentValue] = useState(value)
43
40
  const [hidden, setHidden] = useState(true)
44
41
 
45
- const showPassword = (): any => {
42
+ const showPassword = (): void => {
46
43
  if (value !== null) setHidden(!hidden)
47
44
  }
48
45
 
46
+ const handleChange = useCallback(
47
+ (event: React.ChangeEvent<HTMLInputElement>) => {
48
+ setCurrentValue(event.target.value)
49
+ onChange(event)
50
+ },
51
+ [currentValue]
52
+ )
53
+
49
54
  return (
50
55
  <>
51
56
  <input
@@ -55,18 +60,26 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
55
60
  className={className}
56
61
  maxLength={maxLength}
57
62
  placeholder={placeholder}
58
- onChange={onChange}
63
+ onChange={handleChange}
59
64
  onClick={onClick}
60
65
  onKeyDown={onKeyDown}
61
66
  onKeyUp={onKeyUp}
62
67
  onBlur={onBlur}
63
- value={value}
68
+ value={currentValue}
64
69
  data-qa={name}
65
70
  disabled={disabled}
66
71
  ref={ref}
67
72
  />
68
73
  {type === 'password' && (
69
- <img className='input-icon-password' src={hidden ? eyeIcon : eyeCloseIcon} onClick={showPassword} alt='' />
74
+ <button
75
+ className='input-icon-password-button'
76
+ onClick={showPassword}
77
+ onKeyDown={(e) => {
78
+ if (e.key === 'Enter') showPassword()
79
+ }}
80
+ >
81
+ <img src={hidden ? eyeIcon : eyeCloseIcon} alt='' />
82
+ </button>
70
83
  )}
71
84
  </>
72
85
  )
@@ -155,12 +155,13 @@
155
155
  bottom: 0;
156
156
  }
157
157
 
158
- .input-icon-password {
158
+ .input-icon-password-button {
159
159
  cursor: pointer;
160
160
  position: absolute;
161
- transform: translate(-40%, -65%);
162
- right: 0;
163
- bottom: 0;
161
+ right: 0px;
162
+ bottom: 6px;
163
+ background: none;
164
+ border: none;
164
165
  }
165
166
 
166
167
  .formgroup--input__button {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npm_leadtech/legal-lib-components",
3
- "version": "5.43.8",
3
+ "version": "5.43.10",
4
4
  "license": "ISC",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",