@atscript/ui 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.
- package/dist/client-factory.cjs +27 -0
- package/dist/client-factory.d.cts +53 -0
- package/dist/client-factory.d.mts +53 -0
- package/dist/client-factory.mjs +25 -0
- package/dist/form/apply.cjs +38 -0
- package/dist/form/apply.d.cts +36 -0
- package/dist/form/apply.d.mts +36 -0
- package/dist/form/apply.mjs +38 -0
- package/dist/form/clone.cjs +30 -0
- package/dist/form/clone.d.cts +23 -0
- package/dist/form/clone.d.mts +23 -0
- package/dist/form/clone.mjs +30 -0
- package/dist/form/create-form-def.cjs +440 -0
- package/dist/form/create-form-def.d.cts +67 -0
- package/dist/form/create-form-def.d.mts +67 -0
- package/dist/form/create-form-def.mjs +438 -0
- package/dist/form/decimal-format.cjs +324 -0
- package/dist/form/decimal-format.d.cts +86 -0
- package/dist/form/decimal-format.d.mts +86 -0
- package/dist/form/decimal-format.mjs +315 -0
- package/dist/form/diff.cjs +458 -0
- package/dist/form/diff.d.cts +80 -0
- package/dist/form/diff.d.mts +80 -0
- package/dist/form/diff.mjs +457 -0
- package/dist/form/dirty.cjs +65 -0
- package/dist/form/dirty.d.cts +47 -0
- package/dist/form/dirty.d.mts +47 -0
- package/dist/form/dirty.mjs +64 -0
- package/dist/form/error-utils.cjs +97 -0
- package/dist/form/error-utils.d.cts +58 -0
- package/dist/form/error-utils.d.mts +58 -0
- package/dist/form/error-utils.mjs +92 -0
- package/dist/form/form-actions.cjs +30 -0
- package/dist/form/form-actions.d.cts +17 -0
- package/dist/form/form-actions.d.mts +17 -0
- package/dist/form/form-actions.mjs +30 -0
- package/dist/form/grid.cjs +69 -0
- package/dist/form/grid.d.cts +49 -0
- package/dist/form/grid.d.mts +49 -0
- package/dist/form/grid.mjs +64 -0
- package/dist/form/labels.cjs +10 -0
- package/dist/form/labels.d.cts +7 -0
- package/dist/form/labels.d.mts +7 -0
- package/dist/form/labels.mjs +10 -0
- package/dist/form/measurement.cjs +20 -0
- package/dist/form/measurement.d.cts +29 -0
- package/dist/form/measurement.d.mts +29 -0
- package/dist/form/measurement.mjs +20 -0
- package/dist/form/path-utils.cjs +182 -0
- package/dist/form/path-utils.d.cts +47 -0
- package/dist/form/path-utils.d.mts +47 -0
- package/dist/form/path-utils.mjs +175 -0
- package/dist/form/rebase.cjs +89 -0
- package/dist/form/rebase.d.cts +61 -0
- package/dist/form/rebase.d.mts +61 -0
- package/dist/form/rebase.mjs +89 -0
- package/dist/form/skipped-nav.cjs +100 -0
- package/dist/form/skipped-nav.d.cts +13 -0
- package/dist/form/skipped-nav.d.mts +13 -0
- package/dist/form/skipped-nav.mjs +98 -0
- package/dist/form/types.cjs +40 -0
- package/dist/form/types.d.cts +133 -0
- package/dist/form/types.d.mts +133 -0
- package/dist/form/types.mjs +36 -0
- package/dist/form/union-detect.cjs +46 -0
- package/dist/form/union-detect.d.cts +22 -0
- package/dist/form/union-detect.d.mts +22 -0
- package/dist/form/union-detect.mjs +46 -0
- package/dist/form/validate.cjs +150 -0
- package/dist/form/validate.d.cts +50 -0
- package/dist/form/validate.d.mts +50 -0
- package/dist/form/validate.mjs +147 -0
- package/dist/index.cjs +217 -3360
- package/dist/index.d.cts +38 -1693
- package/dist/index.d.mts +38 -1693
- package/dist/index.mjs +35 -3179
- package/dist/nav/model-routes.cjs +59 -0
- package/dist/nav/model-routes.d.cts +33 -0
- package/dist/nav/model-routes.d.mts +33 -0
- package/dist/nav/model-routes.mjs +59 -0
- package/dist/plugin/annotations.cjs +577 -0
- package/dist/plugin/annotations.mjs +577 -0
- package/dist/plugin/primitives.cjs +30 -0
- package/dist/plugin/primitives.mjs +30 -0
- package/dist/plugin/value-help-validation.cjs +419 -0
- package/dist/plugin/value-help-validation.mjs +413 -0
- package/dist/plugin.cjs +4 -1001
- package/dist/plugin.mjs +2 -999
- package/dist/shared/annotation-keys.cjs +189 -0
- package/dist/shared/annotation-keys.d.cts +82 -0
- package/dist/shared/annotation-keys.d.mts +82 -0
- package/dist/shared/annotation-keys.mjs +97 -0
- package/dist/shared/field-resolver.cjs +123 -0
- package/dist/shared/field-resolver.d.cts +77 -0
- package/dist/shared/field-resolver.d.mts +77 -0
- package/dist/shared/field-resolver.mjs +110 -0
- package/dist/shared/meta-cache.cjs +244 -0
- package/dist/shared/meta-cache.d.cts +110 -0
- package/dist/shared/meta-cache.d.mts +110 -0
- package/dist/shared/meta-cache.mjs +237 -0
- package/dist/shared/str.cjs +19 -0
- package/dist/shared/str.d.cts +7 -0
- package/dist/shared/str.d.mts +7 -0
- package/dist/shared/str.mjs +17 -0
- package/dist/table/column-resolver.cjs +17 -0
- package/dist/table/column-resolver.d.cts +11 -0
- package/dist/table/column-resolver.d.mts +11 -0
- package/dist/table/column-resolver.mjs +15 -0
- package/dist/table/create-table-def.cjs +233 -0
- package/dist/table/create-table-def.d.cts +15 -0
- package/dist/table/create-table-def.d.mts +15 -0
- package/dist/table/create-table-def.mjs +233 -0
- package/dist/table/navigate-href.cjs +45 -0
- package/dist/table/navigate-href.d.cts +31 -0
- package/dist/table/navigate-href.d.mts +31 -0
- package/dist/table/navigate-href.mjs +45 -0
- package/dist/table/types.d.cts +287 -0
- package/dist/table/types.d.mts +287 -0
- package/dist/table/value-kind.cjs +20 -0
- package/dist/table/value-kind.d.cts +15 -0
- package/dist/table/value-kind.d.mts +15 -0
- package/dist/table/value-kind.mjs +19 -0
- package/dist/value-help/dict-paths.cjs +17 -0
- package/dist/value-help/dict-paths.d.cts +11 -0
- package/dist/value-help/dict-paths.d.mts +11 -0
- package/dist/value-help/dict-paths.mjs +17 -0
- package/dist/value-help/distinct-client.cjs +51 -0
- package/dist/value-help/distinct-client.d.cts +40 -0
- package/dist/value-help/distinct-client.d.mts +40 -0
- package/dist/value-help/distinct-client.mjs +50 -0
- package/dist/value-help/extract-literals.cjs +76 -0
- package/dist/value-help/extract-literals.d.cts +32 -0
- package/dist/value-help/extract-literals.d.mts +32 -0
- package/dist/value-help/extract-literals.mjs +74 -0
- package/dist/value-help/extract-ref.cjs +100 -0
- package/dist/value-help/extract-ref.d.cts +37 -0
- package/dist/value-help/extract-ref.d.mts +37 -0
- package/dist/value-help/extract-ref.mjs +100 -0
- package/dist/value-help/filter-tree.cjs +45 -0
- package/dist/value-help/filter-tree.mjs +45 -0
- package/dist/value-help/index.d.mts +8 -0
- package/dist/value-help/resolve-options.cjs +64 -0
- package/dist/value-help/resolve-options.d.cts +35 -0
- package/dist/value-help/resolve-options.d.mts +35 -0
- package/dist/value-help/resolve-options.mjs +60 -0
- package/dist/value-help/resolve.cjs +62 -0
- package/dist/value-help/resolve.d.cts +31 -0
- package/dist/value-help/resolve.d.mts +31 -0
- package/dist/value-help/resolve.mjs +61 -0
- package/dist/value-help/types.d.cts +36 -0
- package/dist/value-help/types.d.mts +36 -0
- package/dist/value-help/value-help-client.cjs +136 -0
- package/dist/value-help/value-help-client.d.cts +67 -0
- package/dist/value-help/value-help-client.d.mts +67 -0
- package/dist/value-help/value-help-client.mjs +134 -0
- package/package.json +10 -10
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import { isValueHelpTarget, literalLabelValues, validateDistinct, validateFormType, validateLiteralLabel, validateValueHelp, valueHelpScopes } from "./value-help-validation.mjs";
|
|
2
|
+
import { AnnotationSpec } from "@atscript/core";
|
|
3
|
+
//#region src/plugin/annotations.ts
|
|
4
|
+
const BUILTIN_TYPES = [
|
|
5
|
+
"text",
|
|
6
|
+
"password",
|
|
7
|
+
"number",
|
|
8
|
+
"decimal",
|
|
9
|
+
"select",
|
|
10
|
+
"multiselect",
|
|
11
|
+
"tags",
|
|
12
|
+
"textarea",
|
|
13
|
+
"checkbox",
|
|
14
|
+
"radio",
|
|
15
|
+
"date",
|
|
16
|
+
"datetime",
|
|
17
|
+
"time",
|
|
18
|
+
"paragraph",
|
|
19
|
+
"action"
|
|
20
|
+
];
|
|
21
|
+
const COL_SPAN_VALUES = [
|
|
22
|
+
"1",
|
|
23
|
+
"2",
|
|
24
|
+
"3",
|
|
25
|
+
"4",
|
|
26
|
+
"5",
|
|
27
|
+
"6",
|
|
28
|
+
"7",
|
|
29
|
+
"8",
|
|
30
|
+
"9",
|
|
31
|
+
"10",
|
|
32
|
+
"11",
|
|
33
|
+
"12",
|
|
34
|
+
"full",
|
|
35
|
+
"half",
|
|
36
|
+
"third"
|
|
37
|
+
];
|
|
38
|
+
const ROW_SPAN_VALUES = [
|
|
39
|
+
"1",
|
|
40
|
+
"2",
|
|
41
|
+
"3",
|
|
42
|
+
"4",
|
|
43
|
+
"5",
|
|
44
|
+
"6"
|
|
45
|
+
];
|
|
46
|
+
/**
|
|
47
|
+
* Static `@ui.*` annotation specs registered by the `@atscript/ui` plugin.
|
|
48
|
+
*
|
|
49
|
+
* Namespace contract (see Decision 1 in design.md):
|
|
50
|
+
* - `ui.<key>` — explicit cross-surface shared (`type`)
|
|
51
|
+
* - `ui.form.<key>` — form-only static
|
|
52
|
+
* - `ui.table.<key>` — table-only static
|
|
53
|
+
* - `ui.dict.<key>` — value-help annotations
|
|
54
|
+
* - `ui.valueHelp`, `ui.literalLabel` — dictionary binding, union literal labels
|
|
55
|
+
* - `ui.nav.<key>` — model-level navigation annotations
|
|
56
|
+
* - `ui.array.<key>` — array control annotations
|
|
57
|
+
*
|
|
58
|
+
* The dynamic `ui.form.fn.*` / `ui.table.fn.*` and `ui.form.validate` specs
|
|
59
|
+
* are declared by `@atscript/ui-fns`.
|
|
60
|
+
*/
|
|
61
|
+
const uiAnnotations = { ui: {
|
|
62
|
+
type: new AnnotationSpec({
|
|
63
|
+
description: "Cell + input renderer type override applied to whichever surface lacks its own override (`ui.form.type` / `ui.table.type`). Built-in types: " + BUILTIN_TYPES.join(", ") + ". Consumers may dispatch additional custom types via the renderer registry — the argument is intentionally open-ended.\n\n**Example:**\n```atscript\n@ui.type \"currency\"\namount: number\n```\n",
|
|
64
|
+
nodeType: ["prop", "type"],
|
|
65
|
+
argument: {
|
|
66
|
+
name: "type",
|
|
67
|
+
type: "string",
|
|
68
|
+
description: "The renderer type used by both form input and table cell unless overridden."
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
form: {
|
|
72
|
+
placeholder: new AnnotationSpec({
|
|
73
|
+
description: "Defines **placeholder text** for UI input fields.\n\n**Example:**\n```atscript\n@ui.form.placeholder \"Enter your name\"\nname: string\n```\n",
|
|
74
|
+
nodeType: ["prop", "type"],
|
|
75
|
+
argument: {
|
|
76
|
+
name: "text",
|
|
77
|
+
type: "string",
|
|
78
|
+
description: "The placeholder text to display in UI input fields."
|
|
79
|
+
}
|
|
80
|
+
}),
|
|
81
|
+
hint: new AnnotationSpec({
|
|
82
|
+
description: "Provides **help text or tooltip** displayed near the field in UI forms.\n\n**Example:**\n```atscript\n@ui.form.hint \"Must be a valid business email\"\nemail: string.email\n```\n",
|
|
83
|
+
nodeType: ["prop", "type"],
|
|
84
|
+
argument: {
|
|
85
|
+
name: "text",
|
|
86
|
+
type: "string",
|
|
87
|
+
description: "Help text or tooltip content."
|
|
88
|
+
}
|
|
89
|
+
}),
|
|
90
|
+
classes: new AnnotationSpec({
|
|
91
|
+
description: "Adds **CSS class names** to the rendered field. Multiple `@ui.form.classes` annotations are appended.\n\n**Example:**\n```atscript\n@ui.form.classes \"text-bold\"\n@ui.form.classes \"mt-4\"\ntitle: string\n```\n",
|
|
92
|
+
nodeType: [
|
|
93
|
+
"prop",
|
|
94
|
+
"type",
|
|
95
|
+
"interface"
|
|
96
|
+
],
|
|
97
|
+
multiple: true,
|
|
98
|
+
mergeStrategy: "append",
|
|
99
|
+
argument: {
|
|
100
|
+
name: "names",
|
|
101
|
+
type: "string",
|
|
102
|
+
description: "One or more CSS class names (space-separated)."
|
|
103
|
+
}
|
|
104
|
+
}),
|
|
105
|
+
styles: new AnnotationSpec({
|
|
106
|
+
description: "Adds **inline CSS styles** to the rendered field. Multiple `@ui.form.styles` annotations are appended.\n\n**Example:**\n```atscript\n@ui.form.styles \"color: red\"\n@ui.form.styles \"font-weight: bold\"\nwarning: string\n```\n",
|
|
107
|
+
nodeType: [
|
|
108
|
+
"prop",
|
|
109
|
+
"type",
|
|
110
|
+
"interface"
|
|
111
|
+
],
|
|
112
|
+
multiple: true,
|
|
113
|
+
mergeStrategy: "append",
|
|
114
|
+
argument: {
|
|
115
|
+
name: "css",
|
|
116
|
+
type: "string",
|
|
117
|
+
description: "CSS style declarations (semicolon-separated)."
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
autocomplete: new AnnotationSpec({
|
|
121
|
+
description: "Provides an **autocomplete hint** for the rendered input field.\n\n**Example:**\n```atscript\n@ui.form.autocomplete \"email\"\nemail: string.email\n```\n",
|
|
122
|
+
nodeType: ["prop", "type"],
|
|
123
|
+
argument: {
|
|
124
|
+
name: "value",
|
|
125
|
+
type: "string",
|
|
126
|
+
description: "HTML autocomplete attribute value."
|
|
127
|
+
}
|
|
128
|
+
}),
|
|
129
|
+
disabled: new AnnotationSpec({
|
|
130
|
+
description: "Statically mark this field as disabled in the form.",
|
|
131
|
+
nodeType: ["prop", "type"],
|
|
132
|
+
passedWhenReferred: false
|
|
133
|
+
}),
|
|
134
|
+
options: new AnnotationSpec({
|
|
135
|
+
description: "Static option for select/radio fields. Repeat for each option. Label is the display text, value is the key (defaults to label).",
|
|
136
|
+
nodeType: ["prop", "type"],
|
|
137
|
+
multiple: true,
|
|
138
|
+
mergeStrategy: "replace",
|
|
139
|
+
argument: [{
|
|
140
|
+
name: "label",
|
|
141
|
+
type: "string",
|
|
142
|
+
description: "Display label for the option"
|
|
143
|
+
}, {
|
|
144
|
+
name: "value",
|
|
145
|
+
type: "string",
|
|
146
|
+
optional: true,
|
|
147
|
+
description: "Value/key for the option (defaults to label if omitted)"
|
|
148
|
+
}]
|
|
149
|
+
}),
|
|
150
|
+
order: new AnnotationSpec({
|
|
151
|
+
description: "Explicit form-field ordering (lower values render first).",
|
|
152
|
+
nodeType: ["prop", "type"],
|
|
153
|
+
passedWhenReferred: false,
|
|
154
|
+
argument: {
|
|
155
|
+
name: "order",
|
|
156
|
+
type: "number",
|
|
157
|
+
description: "Numeric order (lower = earlier)"
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
type: new AnnotationSpec({
|
|
161
|
+
description: "Form input type override. Wins over the shared `@ui.type` for this prop's form input. Built-in types: " + BUILTIN_TYPES.join(", ") + ". Consumers may register additional types in the form types map; the argument is intentionally open-ended.",
|
|
162
|
+
nodeType: ["prop", "type"],
|
|
163
|
+
argument: {
|
|
164
|
+
name: "type",
|
|
165
|
+
type: "string",
|
|
166
|
+
description: "The input type used by `<as-field>` for this prop."
|
|
167
|
+
},
|
|
168
|
+
validate: validateFormType
|
|
169
|
+
}),
|
|
170
|
+
component: new AnnotationSpec({
|
|
171
|
+
description: "Named component override for the form-side renderer.",
|
|
172
|
+
nodeType: [
|
|
173
|
+
"prop",
|
|
174
|
+
"interface",
|
|
175
|
+
"type"
|
|
176
|
+
],
|
|
177
|
+
argument: {
|
|
178
|
+
name: "name",
|
|
179
|
+
type: "string",
|
|
180
|
+
description: "Component name from the form components registry"
|
|
181
|
+
}
|
|
182
|
+
}),
|
|
183
|
+
hidden: new AnnotationSpec({
|
|
184
|
+
description: "Statically hide this field in the form.",
|
|
185
|
+
nodeType: ["prop", "type"],
|
|
186
|
+
passedWhenReferred: false
|
|
187
|
+
}),
|
|
188
|
+
attr: new AnnotationSpec({
|
|
189
|
+
description: "Custom attribute or component prop applied to the form input. Repeat for each attr. Passed via v-bind.",
|
|
190
|
+
nodeType: ["prop", "type"],
|
|
191
|
+
multiple: true,
|
|
192
|
+
mergeStrategy: "replace",
|
|
193
|
+
argument: [{
|
|
194
|
+
name: "name",
|
|
195
|
+
type: "string",
|
|
196
|
+
description: "Attribute/prop name (e.g., \"data-testid\", \"variant\", \"size\")"
|
|
197
|
+
}, {
|
|
198
|
+
name: "value",
|
|
199
|
+
type: "string",
|
|
200
|
+
description: "Static value (string, number, boolean, or undefined)"
|
|
201
|
+
}]
|
|
202
|
+
}),
|
|
203
|
+
grid: {
|
|
204
|
+
colSpan: new AnnotationSpec({
|
|
205
|
+
description: "Grid column span for the field in auto-generated forms. Accepts numeric strings `\"1\"` to `\"12\"` or aliases `\"full\"` (12), `\"half\"` (6), `\"third\"` (4). Optional second argument applies inside narrow containers (≤480px); defaults to `\"full\"` when omitted.\n\n**Example:**\n```atscript\n@ui.form.grid.colSpan \"6\", \"12\" // half-width desktop, full-width narrow\nfirstName: string\n```\n",
|
|
206
|
+
nodeType: ["prop", "type"],
|
|
207
|
+
argument: [{
|
|
208
|
+
name: "desktop",
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "Column span for non-narrow containers. \"1\"-\"12\", \"full\", \"half\", or \"third\".",
|
|
211
|
+
values: COL_SPAN_VALUES
|
|
212
|
+
}, {
|
|
213
|
+
name: "narrow",
|
|
214
|
+
type: "string",
|
|
215
|
+
optional: true,
|
|
216
|
+
description: "Column span for containers ≤480px wide. Defaults to \"full\".",
|
|
217
|
+
values: COL_SPAN_VALUES
|
|
218
|
+
}]
|
|
219
|
+
}),
|
|
220
|
+
rowSpan: new AnnotationSpec({
|
|
221
|
+
description: "Grid row span for the field. Accepts numeric strings `\"1\"` to `\"6\"`. Optional second argument applies inside narrow containers (≤480px); defaults to `\"1\"` when omitted.\n\n**Example:**\n```atscript\n@ui.form.grid.rowSpan \"2\"\nbio: string\n```\n",
|
|
222
|
+
nodeType: ["prop", "type"],
|
|
223
|
+
argument: [{
|
|
224
|
+
name: "desktop",
|
|
225
|
+
type: "string",
|
|
226
|
+
description: "Row span for non-narrow containers. \"1\"-\"6\".",
|
|
227
|
+
values: ROW_SPAN_VALUES
|
|
228
|
+
}, {
|
|
229
|
+
name: "narrow",
|
|
230
|
+
type: "string",
|
|
231
|
+
optional: true,
|
|
232
|
+
description: "Row span for containers ≤480px wide. Defaults to \"1\".",
|
|
233
|
+
values: ROW_SPAN_VALUES
|
|
234
|
+
}]
|
|
235
|
+
})
|
|
236
|
+
},
|
|
237
|
+
submit: { text: new AnnotationSpec({
|
|
238
|
+
description: "Static submit button text.",
|
|
239
|
+
nodeType: ["interface", "type"],
|
|
240
|
+
argument: {
|
|
241
|
+
name: "text",
|
|
242
|
+
type: "string",
|
|
243
|
+
description: "Submit button label"
|
|
244
|
+
}
|
|
245
|
+
}) },
|
|
246
|
+
label: { singular: new AnnotationSpec({
|
|
247
|
+
description: "Singular label form for an array field. Used by AsArray to render \"Add <singular>\" / \"Remove <singular>\" / per-item \"#N\"-suffixed labels. When omitted, the array falls back to `'item'`.\n\n**Example:**\n```atscript\n@meta.label 'Phone numbers'\n@ui.form.label.singular 'phone number'\nphones: string[]\n```\n",
|
|
248
|
+
nodeType: ["prop", "type"],
|
|
249
|
+
argument: {
|
|
250
|
+
name: "singular",
|
|
251
|
+
type: "string",
|
|
252
|
+
description: "Singular label, e.g. \"phone number\" for a `phones` field."
|
|
253
|
+
}
|
|
254
|
+
}) },
|
|
255
|
+
pushDown: new AnnotationSpec({
|
|
256
|
+
description: "Render this field below the form's submit button instead of above it. Pushed-down fields collect into their own grid (same 12-column layout, `@ui.form.order`/`@ui.form.grid.*` honoured) that sits under the submit action. Typical use: a secondary `ui.action` link such as \"Already have an account? Sign in\" beneath a Sign-up button.\n\n**Example:**\n```atscript\n@ui.form.pushDown\n@ui.form.attr 'text', 'Already have an account?'\n@ui.form.attr 'align', 'center'\n@ui.form.action 'signin', 'Sign in'\nsigninAction: ui.action\n```\n",
|
|
257
|
+
nodeType: ["prop", "type"]
|
|
258
|
+
}),
|
|
259
|
+
action: new AnnotationSpec({
|
|
260
|
+
description: "Form action button for this field.",
|
|
261
|
+
nodeType: ["prop", "type"],
|
|
262
|
+
argument: [{
|
|
263
|
+
name: "id",
|
|
264
|
+
type: "string",
|
|
265
|
+
description: "The action name emitted on trigger"
|
|
266
|
+
}, {
|
|
267
|
+
name: "label",
|
|
268
|
+
type: "string",
|
|
269
|
+
optional: true,
|
|
270
|
+
description: "Display label for the action (falls back to @meta.label)"
|
|
271
|
+
}]
|
|
272
|
+
}),
|
|
273
|
+
prefix: {
|
|
274
|
+
$self: new AnnotationSpec({
|
|
275
|
+
description: "Literal **prefix adornment** rendered before the input value. Works on all default inputs (`AsInput`, `AsNumber`, `AsDecimal`). When set on a field that also carries `@db.amount.currency*`, the explicit prefix wins — currency only contributes a prefix when no explicit one is present.\n\n**Example:**\n```atscript\n@ui.form.prefix \"+1\"\nphone: string\n```\n",
|
|
276
|
+
nodeType: ["prop", "type"],
|
|
277
|
+
argument: {
|
|
278
|
+
name: "value",
|
|
279
|
+
type: "string",
|
|
280
|
+
description: "Literal text to display before the input value."
|
|
281
|
+
}
|
|
282
|
+
}),
|
|
283
|
+
ref: new AnnotationSpec({
|
|
284
|
+
description: "**Sibling-field reference** for the prefix adornment. The string argument is the name of another field on the same parent whose value will be displayed as the prefix at runtime. `@ui.form.prefix` wins over `@ui.form.prefix.ref` when both are present.\n\n**Example:**\n```atscript\ncountryCode: string\n@ui.form.prefix.ref \"countryCode\"\nphone: string\n```\n",
|
|
285
|
+
nodeType: ["prop", "type"],
|
|
286
|
+
passedWhenReferred: false,
|
|
287
|
+
argument: {
|
|
288
|
+
name: "field",
|
|
289
|
+
type: "string",
|
|
290
|
+
description: "Name of a sibling field whose value drives the prefix."
|
|
291
|
+
}
|
|
292
|
+
}),
|
|
293
|
+
icon: new AnnotationSpec({
|
|
294
|
+
description: "**Icon adornment** rendered to the left of the input (further out than `@ui.form.prefix` text). The argument is a CSS class that paints the glyph — typically a UnoCSS preset-icons utility like `i-mdi-mail` or a custom registry alias. The consumer is responsible for ensuring the class is reachable (safelist / preset / shortcut). Combined order: `[prefix-icon][prefix-text][input]`.\n\n**Example:**\n```atscript\n@ui.form.prefix.icon \"i-mdi-mail\"\nemail: string.email\n```\n",
|
|
295
|
+
nodeType: ["prop", "type"],
|
|
296
|
+
argument: {
|
|
297
|
+
name: "class",
|
|
298
|
+
type: "string",
|
|
299
|
+
description: "CSS class painting the icon glyph. Consumer manages safelist / preset coverage."
|
|
300
|
+
}
|
|
301
|
+
})
|
|
302
|
+
},
|
|
303
|
+
suffix: {
|
|
304
|
+
$self: new AnnotationSpec({
|
|
305
|
+
description: "Literal **suffix adornment** rendered after the input value. Works on all default inputs. When set on a field that also carries `@db.unit*`, the explicit suffix wins — unit code only contributes a suffix when no explicit one is present.\n\n**Example:**\n```atscript\n@ui.form.suffix \"/hr\"\nrate: number\n```\n",
|
|
306
|
+
nodeType: ["prop", "type"],
|
|
307
|
+
argument: {
|
|
308
|
+
name: "value",
|
|
309
|
+
type: "string",
|
|
310
|
+
description: "Literal text to display after the input value."
|
|
311
|
+
}
|
|
312
|
+
}),
|
|
313
|
+
ref: new AnnotationSpec({
|
|
314
|
+
description: "**Sibling-field reference** for the suffix adornment. The string argument is the name of another field on the same parent whose value will be displayed as the suffix at runtime. `@ui.form.suffix` wins over `@ui.form.suffix.ref` when both are present.\n\n**Example:**\n```atscript\nunit: 'kg' | 'lb'\n@ui.form.suffix.ref \"unit\"\nweight: number\n```\n",
|
|
315
|
+
nodeType: ["prop", "type"],
|
|
316
|
+
passedWhenReferred: false,
|
|
317
|
+
argument: {
|
|
318
|
+
name: "field",
|
|
319
|
+
type: "string",
|
|
320
|
+
description: "Name of a sibling field whose value drives the suffix."
|
|
321
|
+
}
|
|
322
|
+
}),
|
|
323
|
+
icon: new AnnotationSpec({
|
|
324
|
+
description: "**Icon adornment** rendered to the right of the input (further out than `@ui.form.suffix` text). The argument is a CSS class that paints the glyph — typically a UnoCSS preset-icons utility like `i-mdi-mail` or a custom registry alias. The consumer is responsible for ensuring the class is reachable (safelist / preset / shortcut). Combined order: `[input][suffix-text][suffix-icon]`.\n\n**Example:**\n```atscript\n@ui.form.suffix.icon \"i-mdi-check\"\ncode: string\n```\n",
|
|
325
|
+
nodeType: ["prop", "type"],
|
|
326
|
+
argument: {
|
|
327
|
+
name: "class",
|
|
328
|
+
type: "string",
|
|
329
|
+
description: "CSS class painting the icon glyph. Consumer manages safelist / preset coverage."
|
|
330
|
+
}
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
},
|
|
334
|
+
table: {
|
|
335
|
+
width: new AnnotationSpec({
|
|
336
|
+
description: "Sets the **default column width** for this field when rendered in a table. Accepts any CSS width string (e.g. `120px`, `12em`, `20ch`). The user can still resize the column manually; double-click on the resize handle auto-fits to content; the column-menu Reset entry returns to this value.\n\n**Example:**\n```atscript\n@ui.table.width \"240px\"\ndescription: string\n```\n",
|
|
337
|
+
nodeType: ["prop", "type"],
|
|
338
|
+
argument: {
|
|
339
|
+
name: "width",
|
|
340
|
+
type: "string",
|
|
341
|
+
description: "CSS width for the column (e.g. '120px', '15em', '20ch')."
|
|
342
|
+
}
|
|
343
|
+
}),
|
|
344
|
+
component: new AnnotationSpec({
|
|
345
|
+
description: "Named component override for the table-cell renderer.",
|
|
346
|
+
nodeType: [
|
|
347
|
+
"prop",
|
|
348
|
+
"interface",
|
|
349
|
+
"type"
|
|
350
|
+
],
|
|
351
|
+
argument: {
|
|
352
|
+
name: "name",
|
|
353
|
+
type: "string",
|
|
354
|
+
description: "Component name from the table components registry"
|
|
355
|
+
}
|
|
356
|
+
}),
|
|
357
|
+
exclude: new AnnotationSpec({
|
|
358
|
+
description: "Completely removes this field from the table — not displayable, filterable, or sortable, and not shown in the config dialog. The field stays in the type and remains a valid `@ui.table.selectWith` target so its data can still be fetched for custom cells.",
|
|
359
|
+
nodeType: ["prop", "type"],
|
|
360
|
+
passedWhenReferred: false
|
|
361
|
+
}),
|
|
362
|
+
attr: new AnnotationSpec({
|
|
363
|
+
description: "Custom attribute or component prop applied to the rendered `<td>`. Repeat for each attr. Passed via v-bind.",
|
|
364
|
+
nodeType: ["prop", "type"],
|
|
365
|
+
multiple: true,
|
|
366
|
+
mergeStrategy: "replace",
|
|
367
|
+
argument: [{
|
|
368
|
+
name: "name",
|
|
369
|
+
type: "string",
|
|
370
|
+
description: "Attribute/prop name (e.g., \"title\", \"data-row\", \"aria-label\")"
|
|
371
|
+
}, {
|
|
372
|
+
name: "value",
|
|
373
|
+
type: "string",
|
|
374
|
+
description: "Static value applied to the cell."
|
|
375
|
+
}]
|
|
376
|
+
}),
|
|
377
|
+
classes: new AnnotationSpec({
|
|
378
|
+
description: "CSS classes applied to the rendered `<td>` for this column's cells. Multiple `@ui.table.classes` annotations are appended.\n\n**Example:**\n```atscript\n@ui.table.classes \"font-bold\"\n@ui.table.classes \"text-right\"\namount: number\n```\n",
|
|
379
|
+
nodeType: [
|
|
380
|
+
"prop",
|
|
381
|
+
"type",
|
|
382
|
+
"interface"
|
|
383
|
+
],
|
|
384
|
+
multiple: true,
|
|
385
|
+
mergeStrategy: "append",
|
|
386
|
+
argument: {
|
|
387
|
+
name: "names",
|
|
388
|
+
type: "string",
|
|
389
|
+
description: "One or more CSS class names (space-separated)."
|
|
390
|
+
}
|
|
391
|
+
}),
|
|
392
|
+
selectWith: new AnnotationSpec({
|
|
393
|
+
description: "Extra sibling leaf field paths to include in the table `$select` whenever this column is displayed. These fields are fetched but never rendered as their own columns — use them to back a custom cell renderer or formatter. Multiple `@ui.table.selectWith` annotations are appended. Names siblings of the DECLARING interface, so it never travels across refs.\n\n**Example:**\n```atscript\n@ui.table.selectWith \"firstName\"\n@ui.table.selectWith \"lastName\"\nfullName: string\n```\n",
|
|
394
|
+
nodeType: [
|
|
395
|
+
"prop",
|
|
396
|
+
"type",
|
|
397
|
+
"interface"
|
|
398
|
+
],
|
|
399
|
+
multiple: true,
|
|
400
|
+
mergeStrategy: "append",
|
|
401
|
+
argument: {
|
|
402
|
+
name: "path",
|
|
403
|
+
type: "string",
|
|
404
|
+
description: "Sibling leaf field path to fetch alongside this column."
|
|
405
|
+
},
|
|
406
|
+
passedWhenReferred: false
|
|
407
|
+
}),
|
|
408
|
+
styles: new AnnotationSpec({
|
|
409
|
+
description: "Inline CSS styles applied to the rendered `<td>` for this column's cells. Multiple `@ui.table.styles` annotations are appended.\n\n**Example:**\n```atscript\n@ui.table.styles \"padding-left: 12px\"\ndescription: string\n```\n",
|
|
410
|
+
nodeType: [
|
|
411
|
+
"prop",
|
|
412
|
+
"type",
|
|
413
|
+
"interface"
|
|
414
|
+
],
|
|
415
|
+
multiple: true,
|
|
416
|
+
mergeStrategy: "append",
|
|
417
|
+
argument: {
|
|
418
|
+
name: "css",
|
|
419
|
+
type: "string",
|
|
420
|
+
description: "CSS style declarations (semicolon-separated)."
|
|
421
|
+
}
|
|
422
|
+
}),
|
|
423
|
+
type: new AnnotationSpec({
|
|
424
|
+
description: "Cell renderer type override. Wins over the shared `@ui.type` for this prop's table cell. Built-in types: " + BUILTIN_TYPES.join(", ") + ". Consumers may register additional types in the table types map; the argument is intentionally open-ended.",
|
|
425
|
+
nodeType: ["prop", "type"],
|
|
426
|
+
argument: {
|
|
427
|
+
name: "type",
|
|
428
|
+
type: "string",
|
|
429
|
+
description: "The cell renderer type dispatched via the table types map."
|
|
430
|
+
}
|
|
431
|
+
}),
|
|
432
|
+
order: new AnnotationSpec({
|
|
433
|
+
description: "Initial column ordering — lower values appear first; user-driven runtime reorder still mutates table state's `columnNames`.",
|
|
434
|
+
nodeType: ["prop", "type"],
|
|
435
|
+
passedWhenReferred: false,
|
|
436
|
+
argument: {
|
|
437
|
+
name: "order",
|
|
438
|
+
type: "number",
|
|
439
|
+
description: "Numeric order (lower = earlier)"
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
},
|
|
443
|
+
valueHelp: {
|
|
444
|
+
$self: new AnnotationSpec({
|
|
445
|
+
description: "Binds this field to a value-help dictionary **without a foreign key** — no constraint, no query semantics, presentation only. Filter pickers (table filter dialog / inline field) and form reference pickers search the target's controller and commit the target's `field`. The binding wins over a `@db.rel.FK` on the field or its chain, and travels through chain refs and `extends`. The optional `filter` is a static scope AND'd into every picker query; fields it pins with `=` are hidden from the picker columns.\n\n**Example:**\n```atscript\n@ui.valueHelp AttributeValue, 'value', `attribute = 'color'`\ncolor: Ticket.color\n```\n",
|
|
446
|
+
nodeType: ["prop", "type"],
|
|
447
|
+
multiple: false,
|
|
448
|
+
argument: [
|
|
449
|
+
{
|
|
450
|
+
name: "target",
|
|
451
|
+
type: "ref",
|
|
452
|
+
description: "The dictionary interface (served by a controller exposing `@db.http.path`). Not a `@db.alias`.",
|
|
453
|
+
refFilter: isValueHelpTarget
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
name: "field",
|
|
457
|
+
type: "string",
|
|
458
|
+
description: "Top-level scalar field of the target whose value this field stores. Same type as this field.",
|
|
459
|
+
fieldScope: valueHelpScopes.field
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
optional: true,
|
|
463
|
+
name: "filter",
|
|
464
|
+
type: "query",
|
|
465
|
+
description: "Static scope on the target (`attribute = 'color' and active = true`) — field-to-value comparisons of the target's fields only.",
|
|
466
|
+
fieldScope: valueHelpScopes.filter
|
|
467
|
+
}
|
|
468
|
+
],
|
|
469
|
+
validate: validateValueHelp
|
|
470
|
+
}),
|
|
471
|
+
distinct: new AnnotationSpec({
|
|
472
|
+
description: "Offers a **distinct-values picker** for this column in table filters: the values already stored, read from the table's own controller via `$groupBy`. Shown only when the server reports the field filterable and groupable, and the field has no dictionary binding, FK help or literal options. Not offered in forms.\n\n**Example:**\n```atscript\n@ui.valueHelp.distinct\ncity?: string\n```\n",
|
|
473
|
+
nodeType: ["prop", "type"],
|
|
474
|
+
validate: validateDistinct
|
|
475
|
+
})
|
|
476
|
+
},
|
|
477
|
+
literalLabel: new AnnotationSpec({
|
|
478
|
+
description: "Display label for one literal of a union (`'open' | 'closed'`). Repeat per literal; unlabelled literals keep their raw text. Used by form selects/radios, table cells, enum filter options, filter chips and export. A prop's labels are added to the referenced type's (`append` merge: the type's other labels stay); for the same literal the prop's label wins.\n\n**Example:**\n```atscript\n@ui.literalLabel 'in_progress', 'In progress'\nexport type Status = 'open' | 'in_progress'\n```\n",
|
|
479
|
+
nodeType: ["prop", "type"],
|
|
480
|
+
multiple: true,
|
|
481
|
+
mergeStrategy: "append",
|
|
482
|
+
argument: [{
|
|
483
|
+
name: "value",
|
|
484
|
+
type: "string",
|
|
485
|
+
description: "The literal as text (`'2'` for the number literal `2`).",
|
|
486
|
+
valueScope: literalLabelValues
|
|
487
|
+
}, {
|
|
488
|
+
name: "label",
|
|
489
|
+
type: "string",
|
|
490
|
+
description: "Display label."
|
|
491
|
+
}],
|
|
492
|
+
validate: validateLiteralLabel
|
|
493
|
+
}),
|
|
494
|
+
dict: {
|
|
495
|
+
label: new AnnotationSpec({
|
|
496
|
+
description: "Marks this field as the primary display label when the table is used as a value-help dictionary",
|
|
497
|
+
nodeType: ["prop"],
|
|
498
|
+
passedWhenReferred: false
|
|
499
|
+
}),
|
|
500
|
+
descr: new AnnotationSpec({
|
|
501
|
+
description: "Marks this field as the secondary description in value-help display",
|
|
502
|
+
nodeType: ["prop"],
|
|
503
|
+
passedWhenReferred: false
|
|
504
|
+
}),
|
|
505
|
+
attr: new AnnotationSpec({
|
|
506
|
+
description: "Marks this field as an additional attribute column in table-mode value help",
|
|
507
|
+
nodeType: ["prop"],
|
|
508
|
+
multiple: true,
|
|
509
|
+
mergeStrategy: "append",
|
|
510
|
+
passedWhenReferred: false
|
|
511
|
+
}),
|
|
512
|
+
filterable: new AnnotationSpec({
|
|
513
|
+
description: "Marks this field as filterable in the value-help picker UI. Surfaced via `meta.fields[name].filterable` on value-help `/meta` responses.",
|
|
514
|
+
nodeType: ["prop"],
|
|
515
|
+
passedWhenReferred: false
|
|
516
|
+
}),
|
|
517
|
+
sortable: new AnnotationSpec({
|
|
518
|
+
description: "Marks this field as sortable in the value-help picker UI. Surfaced via `meta.fields[name].sortable` on value-help `/meta` responses.",
|
|
519
|
+
nodeType: ["prop"],
|
|
520
|
+
passedWhenReferred: false
|
|
521
|
+
}),
|
|
522
|
+
searchable: new AnnotationSpec({
|
|
523
|
+
description: "Marks a prop as participating in `$search`, or — on an interface — marks every `string` prop on the target as searchable. Surfaced via `meta.searchable` on value-help `/meta` responses.",
|
|
524
|
+
nodeType: ["prop", "interface"],
|
|
525
|
+
passedWhenReferred: false
|
|
526
|
+
})
|
|
527
|
+
},
|
|
528
|
+
nav: {
|
|
529
|
+
group: new AnnotationSpec({
|
|
530
|
+
description: "Navigation section this model belongs to when the app generates navigation from model metadata (`buildModelRoutes`). Models sharing a group value are meant to render under one nav section — grouping itself is left to the consumer.\n\n**Example:**\n```atscript\n@db.table 'orders'\n@ui.nav.group 'Sales'\nexport interface Order {\n```\n",
|
|
531
|
+
nodeType: ["interface", "type"],
|
|
532
|
+
passedWhenReferred: false,
|
|
533
|
+
argument: {
|
|
534
|
+
name: "group",
|
|
535
|
+
type: "string",
|
|
536
|
+
description: "Nav section name shared by related models."
|
|
537
|
+
}
|
|
538
|
+
}),
|
|
539
|
+
order: new AnnotationSpec({
|
|
540
|
+
description: "Position of this model in generated navigation — lower values appear first; models without an order sort last (in input order).\n\n**Example:**\n```atscript\n@db.table 'orders'\n@ui.nav.order 1\nexport interface Order {\n```\n",
|
|
541
|
+
nodeType: ["interface", "type"],
|
|
542
|
+
passedWhenReferred: false,
|
|
543
|
+
argument: {
|
|
544
|
+
name: "order",
|
|
545
|
+
type: "number",
|
|
546
|
+
description: "Numeric order (lower = earlier)"
|
|
547
|
+
}
|
|
548
|
+
}),
|
|
549
|
+
hidden: new AnnotationSpec({
|
|
550
|
+
description: "Opts this model out of generated navigation (e.g. API-only models). `buildModelRoutes` still returns the route flagged `hidden: true` — filtering is the consumer's decision.\n\n**Example:**\n```atscript\n@db.table 'audit_log'\n@ui.nav.hidden\nexport interface AuditLog {\n```\n",
|
|
551
|
+
nodeType: ["interface", "type"],
|
|
552
|
+
passedWhenReferred: false
|
|
553
|
+
})
|
|
554
|
+
},
|
|
555
|
+
array: {
|
|
556
|
+
add: { label: new AnnotationSpec({
|
|
557
|
+
description: "Label for the add-item button (default: \"Add item\")",
|
|
558
|
+
nodeType: ["prop"],
|
|
559
|
+
argument: {
|
|
560
|
+
name: "label",
|
|
561
|
+
type: "string",
|
|
562
|
+
description: "Button label text"
|
|
563
|
+
}
|
|
564
|
+
}) },
|
|
565
|
+
remove: { label: new AnnotationSpec({
|
|
566
|
+
description: "Label for the remove-item button (default: \"Remove\")",
|
|
567
|
+
nodeType: ["prop"],
|
|
568
|
+
argument: {
|
|
569
|
+
name: "label",
|
|
570
|
+
type: "string",
|
|
571
|
+
description: "Button label text"
|
|
572
|
+
}
|
|
573
|
+
}) }
|
|
574
|
+
}
|
|
575
|
+
} };
|
|
576
|
+
//#endregion
|
|
577
|
+
export { uiAnnotations };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/plugin/primitives.ts
|
|
2
|
+
/**
|
|
3
|
+
* UI primitive types for atscript `.as` files.
|
|
4
|
+
*
|
|
5
|
+
* These register `ui.paragraph`, `ui.action`, `ui.select`, `ui.radio`, and `ui.checkbox`
|
|
6
|
+
* as first-class types usable in interface property definitions.
|
|
7
|
+
*/
|
|
8
|
+
const uiPrimitives = { ui: {
|
|
9
|
+
type: "phantom",
|
|
10
|
+
isContainer: true,
|
|
11
|
+
documentation: "Non-data UI elements for form rendering",
|
|
12
|
+
extensions: {
|
|
13
|
+
action: { documentation: "Form action button — not a data field, excluded from form data. Use with @ui.form.action to define alternate submit actions." },
|
|
14
|
+
paragraph: { documentation: "Read-only paragraph text — rendered as static content, not an input field. Use @meta.default for static text or @ui.form.fn.value for computed text." },
|
|
15
|
+
select: {
|
|
16
|
+
type: "string",
|
|
17
|
+
documentation: "Dropdown select field. Use @ui.form.options to define static choices or @ui.form.fn.options for computed choices."
|
|
18
|
+
},
|
|
19
|
+
radio: {
|
|
20
|
+
type: "string",
|
|
21
|
+
documentation: "Radio button group. Use @ui.form.options to define static choices or @ui.form.fn.options for computed choices."
|
|
22
|
+
},
|
|
23
|
+
checkbox: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
documentation: "Single boolean checkbox toggle."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} };
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.uiPrimitives = uiPrimitives;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/plugin/primitives.ts
|
|
2
|
+
/**
|
|
3
|
+
* UI primitive types for atscript `.as` files.
|
|
4
|
+
*
|
|
5
|
+
* These register `ui.paragraph`, `ui.action`, `ui.select`, `ui.radio`, and `ui.checkbox`
|
|
6
|
+
* as first-class types usable in interface property definitions.
|
|
7
|
+
*/
|
|
8
|
+
const uiPrimitives = { ui: {
|
|
9
|
+
type: "phantom",
|
|
10
|
+
isContainer: true,
|
|
11
|
+
documentation: "Non-data UI elements for form rendering",
|
|
12
|
+
extensions: {
|
|
13
|
+
action: { documentation: "Form action button — not a data field, excluded from form data. Use with @ui.form.action to define alternate submit actions." },
|
|
14
|
+
paragraph: { documentation: "Read-only paragraph text — rendered as static content, not an input field. Use @meta.default for static text or @ui.form.fn.value for computed text." },
|
|
15
|
+
select: {
|
|
16
|
+
type: "string",
|
|
17
|
+
documentation: "Dropdown select field. Use @ui.form.options to define static choices or @ui.form.fn.options for computed choices."
|
|
18
|
+
},
|
|
19
|
+
radio: {
|
|
20
|
+
type: "string",
|
|
21
|
+
documentation: "Radio button group. Use @ui.form.options to define static choices or @ui.form.fn.options for computed choices."
|
|
22
|
+
},
|
|
23
|
+
checkbox: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
documentation: "Single boolean checkbox toggle."
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
} };
|
|
29
|
+
//#endregion
|
|
30
|
+
export { uiPrimitives };
|