@atscript/vue-form 0.1.181 → 0.1.182

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.
Files changed (93) hide show
  1. package/dist/as-action.d.cts +1 -1
  2. package/dist/as-action.d.mts +1 -1
  3. package/dist/{as-action.vue-CQbDa3g4.d.mts → as-action.vue-BmHLq5PU.d.cts} +1 -1
  4. package/dist/{as-action.vue-Cp9Q8a-6.d.cts → as-action.vue-BskkSynK.d.mts} +1 -1
  5. package/dist/as-array.d.cts +1 -1
  6. package/dist/as-array.d.mts +1 -1
  7. package/dist/{as-array.vue-Cgfjz2I-.d.cts → as-array.vue-BWUhWKKn.d.cts} +1 -1
  8. package/dist/{as-array.vue-DpKFsuRS.d.mts → as-array.vue-C4mSQIUB.d.mts} +1 -1
  9. package/dist/as-checkbox.d.cts +1 -1
  10. package/dist/as-checkbox.d.mts +1 -1
  11. package/dist/{as-checkbox.vue-CXiUHIZj.d.cts → as-checkbox.vue-B_LntkDl.d.cts} +1 -1
  12. package/dist/{as-checkbox.vue-Db6OT_lL.d.mts → as-checkbox.vue-CPLwFPve.d.mts} +1 -1
  13. package/dist/as-collapsible.d.cts +1 -1
  14. package/dist/as-collapsible.d.mts +1 -1
  15. package/dist/{as-collapsible.vue-BXwe24OV.d.cts → as-collapsible.vue-9XMYb39s.d.cts} +1 -1
  16. package/dist/{as-collapsible.vue-By-ZBZt3.d.mts → as-collapsible.vue-BtUZuqGF.d.mts} +1 -1
  17. package/dist/as-date.d.cts +1 -1
  18. package/dist/as-date.d.mts +1 -1
  19. package/dist/{as-date.vue-BUaHHI42.d.mts → as-date.vue-CQZp-yqF.d.mts} +1 -1
  20. package/dist/{as-date.vue-axahL_Zv.d.cts → as-date.vue-DQVHGLMc.d.cts} +1 -1
  21. package/dist/as-datetime.d.cts +1 -1
  22. package/dist/as-datetime.d.mts +1 -1
  23. package/dist/{as-datetime.vue-C6ILTI-7.d.cts → as-datetime.vue-DrWth1Pe.d.mts} +1 -1
  24. package/dist/{as-datetime.vue-D3WJpAVe.d.mts → as-datetime.vue-TMgV54Z5.d.cts} +1 -1
  25. package/dist/as-decimal.d.cts +1 -1
  26. package/dist/as-decimal.d.mts +1 -1
  27. package/dist/{as-decimal.vue-BVDyP4LN.d.mts → as-decimal.vue-Bw9vY0br.d.mts} +1 -1
  28. package/dist/{as-decimal.vue-Dgfz9UDJ.d.cts → as-decimal.vue-D-C_ywhy.d.cts} +1 -1
  29. package/dist/as-field-shell.d.cts +1 -1
  30. package/dist/as-field-shell.d.mts +1 -1
  31. package/dist/{as-field-shell.vue-DAcRqi7G.d.cts → as-field-shell.vue-CouocQ2f.d.cts} +1 -1
  32. package/dist/{as-field-shell.vue-DBufTHVO.d.mts → as-field-shell.vue-DIYpxzud.d.mts} +1 -1
  33. package/dist/{as-form-DroFS2lv.cjs → as-form-BTNctHb9.cjs} +15 -7
  34. package/dist/{as-form-B9hRTvod.mjs → as-form-CRDqdXnl.mjs} +15 -7
  35. package/dist/as-form.cjs +1 -1
  36. package/dist/as-form.d.cts +1 -1
  37. package/dist/as-form.d.mts +1 -1
  38. package/dist/as-form.mjs +1 -1
  39. package/dist/{as-form.vue-BdCoE0YG.d.mts → as-form.vue-BI5mC0o7.d.cts} +15 -389
  40. package/dist/{as-form.vue-CPrH175H.d.cts → as-form.vue-BJ79OYA6.d.mts} +15 -389
  41. package/dist/as-input.d.cts +1 -1
  42. package/dist/as-input.d.mts +1 -1
  43. package/dist/{as-input.vue-BiPsULeF.d.mts → as-input.vue-D4UQSSmo.d.cts} +1 -1
  44. package/dist/{as-input.vue-mZ0h1Q2J.d.cts → as-input.vue-Q5EXxW3x.d.mts} +1 -1
  45. package/dist/as-multi-select.d.cts +1 -1
  46. package/dist/as-multi-select.d.mts +1 -1
  47. package/dist/{as-multi-select.vue-Bmngkww7.d.mts → as-multi-select.vue-Ce-V2A81.d.mts} +1 -1
  48. package/dist/{as-multi-select.vue-DAFz9hZR.d.cts → as-multi-select.vue-Iy3G3eu8.d.cts} +1 -1
  49. package/dist/as-number.d.cts +1 -1
  50. package/dist/as-number.d.mts +1 -1
  51. package/dist/{as-number.vue-BsJdJS36.d.cts → as-number.vue-FKc6UVot.d.mts} +1 -1
  52. package/dist/{as-number.vue-C2QSKpVL.d.mts → as-number.vue-PH0wnd3B.d.cts} +1 -1
  53. package/dist/as-object.d.cts +1 -1
  54. package/dist/as-object.d.mts +1 -1
  55. package/dist/{as-object.vue-DFo_5DXv.d.mts → as-object.vue-B0qKMWPB.d.cts} +1 -1
  56. package/dist/{as-object.vue-DduGoHKD.d.cts → as-object.vue-DLCEWLe4.d.mts} +1 -1
  57. package/dist/as-paragraph.d.cts +1 -1
  58. package/dist/as-paragraph.d.mts +1 -1
  59. package/dist/{as-paragraph.vue-BJSA27kd.d.cts → as-paragraph.vue-BIrekTzU.d.mts} +1 -1
  60. package/dist/{as-paragraph.vue-DiHaNFSX.d.mts → as-paragraph.vue-C8JeTZ1s.d.cts} +1 -1
  61. package/dist/as-radio.d.cts +1 -1
  62. package/dist/as-radio.d.mts +1 -1
  63. package/dist/{as-radio.vue-C_ZjbI4s.d.mts → as-radio.vue-Rwknlgr7.d.mts} +1 -1
  64. package/dist/{as-radio.vue-Dw1QaJoY.d.cts → as-radio.vue-jeHiMfc7.d.cts} +1 -1
  65. package/dist/as-ref.d.cts +1 -1
  66. package/dist/as-ref.d.mts +1 -1
  67. package/dist/{as-ref.vue-CvY88H7p.d.cts → as-ref.vue-D0A4vPXL.d.mts} +1 -1
  68. package/dist/{as-ref.vue-DaXQsjsX.d.mts → as-ref.vue-WufE6ltR.d.cts} +1 -1
  69. package/dist/as-select.d.cts +1 -1
  70. package/dist/as-select.d.mts +1 -1
  71. package/dist/{as-select.vue-7xiuC9JG.d.cts → as-select.vue-BIpvu4ba.d.mts} +1 -1
  72. package/dist/{as-select.vue-IGtjEyQD.d.mts → as-select.vue-eMp1zUQE.d.cts} +1 -1
  73. package/dist/as-time.d.cts +1 -1
  74. package/dist/as-time.d.mts +1 -1
  75. package/dist/{as-time.vue-CKVgGb-m.d.mts → as-time.vue-DAeXJ0Zv.d.cts} +1 -1
  76. package/dist/{as-time.vue-CQhIKAs0.d.cts → as-time.vue-DudhL8yx.d.mts} +1 -1
  77. package/dist/as-tuple.d.cts +1 -1
  78. package/dist/as-tuple.d.mts +1 -1
  79. package/dist/{as-tuple.vue-BSh2-1uv.d.cts → as-tuple.vue-C2KTK2RH.d.cts} +1 -1
  80. package/dist/{as-tuple.vue-CDOHXKBr.d.mts → as-tuple.vue-CLIDqVFv.d.mts} +1 -1
  81. package/dist/as-union.d.cts +1 -1
  82. package/dist/as-union.d.mts +1 -1
  83. package/dist/{as-union.vue-BcaUH5bH.d.mts → as-union.vue-43Gq2Lh0.d.cts} +1 -1
  84. package/dist/{as-union.vue-CnF4bNex.d.cts → as-union.vue-CllUYjuh.d.mts} +1 -1
  85. package/dist/index.cjs +1 -1
  86. package/dist/index.d.cts +22 -22
  87. package/dist/index.d.mts +22 -22
  88. package/dist/index.mjs +1 -1
  89. package/dist/types-BbGuPzZk.d.cts +705 -0
  90. package/dist/types-DxmDaJXr.d.mts +705 -0
  91. package/package.json +10 -10
  92. package/dist/types-B0Ey_eD-.d.mts +0 -309
  93. package/dist/types-DoLxVJhd.d.cts +0 -309
