@atscript/vue-form 0.1.163 → 0.1.164

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 (115) 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-wcB6Dkpu.d.cts → as-action.vue-CYGG4gUQ.d.mts} +1 -1
  4. package/dist/{as-action.vue-yDKx8hC0.d.mts → as-action.vue-Cp9Q8a-6.d.cts} +1 -1
  5. package/dist/{as-array-CD_Z7lZV.mjs → as-array-CqnBh3rv.mjs} +1 -1
  6. package/dist/{as-array-CX52_z_L.cjs → as-array-CxeMe9Dw.cjs} +1 -1
  7. package/dist/as-array.cjs +1 -1
  8. package/dist/as-array.d.cts +1 -1
  9. package/dist/as-array.d.mts +1 -1
  10. package/dist/as-array.mjs +1 -1
  11. package/dist/{as-array.vue-BoKbyO1a.d.cts → as-array.vue-Cgfjz2I-.d.cts} +1 -1
  12. package/dist/{as-array.vue-DKcxkmjP.d.mts → as-array.vue-Wj9giGdu.d.mts} +1 -1
  13. package/dist/as-checkbox.d.cts +1 -1
  14. package/dist/as-checkbox.d.mts +1 -1
  15. package/dist/{as-checkbox.vue-BXS5v6Ru.d.mts → as-checkbox.vue-CWe73b3Z.d.mts} +1 -1
  16. package/dist/{as-checkbox.vue-DdttMJAS.d.cts → as-checkbox.vue-CXiUHIZj.d.cts} +1 -1
  17. package/dist/as-collapsible.d.cts +1 -1
  18. package/dist/as-collapsible.d.mts +1 -1
  19. package/dist/{as-collapsible.vue-1JSWgRMg.d.cts → as-collapsible.vue-BXwe24OV.d.cts} +1 -1
  20. package/dist/{as-collapsible.vue-DowxhNde.d.mts → as-collapsible.vue-hfAqxx1w.d.mts} +1 -1
  21. package/dist/as-date.d.cts +1 -1
  22. package/dist/as-date.d.mts +1 -1
  23. package/dist/{as-date.vue-BVvALvZ_.d.mts → as-date.vue-BTm9X4fW.d.mts} +1 -1
  24. package/dist/{as-date.vue-BiUgcOwZ.d.cts → as-date.vue-axahL_Zv.d.cts} +1 -1
  25. package/dist/as-datetime.d.cts +1 -1
  26. package/dist/as-datetime.d.mts +1 -1
  27. package/dist/{as-datetime.vue-BVc6jcUI.d.cts → as-datetime.vue-C6ILTI-7.d.cts} +1 -1
  28. package/dist/{as-datetime.vue-CCQqZsKA.d.mts → as-datetime.vue-vysHc3Ug.d.mts} +1 -1
  29. package/dist/as-decimal.d.cts +1 -1
  30. package/dist/as-decimal.d.mts +1 -1
  31. package/dist/{as-decimal.vue-BDfM2ICc.d.mts → as-decimal.vue-CAq25zbX.d.mts} +1 -1
  32. package/dist/{as-decimal.vue-Cc9pNTqj.d.cts → as-decimal.vue-Dgfz9UDJ.d.cts} +1 -1
  33. package/dist/{as-field-C_DB6Lbi.cjs → as-field-8MDWK_jb.cjs} +16 -3
  34. package/dist/{as-field-DqK4Yiev.mjs → as-field-DQxlwJVM.mjs} +17 -4
  35. package/dist/as-field-shell.d.cts +1 -1
  36. package/dist/as-field-shell.d.mts +1 -1
  37. package/dist/{as-field-shell.vue-B1ep312_.d.cts → as-field-shell.vue-BU0_8-uI.d.mts} +1 -1
  38. package/dist/{as-field-shell.vue-DisEXQI1.d.mts → as-field-shell.vue-DAcRqi7G.d.cts} +1 -1
  39. package/dist/as-field.cjs +1 -1
  40. package/dist/as-field.mjs +1 -1
  41. package/dist/{as-form-DLYEF8Ez.mjs → as-form-C-CV5ezE.mjs} +5 -4
  42. package/dist/{as-form-DgbRGqD8.cjs → as-form-DLSFfuLR.cjs} +4 -3
  43. package/dist/as-form.cjs +1 -1
  44. package/dist/as-form.d.cts +1 -1
  45. package/dist/as-form.d.mts +1 -1
  46. package/dist/as-form.mjs +1 -1
  47. package/dist/{as-form.vue-BmKBCn6P.d.cts → as-form.vue-BA70Ib2m.d.cts} +50 -317
  48. package/dist/{as-form.vue-hHJm_Rxq.d.mts → as-form.vue-D2SQ5VeJ.d.mts} +50 -317
  49. package/dist/as-input.d.cts +1 -1
  50. package/dist/as-input.d.mts +1 -1
  51. package/dist/{as-input.vue-CL-Om6Ed.d.mts → as-input.vue-CyLveDWK.d.mts} +1 -1
  52. package/dist/{as-input.vue-D-RM35Rp.d.cts → as-input.vue-mZ0h1Q2J.d.cts} +1 -1
  53. package/dist/{as-iterator-DHNJwo-R.cjs → as-iterator-Bbyxog8g.cjs} +1 -1
  54. package/dist/{as-iterator-mOyaYJiN.mjs → as-iterator-CaQ1TkIR.mjs} +1 -1
  55. package/dist/as-iterator.cjs +1 -1
  56. package/dist/as-iterator.mjs +1 -1
  57. package/dist/{as-multi-select-AC05uVzY.mjs → as-multi-select-B7Nc2brD.mjs} +80 -12
  58. package/dist/{as-multi-select-BedSzod1.cjs → as-multi-select-BiUexFnY.cjs} +78 -10
  59. package/dist/as-multi-select.cjs +1 -1
  60. package/dist/as-multi-select.d.cts +1 -1
  61. package/dist/as-multi-select.d.mts +1 -1
  62. package/dist/as-multi-select.mjs +1 -1
  63. package/dist/{as-multi-select.vue-5GHWrbim.d.mts → as-multi-select.vue-BS9bNhCB.d.mts} +1 -1
  64. package/dist/{as-multi-select.vue-D1OnCH-x.d.cts → as-multi-select.vue-DAFz9hZR.d.cts} +1 -1
  65. package/dist/as-number.d.cts +1 -1
  66. package/dist/as-number.d.mts +1 -1
  67. package/dist/{as-number.vue-BiZ2B2iJ.d.mts → as-number.vue-BsJdJS36.d.cts} +1 -1
  68. package/dist/{as-number.vue-DE33Giq3.d.cts → as-number.vue-DSP2S_xP.d.mts} +1 -1
  69. package/dist/{as-object-B_x-yycI.mjs → as-object-0Qo0bPi5.mjs} +1 -1
  70. package/dist/{as-object-YYxV2y77.cjs → as-object-BjOUiVDG.cjs} +1 -1
  71. package/dist/as-object.cjs +1 -1
  72. package/dist/as-object.d.cts +1 -1
  73. package/dist/as-object.d.mts +1 -1
  74. package/dist/as-object.mjs +1 -1
  75. package/dist/{as-object.vue-Dg4IT2JT.d.mts → as-object.vue-CpDhlJ_D.d.mts} +1 -1
  76. package/dist/{as-object.vue-PUhmGqhY.d.cts → as-object.vue-DduGoHKD.d.cts} +1 -1
  77. package/dist/as-paragraph.d.cts +1 -1
  78. package/dist/as-paragraph.d.mts +1 -1
  79. package/dist/{as-paragraph.vue-BUfbXaiy.d.cts → as-paragraph.vue-BJSA27kd.d.cts} +1 -1
  80. package/dist/{as-paragraph.vue-Bp-MUDcH.d.mts → as-paragraph.vue-CMUaF6WV.d.mts} +1 -1
  81. package/dist/as-radio.d.cts +1 -1
  82. package/dist/as-radio.d.mts +1 -1
  83. package/dist/{as-radio.vue-NmjJm8Pj.d.mts → as-radio.vue-BR2ThEbi.d.mts} +1 -1
  84. package/dist/{as-radio.vue-h4XkpaW0.d.cts → as-radio.vue-Dw1QaJoY.d.cts} +1 -1
  85. package/dist/as-ref.d.cts +1 -1
  86. package/dist/as-ref.d.mts +1 -1
  87. package/dist/{as-ref.vue-ec447Bmx.d.cts → as-ref.vue-CZzOVBz1.d.mts} +1 -1
  88. package/dist/{as-ref.vue-vP2P1ePF.d.mts → as-ref.vue-CvY88H7p.d.cts} +1 -1
  89. package/dist/as-select.d.cts +1 -1
  90. package/dist/as-select.d.mts +1 -1
  91. package/dist/{as-select.vue-9mQ6cjW7.d.mts → as-select.vue-7xiuC9JG.d.cts} +1 -1
  92. package/dist/{as-select.vue-DV0C1MsH.d.cts → as-select.vue-BPPctxZT.d.mts} +1 -1
  93. package/dist/as-time.d.cts +1 -1
  94. package/dist/as-time.d.mts +1 -1
  95. package/dist/{as-time.vue-CmvsgHJd.d.cts → as-time.vue-CQhIKAs0.d.cts} +1 -1
  96. package/dist/{as-time.vue-DGfZPnWK.d.mts → as-time.vue-CjzRrsFg.d.mts} +1 -1
  97. package/dist/{as-tuple-CfgSnsT9.cjs → as-tuple-DKBOLriy.cjs} +1 -1
  98. package/dist/{as-tuple-Dny4Ov_j.mjs → as-tuple-fwxeV71M.mjs} +1 -1
  99. package/dist/as-tuple.cjs +1 -1
  100. package/dist/as-tuple.d.cts +1 -1
  101. package/dist/as-tuple.d.mts +1 -1
  102. package/dist/as-tuple.mjs +1 -1
  103. package/dist/{as-tuple.vue-CInEbMRo.d.mts → as-tuple.vue-BSh2-1uv.d.cts} +1 -1
  104. package/dist/{as-tuple.vue-zZkuYxet.d.cts → as-tuple.vue-DvHHrn-6.d.mts} +1 -1
  105. package/dist/as-union.d.cts +1 -1
  106. package/dist/as-union.d.mts +1 -1
  107. package/dist/{as-union.vue-Bz3EO0Gg.d.mts → as-union.vue-BJ8xFYYb.d.mts} +1 -1
  108. package/dist/{as-union.vue-K9ZSRg0G.d.cts → as-union.vue-CnF4bNex.d.cts} +1 -1
  109. package/dist/index.cjs +12 -9
  110. package/dist/index.d.cts +22 -22
  111. package/dist/index.d.mts +22 -22
  112. package/dist/index.mjs +12 -9
  113. package/dist/{types-BLoV3zIo.d.mts → types-BoguW89D.d.mts} +24 -19
  114. package/dist/{types-Crwu2D-w.d.cts → types-DoLxVJhd.d.cts} +24 -19
  115. package/package.json +11 -11
