@atscript/ui 0.1.189 → 0.1.190

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 (60) hide show
  1. package/dist/client-factory.d.cts +9 -7
  2. package/dist/client-factory.d.mts +9 -7
  3. package/dist/form/create-form-def.cjs +38 -1
  4. package/dist/form/create-form-def.d.cts +1 -1
  5. package/dist/form/create-form-def.d.mts +1 -1
  6. package/dist/form/create-form-def.mjs +38 -1
  7. package/dist/form/diff.cjs +8 -1
  8. package/dist/form/diff.d.cts +5 -2
  9. package/dist/form/diff.d.mts +5 -2
  10. package/dist/form/diff.mjs +9 -2
  11. package/dist/form/skipped-nav.cjs +1 -1
  12. package/dist/form/skipped-nav.mjs +1 -1
  13. package/dist/index.cjs +11 -0
  14. package/dist/index.d.cts +7 -4
  15. package/dist/index.d.mts +7 -4
  16. package/dist/index.mjs +6 -3
  17. package/dist/messages.cjs +3 -0
  18. package/dist/messages.d.cts +3 -0
  19. package/dist/messages.d.mts +3 -0
  20. package/dist/messages.mjs +3 -0
  21. package/dist/plugin/annotations.cjs +57 -2
  22. package/dist/plugin/annotations.mjs +58 -3
  23. package/dist/plugin/value-help-validation.cjs +358 -24
  24. package/dist/plugin/value-help-validation.mjs +356 -26
  25. package/dist/shared/annotation-keys.cjs +11 -0
  26. package/dist/shared/annotation-keys.d.cts +3 -1
  27. package/dist/shared/annotation-keys.d.mts +3 -1
  28. package/dist/shared/annotation-keys.mjs +8 -1
  29. package/dist/shared/meta-cache.d.cts +3 -3
  30. package/dist/shared/meta-cache.d.mts +3 -3
  31. package/dist/shared/value-label.cjs +28 -0
  32. package/dist/shared/value-label.d.cts +25 -0
  33. package/dist/shared/value-label.d.mts +25 -0
  34. package/dist/shared/value-label.mjs +27 -0
  35. package/dist/table/create-table-def.cjs +15 -1
  36. package/dist/table/create-table-def.mjs +15 -1
  37. package/dist/table/types.d.cts +31 -9
  38. package/dist/table/types.d.mts +31 -9
  39. package/dist/value-help/distinct-client.d.cts +2 -2
  40. package/dist/value-help/distinct-client.d.mts +2 -2
  41. package/dist/value-help/extract-ref.cjs +22 -5
  42. package/dist/value-help/extract-ref.mjs +23 -6
  43. package/dist/value-help/filter-tree.cjs +39 -14
  44. package/dist/value-help/filter-tree.mjs +39 -14
  45. package/dist/value-help/index.d.mts +3 -1
  46. package/dist/value-help/options.cjs +30 -0
  47. package/dist/value-help/options.d.cts +19 -0
  48. package/dist/value-help/options.d.mts +19 -0
  49. package/dist/value-help/options.mjs +29 -0
  50. package/dist/value-help/scope.cjs +50 -0
  51. package/dist/value-help/scope.d.cts +32 -0
  52. package/dist/value-help/scope.d.mts +32 -0
  53. package/dist/value-help/scope.mjs +49 -0
  54. package/dist/value-help/types.d.cts +29 -1
  55. package/dist/value-help/types.d.mts +29 -1
  56. package/dist/value-help/value-help-client.cjs +23 -4
  57. package/dist/value-help/value-help-client.d.cts +27 -8
  58. package/dist/value-help/value-help-client.d.mts +27 -8
  59. package/dist/value-help/value-help-client.mjs +23 -5
  60. package/package.json +9 -9
