@atscript/ui 0.1.190 → 0.1.192
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/form/create-form-def.cjs +5 -3
- package/dist/form/create-form-def.mjs +5 -3
- package/dist/plugin/annotations.cjs +2 -2
- package/dist/plugin/annotations.mjs +2 -2
- package/dist/plugin/value-help-validation.cjs +7 -8
- package/dist/plugin/value-help-validation.mjs +7 -8
- package/dist/value-help/distinct-client.cjs +2 -1
- package/dist/value-help/distinct-client.mjs +2 -1
- package/package.json +4 -4
|
@@ -168,8 +168,10 @@ function collectFields(objectType, flatMap, edit, opts) {
|
|
|
168
168
|
* declaring the bound field; a field the def lists by a dotted path — a field of
|
|
169
169
|
* a namespace object rendered inline, `shipping.city` — has those siblings under
|
|
170
170
|
* the same parent, so they become `shipping.country`. A fill whose field the def
|
|
171
|
-
* does not have (a view or a chain reference without it
|
|
172
|
-
*
|
|
171
|
+
* does not have (a view or a chain reference without it, a field the served type
|
|
172
|
+
* leaves out), or holds as derived or a navigation, is dropped from the bound
|
|
173
|
+
* field's `valueHelpInfo`. A read-only field is written (since 0.1.191): the
|
|
174
|
+
* text next to a code that the server computes shows the picked row's.
|
|
173
175
|
*/
|
|
174
176
|
function keepWritableFills(fields) {
|
|
175
177
|
const byPath = new Map(fields.map((c) => [c.field.path, c.field]));
|
|
@@ -187,7 +189,7 @@ function keepWritableFills(fields) {
|
|
|
187
189
|
local: parent + f.local
|
|
188
190
|
} : f).filter(({ local }) => {
|
|
189
191
|
const sibling = byPath.get(local);
|
|
190
|
-
return !!sibling && !sibling.derived &&
|
|
192
|
+
return !!sibling && !sibling.derived && !(0, _atscript_db_validator.isNavRelation)(sibling.prop);
|
|
191
193
|
});
|
|
192
194
|
if (!parent && fill?.length === info.fill?.length) continue;
|
|
193
195
|
const { fill: _fill, hostFilter: _hostFilter, ...rest } = info;
|
|
@@ -168,8 +168,10 @@ function collectFields(objectType, flatMap, edit, opts) {
|
|
|
168
168
|
* declaring the bound field; a field the def lists by a dotted path — a field of
|
|
169
169
|
* a namespace object rendered inline, `shipping.city` — has those siblings under
|
|
170
170
|
* the same parent, so they become `shipping.country`. A fill whose field the def
|
|
171
|
-
* does not have (a view or a chain reference without it
|
|
172
|
-
*
|
|
171
|
+
* does not have (a view or a chain reference without it, a field the served type
|
|
172
|
+
* leaves out), or holds as derived or a navigation, is dropped from the bound
|
|
173
|
+
* field's `valueHelpInfo`. A read-only field is written (since 0.1.191): the
|
|
174
|
+
* text next to a code that the server computes shows the picked row's.
|
|
173
175
|
*/
|
|
174
176
|
function keepWritableFills(fields) {
|
|
175
177
|
const byPath = new Map(fields.map((c) => [c.field.path, c.field]));
|
|
@@ -187,7 +189,7 @@ function keepWritableFills(fields) {
|
|
|
187
189
|
local: parent + f.local
|
|
188
190
|
} : f).filter(({ local }) => {
|
|
189
191
|
const sibling = byPath.get(local);
|
|
190
|
-
return !!sibling && !sibling.derived &&
|
|
192
|
+
return !!sibling && !sibling.derived && !isNavRelation(sibling.prop);
|
|
191
193
|
});
|
|
192
194
|
if (!parent && fill?.length === info.fill?.length) continue;
|
|
193
195
|
const { fill: _fill, hostFilter: _hostFilter, ...rest } = info;
|
|
@@ -481,7 +481,7 @@ const uiAnnotations = { ui: {
|
|
|
481
481
|
validate: require_value_help_validation.validateValueHelp
|
|
482
482
|
}),
|
|
483
483
|
fill: new _atscript_core.AnnotationSpec({
|
|
484
|
-
description: "A pick also fills another field of the form: writes the picked row's `targetField` into the sibling `local`, as an edit would. Repeat per field. Applies to the field's own binding (`@ui.valueHelp`, else `@db.rel.FK`) in forms only; a derived, read-only
|
|
484
|
+
description: "A pick also fills another field of the form: writes the picked row's `targetField` into the sibling `local`, as an edit would. Repeat per field. Applies to the field's own binding (`@ui.valueHelp`, else `@db.rel.FK`) in forms only; a derived or navigation sibling is skipped, a read-only one is written (the text next to a code). The clear button clears a filled field again while it still holds what the last pick wrote. Not passed through references.\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'id'\n@ui.valueHelp.fill 'cityName', 'name'\ncity?: string\ncityName?: string\n```\n",
|
|
485
485
|
nodeType: ["prop"],
|
|
486
486
|
multiple: true,
|
|
487
487
|
mergeStrategy: "replace",
|
|
@@ -500,7 +500,7 @@ const uiAnnotations = { ui: {
|
|
|
500
500
|
validate: require_value_help_validation.validateFill
|
|
501
501
|
}),
|
|
502
502
|
column: new _atscript_core.AnnotationSpec({
|
|
503
|
-
description: "A column of this binding's picker dialogs: they show exactly these dictionary fields, in order, instead of the dictionary's key / label / description view. Repeat per column. The combobox and the dropdown keep key, label and description.\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'id'\n@ui.valueHelp.column 'id'\n@ui.valueHelp.column 'name'\n@ui.valueHelp.column 'region'\ncity?: string\n```\n",
|
|
503
|
+
description: "A column of this binding's picker dialogs: they show exactly these dictionary fields, in order, instead of the dictionary's key / label / description view. Repeat per column. The combobox and the dropdown keep key, label and description; the combobox also shows, next to each key, the values of the key members listed here. A composite-key member listed here tells rows holding the same value apart, so the compiler does not warn that values may repeat (every other key member listed or pinned; not on a select / radio).\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'id'\n@ui.valueHelp.column 'id'\n@ui.valueHelp.column 'name'\n@ui.valueHelp.column 'region'\ncity?: string\n```\n",
|
|
504
504
|
nodeType: ["prop"],
|
|
505
505
|
multiple: true,
|
|
506
506
|
mergeStrategy: "replace",
|
|
@@ -481,7 +481,7 @@ const uiAnnotations = { ui: {
|
|
|
481
481
|
validate: validateValueHelp
|
|
482
482
|
}),
|
|
483
483
|
fill: new AnnotationSpec({
|
|
484
|
-
description: "A pick also fills another field of the form: writes the picked row's `targetField` into the sibling `local`, as an edit would. Repeat per field. Applies to the field's own binding (`@ui.valueHelp`, else `@db.rel.FK`) in forms only; a derived, read-only
|
|
484
|
+
description: "A pick also fills another field of the form: writes the picked row's `targetField` into the sibling `local`, as an edit would. Repeat per field. Applies to the field's own binding (`@ui.valueHelp`, else `@db.rel.FK`) in forms only; a derived or navigation sibling is skipped, a read-only one is written (the text next to a code). The clear button clears a filled field again while it still holds what the last pick wrote. Not passed through references.\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'id'\n@ui.valueHelp.fill 'cityName', 'name'\ncity?: string\ncityName?: string\n```\n",
|
|
485
485
|
nodeType: ["prop"],
|
|
486
486
|
multiple: true,
|
|
487
487
|
mergeStrategy: "replace",
|
|
@@ -500,7 +500,7 @@ const uiAnnotations = { ui: {
|
|
|
500
500
|
validate: validateFill
|
|
501
501
|
}),
|
|
502
502
|
column: new AnnotationSpec({
|
|
503
|
-
description: "A column of this binding's picker dialogs: they show exactly these dictionary fields, in order, instead of the dictionary's key / label / description view. Repeat per column. The combobox and the dropdown keep key, label and description.\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'id'\n@ui.valueHelp.column 'id'\n@ui.valueHelp.column 'name'\n@ui.valueHelp.column 'region'\ncity?: string\n```\n",
|
|
503
|
+
description: "A column of this binding's picker dialogs: they show exactly these dictionary fields, in order, instead of the dictionary's key / label / description view. Repeat per column. The combobox and the dropdown keep key, label and description; the combobox also shows, next to each key, the values of the key members listed here. A composite-key member listed here tells rows holding the same value apart, so the compiler does not warn that values may repeat (every other key member listed or pinned; not on a select / radio).\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'id'\n@ui.valueHelp.column 'id'\n@ui.valueHelp.column 'name'\n@ui.valueHelp.column 'region'\ncity?: string\n```\n",
|
|
504
504
|
nodeType: ["prop"],
|
|
505
505
|
multiple: true,
|
|
506
506
|
mergeStrategy: "replace",
|
|
@@ -420,19 +420,20 @@ function validateValueHelp(token, args, doc) {
|
|
|
420
420
|
if (!ok && fieldProp.countAnnotations("meta.id") > 0) {
|
|
421
421
|
const literal = pinnedFields(filterArg);
|
|
422
422
|
const byHost = validHost ? hostPins(filterArg, validHost.name) : void 0;
|
|
423
|
-
const fieldAnnotations =
|
|
423
|
+
const fieldAnnotations = (0, _atscript_db_shared.annotationTarget)(token, doc)?.annotations ?? [];
|
|
424
424
|
const argOf = (name) => fieldAnnotations.find((a) => a.name === name)?.args[0]?.text;
|
|
425
425
|
const formType = argOf("ui.form.type") ?? argOf("ui.type");
|
|
426
426
|
const dropdown = formType === "select" || formType === "radio";
|
|
427
427
|
const fills = fieldAnnotations.filter((a) => a.name === "ui.valueHelp.fill");
|
|
428
|
+
const columns = new Set(fieldAnnotations.filter((a) => a.name === "ui.valueHelp.column").map((a) => a.args[0]?.text));
|
|
428
429
|
const writtenBack = (member) => {
|
|
429
430
|
const local = byHost?.get(member);
|
|
430
|
-
return
|
|
431
|
+
return local !== void 0 && fills.some((a) => a.args[0]?.text === local && a.args[1]?.text === member);
|
|
431
432
|
};
|
|
432
|
-
ok = idFields.every(([name]) => name === fieldName || literal.has(name) || writtenBack(name));
|
|
433
|
+
ok = idFields.every(([name]) => name === fieldName || literal.has(name) || !dropdown && (writtenBack(name) || columns.has(name)));
|
|
433
434
|
}
|
|
434
435
|
if (!ok) errors.push({
|
|
435
|
-
message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' to a literal in the filter, or to a host field a fill writes back from the picked row)`,
|
|
436
|
+
message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' to a literal in the filter, or to a host field a fill writes back from the picked row, or shown as a @ui.valueHelp.column of this field)`,
|
|
436
437
|
severity: WARNING,
|
|
437
438
|
range: token.range
|
|
438
439
|
});
|
|
@@ -574,10 +575,8 @@ function validateFill(token, args, doc) {
|
|
|
574
575
|
});
|
|
575
576
|
else {
|
|
576
577
|
localOk = true;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (why) errors.push({
|
|
580
|
-
message: `'${local}' is ${why} — a pick never writes it`,
|
|
578
|
+
if ((0, _atscript_db_shared.effectiveAnnotationNames)(prop, doc).has("db.column.derived")) errors.push({
|
|
579
|
+
message: `'${local}' is @db.column.derived — a pick never writes it`,
|
|
581
580
|
severity: WARNING,
|
|
582
581
|
range: localArg.range
|
|
583
582
|
});
|
|
@@ -420,19 +420,20 @@ function validateValueHelp(token, args, doc) {
|
|
|
420
420
|
if (!ok && fieldProp.countAnnotations("meta.id") > 0) {
|
|
421
421
|
const literal = pinnedFields(filterArg);
|
|
422
422
|
const byHost = validHost ? hostPins(filterArg, validHost.name) : void 0;
|
|
423
|
-
const fieldAnnotations =
|
|
423
|
+
const fieldAnnotations = annotationTarget(token, doc)?.annotations ?? [];
|
|
424
424
|
const argOf = (name) => fieldAnnotations.find((a) => a.name === name)?.args[0]?.text;
|
|
425
425
|
const formType = argOf("ui.form.type") ?? argOf("ui.type");
|
|
426
426
|
const dropdown = formType === "select" || formType === "radio";
|
|
427
427
|
const fills = fieldAnnotations.filter((a) => a.name === "ui.valueHelp.fill");
|
|
428
|
+
const columns = new Set(fieldAnnotations.filter((a) => a.name === "ui.valueHelp.column").map((a) => a.args[0]?.text));
|
|
428
429
|
const writtenBack = (member) => {
|
|
429
430
|
const local = byHost?.get(member);
|
|
430
|
-
return
|
|
431
|
+
return local !== void 0 && fills.some((a) => a.args[0]?.text === local && a.args[1]?.text === member);
|
|
431
432
|
};
|
|
432
|
-
ok = idFields.every(([name]) => name === fieldName || literal.has(name) || writtenBack(name));
|
|
433
|
+
ok = idFields.every(([name]) => name === fieldName || literal.has(name) || !dropdown && (writtenBack(name) || columns.has(name)));
|
|
433
434
|
}
|
|
434
435
|
if (!ok) errors.push({
|
|
435
|
-
message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' to a literal in the filter, or to a host field a fill writes back from the picked row)`,
|
|
436
|
+
message: `values may repeat in the picker — '${targetName}.${fieldName}' is not unique (a sole @meta.id, @db.index.unique, or a composite key member with the other members pinned by '=' to a literal in the filter, or to a host field a fill writes back from the picked row, or shown as a @ui.valueHelp.column of this field)`,
|
|
436
437
|
severity: WARNING,
|
|
437
438
|
range: token.range
|
|
438
439
|
});
|
|
@@ -574,10 +575,8 @@ function validateFill(token, args, doc) {
|
|
|
574
575
|
});
|
|
575
576
|
else {
|
|
576
577
|
localOk = true;
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
if (why) errors.push({
|
|
580
|
-
message: `'${local}' is ${why} — a pick never writes it`,
|
|
578
|
+
if (effectiveAnnotationNames(prop, doc).has("db.column.derived")) errors.push({
|
|
579
|
+
message: `'${local}' is @db.column.derived — a pick never writes it`,
|
|
581
580
|
severity: WARNING,
|
|
582
581
|
range: localArg.range
|
|
583
582
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const require_path_utils = require("../form/path-utils.cjs");
|
|
1
2
|
const require_str = require("../shared/str.cjs");
|
|
2
3
|
//#region src/value-help/distinct-client.ts
|
|
3
4
|
/**
|
|
@@ -42,7 +43,7 @@ async function fetchDistinctValues(client, field, opts = {}) {
|
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
return {
|
|
45
|
-
items: rows.slice(0, limit).map((r) => r
|
|
46
|
+
items: rows.slice(0, limit).map((r) => require_path_utils.getByPath({ value: r }, field)).filter((v) => v !== null && v !== void 0),
|
|
46
47
|
hasMore: rows.length > limit
|
|
47
48
|
};
|
|
48
49
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getByPath } from "../form/path-utils.mjs";
|
|
1
2
|
import { escapeRegex } from "../shared/str.mjs";
|
|
2
3
|
//#region src/value-help/distinct-client.ts
|
|
3
4
|
/**
|
|
@@ -42,7 +43,7 @@ async function fetchDistinctValues(client, field, opts = {}) {
|
|
|
42
43
|
}
|
|
43
44
|
});
|
|
44
45
|
return {
|
|
45
|
-
items: rows.slice(0, limit).map((r) => r
|
|
46
|
+
items: rows.slice(0, limit).map((r) => getByPath({ value: r }, field)).filter((v) => v !== null && v !== void 0),
|
|
46
47
|
hasMore: rows.length > limit
|
|
47
48
|
};
|
|
48
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.192",
|
|
4
4
|
"description": "Framework-agnostic runtime for form and table definitions from atscript annotated types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"annotations",
|
|
@@ -52,11 +52,11 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@atscript/db-client": "^0.1.
|
|
55
|
+
"@atscript/db-client": "^0.1.197"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@atscript/core": "^0.2.23",
|
|
59
|
-
"@atscript/db": "^0.1.
|
|
59
|
+
"@atscript/db": "^0.1.197",
|
|
60
60
|
"@atscript/typescript": "^0.2.23",
|
|
61
61
|
"@uniqu/core": "^0.2.2",
|
|
62
62
|
"unplugin-atscript": "^0.2.23",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
66
|
"@atscript/core": "^0.2.23",
|
|
67
|
-
"@atscript/db": "^0.1.
|
|
67
|
+
"@atscript/db": "^0.1.197",
|
|
68
68
|
"@atscript/typescript": "^0.2.23"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|