@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/vue-form",
3
- "version": "0.1.181",
3
+ "version": "0.1.182",
4
4
  "description": "Type-driven form rendering for Atscript with Vue 3",
5
5
  "keywords": [
6
6
  "atscript",
@@ -165,27 +165,27 @@
165
165
  "access": "public"
166
166
  },
167
167
  "dependencies": {
168
- "@atscript/ui": "^0.1.181",
169
- "@atscript/ui-fns": "^0.1.181"
168
+ "@atscript/ui": "^0.1.182",
169
+ "@atscript/ui-fns": "^0.1.182"
170
170
  },
171
171
  "devDependencies": {
172
- "@atscript/core": "^0.2.15",
173
- "@atscript/db-client": "^0.1.187",
174
- "@atscript/typescript": "^0.2.15",
172
+ "@atscript/core": "^0.2.16",
173
+ "@atscript/db-client": "^0.1.188",
174
+ "@atscript/typescript": "^0.2.16",
175
175
  "@tsdown/css": "^0.21.4",
176
176
  "@vitejs/plugin-vue": "^6",
177
177
  "@vue/test-utils": "^2",
178
178
  "happy-dom": "^18",
179
179
  "reka-ui": "^2.9.8",
180
- "unplugin-atscript": "^0.2.15",
180
+ "unplugin-atscript": "^0.2.16",
181
181
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
182
182
  "vue": "^3",
183
183
  "vue-tsc": "~3.2.9",
184
- "vunor": "^0.4.4"
184
+ "vunor": "^0.4.5"
185
185
  },
186
186
  "peerDependencies": {
187
- "@atscript/db-client": "^0.1.187",
188
- "@atscript/typescript": "^0.2.15",
187
+ "@atscript/db-client": "^0.1.188",
188
+ "@atscript/typescript": "^0.2.16",
189
189
  "reka-ui": "^2.9.8",
190
190
  "vue": "^3"
191
191
  },
