@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.
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moda/om",
3
- "version": "21.9.0",
3
+ "version": "21.11.0",
4
4
  "description": "Moda Operandi design system",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
@@ -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
- <ReactOtpInput
63
- containerStyle={classNames('OtpInput', className)}
64
- inputType={inputType}
65
- numInputs={numInputs}
66
- onChange={onChange}
67
- onPaste={onPaste}
68
- placeholder={placeholder}
69
- renderSeparator={renderSeparator}
70
- shouldAutoFocus={shouldAutoFocus}
71
- skipDefaultStyles
72
- value={value}
73
- renderInput={(inputProps: ReactOtpInputInputProps, index: number) => (
74
- <input
75
- {...inputProps}
76
- id={id ? `${id}-${index + 1}` : undefined}
77
- autoComplete={autoComplete}
78
- aria-describedby={ariaDescribedBy}
79
- aria-invalid={error ? true : undefined}
80
- aria-label={getInputAriaLabel(index, numInputs, ariaLabel, label)}
81
- className={classNames(inputProps.className, 'OtpInput__input', inputClassName, {
82
- 'OtpInput__input--disabled': disabled,
83
- 'OtpInput__input--error': error,
84
- 'OtpInput__input--focus': focus
85
- })}
86
- disabled={disabled}
87
- name={name}
88
- required={required}
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