@@ -1,11 +1,11 @@
1
- import { c as TAsUnionContext, n as TAsChangeType, o as TAsComponentProps, s as TAsTypeComponents } from "./types-B0Ey_eD-.mjs";
1
+ import { c as TAsTypeComponents, d as TAsFormValue, h as TAsFormError, l as TAsUnionContext, r as TAsChangeType, s as TAsComponentProps, t as AsFormExposed, u as TAsFormSubmitResult, v as TFormRule, y as TFormState } from "./types-BbGuPzZk.cjs";
2
2
  import * as vue from "vue";
3
3
  import { Component, ComputedRef, MaybeRef, MaybeRefOrGetter, Ref, ShallowRef, WritableComputedRef } from "vue";
4
4
  import * as _atscript_ui0 from "@atscript/ui";
5
- import { ClientFactory, ClientFactory as ClientFactory$1, CreateFormDefOptions, FormArrayFieldDef, FormDef, FormDiffOptions, FormDiffOptions as FormDiffOptions$1, FormFieldChange, FormFieldChange as FormFieldChange$1, FormFieldDef, FormRebaseOptions, FormRebaseOptions as FormRebaseOptions$1, FormTupleFieldDef, FormUnionFieldDef, FormUnionVariant, ResolvedValueHelp, TResolveOptions, TypedClientFactory, UiT, UserTextT, ValueHelpInfo, getDefaultClientFactory, hasFieldMeta as hasFieldMeta$1, isFieldHidden as isFieldHidden$1, joinPath as joinPath$1, resetDefaultClientFactory, setDefaultClientFactory } from "@atscript/ui";
6
- import { TFnScope } from "@atscript/ui-fns";
5
+ import { ClientFactory, ClientFactory as ClientFactory$1, CreateFormDefOptions, FormArrayFieldDef, FormDef, FormDiffOptions as FormDiffOptions$1, FormFieldChange, FormFieldChange as FormFieldChange$1, FormFieldDef, FormRebaseOptions as FormRebaseOptions$1, FormTupleFieldDef, FormUnionFieldDef, FormUnionVariant, ResolvedValueHelp, TResolveOptions, TypedClientFactory, UiT, UserTextT, ValueHelpInfo, getDefaultClientFactory, hasFieldMeta, isFieldHidden, joinPath, resetDefaultClientFactory, setDefaultClientFactory } from "@atscript/ui";
7
6
  import * as _atscript_typescript_utils0 from "@atscript/typescript/utils";