@@ -1,306 +1,12 @@
1
- import { c as TAsUnionContext, n as TAsChangeType, o as TAsComponentProps, s as TAsTypeComponents } from "./types-Crwu2D-w.cjs";
1
+ import { c as TAsUnionContext, n as TAsChangeType, o as TAsComponentProps, s as TAsTypeComponents } from "./types-DoLxVJhd.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, FormArrayFieldDef, FormDef, FormDiffOptions, FormDiffOptions as FormDiffOptions$1, FormFieldChange, FormFieldChange as FormFieldChange$1, FormFieldDef, FormRebaseOptions, FormRebaseOptions as FormRebaseOptions$1, FormTupleFieldDef, FormUnionFieldDef, FormUnionVariant, ResolvedValueHelp, TResolveOptions, ValueHelpInfo, getDefaultClientFactory, hasFieldMeta, isFieldHidden, joinPath, resetDefaultClientFactory, setDefaultClientFactory } 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, ValueHelpInfo, getDefaultClientFactory, hasFieldMeta, isFieldHidden, joinPath, resetDefaultClientFactory, setDefaultClientFactory } from "@atscript/ui";
6
+ import * as _atscript_typescript_utils0 from "@atscript/typescript/utils";
7
+ import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
6
8
  import { TFnScope } from "@atscript/ui-fns";
