formstand 0.5.0 → 0.6.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.
- package/CHANGELOG.md +14 -1
- package/dist/index.cjs +20 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +20 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -176,8 +176,14 @@ declare function useFormSelectorShallow<U>(form: FormStateApi & {
|
|
|
176
176
|
|
|
177
177
|
declare const useFormError: (form: FormStateApi) => readonly string[] | undefined;
|
|
178
178
|
|
|
179
|
-
declare
|
|
180
|
-
|
|
179
|
+
declare function useIsDirty(form: FormStateApi & {
|
|
180
|
+
readonly schema?: undefined;
|
|
181
|
+
}, path?: string): boolean;
|
|
182
|
+
declare function useIsDirty<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>>>(form: Form<TSchema>, path?: P): boolean;
|
|
183
|
+
declare function useIsValid(form: FormStateApi & {
|
|
184
|
+
readonly schema?: undefined;
|
|
185
|
+
}, path?: string): boolean;
|
|
186
|
+
declare function useIsValid<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>>>(form: Form<TSchema>, path?: P): boolean;
|
|
181
187
|
declare const useIsSubmitting: (form: FormStateApi) => boolean;
|
|
182
188
|
declare const useSubmitCount: (form: FormStateApi) => number;
|
|
183
189
|
|
package/dist/index.d.ts
CHANGED
|
@@ -176,8 +176,14 @@ declare function useFormSelectorShallow<U>(form: FormStateApi & {
|
|
|
176
176
|
|
|
177
177
|
declare const useFormError: (form: FormStateApi) => readonly string[] | undefined;
|
|
178
178
|
|
|
179
|
-
declare
|
|
180
|
-
|
|
179
|
+
declare function useIsDirty(form: FormStateApi & {
|
|
180
|
+
readonly schema?: undefined;
|
|
181
|
+
}, path?: string): boolean;
|
|
182
|
+
declare function useIsDirty<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>>>(form: Form<TSchema>, path?: P): boolean;
|
|
183
|
+
declare function useIsValid(form: FormStateApi & {
|
|
184
|
+
readonly schema?: undefined;
|
|
185
|
+
}, path?: string): boolean;
|
|
186
|
+
declare function useIsValid<TSchema extends z.ZodType, P extends FieldPath<z.input<TSchema>>>(form: Form<TSchema>, path?: P): boolean;
|
|
181
187
|
declare const useIsSubmitting: (form: FormStateApi) => boolean;
|
|
182
188
|
declare const useSubmitCount: (form: FormStateApi) => number;
|
|
183
189
|
|
package/dist/index.js
CHANGED
|
@@ -993,17 +993,26 @@ var useFormError = (form) => useStore(
|
|
|
993
993
|
form.store,
|
|
994
994
|
useShallow((state) => state.errors[""])
|
|
995
995
|
);
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
)
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
996
|
+
function useIsDirty(form, path) {
|
|
997
|
+
return useStore(
|
|
998
|
+
form.store,
|
|
999
|
+
(state) => path === void 0 || path === "" ? isFieldDirty(state.values, state.initialValues) : isFieldDirty(
|
|
1000
|
+
getAtPath(state.values, path),
|
|
1001
|
+
getAtPath(state.initialValues, path)
|
|
1002
|
+
)
|
|
1003
|
+
);
|
|
1004
|
+
}
|
|
1005
|
+
function useIsValid(form, path) {
|
|
1006
|
+
return useStore(form.store, (state) => {
|
|
1007
|
+
for (const k in state.errors) {
|
|
1008
|
+
const errs = state.errors[k];
|
|
1009
|
+
if (errs !== void 0 && errs.length > 0 && (path === void 0 || path === "" || isPathOrChild(k, path))) {
|
|
1010
|
+
return false;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return true;
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1007
1016
|
var useIsSubmitting = (form) => useStore(form.store, (state) => state.isSubmitting);
|
|
1008
1017
|
var useSubmitCount = (form) => useStore(form.store, (state) => state.submitCount);
|
|
1009
1018
|
function useField(form, pathArg, options) {
|