@atscript/ui 0.1.147 → 0.1.149

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/index.mjs CHANGED
@@ -42,6 +42,7 @@ const UI_DICT_ATTR = "ui.dict.attr";
42
42
  const UI_DICT_FILTERABLE = "ui.dict.filterable";
43
43
  const UI_DICT_SORTABLE = "ui.dict.sortable";
44
44
  const UI_DICT_SEARCHABLE = "ui.dict.searchable";
45
+ const UI_VALUE_HELP = "ui.valueHelp";
45
46
  const UI_NAV_GROUP = "ui.nav.group";
46
47
  const UI_NAV_ORDER = "ui.nav.order";
47
48
  const UI_NAV_HIDDEN = "ui.nav.hidden";
@@ -220,10 +221,25 @@ function resolveAttrs(prop, scope, keys = {}) {
220
221
  * into union items and produces synthetic unions containing both individual
221
222
  * literals and the original union type as nested items.
222
223
  */
223
- function extractLiteralOptions(prop) {
224
+ function extractLiteralOptions(prop, outer) {
224
225
  if (prop.type.kind !== "union") return void 0;
225
226
  const result = collectLiterals(prop.type.items, /* @__PURE__ */ new Set());
226
- return result && result.length > 0 ? result : void 0;
227
+ if (!result || result.length === 0) return void 0;
228
+ const labels = [prop, outer].flatMap((node) => node?.metadata.get("ui.literalLabel") ?? []);
229
+ if (labels.length) {
230
+ const byValue = new Map(labels.map((l) => [l.value, l.label]));
231
+ for (const option of result) option.label = byValue.get(option.key) ?? option.label;
232
+ }
233
+ return result;
234
+ }
235
+ /**
236
+ * The literal options of a field: a literal union's, or those of an array of one
237
+ * (`tags: Tag[]`), where the array prop's own `@ui.literalLabel` labels win over the
238
+ * element type's. `undefined` when the field is neither. Since 0.1.148.
239
+ */
240
+ function extractFieldLiteralOptions(prop) {
241
+ if (prop.type.kind === "array") return extractLiteralOptions(prop.type.of, prop);
242
+ return extractLiteralOptions(prop);
227
243
  }
228
244
  /** Returns true when the annotated type is a union composed entirely of literal values. */
229
245
  function isPureLiteralUnion(prop) {
@@ -250,12 +266,14 @@ function checkAllLiterals(items) {
250
266
  function collectLiterals(items, seen) {
251
267
  const result = [];
252
268
  for (const item of items) if (item.type.kind === "" && item.type.value !== void 0) {
253
- const val = String(item.type.value);
269
+ const raw = item.type.value;
270
+ const val = String(raw);
254
271
  if (!seen.has(val)) {
255
272
  seen.add(val);
256
273
  result.push({
257
274
  key: val,
258
- label: val
275
+ label: val,
276
+ value: raw
259
277
  });
260
278
  }
261
279
  } else if (item.type.kind === "union") {
@@ -266,6 +284,50 @@ function collectLiterals(items, seen) {
266
284
  return result;
267
285
  }
268
286
  //#endregion
287
+ //#region src/value-help/filter-tree.ts
288
+ function isFieldRef(value) {
289
+ return value !== null && typeof value === "object" && "field" in value;
290
+ }
291
+ /**
292
+ * A deliberate copy of `translateQueryTree` from `@atscript/db`: that module is a
293
+ * server-side runtime, and importing it would pull `@atscript/db` into the browser
294
+ * bundle. `filter-tree.spec.ts` guards the two against drift.
295
+ */
296
+ function translate(node) {
297
+ if (Array.isArray(node.$and)) return { $and: node.$and.map(translate) };
298
+ if (Array.isArray(node.$or)) return { $or: node.$or.map(translate) };
299
+ if (node.$not && typeof node.$not === "object") return { $not: translate(node.$not) };
300
+ const left = node.left.field;
301
+ const op = node.op;
302
+ const right = node.right;
303
+ if (isFieldRef(right)) return { [left]: { [op]: { $field: right.field } } };
304
+ if (op === "$exists") return { [left]: { $exists: right !== false } };
305
+ return { [left]: { [op]: right } };
306
+ }
307
+ /**
308
+ * Fields the tree pins to one value (`=` comparison against a literal) at its top-level
309
+ * `and` chain. The runtime twin of `pinnedFields` in `plugin/value-help-validation.ts`
310
+ * (which reads the source predicate) — keep the two rules in step.
311
+ */
312
+ function pinnedOf(node, out) {
313
+ if (Array.isArray(node.$and)) for (const n of node.$and) pinnedOf(n, out);
314
+ else if (node.left && node.op === "$eq" && !isFieldRef(node.right)) out.push(node.left.field);
315
+ }
316
+ /**
317
+ * Translates the static `filter` of a `@ui.valueHelp` binding into a Uniquery
318
+ * `FilterExpr` (mirrors `translateQueryTree` of `@atscript/db`, with refs
319
+ * resolved to the plain field path), plus the target fields it pins with `=` —
320
+ * constant inside the picker, so their columns are hidden. Since 0.1.148.
321
+ */
322
+ function valueHelpFilter(tree) {
323
+ const pinned = [];
324
+ pinnedOf(tree, pinned);
325
+ return {
326
+ filter: translate(tree),
327
+ pinned: [...new Set(pinned)]
328
+ };
329
+ }
330
+ //#endregion
269
331
  //#region src/value-help/extract-ref.ts
270
332
  /**
271
333
  * Hard cap on how many `.ref` hops the chain walk follows. Real chains are one
@@ -274,8 +336,50 @@ function collectLiterals(items, seen) {
274
336
  */
275
337
  const MAX_REF_CHAIN_DEPTH = 8;
276
338
  /**
339
+ * `@db.http.path` of a binding target. Two producers, two shapes — `/meta`
340
+ * deserialization does not normalize annotation values, so both are read here:
341
+ *
342
+ * - compiled `.as` (the atscript runtime): the annotated type itself (a class
343
+ * with a `metadata` Map) or a getter `() => Type` for a cross-file ref;
344
+ * - `/meta` (the serialized type): a shallow target `{ id, metadata }` whose
345
+ * `metadata` is a plain record.
346
+ *
347
+ * Also accepts `{ type: () => Type }`.
348
+ */
349
+ function bindingTargetPath(target) {
350
+ if (target === null || typeof target !== "object" && typeof target !== "function") return;
351
+ const t = target;
352
+ if (typeof target === "function" && t.metadata === void 0) return bindingTargetPath(target());
353
+ if (t.metadata instanceof Map) return t.metadata.get(DB_HTTP_PATH);
354
+ if (t.metadata && typeof t.metadata === "object") return t.metadata[DB_HTTP_PATH];
355
+ return t.type === void 0 ? void 0 : bindingTargetPath(t.type);
356
+ }
357
+ /**
358
+ * The `@ui.valueHelp` binding of a node, when its target is served by a
359
+ * controller (`@db.http.path`). Without a path the binding is ignored and the
360
+ * caller falls back to the FK walk.
361
+ */
362
+ function bindingInfo(node) {
363
+ const binding = node.metadata.get(UI_VALUE_HELP);
364
+ if (!binding?.field) return void 0;
365
+ const url = bindingTargetPath(binding.target);
366
+ if (!url) return void 0;
367
+ const info = {
368
+ url,
369
+ targetField: binding.field
370
+ };
371
+ if (binding.filter) {
372
+ const { filter, pinned } = valueHelpFilter(binding.filter);
373
+ info.filter = filter;
374
+ if (pinned.length > 0) info.pinned = pinned;
375
+ }
376
+ return info;
377
+ }
378
+ /**
277
379
  * Synchronous probe. Returns `{ url, targetField }` for the first link of the
278
- * reference chain starting at `prop` that satisfies all three conditions:
380
+ * reference chain starting at `prop` that carries a `@ui.valueHelp` binding
381
+ * (since 0.1.148 — an explicit binding beats `@db.rel.FK`, and also supplies
382
+ * the static `filter` / `pinned` fields), or that satisfies all three conditions:
279
383
  *
280
384
  * 1. the link carries `@db.rel.FK`,
281
385
  * 2. the link has a `.ref`,
@@ -304,6 +408,8 @@ const MAX_REF_CHAIN_DEPTH = 8;
304
408
  function extractValueHelp(prop) {
305
409
  let node = prop;
306
410
  for (let depth = 0; node && depth < MAX_REF_CHAIN_DEPTH; depth++) {
411
+ const bound = bindingInfo(node);
412
+ if (bound) return bound;
307
413
  const ref = node.ref;
308
414
  if (!ref) return void 0;
309
415
  const target = ref.type();
@@ -663,6 +769,25 @@ function optKey(opt) {
663
769
  function optLabel(opt) {
664
770
  return typeof opt === "string" ? opt : opt.label;
665
771
  }
772
+ const labelMaps = /* @__PURE__ */ new WeakMap();
773
+ /**
774
+ * The display label of a literal-union column's option (`@ui.literalLabel`) for
775
+ * `value` — `undefined` when the column has no options or none matches. Map-backed
776
+ * per options array, so rendering a table does not scan the options per cell.
777
+ * The one lookup behind the table cell, the filter chips, export and a custom cell.
778
+ * Since 0.1.148.
779
+ */
780
+ function optionLabel(column, value) {
781
+ const options = column.options;
782
+ if (!options?.length) return void 0;
783
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return;
784
+ let labels = labelMaps.get(options);
785
+ if (!labels) {
786
+ labels = new Map(options.map((o) => [o.key, o.label]));
787
+ labelMaps.set(options, labels);
788
+ }
789
+ return labels.get(String(value));
790
+ }
666
791
  /**
667
792
  * Converts raw option annotation value to a normalized array.
668
793
  */
@@ -688,9 +813,23 @@ function parseStaticOptions(raw) {
688
813
  function resolveOptions(prop, scope) {
689
814
  const resolved = resolveFieldProp(prop, UI_FORM_FN_OPTIONS, UI_FORM_OPTIONS, scope, { transform: parseStaticOptions });
690
815
  if (resolved !== void 0) return resolved;
691
- const literals = extractLiteralOptions(prop);
692
- if (literals !== void 0) return literals;
693
- if (prop.type.kind === "array") return extractLiteralOptions(prop.type.of);
816
+ return extractFieldLiteralOptions(prop);
817
+ }
818
+ //#endregion
819
+ //#region src/shared/str.ts
820
+ /** Converts a dot-path to a human-readable label (e.g. 'firstName' → 'First Name'). */
821
+ function humanizePath(path) {
822
+ return path.slice(path.lastIndexOf(".") + 1).replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (s) => s.toUpperCase());
823
+ }
824
+ /** Escape special regex characters in user input for safe embedding in a `$regex` filter. */
825
+ function escapeRegex(input) {
826
+ return input.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
827
+ }
828
+ /** Safely convert an unknown value to a string without triggering no-base-to-string lint errors. */
829
+ function str(value) {
830
+ if (typeof value === "string") return value;
831
+ if (typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") return `${value}`;
832
+ return JSON.stringify(value) ?? "";
694
833
  }
695
834
  //#endregion
696
835
  //#region src/value-help/value-help-client.ts
@@ -717,32 +856,33 @@ var ValueHelpClient = class {
717
856
  async search(resolved, opts) {
718
857
  const mode = opts?.mode ?? "form";
719
858
  const limit = opts?.limit ?? 20;
720
- const selectFields = opts?.select ?? computeSelectFields(resolved, mode);
859
+ const valueField = opts?.valueField;
860
+ const selectFields = opts?.select ?? computeSelectFields(resolved, mode, valueField);
721
861
  const text = opts?.text;
722
- if (!text) return { items: await this._client.query({ controls: {
862
+ const scope = opts?.filter;
863
+ const controls = {
723
864
  $select: selectFields,
724
865
  $limit: limit
725
- } }) };
726
- if (resolved.searchable) return { items: await this._client.query({ controls: {
727
- $select: selectFields,
728
- $limit: limit,
729
- $search: text
730
- } }) };
731
- const filter = buildOrFilter(text, selectFields, resolved.primaryKeys[0] ?? resolved.labelField);
866
+ };
867
+ let filter = scope;
868
+ if (text) if (resolved.searchable) controls.$search = text;
869
+ else {
870
+ const search = buildOrFilter(text, selectFields, valueField ?? resolved.primaryKeys[0] ?? resolved.labelField);
871
+ filter = scope ? { $and: [scope, search] } : search;
872
+ }
732
873
  return { items: await this._client.query({
733
- filter,
734
- controls: {
735
- $select: selectFields,
736
- $limit: limit
737
- }
874
+ ...filter && { filter },
875
+ controls
738
876
  }) };
739
877
  }
740
878
  };
741
879
  /**
742
- * Compute the $select fields for a value-help query.
880
+ * Compute the $select fields for a value-help query — always including the
881
+ * `valueField` the picker commits (a unique non-PK field is otherwise never fetched).
743
882
  */
744
- function computeSelectFields(resolved, mode) {
883
+ function computeSelectFields(resolved, mode, valueField) {
745
884
  const fields = [...resolved.primaryKeys, resolved.labelField];
885
+ if (valueField) fields.push(valueField);
746
886
  if (resolved.descrField) fields.push(resolved.descrField);
747
887
  if (mode === "filter") fields.push(...resolved.attrFields);
748
888
  return [...new Set(fields)];
@@ -752,7 +892,7 @@ function computeSelectFields(resolved, mode) {
752
892
  * Uses regex startsWith (case-insensitive) on text fields + exact match on PK.
753
893
  */
754
894
  function buildOrFilter(text, fields, pkField) {
755
- const escaped = text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
895
+ const escaped = escapeRegex(text);
756
896
  const conditions = [];
757
897
  for (const field of fields) if (field !== pkField) conditions.push({ [field]: { $regex: `/^${escaped}/i` } });
758
898
  const asNum = Number(text);
@@ -761,6 +901,54 @@ function buildOrFilter(text, fields, pkField) {
761
901
  return { $or: conditions };
762
902
  }
763
903
  //#endregion
904
+ //#region src/value-help/distinct-client.ts
905
+ /**
906
+ * `true` for a 4xx answer — the server declined this picker (gate, ARBAC, unknown field).
907
+ * @internal Shared with `@atscript/vue-table`.
908
+ */
909
+ function isPickerDeclined(err) {
910
+ const status = err?.status;
911
+ return typeof status === "number" && status >= 400 && status < 500;
912
+ }
913
+ /**
914
+ * Distinct values of one column of the table behind `client`, via
915
+ * `/query?$groupBy=<field>`. All server gates (hidden field, ARBAC `$groupBy`
916
+ * control, row scope, write-only, encrypted) apply as for any grouped read; a
917
+ * 4xx rejects with a `ClientError` — see {@link isPickerDeclined}.
918
+ * `hasMore` tells whether another page follows.
919
+ *
920
+ * @internal Backs the distinct-values picker of `@atscript/vue-table`.
921
+ */
922
+ async function fetchDistinctValues(client, field, opts = {}) {
923
+ const limit = opts.limit ?? 50;
924
+ const text = opts.text?.trim();
925
+ const conditions = [];
926
+ if (opts.filter) conditions.push(opts.filter);
927
+ if (text) if (opts.numeric) {
928
+ const n = Number(text);
929
+ if (!Number.isFinite(n)) return {
930
+ items: [],
931
+ hasMore: false
932
+ };
933
+ conditions.push({ [field]: n });
934
+ } else conditions.push({ [field]: { $regex: `/^${escapeRegex(text)}/i` } });
935
+ const filter = conditions.length > 1 ? { $and: conditions } : conditions[0];
936
+ const rows = await client.aggregate({
937
+ ...filter && { filter },
938
+ controls: {
939
+ $groupBy: [field],
940
+ $select: [field],
941
+ ...opts.sortable && { $sort: { [field]: 1 } },
942
+ $limit: limit + 1,
943
+ $skip: opts.skip ?? 0
944
+ }
945
+ });
946
+ return {
947
+ items: rows.slice(0, limit).map((r) => r[field]).filter((v) => v !== null && v !== void 0),
948
+ hasMore: rows.length > limit
949
+ };
950
+ }
951
+ //#endregion
764
952
  //#region src/client-factory.ts
765
953
  const builtin = (url) => new Client(url);
766
954
  let _default = builtin;
@@ -2270,18 +2458,6 @@ function groupInteger(integer, locale) {
2270
2458
  return out.join(sep);
2271
2459
  }
2272
2460
  //#endregion
2273
- //#region src/shared/str.ts
2274
- /** Converts a dot-path to a human-readable label (e.g. 'firstName' → 'First Name'). */
2275
- function humanizePath(path) {
2276
- return path.slice(path.lastIndexOf(".") + 1).replace(/([a-z])([A-Z])/g, "$1 $2").replace(/^./, (s) => s.toUpperCase());
2277
- }
2278
- /** Safely convert an unknown value to a string without triggering no-base-to-string lint errors. */
2279
- function str(value) {
2280
- if (typeof value === "string") return value;
2281
- if (typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") return `${value}`;
2282
- return JSON.stringify(value) ?? "";
2283
- }
2284
- //#endregion
2285
2461
  //#region src/table/create-table-def.ts
2286
2462
  /**
2287
2463
  * Builds a TableDef from a moost-db MetaResponse.
@@ -2301,29 +2477,31 @@ function createTableDef(meta, preDeserializedType) {
2301
2477
  const fieldMeta = meta.fields[path];
2302
2478
  if (!isReadable(fieldMeta)) continue;
2303
2479
  if (getFieldMeta(prop, "ui.table.exclude") !== void 0) continue;
2304
- const options = extractLiteralOptions(prop);
2480
+ const options = extractFieldLiteralOptions(prop);
2305
2481
  const valueHelpInfo = extractValueHelp(prop);
2306
- const maxLengthMeta = getFieldMeta(prop, EXPECT_MAX_LENGTH);
2307
- const tableType = getFieldMeta(prop, UI_TABLE_TYPE);
2308
- const sharedType = getFieldMeta(prop, UI_TYPE);
2309
- const tableComponent = getFieldMeta(prop, UI_TABLE_COMPONENT);
2310
- columns.push({
2311
- path,
2312
- label: getFieldMeta(prop, "meta.label") ?? humanizePath(path),
2313
- type: tableType ?? sharedType ?? (valueHelpInfo ? "ref" : inferDisplayType(prop, options)),
2314
- component: tableComponent,
2315
- selectWith: getFieldMeta(prop, UI_TABLE_SELECT_WITH),
2316
- sortable: fieldMeta.sortable ?? false,
2317
- filterable: fieldMeta.filterable ?? false,
2318
- ...fieldMeta.filterOps && { filterOps: [...fieldMeta.filterOps] },
2319
- nullable: prop.optional === true,
2320
- width: getFieldMeta(prop, UI_TABLE_WIDTH),
2321
- maxLen: maxLengthMeta?.length,
2322
- order: getFieldMeta(prop, "ui.table.order") ?? Infinity,
2482
+ let distinct;
2483
+ if (!valueHelpInfo && !options && fieldMeta.groupable && fieldMeta.filterable) {
2484
+ const url = type.metadata.get(DB_HTTP_PATH);
2485
+ if (url && getFieldMeta(prop, "ui.valueHelp.distinct") !== void 0) distinct = {
2486
+ url,
2487
+ field: path
2488
+ };
2489
+ }
2490
+ columns.push(buildColumn(path, prop, fieldMeta, {
2323
2491
  options,
2324
2492
  valueHelpInfo,
2325
- ...extractMeasurement(prop)
2326
- });
2493
+ distinct
2494
+ }));
2495
+ }
2496
+ if (meta.decorations) {
2497
+ const decoType = deserializeAnnotatedType(meta.decorations);
2498
+ if (decoType.type.kind === "object") for (const [path, prop] of decoType.type.props) {
2499
+ const fieldMeta = meta.fields[path];
2500
+ if (!fieldMeta?.decoration || flatMap.has(path)) continue;
2501
+ if (getFieldMeta(prop, "ui.table.exclude") !== void 0) continue;
2502
+ flatMap.set(path, prop);
2503
+ columns.push(buildColumn(path, prop, fieldMeta, { options: extractFieldLiteralOptions(prop) }));
2504
+ }
2327
2505
  }
2328
2506
  columns.sort((a, b) => a.order - b.order);
2329
2507
  const actions = groupActions(meta.actions ?? []);
@@ -2348,6 +2526,39 @@ function createTableDef(meta, preDeserializedType) {
2348
2526
  };
2349
2527
  }
2350
2528
  /**
2529
+ * One column. A server-declared display-only column (`fieldMeta.decoration`)
2530
+ * is never sortable, filterable or groupable and always nullable (a decoration
2531
+ * can be absent); an ordinary one takes its capabilities from `/meta`.
2532
+ */
2533
+ function buildColumn(path, prop, fieldMeta, resolved) {
2534
+ const { options, valueHelpInfo, distinct } = resolved;
2535
+ const maxLengthMeta = getFieldMeta(prop, EXPECT_MAX_LENGTH);
2536
+ const tableType = getFieldMeta(prop, UI_TABLE_TYPE);
2537
+ const sharedType = getFieldMeta(prop, UI_TYPE);
2538
+ const tableComponent = getFieldMeta(prop, UI_TABLE_COMPONENT);
2539
+ const decoration = fieldMeta.decoration === true;
2540
+ const filterOps = decoration ? void 0 : fieldMeta.filterOps;
2541
+ return {
2542
+ path,
2543
+ label: getFieldMeta(prop, "meta.label") ?? humanizePath(path),
2544
+ type: tableType ?? sharedType ?? (valueHelpInfo ? "ref" : inferDisplayType(prop, options)),
2545
+ valueKind: inferValueKind(prop),
2546
+ component: tableComponent,
2547
+ selectWith: getFieldMeta(prop, UI_TABLE_SELECT_WITH),
2548
+ sortable: !decoration && (fieldMeta.sortable ?? false),
2549
+ filterable: !decoration && (fieldMeta.filterable ?? false),
2550
+ ...filterOps && { filterOps: [...filterOps] },
2551
+ nullable: decoration || prop.optional === true,
2552
+ width: getFieldMeta(prop, UI_TABLE_WIDTH),
2553
+ maxLen: maxLengthMeta?.length,
2554
+ order: getFieldMeta(prop, "ui.table.order") ?? Infinity,
2555
+ options,
2556
+ valueHelpInfo,
2557
+ ...distinct && { distinct },
2558
+ ...extractMeasurement(prop)
2559
+ };
2560
+ }
2561
+ /**
2351
2562
  * `preferredId` ∪ every delegated action's `idMap` paths, in that order —
2352
2563
  * the same array when no action carries an `idMap`.
2353
2564
  */
@@ -2413,6 +2624,82 @@ function inferDisplayType(prop, literalOpts) {
2413
2624
  }
2414
2625
  return "text";
2415
2626
  }
2627
+ /**
2628
+ * Number metadata that makes the server treat a plain `number` column as an
2629
+ * integer (mirrors the db layer's `valueTypeOf`), beside the `int` / `expect.int` tags.
2630
+ */
2631
+ const INTEGER_NUMBER_META = [
2632
+ "expect.int",
2633
+ "db.default.increment",
2634
+ "db.default.now",
2635
+ "db.agg.count",
2636
+ "db.agg.countDistinct"
2637
+ ];
2638
+ /** The kind of one scalar leaf, or `undefined` for a non-scalar / unknown design type. */
2639
+ function scalarValueKind(prop) {
2640
+ const final = prop.type;
2641
+ const tags = final.tags;
2642
+ switch (final.designType) {
2643
+ case "string": return tags?.has("isoDate") ? "isoDate" : tags?.has("date") ? "date" : "string";
2644
+ case "number":
2645
+ if (tags?.has("timestamp")) return "timestamp";
2646
+ if (tags?.has("int") || INTEGER_NUMBER_META.some((k) => prop.metadata.has(k))) return "integer";
2647
+ return "number";
2648
+ case "decimal": return "decimal";
2649
+ case "boolean": return "boolean";
2650
+ default: return;
2651
+ }
2652
+ }
2653
+ /** Kinds of every non-null leaf of a (possibly nested) union; `null` when one is not a scalar. */
2654
+ function collectUnionKinds(items, out) {
2655
+ for (const item of items) {
2656
+ if (item.type.kind === "union") {
2657
+ collectUnionKinds(item.type.items, out);
2658
+ continue;
2659
+ }
2660
+ if (item.type.kind === "") {
2661
+ const dt = item.type.designType;
2662
+ if (dt === "null" || dt === "undefined") continue;
2663
+ out.add(scalarValueKind(item));
2664
+ continue;
2665
+ }
2666
+ out.add(void 0);
2667
+ }
2668
+ }
2669
+ /**
2670
+ * Scalar storage kind of the column's value — what the server's filter guard
2671
+ * checks. A scalar maps to its kind; a union that agrees on one kind across
2672
+ * its non-null members (`'a' | 'b'`, `1 | 2`, `number.timestamp | null`)
2673
+ * takes it; arrays, objects, JSON and mixed unions have none (`undefined`),
2674
+ * which means no value coercion.
2675
+ */
2676
+ function inferValueKind(prop) {
2677
+ const kind = prop.type.kind;
2678
+ if (kind === "") return scalarValueKind(prop);
2679
+ if (kind !== "union") return void 0;
2680
+ const kinds = /* @__PURE__ */ new Set();
2681
+ collectUnionKinds(prop.type.items, kinds);
2682
+ if (kinds.size !== 1) return void 0;
2683
+ return [...kinds][0];
2684
+ }
2685
+ //#endregion
2686
+ //#region src/table/value-kind.ts
2687
+ /** Storage kinds that hold plain numbers (a `timestamp` is epoch ms, but filters treat it as a date). */
2688
+ const NUMERIC_VALUE_KINDS = new Set([
2689
+ "number",
2690
+ "integer",
2691
+ "decimal"
2692
+ ]);
2693
+ /**
2694
+ * The typed value of one of a column's `options` — the literal itself
2695
+ * (`true`, `3`, `'a'`), falling back to the string `key` for a hand-built
2696
+ * column that has no `value`.
2697
+ *
2698
+ * @internal Shared with `@atscript/vue-table`.
2699
+ */
2700
+ function optionValue(option) {
2701
+ return option.value ?? option.key;
2702
+ }
2416
2703
  //#endregion
2417
2704
  //#region src/table/column-resolver.ts
2418
2705
  /** Get sortable columns. */
@@ -2526,4 +2813,4 @@ function resolvePath(model, table, view) {
2526
2813
  return path.length > 0 ? path : void 0;
2527
2814
  }
2528
2815
  //#endregion
2529
- export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, StaticFieldResolver, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, extractLiteralOptions, extractMeasurement, extractValueHelp, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, optKey, optLabel, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };
2816
+ export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_HTTP_PATH, DB_REL_FK, DB_UNIT, DB_UNIT_REF, DEFAULT_COL_SPAN, DEFAULT_ROW_SPAN, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, NUMERIC_VALUE_KINDS, StaticFieldResolver, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, ValueHelpClient, WF_ACTION_WITH_DATA, applyFormChanges, asArray, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, buildGridClasses, buildModelRoutes, buildUnionVariants, collectDirtyPaths, createFieldValidator, createFormData, createFormDef, createFormValueResolver, createTableDef, deepClone, deepEqual, defaultResolver, deleteByPath, detectUnionVariant, enforceScale, escapeRegex, extractFieldLiteralOptions, extractLiteralOptions, extractMeasurement, extractValueHelp, fetchDistinctValues, formatDecimalForDisplay, getByPath, getColumn, getCurrencyDecimals, getCurrencyDisplayParts, getDecimalSeparator, getDeclaredFormActions, getDefaultClientFactory, getDefaultValidatorPlugins, getFieldMeta, getFilterableColumns, getFormValidator, getMetaEntry, getResolver, getSortableColumns, getThousandsSeparator, groupInteger, hasComputedAnnotations, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isPathDirty, isPickerDeclined, isPureLiteralUnion, isTupleField, isUnionField, iteratePathAncestors, joinDecimalString, joinPath, mergeErrorMaps, navigateHrefFor, omitPaths, optKey, optLabel, optionLabel, optionValue, parseColSpan, parseDecimalInput, parseRowSpan, parseStaticAttrs, parseStaticOptions, resetDefaultClientFactory, resetMetaCache, resetValueHelpCache, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, resolveStatic, resolveValueHelp, setByPath, setDefaultClientFactory, setDefaultValidatorPlugins, setResolver, splitDecimalString, str, unionVariantChanged, valueHelpDictPaths };