7
9
 
8
- //#region ../../node_modules/.pnpm/@atscript+typescript@0.2.3_@atscript+core@0.2.3_@emnapi+core@1.10.0_@emnapi+runtime@1.1_827f363eb78bb82886801a5bf792b425/node_modules/@atscript/typescript/dist/utils.d.ts
9
- interface TError {
10
- path: string;
11
- message: string;
12
- details?: TError[];
13
- }
14
- /**
15
- * A plugin function that can intercept validation.
16
- *
17
- * Return `true` to accept the value, `false` to reject it,
18
- * or `undefined` to fall through to the default validation.
19
- */
20
- type TValidatorPlugin = (ctx: TValidatorPluginContext, def: TAtscriptAnnotatedType, value: any) => boolean | undefined;
21
- /** Options for configuring {@link Validator} behavior. */
22
- interface TValidatorOptions {
23
- partial: boolean | 'deep' | ((type: TAtscriptAnnotatedType<TAtscriptTypeObject>, path: string) => boolean);
24
- replace?: (type: TAtscriptAnnotatedType, path: string) => TAtscriptAnnotatedType;
25
- plugins: TValidatorPlugin[];
26
- unknownProps: 'strip' | 'ignore' | 'error';
27
- errorLimit: number;
28
- skipList?: Set<string>;
29
- }
30
- /** Context exposed to {@link TValidatorPlugin} functions. */
31
- interface TValidatorPluginContext {
32
- opts: Validator<any>['opts'];
33
- /**
34
- * Validates `value` against `def` at the current path (errors go to the current level). With
35
- * `unknownProps: 'strip'`, a call that returns `false` strips nothing: the keys it recorded are
36
- * dropped, as for a rejected union branch, so trying alternatives (`a || b`) strips what the
37
- * union `a | b` would.
38
- */
39
- validateAnnotatedType: Validator<any>['validateAnnotatedType'];
40
- error: Validator<any>['error'];
41
- path: Validator<any>['path'];
42
- /**
43
- * The type the validator was created for — the root of the walk, as passed to the
44
- * constructor (before `replace`). The plugin's `def` argument is the node visited now.
45
- */
46
- readonly root: TAtscriptAnnotatedType;
47
- context: unknown;
48
- }
49
- /**
50
- * Validates values against an {@link TAtscriptAnnotatedType} definition.
51
- *
52
- * `DataType` is automatically inferred from the type definition's phantom generic,
53
- * enabling the {@link validate} method to act as a type guard.
54
- *
55
- * @example
56
- * ```ts
57
- * // From a generated interface class:
58
- * const validator = new Validator(MyInterface)
59
- * if (validator.validate(data, true)) {
60
- * data // narrowed to MyInterface
61
- * }
62
- *
63
- * // Or use the built-in factory:
64
- * MyInterface.validator().validate(data)
65
- * ```
66
- *
67
- * @typeParam T - The annotated type definition.
68
- * @typeParam DataType - The TypeScript type that `validate` narrows to (auto-inferred).
69
- */
70
- declare class Validator<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> {
71
- protected readonly def: T;
72
- protected opts: TValidatorOptions;
73
- protected hasPlugins: boolean;
74
- protected hasReplace: boolean;
75
- private replaceCache?;
76
- constructor(def: T, opts?: Partial<TValidatorOptions>);
77
- /** Validation errors collected during the last {@link validate} call. */
78
- errors: TError[];
79
- protected stackErrors: Array<TError[] | null>;
80
- protected pathSegments: string[];
81
- protected depth: number;
82
- protected limitExceeded: boolean;
83
- protected context: unknown;
84
- /**
85
- * The unions over objects this call decided inside union branches (value → outcomes). A union
86
- * nested in its own branches, many branches each, is reached again with the same value and path
87
- * from every branch of every union above it — (branches)^(depth) work. The memo is made once
88
- * the call has wasted {@link WASTE_BEFORE_MEMO} union branches (failed after branches of nested
89
- * unions over objects failed) since the outermost union, as in the pre-check — ordinary walks
90
- * never make it. It decides each such union once, with the same result and the same error object
91
- * (both depend only on these, the options and the input, which the walk never changes), and
92
- * records the same strips again.
93
- */
94
- private unionMemo?;
95
- /** Union branches being checked (`> 0`: inside a union branch). */
96
- private unionDepth;
97
- /** Failed branches of unions over objects inside union branches (see `unionMemo`). */
98
- private nestedFailures;
99
- /** Wasted union branches since the outermost union was entered (see `unionMemo`). */
100
- private wasted;
101
- /**
102
- * `unknownProps: 'strip'`: the unknown keys of the objects that passed (`object, key, …`), in the
103
- * order the objects completed, then in key order. A rejected union branch, pattern property
104
- * attempt or plugin sub-validation drops what it recorded; the keys are deleted once the whole
105
- * call passes (`performStrips`).
106
- */
107
- private strips;
108
- protected buildPath(): string;
109
- protected push(name: string): void;
110
- protected pop(saveErrors: boolean): TError[] | null | undefined;
111
- protected clear(): void;
112
- protected error(message: string, path?: string, details?: TError[]): TError;
113
- /** Adds `error`, already made, to the errors of the current level (as {@link error} does). */
114
- private report;
115
- protected throw(): void;
116
- /**
117
- * Validates a value against the type definition.
118
- *
119
- * Acts as a TypeScript type guard — when it returns `true`, the value
120
- * is narrowed to `DataType`.
121
- *
122
- * @param value - The value to validate.
123
- * @param safe - If `true`, returns `false` on failure instead of throwing.
124
- * @returns `true` if the value matches the type definition.
125
- * @throws {ValidatorError} When validation fails and `safe` is not `true`.
126
- */
127
- validate<TT = DataType>(value: any, safe?: boolean, context?: unknown): value is TT;
128
- /**
129
- * Plain `Validator` without plugins / `replace`: eligible for the allocation-free
130
- * shortcuts. Subclasses may override the protected `validate*` hooks, so they
131
- * always take the full walk. (A getter, not a constructor-set field: validators are
132
- * often built per call, so construction stays as cheap as before.)
133
- */
134
- private get shortcuts();
135
- /** Validates `value` against `def` (after `replace`, `optional` and the plugins). */
136
- protected validateSafe(def: TAtscriptAnnotatedType, value: any): boolean;
137
- /**
138
- * What {@link validateSafe} decides of `def` (replaced) before its own validation: an
139
- * optional `def` passes `undefined` / `null`, a plugin may decide — `undefined` to go on.
140
- */
141
- private preCheck;
142
- /** The context the plugins get (see {@link pluginContext}), made on the first plugin call. */
143
- private pluginCtx?;
144
- /**
145
- * The plugins' view of this validator: its state read live; `validateAnnotatedType` drops the
146
- * strips a failed call recorded (a failed validation at any level strips nothing).
147
- */
148
- private pluginContext;
149
- /** `def` as the `replace` option replaces it at the current path (memoized per node). */
150
- private replaced;
151
- protected get path(): string;
152
- /** The type this validator was created for (see {@link TValidatorPluginContext.root}). */
153
- protected get root(): T;
154
- protected validateAnnotatedType(def: TAtscriptAnnotatedType, value: any): boolean;
155
- protected validateUnion(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, value: any): boolean;
156
- /** A union branch failed after branches of nested unions over objects did (see `unionMemo`). */
157
- private wasteBranch;
158
- /** The outcome this call recorded for union `def` over `value` at `path` (see `unionMemo`). */
159
- private decided;
160
- /**
161
- * Records the outcome of union `def` over `value` at `path`, entered with `kept` strips (the
162
- * ones after them are its own).
163
- */
164
- private decide;
165
- /**
166
- * Constraints annotated on the union itself (`@expect.min 0` on `number | null`)
167
- * apply to the non-null value that matched `branch`, on top of the branch's own.
168
- * A literal branch (an enum value) is exempt: its value is fixed.
169
- */
170
- protected validateUnionConstraints(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, branch: TAtscriptAnnotatedType, value: any): boolean;
171
- /** Every member must pass, each on its own (JSON Schema `allOf`). */
172
- protected validateIntersection(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, value: any): boolean;
173
- /**
174
- * An unknown key (`unknownProps`): 'error' reports it, 'strip' adds it to the keys to strip
175
- * (returned; recorded in `strips` once the object passed).
176
- */
177
- private unknownKey;
178
- /** The `skipList` keys of the object at the current path. */
179
- private skipListHere;
180
- protected validateTuple(def: TAtscriptAnnotatedType<TAtscriptTypeComplex>, value: any): boolean;
181
- protected validateArray(def: TAtscriptAnnotatedType<TAtscriptTypeArray>, value: any): boolean;
182
- /** `@expect.minLength` / `maxLength` / `array.uniqueItems` checks for an array value. */
183
- protected validateArrayConstraints(meta: TMetadataMap<AtscriptMetadata>, value: any[], of?: TAtscriptAnnotatedType): boolean;
184
- protected validateObject(def: TAtscriptAnnotatedType<TAtscriptTypeObject>, value: any): boolean;
185
- protected validatePrimitive(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: any): boolean;
186
- protected validateString(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: string): boolean;
187
- /** `@meta.required` / `@expect.minLength` / `maxLength` / `pattern` checks for a string value. */
188
- protected validateStringConstraints(meta: TMetadataMap<AtscriptMetadata>, value: string): boolean;
189
- protected validateNumber(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: number): boolean;
190
- /** `@expect.int` / `min` / `max` / `exclusiveMin` / `exclusiveMax` checks for a number value. */
191
- protected validateNumberConstraints(meta: TMetadataMap<AtscriptMetadata>, value: number): boolean;
192
- /** Reports a failed number bound: its custom message, else `Expected <label> <bound>, got <value>`. */
193
- private numberBoundFailed;
194
- protected validateBoolean(def: TAtscriptAnnotatedType<TAtscriptTypeFinal>, value: boolean): boolean;
195
- /** `@meta.required` check for a boolean value (must be `true`). */
196
- protected validateBooleanConstraints(meta: TMetadataMap<AtscriptMetadata>, value: boolean): boolean;
197
- }
198
- /** Error thrown by {@link Validator.validate} when validation fails. Contains structured error details. */
199
- /** Type definition for union, intersection, or tuple types. */
200
- interface TAtscriptTypeComplex<DataType = unknown> {
201
- kind: 'union' | 'intersection' | 'tuple';
202
- items: TAtscriptAnnotatedType[];
203
- tags: Set<AtscriptPrimitiveTags>;
204
- /** @internal phantom — carries the DataType at the type level, never set at runtime */
205
- __dataType?: DataType;
206
- }
207
- /** Type definition for array types. */
208
- interface TAtscriptTypeArray<DataType = unknown[]> {
209
- kind: 'array';
210
- of: TAtscriptAnnotatedType;
211
- tags: Set<AtscriptPrimitiveTags>;
212
- /** @internal phantom — carries the DataType at the type level, never set at runtime */
213
- __dataType?: DataType;
214
- }
215
- /** Type definition for object types with named and pattern-matched properties. */
216
- interface TAtscriptTypeObject<K extends string = string, DataType = Record<K, unknown>> {
217
- kind: 'object';
218
- props: Map<K, TAtscriptAnnotatedType>;
219
- propsPatterns: Array<{
220
- pattern: RegExp;
221
- def: TAtscriptAnnotatedType;
222
- }>;
223
- tags: Set<AtscriptPrimitiveTags>;
224
- /** @internal phantom — carries the DataType at the type level, never set at runtime */
225
- __dataType?: DataType;
226
- }
227
- /** Type definition for primitive/literal types (string, number, boolean, null, etc.). */
228
- interface TAtscriptTypeFinal<DataType = unknown> {
229
- kind: '';
230
- /**
231
- * design type
232
- */
233
- designType: 'string' | 'number' | 'boolean' | 'undefined' | 'null' | 'object' | 'any' | 'never' | 'phantom' | 'decimal';
234
- /**
235
- * value for literals
236
- */
237
- value?: string | number | boolean;
238
- tags: Set<AtscriptPrimitiveTags>;
239
- /** @internal phantom — carries the DataType at the type level, never set at runtime */
240
- __dataType?: DataType;
241
- }
242
- /**
243
- * Extract DataType from a type def's phantom generic
244
- */
245
- type InferDataType<T> = T extends {
246
- __dataType?: infer D;
247
- } ? D : unknown;
248
- /**
249
- * Extract the DataType from a {@link TAtscriptAnnotatedType}.
250
- *
251
- * Resolves the phantom `__dataType` carried by the type definition.
252
- * When `__dataType` is `unknown` (unset), falls back to the constructor
253
- * instance type if `T` is also a class (i.e. a generated interface).
254
- *
255
- * @example
256
- * ```ts
257
- * import type { TAtscriptDataType } from '@atscript/typescript/utils'
258
- * import MyInterface from './my-interface.as'
259
- *
260
- * type Data = TAtscriptDataType<typeof MyInterface>
261
- * ```
262
- */
263
- type TAtscriptDataType<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType> = T extends {
264
- type: {
265
- __dataType?: infer D;
266
- };
267
- } ? unknown extends D ? T extends (new (...args: any[]) => infer I) ? I : unknown : D : unknown;
268
- /** Union of all possible type definition shapes. */
269
- type TAtscriptTypeDef<DataType = unknown> = TAtscriptTypeComplex<DataType> | TAtscriptTypeFinal<DataType> | TAtscriptTypeArray<DataType> | TAtscriptTypeObject<string, DataType>;
270
- /**
271
- * Core annotated type — wraps a type definition with metadata and a validator factory.
272
- *
273
- * Generated `.as` files produce classes/namespaces that conform to this interface.
274
- * The `DataType` phantom generic carries the TypeScript data shape for type-safe validation.
275
- *
276
- * @typeParam T - The underlying type definition (e.g. {@link TAtscriptTypeObject}).
277
- * @typeParam DataType - The TypeScript type the validated data narrows to (auto-inferred from `T`).
278
- */
279
- interface TAtscriptAnnotatedType<T extends TAtscriptTypeDef = TAtscriptTypeDef, DataType = InferDataType<T>> {
280
- __is_atscript_annotated_type: true;
281
- type: T;
282
- validator(opts?: Partial<TValidatorOptions>): Validator<this, DataType>;
283
- metadata: TMetadataMap<AtscriptMetadata>;
284
- optional?: boolean;
285
- id?: string;
286
- ref?: {
287
- type: () => TAtscriptAnnotatedType;
288
- field: string;
289
- };
290
- }
291
- /** An annotated type that is also a class constructor (i.e. a generated interface class). */
292
- /**
293
- * Atscript Metadata Map with typed setters/getters
294
- */
295
- interface TMetadataMap<O extends object> extends Map<keyof O, O[keyof O]> {
296
- get<K extends keyof O>(key: K): O[K] | undefined;
297
- get(key: string): unknown;
298
- set<K extends keyof O>(key: K, value: O[K]): this;
299
- has<K extends keyof O>(key: K): boolean;
300
- has(key: string): boolean;
301
- }
302
- /** Fluent builder handle returned by {@link defineAnnotatedType}. */
303
- //#endregion
304
10
  //#region src/composables/create-as-form-def.d.ts