8
7
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
8
+ import { TFnScope } from "@atscript/ui-fns";
9
9
 
10
10
  //#region src/composables/create-as-form-def.d.ts
11
11
  /**
@@ -36,43 +36,6 @@ declare function createAsFormDef<T extends TAtscriptAnnotatedType>(type: T, cont
36
36
  */
37
37
  declare function createDefaultTypes(): TAsTypeComponents;
38
38
  //#endregion
39
- //#region src/composables/types.d.ts
40
- type TFormRule<TValue, TFormData, TContext> = (v: TValue, data?: TFormData, context?: TContext) => boolean | string;
41
- interface TFormFieldCallbacks {
42
- validate: () => boolean | string;
43
- clearErrors: () => void;
44
- reset: () => void;
45
- setExternalError: (msg?: string) => void;
46
- /**
47
- * Read the error message the field is DISPLAYING right now (external >
48
- * submit > live-validated per `firstValidation` gating), or `undefined`
49
- * when clean. Feeds the form-level live error aggregation (descendant
50
- * error-count badges / auto-open), so badges track what's on screen
51
- * without waiting for a submit. Optional so manually built registrations
52
- * keep working — a field that omits it simply doesn't contribute live
53
- * errors (submit-time errors still count through the form's own map).
54
- */
55
- getError?: () => string | undefined;
56
- }
57
- interface TFormFieldRegistration {
58
- path: () => string;
59
- callbacks: TFormFieldCallbacks;
60
- }
61
- interface TFormState {
62
- firstSubmitHappened: boolean;
63
- firstValidation: "on-change" | "touched-on-blur" | "on-blur" | "on-submit" | "none";
64
- /**
65
- * Fields registered AFTER `firstSubmitHappened` flipped to true. They stay
66
- * in this set until either the user edits the field (model watch removes
67
- * the id) or the next submit fires (set is cleared). Live validation is
68
- * suppressed for these fields so a freshly-added array item doesn't render
69
- * red required-field errors before the user has had a chance to type.
70
- */
71
- freshFields: Set<symbol>;
72
- register: (id: symbol, registration: TFormFieldRegistration) => void;
73
- unregister: (id: symbol) => void;
74
- }
75
- //#endregion
76
39
  //#region src/composables/use-as-field.d.ts
