@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.
Files changed (156) hide show
  1. package/dist/client-factory.cjs +27 -0
  2. package/dist/client-factory.d.cts +53 -0
  3. package/dist/client-factory.d.mts +53 -0
  4. package/dist/client-factory.mjs +25 -0
  5. package/dist/form/apply.cjs +38 -0
  6. package/dist/form/apply.d.cts +36 -0
  7. package/dist/form/apply.d.mts +36 -0
  8. package/dist/form/apply.mjs +38 -0
  9. package/dist/form/clone.cjs +30 -0
  10. package/dist/form/clone.d.cts +23 -0
  11. package/dist/form/clone.d.mts +23 -0
  12. package/dist/form/clone.mjs +30 -0
  13. package/dist/form/create-form-def.cjs +440 -0
  14. package/dist/form/create-form-def.d.cts +67 -0
  15. package/dist/form/create-form-def.d.mts +67 -0
  16. package/dist/form/create-form-def.mjs +438 -0
  17. package/dist/form/decimal-format.cjs +324 -0
  18. package/dist/form/decimal-format.d.cts +86 -0
  19. package/dist/form/decimal-format.d.mts +86 -0
  20. package/dist/form/decimal-format.mjs +315 -0
  21. package/dist/form/diff.cjs +458 -0
  22. package/dist/form/diff.d.cts +80 -0
  23. package/dist/form/diff.d.mts +80 -0
  24. package/dist/form/diff.mjs +457 -0
  25. package/dist/form/dirty.cjs +65 -0
  26. package/dist/form/dirty.d.cts +47 -0
  27. package/dist/form/dirty.d.mts +47 -0
  28. package/dist/form/dirty.mjs +64 -0
  29. package/dist/form/error-utils.cjs +97 -0
  30. package/dist/form/error-utils.d.cts +58 -0
  31. package/dist/form/error-utils.d.mts +58 -0
  32. package/dist/form/error-utils.mjs +92 -0
  33. package/dist/form/form-actions.cjs +30 -0
  34. package/dist/form/form-actions.d.cts +17 -0
  35. package/dist/form/form-actions.d.mts +17 -0
  36. package/dist/form/form-actions.mjs +30 -0
  37. package/dist/form/grid.cjs +69 -0
  38. package/dist/form/grid.d.cts +49 -0
  39. package/dist/form/grid.d.mts +49 -0
  40. package/dist/form/grid.mjs +64 -0
  41. package/dist/form/labels.cjs +10 -0
  42. package/dist/form/labels.d.cts +7 -0
  43. package/dist/form/labels.d.mts +7 -0
  44. package/dist/form/labels.mjs +10 -0
  45. package/dist/form/measurement.cjs +20 -0
  46. package/dist/form/measurement.d.cts +29 -0
  47. package/dist/form/measurement.d.mts +29 -0
  48. package/dist/form/measurement.mjs +20 -0
  49. package/dist/form/path-utils.cjs +182 -0
  50. package/dist/form/path-utils.d.cts +47 -0
  51. package/dist/form/path-utils.d.mts +47 -0
  52. package/dist/form/path-utils.mjs +175 -0
  53. package/dist/form/rebase.cjs +89 -0
  54. package/dist/form/rebase.d.cts +61 -0
  55. package/dist/form/rebase.d.mts +61 -0
  56. package/dist/form/rebase.mjs +89 -0
  57. package/dist/form/skipped-nav.cjs +100 -0
  58. package/dist/form/skipped-nav.d.cts +13 -0
  59. package/dist/form/skipped-nav.d.mts +13 -0
  60. package/dist/form/skipped-nav.mjs +98 -0
  61. package/dist/form/types.cjs +40 -0
  62. package/dist/form/types.d.cts +133 -0
  63. package/dist/form/types.d.mts +133 -0
  64. package/dist/form/types.mjs +36 -0
  65. package/dist/form/union-detect.cjs +46 -0
  66. package/dist/form/union-detect.d.cts +22 -0
  67. package/dist/form/union-detect.d.mts +22 -0
  68. package/dist/form/union-detect.mjs +46 -0
  69. package/dist/form/validate.cjs +150 -0
  70. package/dist/form/validate.d.cts +50 -0
  71. package/dist/form/validate.d.mts +50 -0
  72. package/dist/form/validate.mjs +147 -0
  73. package/dist/index.cjs +217 -3360
  74. package/dist/index.d.cts +38 -1693
  75. package/dist/index.d.mts +38 -1693
  76. package/dist/index.mjs +35 -3179
  77. package/dist/nav/model-routes.cjs +59 -0
  78. package/dist/nav/model-routes.d.cts +33 -0
  79. package/dist/nav/model-routes.d.mts +33 -0
  80. package/dist/nav/model-routes.mjs +59 -0
  81. package/dist/plugin/annotations.cjs +577 -0
  82. package/dist/plugin/annotations.mjs +577 -0
  83. package/dist/plugin/primitives.cjs +30 -0
  84. package/dist/plugin/primitives.mjs +30 -0
  85. package/dist/plugin/value-help-validation.cjs +419 -0
  86. package/dist/plugin/value-help-validation.mjs +413 -0
  87. package/dist/plugin.cjs +4 -1001
  88. package/dist/plugin.mjs +2 -999
  89. package/dist/shared/annotation-keys.cjs +189 -0
  90. package/dist/shared/annotation-keys.d.cts +82 -0
  91. package/dist/shared/annotation-keys.d.mts +82 -0
  92. package/dist/shared/annotation-keys.mjs +97 -0
  93. package/dist/shared/field-resolver.cjs +123 -0
  94. package/dist/shared/field-resolver.d.cts +77 -0
  95. package/dist/shared/field-resolver.d.mts +77 -0
  96. package/dist/shared/field-resolver.mjs +110 -0
  97. package/dist/shared/meta-cache.cjs +244 -0
  98. package/dist/shared/meta-cache.d.cts +110 -0
  99. package/dist/shared/meta-cache.d.mts +110 -0
  100. package/dist/shared/meta-cache.mjs +237 -0
  101. package/dist/shared/str.cjs +19 -0
  102. package/dist/shared/str.d.cts +7 -0
  103. package/dist/shared/str.d.mts +7 -0
  104. package/dist/shared/str.mjs +17 -0
  105. package/dist/table/column-resolver.cjs +17 -0
  106. package/dist/table/column-resolver.d.cts +11 -0
  107. package/dist/table/column-resolver.d.mts +11 -0
  108. package/dist/table/column-resolver.mjs +15 -0
  109. package/dist/table/create-table-def.cjs +233 -0
  110. package/dist/table/create-table-def.d.cts +15 -0
  111. package/dist/table/create-table-def.d.mts +15 -0
  112. package/dist/table/create-table-def.mjs +233 -0
  113. package/dist/table/navigate-href.cjs +45 -0
  114. package/dist/table/navigate-href.d.cts +31 -0
  115. package/dist/table/navigate-href.d.mts +31 -0
  116. package/dist/table/navigate-href.mjs +45 -0
  117. package/dist/table/types.d.cts +287 -0
  118. package/dist/table/types.d.mts +287 -0
  119. package/dist/table/value-kind.cjs +20 -0
  120. package/dist/table/value-kind.d.cts +15 -0
  121. package/dist/table/value-kind.d.mts +15 -0
  122. package/dist/table/value-kind.mjs +19 -0
  123. package/dist/value-help/dict-paths.cjs +17 -0
  124. package/dist/value-help/dict-paths.d.cts +11 -0
  125. package/dist/value-help/dict-paths.d.mts +11 -0
  126. package/dist/value-help/dict-paths.mjs +17 -0
  127. package/dist/value-help/distinct-client.cjs +51 -0
  128. package/dist/value-help/distinct-client.d.cts +40 -0
  129. package/dist/value-help/distinct-client.d.mts +40 -0
  130. package/dist/value-help/distinct-client.mjs +50 -0
  131. package/dist/value-help/extract-literals.cjs +76 -0
  132. package/dist/value-help/extract-literals.d.cts +32 -0
  133. package/dist/value-help/extract-literals.d.mts +32 -0
  134. package/dist/value-help/extract-literals.mjs +74 -0
  135. package/dist/value-help/extract-ref.cjs +100 -0
  136. package/dist/value-help/extract-ref.d.cts +37 -0
  137. package/dist/value-help/extract-ref.d.mts +37 -0
  138. package/dist/value-help/extract-ref.mjs +100 -0
  139. package/dist/value-help/filter-tree.cjs +45 -0
  140. package/dist/value-help/filter-tree.mjs +45 -0
  141. package/dist/value-help/index.d.mts +8 -0
  142. package/dist/value-help/resolve-options.cjs +64 -0
  143. package/dist/value-help/resolve-options.d.cts +35 -0
  144. package/dist/value-help/resolve-options.d.mts +35 -0
  145. package/dist/value-help/resolve-options.mjs +60 -0
  146. package/dist/value-help/resolve.cjs +62 -0
  147. package/dist/value-help/resolve.d.cts +31 -0
  148. package/dist/value-help/resolve.d.mts +31 -0
  149. package/dist/value-help/resolve.mjs +61 -0
  150. package/dist/value-help/types.d.cts +36 -0
  151. package/dist/value-help/types.d.mts +36 -0
  152. package/dist/value-help/value-help-client.cjs +136 -0
  153. package/dist/value-help/value-help-client.d.cts +67 -0
  154. package/dist/value-help/value-help-client.d.mts +67 -0
  155. package/dist/value-help/value-help-client.mjs +134 -0
  156. package/package.json +10 -10
