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