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/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.6.0 — 2026-07-09
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `useIsDirty(form, path?)` and `useIsValid(form, path?)`: an optional
|
|
8
|
+
typed path scopes the flag to a subtree with the library's usual prefix
|
|
9
|
+
semantics (`"shipping"` covers `shipping.city`; for validity the path's
|
|
10
|
+
own key counts, so array-level errors match their array's path).
|
|
11
|
+
Subscriptions stay boolean-only — the component re-renders when the flag
|
|
12
|
+
flips, not on every keystroke like `useField(...).dirty`. Omitting the
|
|
13
|
+
path keeps the whole-form behavior; schema-less `FieldFormApi`-style
|
|
14
|
+
forms take plain string paths.
|
|
15
|
+
|
|
16
|
+
## formstand-cli 0.2.2 — 2026-07-09
|
|
4
17
|
|
|
5
18
|
- Generated array hooks drop the explicit item type
|
|
6
19
|
(`useFieldArray(form, "items")`): formstand ≥ 0.5 infers it from the
|
package/dist/index.cjs
CHANGED
|
@@ -995,17 +995,26 @@ var useFormError = (form) => react$1.useStore(
|
|
|
995
995
|
form.store,
|
|
996
996
|
shallow.useShallow((state) => state.errors[""])
|
|
997
997
|
);
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
)
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
998
|
+
function useIsDirty(form, path) {
|
|
999
|
+
return react$1.useStore(
|
|
1000
|
+
form.store,
|
|
1001
|
+
(state) => path === void 0 || path === "" ? isFieldDirty(state.values, state.initialValues) : isFieldDirty(
|
|
1002
|
+
getAtPath(state.values, path),
|
|
1003
|
+
getAtPath(state.initialValues, path)
|
|
1004
|
+
)
|
|
1005
|
+
);
|
|
1006
|
+
}
|
|
1007
|
+
function useIsValid(form, path) {
|
|
1008
|
+
return react$1.useStore(form.store, (state) => {
|
|
1009
|
+
for (const k in state.errors) {
|
|
1010
|
+
const errs = state.errors[k];
|
|
1011
|
+
if (errs !== void 0 && errs.length > 0 && (path === void 0 || path === "" || isPathOrChild(k, path))) {
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
return true;
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1009
1018
|
var useIsSubmitting = (form) => react$1.useStore(form.store, (state) => state.isSubmitting);
|
|
1010
1019
|
var useSubmitCount = (form) => react$1.useStore(form.store, (state) => state.submitCount);
|
|
1011
1020
|
function useField(form, pathArg, options) {
|