305
11
  /**
306
12
  * Creates a reactive form definition and data object from an ATScript annotated type.
@@ -308,12 +14,14 @@ interface TMetadataMap<O extends object> extends Map<keyof O, O[keyof O]> {
308
14
  * @param type - An ATScript annotated type (imported from a `.as` file).
309
15
  * @param context - Optional context object forwarded to `ui.fn.value` resolvers during data creation.
310
16
  * Only effective when `@atscript/ui-fns` is installed (dynamic resolver).
17
+ * @param opts - Options for `createFormDef`: `mode: "edit"` for a form that edits a stored row,
18
+ * `versionColumn`, `metaFields`.
311
19
  * @returns `{ def, formData }` — the FormDef and a Vue reactive data object with defaults applied
312
20
  */
313
- declare function createAsFormDef<T extends TAtscriptAnnotatedType>(type: T, context?: Record<string, unknown>): {
21
+ declare function createAsFormDef<T extends TAtscriptAnnotatedType>(type: T, context?: Record<string, unknown>, opts?: CreateFormDefOptions): {
314
22
  def: _atscript_ui0.FormDef;
315
23
  formData: {
316
- value: vue.UnwrapRef<TAtscriptDataType<T>>;
24
+ value: vue.UnwrapRef<_atscript_typescript_utils0.TAtscriptDataType<T>>;
317
25
  };
318
26
  };
319
27
  //#endregion
@@ -598,16 +306,25 @@ interface UseAsFormOptions<TFormData = unknown, TFormContext = unknown> {
598
306
  * `defineEmits`; advanced uses can pass plain functions.
599
307
  */
600
308
  emits?: {
601
- submit?: (data: TFormData) => void;
309
+ submit?: (data: TAsFormValue<TFormData>) => void;
602
310
  error?: (errors: {
603
311
  path: string;
604
312
  message: string;
605
313
  }[]) => void;
606
- action?: (name: string, data: TFormData) => void;
607
- unsupportedAction?: (name: string, data: TFormData) => void;
608
- change?: (type: TAsChangeType, path: string, value: unknown, formData: TFormData) => void;
314
+ action?: (name: string, data: TAsFormValue<TFormData>) => void;
315
+ unsupportedAction?: (name: string, data: TAsFormValue<TFormData>) => void;
316
+ change?: (type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>) => void;
609
317
  };
610
318
  }
319
+ /**
320
+ * The value inside a `{ value }` form-data container (`value` may be
321
+ * optional): what the `submit`, `action`, `unsupportedAction` and `change`
322
+ * callbacks (and `<AsForm>`'s events) receive. `any` for an `any` container,
323
+ * `unknown` when the container has no `value`.
324
+ */
325
+ type TAsFormValue<TFormData> = 0 extends 1 & TFormData ? any : TFormData extends {
326
+ value?: infer V;
327
+ } ? V : unknown;
611
328
  interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
612
329
  /** Reactive form-data container `{ value: domainData }`. */
613
330
  data: ComputedRef<TFormData>;
@@ -1355,10 +1072,26 @@ interface UseAsDataReturn {
1355
1072
  getValueAt: (path: string) => ComputedRef<unknown>;
1356
1073
  /** Read a sibling field's value relative to the current `useAsPath()` prefix. */
1357
1074
  siblingValue: <T = unknown>(name: string) => ComputedRef<T | undefined>;
1075
+ /**
1076
+ * Write the value at an absolute dotted path inside the form (missing
1077
+ * containers are created: an array where the next segment is an index,
1078
+ * else an object; an empty form root too). The write is a committed edit:
1079
+ * change tracking sees it, the field at that path re-validates like one the
1080
+ * user changed, and `AsForm` emits `change` with type `"update"`. Outside a
1081
+ * form, a no-op.
1082
+ */
1083
+ setValueAt: (path: string, value: unknown) => void;
1084
+ /**
1085
+ * Write a sibling field's value, relative to the current `useAsPath()`
1086
+ * prefix — e.g. a custom picker filling the fields next to it. Same rules
1087
+ * as `setValueAt`.
1088
+ */
1089
+ setSibling: (name: string, value: unknown) => void;
1358
1090
  }
1359
1091
  /**
1360
- * Reactive read-only access to form data at any point in the
1361
- * `<AsForm>` tree. Outside a form, all readers return `undefined`.
1092
+ * Reactive access to form data at any point in the `<AsForm>` tree: readers
1093
+ * plus `setValueAt` / `setSibling` writers. Outside a form, all readers
1094
+ * return `undefined` and the writers do nothing.
1362
1095
  *
1363
1096
  * Call sites get a `ComputedRef` so they can compose it directly with
1364
1097
  * other reactive primitives without an extra `computed()` wrapper.
@@ -1390,8 +1123,8 @@ interface Props<TF, TC> {
1390
1123
  components?: Record<string, Component<TAsComponentProps>>;
1391
1124
  /**
1392
1125
  * Type-to-component map for field rendering. Maps field types to Vue components.
1393
- * Must include entries for all built-in field types. Use `createDefaultTypes()`
1394
- * for a pre-filled map, or supply your own.
1126
+ * Use `createDefaultTypes()` for a pre-filled map, or supply your own — it
1127
+ * needs entries only for the types its forms use.
1395
1128
  */
1396
1129
  types: TAsTypeComponents;
1397
1130
  errors?: Record<string, string | undefined>;
@@ -1441,10 +1174,10 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1441
1174
  path: string;
1442
1175
  message: string;
1443
1176
  }[]) => any) | undefined;
