@atscript/ui 0.1.164 → 0.1.166

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 +6 -1
  2. package/dist/client-factory.d.mts +6 -1
  3. package/dist/form/create-form-def.cjs +28 -6
  4. package/dist/form/create-form-def.mjs +29 -7
  5. package/dist/form/labels.cjs +7 -4
  6. package/dist/form/labels.d.cts +6 -2
  7. package/dist/form/labels.d.mts +6 -2
  8. package/dist/form/labels.mjs +7 -4
  9. package/dist/form/types.d.cts +14 -0
  10. package/dist/form/types.d.mts +14 -0
  11. package/dist/form/validate.cjs +59 -23
  12. package/dist/form/validate.d.cts +37 -6
  13. package/dist/form/validate.d.mts +37 -6
  14. package/dist/form/validate.mjs +58 -23
  15. package/dist/i18n/ui-texts.cjs +135 -0
  16. package/dist/i18n/ui-texts.d.cts +81 -0
  17. package/dist/i18n/ui-texts.d.mts +81 -0
  18. package/dist/i18n/ui-texts.mjs +132 -0
  19. package/dist/index.cjs +6 -0
  20. package/dist/index.d.cts +7 -6
  21. package/dist/index.d.mts +7 -6
  22. package/dist/index.mjs +3 -2
  23. package/dist/messages.cjs +301 -0
  24. package/dist/messages.d.cts +302 -0
  25. package/dist/messages.d.mts +302 -0
  26. package/dist/messages.mjs +300 -0
  27. package/dist/plugin/annotations.cjs +30 -15
  28. package/dist/plugin/annotations.mjs +30 -15
  29. package/dist/plugin/value-help-validation.cjs +17 -7
  30. package/dist/plugin/value-help-validation.mjs +17 -7
  31. package/dist/shared/meta-cache.cjs +75 -37
  32. package/dist/shared/meta-cache.d.cts +40 -20
  33. package/dist/shared/meta-cache.d.mts +40 -20
  34. package/dist/shared/meta-cache.mjs +75 -37
  35. package/dist/table/create-table-def.cjs +17 -8
  36. package/dist/table/create-table-def.d.cts +5 -1
  37. package/dist/table/create-table-def.d.mts +5 -1
  38. package/dist/table/create-table-def.mjs +18 -9
  39. package/dist/table/types.d.cts +5 -2
  40. package/dist/table/types.d.mts +5 -2
  41. package/dist/table/value-kind.cjs +6 -6
  42. package/dist/table/value-kind.d.cts +8 -7
  43. package/dist/table/value-kind.d.mts +8 -7
  44. package/dist/table/value-kind.mjs +6 -6
  45. package/dist/value-help/extract-literals.cjs +61 -22
  46. package/dist/value-help/extract-literals.d.cts +20 -8
  47. package/dist/value-help/extract-literals.d.mts +20 -8
  48. package/dist/value-help/extract-literals.mjs +60 -23
  49. package/dist/value-help/index.d.mts +1 -1
  50. package/dist/value-help/resolve-options.cjs +8 -4
  51. package/dist/value-help/resolve-options.d.cts +8 -3
  52. package/dist/value-help/resolve-options.d.mts +8 -3
  53. package/dist/value-help/resolve-options.mjs +9 -5
  54. package/dist/value-help/resolve.cjs +7 -3
  55. package/dist/value-help/resolve.d.cts +7 -2
  56. package/dist/value-help/resolve.d.mts +7 -2
  57. package/dist/value-help/resolve.mjs +7 -3
  58. package/dist/value-help/types.d.cts +5 -0
  59. package/dist/value-help/types.d.mts +5 -0
  60. package/package.json +15 -10
@@ -1,16 +1,31 @@
1
1
  require("../shared/annotation-keys.cjs");
2
+ const require_messages = require("../messages.cjs");
3
+ const require_ui_texts = require("../i18n/ui-texts.cjs");
2
4
  //#region src/value-help/extract-literals.ts
3
5
  /**
4
- * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c').
5
- * Returns undefined if the type is not a pure union of literals.
6
+ * The English labels an unlabelled `boolean` value shows — in table cells,
7
+ * filter chips, the filter picker, export and read-only form fields. They are
8
+ * the UI texts `UI_YES` / `UI_NO` (`AS_UI_MESSAGES`), shown in the UI locale.
9
+ * Since 0.1.165.
10
+ */
11
+ const DEFAULT_BOOLEAN_LABELS = Object.freeze({
12
+ true: require_messages.AS_UI_MESSAGES.UI_YES,
13
+ false: require_messages.AS_UI_MESSAGES.UI_NO
14
+ });
15
+ /**
16
+ * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c') or a
17
+ * `boolean` (since 0.1.165: the two values `true` / `false`, labelled
18
+ * {@link DEFAULT_BOOLEAN_LABELS} unless `@ui.literalLabel` says otherwise).
19
+ * `null` / `undefined` members of a union (`'a' | 'b' | null`, `boolean | null`)
20
+ * are not values and are skipped. Returns undefined for anything else.
6
21
  *
7
22
  * Handles nested unions created by flattenAnnotatedType, which recurses
8
23
  * into union items and produces synthetic unions containing both individual
9
24
  * literals and the original union type as nested items.
10
25
  */