@@ -0,0 +1,28 @@
1
+ const require_annotation_keys = require("./annotation-keys.cjs");
2
+ const require_field_resolver = require("./field-resolver.cjs");
3
+ //#region src/shared/value-label.ts
4
+ /** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
5
+ function valueLabelOf(prop) {
6
+ const meta = require_field_resolver.getFieldMeta(prop, require_annotation_keys.UI_VALUE_LABEL);
7
+ if (!meta?.field) return void 0;
8
+ return {
9
+ field: meta.field,
10
+ arrangement: meta.arrangement ?? "textKey"
11
+ };
12
+ }
13
+ /**
14
+ * The one rendering of a code with its text (`@ui.valueLabel`, since 0.1.190):
15
+ * `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
16
+ * alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
17
+ * key; an empty key yields `""` — a text without a code labels nothing.
18
+ */
19
+ function arrangeText(key, text, arrangement = "textKey") {
20
+ if (key === "") return "";
21
+ const label = typeof text === "string" ? text : typeof text === "number" ? String(text) : void 0;
22
+ if (!label) return key;
23
+ if (arrangement === "text") return label;
24
+ return arrangement === "keyText" ? `${key} (${label})` : `${label} (${key})`;
25
+ }
26
+ //#endregion
27
+ exports.arrangeText = arrangeText;
28
+ exports.valueLabelOf = valueLabelOf;
@@ -0,0 +1,25 @@
1
+ import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
2
+
3
+ //#region src/shared/value-label.d.ts
4
+ /**
5
+ * How `@ui.valueLabel` shows a code with its text (since 0.1.190):
6
+ * `textKey` — `Berlin (BER)`, `keyText` — `BER (Berlin)`, `text` — `Berlin`.
7
+ */
8
+ type ValueLabelArrangement = "textKey" | "keyText" | "text";
9
+ /** `@ui.valueLabel` of a field: the sibling holding the text, and the arrangement. Since 0.1.190. */
10
+ interface ValueLabel {
11
+ /** The sibling field holding the text (a name, relative to the field's parent). */
12
+ field: string;
13
+ arrangement: ValueLabelArrangement;
14
+ }
15
+ /** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
16
+ declare function valueLabelOf(prop: TAtscriptAnnotatedType): ValueLabel | undefined;
17
+ /**
18
+ * The one rendering of a code with its text (`@ui.valueLabel`, since 0.1.190):
19
+ * `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
20
+ * alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
21
+ * key; an empty key yields `""` — a text without a code labels nothing.
22
+ */
23
+ declare function arrangeText(key: string, text: unknown, arrangement?: ValueLabelArrangement): string;
24
+ //#endregion
25
+ export { ValueLabel, ValueLabelArrangement, arrangeText, valueLabelOf };
@@ -0,0 +1,25 @@
1
+ import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
2
+
3
+ //#region src/shared/value-label.d.ts
4
+ /**
5
+ * How `@ui.valueLabel` shows a code with its text (since 0.1.190):
6
+ * `textKey` — `Berlin (BER)`, `keyText` — `BER (Berlin)`, `text` — `Berlin`.
7
+ */
8
+ type ValueLabelArrangement = "textKey" | "keyText" | "text";
9
+ /** `@ui.valueLabel` of a field: the sibling holding the text, and the arrangement. Since 0.1.190. */
10
+ interface ValueLabel {
11
+ /** The sibling field holding the text (a name, relative to the field's parent). */
12
+ field: string;
13
+ arrangement: ValueLabelArrangement;
14
+ }
15
+ /** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
16
+ declare function valueLabelOf(prop: TAtscriptAnnotatedType): ValueLabel | undefined;
17
+ /**
18
+ * The one rendering of a code with its text (`@ui.valueLabel`, since 0.1.190):
19
+ * `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
20
+ * alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
21
+ * key; an empty key yields `""` — a text without a code labels nothing.
22
+ */
23
+ declare function arrangeText(key: string, text: unknown, arrangement?: ValueLabelArrangement): string;
24
+ //#endregion
25
+ export { ValueLabel, ValueLabelArrangement, arrangeText, valueLabelOf };
@@ -0,0 +1,27 @@
1
+ import { UI_VALUE_LABEL } from "./annotation-keys.mjs";
2
+ import { getFieldMeta } from "./field-resolver.mjs";
3
+ //#region src/shared/value-label.ts
4
+ /** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
5
+ function valueLabelOf(prop) {
6
+ const meta = getFieldMeta(prop, UI_VALUE_LABEL);
7
+ if (!meta?.field) return void 0;
8
+ return {
9
+ field: meta.field,
10
+ arrangement: meta.arrangement ?? "textKey"
11
+ };
12
+ }
13
+ /**
14
+ * The one rendering of a code with its text (`@ui.valueLabel`, since 0.1.190):
15
+ * `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
16
+ * alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
17
+ * key; an empty key yields `""` — a text without a code labels nothing.
18
+ */
19
+ function arrangeText(key, text, arrangement = "textKey") {
20
+ if (key === "") return "";
21
+ const label = typeof text === "string" ? text : typeof text === "number" ? String(text) : void 0;
22
+ if (!label) return key;
23
+ if (arrangement === "text") return label;
24
+ return arrangement === "keyText" ? `${key} (${label})` : `${label} (${key})`;
25
+ }
26
+ //#endregion
27
+ export { arrangeText, valueLabelOf };
@@ -5,6 +5,7 @@ const require_extract_literals = require("../value-help/extract-literals.cjs");
5
5
  const require_extract_ref = require("../value-help/extract-ref.cjs");
6
6
  const require_str = require("../shared/str.cjs");
7
7
  const require_measurement = require("../form/measurement.cjs");
8
+ const require_value_label = require("../shared/value-label.cjs");
8
9
  let _atscript_typescript_utils = require("@atscript/typescript/utils");
9
10
  //#region src/table/create-table-def.ts