package/dist/plugin.cjs CHANGED
@@ -1,1002 +1,5 @@
1
- let _atscript_core = require("@atscript/core");
2
- let _atscript_db_shared = require("@atscript/db/shared");
3
- //#region src/plugin/value-help-validation.ts
4
- /**
5
- * Editor scopes + validators of `@ui.valueHelp`, `@ui.valueHelp.distinct` and
6
- * `@ui.literalLabel` (since 0.1.148). Scopes and validators share one source,
7
- * so a diagnostic and what the editor completes never diverge.
8
- */
9
- const WARNING = 2;
10
- const ERROR = 1;
11
- const MAX_DEPTH = 8;
12
- /** The target type text (first argument) of the annotation the argument belongs to. */
13
- function targetOf(arg) {
14
- return (0, _atscript_core.getSiblingAnnotation)(arg)?.args[0]?.text || void 0;
15
- }
16
- const valueHelpScopes = {
17
- field: (arg) => {
18
- const target = targetOf(arg);
19
- return target ? {
20
- allowedTypes: [],
21
- unqualifiedTarget: target
22
- } : void 0;
23
- },
24
- filter: (arg) => {
25
- const target = targetOf(arg);
26
- return target ? {
27
- allowedTypes: [target],
28
- unqualifiedTarget: target
29
- } : void 0;
30
- }
31
- };
32
- /** `refFilter` of the binding target: an interface that is not a `@db.alias`. */
33
- function isValueHelpTarget(decl) {
34
- return (0, _atscript_core.isInterface)(decl) && !(0, _atscript_db_shared.isAliasDecl)(decl);
35
- }
36
- /**
37
- * The one resolver behind {@link designOf} and {@link collectLiterals}: the leaf
38
- * definitions of a type expression with refs, type aliases and unions unwound
39
- * (an intersection is one leaf). `null` marks a branch that cannot be resolved,
40
- * so the callers skip their check instead of guessing.
41
- */
42
- function leavesOf(def, doc, depth = 0) {
43
- if (!def || depth > MAX_DEPTH) return [null];
44
- switch (def.entity) {
45
- case "ref": {
46
- const ref = def;
47
- const unwound = doc.unwindType(ref.id, ref.chain);
48
- return unwound ? leavesOf(unwound.def, unwound.doc, depth + 1) : [null];
49
- }
50
- case "type": return leavesOf(def.getDefinition(), doc, depth + 1);
51
- case "group": {
52
- const group = def;
53
- if (group.op === "&") return [{
54
- def,
55
- doc
56
- }];
57
- return group.unwrap().flatMap((item) => leavesOf(item, doc, depth + 1));
58
- }
59
- default: return [{
60
- def,
61
- doc
62
- }];
63
- }
64
- }
65
- function constDesign(def) {
66
- const token = def.token("identifier");
67
- if (token?.type === "text") return "string";
68
- if (token?.type === "number") return "number";
69
- if (token?.text === "true" || token?.text === "false") return "boolean";
70
- return "other";
71
- }
72
- function leafDesign(def) {
73
- switch (def.entity) {
74
- case "primitive": {
75
- const base = (0, _atscript_db_shared.primitiveBaseType)(def);
76
- if (base === "string" || base === "number" || base === "decimal" || base === "boolean") return base;
77
- if (base === "object") return "object";
78
- if (base === "array" || base === "tuple") return "array";
79
- return base ? "other" : void 0;
80
- }
81
- case "const": return constDesign(def);
82
- case "structure":
83
- case "interface":
84
- case "group": return "object";
85
- case "array":
86
- case "tuple": return "array";
87
- default: return;
88
- }
89
- }
90
- /** A `null` / `undefined` / `void` leaf: it does not take part in a field's value kind. */
91
- function isEmptyLeaf(def) {
92
- if (def.entity !== "primitive") return false;
93
- const base = (0, _atscript_db_shared.primitiveBaseType)(def);
94
- return base === "null" || base === "void" || base === "undefined";
95
- }
96
- /** Design type of a resolved definition; `undefined` when it cannot be resolved (skip checks). */
97
- function designOf(def, doc) {
98
- const leaves = leavesOf(def, doc);
99
- const present = leaves.filter((leaf) => !leaf || !isEmptyLeaf(leaf.def));
100
- const kinds = new Set((present.length > 0 ? present : leaves).map((leaf) => leaf ? leafDesign(leaf.def) : void 0));
101
- if (kinds.has(void 0)) return void 0;
102
- return kinds.size === 1 ? [...kinds][0] : "other";
103
- }
104
- /**
105
- * The definition an annotated node stands for, with the document that declares it: a prop /
106
- * type declaration's definition, or — in an `annotate` block — the entry's target type.
107
- */
108
- function hostLeaves(node, doc) {
109
- const host = doc.annotatedDefinition(node);
110
- return host ? leavesOf(host.def, host.doc) : [null];
111
- }
112
- /** Whether a resolved leaf is a `number.timestamp` (any extension of it): the primitive's tags say so. */
113
- function isTimestampLeaf(def) {
114
- if ((0, _atscript_db_shared.primitiveBaseType)(def) !== "number") return false;
115
- const tags = def.tags;
116
- return !!tags && (tags.has("timestamp") || tags.has("created") || tags.has("updated"));
117
- }
118
- function hostDesign(token, doc) {
119
- const host = doc.annotatedDefinition(token.parentNode);
120
- return host ? designOf(host.def, host.doc) : void 0;
121
- }
122
- /** Collects the literal values of a pure literal union; `undefined` when it cannot be resolved. */
123
- function collectLiterals(def, doc, out, depth = 0) {
124
- let unresolved = false;
125
- for (const leaf of leavesOf(def, doc, depth)) if (!leaf) unresolved = true;
126
- else if (leaf.def.entity === "const") {
127
- const text = leaf.def.token("identifier")?.text;
128
- if (text === void 0) return false;
129
- out.push({
130
- text,
131
- def: leaf.def,
132
- doc: leaf.doc
133
- });
134
- } else if (leaf.def.entity === "array") {
135
- const ok = collectLiterals(leaf.def.getDefinition(), leaf.doc, out, depth + 1);
136
- if (ok === false) return false;
137
- if (ok === void 0) unresolved = true;
138
- } else return false;
139
- return unresolved ? void 0 : true;
140
- }
141
- /** {@link collectLiterals} of the type an annotated node stands for. */
142
- function collectHostLiterals(node, doc, out) {
143
- const host = doc.annotatedDefinition(node);
144
- return collectLiterals(host?.def, host?.doc ?? doc, out);
145
- }
146
- function resolveTarget(name, doc) {
147
- const owner = doc.getDeclarationOwnerNode(name);
148
- if (!owner?.node || !(0, _atscript_core.isInterface)(owner.node)) return void 0;
149
- const props = /* @__PURE__ */ new Map();
150
- for (const prop of (0, _atscript_core.getFieldsForType)(doc, name)) if (prop.id) props.set(prop.id, prop);
151
- return {
152
- doc: owner.doc,
153
- decl: owner.node,
154
- props
155
- };
156
- }
157
- /**
158
- * The annotated TARGET prop: the prop itself for an inline annotation, or — for an `annotate`
159
- * entry — the prop of the target type the entry names. Its owning struct and declaration are
160
- * resolved the same way as for an inline prop. `undefined` when the entry does not resolve.
161
- */
162
- function annotatedField(node, doc) {
163
- if (!node) return void 0;
164
- let prop = node;
165
- let path = node.id ?? "";
166
- if ((0, _atscript_core.isRef)(node)) {
167
- const idToken = node.token("identifier");
168
- const block = idToken ? doc.annotateBlockAt(idToken.range.start.line, idToken.range.start.character) : void 0;
169
- if (block) {
170
- const chain = [node.id, ...node.chain.map((c) => c.text)];
171
- path = chain.join(".");
172
- prop = (doc.unwindType(block.targetName, chain.slice(0, -1))?.def)?.props?.get(chain.at(-1));
173
- }
174
- }
175
- if (!prop || !(0, _atscript_core.isProp)(prop)) return void 0;
176
- let struct;
177
- let up = prop.ownerNode;
178
- while (up && !(0, _atscript_core.isInterface)(up)) {
179
- if ((0, _atscript_core.isStructure)(up)) struct = up;
180
- up = up.ownerNode;
181
- }
182
- const owner = up && (0, _atscript_core.isInterface)(up) ? up : struct;
183
- return {
184
- prop,
185
- path,
186
- struct,
187
- owner
188
- };
189
- }
190
- function isNavigation(node) {
191
- return !!node && (node.countAnnotations("db.rel.to") > 0 || node.countAnnotations("db.rel.from") > 0 || node.countAnnotations("db.rel.via") > 0);
192
- }
193
- /** Top-level conjuncts of a predicate (an `and` chain flattened). */
194
- function conjuncts(expr) {
195
- if ((0, _atscript_core.isQueryLogical)(expr) && expr.operator === "and") return expr.operands.flatMap(conjuncts);
196
- return [expr];
197
- }
198
- /**
199
- * Fields the filter pins with a top-level `=` against a literal value. The
200
- * compile-time twin of `pinnedOf` in `value-help/filter-tree.ts` (which reads the
201
- * emitted tree at runtime) — keep the two rules in step.
202
- */
203
- function pinnedFields(filter) {
204
- const pinned = /* @__PURE__ */ new Set();
205
- const expr = filter?.queryNode?.expression;
206
- if (!expr) return pinned;
207
- for (const c of conjuncts(expr)) if ((0, _atscript_core.isQueryComparison)(c) && c.operator === "=" && c.right && !("fieldRef" in c.right)) pinned.add(c.left.fieldRef.text);
208
- return pinned;
209
- }
210
- function validateValueHelp(token, args, doc) {
211
- const errors = [];
212
- const [targetArg, fieldArg, filterArg] = args;
213
- const host = token.parentNode;
214
- const field = annotatedField(host, doc);
215
- if (isNavigation(field?.prop ?? host)) errors.push({
216
- message: "@ui.valueHelp is not valid on a navigation field — bind the foreign-key field",
217
- severity: ERROR,
218
- range: token.range
219
- });
220
- errors.push(...(0, _atscript_db_shared.validateExclusiveWith)(token, "@ui.valueHelp", [{ key: "ui.valueHelp.distinct" }], doc));
221
- if (!targetArg) return errors;
222
- const targetErrors = (0, _atscript_db_shared.validateRefArgument)(targetArg, doc, {
223
- accept: isValueHelpTarget,
224
- expected: "must be an interface — a value-help dictionary."
225
- });
226
- errors.push(...targetErrors);
227
- if (targetErrors.length > 0) return errors;
228
- const targetName = targetArg.text;
229
- const target = resolveTarget(targetName, doc);
230
- if (!target) return errors;
231
- if (!(0, _atscript_db_shared.isDbSourceDecl)(target.decl) && target.decl.countAnnotations("db.http.path") === 0) errors.push({
232
- message: `'${targetName}' is not a @db.table / @db.view and has no @db.http.path — the binding is ignored and the field falls back to its foreign key`,
233
- severity: WARNING,
234
- range: targetArg.range
235
- });
236
- const fieldName = fieldArg?.text;
237
- let fieldDesign;
238
- let fieldProp;
239
- if (fieldArg && fieldName !== void 0) {
240
- fieldProp = fieldName.includes(".") ? void 0 : target.props.get(fieldName);
241
- if (!fieldProp) errors.push({
242
- message: fieldName.includes(".") ? `Value-help field '${fieldName}' must be a top-level field of '${targetName}', not a dotted path` : `Field '${fieldName}' does not exist on '${targetName}'`,
243
- severity: ERROR,
244
- range: fieldArg.range
245
- });
246
- else {
247
- fieldDesign = designOf(fieldProp.getDefinition(), target.doc);
248
- if (fieldProp.countAnnotations("db.json") > 0 || fieldDesign === "object" || fieldDesign === "array") {
249
- errors.push({
250
- message: `Value-help field '${targetName}.${fieldName}' must be a scalar (not an object, array or @db.json)`,
251
- severity: ERROR,
252
- range: fieldArg.range
253
- });
254
- fieldDesign = void 0;
255
- }
256
- }
257
- }
258
- if (fieldDesign && fieldDesign !== "other") {
259
- const hostType = hostDesign(token, doc);
260
- if (hostType && hostType !== fieldDesign) errors.push({
261
- message: `Value-help field '${targetName}.${fieldName}' is ${fieldDesign}, '${field?.path || host?.id || "this field"}' is ${hostType}`,
262
- severity: ERROR,
263
- range: token.range
264
- });
265
- }
266
- const filterQuery = filterArg?.queryNode;
267
- if (filterArg && filterQuery) {
268
- errors.push(...(0, _atscript_db_shared.validateQueryScope)(filterArg, {
269
- allowedTypes: [targetName],
270
- unqualifiedTarget: targetName
271
- }, doc));
272
- for (const cmp of comparisons(filterQuery.expression)) if (cmp.right && "fieldRef" in cmp.right) errors.push({
273
- message: "a value-help filter compares target fields with literal values",
274
- severity: ERROR,
275
- range: cmp.right.fieldRef.range
276
- });
277
- }
278
- if (fieldProp && fieldName !== void 0) {
279
- const idFields = [...target.props.entries()].filter(([, p]) => p.countAnnotations("meta.id") > 0);
280
- let ok = fieldProp.countAnnotations("db.index.unique") > 0 || fieldProp.countAnnotations("meta.id") > 0 && idFields.length === 1;
281
- if (!ok && fieldProp.countAnnotations("meta.id") > 0) {
282
- const pinned = pinnedFields(filterArg);
283
- ok = idFields.every(([name]) => name === fieldName || pinned.has(name));
284
- }
285
- if (!ok) errors.push({
286
- message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' in the filter)`,
287
- severity: WARNING,
288
- range: token.range
289
- });
290
- }
291
- if (filterQuery && (0, _atscript_db_shared.getAnnotationAlias)(target.decl, "db.table.filterable") === "manual") {
292
- const seen = /* @__PURE__ */ new Set();
293
- (0, _atscript_db_shared.forEachFieldRef)(filterQuery.expression, (ref) => {
294
- if (ref.typeRef && ref.typeRef.text !== targetName) return;
295
- const name = ref.fieldRef.text;
296
- if (seen.has(name)) return;
297
- seen.add(name);
298
- const prop = target.props.get(name.split(".")[0]);
299
- if (prop && prop.countAnnotations("db.column.filterable") === 0) errors.push({
300
- message: `the dictionary controller will reject this filter ('${name}' needs @db.column.filterable)`,
301
- severity: WARNING,
302
- range: ref.fieldRef.range
303
- });
304
- });
305
- }
306
- return errors;
307
- }
308
- /** Every comparison of a predicate, depth-first. */
309
- function comparisons(expr) {
310
- if ((0, _atscript_core.isQueryLogical)(expr)) return expr.operands.flatMap(comparisons);
311
- return (0, _atscript_core.isQueryComparison)(expr) ? [expr] : [];
312
- }
313
- function validateDistinct(token, _args, doc) {
314
- const errors = [];
315
- const host = token.parentNode;
316
- const design = hostDesign(token, doc);
317
- if (hostLeaves(host, doc).some((leaf) => leaf && isTimestampLeaf(leaf.def))) errors.push({
318
- message: "@ui.valueHelp.distinct requires a string or number field, got timestamp — a timestamp is not a value to pick from a list",
319
- severity: ERROR,
320
- range: token.range
321
- });
322
- else if (design && design !== "string" && design !== "number") errors.push({
323
- message: `@ui.valueHelp.distinct requires a string or number field, got ${design}`,
324
- severity: ERROR,
325
- range: token.range
326
- });
327
- const field = annotatedField(host, doc);
328
- const owner = field?.owner;
329
- if (!owner || !field) return errors;
330
- if (!(0, _atscript_db_shared.isDbSourceDecl)(owner)) {
331
- errors.push({
332
- message: "distinct values are served by a DB controller — declare this on a @db.table/@db.view",
333
- severity: WARNING,
334
- range: token.range
335
- });
336
- return errors;
337
- }
338
- const struct = field.struct;
339
- if (struct && (0, _atscript_core.isStructure)(struct) && field.prop.countAnnotations("db.column.dimension") === 0 && (0, _atscript_db_shared.isStrictAggregateStruct)(struct)) errors.push({
340
- message: `$groupBy rejects this field of a strict aggregate table: ${_atscript_db_shared.NOT_DIMENSION_REASON} (add @db.column.dimension)`,
341
- severity: WARNING,
342
- range: token.range
343
- });
344
- return errors;
345
- }
346
- /**
347
- * `valueScope` of `@ui.literalLabel`'s `value`: the literals of the annotated
348
- * union (or array of one), each linked to the literal it declares — completion
349
- * offers them and go-to-definition on the value jumps to the literal.
350
- */
351
- function literalLabelValues(annotationToken, doc) {
352
- const found = [];
353
- if (collectHostLiterals(annotationToken.parentNode, doc, found) === false) return;
354
- const seen = /* @__PURE__ */ new Set();
355
- const candidates = [];
356
- for (const { text, def, doc: declaring } of found) {
357
- if (seen.has(text)) continue;
358
- seen.add(text);
359
- const token = def.token("identifier");
360
- candidates.push({
361
- value: text,
362
- ...token && { definition: {
363
- doc: declaring,
364
- token
365
- } }
366
- });
367
- }
368
- return candidates.length > 0 ? candidates : void 0;
369
- }
370
- function validateLiteralLabel(token, args, doc) {
371
- const errors = [];
372
- const host = token.parentNode;
373
- const found = [];
374
- const pure = collectHostLiterals(host, doc, found);
375
- const literals = found.map((l) => l.text);
376
- if (pure === false) {
377
- errors.push({
378
- message: "@ui.literalLabel requires a union of literal values (or an array of one)",
379
- severity: ERROR,
380
- range: token.range
381
- });
382
- return errors;
383
- }
384
- const value = args[0];
385
- if (!value) return errors;
386
- if (pure === true && !literals.includes(value.text)) errors.push({
387
- message: `'${value.text}' is not one of the literals: ${literals.map((l) => `'${l}'`).join(", ")}`,
388
- severity: ERROR,
389
- range: value.range
390
- });
391
- if ((host?.annotations ?? []).filter((a) => a.name === "ui.literalLabel" && a.args[0]?.text === value.text).findIndex((a) => a.token === token) > 0) errors.push({
392
- message: `duplicate @ui.literalLabel for '${value.text}'`,
393
- severity: ERROR,
394
- range: value.range
395
- });
396
- return errors;
397
- }
398
- //#endregion
399
- //#region src/plugin/annotations.ts
400
- const BUILTIN_TYPES = [
401
- "text",
402
- "password",
403
- "number",
404
- "decimal",
405
- "select",
406
- "multiselect",
407
- "textarea",
408
- "checkbox",
409
- "radio",
410
- "date",
411
- "datetime",
412
- "time",
413
- "paragraph",
414
- "action"
415
- ];
416
- const COL_SPAN_VALUES = [
417
- "1",
418
- "2",
419
- "3",
420
- "4",
421
- "5",
422
- "6",
423
- "7",
424
- "8",
425
- "9",
426
- "10",
427
- "11",
428
- "12",
429
- "full",
430
- "half",
431
- "third"
432
- ];
433
- const ROW_SPAN_VALUES = [
434
- "1",
435
- "2",
436
- "3",
437
- "4",
438
- "5",
439
- "6"
440
- ];
441
- /**
442
- * Static `@ui.*` annotation specs registered by the `@atscript/ui` plugin.
443
- *
444
- * Namespace contract (see Decision 1 in design.md):
445
- * - `ui.<key>` — explicit cross-surface shared (`type`)
446
- * - `ui.form.<key>` — form-only static
447
- * - `ui.table.<key>` — table-only static
448
- * - `ui.dict.<key>` — value-help annotations
449
- * - `ui.valueHelp`, `ui.literalLabel` — dictionary binding, union literal labels
450
- * - `ui.nav.<key>` — model-level navigation annotations
451
- * - `ui.array.<key>` — array control annotations
452
- *
453
- * The dynamic `ui.form.fn.*` / `ui.table.fn.*` and `ui.form.validate` specs
454
- * are declared by `@atscript/ui-fns`.
455
- */
456
- const uiAnnotations = { ui: {
457
- type: new _atscript_core.AnnotationSpec({
458
- 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",
459
- nodeType: ["prop", "type"],
460
- argument: {
461
- name: "type",
462
- type: "string",
463
- description: "The renderer type used by both form input and table cell unless overridden."
464
- }
465
- }),
466
- form: {
467
- placeholder: new _atscript_core.AnnotationSpec({
468
- description: "Defines **placeholder text** for UI input fields.\n\n**Example:**\n```atscript\n@ui.form.placeholder \"Enter your name\"\nname: string\n```\n",
469
- nodeType: ["prop", "type"],
470
- argument: {
471
- name: "text",
472
- type: "string",
473
- description: "The placeholder text to display in UI input fields."
474
- }
475
- }),
476
- hint: new _atscript_core.AnnotationSpec({
477
- 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",
478
- nodeType: ["prop", "type"],
479
- argument: {
480
- name: "text",
481
- type: "string",
482
- description: "Help text or tooltip content."
483
- }
484
- }),
485
- classes: new _atscript_core.AnnotationSpec({
486
- 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",
487
- nodeType: [
488
- "prop",
489
- "type",
490
- "interface"
491
- ],
492
- multiple: true,
493
- mergeStrategy: "append",
494
- argument: {
495
- name: "names",
496
- type: "string",
497
- description: "One or more CSS class names (space-separated)."
498
- }
499
- }),
500
- styles: new _atscript_core.AnnotationSpec({
501
- 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",
502
- nodeType: [
503
- "prop",
504
- "type",
505
- "interface"
506
- ],
507
- multiple: true,
508
- mergeStrategy: "append",
509
- argument: {
510
- name: "css",
511
- type: "string",
512
- description: "CSS style declarations (semicolon-separated)."
513
- }
514
- }),
515
- autocomplete: new _atscript_core.AnnotationSpec({
516
- 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",
517
- nodeType: ["prop", "type"],
518
- argument: {
519
- name: "value",
520
- type: "string",
521
- description: "HTML autocomplete attribute value."
522
- }
523
- }),
524
- disabled: new _atscript_core.AnnotationSpec({
525
- description: "Statically mark this field as disabled in the form.",
526
- nodeType: ["prop", "type"],
527
- passedWhenReferred: false
528
- }),
529
- options: new _atscript_core.AnnotationSpec({
530
- description: "Static option for select/radio fields. Repeat for each option. Label is the display text, value is the key (defaults to label).",
531
- nodeType: ["prop", "type"],
532
- multiple: true,
533
- mergeStrategy: "replace",
534
- argument: [{
535
- name: "label",
536
- type: "string",
537
- description: "Display label for the option"
538
- }, {
539
- name: "value",
540
- type: "string",
541
- optional: true,
542
- description: "Value/key for the option (defaults to label if omitted)"
543
- }]
544
- }),
545
- order: new _atscript_core.AnnotationSpec({
546
- description: "Explicit form-field ordering (lower values render first).",
547
- nodeType: ["prop", "type"],
548
- passedWhenReferred: false,
549
- argument: {
550
- name: "order",
551
- type: "number",
552
- description: "Numeric order (lower = earlier)"
553
- }
554
- }),
555
- type: new _atscript_core.AnnotationSpec({
556
- 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.",
557
- nodeType: ["prop", "type"],
558
- argument: {
559
- name: "type",
560
- type: "string",
561
- description: "The input type used by `<as-field>` for this prop."
562
- }
563
- }),
564
- component: new _atscript_core.AnnotationSpec({
565
- description: "Named component override for the form-side renderer.",
566
- nodeType: [
567
- "prop",
568
- "interface",
569
- "type"
570
- ],
571
- argument: {
572
- name: "name",
573
- type: "string",
574
- description: "Component name from the form components registry"
575
- }
576
- }),
577
- hidden: new _atscript_core.AnnotationSpec({
578
- description: "Statically hide this field in the form.",
579
- nodeType: ["prop", "type"],
580
- passedWhenReferred: false
581
- }),
582
- attr: new _atscript_core.AnnotationSpec({
583
- description: "Custom attribute or component prop applied to the form input. Repeat for each attr. Passed via v-bind.",
584
- nodeType: ["prop", "type"],
585
- multiple: true,
586
- mergeStrategy: "replace",
587
- argument: [{
588
- name: "name",
589
- type: "string",
590
- description: "Attribute/prop name (e.g., \"data-testid\", \"variant\", \"size\")"
591
- }, {
592
- name: "value",
593
- type: "string",
594
- description: "Static value (string, number, boolean, or undefined)"
595
- }]
596
- }),
597
- grid: {
598
- colSpan: new _atscript_core.AnnotationSpec({
599
- 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",
600
- nodeType: ["prop", "type"],
601
- argument: [{
602
- name: "desktop",
603
- type: "string",
604
- description: "Column span for non-narrow containers. \"1\"-\"12\", \"full\", \"half\", or \"third\".",
605
- values: COL_SPAN_VALUES
606
- }, {
607
- name: "narrow",
608
- type: "string",
609
- optional: true,
610
- description: "Column span for containers ≤480px wide. Defaults to \"full\".",
611
- values: COL_SPAN_VALUES
612
- }]
613
- }),
614
- rowSpan: new _atscript_core.AnnotationSpec({
615
- 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",
616
- nodeType: ["prop", "type"],
617
- argument: [{
618
- name: "desktop",
619
- type: "string",
620
- description: "Row span for non-narrow containers. \"1\"-\"6\".",
621
- values: ROW_SPAN_VALUES
622
- }, {
623
- name: "narrow",
624
- type: "string",
625
- optional: true,
626
- description: "Row span for containers ≤480px wide. Defaults to \"1\".",
627
- values: ROW_SPAN_VALUES
628
- }]
629
- })
630
- },
631
- submit: { text: new _atscript_core.AnnotationSpec({
632
- description: "Static submit button text.",
633
- nodeType: ["interface", "type"],
634
- argument: {
635
- name: "text",
636
- type: "string",
637
- description: "Submit button label"
638
- }
639
- }) },
640
- label: { singular: new _atscript_core.AnnotationSpec({
641
- 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",
642
- nodeType: ["prop", "type"],
643
- argument: {
644
- name: "singular",
645
- type: "string",
646
- description: "Singular label, e.g. \"phone number\" for a `phones` field."
647
- }
648
- }) },
649
- pushDown: new _atscript_core.AnnotationSpec({
650
- 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",
651
- nodeType: ["prop", "type"]
652
- }),
653
- action: new _atscript_core.AnnotationSpec({
654
- description: "Form action button for this field.",
655
- nodeType: ["prop", "type"],
656
- argument: [{
657
- name: "id",
658
- type: "string",
659
- description: "The action name emitted on trigger"
660
- }, {
661
- name: "label",
662
- type: "string",
663
- optional: true,
664
- description: "Display label for the action (falls back to @meta.label)"
665
- }]
666
- }),
667
- prefix: {
668
- $self: new _atscript_core.AnnotationSpec({
669
- 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",
670
- nodeType: ["prop", "type"],
671
- argument: {
672
- name: "value",
673
- type: "string",
674
- description: "Literal text to display before the input value."
675
- }
676
- }),
677
- ref: new _atscript_core.AnnotationSpec({
678
- 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",
679
- nodeType: ["prop", "type"],
680
- passedWhenReferred: false,
681
- argument: {
682
- name: "field",
683
- type: "string",
684
- description: "Name of a sibling field whose value drives the prefix."
685
- }
686
- }),
687
- icon: new _atscript_core.AnnotationSpec({
688
- 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",
689
- nodeType: ["prop", "type"],
690
- argument: {
691
- name: "class",
692
- type: "string",
693
- description: "CSS class painting the icon glyph. Consumer manages safelist / preset coverage."
694
- }
695
- })
696
- },
697
- suffix: {
698
- $self: new _atscript_core.AnnotationSpec({
699
- 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",
700
- nodeType: ["prop", "type"],
701
- argument: {
702
- name: "value",
703
- type: "string",
704
- description: "Literal text to display after the input value."
705
- }
706
- }),
707
- ref: new _atscript_core.AnnotationSpec({
708
- 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",
709
- nodeType: ["prop", "type"],
710
- passedWhenReferred: false,
711
- argument: {
712
- name: "field",
713
- type: "string",
714
- description: "Name of a sibling field whose value drives the suffix."
715
- }
716
- }),
717
- icon: new _atscript_core.AnnotationSpec({
718
- 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",
719
- nodeType: ["prop", "type"],
720
- argument: {
721
- name: "class",
722
- type: "string",
723
- description: "CSS class painting the icon glyph. Consumer manages safelist / preset coverage."
724
- }
725
- })
726
- }
727
- },
728
- table: {
729
- width: new _atscript_core.AnnotationSpec({
730
- 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",
731
- nodeType: ["prop", "type"],
732
- argument: {
733
- name: "width",
734
- type: "string",
735
- description: "CSS width for the column (e.g. '120px', '15em', '20ch')."
736
- }
737
- }),
738
- component: new _atscript_core.AnnotationSpec({
739
- description: "Named component override for the table-cell renderer.",
740
- nodeType: [
741
- "prop",
742
- "interface",
743
- "type"
744
- ],
745
- argument: {
746
- name: "name",
747
- type: "string",
748
- description: "Component name from the table components registry"
749
- }
750
- }),
751
- exclude: new _atscript_core.AnnotationSpec({
752
- 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.",
753
- nodeType: ["prop", "type"],
754
- passedWhenReferred: false
755
- }),
756
- attr: new _atscript_core.AnnotationSpec({
757
- description: "Custom attribute or component prop applied to the rendered `<td>`. Repeat for each attr. Passed via v-bind.",
758
- nodeType: ["prop", "type"],
759
- multiple: true,
760
- mergeStrategy: "replace",
761
- argument: [{
762
- name: "name",
763
- type: "string",
764
- description: "Attribute/prop name (e.g., \"title\", \"data-row\", \"aria-label\")"
765
- }, {
766
- name: "value",
767
- type: "string",
768
- description: "Static value applied to the cell."
769
- }]
770
- }),
771
- classes: new _atscript_core.AnnotationSpec({
772
- 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",
773
- nodeType: [
774
- "prop",
775
- "type",
776
- "interface"
777
- ],
778
- multiple: true,
779
- mergeStrategy: "append",
780
- argument: {
781
- name: "names",
782
- type: "string",
783
- description: "One or more CSS class names (space-separated)."
784
- }
785
- }),
786
- selectWith: new _atscript_core.AnnotationSpec({
787
- 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",
788
- nodeType: [
789
- "prop",
790
- "type",
791
- "interface"
792
- ],
793
- multiple: true,
794
- mergeStrategy: "append",
795
- argument: {
796
- name: "path",
797
- type: "string",
798
- description: "Sibling leaf field path to fetch alongside this column."
799
- },
800
- passedWhenReferred: false
801
- }),
802
- styles: new _atscript_core.AnnotationSpec({
803
- 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",
804
- nodeType: [
805
- "prop",
806
- "type",
807
- "interface"
808
- ],
809
- multiple: true,
810
- mergeStrategy: "append",
811
- argument: {
812
- name: "css",
813
- type: "string",
814
- description: "CSS style declarations (semicolon-separated)."
815
- }
816
- }),
817
- type: new _atscript_core.AnnotationSpec({
818
- 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.",
819
- nodeType: ["prop", "type"],
820
- argument: {
821
- name: "type",
822
- type: "string",
823
- description: "The cell renderer type dispatched via the table types map."
824
- }
825
- }),
826
- order: new _atscript_core.AnnotationSpec({
827
- description: "Initial column ordering — lower values appear first; user-driven runtime reorder still mutates table state's `columnNames`.",
828
- nodeType: ["prop", "type"],
829
- passedWhenReferred: false,
830
- argument: {
831
- name: "order",
832
- type: "number",
833
- description: "Numeric order (lower = earlier)"
834
- }
835
- })
836
- },
837
- valueHelp: {
838
- $self: new _atscript_core.AnnotationSpec({
839
- 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",
840
- nodeType: ["prop", "type"],
841
- multiple: false,
842
- argument: [
843
- {
844
- name: "target",
845
- type: "ref",
846
- description: "The dictionary interface (served by a controller exposing `@db.http.path`). Not a `@db.alias`.",
847
- refFilter: isValueHelpTarget
848
- },
849
- {
850
- name: "field",
851
- type: "string",
852
- description: "Top-level scalar field of the target whose value this field stores. Same type as this field.",
853
- fieldScope: valueHelpScopes.field
854
- },
855
- {
856
- optional: true,
857
- name: "filter",
858
- type: "query",
859
- description: "Static scope on the target (`attribute = 'color' and active = true`) — field-to-value comparisons of the target's fields only.",
860
- fieldScope: valueHelpScopes.filter
861
- }
862
- ],
863
- validate: validateValueHelp
864
- }),
865
- distinct: new _atscript_core.AnnotationSpec({
866
- 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",
867
- nodeType: ["prop", "type"],
868
- validate: validateDistinct
869
- })
870
- },
871
- literalLabel: new _atscript_core.AnnotationSpec({
872
- 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",
873
- nodeType: ["prop", "type"],
874
- multiple: true,
875
- mergeStrategy: "append",
876
- argument: [{
877
- name: "value",
878
- type: "string",
879
- description: "The literal as text (`'2'` for the number literal `2`).",
880
- valueScope: literalLabelValues
881
- }, {
882
- name: "label",
883
- type: "string",
884
- description: "Display label."
885
- }],
886
- validate: validateLiteralLabel
887
- }),
888
- dict: {
889
- label: new _atscript_core.AnnotationSpec({
890
- description: "Marks this field as the primary display label when the table is used as a value-help dictionary",
891
- nodeType: ["prop"],
892
- passedWhenReferred: false
893
- }),
894
- descr: new _atscript_core.AnnotationSpec({
895
- description: "Marks this field as the secondary description in value-help display",
896
- nodeType: ["prop"],
897
- passedWhenReferred: false
898
- }),
899
- attr: new _atscript_core.AnnotationSpec({
900
- description: "Marks this field as an additional attribute column in table-mode value help",
901
- nodeType: ["prop"],
902
- multiple: true,
903
- mergeStrategy: "append",
904
- passedWhenReferred: false
905
- }),
906
- filterable: new _atscript_core.AnnotationSpec({
907
- description: "Marks this field as filterable in the value-help picker UI. Surfaced via `meta.fields[name].filterable` on value-help `/meta` responses.",
908
- nodeType: ["prop"],
909
- passedWhenReferred: false
910
- }),
911
- sortable: new _atscript_core.AnnotationSpec({
912
- description: "Marks this field as sortable in the value-help picker UI. Surfaced via `meta.fields[name].sortable` on value-help `/meta` responses.",
913
- nodeType: ["prop"],
914
- passedWhenReferred: false
915
- }),
916
- searchable: new _atscript_core.AnnotationSpec({
917
- 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.",
918
- nodeType: ["prop", "interface"],
919
- passedWhenReferred: false
920
- })
921
- },
922
- nav: {
923
- group: new _atscript_core.AnnotationSpec({
924
- 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",
925
- nodeType: ["interface", "type"],
926
- passedWhenReferred: false,
927
- argument: {
928
- name: "group",
929
- type: "string",
930
- description: "Nav section name shared by related models."
931
- }
932
- }),
933
- order: new _atscript_core.AnnotationSpec({
934
- 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",
935
- nodeType: ["interface", "type"],
936
- passedWhenReferred: false,
937
- argument: {
938
- name: "order",
939
- type: "number",
940
- description: "Numeric order (lower = earlier)"
941
- }
942
- }),
943
- hidden: new _atscript_core.AnnotationSpec({
944
- 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",
945
- nodeType: ["interface", "type"],
946
- passedWhenReferred: false
947
- })
948
- },
949
- array: {
950
- add: { label: new _atscript_core.AnnotationSpec({
951
- description: "Label for the add-item button (default: \"Add item\")",
952
- nodeType: ["prop"],
953
- argument: {
954
- name: "label",
955
- type: "string",
956
- description: "Button label text"
957
- }
958
- }) },
959
- remove: { label: new _atscript_core.AnnotationSpec({
960
- description: "Label for the remove-item button (default: \"Remove\")",
961
- nodeType: ["prop"],
962
- argument: {
963
- name: "label",
964
- type: "string",
965
- description: "Button label text"
966
- }
967
- }) }
968
- }
969
- } };
970
- //#endregion
971
- //#region src/plugin/primitives.ts
972
- /**
973
- * UI primitive types for atscript `.as` files.
974
- *
975
- * These register `ui.paragraph`, `ui.action`, `ui.select`, `ui.radio`, and `ui.checkbox`
976
- * as first-class types usable in interface property definitions.
977
- */
978
- const uiPrimitives = { ui: {
979
- type: "phantom",
980
- isContainer: true,
981
- documentation: "Non-data UI elements for form rendering",
982
- extensions: {
983
- action: { documentation: "Form action button — not a data field, excluded from form data. Use with @ui.form.action to define alternate submit actions." },
984
- 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." },
985
- select: {
986
- type: "string",
987
- documentation: "Dropdown select field. Use @ui.form.options to define static choices or @ui.form.fn.options for computed choices."
988
- },
989
- radio: {
990
- type: "string",
991
- documentation: "Radio button group. Use @ui.form.options to define static choices or @ui.form.fn.options for computed choices."
992
- },
993
- checkbox: {
994
- type: "boolean",
995
- documentation: "Single boolean checkbox toggle."
996
- }
997
- }
998
- } };
999
- //#endregion
1
+ const require_annotations = require("./plugin/annotations.cjs");
2
+ const require_primitives = require("./plugin/primitives.cjs");
1000
3
  //#region src/plugin.ts
1001
4
  /**
1002
5
  * ATScript plugin that registers static UI annotations (`@ui.*`)
@@ -1016,8 +19,8 @@ function uiPlugin() {
1016
19
  name: "ui",
1017
20
  config() {
1018
21
  return {
1019
- primitives: uiPrimitives,
1020
- annotations: uiAnnotations
22
+ primitives: require_primitives.uiPrimitives,
23
+ annotations: require_annotations.uiAnnotations
1021
24
  };
1022
25
  }
1023
26
  };