77
40
  interface UseAsFieldOptions<TValue = any, TFormData = any, TContext = any> {
78
41
  getValue: () => TValue;
@@ -115,10 +78,7 @@ interface UseAsStateReturn {
115
78
  formState: TFormState;
116
79
  clearErrors: () => void;
117
80
  reset: () => Promise<void>;
118
- submit: () => true | {
119
- path: string;
120
- message: string;
121
- }[];
81
+ submit: () => true | TAsFormError[];
122
82
  setErrors: (errors: Record<string, string>) => void;
123
83
  /**
124
84
  * What every registered field DISPLAYS right now, keyed by path
@@ -137,307 +97,6 @@ declare function useAsState<TFormData, TContext>(opts: {
137
97
  submitValidator?: TFormSubmitValidator;
138
98
  }): UseAsStateReturn;
139
99
  //#endregion
140
- //#region src/composables/use-as-form-patch.d.ts
141
- /**
142
- * Result of {@link AsFormPatchHandle.rebaseOnto}. Aliases the `@atscript/ui`
143
- * rebase shape (minus `next`, which is written into the live container rather
144
- * than returned): the surviving local diff on top of the NEW baseline plus the
145
- * conflict paths.
146
- */
147
- interface RebaseOntoResult {
148
- /** Paths changed on both sides to different values, plus ancestor-clear paths. */
149
- conflicts: string[];
150
- /** Local edits that survive on top of the new (upstream) baseline. */
151
- reapplied: FormFieldChange[];
152
- }
153
- /**
154
- * Change-tracking handle for a single `<AsForm>`. Exposed three ways:
155
- *
156
- * 1. injected via {@link useAsFormPatch} inside any descendant component,
157
- * 2. spread into every `<AsForm>` slot (`isDirty` / `changes` / `getPatch` /
158
- * `getChanges` — so a footer slot can gate a Save button), and
159
- * 3. `defineExpose`d on `<AsForm>` (so a parent template ref can call
160
- * `asForm.value.getPatch()`).
161
- *
162
- * Built on `@atscript/ui`'s `buildFormDiff`, which diffs the form's CURRENT
163
- * data against a BASELINE snapshot and produces both a per-field change list
164
- * and an `@atscript/db` patch object (keyed-array `$update`/`$insert`/`$remove`,
165
- * `$cas` optimistic-concurrency sibling, revert-aware).
166
- */
167
- interface AsFormPatchHandle {
168
- /**
169
- * Reactive dirtiness — `true` when current data differs from the baseline.
170
- * Revert-aware: a value edited back to its baseline flips this back to
171
- * `false`. Memoised by Vue; recomputes only when the form data changes.
172
- */
173
- isDirty: ComputedRef<boolean>;
174
- /**
175
- * Reactive per-field change list (revert-aware — reverted fields drop out).
176
- * `before` / `after` hold live references into the baseline / current data.
177
- */
178
- changes: ComputedRef<FormFieldChange[]>;
179
- /**
180
- * Builds the `@atscript/db` patch object on demand against the baseline
181
- * snapshot. Safe to call at submit time (a fresh re-snapshot point). Returns
182
- * `{}` when nothing changed. Carries a top-level `$cas` sibling when the form
183
- * has a `@db.column.version` column and `opts.cas` is on (default).
184
- */
185
- getPatch: (opts?: FormDiffOptions) => Record<string, unknown>;
186
- /** Builds the per-field change list on demand (same data as `changes`). */
187
- getChanges: () => FormFieldChange[];
188
- /**
189
- * Reactive per-field dirty predicate. `true` when the field at the dot-path
190
- * `path` differs from the baseline. Reads the reactive {@link changes} list,
191
- * so a per-field `isDirty` derived from this recomputes whenever the change
192
- * list does.
193
- *
194
- * Granularity matches the change list (leaf-grained for scalars/objects,
195
- * WHOLE-ARRAY for arrays): a field is dirty iff some change path equals
196
- * `path` OR starts with `path + "."`. Object/section containers light up via
197
- * the prefix branch; whole-array fields via exact match; an array-ITEM leaf
198
- * (e.g. `items.0.qty`) returns `false` (the array container lights up
199
- * instead — a known, documented limitation of the array diff). The empty
200
- * root path `''` is dirty iff there are ANY changes. Backed by an O(1)
201
- * `Set.has` against `@atscript/ui`'s `collectDirtyPaths` precompute, whose
202
- * membership matches `isPathDirty` exactly (locked by an invariant test).
203
- */
204
- isDirtyPath: (path: string) => boolean;
205
- /**
206
- * Re-baseline to the current data. Call after a successful save so the form
207
- * becomes clean again WITHOUT a remount. No-op when tracking is inactive.
208
- */
209
- rebase: () => void;
210
- /**
211
- * 3-way rebase onto a fresh upstream snapshot. Sets the baseline to
212
- * `upstream` and rewrites the live form to `upstream` + the local diff
213
- * (current vs. old baseline) reapplied on top:
214
- *
215
- * - fields the user never touched adopt `upstream`'s value,
216
- * - local edits survive,
217
- * - fields changed on both sides to a different value are conflicts, resolved
218
- * by `opts.conflict` (`'ours'` default keeps local, `'theirs'` takes
219
- * upstream).
220
- *
221
- * `upstream` is the WRAPPED form-data container (`{ value }`). The live form
222
- * data is rewritten in a SINGLE mutation (the bound `:form-data` container
223
- * identity is preserved, so the consumer's ref stays the same object). After
224
- * the write the baseline becomes a deep clone of `upstream`, so a subsequent
225
- * `getPatch()` carries exactly the surviving local diff (`reapplied`).
226
- *
227
- * Returns the conflict paths and the surviving local diff. No-op returning
228
- * empty when tracking is inactive.
229
- */
230
- rebaseOnto: (upstream: Record<string, unknown>, opts?: FormRebaseOptions) => RebaseOntoResult;
231
- }
232
- /**
233
- * Reactive read-only access to the form's change-tracking handle from any
234
- * descendant of an `<AsForm track-changes>`. Mirrors the `useAsData` /
235
- * `useAsPath` injector pattern.
236
- *
237
- * THROWS when called outside a form, or inside a form that did not enable
238
- * `track-changes` — fail loud rather than silently report "not dirty".
239
- *
240
- * @example
241
- * ```vue
242
- * <script setup lang="ts">
243
- * import { useAsFormPatch } from "@atscript/vue-form";
244
- * const { isDirty, getPatch } = useAsFormPatch();
245
- * </script>
246
- * <template>
247
- * <button :disabled="!isDirty" @click="save(getPatch())">Save</button>
248
- * </template>
249
- * ```
250
- */
251
- declare function useAsFormPatch(): AsFormPatchHandle;
252
- //#endregion
253
- //#region src/composables/use-as-form.d.ts
254
- /**
255
- * Options for {@link useAsForm}. Each reactive prop is supplied as a
256
- * **getter** so the composable can subscribe to its changes without owning
257
- * a `Ref`. Pass component-level `defineProps` accessors verbatim:
258
- *
259
- * ```ts
260
- * useAsForm({
261
- * def: () => props.def,
262
- * formData: () => props.formData,
263
- * types: () => props.types,
264
- * // ...
265
- * emits: { submit: (data) => emit("submit", data), ... },
266
- * })
267
- * ```
268
- *
269
- * Generic `TFormData` / `TFormContext` mirror the `<AsForm>` component
270
- * generics. They flow through to emitted callbacks; if you build a custom
271
- * form root with a known data shape, pin them at the call site.
272
- */
273
- interface UseAsFormOptions<TFormData = unknown, TFormContext = unknown> {
274
- /** Form definition produced by `createAsFormDef(type)`. Reactive. */
275
- def: () => FormDef;
276
- /**
277
- * Externally-managed form data container `{ value: domainData }`. When
278
- * unset, the composable creates an internal one initialized to `{}`.
279
- */
280
- formData?: () => TFormData | undefined;
281
- /** Reactive form context — exposed to validators, scope, slots, and emits. */
282
- formContext?: () => TFormContext | undefined;
283
- /** First-validation strategy. Defaults to `"on-change"`. */
284
- firstValidation?: () => TFormState["firstValidation"] | undefined;
285
- /** Custom field components keyed by field name (matches `Props.components`). */
286
- components?: () => Record<string, Component<TAsComponentProps>> | undefined;
287
- /** Type-to-component map keyed by field type (matches `Props.types`). */
288
- types: () => TAsTypeComponents;
289
- /** Server-supplied errors keyed by absolute dotted path (`__form` for form-level). */
290
- errors?: () => Record<string, string | undefined> | undefined;
291
- /** Per-form value-help client factory. Falls back to the app-wide default when unset. */
292
- clientFactory?: () => ClientFactory | undefined;
293
- /** Suppress the root field's title (use when the chrome already shows the form's label). */
294
- hideRootTitle?: () => boolean | undefined;
295
- /**
296
- * Busy-state flag. When `true`, the form is locked (inert + overlay) and the
297
- * default submit button is disabled. `<AsWfForm>` wires this to its
298
- * server round-trip so consumers can drop their own submit overrides.
299
- */
300
- loading?: () => boolean | undefined;
301
- /**
302
- * Enable change tracking. When `true`, the composable captures a deep-clone
303
- * baseline of the form data (the moment it becomes available) and exposes a
304
- * {@link AsFormPatchHandle} via `slotProps`, the return value (`patch`), and
305
- * `provide(FORM_PATCH_KEY)` (read with `useAsFormPatch()`). When falsy
306
- * (default), there is ZERO overhead — no baseline, no deep watch, and
307
- * `useAsFormPatch()` throws. Reactive.
308
- */
309
- trackChanges?: () => boolean | undefined;
310
- /**
311
- * Outbound callbacks. Customer form roots typically wire these to
312
- * `defineEmits`; advanced uses can pass plain functions.
313
- */
314
- emits?: {
315
- submit?: (data: TAsFormValue<TFormData>) => void;
316
- error?: (errors: {
317
- path: string;
318
- message: string;
319
- }[]) => void;
320
- action?: (name: string, data: TAsFormValue<TFormData>) => void;
321
- unsupportedAction?: (name: string, data: TAsFormValue<TFormData>) => void;
322
- change?: (type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>) => void;
323
- };
324
- }
325
- /**
326
- * The value inside a `{ value }` form-data container (`value` may be
327
- * optional): what the `submit`, `action`, `unsupportedAction` and `change`
328
- * callbacks (and `<AsForm>`'s events) receive. `any` for an `any` container,
329
- * `unknown` when the container has no `value`.
330
- */
331
- type TAsFormValue<TFormData> = 0 extends 1 & TFormData ? any : TFormData extends {
332
- value?: infer V;
333
- } ? V : unknown;
334
- interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
335
- /** Reactive form-data container `{ value: domainData }`. */
336
- data: ComputedRef<TFormData>;
337
- /** Effective external errors (post-dismissal), excluding `__form`. */
338
- errors: ComputedRef<Record<string, string | undefined> | undefined>;
339
- /**
340
- * Form-level error message (post banner-dismissal): the root interface's
341
- * `@ui.form.validate` error (live after the first submit), else the
342
- * external `__form` error.
343
- */
344
- formError: ComputedRef<string | undefined>;
345
- /** Errors discovered by the local validator on the most-recent submit. */
346
- internalErrors: Ref<Record<string, string>>;
347
- /**
348
- * Return the form's fields to what a newly created form holds
349
- * (`createFormData` — annotation defaults included, optional fields absent;
350
- * loaded values are not kept). Properties of the data that are not form
351
- * fields (an edit form's version column, navigation rows) are left as they
352
- * are. The field subtree remounts (`remountKey`); touched state, submit and
353
- * live errors are cleared; a server error (`errors`) is dismissed where the
354
- * reset changed the value — on other paths, and the external `__form`
355
- * banner, it stays. When `trackChanges` is enabled, the post-reset state
356
- * becomes the new clean baseline. Focus is left alone: `<AsForm>` moves it
357
- * to the first field control when the reset removed or disabled the
358
- * focused element.
359
- */
360
- reset: () => Promise<void>;
361
- /**
362
- * Imperatively clear ALL error state: per-field (touched / blur / submit /
363
- * external via `useAsState().clearErrors`) plus the form-level submit-time
364
- * error map that feeds the descendant-count badges.
365
- */
366
- clearErrors: () => void;
367
- /** Imperatively set external-error messages by path. */
368
- setErrors: (errors: Record<string, string>) => void;
369
- /**
370
- * Trigger submit. Applies the type's `@normalize.*` (trim, case) to the data,
371
- * validates the result and emits it with `submit` on success, `error` on
372
- * validation failure. The form data itself is left as typed.
373
- */
374
- onSubmit: () => void;
375
- /** Resolved submit-button text (`@ui.form.submit.text` / fn variant). */
376
- submitText: ComputedRef<string>;
377
- /** Resolved submit-button disabled state (`@ui.form.fn.submitDisabled`). */
378
- submitDisabled: ComputedRef<boolean>;
379
- /** Resolved form-level title (`@ui.form.fn.title` / `@meta.label`); may be `undefined`. */
380
- title: ComputedRef<string | undefined>;
381
- /** Resolved form-level description (`@ui.form.fn.description` / `@meta.description`). */
382
- description: ComputedRef<string | undefined>;
383
- /** Unified slot-props bag spread onto every `<AsForm>` slot. */
384
- slotProps: ComputedRef<{
385
- title: string | undefined;
386
- description: string | undefined;
387
- data: TFormData;
388
- errors: Record<string, string | undefined> | undefined;
389
- formError: string | undefined;
390
- disabled: boolean;
391
- loading: boolean;
392
- submitText: string;
393
- submit: () => void;
394
- reset: () => Promise<void>;
395
- clearErrors: () => void;
396
- setErrors: (errors: Record<string, string>) => void;
397
- dismissError: (path: string) => void;
398
- dismissFormError: () => void;
399
- formContext: TFormContext | undefined; /** True when `track-changes` is on AND data differs from baseline. */
400
- isDirty: boolean; /** Revert-aware per-field change list (empty when tracking is off). */
401
- changes: readonly FormFieldChange[]; /** Build the `@atscript/db` patch on demand (`{}` when tracking is off). */
402
- getPatch: (opts?: FormDiffOptions) => Record<string, unknown>; /** Build the per-field change list on demand (`[]` when tracking is off). */
403
- getChanges: () => FormFieldChange[]; /** Per-field dirty predicate (`false` for every path when tracking is off). */
404
- isDirtyPath: (path: string) => boolean;
405
- }>;
406
- /**
407
- * Change-tracking handle — present ONLY when `trackChanges` is enabled.
408
- * `undefined` otherwise. Read it from descendants with `useAsFormPatch()`.
409
- */
410
- patch: AsFormPatchHandle | undefined;
411
- /**
412
- * Remount key for the field subtree. Bound as `:key` on the root `<AsField>`
413
- * (and on the pushed-down fields). Bumped by every `reset()`, and — with
414
- * `trackChanges` — when `patch.rebaseOnto` or a swap of the data's `value`
415
- * lands a different union variant, forcing the variant picker to re-detect.
416
- */
417
- remountKey: Ref<number>;
418
- /** Dispatch an action — invoked by `<AsAction>`. */
419
- invokeAction: (name: string) => void;
420
- /** Dismiss a single external leaf error. */
421
- dismissError: (path: string) => void;
422
- /** Dismiss the form-level banner. */
423
- dismissFormError: () => void;
424
- /** Form-context getter (mirrors `options.formContext()`). */
425
- formContext: ComputedRef<TFormContext | undefined>;
426
- /** Internal change-dispatcher used by `<AsField>` and structured components. */
427
- handleChange: (type: TAsChangeType, path: string, value: unknown) => void;
428
- }
429
- /**
430
- * Composable backing `<AsForm>`. Owns the entire form state machine —
431
- * data container, internal validator, external-error dismissal, action
432
- * routing, change merging, descendant counts, auto-open, and all
433
- * provide/inject wiring. Customers building a custom form root can
434
- * call this directly and render their own `<form>` template.
435
- *
436
- * MUST be called from a component's `<script setup>` (it issues
437
- * `provide()` calls that need an active component instance).
438
- */
439
- declare function useAsForm<TFormData = unknown, TFormContext = unknown>(options: UseAsFormOptions<TFormData, TFormContext>): UseAsFormReturn<TFormData, TFormContext>;
440
- //#endregion
441
100
  //#region src/composables/use-as-external-errors.d.ts
442
101
  /**
443
102
  * Source of externally-supplied (server) errors. Reading this getter
@@ -1209,10 +868,7 @@ interface Props<TF, TC> {
1209
868
  }
1210
869
  declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1211
870
  props: vue.PublicProps & __VLS_PrettifyLocal<Props<TFormData, TFormContext> & {
1212
- onError?: ((errors: {
1213
- path: string;
1214
- message: string;
1215
- }[]) => any) | undefined;
871
+ onError?: ((errors: TAsFormError[]) => any) | undefined;
1216
872
  onAction?: ((name: string, data: TAsFormValue<TFormData>) => any) | undefined;
1217
873
  onSubmit?: ((data: TAsFormValue<TFormData>) => any) | undefined;
1218
874
  "onUnsupported-action"?: ((name: string, data: TAsFormValue<TFormData>) => any) | undefined;
@@ -1220,34 +876,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1220
876
  }> & (typeof globalThis extends {
1221
877
  __VLS_PROPS_FALLBACK: infer P;
1222
878
  } ? P : {});
1223
- expose: (exposed: vue.ShallowUnwrapRef<{
1224
- submit: () => void;
1225
- /**
1226
- * Fire a form action as its button would: emits `action` (or
1227
- * `unsupported-action`) with the data a submit would send — normalized,
1228
- * not validated.
1229
- */
1230
- action: (name: string) => void;
1231
- reset: () => Promise<void>; /** Clear all error state (per-field + the submit-time map behind badges). */
1232
- clearErrors: () => void; /** Set external-error messages by path (e.g. mapping a server 400). */
1233
- setErrors: (errors: Record<string, string>) => void; /** True when `track-changes` is on AND data differs from baseline. */
1234
- readonly isDirty: boolean; /** Revert-aware per-field change list (empty when tracking is off). */
1235
- readonly changes: FormFieldChange[]; /** Build the `@atscript/db` patch object on demand (`{}` when off). */
1236
- getPatch: ((opts?: _atscript_ui0.FormDiffOptions) => Record<string, unknown>) | (() => {}); /** Build the per-field change list on demand (`[]` when off). */
1237
- getChanges: () => FormFieldChange[];
1238
- /**
1239
- * Per-field dirty predicate — `true` when the field at `path` differs from
1240
- * the baseline (`false` for every path when tracking is off).
1241
- */
1242
- isDirtyPath: (path: string) => boolean; /** Re-baseline to current data after a successful save (no-op when off). */
1243
- rebase: () => void;
1244
- /**
1245
- * 3-way rebase onto a fresh upstream snapshot (sets baseline := upstream,
1246
- * reapplies the local diff). Pure no-op returning empty when tracking is off
1247
- * — NO side effects, mirroring `rebase`/`getPatch`.
1248
- */
1249
- rebaseOnto: (upstream: Record<string, unknown>, opts?: _atscript_ui0.FormRebaseOptions) => RebaseOntoResult;
1250
- }>) => void;
879
+ expose: (exposed: vue.ShallowUnwrapRef<AsFormExposed<TFormData>>) => void;
1251
880
  attrs: any;