@@ -1,309 +0,0 @@
1
- import { Component, Ref } from "vue";
2
- import { FormFieldDef, FormUnionVariant, TFormAction, TFormEntryOptions, ValueHelpInfo } from "@atscript/ui";
3
-
4
- //#region src/components/types.d.ts
5
- /**
6
- * Shared base props available to all custom form components.
7
- */
8
- interface TAsBaseComponentProps {
9
- /** Whether this component is disabled. */
10
- disabled?: boolean;
11
- /** Whether this component is hidden. */
12
- hidden?: boolean;
13
- }
14
- /**
15
- * Props contract for custom field components used with `AsForm` / `AsField`.
16
- *
17
- * Implement this interface in your UI components so that `AsField` can pass
18
- * all resolved field state (value, label, validation errors, etc.) as props.
19
- *
20
- * @typeParam V - The field value type
21
- * @typeParam TFormData - The full form data object type
22
- * @typeParam TFormContext - The external context object type
23
- */
24
- interface TAsComponentProps<V = unknown> extends TAsBaseComponentProps {
25
- /** Called on field blur — triggers validation. */
26
- onBlur: () => void;
27
- /** Validation error message for this field, if any. */
28
- error?: string;
29
- /** Reactive model wrapping the field value. Bind with `v-model="model.value"`. */
30
- model: {
31
- value: V;
32
- };
33
- /** Phantom field display value from `@meta.default` / `@ui.form.fn.value` (paragraphs, actions). `undefined` for data fields. */
34
- value?: unknown;
35
- /** Resolved field label from `@meta.label` or `@ui.form.fn.label`. */
36
- label?: string;
37
- /** Resolved field description from `@meta.description` or `@ui.form.fn.description`. */
38
- description?: string;
39
- /** Resolved hint text from `@ui.form.hint` or `@ui.form.fn.hint`. */
40
- hint?: string;
41
- /** Resolved placeholder from `@ui.form.placeholder` or `@ui.form.fn.placeholder`. */
42
- placeholder?: string;
43
- /** Resolved CSS class painting the prefix icon glyph from `@ui.form.prefix.icon`. Consumer manages safelist / preset coverage. Rendered as the leftmost adornment, before the `prefix` text. */
44
- prefixIcon?: string;
45
- /** Resolved CSS class painting the suffix icon glyph from `@ui.form.suffix.icon`. Consumer manages safelist / preset coverage. Rendered as the rightmost adornment, after the `suffix` text. */
46
- suffixIcon?: string;
47
- /** CSS class(es) from `@ui.form.classes` or `@ui.form.fn.classes`. */
48
- class?: Record<string, boolean> | string;
49
- /** Inline styles from `@ui.form.styles` or `@ui.form.fn.styles`. */
50
- style?: Record<string, string> | string;
51
- /** Whether the field is optional (not required). */
52
- optional?: boolean | undefined;
53
- /** Toggle an optional field on/off. `true` sets default value; `false` sets `undefined`. Only present when `optional` is true. */
54
- onToggleOptional?: (enabled: boolean) => void;
55
- /** Whether the field is required (inverse of optional). */
56
- required?: boolean | undefined;
57
- /** Whether the field is read-only. */
58
- readonly?: boolean | undefined;
59
- /** The resolved field input type (e.g., `'text'`, `'select'`, `'checkbox'`). */
60
- type: string;
61
- /** Form action from `@ui.form.action`. Contains the action id and display label. */
62
- formAction?: TFormAction;
63
- /** The field name (last segment of the dot-separated path). */
64
- name?: string;
65
- /** The full FormFieldDef for advanced use cases. */
66
- field?: FormFieldDef;
67
- /** Resolved options for select/radio/checkbox fields. */
68
- options?: TFormEntryOptions[];
69
- /** Max length constraint from `@expect.maxLength`. */
70
- maxLength?: number;
71
- /** Autocomplete hint from `@ui.form.autocomplete`. */
72
- autocomplete?: string;
73
- /** Resolved title from `@ui.form.fn.title` / `@meta.label` for structure/array fields. */
74
- title?: string;
75
- /** Nesting level for structure/array fields. Root structure is 0, each nested structure/array increments by 1. */
76
- level?: number;
77
- /** Callback to remove this item from its parent array. Present when rendered inside an array. */
78
- onRemove?: () => void;
79
- /** Whether removal is allowed (respects minLength constraints). */
80
- canRemove?: boolean;
81
- /** Label for the remove button (from `@ui.array.remove.label`). */
82
- removeLabel?: string;
83
- /** Zero-based index when rendered as a direct array item. `undefined` otherwise. */
84
- arrayIndex?: number;
85
- /** Absolute dotted path to this field inside the form data. Empty string at the root. */
86
- path: string;
87
- /** Resolved value-help descriptor for FK ref fields (`@db.rel.FK` → `@db.http.path`). */
88
- valueHelp?: ValueHelpInfo;
89
- /** Singular label for array fields (`@ui.form.label.singular`) — used in "Add <singular>" affordances. */
90
- singularLabel?: string;
91
- /** Stable input element id, suitable for `<label :for>`. Co-resolved with `errorId` / `descId` so a11y wiring is consistent. Always populated by AsField. */
92
- inputId: string;
93
- /** Stable id for the error/hint container. Pair with `aria-describedby` (already resolved as `ariaDescribedBy`). Always populated by AsField. */
94
- errorId: string;
95
- /** Stable id for the description container. Always populated by AsField. */
96
- descId: string;
97
- /**
98
- * Stable id for the field's a11y status node — the screen-reader-only
99
- * "modified" announcement rendered by `AsFieldShell`'s `status` slot.
100
- * Always populated by AsField; a custom `status` slot that renders its own
101
- * node must put this id on it so `aria-describedby` still resolves.
102
- *
103
- * Optional in the type (unlike the `inputId` / `errorId` / `descId` trio) so
104
- * code that mounts `AsFieldShell` standalone against the pre-0.1.133 prop set
105
- * keeps type-checking — the shell falls back to `` `${inputId}-status` ``.
106
- *
107
- * @since 0.1.133
108
- */
109
- statusId?: string;
110
- /**
111
- * Pre-resolved `aria-describedby` target — `errorId` when error/hint is
112
- * present, else `descId`; `statusId` is appended (space-separated) while the
113
- * field is dirty, so AT reads the "modified" status together with the
114
- * error/description. `undefined` when there is nothing to point at.
115
- */
116
- ariaDescribedBy?: string;
117
- /**
118
- * Resolved currency code (post-sibling resolution).
119
- *
120
- * Resolution chain at AsField: `@db.amount.currency 'EUR'` literal →
121
- * `@db.amount.currency.ref 'fieldName'` sibling-field read → `undefined`.
122
- * Useful for tooltips/titles (e.g. hovering an AsDecimal shell shows
123
- * "USD"). Note: when `prefix` is also resolved from currency, the
124
- * `currencyCode` here is the symbolic identifier; `prefix` carries
125
- * the locale-aware narrow symbol.
126
- */
127
- currencyCode?: string;
128
- /**
129
- * Resolved unit-of-measure code (post-sibling resolution).
130
- *
131
- * Resolution chain at AsField: `@db.unit 'kg'` literal →
132
- * `@db.unit.ref 'fieldName'` sibling-field read → `undefined`. Useful
133
- * for tooltips. Note: when `suffix` is also resolved from `@db.unit*`,
134
- * `unitCode` and `suffix` carry the same string.
135
- */
136
- unitCode?: string;
137
- /**
138
- * Decimal scale storage cap (the DB column's fractional-digit limit) —
139
- * raw second arg of `@db.column.precision precision, scale`. The
140
- * composables pad outgoing strings to this; for display, use `scale`
141
- * (which may be tighter due to currency natural digits).
142
- */
143
- precisionScale?: number;
144
- /**
145
- * Resolved input prefix adornment.
146
- *
147
- * Resolution chain at AsField: explicit `@ui.form.prefix 'value'` →
148
- * `@ui.form.prefix.ref 'fieldName'` sibling-field read → currency
149
- * symbol (locale-narrow form, when currency is resolved) → `undefined`.
150
- * Applied by AsInput, AsNumber, AsDecimal.
151
- */
152
- prefix?: string;
153
- /**
154
- * Resolved input suffix adornment.
155
- *
156
- * Resolution chain at AsField: explicit `@ui.form.suffix 'value'` →
157
- * `@ui.form.suffix.ref 'fieldName'` sibling-field read → unit code
158
- * (resolved `unitCode`) → `undefined`. Applied by AsInput, AsNumber,
159
- * AsDecimal.
160
- */
161
- suffix?: string;
162
- /**
163
- * Effective display scale (fractional digits) — composables enforce
164
- * this when editing decimals.
165
- *
166
- * Resolution: `min(currencyDecimals, precisionScale)` when currency is
167
- * resolved, else `currencyDecimals` (currency only), else
168
- * `precisionScale` (DB only), else `undefined`. Smaller than
169
- * `precisionScale` is fine — storage stays at the DB cap, display
170
- * truncates to this.
171
- */
172
- scale?: number;
173
- /**
174
- * Whether AsField found at least one adornment-driving annotation on
175
- * this field (`@db.amount.currency*`, `@db.unit*`, `@ui.form.prefix*`,
176
- * `@ui.form.suffix*`). Used by AsNumber / AsDecimal to keep the
177
- * merged-chrome shell visible even when a sibling-ref source is
178
- * currently empty — without this flag, the shell would flicker as
179
- * the user picks a source value.
180
- *
181
- * Always populated by AsField; defaults to `false` when no adornment
182
- * annotation is present on the prop.
183
- */
184
- hasAdornment?: boolean;
185
- /**
186
- * Whether this field has changed since the change-tracking baseline.
187
- *
188
- * `true` only when the enclosing `<AsForm>` has `track-changes` enabled AND
189
- * this field's value differs from the baseline; `false` (or absent) when
190
- * tracking is off. AsField resolves it from the change list and surfaces it
191
- * here so default components — and custom swaps — can drive a visual hook
192
- * (the default `AsFieldShell` paints a `data-dirty` attribute from it) without
193
- * re-deriving the predicate. Granularity matches the change list: object /
194
- * section containers light up via their leaves; whole-array fields exactly;
195
- * an array-ITEM field stays `false` (the array container lights up instead).
196
- */
197
- isDirty?: boolean;
198
- }
199
- /**
200
- * Public emits contract for custom field components used with `AsForm` /
201
- * `AsField`. Type your `defineEmits` against this interface so the
202
- * action-button surface stays compatible with the framework.
203
- *
204
- * `_V` is reserved for forward-compat with value-typed emits in Phase 4
205
- * (e.g. `(e: 'change-value', value: _V)`); the underscore prefix marks it
206
- * as deliberately unused under both biome and eslint conventions.
207
- *
208
- * @typeParam _V - The field value type (reserved for future emits)
209
- */
210
- interface TAsComponentEmits<_V = unknown> {
211
- /**
212
- * Action invocation — emitted by phantom action buttons. The form
213
- * routes the named action through its `@action` handler.
214
- */
215
- (e: "action", name: string): void;
216
- }
217
- /**
218
- * Discriminated type for the `change` event emitted by `AsForm`.
219
- *
220
- * - `'update'` — leaf field value committed (blur)
221
- * - `'array-add'` — array item added
222
- * - `'array-remove'` — array item removed
223
- * - `'union-switch'` — union variant switched
224
- */
225
- type TAsChangeType = "update" | "array-add" | "array-remove" | "union-switch";
226
- /**
227
- * Type-to-component map for `AsForm`. Lists the built-in field types and
228
- * accepts additional custom types via index signature. Every key is optional:
229
- * a map may name only the types its forms use (a field whose type has no
230
- * entry renders a "No component" notice).
231
- *
232
- * Use {@link createDefaultTypes} to get a pre-built map with all defaults.
233
- */
234
- type TAsTypeComponents = {
235
- text?: Component;
236
- textarea?: Component;
237
- password?: Component;
238
- select?: Component;
239
- multiselect?: Component;
240
- tags?: Component;
241
- radio?: Component;
242
- checkbox?: Component;
243
- paragraph?: Component;
244
- action?: Component;
245
- object?: Component;
246
- array?: Component;
247
- union?: Component;
248
- tuple?: Component;
249
- ref?: Component;
250
- decimal?: Component;
251
- number?: Component;
252
- date?: Component;
253
- datetime?: Component;
254
- time?: Component;
255
- } & Record<string, Component>;
256
- /**
257
- * Union context provided by `AsUnion` via `UNION_CONTEXT_KEY`.
258
- * Consumed by `AsFieldShell` to render the variant picker inline with the
259
- * item's own header.
260
- */
261
- interface TAsUnionContext {
262
- /** All available union variant branches. */
263
- variants: FormUnionVariant[];
264
- /** Reactive index of the currently selected variant. */
265
- currentIndex: Ref<number>;
266
- /** Switch to a different variant (rewrites model data). */
267
- changeVariant: (index: number) => void;
268
- }
269
- /**
270
- * Public props contract for the standalone `AsCollapsible` section component.
271
- */
272
- interface TAsCollapsibleProps {
273
- title?: string;
274
- description?: string;
275
- level: number;
276
- optional?: boolean;
277
- optionalEnabled?: boolean;
278
- path: string;
279
- error?: string;
280
- defaultOpen?: boolean;
281
- hidden?: boolean;
282
- arrayIndex?: number;
283
- /**
284
- * Whether the section this collapsible wraps has changed since the
285
- * change-tracking baseline. Forwarded by the structured defaults
286
- * (`AsObject` / `AsArray` / `AsTuple`) from their own `isDirty` prop, which
287
- * `AsField` resolves from the change list. `AsCollapsible` paints
288
- * `data-dirty=""` on its root and on its heading element ONLY — never on
289
- * descendants — so a dirty container does not make every child label inside
290
- * it look modified. Styling hook: `as-collapsible-section` /
291
- * `as-collapsible-island` / `as-collapsible-title*` (see
292
- * `@atscript/ui-styles`).
293
- *
294
- * @since 0.1.133
295
- */
296
- isDirty?: boolean;
297
- }
298
- /**
299
- * Slots exposed by `AsCollapsible` — all header slots render inside `<summary>`.
300
- */
301
- interface TAsCollapsibleSlots {
302
- "title-extras"(): unknown;
303
- badges(): unknown;
304
- actions(): unknown;
305
- body(): unknown;
306
- empty(): unknown;
307
- }
308
- //#endregion
309
- export { TAsComponentEmits as a, TAsUnionContext as c, TAsCollapsibleSlots as i, TAsChangeType as n, TAsComponentProps as o, TAsCollapsibleProps as r, TAsTypeComponents as s, TAsBaseComponentProps as t };
@@ -1,309 +0,0 @@
1
- import { Component, Ref } from "vue";
2
- import { FormFieldDef, FormUnionVariant, TFormAction, TFormEntryOptions, ValueHelpInfo } from "@atscript/ui";
3
-
4
- //#region src/components/types.d.ts
5
- /**
6
- * Shared base props available to all custom form components.
7
- */
8
- interface TAsBaseComponentProps {
9
- /** Whether this component is disabled. */
10
- disabled?: boolean;
11
- /** Whether this component is hidden. */
12
- hidden?: boolean;
13
- }
14
- /**
15
- * Props contract for custom field components used with `AsForm` / `AsField`.
16
- *
17
- * Implement this interface in your UI components so that `AsField` can pass
18
- * all resolved field state (value, label, validation errors, etc.) as props.
19
- *
20
- * @typeParam V - The field value type
21
- * @typeParam TFormData - The full form data object type
22
- * @typeParam TFormContext - The external context object type
23
- */
24
- interface TAsComponentProps<V = unknown> extends TAsBaseComponentProps {
25
- /** Called on field blur — triggers validation. */
26
- onBlur: () => void;
27
- /** Validation error message for this field, if any. */
28
- error?: string;
29
- /** Reactive model wrapping the field value. Bind with `v-model="model.value"`. */
30
- model: {
31
- value: V;
32
- };
33
- /** Phantom field display value from `@meta.default` / `@ui.form.fn.value` (paragraphs, actions). `undefined` for data fields. */
34
- value?: unknown;
35
- /** Resolved field label from `@meta.label` or `@ui.form.fn.label`. */
36
- label?: string;
37
- /** Resolved field description from `@meta.description` or `@ui.form.fn.description`. */
38
- description?: string;
39
- /** Resolved hint text from `@ui.form.hint` or `@ui.form.fn.hint`. */
40
- hint?: string;
41
- /** Resolved placeholder from `@ui.form.placeholder` or `@ui.form.fn.placeholder`. */
42
- placeholder?: string;
43
- /** Resolved CSS class painting the prefix icon glyph from `@ui.form.prefix.icon`. Consumer manages safelist / preset coverage. Rendered as the leftmost adornment, before the `prefix` text. */
44
- prefixIcon?: string;
45
- /** Resolved CSS class painting the suffix icon glyph from `@ui.form.suffix.icon`. Consumer manages safelist / preset coverage. Rendered as the rightmost adornment, after the `suffix` text. */
46
- suffixIcon?: string;
47
- /** CSS class(es) from `@ui.form.classes` or `@ui.form.fn.classes`. */
48
- class?: Record<string, boolean> | string;
49
- /** Inline styles from `@ui.form.styles` or `@ui.form.fn.styles`. */
50
- style?: Record<string, string> | string;
51
- /** Whether the field is optional (not required). */
52
- optional?: boolean | undefined;
53
- /** Toggle an optional field on/off. `true` sets default value; `false` sets `undefined`. Only present when `optional` is true. */
54
- onToggleOptional?: (enabled: boolean) => void;
55
- /** Whether the field is required (inverse of optional). */
56
- required?: boolean | undefined;
57
- /** Whether the field is read-only. */
58
- readonly?: boolean | undefined;
59
- /** The resolved field input type (e.g., `'text'`, `'select'`, `'checkbox'`). */
60
- type: string;
61
- /** Form action from `@ui.form.action`. Contains the action id and display label. */
62
- formAction?: TFormAction;
63
- /** The field name (last segment of the dot-separated path). */
64
- name?: string;
65
- /** The full FormFieldDef for advanced use cases. */
66
- field?: FormFieldDef;
67
- /** Resolved options for select/radio/checkbox fields. */
68
- options?: TFormEntryOptions[];
69
- /** Max length constraint from `@expect.maxLength`. */
70
- maxLength?: number;
71
- /** Autocomplete hint from `@ui.form.autocomplete`. */
72
- autocomplete?: string;
73
- /** Resolved title from `@ui.form.fn.title` / `@meta.label` for structure/array fields. */
74
- title?: string;
75
- /** Nesting level for structure/array fields. Root structure is 0, each nested structure/array increments by 1. */
76
- level?: number;
77
- /** Callback to remove this item from its parent array. Present when rendered inside an array. */
78
- onRemove?: () => void;
79
- /** Whether removal is allowed (respects minLength constraints). */
80
- canRemove?: boolean;
81
- /** Label for the remove button (from `@ui.array.remove.label`). */
82
- removeLabel?: string;
83
- /** Zero-based index when rendered as a direct array item. `undefined` otherwise. */
84
- arrayIndex?: number;
85
- /** Absolute dotted path to this field inside the form data. Empty string at the root. */
86
- path: string;
87
- /** Resolved value-help descriptor for FK ref fields (`@db.rel.FK` → `@db.http.path`). */
88
- valueHelp?: ValueHelpInfo;
89
- /** Singular label for array fields (`@ui.form.label.singular`) — used in "Add <singular>" affordances. */
90
- singularLabel?: string;
91
- /** Stable input element id, suitable for `<label :for>`. Co-resolved with `errorId` / `descId` so a11y wiring is consistent. Always populated by AsField. */
92
- inputId: string;
93
- /** Stable id for the error/hint container. Pair with `aria-describedby` (already resolved as `ariaDescribedBy`). Always populated by AsField. */
94
- errorId: string;
95
- /** Stable id for the description container. Always populated by AsField. */
96
- descId: string;
97
- /**
98
- * Stable id for the field's a11y status node — the screen-reader-only
99
- * "modified" announcement rendered by `AsFieldShell`'s `status` slot.
100
- * Always populated by AsField; a custom `status` slot that renders its own
101
- * node must put this id on it so `aria-describedby` still resolves.
102
- *
103
- * Optional in the type (unlike the `inputId` / `errorId` / `descId` trio) so
104
- * code that mounts `AsFieldShell` standalone against the pre-0.1.133 prop set
105
- * keeps type-checking — the shell falls back to `` `${inputId}-status` ``.
106
- *
107
- * @since 0.1.133
108
- */
109
- statusId?: string;
110
- /**
111
- * Pre-resolved `aria-describedby` target — `errorId` when error/hint is
112
- * present, else `descId`; `statusId` is appended (space-separated) while the
113
- * field is dirty, so AT reads the "modified" status together with the
114
- * error/description. `undefined` when there is nothing to point at.
115
- */
116
- ariaDescribedBy?: string;
117
- /**
118
- * Resolved currency code (post-sibling resolution).
119
- *
120
- * Resolution chain at AsField: `@db.amount.currency 'EUR'` literal →
121
- * `@db.amount.currency.ref 'fieldName'` sibling-field read → `undefined`.
122
- * Useful for tooltips/titles (e.g. hovering an AsDecimal shell shows
123
- * "USD"). Note: when `prefix` is also resolved from currency, the
124
- * `currencyCode` here is the symbolic identifier; `prefix` carries
125
- * the locale-aware narrow symbol.
126
- */
127
- currencyCode?: string;
128
- /**
129
- * Resolved unit-of-measure code (post-sibling resolution).
130
- *
131
- * Resolution chain at AsField: `@db.unit 'kg'` literal →
132
- * `@db.unit.ref 'fieldName'` sibling-field read → `undefined`. Useful
133
- * for tooltips. Note: when `suffix` is also resolved from `@db.unit*`,
134
- * `unitCode` and `suffix` carry the same string.
135
- */
136
- unitCode?: string;
137
- /**
138
- * Decimal scale storage cap (the DB column's fractional-digit limit) —
139
- * raw second arg of `@db.column.precision precision, scale`. The
140
- * composables pad outgoing strings to this; for display, use `scale`
141
- * (which may be tighter due to currency natural digits).
142
- */
143
- precisionScale?: number;
144
- /**
145
- * Resolved input prefix adornment.
146
- *
147
- * Resolution chain at AsField: explicit `@ui.form.prefix 'value'` →
148
- * `@ui.form.prefix.ref 'fieldName'` sibling-field read → currency
149
- * symbol (locale-narrow form, when currency is resolved) → `undefined`.
150
- * Applied by AsInput, AsNumber, AsDecimal.
151
- */
152
- prefix?: string;
153
- /**
154
- * Resolved input suffix adornment.
155
- *
156
- * Resolution chain at AsField: explicit `@ui.form.suffix 'value'` →
157
- * `@ui.form.suffix.ref 'fieldName'` sibling-field read → unit code
158
- * (resolved `unitCode`) → `undefined`. Applied by AsInput, AsNumber,
159
- * AsDecimal.
160
- */
161
- suffix?: string;
162
- /**
163
- * Effective display scale (fractional digits) — composables enforce
164
- * this when editing decimals.
165
- *
166
- * Resolution: `min(currencyDecimals, precisionScale)` when currency is
167
- * resolved, else `currencyDecimals` (currency only), else
168
- * `precisionScale` (DB only), else `undefined`. Smaller than
169
- * `precisionScale` is fine — storage stays at the DB cap, display
170
- * truncates to this.
171
- */
172
- scale?: number;
173
- /**
174
- * Whether AsField found at least one adornment-driving annotation on
175
- * this field (`@db.amount.currency*`, `@db.unit*`, `@ui.form.prefix*`,
176
- * `@ui.form.suffix*`). Used by AsNumber / AsDecimal to keep the
177
- * merged-chrome shell visible even when a sibling-ref source is
178
- * currently empty — without this flag, the shell would flicker as
179
- * the user picks a source value.
180
- *
181
- * Always populated by AsField; defaults to `false` when no adornment
182
- * annotation is present on the prop.
183
- */
184
- hasAdornment?: boolean;
185
- /**
186
- * Whether this field has changed since the change-tracking baseline.
187
- *
188
- * `true` only when the enclosing `<AsForm>` has `track-changes` enabled AND
189
- * this field's value differs from the baseline; `false` (or absent) when
190
- * tracking is off. AsField resolves it from the change list and surfaces it
191
- * here so default components — and custom swaps — can drive a visual hook
192
- * (the default `AsFieldShell` paints a `data-dirty` attribute from it) without
193
- * re-deriving the predicate. Granularity matches the change list: object /
194
- * section containers light up via their leaves; whole-array fields exactly;
195
- * an array-ITEM field stays `false` (the array container lights up instead).
196
- */
197
- isDirty?: boolean;
198
- }
199
- /**
200
- * Public emits contract for custom field components used with `AsForm` /
201
- * `AsField`. Type your `defineEmits` against this interface so the
202
- * action-button surface stays compatible with the framework.
203
- *
204
- * `_V` is reserved for forward-compat with value-typed emits in Phase 4
205
- * (e.g. `(e: 'change-value', value: _V)`); the underscore prefix marks it
206
- * as deliberately unused under both biome and eslint conventions.
207
- *
208
- * @typeParam _V - The field value type (reserved for future emits)
209
- */
210
- interface TAsComponentEmits<_V = unknown> {
211
- /**
212
- * Action invocation — emitted by phantom action buttons. The form
213
- * routes the named action through its `@action` handler.
214
- */
215
- (e: "action", name: string): void;
216
- }
217
- /**
218
- * Discriminated type for the `change` event emitted by `AsForm`.
219
- *
220
- * - `'update'` — leaf field value committed (blur)
221
- * - `'array-add'` — array item added
222
- * - `'array-remove'` — array item removed
223
- * - `'union-switch'` — union variant switched
224
- */
225
- type TAsChangeType = "update" | "array-add" | "array-remove" | "union-switch";
226
- /**
227
- * Type-to-component map for `AsForm`. Lists the built-in field types and
228
- * accepts additional custom types via index signature. Every key is optional:
229
- * a map may name only the types its forms use (a field whose type has no
230
- * entry renders a "No component" notice).
231
- *
232
- * Use {@link createDefaultTypes} to get a pre-built map with all defaults.
233
- */
234
- type TAsTypeComponents = {
235
- text?: Component;
236
- textarea?: Component;
237
- password?: Component;
238
- select?: Component;
239
- multiselect?: Component;
240
- tags?: Component;
241
- radio?: Component;
242
- checkbox?: Component;
243
- paragraph?: Component;
244
- action?: Component;
245
- object?: Component;
246
- array?: Component;
247
- union?: Component;
248
- tuple?: Component;
249
- ref?: Component;
250
- decimal?: Component;
251
- number?: Component;
252
- date?: Component;
253
- datetime?: Component;
254
- time?: Component;
255
- } & Record<string, Component>;
256
- /**
257
- * Union context provided by `AsUnion` via `UNION_CONTEXT_KEY`.
258
- * Consumed by `AsFieldShell` to render the variant picker inline with the
259
- * item's own header.
260
- */
261
- interface TAsUnionContext {
262
- /** All available union variant branches. */
263
- variants: FormUnionVariant[];
264
- /** Reactive index of the currently selected variant. */
265
- currentIndex: Ref<number>;
266
- /** Switch to a different variant (rewrites model data). */
267
- changeVariant: (index: number) => void;
268
- }
269
- /**
270
- * Public props contract for the standalone `AsCollapsible` section component.
271
- */
272
- interface TAsCollapsibleProps {
273
- title?: string;
274
- description?: string;
275
- level: number;
276
- optional?: boolean;
277
- optionalEnabled?: boolean;
278
- path: string;
279
- error?: string;
280
- defaultOpen?: boolean;
281
- hidden?: boolean;
282
- arrayIndex?: number;
283
- /**
284
- * Whether the section this collapsible wraps has changed since the
285
- * change-tracking baseline. Forwarded by the structured defaults
286
- * (`AsObject` / `AsArray` / `AsTuple`) from their own `isDirty` prop, which
287
- * `AsField` resolves from the change list. `AsCollapsible` paints
288
- * `data-dirty=""` on its root and on its heading element ONLY — never on
289
- * descendants — so a dirty container does not make every child label inside
290
- * it look modified. Styling hook: `as-collapsible-section` /
291
- * `as-collapsible-island` / `as-collapsible-title*` (see
292
- * `@atscript/ui-styles`).
293
- *
294
- * @since 0.1.133
295
- */
296
- isDirty?: boolean;
297
- }
298
- /**
299
- * Slots exposed by `AsCollapsible` — all header slots render inside `<summary>`.
300
- */
301
- interface TAsCollapsibleSlots {
302
- "title-extras"(): unknown;
303
- badges(): unknown;
304
- actions(): unknown;
305
- body(): unknown;
306
- empty(): unknown;
307
- }
308
- //#endregion
309
- export { TAsComponentEmits as a, TAsUnionContext as c, TAsCollapsibleSlots as i, TAsChangeType as n, TAsComponentProps as o, TAsCollapsibleProps as r, TAsTypeComponents as s, TAsBaseComponentProps as t };