@npm_leadtech/legal-lib-components 5.43.5 → 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.
- package/dist/src/components/molecules/MidBannerRatafiaSample/MidBannerRatafiaSample.styled.js +1 -1
- package/dist/src/components/molecules/MidBannerRatafiaSample/MidBannerRatafiaSample.styled.ts +1 -1
- package/dist/src/components/molecules/TextInput/Input.d.ts +1 -1
- package/dist/src/components/molecules/TextInput/Input.js +10 -5
- package/dist/src/components/molecules/TextInput/Input.tsx +23 -10
- package/package.json +1 -1
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
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';
|
|
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
|
-
|
|
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', 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
|
-
|
|
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:
|
|
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 = ():
|
|
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={
|
|
63
|
+
onChange={handleChange}
|
|
59
64
|
onClick={onClick}
|
|
60
65
|
onKeyDown={onKeyDown}
|
|
61
66
|
onKeyUp={onKeyUp}
|
|
62
67
|
onBlur={onBlur}
|
|
63
|
-
value={
|
|
68
|
+
value={currentValue}
|
|
64
69
|
data-qa={name}
|
|
65
70
|
disabled={disabled}
|
|
66
71
|
ref={ref}
|
|
67
72
|
/>
|
|
68
73
|
{type === 'password' && (
|
|
69
|
-
<
|
|
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>
|
|
70
83
|
)}
|
|
71
84
|
</>
|
|
72
85
|
)
|