1252
881
  slots: {
1253
882
  'form.header'?: (props: {
@@ -1260,7 +889,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1260
889
  disabled: boolean;
1261
890
  loading: boolean;
1262
891
  submitText: string;
1263
- submit: () => void;
892
+ submit: () => TAsFormSubmitResult<TFormData>;
1264
893
  clearErrors: () => void;
1265
894
  setErrors: (errors: Record<string, string>) => void;
1266
895
  dismissError: (path: string) => void;
@@ -1283,7 +912,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1283
912
  disabled: boolean;
1284
913
  loading: boolean;
1285
914
  submitText: string;
1286
- submit: () => void;
915
+ submit: () => TAsFormSubmitResult<TFormData>;
1287
916
  clearErrors: () => void;
1288
917
  setErrors: (errors: Record<string, string>) => void;
1289
918
  dismissError: (path: string) => void;
@@ -1306,7 +935,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1306
935
  disabled: boolean;
1307
936
  loading: boolean;
1308
937
  submitText: string;
1309
- submit: () => void;
938
+ submit: () => TAsFormSubmitResult<TFormData>;
1310
939
  clearErrors: () => void;
1311
940
  setErrors: (errors: Record<string, string>) => void;
1312
941
  dismissError: (path: string) => void;
@@ -1331,7 +960,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1331
960
  disabled: boolean;
1332
961
  loading: boolean;
1333
962
  submitText: string;
1334
- submit: () => void;
963
+ submit: () => TAsFormSubmitResult<TFormData>;
1335
964
  clearErrors: () => void;
1336
965
  setErrors: (errors: Record<string, string>) => void;
1337
966
  dismissError: (path: string) => void;
@@ -1355,7 +984,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1355
984
  disabled: boolean;
1356
985
  loading: boolean;
1357
986
  submitText: string;
1358
- submit: () => void;
987
+ submit: () => TAsFormSubmitResult<TFormData>;
1359
988
  clearErrors: () => void;
1360
989
  setErrors: (errors: Record<string, string>) => void;
1361
990
  dismissError: (path: string) => void;
@@ -1378,7 +1007,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1378
1007
  disabled: boolean;
1379
1008
  loading: boolean;
1380
1009
  submitText: string;
1381
- submit: () => void;
1010
+ submit: () => TAsFormSubmitResult<TFormData>;
1382
1011
  clearErrors: () => void;
1383
1012
  setErrors: (errors: Record<string, string>) => void;
1384
1013
  dismissError: (path: string) => void;
@@ -1401,7 +1030,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1401
1030
  disabled: boolean;
1402
1031
  loading: boolean;
1403
1032
  submitText: string;
1404
- submit: () => void;
1033
+ submit: () => TAsFormSubmitResult<TFormData>;
1405
1034
  clearErrors: () => void;
1406
1035
  setErrors: (errors: Record<string, string>) => void;
1407
1036
  dismissError: (path: string) => void;
@@ -1416,10 +1045,7 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1416
1045
  };
1417
1046
  emit: {
1418
1047
  (e: "submit", data: TAsFormValue<TFormData>): void;
1419
- (e: "error", errors: {
1420
- path: string;
1421
- message: string;
1422
- }[]): void;
1048
+ (e: "error", errors: TAsFormError[]): void;
1423
1049
  (e: "action", name: string, data: TAsFormValue<TFormData>): void;
1424
1050
  (e: "unsupported-action", name: string, data: TAsFormValue<TFormData>): void;
1425
1051
  (e: "change", type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>): void;
@@ -1430,4 +1056,4 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1430
1056
  declare const _default: typeof __VLS_export;
1431
1057
  type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
1432
1058
  //#endregion
1433
- export { AsNestedSectionsStore as $, useAsNumber as A, useAsField as At, UseAsOptionalAddFlowReturn as B, UseAsDateReturn as C, RebaseOntoResult as Ct, useAsDualInput as D, useAsState as Dt, UseAsDualInputReturn as E, UseAsStateReturn as Et, useAsModelTexts as F, createDefaultTypes as Ft, useAsVisibleFields as G, focusFirstAfter as H, UseAsTriStateCheckboxOptions as I, createAsFormDef as It, TResolveFieldPropOptions as J, UseAsOptionalFieldReturn as K, UseAsTriStateCheckboxReturn as L, UseAsDecimalReturn as M, TFormFieldRegistration as Mt, useAsDecimal as N, TFormRule as Nt, UseAsNumberOptions as O, UseAsFieldOptions as Ot, variantLabel as P, TFormState as Pt, useAsLevel as Q, useAsTriStateCheckbox as R, UseAsDateOptions as S, AsFormPatchHandle as St, UseAsDualInputOptions as T, TFormSubmitValidator as Tt, focusNewFocusableAfter as U, useAsOptionalAddFlow as V, useAsFocusFirstAfter as W, useAsFieldScope as X, UseAsFieldScopeReturn as Y, provideAsNestedLevel as Z, useAsData as _, useAsExternalErrors as _t, FormFieldChange$1 as a, UseAsValueHelpReturn as at, UseAsPathReturn as b, UseAsFormReturn as bt, getDefaultClientFactory as c, useAsUnionVariant as ct, joinPath$1 as d, UseAsTupleReturn as dt, provideAsNestedSectionsStore as et, resetDefaultClientFactory as f, useAsTuple as ft, UseAsDataReturn as g, UseAsExternalErrorsReturn as gt, useAsErrorDismiss as h, UseAsExternalErrorsOptions as ht, FormDiffOptions$1 as i, UseAsValueHelpOptions as it, UseAsDecimalOptions as j, TFormFieldCallbacks as jt, UseAsNumberReturn as k, UseAsFieldReturn as kt, hasFieldMeta$1 as l, UseAsUnionReturn as lt, AsErrorDismiss as m, useAsArray as mt, _default as n, useAsNestedSectionsStore as nt, FormRebaseOptions$1 as o, useAsValueHelp as ot, setDefaultClientFactory as p, UseAsArrayReturn as pt, useAsOptionalField as q, ClientFactory$1 as r, useAsDropdown as rt, TypedClientFactory as s, formatIndexedLabelParts as st, Props as t, useAsDescendantErrorCounts as tt, isFieldHidden$1 as u, useAsUnion as ut, UseAsTypeMapReturn as v, TAsFormValue as vt, useAsDate as w, useAsFormPatch as wt, useAsPath as x, useAsForm as xt, useAsTypeMap as y, UseAsFormOptions as yt, UseAsOptionalAddFlowOptions as z };
1059
+ export { AsNestedSectionsStore as $, useAsNumber as A, UseAsOptionalAddFlowReturn as B, UseAsDateReturn as C, useAsField as Ct, useAsDualInput as D, UseAsDualInputReturn as E, useAsModelTexts as F, useAsVisibleFields as G, focusFirstAfter as H, UseAsTriStateCheckboxOptions as I, TResolveFieldPropOptions as J, UseAsOptionalFieldReturn as K, UseAsTriStateCheckboxReturn as L, UseAsDecimalReturn as M, useAsDecimal as N, UseAsNumberOptions as O, variantLabel as P, useAsLevel as Q, useAsTriStateCheckbox as R, UseAsDateOptions as S, UseAsFieldReturn as St, UseAsDualInputOptions as T, createAsFormDef as Tt, focusNewFocusableAfter as U, useAsOptionalAddFlow as V, useAsFocusFirstAfter as W, useAsFieldScope as X, UseAsFieldScopeReturn as Y, provideAsNestedLevel as Z, useAsData as _, useAsExternalErrors as _t, FormFieldChange$1 as a, UseAsValueHelpReturn as at, UseAsPathReturn as b, useAsState as bt, getDefaultClientFactory as c, useAsUnionVariant as ct, joinPath as d, UseAsTupleReturn as dt, provideAsNestedSectionsStore as et, resetDefaultClientFactory as f, useAsTuple as ft, UseAsDataReturn as g, UseAsExternalErrorsReturn as gt, useAsErrorDismiss as h, UseAsExternalErrorsOptions as ht, FormDiffOptions$1 as i, UseAsValueHelpOptions as it, UseAsDecimalOptions as j, UseAsNumberReturn as k, hasFieldMeta as l, UseAsUnionReturn as lt, AsErrorDismiss as m, useAsArray as mt, _default as n, useAsNestedSectionsStore as nt, FormRebaseOptions$1 as o, useAsValueHelp as ot, setDefaultClientFactory as p, UseAsArrayReturn as pt, useAsOptionalField as q, ClientFactory$1 as r, useAsDropdown as rt, TypedClientFactory as s, formatIndexedLabelParts as st, Props as t, useAsDescendantErrorCounts as tt, isFieldHidden as u, useAsUnion as ut, UseAsTypeMapReturn as v, TFormSubmitValidator as vt, useAsDate as w, createDefaultTypes as wt, useAsPath as x, UseAsFieldOptions as xt, useAsTypeMap as y, UseAsStateReturn as yt, UseAsOptionalAddFlowOptions as z };