10
11
  /**
@@ -89,13 +90,25 @@ function buildColumn(path, prop, fieldMeta, resolved) {
89
90
  const tableComponent = require_field_resolver.getFieldMeta(prop, require_annotation_keys.UI_TABLE_COMPONENT);
90
91
  const decoration = fieldMeta.decoration === true;
91
92
  const filterOps = decoration ? void 0 : fieldMeta.filterOps;
93
+ let selectWith = require_field_resolver.getFieldMeta(prop, require_annotation_keys.UI_TABLE_SELECT_WITH);
94
+ const label = require_value_label.valueLabelOf(prop);
95
+ let valueLabel;
96
+ if (label) {
97
+ const dot = path.lastIndexOf(".");
98
+ const textPath = dot < 0 ? label.field : `${path.slice(0, dot + 1)}${label.field}`;
99
+ valueLabel = {
100
+ path: textPath,
101
+ arrangement: label.arrangement
102
+ };
103
+ if (!selectWith?.includes(textPath)) selectWith = [...selectWith ?? [], textPath];
104
+ }
92
105
  return {
93
106
  path,
94
107
  label: require_field_resolver.getFieldMeta(prop, "meta.label") ?? require_str.humanizePath(path),
95
108
  type: tableType ?? sharedType ?? (valueHelpInfo ? "ref" : inferDisplayType(prop, options)),
96
109
  valueKind: inferValueKind(prop),
97
110
  component: tableComponent,
98
- selectWith: require_field_resolver.getFieldMeta(prop, require_annotation_keys.UI_TABLE_SELECT_WITH),
111
+ selectWith,
99
112
  sortable: !decoration && (fieldMeta.sortable ?? false),
100
113
  filterable: !decoration && (fieldMeta.filterable ?? false),
101
114
  ...filterOps && { filterOps: [...filterOps] },
@@ -105,6 +118,7 @@ function buildColumn(path, prop, fieldMeta, resolved) {
105
118
  order: require_field_resolver.getFieldMeta(prop, "ui.table.order") ?? Infinity,
106
119
  options,
107
120
  valueHelpInfo,
121
+ ...valueLabel && { valueLabel },
108
122
  ...distinct && { distinct },
109
123
  ...require_measurement.extractMeasurement(prop)
110
124
  };
@@ -5,6 +5,7 @@ import { extractFieldLiteralOptions, isEmptyMember } from "../value-help/extract
5
5
  import { extractValueHelp } from "../value-help/extract-ref.mjs";
6
6
  import { humanizePath } from "../shared/str.mjs";
7
7
  import { extractMeasurement } from "../form/measurement.mjs";
8
+ import { valueLabelOf } from "../shared/value-label.mjs";
8
9
  import { deserializeAnnotatedType, flattenAnnotatedType } from "@atscript/typescript/utils";
9
10
  //#region src/table/create-table-def.ts
10
11
  /**
@@ -89,13 +90,25 @@ function buildColumn(path, prop, fieldMeta, resolved) {
89
90
  const tableComponent = getFieldMeta(prop, UI_TABLE_COMPONENT);
90
91
  const decoration = fieldMeta.decoration === true;
91
92
  const filterOps = decoration ? void 0 : fieldMeta.filterOps;
93
+ let selectWith = getFieldMeta(prop, UI_TABLE_SELECT_WITH);
94
+ const label = valueLabelOf(prop);
95
+ let valueLabel;
96
+ if (label) {
97
+ const dot = path.lastIndexOf(".");
98
+ const textPath = dot < 0 ? label.field : `${path.slice(0, dot + 1)}${label.field}`;
99
+ valueLabel = {
100
+ path: textPath,
101
+ arrangement: label.arrangement
102
+ };
103
+ if (!selectWith?.includes(textPath)) selectWith = [...selectWith ?? [], textPath];
104
+ }
92
105
  return {
93
106
  path,
94
107
  label: getFieldMeta(prop, "meta.label") ?? humanizePath(path),
95
108
  type: tableType ?? sharedType ?? (valueHelpInfo ? "ref" : inferDisplayType(prop, options)),
96
109
  valueKind: inferValueKind(prop),
97
110
  component: tableComponent,
98
- selectWith: getFieldMeta(prop, UI_TABLE_SELECT_WITH),
111
+ selectWith,
99
112
  sortable: !decoration && (fieldMeta.sortable ?? false),
100
113
  filterable: !decoration && (fieldMeta.filterable ?? false),
101
114
  ...filterOps && { filterOps: [...filterOps] },
@@ -105,6 +118,7 @@ function buildColumn(path, prop, fieldMeta, resolved) {
105
118
  order: getFieldMeta(prop, "ui.table.order") ?? Infinity,
106
119
  options,
107
120
  valueHelpInfo,
121
+ ...valueLabel && { valueLabel },
108
122
  ...distinct && { distinct },
109
123
  ...extractMeasurement(prop)
110
124
  };
@@ -1,4 +1,5 @@
1
1
  import { ValueHelpInfo } from "../value-help/types.cjs";
2
+ import { ValueLabelArrangement } from "../shared/value-label.cjs";
2
3
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
3
4
  import { TCrudPermissions, TDbActionInfo } from "@atscript/db-client";
4
5
 
@@ -12,7 +13,12 @@ interface SearchIndexInfo {
12
13
  /** Relation summary in meta response. */