1444
- onAction?: ((name: string, data: TFormData) => any) | undefined;
1445
- onSubmit?: ((data: TFormData) => any) | undefined;
1446
- "onUnsupported-action"?: ((name: string, data: TFormData) => any) | undefined;
1447
- onChange?: ((type: TAsChangeType, path: string, value: unknown, formData: TFormData) => any) | undefined;
1177
+ onAction?: ((name: string, data: TAsFormValue<TFormData>) => any) | undefined;
1178
+ onSubmit?: ((data: TAsFormValue<TFormData>) => any) | undefined;
1179
+ "onUnsupported-action"?: ((name: string, data: TAsFormValue<TFormData>) => any) | undefined;
1180
+ onChange?: ((type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>) => any) | undefined;
1448
1181
  }> & (typeof globalThis extends {
1449
1182
  __VLS_PROPS_FALLBACK: infer P;
1450
1183
  } ? P : {});
@@ -1637,14 +1370,14 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1637
1370
  }) => any;
1638
1371
  };
1639
1372
  emit: {
1640
- (e: "submit", data: TFormData): void;
1373
+ (e: "submit", data: TAsFormValue<TFormData>): void;
1641
1374
  (e: "error", errors: {
1642
1375
  path: string;
1643
1376
  message: string;
1644
1377
  }[]): void;
1645
- (e: "action", name: string, data: TFormData): void;
1646
- (e: "unsupported-action", name: string, data: TFormData): void;
1647
- (e: "change", type: TAsChangeType, path: string, value: unknown, formData: TFormData): void;
1378
+ (e: "action", name: string, data: TAsFormValue<TFormData>): void;
1379
+ (e: "unsupported-action", name: string, data: TAsFormValue<TFormData>): void;
1380
+ (e: "change", type: TAsChangeType, path: string, value: unknown, formData: TAsFormValue<TFormData>): void;
1648
1381
  };
