@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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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: (
|
|
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: (
|
|
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
|
-
|
|
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: (
|
|
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
|
-
|
|
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
|
}
|