@sqrzro/ui 4.0.0-alpha.57 → 4.0.0-alpha.58

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.
@@ -20,7 +20,8 @@ export interface FormFieldProps<T, V extends T> extends ClassNameProps<FormField
20
20
  isOptional?: boolean;
21
21
  label?: React.ReactNode;
22
22
  onChange?: (event: InputEvent<T>) => void;
23
+ onFieldChange?: (event: InputEvent<T>) => void;
23
24
  render: (props: InputProps<T>) => React.ReactElement | null;
24
25
  }
25
- declare function FormField<T, V extends T>({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
26
+ declare function FormField<T, V extends T>({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onFieldChange, onKeyDown, render, value, }: Readonly<FormFieldProps<T, V>>): React.ReactElement | null;
26
27
  export default FormField;
@@ -11,10 +11,14 @@ function checkHasError(error) {
11
11
  Object.keys(error).length > 0 &&
12
12
  Object.values(error).some((item) => typeof item === 'string'));
13
13
  }
14
- function FormField({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onKeyDown, render, value, }) {
14
+ function FormField({ action, classNameProps, classNames, details, error, hasAssistiveError, hasAssistiveDetails, hasAssistiveLabel, id, isContentOnly, isDisabled, isOptional, label, name, onChange, onFieldChange, onKeyDown, render, value, }) {
15
15
  const componentClassNames = useClassNames('formField', { props: classNameProps, states: { isError: checkHasError(error) } }, classNames);
16
16
  const inputId = id || `ff_${name}`;
17
17
  const [inputError, setInputError] = useState(null);
18
+ function handleChange(event) {
19
+ onFieldChange?.(event);
20
+ onChange?.(event);
21
+ }
18
22
  function handleError(message) {
19
23
  setInputError(message);
20
24
  }
@@ -28,7 +32,7 @@ function FormField({ action, classNameProps, classNames, details, error, hasAssi
28
32
  isOptional,
29
33
  label,
30
34
  name,
31
- onChange,
35
+ onChange: handleChange,
32
36
  onError: handleError,
33
37
  onKeyDown,
34
38
  value,
@@ -12,7 +12,7 @@ export interface FieldPropsReturn<Request, K extends keyof Request = keyof Reque
12
12
  isDisabled?: boolean;
13
13
  label?: string;
14
14
  name: string;
15
- onChange: (event: InputEvent<Request[K]>) => void;
15
+ onFieldChange: (event: InputEvent<Request[K]>) => void;
16
16
  value: Request[K];
17
17
  }
18
18
  export interface ToastsArgs {
@@ -173,7 +173,7 @@ function useForm({ defaults = {}, onError, onSubmit, onSuccess, onValidation, re
173
173
  error: getErrorsForField(errors, name),
174
174
  label: getLabel(name, label),
175
175
  name: name,
176
- onChange: handleChange,
176
+ onFieldChange: handleChange,
177
177
  value: data[name],
178
178
  };
179
179
  }
@@ -13,6 +13,7 @@ export function getFieldPropKeys() {
13
13
  'label',
14
14
  'name',
15
15
  'onChange',
16
+ 'onFieldChange',
16
17
  'onKeyDown',
17
18
  'value',
18
19
  ];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sqrzro/ui",
3
3
  "type": "module",
4
- "version": "4.0.0-alpha.57",
4
+ "version": "4.0.0-alpha.58",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "ISC",