13
14
  interface RelationInfo {
14
15
  name: string;
15
- direction: "to" | "from" | "via";
16
+ /**
17
+ * `"store"` (since 0.1.190, `@db.rel.store`, `@atscript/db` 0.1.196+): no
18
+ * foreign key, the store correlates the rows; like `"to"` / `"from"`, it is
19
+ * a to-one relation unless `isArray`.
20
+ */
21
+ direction: "to" | "from" | "via" | "store";
16
22
  isArray: boolean;
17
23
  /**
18
24
  * `true` when the relation is `@db.rel.filterable`: the server accepts
@@ -29,9 +35,13 @@ interface FieldMeta {
29
35
  /** Whether the field accepts value comparisons (`=`, `>`, `$regex`, …). */
30
36
  filterable: boolean;
31
37
  /**
32
- * Present only when `filterable` is `false` but narrower predicates still
33
- * pass the server's gate — e.g. `["$exists"]` on a JSON-stored column.
34
- * Needs `@atscript/moost-db` 0.1.132+. Since 0.1.139.
38
+ * The filter operators the server accepts on this field when that is fewer
39
+ * than its type takes: an adapter's own list (served on a `filterable` field
40
+ * too since `@atscript/moost-db` 0.1.196; `filterable` is `false` when it
41
+ * leaves no comparison), or the narrower predicates that still pass on a
42
+ * field that is not `filterable` — e.g. `["$exists"]` on a JSON-stored
43
+ * column (`@atscript/moost-db` 0.1.132+). Absent: no restriction.
44
+ * Since 0.1.139.
35
45
  */
36
46
  filterOps?: string[];
37
47
  /**
@@ -197,11 +207,13 @@ interface ColumnDef {
197
207
  /** Whether this column supports value filtering (the server's `filterable`). */
198
208
  filterable: boolean;
199
209
  /**
200
- * Narrower filter operators the server accepts on a column that is not
201
- * value-filterable — `["$exists"]` on a JSON-stored column, whose value
202
- * cannot be compared but whose presence can. Copied from
203
- * `meta.fields[path].filterOps`; omitted when absent. Filter UIs read it
204
- * through `columnFilterConditions()` from `@atscript/ui-table`. Since 0.1.139.
210
+ * The filter operators the server accepts on this column when that is
211
+ * fewer than its type takes — an adapter's list on a value-filterable
212
+ * column, or `["$exists"]` on a JSON-stored one, whose value cannot be
213
+ * compared but whose presence can. Copied from
214
+ * `meta.fields[path].filterOps`; omitted when absent (no restriction).
215
+ * Filter UIs read it through `columnFilterConditions()` from
216
+ * `@atscript/ui-table`. Since 0.1.139.
205
217
  */
206
218
  filterOps?: string[];
207
219
  /**
@@ -232,6 +244,16 @@ interface ColumnDef {
232
244
  }[];
233
245
  /** Value-help info for FK columns (from extractValueHelp). */
234
246
  valueHelpInfo?: ValueHelpInfo;
247
+ /**
248
+ * `@ui.valueLabel`: the column's value is a code shown with its text, which
249
+ * the row holds at `path` (the sibling field, joined to `selectWith`). Cells
250
+ * and export show `arrangeText(code, text, arrangement)`; sorting, filtering
251
+ * and filter chips keep the code. Since 0.1.190.
252
+ */
253
+ valueLabel?: {
254
+ path: string;
255
+ arrangement: ValueLabelArrangement;
256
+ };
235
257
  /**
236
258
  * Distinct-values picker (`@ui.valueHelp.distinct`): the table's own controller
237
259
  * (`url`) answers the values of `field` via `$groupBy`. Set only when the server
@@ -1,4 +1,5 @@
1
1
  import { ValueHelpInfo } from "../value-help/types.mjs";
2
+ import { ValueLabelArrangement } from "../shared/value-label.mjs";
2
3
  import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
3
4
  import { TCrudPermissions, TDbActionInfo } from "@atscript/db-client";
4
5
 
@@ -12,7 +13,12 @@ interface SearchIndexInfo {
12
13
  /** Relation summary in meta response. */
13
14
  interface RelationInfo {
14
15
  name: string;
15
- direction: "to" | "from" | "via";
16
+ /**
17
+ * `"store"` (since 0.1.190, `@db.rel.store`, `@atscript/db` 0.1.196+): no
18
+ * foreign key, the store correlates the rows; like `"to"` / `"from"`, it is
19
+ * a to-one relation unless `isArray`.
20
+ */
21
+ direction: "to" | "from" | "via" | "store";
16
22
  isArray: boolean;
17
23
  /**
18
24
  * `true` when the relation is `@db.rel.filterable`: the server accepts
@@ -29,9 +35,13 @@ interface FieldMeta {
29
35
  /** Whether the field accepts value comparisons (`=`, `>`, `$regex`, …). */
30
36
  filterable: boolean;
31
37
  /**
32
- * Present only when `filterable` is `false` but narrower predicates still
33
- * pass the server's gate — e.g. `["$exists"]` on a JSON-stored column.
34
- * Needs `@atscript/moost-db` 0.1.132+. Since 0.1.139.
38
+ * The filter operators the server accepts on this field when that is fewer
39
+ * than its type takes: an adapter's own list (served on a `filterable` field
40
+ * too since `@atscript/moost-db` 0.1.196; `filterable` is `false` when it
41
+ * leaves no comparison), or the narrower predicates that still pass on a
42
+ * field that is not `filterable` — e.g. `["$exists"]` on a JSON-stored
43
+ * column (`@atscript/moost-db` 0.1.132+). Absent: no restriction.
44
+ * Since 0.1.139.
35
45
  */
36
46
  filterOps?: string[];
37
47
  /**
@@ -197,11 +207,13 @@ interface ColumnDef {
197
207
  /** Whether this column supports value filtering (the server's `filterable`). */
198
208
  filterable: boolean;
199
209
  /**
200
- * Narrower filter operators the server accepts on a column that is not
201
- * value-filterable — `["$exists"]` on a JSON-stored column, whose value
202
- * cannot be compared but whose presence can. Copied from
203
- * `meta.fields[path].filterOps`; omitted when absent. Filter UIs read it
204
- * through `columnFilterConditions()` from `@atscript/ui-table`. Since 0.1.139.
210
+ * The filter operators the server accepts on this column when that is
211
+ * fewer than its type takes — an adapter's list on a value-filterable
212
+ * column, or `["$exists"]` on a JSON-stored one, whose value cannot be
213
+ * compared but whose presence can. Copied from
214
+ * `meta.fields[path].filterOps`; omitted when absent (no restriction).
215
+ * Filter UIs read it through `columnFilterConditions()` from
216
+ * `@atscript/ui-table`. Since 0.1.139.
205
217
  */
206
218
  filterOps?: string[];
207
219
  /**
@@ -232,6 +244,16 @@ interface ColumnDef {
232
244
  }[];
233
245
  /** Value-help info for FK columns (from extractValueHelp). */
234
246
  valueHelpInfo?: ValueHelpInfo;
247
+ /**
248
+ * `@ui.valueLabel`: the column's value is a code shown with its text, which
249
+ * the row holds at `path` (the sibling field, joined to `selectWith`). Cells
250
+ * and export show `arrangeText(code, text, arrangement)`; sorting, filtering
251
+ * and filter chips keep the code. Since 0.1.190.
252
+ */
253
+ valueLabel?: {
254
+ path: string;
255
+ arrangement: ValueLabelArrangement;
256
+ };
235
257
  /**
236
258
  * Distinct-values picker (`@ui.valueHelp.distinct`): the table's own controller
237
259
  * (`url`) answers the values of `field` via `$groupBy`. Set only when the server
@@ -1,4 +1,4 @@
1
- import { Client, FilterExpr } from "@atscript/db-client";
1
+ import { ClientLike, FilterExpr } from "@atscript/db-client";
2
2
 
3
3
  //#region src/value-help/distinct-client.d.ts
4
4
  interface DistinctValuesOptions {
@@ -32,7 +32,7 @@ declare function isPickerDeclined(err: unknown): boolean;
32
32
  *
33
33
  * @internal Backs the distinct-values picker of `@atscript/vue-table`.
34
34
  */
35
- declare function fetchDistinctValues(client: Pick<Client, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
35
+ declare function fetchDistinctValues(client: Pick<ClientLike, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
36
36
  items: unknown[];
37
37
  hasMore: boolean;
38
38
  }>;
@@ -1,4 +1,4 @@
1
- import { Client, FilterExpr } from "@atscript/db-client";
1
+ import { ClientLike, FilterExpr } from "@atscript/db-client";
2
2
 
3
3
  //#region src/value-help/distinct-client.d.ts
4
4
  interface DistinctValuesOptions {
@@ -32,7 +32,7 @@ declare function isPickerDeclined(err: unknown): boolean;
32
32
  *
33
33
  * @internal Backs the distinct-values picker of `@atscript/vue-table`.
34
34
  */
35
- declare function fetchDistinctValues(client: Pick<Client, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
35
+ declare function fetchDistinctValues(client: Pick<ClientLike, "aggregate">, field: string, opts?: DistinctValuesOptions): Promise<{
36
36
  items: unknown[];
37
37
  hasMore: boolean;
38
38
  }>;
@@ -41,13 +41,30 @@ function bindingInfo(node) {
41
41
  targetField: binding.field
42
42
  };
43
43
  if (binding.filter) {
44
- const { filter, pinned } = require_filter_tree.valueHelpFilter(binding.filter);
45
- info.filter = filter;
44
+ const { filter, pinned, hostFilter } = require_filter_tree.valueHelpFilter(binding.filter);
45
+ if (filter) info.filter = filter;
46
46
  if (pinned.length > 0) info.pinned = pinned;
47
+ if (hostFilter.length > 0) info.hostFilter = hostFilter;
47
48
  }
48
49
  return info;
49
50
  }
50
51
  /**
52
+ * Adds a link's `@ui.valueHelp.column` list and — on the prop itself only
53
+ * (`own`) — its `@ui.valueHelp.fill` list to `info` (since 0.1.190). A link
54
+ * reached through a reference names fields of ANOTHER interface, so its fills
55
+ * stay there; its columns name the target, so they come along.
56
+ */
57
+ function withExtras(info, node, own) {
58
+ const columns = node.metadata.get(require_annotation_keys.UI_VALUE_HELP_COLUMN);
59
+ if (columns && columns.length > 0) info.columns = [...columns];
60
+ const fills = own ? node.metadata.get(require_annotation_keys.UI_VALUE_HELP_FILL) : void 0;
61
+ if (fills && fills.length > 0) info.fill = fills.map((f) => ({
62
+ local: f.local,
63
+ target: f.targetField
64
+ }));
65
+ return info;
66
+ }
67
+ /**
51
68
  * Synchronous probe. Returns `{ url, targetField }` for the first link of the
52
69
  * reference chain starting at `prop` that carries a `@ui.valueHelp` binding
53
70
  * (since 0.1.148 — an explicit binding beats `@db.rel.FK`, and also supplies
@@ -81,17 +98,17 @@ function extractValueHelp(prop) {
81
98
  let node = prop;
82
99
  for (let depth = 0; node && depth < MAX_REF_CHAIN_DEPTH; depth++) {
83
100
  const bound = bindingInfo(node);
84
- if (bound) return bound;
101
+ if (bound) return withExtras(bound, node, depth === 0);
85
102
  const ref = node.ref;
86
103
  if (!ref) return void 0;
87
104
  const target = ref.type();
88
105
  if (!target) return void 0;
89
106
  if (node.metadata.has("db.rel.FK")) {
90
107
  const url = target.metadata.get(require_annotation_keys.DB_HTTP_PATH);
91
- if (url) return {
108
+ if (url) return withExtras({
92
109
  url,
93
110
  targetField: ref.field
94
- };
111
+ }, node, depth === 0);
95
112
  }
96
113
  node = (target.type.kind === "object" ? target.type : void 0)?.props.get(ref.field);
97
114
  }
@@ -1,4 +1,4 @@
1
- import { DB_HTTP_PATH, UI_VALUE_HELP } from "../shared/annotation-keys.mjs";
1
+ import { DB_HTTP_PATH, UI_VALUE_HELP, UI_VALUE_HELP_COLUMN, UI_VALUE_HELP_FILL } from "../shared/annotation-keys.mjs";
2
2
  import { valueHelpFilter } from "./filter-tree.mjs";
3
3
  //#region src/value-help/extract-ref.ts
4
4
  /**
@@ -41,13 +41,30 @@ function bindingInfo(node) {
41
41
  targetField: binding.field
42
42
  };
43
43
  if (binding.filter) {
44
- const { filter, pinned } = valueHelpFilter(binding.filter);
45
- info.filter = filter;
44
+ const { filter, pinned, hostFilter } = valueHelpFilter(binding.filter);
45
+ if (filter) info.filter = filter;
46
46
  if (pinned.length > 0) info.pinned = pinned;
47
+ if (hostFilter.length > 0) info.hostFilter = hostFilter;
47
48
  }
48
49
  return info;
49
50
  }
50
51
  /**
52
+ * Adds a link's `@ui.valueHelp.column` list and — on the prop itself only
53
+ * (`own`) — its `@ui.valueHelp.fill` list to `info` (since 0.1.190). A link
54
+ * reached through a reference names fields of ANOTHER interface, so its fills
55
+ * stay there; its columns name the target, so they come along.
56
+ */
57
+ function withExtras(info, node, own) {
58
+ const columns = node.metadata.get(UI_VALUE_HELP_COLUMN);
59
+ if (columns && columns.length > 0) info.columns = [...columns];
60
+ const fills = own ? node.metadata.get(UI_VALUE_HELP_FILL) : void 0;
61
+ if (fills && fills.length > 0) info.fill = fills.map((f) => ({
62
+ local: f.local,
63
+ target: f.targetField
64
+ }));
65
+ return info;
66
+ }
67
+ /**
51
68
  * Synchronous probe. Returns `{ url, targetField }` for the first link of the
52
69
  * reference chain starting at `prop` that carries a `@ui.valueHelp` binding
53
70
  * (since 0.1.148 — an explicit binding beats `@db.rel.FK`, and also supplies
@@ -81,17 +98,17 @@ function extractValueHelp(prop) {
81
98
  let node = prop;
82
99
  for (let depth = 0; node && depth < MAX_REF_CHAIN_DEPTH; depth++) {
83
100
  const bound = bindingInfo(node);
84
- if (bound) return bound;
101
+ if (bound) return withExtras(bound, node, depth === 0);
85
102
  const ref = node.ref;
86
103
  if (!ref) return void 0;
87
104
  const target = ref.type();
88
105
  if (!target) return void 0;
89
106
  if (node.metadata.has("db.rel.FK")) {
90
107
  const url = target.metadata.get(DB_HTTP_PATH);
91
- if (url) return {
108
+ if (url) return withExtras({
92
109
  url,
93
110
  targetField: ref.field
94
- };
111
+ }, node, depth === 0);
95
112
  }
96
113
  node = (target.type.kind === "object" ? target.type : void 0)?.props.get(ref.field);
97
114
  }
@@ -18,27 +18,52 @@ function translate(node) {
18
18
  if (op === "$exists") return { [left]: { $exists: right !== false } };
19
19
  return { [left]: { [op]: right } };
20
20
  }
21
- /**
22
- * Fields the tree pins to one value (`=` comparison against a literal) at its top-level
23
- * `and` chain. The runtime twin of `pinnedFields` in `plugin/value-help-validation.ts`
24
- * (which reads the source predicate) — keep the two rules in step.
25
- */
26
- function pinnedOf(node, out) {
27
- if (Array.isArray(node.$and)) for (const n of node.$and) pinnedOf(n, out);
28
- else if (node.left && node.op === "$eq" && !isFieldRef(node.right)) out.push(node.left.field);
21
+ /** The top-level `and` chain of a tree, nested `$and`s flattened. */
22
+ function conjunctsOf(node) {
23
+ return Array.isArray(node.$and) ? node.$and.flatMap((n) => conjunctsOf(n)) : [node];
24
+ }
25
+ /** A host reference: a top-level `targetField = Host.field` (a right-hand field ref). */
26
+ function isHostRef(node) {
27
+ return !!node.left && node.op === "$eq" && isFieldRef(node.right);
29
28
  }
30
29
  /**
31
- * Translates the static `filter` of a `@ui.valueHelp` binding into a Uniquery
30
+ * Translates the `filter` of a `@ui.valueHelp` binding into a Uniquery
32
31
  * `FilterExpr` (mirrors `translateQueryTree` of `@atscript/db`, with refs
33
- * resolved to the plain field path), plus the target fields it pins with `=` —
34
- * constant inside the picker, so their columns are hidden. Since 0.1.148.
32
+ * resolved to the plain field path), plus the target fields it pins with `=`
33
+ * against a literal — constant inside the picker, so their columns are hidden.
34
+ * Since 0.1.148.
35
+ *
36
+ * Since 0.1.190 the host references (`targetField = Host.field`, top-level
37
+ * conjuncts; position decides, the type of the reference is not read) are
38
+ * lifted out into `hostFilter`: `filter` holds the literal comparisons only
39
+ * (`undefined` when nothing else is left), so it never sends a field-to-field
40
+ * comparison to the dictionary.
41
+ *
42
+ * `pinned` is the runtime twin of `pinnedFields` in
43
+ * `plugin/value-help-validation.ts` (which reads the source predicate) — keep
44
+ * the two rules in step.
35
45
  */
36
46
  function valueHelpFilter(tree) {
37
47
  const pinned = [];
38
- pinnedOf(tree, pinned);
48
+ const hostFilter = [];
49
+ const rest = [];
50
+ for (const node of conjunctsOf(tree)) {
51
+ const left = node.left?.field;
52
+ if (isHostRef(node)) {
53
+ hostFilter.push({
54
+ target: left,
55
+ local: node.right.field
56
+ });
57
+ continue;
58
+ }
59
+ if (left !== void 0 && node.op === "$eq" && !isFieldRef(node.right)) pinned.push(left);
60
+ rest.push(translate(node));
61
+ }
62
+ const filter = rest.length === 0 ? void 0 : rest.length === 1 ? rest[0] : { $and: rest };
39
63
  return {
40
- filter: translate(tree),
41
- pinned: [...new Set(pinned)]
64
+ ...filter && { filter },
65
+ pinned: [...new Set(pinned)],
66
+ hostFilter
42
67
  };
43
68
  }
44
69
  //#endregion
@@ -18,27 +18,52 @@ function translate(node) {
18
18
  if (op === "$exists") return { [left]: { $exists: right !== false } };
19
19
  return { [left]: { [op]: right } };
20
20
  }
21
- /**
22
- * Fields the tree pins to one value (`=` comparison against a literal) at its top-level
23
- * `and` chain. The runtime twin of `pinnedFields` in `plugin/value-help-validation.ts`
24
- * (which reads the source predicate) — keep the two rules in step.
25
- */
26
- function pinnedOf(node, out) {
27
- if (Array.isArray(node.$and)) for (const n of node.$and) pinnedOf(n, out);
28
- else if (node.left && node.op === "$eq" && !isFieldRef(node.right)) out.push(node.left.field);
21
+ /** The top-level `and` chain of a tree, nested `$and`s flattened. */
22
+ function conjunctsOf(node) {
23
+ return Array.isArray(node.$and) ? node.$and.flatMap((n) => conjunctsOf(n)) : [node];
24
+ }
25
+ /** A host reference: a top-level `targetField = Host.field` (a right-hand field ref). */
26
+ function isHostRef(node) {
27
+ return !!node.left && node.op === "$eq" && isFieldRef(node.right);
29
28
  }
30
29
  /**
31
- * Translates the static `filter` of a `@ui.valueHelp` binding into a Uniquery
30
+ * Translates the `filter` of a `@ui.valueHelp` binding into a Uniquery
32
31
  * `FilterExpr` (mirrors `translateQueryTree` of `@atscript/db`, with refs
33
- * resolved to the plain field path), plus the target fields it pins with `=` —
34
- * constant inside the picker, so their columns are hidden. Since 0.1.148.
32
+ * resolved to the plain field path), plus the target fields it pins with `=`
33
+ * against a literal — constant inside the picker, so their columns are hidden.
34
+ * Since 0.1.148.
35
+ *
36
+ * Since 0.1.190 the host references (`targetField = Host.field`, top-level
37
+ * conjuncts; position decides, the type of the reference is not read) are
38
+ * lifted out into `hostFilter`: `filter` holds the literal comparisons only
39
+ * (`undefined` when nothing else is left), so it never sends a field-to-field
40
+ * comparison to the dictionary.
41
+ *
42
+ * `pinned` is the runtime twin of `pinnedFields` in
43
+ * `plugin/value-help-validation.ts` (which reads the source predicate) — keep
44
+ * the two rules in step.
35
45
  */
36
46
  function valueHelpFilter(tree) {
37
47
  const pinned = [];
38
- pinnedOf(tree, pinned);
48
+ const hostFilter = [];
49
+ const rest = [];
50
+ for (const node of conjunctsOf(tree)) {
51
+ const left = node.left?.field;
52
+ if (isHostRef(node)) {
53
+ hostFilter.push({
54
+ target: left,
55
+ local: node.right.field
56
+ });
57
+ continue;
58
+ }
59
+ if (left !== void 0 && node.op === "$eq" && !isFieldRef(node.right)) pinned.push(left);
60
+ rest.push(translate(node));
61
+ }
62
+ const filter = rest.length === 0 ? void 0 : rest.length === 1 ? rest[0] : { $and: rest };
39
63
  return {
40
- filter: translate(tree),
41
- pinned: [...new Set(pinned)]
64
+ ...filter && { filter },
65
+ pinned: [...new Set(pinned)],
66
+ hostFilter
42
67
  };
43
68
  }
44
69
  //#endregion
@@ -1,8 +1,10 @@
1
1
  import { TFormEntryOptions, ValueHelpInfo } from "./types.mjs";
2
2
  import { ResolvedValueHelp, resetValueHelpCache, resolveValueHelp } from "./resolve.mjs";
3
- import { ValueHelpClient, ValueHelpResult, ValueHelpSearchOptions, invalidateValueHelpCache, setValueHelpCacheTtl } from "./value-help-client.mjs";
3
+ import { ValueHelpClient, ValueHelpResult, ValueHelpSearchOptions, invalidateValueHelpCache, setValueHelpCacheTtl, valueHelpSelect } from "./value-help-client.mjs";
4
4
  import { valueHelpDictPaths } from "./dict-paths.mjs";
5
5
  import { DEFAULT_BOOLEAN_LABELS, extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion } from "./extract-literals.mjs";
6
6
  import { extractValueHelp } from "./extract-ref.mjs";
7
7
  import { optKey, optLabel, optionLabel, parseStaticOptions, resolveOptions } from "./resolve-options.mjs";
8
+ import { ValueHelpFillWrite, ValueHelpScope, valueHelpFills, valueHelpScope } from "./scope.mjs";
9
+ import { VALUE_HELP_OPTIONS_CAP, valueHelpOptions } from "./options.mjs";
8
10
  import { fetchDistinctValues, isPickerDeclined } from "./distinct-client.mjs";