@atscript/ui 0.1.205 → 0.1.207
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 +40 -58
- package/dist/form/create-form-def.d.cts +9 -0
- package/dist/form/create-form-def.d.mts +9 -0
- package/dist/form/create-form-def.mjs +39 -57
- package/dist/form/db-column.cjs +37 -0
- package/dist/form/db-column.mjs +35 -0
- package/dist/form/path-utils.cjs +20 -5
- package/dist/form/path-utils.d.cts +8 -1
- package/dist/form/path-utils.d.mts +8 -1
- package/dist/form/path-utils.mjs +20 -6
- package/dist/form/types.d.cts +1 -0
- package/dist/form/types.d.mts +1 -0
- package/dist/index.cjs +18 -3
- package/dist/index.d.cts +8 -5
- package/dist/index.d.mts +8 -5
- package/dist/index.mjs +11 -8
- package/dist/plugin/annotations.cjs +33 -14
- package/dist/plugin/annotations.mjs +34 -15
- package/dist/plugin/value-help-validation.cjs +26 -6
- package/dist/plugin/value-help-validation.mjs +26 -7
- package/dist/shared/annotation-keys.cjs +3 -0
- package/dist/shared/annotation-keys.mjs +3 -1
- package/dist/shared/meta-cache.cjs +5 -4
- package/dist/shared/meta-cache.d.cts +3 -2
- package/dist/shared/meta-cache.d.mts +3 -2
- package/dist/shared/meta-cache.mjs +5 -4
- package/dist/shared/value-label.cjs +14 -2
- package/dist/shared/value-label.d.cts +23 -6
- package/dist/shared/value-label.d.mts +23 -6
- package/dist/shared/value-label.mjs +14 -3
- package/dist/table/create-table-def.cjs +7 -1
- package/dist/table/create-table-def.mjs +7 -2
- package/dist/table/types.d.cts +1 -1
- package/dist/table/types.d.mts +1 -1
- package/dist/value-help/client-store.cjs +43 -0
- package/dist/value-help/client-store.d.mts +1 -0
- package/dist/value-help/client-store.mjs +40 -0
- package/dist/value-help/display-value.cjs +30 -0
- package/dist/value-help/display-value.d.cts +45 -0
- package/dist/value-help/display-value.d.mts +45 -0
- package/dist/value-help/display-value.mjs +30 -0
- package/dist/value-help/extract-ref.cjs +15 -4
- package/dist/value-help/extract-ref.d.cts +6 -1
- package/dist/value-help/extract-ref.d.mts +6 -1
- package/dist/value-help/extract-ref.mjs +16 -6
- package/dist/value-help/index.d.mts +6 -3
- package/dist/value-help/options.cjs +49 -8
- package/dist/value-help/options.d.cts +41 -4
- package/dist/value-help/options.d.mts +41 -4
- package/dist/value-help/options.mjs +47 -9
- package/dist/value-help/resolve-options.cjs +9 -7
- package/dist/value-help/resolve-options.d.cts +8 -9
- package/dist/value-help/resolve-options.d.mts +8 -9
- package/dist/value-help/resolve-options.mjs +9 -7
- package/dist/value-help/resolve.cjs +39 -8
- package/dist/value-help/resolve.d.cts +22 -5
- package/dist/value-help/resolve.d.mts +22 -5
- package/dist/value-help/resolve.mjs +40 -9
- package/dist/value-help/source.cjs +72 -0
- package/dist/value-help/source.d.cts +55 -0
- package/dist/value-help/source.d.mts +55 -0
- package/dist/value-help/source.mjs +71 -0
- package/dist/value-help/texts.cjs +315 -0
- package/dist/value-help/texts.d.cts +53 -0
- package/dist/value-help/texts.d.mts +53 -0
- package/dist/value-help/texts.mjs +310 -0
- package/dist/value-help/types.d.cts +10 -0
- package/dist/value-help/types.d.mts +10 -0
- package/dist/value-help/value-help-client.cjs +21 -19
- package/dist/value-help/value-help-client.d.cts +9 -5
- package/dist/value-help/value-help-client.d.mts +9 -5
- package/dist/value-help/value-help-client.mjs +19 -17
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateOptionalMode, validateValueHelp, validateValueLabel, valueHelpScopes, valueLabelFields } from "./value-help-validation.mjs";
|
|
1
|
+
import { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateOptionalMode, validateValueHelp, validateValueHelpLabel, validateValueLabel, valueHelpScopes, valueLabelFields } from "./value-help-validation.mjs";
|
|
2
2
|
import { AnnotationSpec } from "@atscript/core";
|
|
3
3
|
//#region src/plugin/annotations.ts
|
|
4
4
|
const BUILTIN_TYPES = [
|
|
@@ -18,6 +18,23 @@ const BUILTIN_TYPES = [
|
|
|
18
18
|
"paragraph",
|
|
19
19
|
"action"
|
|
20
20
|
];
|
|
21
|
+
/**
|
|
22
|
+
* The optional `arrangement` of `@ui.valueLabel`, `@ui.dict.label` and
|
|
23
|
+
* `@ui.valueHelp.label`: how a code shows with its text.
|
|
24
|
+
*/
|
|
25
|
+
function arrangementArg(defaultNote) {
|
|
26
|
+
return {
|
|
27
|
+
optional: true,
|
|
28
|
+
name: "arrangement",
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "How the code and its text are shown: `textKey` — `Berlin (BER)`; `keyText` — `BER (Berlin)`; `text` — `Berlin`. An empty text shows the code alone. " + defaultNote,
|
|
31
|
+
values: [
|
|
32
|
+
"textKey",
|
|
33
|
+
"keyText",
|
|
34
|
+
"text"
|
|
35
|
+
]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
21
38
|
const COL_SPAN_VALUES = [
|
|
22
39
|
"1",
|
|
23
40
|
"2",
|
|
@@ -529,6 +546,17 @@ const uiAnnotations = { ui: {
|
|
|
529
546
|
},
|
|
530
547
|
validate: validateColumn
|
|
531
548
|
}),
|
|
549
|
+
label: new AnnotationSpec({
|
|
550
|
+
description: "The text of this binding's codes: a string field of the dictionary, instead of its `@ui.dict.label`. A code shows with the text of its dictionary row in table cells, export, filter chips, read-only form fields and the reference field while it is not focused; the pickers show it as each row's text. Sorting and filtering stay on the code. An `@ui.valueLabel` of the field wins where the row holds its text.\n\n**Example:**\n```atscript\n@db.rel.FK\n@ui.valueHelp.label 'fullName', 'text'\nassigneeId?: User.id\n```\n",
|
|
551
|
+
nodeType: ["prop"],
|
|
552
|
+
argument: [{
|
|
553
|
+
name: "field",
|
|
554
|
+
type: "string",
|
|
555
|
+
description: "A string field of the dictionary holding the text of the codes.",
|
|
556
|
+
fieldScope: valueHelpScopes.bindingField
|
|
557
|
+
}, arrangementArg("Default: the dictionary's (`@ui.dict.label`), else `textKey`.")],
|
|
558
|
+
validate: validateValueHelpLabel
|
|
559
|
+
}),
|
|
532
560
|
distinct: new AnnotationSpec({
|
|
533
561
|
description: "Offers a **distinct-values picker** for this column in table filters: the values already stored, read from the table's own controller via `$groupBy`. Shown only when the server reports the field filterable and groupable, and the field has no dictionary binding, FK help or literal options. Not offered in forms.\n\n**Example:**\n```atscript\n@ui.valueHelp.distinct\ncity?: string\n```\n",
|
|
534
562
|
nodeType: ["prop", "type"],
|
|
@@ -554,7 +582,7 @@ const uiAnnotations = { ui: {
|
|
|
554
582
|
validate: validateLiteralLabel
|
|
555
583
|
}),
|
|
556
584
|
valueLabel: new AnnotationSpec({
|
|
557
|
-
description: "Shows this field's value — a code — together with its text, read from a string field of the same interface: in table cells, export, read-only form fields and the reference field while it is not focused.
|
|
585
|
+
description: "Shows this field's value — a code — together with its text, read from a string field of the same interface: in table cells, export, read-only form fields and the reference field while it is not focused. Wins over a dictionary label (`@ui.dict.label`, `@ui.valueHelp.label`) wherever the row is at hand; filter chips show the dictionary's. Sorting and filtering stay on the code. On a field with a value-help binding, let the pick fill the text (`@ui.valueHelp.fill`), or it goes stale after a pick. Not passed through references.\n\n**Example:**\n```atscript\n@ui.valueHelp City, 'code'\n@ui.valueHelp.fill 'cityName', 'name'\n@ui.valueLabel 'cityName'\ncity?: string\ncityName?: string\n```\n",
|
|
558
586
|
nodeType: ["prop"],
|
|
559
587
|
passedWhenReferred: false,
|
|
560
588
|
argument: [{
|
|
@@ -562,24 +590,15 @@ const uiAnnotations = { ui: {
|
|
|
562
590
|
type: "string",
|
|
563
591
|
description: "A string field of this interface holding the text of this field's value — not this field.",
|
|
564
592
|
valueScope: valueLabelFields
|
|
565
|
-
},
|
|
566
|
-
optional: true,
|
|
567
|
-
name: "arrangement",
|
|
568
|
-
type: "string",
|
|
569
|
-
description: "How the code and its text are shown: `textKey` (default) — `Berlin (BER)`; `keyText` — `BER (Berlin)`; `text` — `Berlin`. An empty text shows the code alone.",
|
|
570
|
-
values: [
|
|
571
|
-
"textKey",
|
|
572
|
-
"keyText",
|
|
573
|
-
"text"
|
|
574
|
-
]
|
|
575
|
-
}],
|
|
593
|
+
}, arrangementArg("Default: `textKey`.")],
|
|
576
594
|
validate: validateValueLabel
|
|
577
595
|
}),
|
|
578
596
|
dict: {
|
|
579
597
|
label: new AnnotationSpec({
|
|
580
|
-
description: "
|
|
598
|
+
description: "The label of this dictionary's records: every code bound to it (`@db.rel.FK` or `@ui.valueHelp`) shows with this field's text — in table cells, export, filter chips, read-only form fields and the reference field while it is not focused — and the pickers show it as each row's text. A binding may name another field (`@ui.valueHelp.label`). Without it, codes show alone.\n\n**Example:**\n```atscript\n@ui.dict.label 'keyText'\nname: string\n```\n",
|
|
581
599
|
nodeType: ["prop"],
|
|
582
|
-
passedWhenReferred: false
|
|
600
|
+
passedWhenReferred: false,
|
|
601
|
+
argument: arrangementArg("Default: `textKey`.")
|
|
583
602
|
}),
|
|
584
603
|
descr: new AnnotationSpec({
|
|
585
604
|
description: "Marks this field as the secondary description in value-help display",
|
|
@@ -3,10 +3,11 @@ let _atscript_db_shared = require("@atscript/db/shared");
|
|
|
3
3
|
//#region src/plugin/value-help-validation.ts
|
|
4
4
|
/**
|
|
5
5
|
* Editor scopes + validators of `@ui.valueHelp`, `@ui.valueHelp.distinct` and
|
|
6
|
-
* `@ui.literalLabel` (since 0.1.148),
|
|
6
|
+
* `@ui.literalLabel` (since 0.1.148), of `@ui.valueHelp.fill`,
|
|
7
7
|
* `@ui.valueHelp.column`, host references in a binding filter and
|
|
8
|
-
* `@ui.valueLabel` (since 0.1.190)
|
|
9
|
-
* so a diagnostic and what
|
|
8
|
+
* `@ui.valueLabel` (since 0.1.190), and of `@ui.valueHelp.label` (since
|
|
9
|
+
* 0.1.207). Scopes and validators share one source, so a diagnostic and what
|
|
10
|
+
* the editor completes never diverge.
|
|
10
11
|
*/
|
|
11
12
|
const WARNING = 2;
|
|
12
13
|
const ERROR = 1;
|
|
@@ -601,23 +602,41 @@ function validateFill(token, args, doc) {
|
|
|
601
602
|
}
|
|
602
603
|
return errors;
|
|
603
604
|
}
|
|
604
|
-
|
|
605
|
+
/**
|
|
606
|
+
* A field of the target of the field's own binding, named by `args[0]` —
|
|
607
|
+
* `@ui.valueHelp.column` (CL1/CL2) and `@ui.valueHelp.label` (LB1/LB2): the
|
|
608
|
+
* binding must be there (`@ui.valueHelp` or `@db.rel.FK`) and hold the field;
|
|
609
|
+
* `check` adds the annotation's own rule.
|
|
610
|
+
*/
|
|
611
|
+
function bindingFieldMessages(token, args, doc, annotation, check) {
|
|
605
612
|
const field = (0, _atscript_db_shared.annotationTarget)(token, doc);
|
|
606
613
|
if (!field) return [];
|
|
607
614
|
const binding = bindingOf(field, doc);
|
|
608
615
|
if (!binding) return [{
|
|
609
|
-
message:
|
|
616
|
+
message: `${annotation} needs a binding of this field's own (@ui.valueHelp or @db.rel.FK)`,
|
|
610
617
|
severity: ERROR,
|
|
611
618
|
range: token.range
|
|
612
619
|
}];
|
|
613
620
|
const name = args[0]?.text;
|
|
614
|
-
|
|
621
|
+
if (name === void 0) return [];
|
|
622
|
+
const problem = targetFieldProblem(binding, name) ?? check?.(binding, name);
|
|
615
623
|
return problem ? [{
|
|
616
624
|
message: problem,
|
|
617
625
|
severity: ERROR,
|
|
618
626
|
range: args[0].range
|
|
619
627
|
}] : [];
|
|
620
628
|
}
|
|
629
|
+
function validateColumn(token, args, doc) {
|
|
630
|
+
return bindingFieldMessages(token, args, doc, "@ui.valueHelp.column");
|
|
631
|
+
}
|
|
632
|
+
function validateValueHelpLabel(token, args, doc) {
|
|
633
|
+
return bindingFieldMessages(token, args, doc, "@ui.valueHelp.label", (binding, name) => {
|
|
634
|
+
const target = binding.target;
|
|
635
|
+
const prop = target?.props.get(name);
|
|
636
|
+
const design = prop && target && designOf(prop.getDefinition(), target.doc);
|
|
637
|
+
return design && design !== "string" ? `'${binding.name}.${name}' must be a string field (the text of the codes)` : void 0;
|
|
638
|
+
});
|
|
639
|
+
}
|
|
621
640
|
function validateDistinct(token, _args, doc) {
|
|
622
641
|
const errors = [];
|
|
623
642
|
const host = token.parentNode;
|
|
@@ -789,6 +808,7 @@ exports.validateFormType = validateFormType;
|
|
|
789
808
|
exports.validateLiteralLabel = validateLiteralLabel;
|
|
790
809
|
exports.validateOptionalMode = validateOptionalMode;
|
|
791
810
|
exports.validateValueHelp = validateValueHelp;
|
|
811
|
+
exports.validateValueHelpLabel = validateValueHelpLabel;
|
|
792
812
|
exports.validateValueLabel = validateValueLabel;
|
|
793
813
|
exports.valueHelpScopes = valueHelpScopes;
|
|
794
814
|
exports.valueLabelFields = valueLabelFields;
|
|
@@ -3,10 +3,11 @@ import { NOT_DIMENSION_REASON, annotationTarget, effectiveAnnotationNames, fkCha
|
|
|
3
3
|
//#region src/plugin/value-help-validation.ts
|
|
4
4
|
/**
|
|
5
5
|
* Editor scopes + validators of `@ui.valueHelp`, `@ui.valueHelp.distinct` and
|
|
6
|
-
* `@ui.literalLabel` (since 0.1.148),
|
|
6
|
+
* `@ui.literalLabel` (since 0.1.148), of `@ui.valueHelp.fill`,
|
|
7
7
|
* `@ui.valueHelp.column`, host references in a binding filter and
|
|
8
|
-
* `@ui.valueLabel` (since 0.1.190)
|
|
9
|
-
* so a diagnostic and what
|
|
8
|
+
* `@ui.valueLabel` (since 0.1.190), and of `@ui.valueHelp.label` (since
|
|
9
|
+
* 0.1.207). Scopes and validators share one source, so a diagnostic and what
|
|
10
|
+
* the editor completes never diverge.
|
|
10
11
|
*/
|
|
11
12
|
const WARNING = 2;
|
|
12
13
|
const ERROR = 1;
|
|
@@ -601,23 +602,41 @@ function validateFill(token, args, doc) {
|
|
|
601
602
|
}
|
|
602
603
|
return errors;
|
|
603
604
|
}
|
|
604
|
-
|
|
605
|
+
/**
|
|
606
|
+
* A field of the target of the field's own binding, named by `args[0]` —
|
|
607
|
+
* `@ui.valueHelp.column` (CL1/CL2) and `@ui.valueHelp.label` (LB1/LB2): the
|
|
608
|
+
* binding must be there (`@ui.valueHelp` or `@db.rel.FK`) and hold the field;
|
|
609
|
+
* `check` adds the annotation's own rule.
|
|
610
|
+
*/
|
|
611
|
+
function bindingFieldMessages(token, args, doc, annotation, check) {
|
|
605
612
|
const field = annotationTarget(token, doc);
|
|
606
613
|
if (!field) return [];
|
|
607
614
|
const binding = bindingOf(field, doc);
|
|
608
615
|
if (!binding) return [{
|
|
609
|
-
message:
|
|
616
|
+
message: `${annotation} needs a binding of this field's own (@ui.valueHelp or @db.rel.FK)`,
|
|
610
617
|
severity: ERROR,
|
|
611
618
|
range: token.range
|
|
612
619
|
}];
|
|
613
620
|
const name = args[0]?.text;
|
|
614
|
-
|
|
621
|
+
if (name === void 0) return [];
|
|
622
|
+
const problem = targetFieldProblem(binding, name) ?? check?.(binding, name);
|
|
615
623
|
return problem ? [{
|
|
616
624
|
message: problem,
|
|
617
625
|
severity: ERROR,
|
|
618
626
|
range: args[0].range
|
|
619
627
|
}] : [];
|
|
620
628
|
}
|
|
629
|
+
function validateColumn(token, args, doc) {
|
|
630
|
+
return bindingFieldMessages(token, args, doc, "@ui.valueHelp.column");
|
|
631
|
+
}
|
|
632
|
+
function validateValueHelpLabel(token, args, doc) {
|
|
633
|
+
return bindingFieldMessages(token, args, doc, "@ui.valueHelp.label", (binding, name) => {
|
|
634
|
+
const target = binding.target;
|
|
635
|
+
const prop = target?.props.get(name);
|
|
636
|
+
const design = prop && target && designOf(prop.getDefinition(), target.doc);
|
|
637
|
+
return design && design !== "string" ? `'${binding.name}.${name}' must be a string field (the text of the codes)` : void 0;
|
|
638
|
+
});
|
|
639
|
+
}
|
|
621
640
|
function validateDistinct(token, _args, doc) {
|
|
622
641
|
const errors = [];
|
|
623
642
|
const host = token.parentNode;
|
|
@@ -780,4 +799,4 @@ function validateFormType(token, args, doc) {
|
|
|
780
799
|
}];
|
|
781
800
|
}
|
|
782
801
|
//#endregion
|
|
783
|
-
export { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateOptionalMode, validateValueHelp, validateValueLabel, valueHelpScopes, valueLabelFields };
|
|
802
|
+
export { isValueHelpTarget, literalLabelValues, validateColumn, validateDistinct, validateFill, validateFormType, validateLiteralLabel, validateOptionalMode, validateValueHelp, validateValueHelpLabel, validateValueLabel, valueHelpScopes, valueLabelFields };
|
|
@@ -51,6 +51,8 @@ const UI_VALUE_HELP_DISTINCT = "ui.valueHelp.distinct";
|
|
|
51
51
|
const UI_VALUE_HELP_FILL = "ui.valueHelp.fill";
|
|
52
52
|
/** `@ui.valueHelp.column 'field'` — since 0.1.190. */
|
|
53
53
|
const UI_VALUE_HELP_COLUMN = "ui.valueHelp.column";
|
|
54
|
+
/** `@ui.valueHelp.label 'field', 'arrangement'?` — since 0.1.207. */
|
|
55
|
+
const UI_VALUE_HELP_LABEL = "ui.valueHelp.label";
|
|
54
56
|
const UI_LITERAL_LABEL = "ui.literalLabel";
|
|
55
57
|
/** `@ui.valueLabel 'field', 'arrangement'?` — a code shown with its text; since 0.1.190. */
|
|
56
58
|
const UI_VALUE_LABEL = "ui.valueLabel";
|
|
@@ -208,5 +210,6 @@ exports.UI_VALUE_HELP = UI_VALUE_HELP;
|
|
|
208
210
|
exports.UI_VALUE_HELP_COLUMN = UI_VALUE_HELP_COLUMN;
|
|
209
211
|
exports.UI_VALUE_HELP_DISTINCT = UI_VALUE_HELP_DISTINCT;
|
|
210
212
|
exports.UI_VALUE_HELP_FILL = UI_VALUE_HELP_FILL;
|
|
213
|
+
exports.UI_VALUE_HELP_LABEL = UI_VALUE_HELP_LABEL;
|
|
211
214
|
exports.UI_VALUE_LABEL = UI_VALUE_LABEL;
|
|
212
215
|
exports.WF_ACTION_WITH_DATA = WF_ACTION_WITH_DATA;
|
|
@@ -51,6 +51,8 @@ const UI_VALUE_HELP_DISTINCT = "ui.valueHelp.distinct";
|
|
|
51
51
|
const UI_VALUE_HELP_FILL = "ui.valueHelp.fill";
|
|
52
52
|
/** `@ui.valueHelp.column 'field'` — since 0.1.190. */
|
|
53
53
|
const UI_VALUE_HELP_COLUMN = "ui.valueHelp.column";
|
|
54
|
+
/** `@ui.valueHelp.label 'field', 'arrangement'?` — since 0.1.207. */
|
|
55
|
+
const UI_VALUE_HELP_LABEL = "ui.valueHelp.label";
|
|
54
56
|
const UI_LITERAL_LABEL = "ui.literalLabel";
|
|
55
57
|
/** `@ui.valueLabel 'field', 'arrangement'?` — a code shown with its text; since 0.1.190. */
|
|
56
58
|
const UI_VALUE_LABEL = "ui.valueLabel";
|
|
@@ -108,4 +110,4 @@ const UI_TABLE_FN_CLASSES = "ui.table.fn.classes";
|
|
|
108
110
|
const UI_TABLE_FN_STYLES = "ui.table.fn.styles";
|
|
109
111
|
const UI_FORM_VALIDATE = "ui.form.validate";
|
|
110
112
|
//#endregion
|
|
111
|
-
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_DERIVED, DB_COLUMN_PRECISION, DB_COLUMN_VERSION, DB_COLUMN_VERSION_TOKEN, DB_COMPUTE, DB_COMPUTE_HOST, DB_ENCRYPTED, DB_HTTP_PATH, DB_JSON, DB_REL_FK, DB_TABLE, DB_UNIT, DB_UNIT_REF, DB_VIEW, DB_VIEW_FOR, EXPECT_ARRAY_KEY, EXPECT_ARRAY_UNIQUE_ITEMS, EXPECT_MAX_LENGTH, EXPECT_MESSAGE, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_NS, UI_FORM_OPTIONAL_MODE, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_PUSH_DOWN, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_LITERAL_LABEL, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FILL, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, UI_VALUE_HELP, UI_VALUE_HELP_COLUMN, UI_VALUE_HELP_DISTINCT, UI_VALUE_HELP_FILL, UI_VALUE_LABEL, WF_ACTION_WITH_DATA };
|
|
113
|
+
export { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_DERIVED, DB_COLUMN_PRECISION, DB_COLUMN_VERSION, DB_COLUMN_VERSION_TOKEN, DB_COMPUTE, DB_COMPUTE_HOST, DB_ENCRYPTED, DB_HTTP_PATH, DB_JSON, DB_REL_FK, DB_TABLE, DB_UNIT, DB_UNIT_REF, DB_VIEW, DB_VIEW_FOR, EXPECT_ARRAY_KEY, EXPECT_ARRAY_UNIQUE_ITEMS, EXPECT_MAX_LENGTH, EXPECT_MESSAGE, META_DEFAULT, META_DESCRIPTION, META_ID, META_LABEL, META_READONLY, META_REQUIRED, META_SENSITIVE, UI_DICT_ATTR, UI_DICT_DESCR, UI_DICT_FILTERABLE, UI_DICT_LABEL, UI_DICT_SEARCHABLE, UI_DICT_SORTABLE, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_ATTR, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HIDDEN, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_OPTIONS, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_NS, UI_FORM_OPTIONAL_MODE, UI_FORM_OPTIONS, UI_FORM_ORDER, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_PUSH_DOWN, UI_FORM_STYLES, UI_FORM_SUBMIT_TEXT, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_TYPE, UI_FORM_VALIDATE, UI_LITERAL_LABEL, UI_NAV_GROUP, UI_NAV_HIDDEN, UI_NAV_ORDER, UI_TABLE_ATTR, UI_TABLE_CLASSES, UI_TABLE_COMPONENT, UI_TABLE_EXCLUDE, UI_TABLE_FILL, UI_TABLE_FN_ATTR, UI_TABLE_FN_CLASSES, UI_TABLE_FN_PREFIX, UI_TABLE_FN_STYLES, UI_TABLE_ORDER, UI_TABLE_SELECT_WITH, UI_TABLE_STYLES, UI_TABLE_TYPE, UI_TABLE_WIDTH, UI_TYPE, UI_VALUE_HELP, UI_VALUE_HELP_COLUMN, UI_VALUE_HELP_DISTINCT, UI_VALUE_HELP_FILL, UI_VALUE_HELP_LABEL, UI_VALUE_LABEL, WF_ACTION_WITH_DATA };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_model_texts = require("../i18n/model-texts.cjs");
|
|
2
2
|
const require_ui_texts = require("../i18n/ui-texts.cjs");
|
|
3
3
|
const require_create_table_def = require("../table/create-table-def.cjs");
|
|
4
|
-
const require_value_help_client = require("../value-help/value-help-client.cjs");
|
|
5
4
|
const require_client_factory = require("../client-factory.cjs");
|
|
5
|
+
const require_texts = require("../value-help/texts.cjs");
|
|
6
6
|
let _atscript_db_client = require("@atscript/db-client");
|
|
7
7
|
//#region src/shared/meta-cache.ts
|
|
8
8
|
/**
|
|
@@ -231,8 +231,9 @@ function customStoreOf(client) {
|
|
|
231
231
|
* Drop every cached `/meta` — including the copy each cached `Client`
|
|
232
232
|
* memoizes and the `@atscript/db-client` meta stores used to revalidate it
|
|
233
233
|
* (the shared default one and any custom one a factory supplied) — the
|
|
234
|
-
* value-help searches shared under them,
|
|
235
|
-
*
|
|
234
|
+
* value-help searches shared under them, the texts of codes read from the
|
|
235
|
+
* dictionaries and the labels resolved for their bindings, and everything
|
|
236
|
+
* registered through {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
|
|
236
237
|
* handed out keep working; the next `getMetaEntry` refetches.
|
|
237
238
|
*/
|
|
238
239
|
function resetMetaCache() {
|
|
@@ -243,7 +244,7 @@ function resetMetaCache() {
|
|
|
243
244
|
(0, _atscript_db_client.clearMetaStore)();
|
|
244
245
|
for (const store of customStores.keys()) store.clear();
|
|
245
246
|
customStores.clear();
|
|
246
|
-
|
|
247
|
+
require_texts.resetValueHelpTexts();
|
|
247
248
|
for (const listener of resetListeners) listener();
|
|
248
249
|
}
|
|
249
250
|
/**
|
|
@@ -106,8 +106,9 @@ declare function getMetaTableDef(entry: MetaCacheEntry, texts?: Pick<UiTexts, "l
|
|
|
106
106
|
* Drop every cached `/meta` — including the copy each cached `Client`
|
|
107
107
|
* memoizes and the `@atscript/db-client` meta stores used to revalidate it
|
|
108
108
|
* (the shared default one and any custom one a factory supplied) — the
|
|
109
|
-
* value-help searches shared under them,
|
|
110
|
-
*
|
|
109
|
+
* value-help searches shared under them, the texts of codes read from the
|
|
110
|
+
* dictionaries and the labels resolved for their bindings, and everything
|
|
111
|
+
* registered through {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
|
|
111
112
|
* handed out keep working; the next `getMetaEntry` refetches.
|
|
112
113
|
*/
|
|
113
114
|
declare function resetMetaCache(): void;
|
|
@@ -106,8 +106,9 @@ declare function getMetaTableDef(entry: MetaCacheEntry, texts?: Pick<UiTexts, "l
|
|
|
106
106
|
* Drop every cached `/meta` — including the copy each cached `Client`
|
|
107
107
|
* memoizes and the `@atscript/db-client` meta stores used to revalidate it
|
|
108
108
|
* (the shared default one and any custom one a factory supplied) — the
|
|
109
|
-
* value-help searches shared under them,
|
|
110
|
-
*
|
|
109
|
+
* value-help searches shared under them, the texts of codes read from the
|
|
110
|
+
* dictionaries and the labels resolved for their bindings, and everything
|
|
111
|
+
* registered through {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
|
|
111
112
|
* handed out keep working; the next `getMetaEntry` refetches.
|
|
112
113
|
*/
|
|
113
114
|
declare function resetMetaCache(): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { deserializeServedType } from "../i18n/model-texts.mjs";
|
|
2
2
|
import { getUiTexts } from "../i18n/ui-texts.mjs";
|
|
3
3
|
import { createTableDef } from "../table/create-table-def.mjs";
|
|
4
|
-
import { invalidateValueHelpCache } from "../value-help/value-help-client.mjs";
|
|
5
4
|
import { getDefaultClientFactory } from "../client-factory.mjs";
|
|
5
|
+
import { resetValueHelpTexts } from "../value-help/texts.mjs";
|
|
6
6
|
import { clearMetaStore, defaultMetaStore } from "@atscript/db-client";
|
|
7
7
|
//#region src/shared/meta-cache.ts
|
|
8
8
|
/**
|
|
@@ -231,8 +231,9 @@ function customStoreOf(client) {
|
|
|
231
231
|
* Drop every cached `/meta` — including the copy each cached `Client`
|
|
232
232
|
* memoizes and the `@atscript/db-client` meta stores used to revalidate it
|
|
233
233
|
* (the shared default one and any custom one a factory supplied) — the
|
|
234
|
-
* value-help searches shared under them,
|
|
235
|
-
*
|
|
234
|
+
* value-help searches shared under them, the texts of codes read from the
|
|
235
|
+
* dictionaries and the labels resolved for their bindings, and everything
|
|
236
|
+
* registered through {@link onMetaCacheReset} (e.g. the table-presets cache). Entries already
|
|
236
237
|
* handed out keep working; the next `getMetaEntry` refetches.
|
|
237
238
|
*/
|
|
238
239
|
function resetMetaCache() {
|
|
@@ -243,7 +244,7 @@ function resetMetaCache() {
|
|
|
243
244
|
clearMetaStore();
|
|
244
245
|
for (const store of customStores.keys()) store.clear();
|
|
245
246
|
customStores.clear();
|
|
246
|
-
|
|
247
|
+
resetValueHelpTexts();
|
|
247
248
|
for (const listener of resetListeners) listener();
|
|
248
249
|
}
|
|
249
250
|
/**
|
|
@@ -11,18 +11,30 @@ function valueLabelOf(prop) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* The one rendering of a code with its text (
|
|
14
|
+
* The one rendering of a code with its text (since 0.1.190) — a sibling's
|
|
15
|
+
* (`@ui.valueLabel`) or a dictionary's (`valueHelpText`, since 0.1.207):
|
|
15
16
|
* `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
|
|
16
17
|
* alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
|
|
17
18
|
* key; an empty key yields `""` — a text without a code labels nothing.
|
|
18
19
|
*/
|
|
19
20
|
function arrangeText(key, text, arrangement = "textKey") {
|
|
20
21
|
if (key === "") return "";
|
|
21
|
-
const label =
|
|
22
|
+
const label = codeOf(text);
|
|
22
23
|
if (!label) return key;
|
|
23
24
|
if (arrangement === "text") return label;
|
|
24
25
|
return arrangement === "keyText" ? `${key} (${label})` : `${label} (${key})`;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A value as a code (since 0.1.207): a non-empty string, or a finite number
|
|
29
|
+
* written out; `undefined` for anything else. Only a code shows with a text
|
|
30
|
+
* (`displayValue`, `arrangeText`) or is looked up in a dictionary
|
|
31
|
+
* (`valueHelpText`).
|
|
32
|
+
*/
|
|
33
|
+
function codeOf(value) {
|
|
34
|
+
if (typeof value === "string") return value === "" ? void 0 : value;
|
|
35
|
+
return typeof value === "number" && Number.isFinite(value) ? String(value) : void 0;
|
|
36
|
+
}
|
|
26
37
|
//#endregion
|
|
27
38
|
exports.arrangeText = arrangeText;
|
|
39
|
+
exports.codeOf = codeOf;
|
|
28
40
|
exports.valueLabelOf = valueLabelOf;
|
|
@@ -2,24 +2,41 @@ import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
|
2
2
|
|
|
3
3
|
//#region src/shared/value-label.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* How
|
|
6
|
-
* `
|
|
5
|
+
* How a code shows with its text (since 0.1.190): `textKey` — `Berlin (BER)`,
|
|
6
|
+
* `keyText` — `BER (Berlin)`, `text` — `Berlin`.
|
|
7
7
|
*/
|
|
8
8
|
type ValueLabelArrangement = "textKey" | "keyText" | "text";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Where a code's text is, and how it shows: `@ui.valueLabel` of a field (the
|
|
11
|
+
* sibling holding the text, since 0.1.190), or the label of a dictionary
|
|
12
|
+
* (`ResolvedValueHelp.label`: a field of the dictionary, since 0.1.207).
|
|
13
|
+
*/
|
|
10
14
|
interface ValueLabel {
|
|
11
|
-
/** The
|
|
15
|
+
/** The field holding the text: a sibling's name, or a field of the dictionary. */
|
|
12
16
|
field: string;
|
|
13
17
|
arrangement: ValueLabelArrangement;
|
|
14
18
|
}
|
|
19
|
+
/** A code's text and the arrangement it shows in — what `arrangeText` renders. Since 0.1.207. */
|
|
20
|
+
interface ValueText {
|
|
21
|
+
text: string;
|
|
22
|
+
arrangement: ValueLabelArrangement;
|
|
23
|
+
}
|
|
15
24
|
/** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
|
|
16
25
|
declare function valueLabelOf(prop: TAtscriptAnnotatedType): ValueLabel | undefined;
|
|
17
26
|
/**
|
|
18
|
-
* The one rendering of a code with its text (
|
|
27
|
+
* The one rendering of a code with its text (since 0.1.190) — a sibling's
|
|
28
|
+
* (`@ui.valueLabel`) or a dictionary's (`valueHelpText`, since 0.1.207):
|
|
19
29
|
* `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
|
|
20
30
|
* alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
|
|
21
31
|
* key; an empty key yields `""` — a text without a code labels nothing.
|
|
22
32
|
*/
|
|
23
33
|
declare function arrangeText(key: string, text: unknown, arrangement?: ValueLabelArrangement): string;
|
|
34
|
+
/**
|
|
35
|
+
* A value as a code (since 0.1.207): a non-empty string, or a finite number
|
|
36
|
+
* written out; `undefined` for anything else. Only a code shows with a text
|
|
37
|
+
* (`displayValue`, `arrangeText`) or is looked up in a dictionary
|
|
38
|
+
* (`valueHelpText`).
|
|
39
|
+
*/
|
|
40
|
+
declare function codeOf(value: unknown): string | undefined;
|
|
24
41
|
//#endregion
|
|
25
|
-
export { ValueLabel, ValueLabelArrangement, arrangeText, valueLabelOf };
|
|
42
|
+
export { ValueLabel, ValueLabelArrangement, ValueText, arrangeText, codeOf, valueLabelOf };
|
|
@@ -2,24 +2,41 @@ import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
|
2
2
|
|
|
3
3
|
//#region src/shared/value-label.d.ts
|
|
4
4
|
/**
|
|
5
|
-
* How
|
|
6
|
-
* `
|
|
5
|
+
* How a code shows with its text (since 0.1.190): `textKey` — `Berlin (BER)`,
|
|
6
|
+
* `keyText` — `BER (Berlin)`, `text` — `Berlin`.
|
|
7
7
|
*/
|
|
8
8
|
type ValueLabelArrangement = "textKey" | "keyText" | "text";
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Where a code's text is, and how it shows: `@ui.valueLabel` of a field (the
|
|
11
|
+
* sibling holding the text, since 0.1.190), or the label of a dictionary
|
|
12
|
+
* (`ResolvedValueHelp.label`: a field of the dictionary, since 0.1.207).
|
|
13
|
+
*/
|
|
10
14
|
interface ValueLabel {
|
|
11
|
-
/** The
|
|
15
|
+
/** The field holding the text: a sibling's name, or a field of the dictionary. */
|
|
12
16
|
field: string;
|
|
13
17
|
arrangement: ValueLabelArrangement;
|
|
14
18
|
}
|
|
19
|
+
/** A code's text and the arrangement it shows in — what `arrangeText` renders. Since 0.1.207. */
|
|
20
|
+
interface ValueText {
|
|
21
|
+
text: string;
|
|
22
|
+
arrangement: ValueLabelArrangement;
|
|
23
|
+
}
|
|
15
24
|
/** The field's `@ui.valueLabel`, the arrangement defaulted to `textKey`; `undefined` without one. */
|
|
16
25
|
declare function valueLabelOf(prop: TAtscriptAnnotatedType): ValueLabel | undefined;
|
|
17
26
|
/**
|
|
18
|
-
* The one rendering of a code with its text (
|
|
27
|
+
* The one rendering of a code with its text (since 0.1.190) — a sibling's
|
|
28
|
+
* (`@ui.valueLabel`) or a dictionary's (`valueHelpText`, since 0.1.207):
|
|
19
29
|
* `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
|
|
20
30
|
* alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
|
|
21
31
|
* key; an empty key yields `""` — a text without a code labels nothing.
|
|
22
32
|
*/
|
|
23
33
|
declare function arrangeText(key: string, text: unknown, arrangement?: ValueLabelArrangement): string;
|
|
34
|
+
/**
|
|
35
|
+
* A value as a code (since 0.1.207): a non-empty string, or a finite number
|
|
36
|
+
* written out; `undefined` for anything else. Only a code shows with a text
|
|
37
|
+
* (`displayValue`, `arrangeText`) or is looked up in a dictionary
|
|
38
|
+
* (`valueHelpText`).
|
|
39
|
+
*/
|
|
40
|
+
declare function codeOf(value: unknown): string | undefined;
|
|
24
41
|
//#endregion
|
|
25
|
-
export { ValueLabel, ValueLabelArrangement, arrangeText, valueLabelOf };
|
|
42
|
+
export { ValueLabel, ValueLabelArrangement, ValueText, arrangeText, codeOf, valueLabelOf };
|
|
@@ -11,17 +11,28 @@ function valueLabelOf(prop) {
|
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* The one rendering of a code with its text (
|
|
14
|
+
* The one rendering of a code with its text (since 0.1.190) — a sibling's
|
|
15
|
+
* (`@ui.valueLabel`) or a dictionary's (`valueHelpText`, since 0.1.207):
|
|
15
16
|
* `textKey` (default) `text (key)`, `keyText` `key (text)`, `text` the text
|
|
16
17
|
* alone. An empty text (`undefined`, `null`, `""`, or no scalar) yields the
|
|
17
18
|
* key; an empty key yields `""` — a text without a code labels nothing.
|
|
18
19
|
*/
|
|
19
20
|
function arrangeText(key, text, arrangement = "textKey") {
|
|
20
21
|
if (key === "") return "";
|
|
21
|
-
const label =
|
|
22
|
+
const label = codeOf(text);
|
|
22
23
|
if (!label) return key;
|
|
23
24
|
if (arrangement === "text") return label;
|
|
24
25
|
return arrangement === "keyText" ? `${key} (${label})` : `${label} (${key})`;
|
|
25
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* A value as a code (since 0.1.207): a non-empty string, or a finite number
|
|
29
|
+
* written out; `undefined` for anything else. Only a code shows with a text
|
|
30
|
+
* (`displayValue`, `arrangeText`) or is looked up in a dictionary
|
|
31
|
+
* (`valueHelpText`).
|
|
32
|
+
*/
|
|
33
|
+
function codeOf(value) {
|
|
34
|
+
if (typeof value === "string") return value === "" ? void 0 : value;
|
|
35
|
+
return typeof value === "number" && Number.isFinite(value) ? String(value) : void 0;
|
|
36
|
+
}
|
|
26
37
|
//#endregion
|
|
27
|
-
export { arrangeText, valueLabelOf };
|
|
38
|
+
export { arrangeText, codeOf, valueLabelOf };
|
|
@@ -129,7 +129,12 @@ function identifierFieldsOf(preferredId, actions) {
|
|
|
129
129
|
}
|
|
130
130
|
return out ?? preferredId;
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* A field the caller may read: listed in `meta.fields` and not write-only —
|
|
134
|
+
* the one rule for a table's columns and a dictionary's label.
|
|
135
|
+
*
|
|
136
|
+
* @internal Shared with the value help.
|
|
137
|
+
*/
|
|
133
138
|
function isReadable(field) {
|
|
134
139
|
return field !== void 0 && field.writeOnly !== true;
|
|
135
140
|
}
|
|
@@ -248,3 +253,4 @@ function inferValueKind(prop) {
|
|
|
248
253
|
//#endregion
|
|
249
254
|
exports.createTableDef = createTableDef;
|
|
250
255
|
exports.inferValueKind = inferValueKind;
|
|
256
|
+
exports.isReadable = isReadable;
|
|
@@ -129,7 +129,12 @@ function identifierFieldsOf(preferredId, actions) {
|
|
|
129
129
|
}
|
|
130
130
|
return out ?? preferredId;
|
|
131
131
|
}
|
|
132
|
-
/**
|
|
132
|
+
/**
|
|
133
|
+
* A field the caller may read: listed in `meta.fields` and not write-only —
|
|
134
|
+
* the one rule for a table's columns and a dictionary's label.
|
|
135
|
+
*
|
|
136
|
+
* @internal Shared with the value help.
|
|
137
|
+
*/
|
|
133
138
|
function isReadable(field) {
|
|
134
139
|
return field !== void 0 && field.writeOnly !== true;
|
|
135
140
|
}
|
|
@@ -246,4 +251,4 @@ function inferValueKind(prop) {
|
|
|
246
251
|
return [...kinds][0];
|
|
247
252
|
}
|
|
248
253
|
//#endregion
|
|
249
|
-
export { createTableDef, inferValueKind };
|
|
254
|
+
export { createTableDef, inferValueKind, isReadable };
|
package/dist/table/types.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValueHelpInfo } from "../value-help/types.cjs";
|
|
2
1
|
import { ValueLabelArrangement } from "../shared/value-label.cjs";
|
|
2
|
+
import { ValueHelpInfo } from "../value-help/types.cjs";
|
|
3
3
|
import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
import { TCrudPermissions, TDbActionInfo } from "@atscript/db-client";
|
|
5
5
|
|
package/dist/table/types.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ValueHelpInfo } from "../value-help/types.mjs";
|
|
2
1
|
import { ValueLabelArrangement } from "../shared/value-label.mjs";
|
|
2
|
+
import { ValueHelpInfo } from "../value-help/types.mjs";
|
|
3
3
|
import { TAtscriptAnnotatedType, TSerializedAnnotatedType } from "@atscript/typescript/utils";
|
|
4
4
|
import { TCrudPermissions, TDbActionInfo } from "@atscript/db-client";
|
|
5
5
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
//#region src/value-help/client-store.ts
|
|
2
|
+
let stores = /* @__PURE__ */ new WeakMap();
|
|
3
|
+
/** Data drops of every client so far. */
|
|
4
|
+
let drops = 0;
|
|
5
|
+
/**
|
|
6
|
+
* The store of `client`, created on first use — and again after a data drop,
|
|
7
|
+
* keeping the texts of the store it replaces (one back) as `stale`.
|
|
8
|
+
*/
|
|
9
|
+
function clientStore(client) {
|
|
10
|
+
const prev = stores.get(client);
|
|
11
|
+
if (prev?.drop === drops) return prev;
|
|
12
|
+
for (const texts of prev?.texts.values() ?? []) texts.stale = void 0;
|
|
13
|
+
const store = {
|
|
14
|
+
client,
|
|
15
|
+
drop: drops,
|
|
16
|
+
searches: /* @__PURE__ */ new Map(),
|
|
17
|
+
texts: /* @__PURE__ */ new Map(),
|
|
18
|
+
stale: prev?.texts
|
|
19
|
+
};
|
|
20
|
+
stores.set(client, store);
|
|
21
|
+
return store;
|
|
22
|
+
}
|
|
23
|
+
/** The data of `client`, or of every client, changed: its store is replaced on its next use. */
|
|
24
|
+
function staleClientStores(client) {
|
|
25
|
+
if (!client) drops++;
|
|
26
|
+
else {
|
|
27
|
+
const store = stores.get(client);
|
|
28
|
+
if (store) store.drop = -1;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Drop every client's store, stale texts too (`resetMetaCache`: another viewer). */
|
|
32
|
+
function dropClientStores() {
|
|
33
|
+
stores = /* @__PURE__ */ new WeakMap();
|
|
34
|
+
}
|
|
35
|
+
/** A monotonic clock (ms) where there is one. */
|
|
36
|
+
function now() {
|
|
37
|
+
return typeof performance === "undefined" ? Date.now() : performance.now();
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
exports.clientStore = clientStore;
|
|
41
|
+
exports.dropClientStores = dropClientStores;
|
|
42
|
+
exports.now = now;
|
|
43
|
+
exports.staleClientStores = staleClientStores;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import { ClientLike } from "@atscript/db-client";
|