@npm_leadtech/legal-lib-components 7.106.17 → 7.106.32
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/css/styles.css +0 -3
- package/dist/src/components/atoms/Button/Button.js +6 -19
- package/dist/src/components/atoms/Button/Button.scss +0 -4
- package/dist/src/components/atoms/Button/Button.tsx +13 -59
- package/dist/src/components/atoms/Button/ButtonProps.types.d.ts +0 -1
- package/dist/src/components/atoms/Button/ButtonProps.types.ts +0 -1
- package/dist/src/components/atoms/Spinner/Spinner.js +1 -1
- package/dist/src/components/atoms/Spinner/Spinner.tsx +2 -9
- package/dist/src/components/molecules/TextInput/Input.d.ts +2 -0
- package/dist/src/components/molecules/TextInput/Input.js +2 -2
- package/dist/src/components/molecules/TextInput/Input.tsx +5 -1
- package/dist/src/components/molecules/TextInput/TextInput.js +3 -3
- package/dist/src/components/molecules/TextInput/TextInput.tsx +4 -1
- package/dist/src/components/molecules/TextInput/TextInputProps.types.d.ts +2 -0
- package/dist/src/components/molecules/TextInput/TextInputProps.types.ts +3 -0
- package/dist/src/components/molecules/TextInput/stories/TextInput.stories.tsx +11 -0
- package/package.json +1 -1
package/dist/css/styles.css
CHANGED
|
@@ -1039,9 +1039,6 @@ html[data-theme=primarygreen] .e-button.--primary-3 {
|
|
|
1039
1039
|
color: var(--neutral-neutral-1);
|
|
1040
1040
|
pointer-events: none;
|
|
1041
1041
|
}
|
|
1042
|
-
.e-button.--processing {
|
|
1043
|
-
pointer-events: none;
|
|
1044
|
-
}
|
|
1045
1042
|
.e-button.--error {
|
|
1046
1043
|
border-color: var(--error-main);
|
|
1047
1044
|
color: var(--error-main);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
|
|
4
|
-
const Button = ({ label, dataQa, labelMobile, link, LinkComponent = null, noLink = false, noLinkNoFunc = false, onClick = undefined, functionParameters, color = 'primary', error, disabled = false, isProcessing = false, fluid, givenClass, children, size = undefined, isExternal = false, centered = false, gtmTag = undefined, hasNoFollow = false, target = '_self' }) => {
|
|
3
|
+
const Button = ({ label, dataQa, labelMobile, link, LinkComponent = null, noLink = false, noLinkNoFunc = false, onClick = undefined, functionParameters, color = 'primary', error, disabled = false, fluid, givenClass, children, size = undefined, isExternal = false, centered = false, gtmTag = undefined, hasNoFollow = false, target = '_self' }) => {
|
|
5
4
|
const sizes = {
|
|
6
5
|
S: 'button--small',
|
|
7
6
|
M: 'button--medium'
|
|
@@ -25,14 +24,11 @@ const Button = ({ label, dataQa, labelMobile, link, LinkComponent = null, noLink
|
|
|
25
24
|
'--styleless': color === 'styleless',
|
|
26
25
|
'--transparent': color === 'transparent',
|
|
27
26
|
'--disabled': disabled,
|
|
28
|
-
'--processing': isProcessing,
|
|
29
27
|
'button--center': centered,
|
|
30
28
|
'--error': error,
|
|
31
29
|
'e-button--fluid': fluid
|
|
32
30
|
});
|
|
33
31
|
const onButtonClick = () => {
|
|
34
|
-
if (isProcessing)
|
|
35
|
-
return;
|
|
36
32
|
if (onClick !== undefined)
|
|
37
33
|
onClick(functionParameters);
|
|
38
34
|
if (gtmTag !== undefined) {
|
|
@@ -44,25 +40,16 @@ const Button = ({ label, dataQa, labelMobile, link, LinkComponent = null, noLink
|
|
|
44
40
|
});
|
|
45
41
|
}
|
|
46
42
|
};
|
|
47
|
-
const
|
|
48
|
-
if (isProcessing) {
|
|
49
|
-
event?.preventDefault();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
onButtonClick();
|
|
53
|
-
};
|
|
54
|
-
const ariaProcessing = isProcessing || undefined;
|
|
55
|
-
const labelContent = labelMobile !== undefined ? (_jsxs(_Fragment, { children: [_jsx("label", { className: 'e-button-labelMobile', children: labelMobile }), _jsx("label", { className: 'e-button-labelDesktop', children: label })] })) : (_jsx("label", { children: label }));
|
|
56
|
-
const buttonContent = (_jsxs(_Fragment, { children: [isProcessing ? _jsx(Spinner, {}) : null, children && label === '' ? (children) : (_jsxs(_Fragment, { children: [children ?? null, labelContent] }))] }));
|
|
43
|
+
const buttonContent = (_jsxs(_Fragment, { children: [children ?? null, labelMobile !== undefined ? (_jsxs(_Fragment, { children: [_jsx("label", { className: 'e-button-labelMobile', children: labelMobile }), _jsx("label", { className: 'e-button-labelDesktop', children: label })] })) : (_jsx("label", { children: label }))] }));
|
|
57
44
|
if (isExternal || (!LinkComponent && link)) {
|
|
58
|
-
return (_jsx("a", { className: `e-button ${classnames}`, href: link ?? '', onClick:
|
|
45
|
+
return (_jsx("a", { className: `e-button ${classnames}`, href: link ?? '', onClick: onButtonClick, "data-qa": dataQa, rel: hasNoFollow ? 'nofollow' : '', target: target, children: children && label === '' ? children : buttonContent }));
|
|
59
46
|
}
|
|
60
47
|
if (noLink) {
|
|
61
|
-
return (_jsx("button", { className: `e-button --noLink ${classnames}`, "data-qa": dataQa, onClick: onButtonClick,
|
|
48
|
+
return (_jsx("button", { className: `e-button --noLink ${classnames}`, "data-qa": dataQa, onClick: onButtonClick, children: children && label === '' ? children : buttonContent }));
|
|
62
49
|
}
|
|
63
50
|
if (noLinkNoFunc) {
|
|
64
|
-
return (_jsx("button", { className: `e-button --noLinkNoFunc ${classnames}`, "data-qa": dataQa,
|
|
51
|
+
return (_jsx("button", { className: `e-button --noLinkNoFunc ${classnames}`, "data-qa": dataQa, children: children && label === '' ? children : buttonContent }));
|
|
65
52
|
}
|
|
66
|
-
return (_jsx(LinkComponent, { className: `e-button ${classnames}`, to: link ?? '', onClick:
|
|
53
|
+
return (_jsx(LinkComponent, { className: `e-button ${classnames}`, to: link ?? '', onClick: onButtonClick, "data-qa": dataQa, children: buttonContent }));
|
|
67
54
|
};
|
|
68
55
|
export default Button;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import React, { type FC } from 'react'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { Spinner } from '../Spinner'
|
|
6
5
|
import { type ButtonProps } from './ButtonProps.types'
|
|
7
6
|
|
|
8
7
|
const Button: FC<ButtonProps> = ({
|
|
@@ -18,7 +17,6 @@ const Button: FC<ButtonProps> = ({
|
|
|
18
17
|
color = 'primary',
|
|
19
18
|
error,
|
|
20
19
|
disabled = false,
|
|
21
|
-
isProcessing = false,
|
|
22
20
|
fluid,
|
|
23
21
|
givenClass,
|
|
24
22
|
children,
|
|
@@ -54,14 +52,12 @@ const Button: FC<ButtonProps> = ({
|
|
|
54
52
|
'--styleless': color === 'styleless',
|
|
55
53
|
'--transparent': color === 'transparent',
|
|
56
54
|
'--disabled': disabled,
|
|
57
|
-
'--processing': isProcessing,
|
|
58
55
|
'button--center': centered,
|
|
59
56
|
'--error': error,
|
|
60
57
|
'e-button--fluid': fluid
|
|
61
58
|
})
|
|
62
59
|
|
|
63
60
|
const onButtonClick = (): void => {
|
|
64
|
-
if (isProcessing) return
|
|
65
61
|
if (onClick !== undefined) onClick(functionParameters)
|
|
66
62
|
if (gtmTag !== undefined) {
|
|
67
63
|
if (typeof window !== 'undefined') {
|
|
@@ -73,36 +69,16 @@ const Button: FC<ButtonProps> = ({
|
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
const onAnchorClick = (event?: React.MouseEvent<HTMLAnchorElement>): void => {
|
|
77
|
-
if (isProcessing) {
|
|
78
|
-
event?.preventDefault()
|
|
79
|
-
return
|
|
80
|
-
}
|
|
81
|
-
onButtonClick()
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const ariaProcessing = isProcessing || undefined
|
|
85
|
-
|
|
86
|
-
const labelContent =
|
|
87
|
-
labelMobile !== undefined ? (
|
|
88
|
-
<>
|
|
89
|
-
<label className='e-button-labelMobile'>{labelMobile}</label>
|
|
90
|
-
<label className='e-button-labelDesktop'>{label}</label>
|
|
91
|
-
</>
|
|
92
|
-
) : (
|
|
93
|
-
<label>{label}</label>
|
|
94
|
-
)
|
|
95
|
-
|
|
96
72
|
const buttonContent = (
|
|
97
73
|
<>
|
|
98
|
-
{
|
|
99
|
-
{
|
|
100
|
-
children
|
|
101
|
-
) : (
|
|
74
|
+
{children ?? null}
|
|
75
|
+
{labelMobile !== undefined ? (
|
|
102
76
|
<>
|
|
103
|
-
{
|
|
104
|
-
{
|
|
77
|
+
<label className='e-button-labelMobile'>{labelMobile}</label>
|
|
78
|
+
<label className='e-button-labelDesktop'>{label}</label>
|
|
105
79
|
</>
|
|
80
|
+
) : (
|
|
81
|
+
<label>{label}</label>
|
|
106
82
|
)}
|
|
107
83
|
</>
|
|
108
84
|
)
|
|
@@ -112,56 +88,34 @@ const Button: FC<ButtonProps> = ({
|
|
|
112
88
|
<a
|
|
113
89
|
className={`e-button ${classnames}`}
|
|
114
90
|
href={link ?? ''}
|
|
115
|
-
onClick={
|
|
91
|
+
onClick={onButtonClick}
|
|
116
92
|
data-qa={dataQa}
|
|
117
93
|
rel={hasNoFollow ? 'nofollow' : ''}
|
|
118
94
|
target={target}
|
|
119
|
-
tabIndex={isProcessing ? -1 : undefined}
|
|
120
|
-
aria-busy={ariaProcessing}
|
|
121
|
-
aria-disabled={ariaProcessing}
|
|
122
95
|
>
|
|
123
|
-
{buttonContent}
|
|
96
|
+
{children && label === '' ? children : buttonContent}
|
|
124
97
|
</a>
|
|
125
98
|
)
|
|
126
99
|
}
|
|
127
100
|
|
|
128
101
|
if (noLink) {
|
|
129
102
|
return (
|
|
130
|
-
<button
|
|
131
|
-
|
|
132
|
-
data-qa={dataQa}
|
|
133
|
-
onClick={onButtonClick}
|
|
134
|
-
disabled={isProcessing}
|
|
135
|
-
aria-busy={ariaProcessing}
|
|
136
|
-
>
|
|
137
|
-
{buttonContent}
|
|
103
|
+
<button className={`e-button --noLink ${classnames}`} data-qa={dataQa} onClick={onButtonClick}>
|
|
104
|
+
{children && label === '' ? children : buttonContent}
|
|
138
105
|
</button>
|
|
139
106
|
)
|
|
140
107
|
}
|
|
141
108
|
|
|
142
109
|
if (noLinkNoFunc) {
|
|
143
110
|
return (
|
|
144
|
-
<button
|
|
145
|
-
|
|
146
|
-
data-qa={dataQa}
|
|
147
|
-
disabled={isProcessing}
|
|
148
|
-
aria-busy={ariaProcessing}
|
|
149
|
-
>
|
|
150
|
-
{buttonContent}
|
|
111
|
+
<button className={`e-button --noLinkNoFunc ${classnames}`} data-qa={dataQa}>
|
|
112
|
+
{children && label === '' ? children : buttonContent}
|
|
151
113
|
</button>
|
|
152
114
|
)
|
|
153
115
|
}
|
|
154
116
|
|
|
155
117
|
return (
|
|
156
|
-
<LinkComponent
|
|
157
|
-
className={`e-button ${classnames}`}
|
|
158
|
-
to={link ?? ''}
|
|
159
|
-
onClick={onAnchorClick}
|
|
160
|
-
data-qa={dataQa}
|
|
161
|
-
tabIndex={isProcessing ? -1 : undefined}
|
|
162
|
-
aria-busy={ariaProcessing}
|
|
163
|
-
aria-disabled={ariaProcessing}
|
|
164
|
-
>
|
|
118
|
+
<LinkComponent className={`e-button ${classnames}`} to={link ?? ''} onClick={onButtonClick} data-qa={dataQa}>
|
|
165
119
|
{buttonContent}
|
|
166
120
|
</LinkComponent>
|
|
167
121
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { SpinnerStyled } from './Spinner.styled';
|
|
3
3
|
const Spinner = ({ className = '', big = false }) => {
|
|
4
|
-
return !big ? (_jsx(SpinnerStyled, { className: `e-spinner ${className}`, width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none',
|
|
4
|
+
return !big ? (_jsx(SpinnerStyled, { className: `e-spinner ${className}`, width: '24', height: '24', viewBox: '0 0 24 24', fill: 'none', children: _jsx("path", { d: 'M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 11.3864 2.49746 10.8889 3.11111 10.8889C3.72476 10.8889 4.22222 11.3864 4.22222 12C4.22222 16.2955 7.70445 19.7778 12 19.7778C16.2955 19.7778 19.7778 16.2955 19.7778 12C19.7778 7.70445 16.2955 4.22222 12 4.22222C11.3864 4.22222 10.8889 3.72476 10.8889 3.11111C10.8889 2.49746 11.3864 2 12 2Z', fill: '#6D7275' }) })) : (_jsx(SpinnerStyled, { className: `e-spinner big ${className}`, viewBox: '0 0 24 24', fill: 'none', children: _jsx("path", { d: 'M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 11.3864 2.49746 10.8889 3.11111 10.8889C3.72476 10.8889 4.22222 11.3864 4.22222 12C4.22222 16.2955 7.70445 19.7778 12 19.7778C16.2955 19.7778 19.7778 16.2955 19.7778 12C19.7778 7.70445 16.2955 4.22222 12 4.22222C11.3864 4.22222 10.8889 3.72476 10.8889 3.11111C10.8889 2.49746 11.3864 2 12 2Z', fill: '#6D7275' }) }));
|
|
5
5
|
};
|
|
6
6
|
export default Spinner;
|
|
@@ -5,21 +5,14 @@ import { SpinnerStyled } from './Spinner.styled'
|
|
|
5
5
|
|
|
6
6
|
const Spinner: FC<SpinnerProps> = ({ className = '', big = false }) => {
|
|
7
7
|
return !big ? (
|
|
8
|
-
<SpinnerStyled
|
|
9
|
-
className={`e-spinner ${className}`}
|
|
10
|
-
width='24'
|
|
11
|
-
height='24'
|
|
12
|
-
viewBox='0 0 24 24'
|
|
13
|
-
fill='none'
|
|
14
|
-
aria-hidden='true'
|
|
15
|
-
>
|
|
8
|
+
<SpinnerStyled className={`e-spinner ${className}`} width='24' height='24' viewBox='0 0 24 24' fill='none'>
|
|
16
9
|
<path
|
|
17
10
|
d='M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 11.3864 2.49746 10.8889 3.11111 10.8889C3.72476 10.8889 4.22222 11.3864 4.22222 12C4.22222 16.2955 7.70445 19.7778 12 19.7778C16.2955 19.7778 19.7778 16.2955 19.7778 12C19.7778 7.70445 16.2955 4.22222 12 4.22222C11.3864 4.22222 10.8889 3.72476 10.8889 3.11111C10.8889 2.49746 11.3864 2 12 2Z'
|
|
18
11
|
fill='#6D7275'
|
|
19
12
|
/>
|
|
20
13
|
</SpinnerStyled>
|
|
21
14
|
) : (
|
|
22
|
-
<SpinnerStyled className={`e-spinner big ${className}`} viewBox='0 0 24 24' fill='none'
|
|
15
|
+
<SpinnerStyled className={`e-spinner big ${className}`} viewBox='0 0 24 24' fill='none'>
|
|
23
16
|
<path
|
|
24
17
|
d='M12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 11.3864 2.49746 10.8889 3.11111 10.8889C3.72476 10.8889 4.22222 11.3864 4.22222 12C4.22222 16.2955 7.70445 19.7778 12 19.7778C16.2955 19.7778 19.7778 16.2955 19.7778 12C19.7778 7.70445 16.2955 4.22222 12 4.22222C11.3864 4.22222 10.8889 3.72476 10.8889 3.11111C10.8889 2.49746 11.3864 2 12 2Z'
|
|
25
18
|
fill='#6D7275'
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type EnterKeyHint } from './TextInputProps.types';
|
|
2
3
|
interface InputProps {
|
|
3
4
|
name: string;
|
|
4
5
|
placeholder: string;
|
|
@@ -15,6 +16,7 @@ interface InputProps {
|
|
|
15
16
|
onKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
16
17
|
country: string;
|
|
17
18
|
currencySymbol?: string;
|
|
19
|
+
enterKeyHint?: EnterKeyHint;
|
|
18
20
|
}
|
|
19
21
|
export declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
20
22
|
export {};
|
|
@@ -3,7 +3,7 @@ import React, { useState } from 'react';
|
|
|
3
3
|
import eyeCloseIcon from '../../../../images/svg/eye-close.svg';
|
|
4
4
|
import eyeIcon from '../../../../images/svg/eye-24-px.svg';
|
|
5
5
|
import percent from '../../../../images/svg/percent.svg';
|
|
6
|
-
export const Input = React.forwardRef(({ value, name, placeholder, className, onChange, onClick, onBlur, onKeyDown, onKeyUp, disabled, type = 'text', maxLength, country, prefix, currencySymbol }, ref) => {
|
|
6
|
+
export const Input = React.forwardRef(({ value, name, placeholder, className, onChange, onClick, onBlur, onKeyDown, onKeyUp, disabled, type = 'text', maxLength, country, prefix, currencySymbol, enterKeyHint }, ref) => {
|
|
7
7
|
const isShortInput = Boolean(maxLength && maxLength <= 5);
|
|
8
8
|
const [hidden, setHidden] = useState(true);
|
|
9
9
|
const showPassword = () => {
|
|
@@ -24,7 +24,7 @@ export const Input = React.forwardRef(({ value, name, placeholder, className, on
|
|
|
24
24
|
else if (isPercent) {
|
|
25
25
|
finalClassName += ' has-percent-suffix';
|
|
26
26
|
}
|
|
27
|
-
return (_jsxs(_Fragment, { children: [isCurrency && !!prefix && otherCurrency && currencySymbol && (_jsx("div", { className: 'input-icon-currency-prefix', children: _jsx("span", { children: currencySymbol }) })), _jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: `${finalClassName} ${isShortInput ? 'e-text-input__short' : ''}`, 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("button", { type: 'button', className: 'input-icon-password-button', onClick: showPassword, onKeyDown: (e) => {
|
|
27
|
+
return (_jsxs(_Fragment, { children: [isCurrency && !!prefix && otherCurrency && currencySymbol && (_jsx("div", { className: 'input-icon-currency-prefix', children: _jsx("span", { children: currencySymbol }) })), _jsx("input", { type: !hidden && type === 'password' ? 'text' : type, name: name, id: name, className: `${finalClassName} ${isShortInput ? 'e-text-input__short' : ''}`, maxLength: maxLength, placeholder: placeholder, onChange: onChange, onClick: onClick, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onBlur: onBlur, value: value, "data-qa": name, disabled: disabled, enterKeyHint: enterKeyHint, ref: ref }), type === 'password' && (_jsx("button", { type: 'button', className: 'input-icon-password-button', onClick: showPassword, onKeyDown: (e) => {
|
|
28
28
|
if (e.key === 'Enter')
|
|
29
29
|
showPassword();
|
|
30
30
|
}, children: _jsx("img", { src: hidden ? eyeIcon : eyeCloseIcon, alt: '' }) })), isCurrency
|
|
@@ -3,6 +3,7 @@ import React, { useState } from 'react'
|
|
|
3
3
|
import eyeCloseIcon from '../../../../images/svg/eye-close.svg'
|
|
4
4
|
import eyeIcon from '../../../../images/svg/eye-24-px.svg'
|
|
5
5
|
import percent from '../../../../images/svg/percent.svg'
|
|
6
|
+
import { type EnterKeyHint } from './TextInputProps.types'
|
|
6
7
|
|
|
7
8
|
interface InputProps {
|
|
8
9
|
name: string
|
|
@@ -20,6 +21,7 @@ interface InputProps {
|
|
|
20
21
|
onKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void
|
|
21
22
|
country: string
|
|
22
23
|
currencySymbol?: string
|
|
24
|
+
enterKeyHint?: EnterKeyHint
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
@@ -39,7 +41,8 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
39
41
|
maxLength,
|
|
40
42
|
country,
|
|
41
43
|
prefix,
|
|
42
|
-
currencySymbol
|
|
44
|
+
currencySymbol,
|
|
45
|
+
enterKeyHint
|
|
43
46
|
}: InputProps,
|
|
44
47
|
ref
|
|
45
48
|
) => {
|
|
@@ -87,6 +90,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
87
90
|
value={value}
|
|
88
91
|
data-qa={name}
|
|
89
92
|
disabled={disabled}
|
|
93
|
+
enterKeyHint={enterKeyHint}
|
|
90
94
|
ref={ref}
|
|
91
95
|
/>
|
|
92
96
|
{type === 'password' && (
|
|
@@ -6,7 +6,7 @@ import { Input } from './Input';
|
|
|
6
6
|
import { TextInputLabel } from './TextInputLabel';
|
|
7
7
|
import { TextInputMessage } from './TextInputMessage';
|
|
8
8
|
import { TextInputTooltip } from './TextInputTooltip';
|
|
9
|
-
const TextInput = React.forwardRef(({ label, value, validate = true, isValidGroup = true, format = undefined, name, placeholder, onChange, onClick, onBlur, onKeyDown, onKeyUp, prefix = '', disabled, type = 'text', maxLength, errorMessage = '', notes, dialogMenuTip, tooltip = '', givenClass = '', children, country, currencySymbol }, ref) => {
|
|
9
|
+
const TextInput = React.forwardRef(({ label, value, validate = true, isValidGroup = true, format = undefined, name, placeholder, onChange, onClick, onBlur, onKeyDown, onKeyUp, prefix = '', disabled, type = 'text', maxLength, errorMessage = '', notes, dialogMenuTip, tooltip = '', givenClass = '', children, country, currencySymbol, enterKeyHint }, ref) => {
|
|
10
10
|
const classnames = classNames('e-text', {
|
|
11
11
|
[givenClass]: givenClass,
|
|
12
12
|
'e-text--is-invalid': !validate,
|
|
@@ -24,9 +24,9 @@ const TextInput = React.forwardRef(({ label, value, validate = true, isValidGrou
|
|
|
24
24
|
};
|
|
25
25
|
const renderInput = () => {
|
|
26
26
|
if (Boolean(format) && type !== 'number' && type !== 'tel') {
|
|
27
|
-
return (_jsx(NumericFormat, { name: name, id: name, placeholder: placeholder, className: 'e-text-input', onChange: onChange, onClick: onClick, value: value, "data-qa": name, disabled: disabled, maxLength: maxLength, onBlur: onBlur }));
|
|
27
|
+
return (_jsx(NumericFormat, { name: name, id: name, placeholder: placeholder, className: 'e-text-input', onChange: onChange, onClick: onClick, value: value, "data-qa": name, disabled: disabled, maxLength: maxLength, onBlur: onBlur, enterKeyHint: enterKeyHint }));
|
|
28
28
|
}
|
|
29
|
-
return (_jsx(Input, { name: name ?? '', type: type, prefix: prefix, placeholder: placeholder ?? '', className: 'e-text-input', onChange: handleChange, onClick: onClick ?? (() => { }), value: value, "data-qa": name, disabled: disabled ?? false, maxLength: maxLength, onBlur: onBlur ?? (() => { }), ref: ref, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, country: country, currencySymbol: currencySymbol }));
|
|
29
|
+
return (_jsx(Input, { name: name ?? '', type: type, prefix: prefix, placeholder: placeholder ?? '', className: 'e-text-input', onChange: handleChange, onClick: onClick ?? (() => { }), value: value, "data-qa": name, disabled: disabled ?? false, maxLength: maxLength, onBlur: onBlur ?? (() => { }), ref: ref, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, country: country, currencySymbol: currencySymbol, enterKeyHint: enterKeyHint }));
|
|
30
30
|
};
|
|
31
31
|
return (_jsxs("div", { className: classnames, children: [Boolean(children) && _jsx("div", { className: 'e-text__children', children: children }), _jsx(TextInputTooltip, { tooltip: tooltip }), _jsx(TextInputMessage, { errorMessage: errorMessage, validate: validate }), renderInput(), _jsx(TextInputLabel, { label: label, htmlFor: name, notes: notes, dialogMenuTip: dialogMenuTip })] }));
|
|
32
32
|
});
|
|
@@ -34,7 +34,8 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
|
|
|
34
34
|
givenClass = '',
|
|
35
35
|
children,
|
|
36
36
|
country,
|
|
37
|
-
currencySymbol
|
|
37
|
+
currencySymbol,
|
|
38
|
+
enterKeyHint
|
|
38
39
|
}: TextInputProps,
|
|
39
40
|
ref
|
|
40
41
|
) => {
|
|
@@ -72,6 +73,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
|
|
|
72
73
|
disabled={disabled}
|
|
73
74
|
maxLength={maxLength}
|
|
74
75
|
onBlur={onBlur}
|
|
76
|
+
enterKeyHint={enterKeyHint}
|
|
75
77
|
/>
|
|
76
78
|
)
|
|
77
79
|
}
|
|
@@ -95,6 +97,7 @@ const TextInput = React.forwardRef<HTMLInputElement, TextInputProps>(
|
|
|
95
97
|
onKeyUp={handleKeyUp}
|
|
96
98
|
country={country}
|
|
97
99
|
currencySymbol={currencySymbol}
|
|
100
|
+
enterKeyHint={enterKeyHint}
|
|
98
101
|
/>
|
|
99
102
|
)
|
|
100
103
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type EnterKeyHint = 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
|
1
2
|
export interface TextInputProps {
|
|
2
3
|
label?: string;
|
|
3
4
|
name?: string;
|
|
@@ -24,4 +25,5 @@ export interface TextInputProps {
|
|
|
24
25
|
children?: React.ReactNode;
|
|
25
26
|
country: string;
|
|
26
27
|
currencySymbol?: string;
|
|
28
|
+
enterKeyHint?: EnterKeyHint;
|
|
27
29
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
export type EnterKeyHint = 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'
|
|
3
|
+
|
|
2
4
|
export interface TextInputProps {
|
|
3
5
|
label?: string
|
|
4
6
|
name?: string
|
|
@@ -25,4 +27,5 @@ export interface TextInputProps {
|
|
|
25
27
|
children?: React.ReactNode
|
|
26
28
|
country: string
|
|
27
29
|
currencySymbol?: string
|
|
30
|
+
enterKeyHint?: EnterKeyHint
|
|
28
31
|
}
|
|
@@ -189,3 +189,14 @@ export const SmallMaxLength: Story = {
|
|
|
189
189
|
maxLength: 5
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
+
|
|
193
|
+
export const WithEnterKeyHint: Story = {
|
|
194
|
+
args: {
|
|
195
|
+
value: '',
|
|
196
|
+
name: 'first_name',
|
|
197
|
+
placeholder: 'First name',
|
|
198
|
+
label: 'First name',
|
|
199
|
+
type: 'text',
|
|
200
|
+
enterKeyHint: 'next'
|
|
201
|
+
}
|
|
202
|
+
}
|