@atscript/ui 0.1.207 → 0.1.208

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 (86) hide show
  1. package/dist/form/create-form-def.cjs +13 -12
  2. package/dist/form/create-form-def.mjs +14 -13
  3. package/dist/form/decimal-format.cjs +8 -3
  4. package/dist/form/decimal-format.d.cts +8 -2
  5. package/dist/form/decimal-format.d.mts +8 -2
  6. package/dist/form/decimal-format.mjs +8 -3
  7. package/dist/form/form-actions.cjs +9 -0
  8. package/dist/form/form-actions.d.cts +7 -1
  9. package/dist/form/form-actions.d.mts +7 -1
  10. package/dist/form/form-actions.mjs +9 -1
  11. package/dist/form/measurement.cjs +58 -0
  12. package/dist/form/measurement.d.cts +36 -1
  13. package/dist/form/measurement.d.mts +36 -1
  14. package/dist/form/measurement.mjs +57 -2
  15. package/dist/form/omit-derived.cjs +11 -0
  16. package/dist/form/omit-derived.d.cts +8 -1
  17. package/dist/form/omit-derived.d.mts +8 -1
  18. package/dist/form/omit-derived.mjs +11 -1
  19. package/dist/form/optional-mode.cjs +7 -7
  20. package/dist/form/optional-mode.d.cts +2 -1
  21. package/dist/form/optional-mode.d.mts +2 -1
  22. package/dist/form/optional-mode.mjs +8 -8
  23. package/dist/form/types.cjs +5 -0
  24. package/dist/form/types.d.cts +14 -0
  25. package/dist/form/types.d.mts +14 -0
  26. package/dist/form/types.mjs +5 -1
  27. package/dist/form/validate.cjs +56 -5
  28. package/dist/form/validate.d.cts +30 -2
  29. package/dist/form/validate.d.mts +30 -2
  30. package/dist/form/validate.mjs +56 -6
  31. package/dist/index.cjs +24 -3
  32. package/dist/index.d.cts +14 -9
  33. package/dist/index.d.mts +14 -9
  34. package/dist/index.mjs +15 -10
  35. package/dist/plugin/annotations.cjs +1 -1
  36. package/dist/plugin/annotations.mjs +1 -1
  37. package/dist/shared/annotation-keys.d.cts +2 -1
  38. package/dist/shared/annotation-keys.d.mts +2 -1
  39. package/dist/shared/dev.cjs +22 -0
  40. package/dist/shared/dev.d.cts +4 -0
  41. package/dist/shared/dev.d.mts +4 -0
  42. package/dist/shared/dev.mjs +22 -0
  43. package/dist/shared/field-resolver.cjs +21 -1
  44. package/dist/shared/field-resolver.d.cts +15 -1
  45. package/dist/shared/field-resolver.d.mts +15 -1
  46. package/dist/shared/field-resolver.mjs +20 -2
  47. package/dist/shared/merge-filters.cjs +28 -0
  48. package/dist/shared/merge-filters.d.cts +13 -0
  49. package/dist/shared/merge-filters.d.mts +13 -0
  50. package/dist/shared/merge-filters.mjs +28 -0
  51. package/dist/shared/resolve-component.cjs +27 -0
  52. package/dist/shared/resolve-component.d.cts +22 -0
  53. package/dist/shared/resolve-component.d.mts +22 -0
  54. package/dist/shared/resolve-component.mjs +27 -0
  55. package/dist/shared/stable-key.cjs +28 -0
  56. package/dist/shared/stable-key.d.cts +13 -0
  57. package/dist/shared/stable-key.d.mts +13 -0
  58. package/dist/shared/stable-key.mjs +28 -0
  59. package/dist/shared/to-date.cjs +65 -0
  60. package/dist/shared/to-date.d.cts +35 -0
  61. package/dist/shared/to-date.d.mts +35 -0
  62. package/dist/shared/to-date.mjs +64 -0
  63. package/dist/table/create-table-def.cjs +49 -15
  64. package/dist/table/create-table-def.mjs +49 -16
  65. package/dist/table/types.d.cts +15 -13
  66. package/dist/table/types.d.mts +15 -13
  67. package/dist/value-help/distinct-client.cjs +80 -7
  68. package/dist/value-help/distinct-client.d.cts +31 -36
  69. package/dist/value-help/distinct-client.d.mts +31 -36
  70. package/dist/value-help/distinct-client.mjs +80 -7
  71. package/dist/value-help/index.d.mts +2 -2
  72. package/dist/value-help/options.cjs +21 -0
  73. package/dist/value-help/options.d.cts +17 -1
  74. package/dist/value-help/options.d.mts +17 -1
  75. package/dist/value-help/options.mjs +21 -1
  76. package/dist/value-help/resolve.cjs +2 -12
  77. package/dist/value-help/resolve.mjs +3 -13
  78. package/dist/value-help/scope.cjs +3 -7
  79. package/dist/value-help/scope.mjs +3 -7
  80. package/dist/value-help/texts.cjs +7 -4
  81. package/dist/value-help/texts.mjs +7 -4
  82. package/dist/value-help/value-help-client.cjs +5 -3
  83. package/dist/value-help/value-help-client.d.cts +3 -2
  84. package/dist/value-help/value-help-client.d.mts +3 -2
  85. package/dist/value-help/value-help-client.mjs +5 -3
  86. package/package.json +10 -10
