@douglasneuroinformatics/libui 4.7.0 → 4.8.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.
@@ -22,7 +22,7 @@ import * as _radix_ui_react_context_menu from '@radix-ui/react-context-menu';
22
22
  import * as _radix_ui_react_dialog from '@radix-ui/react-dialog';
23
23
  import { Drawer as Drawer$1 } from 'vaul';
24
24
  import { ZodTypeLike, ZodErrorLike } from '@douglasneuroinformatics/libjs';
25
- import { FormDataType, FormContent, PartialNullableFormDataType } from '@douglasneuroinformatics/libui-form-types';
25
+ import { FormDataType, FormContent, PartialNullableFormDataType, PartialFormDataType } from '@douglasneuroinformatics/libui-form-types';
26
26
  import * as _radix_ui_react_hover_card from '@radix-ui/react-hover-card';
27
27
  import * as LabelPrimitive from '@radix-ui/react-label';
28
28
  import { L as Language } from './types-CwW4nA_v.js';
@@ -1348,10 +1348,14 @@ type FormProps<TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema[
1348
1348
  resetBtn?: boolean;
1349
1349
  revalidateOnBlur?: boolean;
1350
1350
  submitBtnLabel?: string;
1351
+ subscribe?: {
1352
+ onChange: (values: PartialFormDataType<TData>, setValues: React.Dispatch<React.SetStateAction<PartialFormDataType<TData>>>) => Promisable<void>;
1353
+ selector: (values: PartialFormDataType<TData>) => unknown;
1354
+ };
1351
1355
  suspendWhileSubmitting?: boolean;
1352
1356
  validationSchema: ZodTypeLike<TData>;
1353
1357
  };
1354
- declare const Form: <TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema["_output"] = TSchema["_output"]>({ additionalButtons, className, content, customStyles, fieldsFooter, id, initialValues, onBeforeSubmit, onError, onSubmit, preventResetValuesOnReset, readOnly, resetBtn, revalidateOnBlur, submitBtnLabel, suspendWhileSubmitting, validationSchema, ...props }: FormProps<TSchema, TData>) => react_jsx_runtime.JSX.Element;
1358
+ declare const Form: <TSchema extends ZodTypeLike<FormDataType>, TData extends TSchema["_output"] = TSchema["_output"]>({ additionalButtons, className, content, customStyles, fieldsFooter, id, initialValues, onBeforeSubmit, onError, onSubmit, preventResetValuesOnReset, readOnly, resetBtn, revalidateOnBlur, submitBtnLabel, subscribe, suspendWhileSubmitting, validationSchema, ...props }: FormProps<TSchema, TData>) => react_jsx_runtime.JSX.Element;
1355
1359
 
1356
1360
  type HeadingProps = {
1357
1361
  children: string;
@@ -3680,6 +3680,7 @@ var Form = ({
3680
3680
  resetBtn,
3681
3681
  revalidateOnBlur,
3682
3682
  submitBtnLabel,
3683
+ subscribe,
3683
3684
  suspendWhileSubmitting,
3684
3685
  validationSchema,
3685
3686
  ...props
@@ -3712,6 +3713,12 @@ var Form = ({
3712
3713
  onError(error);
3713
3714
  }
3714
3715
  };
3716
+ useEffect11(() => {
3717
+ if (!subscribe) {
3718
+ return;
3719
+ }
3720
+ subscribe.onChange(values, setValues);
3721
+ }, [subscribe?.selector(values)]);
3715
3722
  const reset = () => {
3716
3723
  setRootErrors([]);
3717
3724
  setErrors({});