11
- function extractLiteralOptions(prop, outer) {
12
- if (prop.type.kind !== "union") return void 0;
13
- const result = collectLiterals(prop.type.items, /* @__PURE__ */ new Set());
26
+ function extractLiteralOptions(prop, outer, t = require_ui_texts.getUiTexts().t) {
27
+ const items = prop.type.kind === "union" ? prop.type.items : isBooleanPrimitive(prop) ? [prop] : void 0;
28
+ const result = items && collectLiterals(items, /* @__PURE__ */ new Set(), t);
14
29
  if (!result || result.length === 0) return void 0;
15
30
  const labels = [prop, outer].flatMap((node) => node?.metadata.get("ui.literalLabel") ?? []);
16
31
  if (labels.length) {
@@ -20,13 +35,24 @@ function extractLiteralOptions(prop, outer) {
20
35
  return result;
21
36
  }
22
37
  /**
23
- * The literal options of a field: a literal union's, or those of an array of one
24
- * (`tags: Tag[]`), where the array prop's own `@ui.literalLabel` labels win over the
25
- * element type's. `undefined` when the field is neither. Since 0.1.148.
38
+ * The literal options of a field: a literal union's or a boolean's (since 0.1.165),
39
+ * or those of an array of one (`tags: Tag[]`, `flags: boolean[]`), where the array
40
+ * prop's own `@ui.literalLabel` labels win over the element type's. `undefined` when
41
+ * the field is neither. Since 0.1.148.
26
42
  */
27
- function extractFieldLiteralOptions(prop) {
28
- if (prop.type.kind === "array") return extractLiteralOptions(prop.type.of, prop);
29
- return extractLiteralOptions(prop);
43
+ function extractFieldLiteralOptions(prop, t = require_ui_texts.getUiTexts().t) {
44
+ if (prop.type.kind === "array") return extractLiteralOptions(prop.type.of, prop, t);
45
+ return extractLiteralOptions(prop, void 0, t);
46
+ }
47
+ /** A `null` / `undefined` member of a union (`T | null`): no value of its own. */
48
+ function isEmptyMember(item) {
49
+ const dt = item.type.designType;
50
+ return item.type.kind === "" && (dt === "null" || dt === "undefined");
51
+ }
52
+ /** A `boolean` (not a `true` / `false` literal). */
53
+ function isBooleanPrimitive(prop) {
54
+ const final = prop.type;
55
+ return prop.type.kind === "" && final.designType === "boolean" && final.value === void 0;
30
56
  }
31
57
  /** Returns true when the annotated type is a union composed entirely of literal values. */
32
58
  function isPureLiteralUnion(prop) {
@@ -46,31 +72,44 @@ function checkAllLiterals(items) {
46
72
  return items.length > 0;
47
73
  }
48
74
  /**
49
- * Recursively collects literal values from union items.
50
- * Returns null if any non-literal, non-union item is found (invalid union).
75
+ * Recursively collects literal values from union items: a literal is one value
76
+ * (a `true` / `false` literal default-labelled like a boolean's), a `boolean` the
77
+ * two (`true` / `false`, default-labelled), a `null` / `undefined`
78
+ * member none. Returns null if any other item is found (no options).
51
79
  * Returns empty array when all items are valid but already seen (deduped).
52
80
  */
53
- function collectLiterals(items, seen) {
81
+ function collectLiterals(items, seen, t) {
54
82
  const result = [];
55
- for (const item of items) if (item.type.kind === "" && item.type.value !== void 0) {
56
- const raw = item.type.value;
83
+ const add = (raw) => {
57
84
  const val = String(raw);
58
85
  if (!seen.has(val)) {
59
86
  seen.add(val);
87
+ const label = typeof raw === "boolean" ? t(raw ? "UI_YES" : "UI_NO") : val;
60
88
  result.push({
61
89
  key: val,
62
- label: val,
90
+ label,
63
91
  value: raw
64
92
  });
65
93
  }
66
- } else if (item.type.kind === "union") {
67
- const nested = collectLiterals(item.type.items, seen);
68
- if (nested === null) return null;
69
- result.push(...nested);
70
- } else return null;
94
+ };
95
+ for (const item of items) {
96
+ const final = item.type;
97
+ if (item.type.kind === "" && final.value !== void 0) add(final.value);
98
+ else if (isBooleanPrimitive(item)) {
99
+ add(true);
100
+ add(false);
101
+ } else if (isEmptyMember(item)) continue;
102
+ else if (item.type.kind === "union") {
103
+ const nested = collectLiterals(item.type.items, seen, t);
104
+ if (nested === null) return null;
105
+ result.push(...nested);
106
+ } else return null;
107
+ }
71
108
  return result;
72
109
  }
73
110
  //#endregion
111
+ exports.DEFAULT_BOOLEAN_LABELS = DEFAULT_BOOLEAN_LABELS;
74
112
  exports.extractFieldLiteralOptions = extractFieldLiteralOptions;
75
113
  exports.extractLiteralOptions = extractLiteralOptions;
114
+ exports.isEmptyMember = isEmptyMember;
76
115
  exports.isPureLiteralUnion = isPureLiteralUnion;
@@ -1,3 +1,4 @@
1
+ import { UiT } from "../i18n/ui-texts.cjs";
1
2
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
2
3
 
3
4
  //#region src/value-help/extract-literals.d.ts
@@ -12,21 +13,32 @@ interface LiteralOption {
12
13
  value: string | number | boolean;
13
14
  }
14
15
  /**
15
- * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c').
16
- * Returns undefined if the type is not a pure union of literals.
16
+ * The English labels an unlabelled `boolean` value shows — in table cells,
17
+ * filter chips, the filter picker, export and read-only form fields. They are
18
+ * the UI texts `UI_YES` / `UI_NO` (`AS_UI_MESSAGES`), shown in the UI locale.
19
+ * Since 0.1.165.
20
+ */
21
+ declare const DEFAULT_BOOLEAN_LABELS: Readonly<Record<"true" | "false", string>>;
22
+ /**
23
+ * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c') or a
24
+ * `boolean` (since 0.1.165: the two values `true` / `false`, labelled
25
+ * {@link DEFAULT_BOOLEAN_LABELS} unless `@ui.literalLabel` says otherwise).
26
+ * `null` / `undefined` members of a union (`'a' | 'b' | null`, `boolean | null`)
27
+ * are not values and are skipped. Returns undefined for anything else.
17
28
  *
18
29
  * Handles nested unions created by flattenAnnotatedType, which recurses
19
30
  * into union items and produces synthetic unions containing both individual
20
31
  * literals and the original union type as nested items.
21
32
  */
22
- declare function extractLiteralOptions(prop: TAtscriptAnnotatedType, outer?: TAtscriptAnnotatedType): LiteralOption[] | undefined;
33
+ declare function extractLiteralOptions(prop: TAtscriptAnnotatedType, outer?: TAtscriptAnnotatedType, t?: UiT): LiteralOption[] | undefined;
23
34
  /**
24
- * The literal options of a field: a literal union's, or those of an array of one
25
- * (`tags: Tag[]`), where the array prop's own `@ui.literalLabel` labels win over the
26
- * element type's. `undefined` when the field is neither. Since 0.1.148.
35
+ * The literal options of a field: a literal union's or a boolean's (since 0.1.165),
36
+ * or those of an array of one (`tags: Tag[]`, `flags: boolean[]`), where the array
37
+ * prop's own `@ui.literalLabel` labels win over the element type's. `undefined` when
38
+ * the field is neither. Since 0.1.148.
27
39
  */
28
- declare function extractFieldLiteralOptions(prop: TAtscriptAnnotatedType): LiteralOption[] | undefined;
40
+ declare function extractFieldLiteralOptions(prop: TAtscriptAnnotatedType, t?: UiT): LiteralOption[] | undefined;
29
41
  /** Returns true when the annotated type is a union composed entirely of literal values. */
30
42
  declare function isPureLiteralUnion(prop: TAtscriptAnnotatedType): boolean;
31
43
  //#endregion
32
- export { extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion };
44
+ export { DEFAULT_BOOLEAN_LABELS, extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion };
@@ -1,3 +1,4 @@
1
+ import { UiT } from "../i18n/ui-texts.mjs";
1
2
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
2
3
 
3
4
  //#region src/value-help/extract-literals.d.ts
@@ -12,21 +13,32 @@ interface LiteralOption {
12
13
  value: string | number | boolean;
13
14
  }
14
15
  /**
15
- * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c').
16
- * Returns undefined if the type is not a pure union of literals.
16
+ * The English labels an unlabelled `boolean` value shows — in table cells,
17
+ * filter chips, the filter picker, export and read-only form fields. They are
18
+ * the UI texts `UI_YES` / `UI_NO` (`AS_UI_MESSAGES`), shown in the UI locale.
19
+ * Since 0.1.165.
20
+ */
21
+ declare const DEFAULT_BOOLEAN_LABELS: Readonly<Record<"true" | "false", string>>;
22
+ /**
23
+ * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c') or a
24
+ * `boolean` (since 0.1.165: the two values `true` / `false`, labelled
25
+ * {@link DEFAULT_BOOLEAN_LABELS} unless `@ui.literalLabel` says otherwise).
26
+ * `null` / `undefined` members of a union (`'a' | 'b' | null`, `boolean | null`)
27
+ * are not values and are skipped. Returns undefined for anything else.
17
28
  *
18
29
  * Handles nested unions created by flattenAnnotatedType, which recurses
19
30
  * into union items and produces synthetic unions containing both individual
20
31
  * literals and the original union type as nested items.
21
32
  */
22
- declare function extractLiteralOptions(prop: TAtscriptAnnotatedType, outer?: TAtscriptAnnotatedType): LiteralOption[] | undefined;
33
+ declare function extractLiteralOptions(prop: TAtscriptAnnotatedType, outer?: TAtscriptAnnotatedType, t?: UiT): LiteralOption[] | undefined;
23
34
  /**
24
- * The literal options of a field: a literal union's, or those of an array of one
25
- * (`tags: Tag[]`), where the array prop's own `@ui.literalLabel` labels win over the
26
- * element type's. `undefined` when the field is neither. Since 0.1.148.
35
+ * The literal options of a field: a literal union's or a boolean's (since 0.1.165),
36
+ * or those of an array of one (`tags: Tag[]`, `flags: boolean[]`), where the array
37
+ * prop's own `@ui.literalLabel` labels win over the element type's. `undefined` when
38
+ * the field is neither. Since 0.1.148.
27
39
  */
28
- declare function extractFieldLiteralOptions(prop: TAtscriptAnnotatedType): LiteralOption[] | undefined;
40
+ declare function extractFieldLiteralOptions(prop: TAtscriptAnnotatedType, t?: UiT): LiteralOption[] | undefined;
29
41
  /** Returns true when the annotated type is a union composed entirely of literal values. */
30
42
  declare function isPureLiteralUnion(prop: TAtscriptAnnotatedType): boolean;
31
43
  //#endregion
32
- export { extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion };
44
+ export { DEFAULT_BOOLEAN_LABELS, extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion };
@@ -1,16 +1,31 @@
1
1
  import "../shared/annotation-keys.mjs";
2
+ import { AS_UI_MESSAGES } from "../messages.mjs";
3
+ import { getUiTexts } from "../i18n/ui-texts.mjs";
2
4
  //#region src/value-help/extract-literals.ts
3
5
  /**
4
- * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c').
5
- * Returns undefined if the type is not a pure union of literals.
6
+ * The English labels an unlabelled `boolean` value shows — in table cells,
7
+ * filter chips, the filter picker, export and read-only form fields. They are
8
+ * the UI texts `UI_YES` / `UI_NO` (`AS_UI_MESSAGES`), shown in the UI locale.
9
+ * Since 0.1.165.
10
+ */
11
+ const DEFAULT_BOOLEAN_LABELS = Object.freeze({
12
+ true: AS_UI_MESSAGES.UI_YES,
13
+ false: AS_UI_MESSAGES.UI_NO
14
+ });
15
+ /**
16
+ * Extracts options from a union of literal types (e.g. 'a' | 'b' | 'c') or a
17
+ * `boolean` (since 0.1.165: the two values `true` / `false`, labelled
18
+ * {@link DEFAULT_BOOLEAN_LABELS} unless `@ui.literalLabel` says otherwise).
19
+ * `null` / `undefined` members of a union (`'a' | 'b' | null`, `boolean | null`)
20
+ * are not values and are skipped. Returns undefined for anything else.
6
21
  *
7
22
  * Handles nested unions created by flattenAnnotatedType, which recurses
8
23
  * into union items and produces synthetic unions containing both individual
9
24
  * literals and the original union type as nested items.
10
25
  */
11
- function extractLiteralOptions(prop, outer) {
12
- if (prop.type.kind !== "union") return void 0;
13
- const result = collectLiterals(prop.type.items, /* @__PURE__ */ new Set());
26
+ function extractLiteralOptions(prop, outer, t = getUiTexts().t) {
27
+ const items = prop.type.kind === "union" ? prop.type.items : isBooleanPrimitive(prop) ? [prop] : void 0;
28
+ const result = items && collectLiterals(items, /* @__PURE__ */ new Set(), t);
14
29
  if (!result || result.length === 0) return void 0;
15
30
  const labels = [prop, outer].flatMap((node) => node?.metadata.get("ui.literalLabel") ?? []);
16
31
  if (labels.length) {
@@ -20,13 +35,24 @@ function extractLiteralOptions(prop, outer) {
20
35
  return result;
21
36
  }
22
37
  /**
23
- * The literal options of a field: a literal union's, or those of an array of one
24
- * (`tags: Tag[]`), where the array prop's own `@ui.literalLabel` labels win over the
25
- * element type's. `undefined` when the field is neither. Since 0.1.148.
38
+ * The literal options of a field: a literal union's or a boolean's (since 0.1.165),
39
+ * or those of an array of one (`tags: Tag[]`, `flags: boolean[]`), where the array
40
+ * prop's own `@ui.literalLabel` labels win over the element type's. `undefined` when
41
+ * the field is neither. Since 0.1.148.
26
42
  */
27
- function extractFieldLiteralOptions(prop) {
28
- if (prop.type.kind === "array") return extractLiteralOptions(prop.type.of, prop);
29
- return extractLiteralOptions(prop);
43
+ function extractFieldLiteralOptions(prop, t = getUiTexts().t) {
44
+ if (prop.type.kind === "array") return extractLiteralOptions(prop.type.of, prop, t);
45
+ return extractLiteralOptions(prop, void 0, t);
46
+ }
47
+ /** A `null` / `undefined` member of a union (`T | null`): no value of its own. */
48
+ function isEmptyMember(item) {
49
+ const dt = item.type.designType;
50
+ return item.type.kind === "" && (dt === "null" || dt === "undefined");
51
+ }
52
+ /** A `boolean` (not a `true` / `false` literal). */
53
+ function isBooleanPrimitive(prop) {
54
+ const final = prop.type;
55
+ return prop.type.kind === "" && final.designType === "boolean" && final.value === void 0;
30
56
  }
31
57
  /** Returns true when the annotated type is a union composed entirely of literal values. */
32
58
  function isPureLiteralUnion(prop) {
@@ -46,29 +72,40 @@ function checkAllLiterals(items) {
46
72
  return items.length > 0;
47
73
  }
48
74
  /**
49
- * Recursively collects literal values from union items.
50
- * Returns null if any non-literal, non-union item is found (invalid union).
75
+ * Recursively collects literal values from union items: a literal is one value
76
+ * (a `true` / `false` literal default-labelled like a boolean's), a `boolean` the
77
+ * two (`true` / `false`, default-labelled), a `null` / `undefined`
78
+ * member none. Returns null if any other item is found (no options).
51
79
  * Returns empty array when all items are valid but already seen (deduped).
52
80
  */
53
- function collectLiterals(items, seen) {
81
+ function collectLiterals(items, seen, t) {
54
82
  const result = [];
55
- for (const item of items) if (item.type.kind === "" && item.type.value !== void 0) {
56
- const raw = item.type.value;
83
+ const add = (raw) => {
57
84
  const val = String(raw);
58
85
  if (!seen.has(val)) {
59
86
  seen.add(val);
87
+ const label = typeof raw === "boolean" ? t(raw ? "UI_YES" : "UI_NO") : val;
60
88
  result.push({
61
89
  key: val,
62
- label: val,
90
+ label,
63
91
  value: raw
64
92
  });
65
93
  }
66
- } else if (item.type.kind === "union") {
67
- const nested = collectLiterals(item.type.items, seen);
68
- if (nested === null) return null;
69
- result.push(...nested);
70
- } else return null;
94
+ };
95
+ for (const item of items) {
96
+ const final = item.type;
97
+ if (item.type.kind === "" && final.value !== void 0) add(final.value);
98
+ else if (isBooleanPrimitive(item)) {
99
+ add(true);
100
+ add(false);
101
+ } else if (isEmptyMember(item)) continue;
102
+ else if (item.type.kind === "union") {
103
+ const nested = collectLiterals(item.type.items, seen, t);
104
+ if (nested === null) return null;
105
+ result.push(...nested);
106
+ } else return null;
107
+ }
71
108
  return result;
72
109
  }
73
110
  //#endregion
74
- export { extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion };
111
+ export { DEFAULT_BOOLEAN_LABELS, extractFieldLiteralOptions, extractLiteralOptions, isEmptyMember, isPureLiteralUnion };
@@ -2,7 +2,7 @@ import { TFormEntryOptions, ValueHelpInfo } from "./types.mjs";
2
2
  import { ResolvedValueHelp, resetValueHelpCache, resolveValueHelp } from "./resolve.mjs";
3
3
  import { ValueHelpClient, ValueHelpResult, ValueHelpSearchOptions, invalidateValueHelpCache, setValueHelpCacheTtl } from "./value-help-client.mjs";
4
4
  import { valueHelpDictPaths } from "./dict-paths.mjs";
5
- import { extractFieldLiteralOptions, extractLiteralOptions, isPureLiteralUnion } from "./extract-literals.mjs";
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
8
  import { fetchDistinctValues, isPickerDeclined } from "./distinct-client.mjs";
@@ -12,7 +12,7 @@ function optLabel(opt) {
12
12
  }
13
13
  const labelMaps = /* @__PURE__ */ new WeakMap();
14
14
  /**
15
- * The display label of a literal-union column's option (`@ui.literalLabel`) for
15
+ * The display label of a literal-union (or boolean) column's option (`@ui.literalLabel`) for
16
16
  * `value` — `undefined` when the column has no options or none matches. Map-backed
17
17
  * per options array, so rendering a table does not scan the options per cell.
18
18
  * The one lookup behind the table cell, the filter chips, export and a custom cell.
@@ -48,13 +48,17 @@ function parseStaticOptions(raw) {
48
48
  * Resolves options from metadata with a fallback chain:
49
49
  * 1. `@ui.form.fn.options` (dynamic, compiled by ui-fns)
50
50
  * 2. `@ui.form.options` (static annotation)
51
- * 3. Literal union type extraction (auto-derived from type)
51
+ * 3. Literal union / boolean extraction (auto-derived from type); `labelsFrom`
52
+ * (`FormFieldDef.labelsFrom`, since 0.1.165) adds an enclosing prop's labels
52
53
  * 4. Future: dictionary / value-help lookup
54
+ *
55
+ * `t` words the default boolean labels (`UI_YES` / `UI_NO`); the active UI
56
+ * texts when omitted — a component passes its app's (`useAsLocale().t`).
53
57
  */
54
- function resolveOptions(prop, scope) {
58
+ function resolveOptions(prop, scope, labelsFrom, t) {
55
59
  const resolved = require_field_resolver.resolveFieldProp(prop, require_annotation_keys.UI_FORM_FN_OPTIONS, require_annotation_keys.UI_FORM_OPTIONS, scope, { transform: parseStaticOptions });
56
60
  if (resolved !== void 0) return resolved;
57
- return require_extract_literals.extractFieldLiteralOptions(prop);
61
+ return labelsFrom ? require_extract_literals.extractLiteralOptions(prop, labelsFrom, t) : require_extract_literals.extractFieldLiteralOptions(prop, t);
58
62
  }
59
63
  //#endregion
60
64
  exports.optKey = optKey;
@@ -1,4 +1,5 @@
1
1
  import { TFormEntryOptions } from "./types.cjs";
2
+ import { UiT } from "../i18n/ui-texts.cjs";
2
3
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
3
4
 
4
5
  //#region src/value-help/resolve-options.d.ts
@@ -7,7 +8,7 @@ declare function optKey(opt: TFormEntryOptions): string;
7
8
  /** Extracts the display label from an option entry. */
8
9
  declare function optLabel(opt: TFormEntryOptions): string;
9
10
  /**
10
- * The display label of a literal-union column's option (`@ui.literalLabel`) for
11
+ * The display label of a literal-union (or boolean) column's option (`@ui.literalLabel`) for
11
12
  * `value` — `undefined` when the column has no options or none matches. Map-backed
12
13
  * per options array, so rendering a table does not scan the options per cell.
13
14
  * The one lookup behind the table cell, the filter chips, export and a custom cell.
@@ -27,9 +28,13 @@ declare function parseStaticOptions(raw: unknown): TFormEntryOptions[];
27
28
  * Resolves options from metadata with a fallback chain:
28
29
  * 1. `@ui.form.fn.options` (dynamic, compiled by ui-fns)
29
30
  * 2. `@ui.form.options` (static annotation)
30
- * 3. Literal union type extraction (auto-derived from type)
31
+ * 3. Literal union / boolean extraction (auto-derived from type); `labelsFrom`
32
+ * (`FormFieldDef.labelsFrom`, since 0.1.165) adds an enclosing prop's labels
31
33
  * 4. Future: dictionary / value-help lookup
34
+ *
35
+ * `t` words the default boolean labels (`UI_YES` / `UI_NO`); the active UI
36
+ * texts when omitted — a component passes its app's (`useAsLocale().t`).
32
37
  */
33
- declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): TFormEntryOptions[] | undefined;
38
+ declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>, labelsFrom?: TAtscriptAnnotatedType, t?: UiT): TFormEntryOptions[] | undefined;
34
39
  //#endregion
35
40
  export { optKey, optLabel, optionLabel, parseStaticOptions, resolveOptions };
@@ -1,4 +1,5 @@
1
1
  import { TFormEntryOptions } from "./types.mjs";
2
+ import { UiT } from "../i18n/ui-texts.mjs";
2
3
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
3
4
 
4
5
  //#region src/value-help/resolve-options.d.ts
@@ -7,7 +8,7 @@ declare function optKey(opt: TFormEntryOptions): string;
7
8
  /** Extracts the display label from an option entry. */
8
9
  declare function optLabel(opt: TFormEntryOptions): string;
9
10
  /**
10
- * The display label of a literal-union column's option (`@ui.literalLabel`) for
11
+ * The display label of a literal-union (or boolean) column's option (`@ui.literalLabel`) for
11
12
  * `value` — `undefined` when the column has no options or none matches. Map-backed
12
13
  * per options array, so rendering a table does not scan the options per cell.
13
14
  * The one lookup behind the table cell, the filter chips, export and a custom cell.
@@ -27,9 +28,13 @@ declare function parseStaticOptions(raw: unknown): TFormEntryOptions[];
27
28
  * Resolves options from metadata with a fallback chain:
28
29
  * 1. `@ui.form.fn.options` (dynamic, compiled by ui-fns)
29
30
  * 2. `@ui.form.options` (static annotation)
30
- * 3. Literal union type extraction (auto-derived from type)
31
+ * 3. Literal union / boolean extraction (auto-derived from type); `labelsFrom`
32
+ * (`FormFieldDef.labelsFrom`, since 0.1.165) adds an enclosing prop's labels
31
33
  * 4. Future: dictionary / value-help lookup
34
+ *
35
+ * `t` words the default boolean labels (`UI_YES` / `UI_NO`); the active UI
36
+ * texts when omitted — a component passes its app's (`useAsLocale().t`).
32
37
  */
33
- declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>): TFormEntryOptions[] | undefined;
38
+ declare function resolveOptions(prop: TAtscriptAnnotatedType, scope: Record<string, unknown>, labelsFrom?: TAtscriptAnnotatedType, t?: UiT): TFormEntryOptions[] | undefined;
34
39
  //#endregion
35
40
  export { optKey, optLabel, optionLabel, parseStaticOptions, resolveOptions };
@@ -1,6 +1,6 @@
1
1
  import { UI_FORM_FN_OPTIONS, UI_FORM_OPTIONS } from "../shared/annotation-keys.mjs";
2
2
  import { asArray, resolveFieldProp } from "../shared/field-resolver.mjs";
3
- import { extractFieldLiteralOptions } from "./extract-literals.mjs";
3
+ import { extractFieldLiteralOptions, extractLiteralOptions } from "./extract-literals.mjs";
4
4
  //#region src/value-help/resolve-options.ts
5
5
  /** Extracts the key from an option entry. */
6
6
  function optKey(opt) {
@@ -12,7 +12,7 @@ function optLabel(opt) {
12
12
  }
13
13
  const labelMaps = /* @__PURE__ */ new WeakMap();
14
14
  /**
15
- * The display label of a literal-union column's option (`@ui.literalLabel`) for
15
+ * The display label of a literal-union (or boolean) column's option (`@ui.literalLabel`) for
16
16
  * `value` — `undefined` when the column has no options or none matches. Map-backed
17
17
  * per options array, so rendering a table does not scan the options per cell.
18
18
  * The one lookup behind the table cell, the filter chips, export and a custom cell.
@@ -48,13 +48,17 @@ function parseStaticOptions(raw) {
48
48
  * Resolves options from metadata with a fallback chain:
49
49
  * 1. `@ui.form.fn.options` (dynamic, compiled by ui-fns)
50
50
  * 2. `@ui.form.options` (static annotation)
51
- * 3. Literal union type extraction (auto-derived from type)
51
+ * 3. Literal union / boolean extraction (auto-derived from type); `labelsFrom`
52
+ * (`FormFieldDef.labelsFrom`, since 0.1.165) adds an enclosing prop's labels
52
53
  * 4. Future: dictionary / value-help lookup
54
+ *
55
+ * `t` words the default boolean labels (`UI_YES` / `UI_NO`); the active UI
56
+ * texts when omitted — a component passes its app's (`useAsLocale().t`).
53
57
  */
54
- function resolveOptions(prop, scope) {
58
+ function resolveOptions(prop, scope, labelsFrom, t) {
55
59
  const resolved = resolveFieldProp(prop, UI_FORM_FN_OPTIONS, UI_FORM_OPTIONS, scope, { transform: parseStaticOptions });
56
60
  if (resolved !== void 0) return resolved;
57
- return extractFieldLiteralOptions(prop);
61
+ return labelsFrom ? extractLiteralOptions(prop, labelsFrom, t) : extractFieldLiteralOptions(prop, t);
58
62
  }
59
63
  //#endregion
60
64
  export { optKey, optLabel, optionLabel, parseStaticOptions, resolveOptions };
@@ -4,13 +4,17 @@ const require_meta_cache = require("../shared/meta-cache.cjs");
4
4
  /**
5
5
  * Lazily fetch and extract value-help metadata for the given URL.
6
6
  *
7
- * - Issues exactly one `GET {url}/meta` per URL across the session (shared via meta-cache).
7
+ * - Issues exactly one `GET {url}/meta` per URL and UI locale across the
8
+ * session (shared via meta-cache).
8
9
  * - Concurrent callers with the same URL share the in-flight promise.
9
10
  * - If the underlying fetch rejects, the cache entry is evicted so a later
10
11
  * retry performs a fresh fetch.
12
+ *
13
+ * `options.texts` — the app's UI texts (see `getMetaEntry`); the active ones
14
+ * by default.
11
15
  */
12
- function resolveValueHelp(url) {
13
- const entry = require_meta_cache.getMetaEntry(url);
16
+ function resolveValueHelp(url, options) {
17
+ const entry = require_meta_cache.getMetaEntry(url, void 0, options);
14
18
  if (entry.resolved) return entry.resolved;
15
19
  entry.resolved = Promise.all([entry.meta, entry.type]).then(([meta, type]) => buildResolved(url, meta, type));
16
20
  return entry.resolved;
@@ -1,3 +1,4 @@
1
+ import { MetaEntryOptions } from "../shared/meta-cache.cjs";
1
2
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
2
3
 
3
4
  //#region src/value-help/resolve.d.ts
@@ -19,12 +20,16 @@ interface ResolvedValueHelp {
19
20
  /**
20
21
  * Lazily fetch and extract value-help metadata for the given URL.
21
22
  *
22
- * - Issues exactly one `GET {url}/meta` per URL across the session (shared via meta-cache).
23
+ * - Issues exactly one `GET {url}/meta` per URL and UI locale across the
24
+ * session (shared via meta-cache).
23
25
  * - Concurrent callers with the same URL share the in-flight promise.
24
26
  * - If the underlying fetch rejects, the cache entry is evicted so a later
25
27
  * retry performs a fresh fetch.
28
+ *
29
+ * `options.texts` — the app's UI texts (see `getMetaEntry`); the active ones
30
+ * by default.
26
31
  */
27
- declare function resolveValueHelp(url: string): Promise<ResolvedValueHelp>;
32
+ declare function resolveValueHelp(url: string, options?: Pick<MetaEntryOptions, "texts">): Promise<ResolvedValueHelp>;
28
33
  /** Thin alias over `resetMetaCache` — retained so existing test code keeps working. */
29
34
  declare function resetValueHelpCache(): void;
30
35
  //#endregion
@@ -1,3 +1,4 @@
1
+ import { MetaEntryOptions } from "../shared/meta-cache.mjs";
1
2
  import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
2
3
 
3
4
  //#region src/value-help/resolve.d.ts
@@ -19,12 +20,16 @@ interface ResolvedValueHelp {
19
20
  /**
20
21
  * Lazily fetch and extract value-help metadata for the given URL.
21
22
  *
22
- * - Issues exactly one `GET {url}/meta` per URL across the session (shared via meta-cache).
23
+ * - Issues exactly one `GET {url}/meta` per URL and UI locale across the
24
+ * session (shared via meta-cache).
23
25
  * - Concurrent callers with the same URL share the in-flight promise.
24
26
  * - If the underlying fetch rejects, the cache entry is evicted so a later
25
27
  * retry performs a fresh fetch.
28
+ *
29
+ * `options.texts` — the app's UI texts (see `getMetaEntry`); the active ones
30
+ * by default.
26
31
  */
27
- declare function resolveValueHelp(url: string): Promise<ResolvedValueHelp>;
32
+ declare function resolveValueHelp(url: string, options?: Pick<MetaEntryOptions, "texts">): Promise<ResolvedValueHelp>;
28
33
  /** Thin alias over `resetMetaCache` — retained so existing test code keeps working. */
29
34
  declare function resetValueHelpCache(): void;
30
35
  //#endregion
@@ -4,13 +4,17 @@ import { getMetaEntry, resetMetaCache } from "../shared/meta-cache.mjs";
4
4
  /**
5
5
  * Lazily fetch and extract value-help metadata for the given URL.
6
6
  *
7
- * - Issues exactly one `GET {url}/meta` per URL across the session (shared via meta-cache).
7
+ * - Issues exactly one `GET {url}/meta` per URL and UI locale across the
8
+ * session (shared via meta-cache).
8
9
  * - Concurrent callers with the same URL share the in-flight promise.
9
10
  * - If the underlying fetch rejects, the cache entry is evicted so a later
10
11
  * retry performs a fresh fetch.
12
+ *
13
+ * `options.texts` — the app's UI texts (see `getMetaEntry`); the active ones
14
+ * by default.
11
15
  */
12
- function resolveValueHelp(url) {
13
- const entry = getMetaEntry(url);
16
+ function resolveValueHelp(url, options) {
17
+ const entry = getMetaEntry(url, void 0, options);
14
18
  if (entry.resolved) return entry.resolved;
15
19
  entry.resolved = Promise.all([entry.meta, entry.type]).then(([meta, type]) => buildResolved(url, meta, type));
16
20
  return entry.resolved;
@@ -2,9 +2,14 @@ import { FilterExpr } from "@atscript/db-client";
2
2
 
3
3
  //#region src/value-help/types.d.ts
4
4
  /** An option for select/radio fields — either a plain string or a `{ key, label }` pair. */
5
+ /**
6
+ * A form option: a plain string, or `{ key, label }` — plus, for options derived from a
7
+ * literal union or a boolean, the typed `value` (`true`, `3`) the field stores (since 0.1.165).
8
+ */
5
9
  type TFormEntryOptions = {
6
10
  key: string;
7
11
  label: string;
12
+ value?: string | number | boolean;
8
13
  } | string;
9
14
  /**
10
15
  * Minimal sync probe output for a value-help–eligible prop.
@@ -2,9 +2,14 @@ import { FilterExpr } from "@atscript/db-client";
2
2
 
3
3
  //#region src/value-help/types.d.ts
4
4
  /** An option for select/radio fields — either a plain string or a `{ key, label }` pair. */
5
+ /**
6
+ * A form option: a plain string, or `{ key, label }` — plus, for options derived from a
7
+ * literal union or a boolean, the typed `value` (`true`, `3`) the field stores (since 0.1.165).
8
+ */
5
9
  type TFormEntryOptions = {
6
10
  key: string;
7
11
  label: string;
12
+ value?: string | number | boolean;
8
13
  } | string;
9
14
  /**
10
15
  * Minimal sync probe output for a value-help–eligible prop.