@@ -33,7 +33,7 @@ function resolveValueHelp(url, options) {
33
33
  if (!resolved) {
34
34
  resolved = Promise.all([entry.meta, entry.resolved]).then(([meta, base]) => {
35
35
  if (!base.targetType.type.props?.has(own.field)) return base;
36
- const label = readableLabel(meta, own.field, own.arrangement ?? base.label?.arrangement);
36
+ const label = require_create_table_def.readableLabel(meta, own.field, own.arrangement ?? base.label?.arrangement);
37
37
  return label ? {
38
38
  ...base,
39
39
  label,
@@ -44,14 +44,6 @@ function resolveValueHelp(url, options) {
44
44
  }
45
45
  return resolved;
46
46
  }
47
- /** `field` of the served type as a label, when the caller may read it (`isReadable`). */
48
- function readableLabel(meta, field, arrangement) {
49
- if (!require_create_table_def.isReadable(meta.fields?.[field])) return void 0;
50
- return {
51
- field,
52
- arrangement: arrangement ?? "textKey"
53
- };
54
- }
55
47
  /** Thin alias over `resetMetaCache` — retained so existing test code keeps working. */
56
48
  function resetValueHelpCache() {
57
49
  require_meta_cache.resetMetaCache();
@@ -60,7 +52,7 @@ function buildResolved(url, meta, targetType) {
60
52
  const objectType = targetType.type.kind === "object" ? targetType.type : void 0;
61
53
  const versionColumn = meta.versionColumn;
62
54
  const primaryKeys = [];
63
- let label;
55
+ const label = require_create_table_def.dictLabelOf(meta, targetType);
64
56
  let descrField;
65
57
  const attrFields = [];
66
58
  let firstStringField;
@@ -68,8 +60,6 @@ function buildResolved(url, meta, targetType) {
68
60
  if (name === versionColumn) continue;
69
61
  const isPK = fieldProp.metadata.has(require_annotation_keys.META_ID);
70
62
  if (isPK) primaryKeys.push(name);
71
- const dictLabel = fieldProp.metadata.get(require_annotation_keys.UI_DICT_LABEL);
72
- if (dictLabel !== void 0) label = readableLabel(meta, name, typeof dictLabel === "string" ? dictLabel : void 0);
73
63
  if (fieldProp.metadata.has("ui.dict.descr")) descrField = name;
74
64
  if (fieldProp.metadata.has("ui.dict.attr")) attrFields.push(name);
75
65
  if (!firstStringField && !isPK && fieldProp.type.kind === "" && fieldProp.type.designType === "string") firstStringField = name;
@@ -1,5 +1,5 @@
1
- import { META_ID, UI_DICT_LABEL } from "../shared/annotation-keys.mjs";
2
- import { isReadable } from "../table/create-table-def.mjs";
1
+ import { META_ID } from "../shared/annotation-keys.mjs";
2
+ import { dictLabelOf, readableLabel } from "../table/create-table-def.mjs";
3
3
  import { getMetaEntry, resetMetaCache } from "../shared/meta-cache.mjs";
4
4
  //#region src/value-help/resolve.ts
5
5
  /** Per meta-cache entry: the dictionary resolved for each binding's label. */
@@ -44,14 +44,6 @@ function resolveValueHelp(url, options) {
44
44
  }
45
45
  return resolved;
46
46
  }
47
- /** `field` of the served type as a label, when the caller may read it (`isReadable`). */
48
- function readableLabel(meta, field, arrangement) {
49
- if (!isReadable(meta.fields?.[field])) return void 0;
50
- return {
51
- field,
52
- arrangement: arrangement ?? "textKey"
53
- };
54
- }
55
47
  /** Thin alias over `resetMetaCache` — retained so existing test code keeps working. */
56
48
  function resetValueHelpCache() {
57
49
  resetMetaCache();
@@ -60,7 +52,7 @@ function buildResolved(url, meta, targetType) {
60
52
  const objectType = targetType.type.kind === "object" ? targetType.type : void 0;
61
53
  const versionColumn = meta.versionColumn;
62
54
  const primaryKeys = [];
63
- let label;
55
+ const label = dictLabelOf(meta, targetType);
64
56
  let descrField;
65
57
  const attrFields = [];
66
58
  let firstStringField;
@@ -68,8 +60,6 @@ function buildResolved(url, meta, targetType) {
68
60
  if (name === versionColumn) continue;
69
61
  const isPK = fieldProp.metadata.has(META_ID);
70
62
  if (isPK) primaryKeys.push(name);
71
- const dictLabel = fieldProp.metadata.get(UI_DICT_LABEL);
72
- if (dictLabel !== void 0) label = readableLabel(meta, name, typeof dictLabel === "string" ? dictLabel : void 0);
73
63
  if (fieldProp.metadata.has("ui.dict.descr")) descrField = name;
74
64
  if (fieldProp.metadata.has("ui.dict.attr")) attrFields.push(name);
75
65
  if (!firstStringField && !isPK && fieldProp.type.kind === "" && fieldProp.type.designType === "string") firstStringField = name;
@@ -1,3 +1,4 @@
1
+ const require_merge_filters = require("../shared/merge-filters.cjs");
1
2
  //#region src/value-help/scope.ts
2
3
  /**
3
4
  * A host value the picker can filter by: one scalar. Empty (`undefined`,
@@ -24,14 +25,9 @@ function valueHelpScope(info, read) {
24
25
  conditions.push({ [target]: value });
25
26
  if (!pinned.includes(target)) pinned.push(target);
26
27
  }
27
- if (conditions.length === 0) return {
28
- ...info.filter && { filter: info.filter },
29
- pinned
30
- };
31
- const base = info.filter;
32
- const all = base ? [...Array.isArray(base.$and) ? base.$and : [info.filter], ...conditions] : conditions;
28
+ const filter = require_merge_filters.mergeFilters(info.filter, ...conditions);
33
29
  return {
34
- filter: all.length === 1 ? all[0] : { $and: all },
30
+ ...filter && { filter },
35
31
  pinned
36
32
  };
37
33
  }
@@ -1,3 +1,4 @@
1
+ import { mergeFilters } from "../shared/merge-filters.mjs";
1
2
  //#region src/value-help/scope.ts
2
3
  /**
3
4
  * A host value the picker can filter by: one scalar. Empty (`undefined`,
@@ -24,14 +25,9 @@ function valueHelpScope(info, read) {
24
25
  conditions.push({ [target]: value });
25
26
  if (!pinned.includes(target)) pinned.push(target);
26
27
  }
27
- if (conditions.length === 0) return {
28
- ...info.filter && { filter: info.filter },
29
- pinned
30
- };
31
- const base = info.filter;
32
- const all = base ? [...Array.isArray(base.$and) ? base.$and : [info.filter], ...conditions] : conditions;
28
+ const filter = mergeFilters(info.filter, ...conditions);
33
29
  return {
34
- filter: all.length === 1 ? all[0] : { $and: all },
30
+ ...filter && { filter },
35
31
  pinned
36
32
  };
37
33
  }
@@ -1,11 +1,12 @@
1
1
  const require_extract_ref = require("./extract-ref.cjs");
2
+ const require_merge_filters = require("../shared/merge-filters.cjs");
2
3
  const require_value_label = require("../shared/value-label.cjs");
3
4
  const require_client_store = require("./client-store.cjs");
4
5
  const require_options = require("./options.cjs");
5
6
  const require_source = require("./source.cjs");
6
7
  //#region src/value-help/texts.ts
7
8
  /** Codes per request: a lookup is a GET, the codes travel in its URL. */
8
- const LOOKUP_BATCH = 100;
9
+ const LOOKUP_BATCH = 50;
9
10
  /** Texts kept per dictionary, binding scope and label field; the least recently read go first. */
10
11
  const MAX_TEXTS = 1e4;
11
12
  /** A failed lookup (no access, no network) asks again after this long (ms). */
@@ -156,10 +157,12 @@ async function lookup(texts, batch) {
156
157
  const requests = [];
157
158
  for (let i = 0; i < entries.length; i += LOOKUP_BATCH) {
158
159
  const chunk = entries.slice(i, i + LOOKUP_BATCH);
159
- const codes = { [key]: { $in: chunk.map(([, value]) => value) } };
160
160
  const request = {
161
- filter: filter ? { $and: [filter, codes] } : codes,
162
- controls: { $select: select }
161
+ filter: require_merge_filters.mergeFilters(filter, { [key]: { $in: chunk.map(([, value]) => value) } }),
162
+ controls: {
163
+ $select: select,
164
+ $limit: chunk.length * 2
165
+ }
163
166
  };
164
167
  requests.push(Promise.resolve().then(() => client.query(request)).then((rows) => {
165
168
  const found = rowTexts(rows, key, field);
@@ -1,11 +1,12 @@
1
1
  import { valueHelpKey } from "./extract-ref.mjs";
2
+ import { mergeFilters } from "../shared/merge-filters.mjs";
2
3
  import { codeOf } from "../shared/value-label.mjs";
3
4
  import { clientStore, dropClientStores, staleClientStores } from "./client-store.mjs";
4
5
  import { valueHelpRowText } from "./options.mjs";
5
6
  import { valueHelpSource } from "./source.mjs";
6
7
  //#region src/value-help/texts.ts
7
8
  /** Codes per request: a lookup is a GET, the codes travel in its URL. */
8
- const LOOKUP_BATCH = 100;
9
+ const LOOKUP_BATCH = 50;
9
10
  /** Texts kept per dictionary, binding scope and label field; the least recently read go first. */
10
11
  const MAX_TEXTS = 1e4;
11
12
  /** A failed lookup (no access, no network) asks again after this long (ms). */
@@ -156,10 +157,12 @@ async function lookup(texts, batch) {
156
157
  const requests = [];
157
158
  for (let i = 0; i < entries.length; i += LOOKUP_BATCH) {
158
159
  const chunk = entries.slice(i, i + LOOKUP_BATCH);
159
- const codes = { [key]: { $in: chunk.map(([, value]) => value) } };
160
160
  const request = {
161
- filter: filter ? { $and: [filter, codes] } : codes,
162
- controls: { $select: select }
161
+ filter: mergeFilters(filter, { [key]: { $in: chunk.map(([, value]) => value) } }),
162
+ controls: {
163
+ $select: select,
164
+ $limit: chunk.length * 2
165
+ }
163
166
  };
164
167
  requests.push(Promise.resolve().then(() => client.query(request)).then((rows) => {
165
168
  const found = rowTexts(rows, key, field);
@@ -1,4 +1,5 @@
1
1
  const require_dict_paths = require("./dict-paths.cjs");
2
+ const require_merge_filters = require("../shared/merge-filters.cjs");
2
3
  const require_str = require("../shared/str.cjs");
3
4
  const require_create_table_def = require("../table/create-table-def.cjs");
4
5
  const require_value_kind = require("../table/value-kind.cjs");
@@ -21,8 +22,9 @@ function setValueHelpCacheTtl(ms) {
21
22
  * the texts of codes read from them stale: a code keeps its text until it is
22
23
  * read again (one batched request), then the new text replaces it. The
23
24
  * labels the bindings resolved stay (they are metadata); a dictionary whose
24
- * `/meta` failed is asked again. Mounted views read their texts again. Call
25
- * after writing to a dictionary outside the built-in table actions.
25
+ * `/meta` failed is asked again. Mounted views read their texts again, and a
26
+ * distinct-values pager its first page (since 0.1.208). Call after writing to
27
+ * a dictionary outside the built-in table actions.
26
28
  */
27
29
  function invalidateValueHelpCache(client) {
28
30
  require_texts.staleValueHelpTexts(client);
@@ -105,7 +107,7 @@ var ValueHelpClient = class {
105
107
  const keyField = valueField ?? resolved.primaryKeys[0] ?? resolved.labelField;
106
108
  const search = buildOrFilter(text, computeSelectFields(resolved, mode, valueField), keyField, resolved.targetType);
107
109
  if (!search) return { items: [] };
108
- filter = scope ? { $and: [scope, search] } : search;
110
+ filter = require_merge_filters.mergeFilters(scope, search);
109
111
  }
110
112
  const items = await sharedQuery(this._client, {
111
113
  ...filter && { filter },
@@ -51,8 +51,9 @@ declare function setValueHelpCacheTtl(ms: number): void;
51
51
  * the texts of codes read from them stale: a code keeps its text until it is
52
52
  * read again (one batched request), then the new text replaces it. The
53
53
  * labels the bindings resolved stay (they are metadata); a dictionary whose
54
- * `/meta` failed is asked again. Mounted views read their texts again. Call
55
- * after writing to a dictionary outside the built-in table actions.
54
+ * `/meta` failed is asked again. Mounted views read their texts again, and a
55
+ * distinct-values pager its first page (since 0.1.208). Call after writing to
56
+ * a dictionary outside the built-in table actions.
56
57
  */
57
58
  declare function invalidateValueHelpCache(client?: ClientLike): void;
58
59
  /**
@@ -51,8 +51,9 @@ declare function setValueHelpCacheTtl(ms: number): void;
51
51
  * the texts of codes read from them stale: a code keeps its text until it is
52
52
  * read again (one batched request), then the new text replaces it. The
53
53
  * labels the bindings resolved stay (they are metadata); a dictionary whose
54
- * `/meta` failed is asked again. Mounted views read their texts again. Call
55
- * after writing to a dictionary outside the built-in table actions.
54
+ * `/meta` failed is asked again. Mounted views read their texts again, and a
55
+ * distinct-values pager its first page (since 0.1.208). Call after writing to
56
+ * a dictionary outside the built-in table actions.
56
57
  */
57
58
  declare function invalidateValueHelpCache(client?: ClientLike): void;
58
59
  /**
@@ -1,4 +1,5 @@
1
1
  import { valueHelpDictPaths } from "./dict-paths.mjs";
2
+ import { mergeFilters } from "../shared/merge-filters.mjs";
2
3
  import { escapeRegex } from "../shared/str.mjs";
3
4
  import { inferValueKind } from "../table/create-table-def.mjs";
4
5
  import { coerceNumericText } from "../table/value-kind.mjs";
@@ -21,8 +22,9 @@ function setValueHelpCacheTtl(ms) {
21
22
  * the texts of codes read from them stale: a code keeps its text until it is
22
23
  * read again (one batched request), then the new text replaces it. The
23
24
  * labels the bindings resolved stay (they are metadata); a dictionary whose
24
- * `/meta` failed is asked again. Mounted views read their texts again. Call
25
- * after writing to a dictionary outside the built-in table actions.
25
+ * `/meta` failed is asked again. Mounted views read their texts again, and a
26
+ * distinct-values pager its first page (since 0.1.208). Call after writing to
27
+ * a dictionary outside the built-in table actions.
26
28
  */
27
29
  function invalidateValueHelpCache(client) {
28
30
  staleValueHelpTexts(client);
@@ -105,7 +107,7 @@ var ValueHelpClient = class {
105
107
  const keyField = valueField ?? resolved.primaryKeys[0] ?? resolved.labelField;
106
108
  const search = buildOrFilter(text, computeSelectFields(resolved, mode, valueField), keyField, resolved.targetType);
107
109
  if (!search) return { items: [] };
108
- filter = scope ? { $and: [scope, search] } : search;
110
+ filter = mergeFilters(scope, search);
109
111
  }
110
112
  const items = await sharedQuery(this._client, {
111
113
  ...filter && { filter },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/ui",
3
- "version": "0.1.207",
3
+ "version": "0.1.208",
4
4
  "description": "Framework-agnostic runtime for form and table definitions from atscript annotated types",
5
5
  "keywords": [
6
6
  "annotations",
@@ -52,19 +52,19 @@
52
52
  "access": "public"
53
53
  },
54
54
  "devDependencies": {
55
- "@atscript/core": "^0.2.33",
56
- "@atscript/db": "^0.1.211",
57
- "@atscript/db-client": "^0.1.211",
58
- "@atscript/typescript": "^0.2.33",
55
+ "@atscript/core": "^0.2.34",
56
+ "@atscript/db": "^0.1.212",
57
+ "@atscript/db-client": "^0.1.212",
58
+ "@atscript/typescript": "^0.2.34",
59
59
  "@uniqu/core": "^0.3.0",
60
- "unplugin-atscript": "^0.2.33",
60
+ "unplugin-atscript": "^0.2.34",
61
61
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14"
62
62
  },
63
63
  "peerDependencies": {
64
- "@atscript/core": "^0.2.33",
65
- "@atscript/db": "^0.1.211",
66
- "@atscript/db-client": "^0.1.211",
67
- "@atscript/typescript": "^0.2.33"
64
+ "@atscript/core": "^0.2.34",
65
+ "@atscript/db": "^0.1.212",
66
+ "@atscript/db-client": "^0.1.212",
67
+ "@atscript/typescript": "^0.2.34"
68
68
  },
69
69
  "scripts": {
70
70
  "build": "vp pack",