@moda/om 21.9.0 → 21.11.0
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/index.cjs.js +78 -71
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +78 -71
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Field/Field.d.ts +2 -0
- package/dist/src/components/PasswordInput/PasswordInput.d.ts +1 -0
- package/package.json +1 -1
- package/src/components/Field/Field.tsx +3 -2
- package/src/components/OtpInput/OtpInput.tsx +35 -31
|
@@ -3,7 +3,9 @@ import { TextInputProps } from '../TextInput';
|
|
|
3
3
|
import './Field.scss';
|
|
4
4
|
export type FieldProps = TextInputProps & {
|
|
5
5
|
children?: JSX.Element;
|
|
6
|
+
showErrorIcon?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const Field: React.ForwardRefExoticComponent<import("..").InputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
|
|
8
9
|
children?: JSX.Element;
|
|
10
|
+
showErrorIcon?: boolean;
|
|
9
11
|
} & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -4,4 +4,5 @@ import './PasswordInput.scss';
|
|
|
4
4
|
export type PasswordInputProps = FieldProps;
|
|
5
5
|
export declare const PasswordInput: React.ForwardRefExoticComponent<import("..").InputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange"> & {
|
|
6
6
|
children?: React.JSX.Element;
|
|
7
|
+
showErrorIcon?: boolean;
|
|
7
8
|
} & React.RefAttributes<HTMLInputElement>>;
|
package/package.json
CHANGED
|
@@ -9,11 +9,12 @@ import './Field.scss';
|
|
|
9
9
|
|
|
10
10
|
export type FieldProps = TextInputProps & {
|
|
11
11
|
children?: JSX.Element;
|
|
12
|
+
showErrorIcon?: boolean;
|
|
12
13
|
};
|
|
13
14
|
|
|
14
15
|
export const Field = React.forwardRef(
|
|
15
16
|
(
|
|
16
|
-
{ className, children, error, label, placeholder, ...rest }: FieldProps,
|
|
17
|
+
{ className, children, error, label, placeholder, showErrorIcon = true, ...rest }: FieldProps,
|
|
17
18
|
ref: React.Ref<HTMLInputElement>
|
|
18
19
|
) => {
|
|
19
20
|
const id = useId();
|
|
@@ -44,7 +45,7 @@ export const Field = React.forwardRef(
|
|
|
44
45
|
...children.props
|
|
45
46
|
})}
|
|
46
47
|
|
|
47
|
-
{error && (
|
|
48
|
+
{error && showErrorIcon && (
|
|
48
49
|
<span className='Field__icon'>
|
|
49
50
|
<WarningIcon />
|
|
50
51
|
</span>
|
|
@@ -56,39 +56,43 @@ export const OtpInput: React.FC<OtpInputProps> = ({
|
|
|
56
56
|
renderSeparator,
|
|
57
57
|
required,
|
|
58
58
|
shouldAutoFocus,
|
|
59
|
-
value = ''
|
|
59
|
+
value = '',
|
|
60
|
+
...rest
|
|
60
61
|
}) => {
|
|
61
62
|
return (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
'OtpInput__input
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
63
|
+
<>
|
|
64
|
+
<input type='hidden' name={name} value={value} />
|
|
65
|
+
<ReactOtpInput
|
|
66
|
+
{...rest}
|
|
67
|
+
containerStyle={classNames('OtpInput', className)}
|
|
68
|
+
inputType={inputType}
|
|
69
|
+
numInputs={numInputs}
|
|
70
|
+
onChange={onChange}
|
|
71
|
+
onPaste={onPaste}
|
|
72
|
+
placeholder={placeholder}
|
|
73
|
+
renderSeparator={renderSeparator}
|
|
74
|
+
shouldAutoFocus={shouldAutoFocus}
|
|
75
|
+
skipDefaultStyles
|
|
76
|
+
value={value}
|
|
77
|
+
renderInput={(inputProps: ReactOtpInputInputProps, index: number) => (
|
|
78
|
+
<input
|
|
79
|
+
{...inputProps}
|
|
80
|
+
id={id ? `${id}-${index + 1}` : undefined}
|
|
81
|
+
autoComplete={autoComplete}
|
|
82
|
+
aria-describedby={ariaDescribedBy}
|
|
83
|
+
aria-invalid={error ? true : undefined}
|
|
84
|
+
aria-label={getInputAriaLabel(index, numInputs, ariaLabel, label)}
|
|
85
|
+
className={classNames(inputProps.className, 'OtpInput__input', inputClassName, {
|
|
86
|
+
'OtpInput__input--disabled': disabled,
|
|
87
|
+
'OtpInput__input--error': error,
|
|
88
|
+
'OtpInput__input--focus': focus
|
|
89
|
+
})}
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
required={required}
|
|
92
|
+
/>
|
|
93
|
+
)}
|
|
94
|
+
/>
|
|
95
|
+
</>
|
|
92
96
|
);
|
|
93
97
|
};
|
|
94
98
|
|