@helpwave/hightide 0.6.0 → 0.6.1

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.d.mts CHANGED
@@ -284,10 +284,11 @@ type UseCreateFormResult<T extends FormValue> = {
284
284
  store: FormStore<T>;
285
285
  reset: () => void;
286
286
  submit: () => void;
287
- update: (value: Partial<T>) => void;
287
+ update: (updater: Partial<T> | ((current: T) => Partial<T>)) => void;
288
288
  validateAll: () => void;
289
289
  getDataProps: <K extends keyof T>(key: K) => FormFieldDataHandling<T[K]>;
290
290
  getError: (key: keyof T) => ReactNode;
291
+ getValues: () => T;
291
292
  getValue: <K extends keyof T>(key: K) => T[K];
292
293
  registerRef: (key: keyof T) => (el: HTMLElement | null) => void;
293
294
  };
package/dist/index.d.ts CHANGED
@@ -284,10 +284,11 @@ type UseCreateFormResult<T extends FormValue> = {
284
284
  store: FormStore<T>;
285
285
  reset: () => void;
286
286
  submit: () => void;
287
- update: (value: Partial<T>) => void;
287
+ update: (updater: Partial<T> | ((current: T) => Partial<T>)) => void;
288
288
  validateAll: () => void;
289
289
  getDataProps: <K extends keyof T>(key: K) => FormFieldDataHandling<T[K]>;
290
290
  getError: (key: keyof T) => ReactNode;
291
+ getValues: () => T;
291
292
  getValue: <K extends keyof T>(key: K) => T[K];
292
293
  registerRef: (key: keyof T) => (el: HTMLElement | null) => void;
293
294
  };
package/dist/index.js CHANGED
@@ -7726,15 +7726,25 @@ function useCreateForm({
7726
7726
  }
7727
7727
  };
7728
7728
  }, []);
7729
- return {
7730
- store: storeRef.current,
7729
+ const callbacks = (0, import_react7.useMemo)(() => ({
7731
7730
  reset: () => storeRef.current.reset(),
7732
7731
  submit: () => storeRef.current.submit(),
7733
- update: (value) => storeRef.current.setValues(value),
7732
+ update: (updater) => {
7733
+ if (typeof updater === "function") {
7734
+ storeRef.current.setValues(updater(storeRef.current.getAllValues()));
7735
+ } else {
7736
+ storeRef.current.setValues(updater);
7737
+ }
7738
+ },
7734
7739
  validateAll: () => storeRef.current.validateAll(),
7735
- getDataProps,
7736
7740
  getError: (key) => storeRef.current.getError(key),
7737
- getValue: (key) => storeRef.current.getValue(key),
7741
+ getValues: () => storeRef.current.getAllValues(),
7742
+ getValue: (key) => storeRef.current.getValue(key)
7743
+ }), []);
7744
+ return {
7745
+ store: storeRef.current,
7746
+ ...callbacks,
7747
+ getDataProps,
7738
7748
  registerRef
7739
7749
  };
7740
7750
  }