1649
1382
  }>) => vue.VNode & {
1650
1383
  __ctx?: Awaited<typeof __VLS_setup>;
@@ -1652,4 +1385,4 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
1652
1385
  declare const _default: typeof __VLS_export;
1653
1386
  type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
1654
1387
  //#endregion
1655
- export { AsNestedSectionsStore as $, UseAsDecimalOptions as A, TFormFieldCallbacks as At, UseAsOptionalAddFlowReturn as B, useAsDate as C, useAsFormPatch as Ct, UseAsNumberOptions as D, UseAsFieldOptions as Dt, useAsDualInput as E, useAsState as Et, useAsLocale as F, createAsFormDef as Ft, useAsVisibleFields as G, focusFirstAfter as H, UseAsTriStateCheckboxOptions as I, TResolveFieldPropOptions as J, UseAsOptionalFieldReturn as K, UseAsTriStateCheckboxReturn as L, useAsDecimal as M, TFormRule as Mt, UseAsLocaleReturn as N, TFormState as Nt, UseAsNumberReturn as O, UseAsFieldReturn as Ot, provideAsLocale as P, createDefaultTypes as Pt, useAsLevel as Q, useAsTriStateCheckbox as R, UseAsDateReturn as S, RebaseOntoResult as St, UseAsDualInputReturn as T, UseAsStateReturn as Tt, focusNewFocusableAfter as U, useAsOptionalAddFlow as V, useAsFocusFirstAfter as W, useAsFieldScope as X, UseAsFieldScopeReturn as Y, provideAsNestedLevel as Z, UseAsTypeMapReturn as _, useAsExternalErrors as _t, FormFieldChange$1 as a, UseAsValueHelpReturn as at, useAsPath as b, useAsForm as bt, hasFieldMeta as c, useAsUnionVariant as ct, resetDefaultClientFactory as d, UseAsTupleReturn as dt, provideAsNestedSectionsStore as et, setDefaultClientFactory as f, useAsTuple as ft, useAsData as g, UseAsExternalErrorsReturn as gt, UseAsDataReturn as h, UseAsExternalErrorsOptions as ht, FormDiffOptions$1 as i, UseAsValueHelpOptions as it, UseAsDecimalReturn as j, TFormFieldRegistration as jt, useAsNumber as k, useAsField as kt, isFieldHidden as l, UseAsUnionReturn as lt, useAsErrorDismiss as m, useAsArray as mt, _default as n, useAsNestedSectionsStore as nt, FormRebaseOptions$1 as o, useAsValueHelp as ot, AsErrorDismiss as p, UseAsArrayReturn as pt, useAsOptionalField as q, ClientFactory$1 as r, useAsDropdown as rt, getDefaultClientFactory as s, formatIndexedLabelParts as st, Props as t, useAsDescendantErrorCounts as tt, joinPath as u, useAsUnion as ut, useAsTypeMap as v, UseAsFormOptions as vt, UseAsDualInputOptions as w, TFormSubmitValidator as wt, UseAsDateOptions as x, AsFormPatchHandle as xt, UseAsPathReturn as y, UseAsFormReturn as yt, UseAsOptionalAddFlowOptions as z };
1388
+ export { useAsLevel as $, useAsNumber as A, UseAsFieldReturn as At, UseAsOptionalAddFlowOptions as B, UseAsDateReturn as C, AsFormPatchHandle as Ct, useAsDualInput as D, UseAsStateReturn as Dt, UseAsDualInputReturn as E, TFormSubmitValidator as Et, provideAsLocale as F, TFormState as Ft, useAsFocusFirstAfter as G, useAsOptionalAddFlow as H, useAsLocale as I, createDefaultTypes as It, useAsOptionalField as J, useAsVisibleFields as K, UseAsTriStateCheckboxOptions as L, createAsFormDef as Lt, UseAsDecimalReturn as M, TFormFieldCallbacks as Mt, useAsDecimal as N, TFormFieldRegistration as Nt, UseAsNumberOptions as O, useAsState as Ot, UseAsLocaleReturn as P, TFormRule as Pt, provideAsNestedLevel as Q, UseAsTriStateCheckboxReturn as R, UseAsDateOptions as S, useAsForm as St, UseAsDualInputOptions as T, useAsFormPatch as Tt, focusFirstAfter as U, UseAsOptionalAddFlowReturn as V, focusNewFocusableAfter as W, UseAsFieldScopeReturn as X, TResolveFieldPropOptions as Y, useAsFieldScope as Z, useAsData as _, UseAsExternalErrorsReturn as _t, FormFieldChange$1 as a, UseAsValueHelpOptions as at, UseAsPathReturn as b, UseAsFormOptions as bt, getDefaultClientFactory as c, formatIndexedLabelParts as ct, joinPath as d, useAsUnion as dt, AsNestedSectionsStore as et, resetDefaultClientFactory as f, UseAsTupleReturn as ft, UseAsDataReturn as g, UseAsExternalErrorsOptions as gt, useAsErrorDismiss as h, useAsArray as ht, FormDiffOptions$1 as i, useAsDropdown as it, UseAsDecimalOptions as j, useAsField as jt, UseAsNumberReturn as k, UseAsFieldOptions as kt, hasFieldMeta as l, useAsUnionVariant as lt, AsErrorDismiss as m, UseAsArrayReturn as mt, _default as n, useAsDescendantErrorCounts as nt, FormRebaseOptions$1 as o, UseAsValueHelpReturn as ot, setDefaultClientFactory as p, useAsTuple as pt, UseAsOptionalFieldReturn as q, ClientFactory$1 as r, useAsNestedSectionsStore as rt, TypedClientFactory as s, useAsValueHelp as st, Props as t, provideAsNestedSectionsStore as tt, isFieldHidden as u, UseAsUnionReturn as ut, UseAsTypeMapReturn as v, useAsExternalErrors as vt, useAsDate as w, RebaseOntoResult as wt, useAsPath as x, UseAsFormReturn as xt, useAsTypeMap as y, TAsFormValue as yt, useAsTriStateCheckbox as z };