@character-foundry/character-foundry 0.4.3-dev.1766103111 → 0.4.3-dev.1767230557
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/app-framework.cjs
CHANGED
|
@@ -1685,6 +1685,8 @@ function AutoForm({
|
|
|
1685
1685
|
defaultValues,
|
|
1686
1686
|
onChange,
|
|
1687
1687
|
onSubmit,
|
|
1688
|
+
onValidationError,
|
|
1689
|
+
onRawChange,
|
|
1688
1690
|
uiHints = {},
|
|
1689
1691
|
fieldOrder,
|
|
1690
1692
|
disabled = false,
|
|
@@ -1779,15 +1781,22 @@ function AutoForm({
|
|
|
1779
1781
|
}, [values, reset, schemaDefaults, defaultValues]);
|
|
1780
1782
|
const onChangeRef = (0, import_react.useRef)(onChange);
|
|
1781
1783
|
onChangeRef.current = onChange;
|
|
1784
|
+
const onValidationErrorRef = (0, import_react.useRef)(onValidationError);
|
|
1785
|
+
onValidationErrorRef.current = onValidationError;
|
|
1786
|
+
const onRawChangeRef = (0, import_react.useRef)(onRawChange);
|
|
1787
|
+
onRawChangeRef.current = onRawChange;
|
|
1782
1788
|
const schemaRef = (0, import_react.useRef)(schema);
|
|
1783
1789
|
schemaRef.current = schema;
|
|
1784
1790
|
(0, import_react.useEffect)(() => {
|
|
1785
|
-
if (!onChangeRef.current) return;
|
|
1791
|
+
if (!onChangeRef.current && !onValidationErrorRef.current && !onRawChangeRef.current) return;
|
|
1786
1792
|
const subscription = watch((formValues, { type }) => {
|
|
1787
1793
|
if (type !== "change") return;
|
|
1794
|
+
onRawChangeRef.current?.(formValues);
|
|
1788
1795
|
const result = schemaRef.current.safeParse(formValues);
|
|
1789
|
-
if (result.success
|
|
1790
|
-
onChangeRef.current(result.data);
|
|
1796
|
+
if (result.success) {
|
|
1797
|
+
onChangeRef.current?.(result.data);
|
|
1798
|
+
} else {
|
|
1799
|
+
onValidationErrorRef.current?.(result.error);
|
|
1791
1800
|
}
|
|
1792
1801
|
});
|
|
1793
1802
|
return () => subscription.unsubscribe();
|