@gramlot/gramlot 0.3.10 → 0.3.16
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/components/editors/__init__.py +13 -0
- package/dist/components/{editors.js → editors/assets/collection.js} +131 -246
- package/dist/components/editors/assets/index.js +2 -0
- package/dist/components/editors/commands.json +7 -0
- package/dist/components/editors/grammar.json +7045 -0
- package/dist/components/inputs/__init__.py +13 -0
- package/dist/components/{inputs.js → inputs/assets/collection.js} +287 -198
- package/dist/components/inputs/assets/index.js +2 -0
- package/dist/components/inputs/commands.json +7 -0
- package/dist/components/inputs/grammar.json +42881 -0
- package/dist/components/layout/__init__.py +13 -0
- package/dist/components/layout/assets/collection.js +25737 -0
- package/dist/components/layout/assets/index.js +2 -0
- package/dist/components/layout/commands.json +7 -0
- package/dist/components/layout/grammar.json +1798 -0
- package/dist/components/tree/__init__.py +13 -0
- package/dist/components/{tree.js → tree/assets/collection.js} +62 -175
- package/dist/components/tree/assets/index.js +2 -0
- package/dist/components/tree/commands.json +7 -0
- package/dist/components/tree/grammar.json +339 -0
- package/dist/components/typst/__init__.py +13 -0
- package/dist/components/typst/assets/collection.js +4 -0
- package/dist/components/typst/assets/index.js +2 -0
- package/dist/components/typst/commands.json +7 -0
- package/dist/components/typst/grammar.json +81 -0
- package/dist/gramlot.js +2496 -905
- package/dist/gramlot.min.js +109 -28
- package/dist/runtime-notices.json +0 -196
- package/package.json +1 -1
- package/src/binding/ask-dialog.js +1 -1
- package/src/binding/installation.js +5 -6
- package/src/binding/runtime.js +4 -2
- package/src/bootstrap.d.ts +1 -1
- package/src/bootstrap.js +52 -30
- package/src/builder/binding.json +25 -0
- package/src/builder/gramlot-builder.js +16 -3
- package/src/builder/source.js +33 -1
- package/src/collection-artifact.d.ts +11 -0
- package/src/collection-artifact.js +57 -0
- package/src/commands.d.ts +9 -0
- package/src/commands.js +36 -0
- package/src/components/bases.js +1 -1
- package/src/components/border-container.js +26 -1
- package/src/components/buttons.js +84 -161
- package/src/components/choice-editor.js +31 -10
- package/src/components/database-choices.js +110 -0
- package/src/components/inputs.js +15 -2
- package/src/components/layout.js +5 -3
- package/src/components/menus.js +346 -0
- package/src/components/popup.js +15 -2
- package/src/components/registry.js +18 -3
- package/src/components/toolbar-overflow.js +181 -0
- package/src/components/tree.js +14 -4
- package/src/components/windows.js +284 -0
- package/src/filesystem.js +1 -0
- package/src/gramlot.d.ts +2 -0
- package/src/gramlot.js +4 -2
- package/src/handlers/rpc-handler.d.ts +6 -1
- package/src/handlers/rpc-handler.js +7 -2
- package/src/handlers/source-handler.d.ts +2 -1
- package/src/handlers/source-handler.js +10 -1
- package/src/ide-documents.js +1 -1
- package/src/ide-runtime.js +3 -2
- package/src/index-page-styles.js +1 -1
- package/src/index-theme.js +1 -1
- package/src/index.d.ts +5 -0
- package/src/index.js +5 -0
- package/src/renderer/gramlot-html-renderer.js +1 -0
- package/src/renderer/gramlot-renderer.js +13 -3
- package/src/server/gramlot-file-server.d.ts +2 -0
- package/src/server/gramlot-file-server.js +45 -1
- package/src/server/gramlot-server.d.ts +20 -2
- package/src/server/gramlot-server.js +86 -6
- package/src/server/page-base.js +1 -0
- package/src/server/page.d.ts +3 -0
- package/src/view/button.js +47 -3
- package/src/view/controls.js +8 -0
- package/src/view/html.js +1 -0
- package/src/view/menu-command.js +45 -0
- package/src/view/menu.js +87 -0
- package/themes/gramlot-compact/README.md +19 -0
- package/themes/gramlot-compact/theme.css +138 -45
- package/themes/joanna/README.md +19 -0
- package/themes/joanna/theme.css +134 -78
- package/themes/mela/theme.css +184 -0
- package/themes/mimi/README.md +19 -0
- package/themes/mimi/theme.css +133 -77
- package/themes/palettes/README.md +3 -0
- package/themes/palettes/compact.css +86 -0
- package/themes/palettes/joanna.css +86 -0
- package/themes/palettes/mimi.css +86 -0
- package/tools/gramlot-tools-inspector.js +3 -3
- package/dist/components/layout.js +0 -3385
- package/dist/components/typst.js +0 -4
|
@@ -23,6 +23,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
23
23
|
}
|
|
24
24
|
return to;
|
|
25
25
|
};
|
|
26
|
+
var __reExport = (target, mod2, secondTarget) => (__copyProps(target, mod2, "default"), secondTarget && __copyProps(secondTarget, mod2, "default"));
|
|
26
27
|
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
|
|
27
28
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
29
|
// file that has been converted to a CommonJS file using a Babel-
|
|
@@ -52,7 +53,7 @@ var require_conventions = __commonJS({
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function freeze(object, oc) {
|
|
56
57
|
if (oc === void 0) {
|
|
57
58
|
oc = Object;
|
|
58
59
|
}
|
|
@@ -75,7 +76,7 @@ var require_conventions = __commonJS({
|
|
|
75
76
|
}
|
|
76
77
|
return target;
|
|
77
78
|
}
|
|
78
|
-
var HTML_BOOLEAN_ATTRIBUTES =
|
|
79
|
+
var HTML_BOOLEAN_ATTRIBUTES = freeze({
|
|
79
80
|
allowfullscreen: true,
|
|
80
81
|
async: true,
|
|
81
82
|
autofocus: true,
|
|
@@ -104,7 +105,7 @@ var require_conventions = __commonJS({
|
|
|
104
105
|
function isHTMLBooleanAttribute(name) {
|
|
105
106
|
return hasOwn(HTML_BOOLEAN_ATTRIBUTES, name.toLowerCase());
|
|
106
107
|
}
|
|
107
|
-
var HTML_VOID_ELEMENTS =
|
|
108
|
+
var HTML_VOID_ELEMENTS = freeze({
|
|
108
109
|
area: true,
|
|
109
110
|
base: true,
|
|
110
111
|
br: true,
|
|
@@ -123,7 +124,7 @@ var require_conventions = __commonJS({
|
|
|
123
124
|
function isHTMLVoidElement(tagName) {
|
|
124
125
|
return hasOwn(HTML_VOID_ELEMENTS, tagName.toLowerCase());
|
|
125
126
|
}
|
|
126
|
-
var HTML_RAW_TEXT_ELEMENTS =
|
|
127
|
+
var HTML_RAW_TEXT_ELEMENTS = freeze({
|
|
127
128
|
script: false,
|
|
128
129
|
style: false,
|
|
129
130
|
textarea: true,
|
|
@@ -143,7 +144,7 @@ var require_conventions = __commonJS({
|
|
|
143
144
|
function hasDefaultHTMLNamespace(mimeType) {
|
|
144
145
|
return isHTMLMimeType(mimeType) || mimeType === MIME_TYPE.XML_XHTML_APPLICATION;
|
|
145
146
|
}
|
|
146
|
-
var MIME_TYPE =
|
|
147
|
+
var MIME_TYPE = freeze({
|
|
147
148
|
/**
|
|
148
149
|
* `text/html`, the only mime type that triggers treating an XML document as HTML.
|
|
149
150
|
*
|
|
@@ -196,7 +197,7 @@ var require_conventions = __commonJS({
|
|
|
196
197
|
function isValidMimeType(mimeType) {
|
|
197
198
|
return _MIME_TYPES.indexOf(mimeType) > -1;
|
|
198
199
|
}
|
|
199
|
-
var NAMESPACE =
|
|
200
|
+
var NAMESPACE = freeze({
|
|
200
201
|
/**
|
|
201
202
|
* The XHTML namespace.
|
|
202
203
|
*
|
|
@@ -224,7 +225,7 @@ var require_conventions = __commonJS({
|
|
|
224
225
|
});
|
|
225
226
|
exports.assign = assign;
|
|
226
227
|
exports.find = find;
|
|
227
|
-
exports.freeze =
|
|
228
|
+
exports.freeze = freeze;
|
|
228
229
|
exports.HTML_BOOLEAN_ATTRIBUTES = HTML_BOOLEAN_ATTRIBUTES;
|
|
229
230
|
exports.HTML_RAW_TEXT_ELEMENTS = HTML_RAW_TEXT_ELEMENTS;
|
|
230
231
|
exports.HTML_VOID_ELEMENTS = HTML_VOID_ELEMENTS;
|
|
@@ -887,12 +888,12 @@ var require_dom = __commonJS({
|
|
|
887
888
|
i++;
|
|
888
889
|
}
|
|
889
890
|
}
|
|
890
|
-
function _nnmBucket(map, namespaceURI,
|
|
891
|
+
function _nnmBucket(map, namespaceURI, create2) {
|
|
891
892
|
if (!namespaceURI) {
|
|
892
893
|
return map._noNsIndex;
|
|
893
894
|
}
|
|
894
895
|
var bucket = map._nsIndex[namespaceURI];
|
|
895
|
-
if (!bucket &&
|
|
896
|
+
if (!bucket && create2) {
|
|
896
897
|
bucket = map._nsIndex[namespaceURI] = /* @__PURE__ */ Object.create(null);
|
|
897
898
|
}
|
|
898
899
|
return bucket;
|
|
@@ -3278,15 +3279,15 @@ var require_dom = __commonJS({
|
|
|
3278
3279
|
var require_entities = __commonJS({
|
|
3279
3280
|
"node_modules/@xmldom/xmldom/lib/entities.js"(exports) {
|
|
3280
3281
|
"use strict";
|
|
3281
|
-
var
|
|
3282
|
-
exports.XML_ENTITIES =
|
|
3282
|
+
var freeze = require_conventions().freeze;
|
|
3283
|
+
exports.XML_ENTITIES = freeze({
|
|
3283
3284
|
amp: "&",
|
|
3284
3285
|
apos: "'",
|
|
3285
3286
|
gt: ">",
|
|
3286
3287
|
lt: "<",
|
|
3287
3288
|
quot: '"'
|
|
3288
3289
|
});
|
|
3289
|
-
exports.HTML_ENTITIES =
|
|
3290
|
+
exports.HTML_ENTITIES = freeze({
|
|
3290
3291
|
Aacute: "\xC1",
|
|
3291
3292
|
aacute: "\xE1",
|
|
3292
3293
|
Abreve: "\u0102",
|
|
@@ -6511,151 +6512,22 @@ var require_lib = __commonJS({
|
|
|
6511
6512
|
}
|
|
6512
6513
|
});
|
|
6513
6514
|
|
|
6514
|
-
//
|
|
6515
|
-
var
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
"font-face-format",
|
|
6523
|
-
"font-face-name",
|
|
6524
|
-
"missing-glyph"
|
|
6525
|
-
]);
|
|
6526
|
-
function webcomponentCode(attrs) {
|
|
6527
|
-
const code = attrs.code;
|
|
6528
|
-
if (typeof code !== "string" || NAME.exec(code)?.[0] !== code || !code.includes("-") || RESERVED.has(code)) {
|
|
6529
|
-
throw new TypeError("webcomponent: code must be a literal custom-element name");
|
|
6530
|
-
}
|
|
6531
|
-
return code;
|
|
6532
|
-
}
|
|
6533
|
-
|
|
6534
|
-
// src/components/registry.js
|
|
6535
|
-
function freeze(value) {
|
|
6536
|
-
for (const child of Object.values(value)) if (child && typeof child === "object") freeze(child);
|
|
6537
|
-
return Object.freeze(value);
|
|
6538
|
-
}
|
|
6539
|
-
function annotation(parameter) {
|
|
6540
|
-
if (typeof parameter.dtype !== "string" && !Array.isArray(parameter.dtype)) throw new TypeError("Component parameter requires dtype");
|
|
6541
|
-
const alternatives = (Array.isArray(parameter.dtype) ? parameter.dtype : [parameter.dtype]).map((dtype) => ({ kind: "dtype", dtype }));
|
|
6542
|
-
if (parameter.nullable) alternatives.push({ kind: "dtype", dtype: "NN" });
|
|
6543
|
-
if (parameter.binding && parameter.dtype !== "T") alternatives.push({
|
|
6544
|
-
kind: "annotated",
|
|
6545
|
-
base: { kind: "dtype", dtype: "T" },
|
|
6546
|
-
metadata: [{ kind: "regex", pattern: "^[\\^=].+", flags: 0 }]
|
|
6547
|
-
});
|
|
6548
|
-
return alternatives.length === 1 ? alternatives[0] : { kind: "union", items: alternatives };
|
|
6549
|
-
}
|
|
6550
|
-
function defineComponent({ name, tag: tag2, base, mixins = [], parameters: parameters2 = {}, subTags = "", presentationDefaults = [], dataScope = false, command = false, childParameters = {}, sourceContext = false, bagStore = false, dragSource = false, implementation }) {
|
|
6551
|
-
webcomponentCode({ code: tag2 });
|
|
6552
|
-
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(name)) throw new TypeError("Invalid component authoring name");
|
|
6553
|
-
const effective = { ...base.parameters };
|
|
6554
|
-
for (const mixin of mixins) {
|
|
6555
|
-
for (const [key, spec] of Object.entries(mixin.parameters)) {
|
|
6556
|
-
if (Object.hasOwn(effective, key)) throw new Error(`Duplicate mixin parameter: ${key}`);
|
|
6557
|
-
effective[key] = spec;
|
|
6558
|
-
}
|
|
6559
|
-
}
|
|
6560
|
-
Object.assign(effective, parameters2);
|
|
6561
|
-
for (const spec of Object.values(effective)) annotation(spec);
|
|
6562
|
-
return Object.freeze({
|
|
6563
|
-
name,
|
|
6564
|
-
tag: tag2,
|
|
6565
|
-
base,
|
|
6566
|
-
subTags,
|
|
6567
|
-
presentationDefaults: Object.freeze([...presentationDefaults]),
|
|
6568
|
-
dataScope,
|
|
6569
|
-
command,
|
|
6570
|
-
bagStore,
|
|
6571
|
-
mixins: Object.freeze([...mixins]),
|
|
6572
|
-
parameters: freeze(structuredClone(effective)),
|
|
6573
|
-
childParameters: freeze(structuredClone(childParameters)),
|
|
6574
|
-
sourceContext,
|
|
6575
|
-
dragSource,
|
|
6576
|
-
implementation
|
|
6577
|
-
});
|
|
6578
|
-
}
|
|
6579
|
-
var ComponentCollection = class {
|
|
6580
|
-
#classes = /* @__PURE__ */ new WeakMap();
|
|
6581
|
-
constructor({ name, components }) {
|
|
6582
|
-
this.name = name;
|
|
6583
|
-
this.components = Object.freeze([...components]);
|
|
6584
|
-
const names = /* @__PURE__ */ new Set(), tags = /* @__PURE__ */ new Set();
|
|
6585
|
-
for (const component of components) {
|
|
6586
|
-
if (names.has(component.name.toLowerCase()) || tags.has(component.tag)) {
|
|
6587
|
-
throw new Error(`Duplicate component: ${component.name}`);
|
|
6588
|
-
}
|
|
6589
|
-
names.add(component.name.toLowerCase());
|
|
6590
|
-
tags.add(component.tag);
|
|
6591
|
-
}
|
|
6592
|
-
}
|
|
6593
|
-
/** Same JSON consumed by Python and JavaScript Builders. */
|
|
6594
|
-
toDocument() {
|
|
6595
|
-
return {
|
|
6596
|
-
document_format: { name: "builder_grammar", version: "1.1" },
|
|
6597
|
-
grammar: { name: this.name, version: null, title: this.name, description: null },
|
|
6598
|
-
abstracts: {},
|
|
6599
|
-
elements: Object.fromEntries(this.components.map((component) => [component.name, {
|
|
6600
|
-
doc: null,
|
|
6601
|
-
sub_tags: component.subTags,
|
|
6602
|
-
parent_tags: null,
|
|
6603
|
-
inherits_from: null,
|
|
6604
|
-
ns: null,
|
|
6605
|
-
node_label: null,
|
|
6606
|
-
collection_key: null,
|
|
6607
|
-
attributes: {
|
|
6608
|
-
parameters: [
|
|
6609
|
-
...Object.entries(component.parameters).map(([name, spec]) => ({
|
|
6610
|
-
name,
|
|
6611
|
-
kind: "keyword_only",
|
|
6612
|
-
role: "attribute",
|
|
6613
|
-
annotation: annotation(spec),
|
|
6614
|
-
has_default: true,
|
|
6615
|
-
default: spec.default ?? null
|
|
6616
|
-
})),
|
|
6617
|
-
{
|
|
6618
|
-
name: "attr",
|
|
6619
|
-
kind: "var_keyword",
|
|
6620
|
-
role: "attribute",
|
|
6621
|
-
annotation: { kind: "any" },
|
|
6622
|
-
has_default: false
|
|
6623
|
-
}
|
|
6624
|
-
],
|
|
6625
|
-
accepts_var_keyword: true,
|
|
6626
|
-
accepts_var_positional: false
|
|
6627
|
-
},
|
|
6628
|
-
_meta: { render_tag: component.tag, gramlot_component: {
|
|
6629
|
-
parameters: structuredClone(component.parameters),
|
|
6630
|
-
presentationDefaults: [...component.presentationDefaults],
|
|
6631
|
-
dataScope: component.dataScope,
|
|
6632
|
-
command: component.command,
|
|
6633
|
-
...Object.keys(component.childParameters).length ? { childParameters: structuredClone(component.childParameters) } : {},
|
|
6634
|
-
...component.sourceContext ? { sourceContext: true } : {},
|
|
6635
|
-
...component.dragSource ? { dragSource: true } : {},
|
|
6636
|
-
...component.bagStore ? { bagStore: true } : {}
|
|
6637
|
-
} }
|
|
6638
|
-
}]))
|
|
6639
|
-
};
|
|
6640
|
-
}
|
|
6641
|
-
/** Register once per document realm, only when the collection is activated. */
|
|
6642
|
-
register(window2) {
|
|
6643
|
-
if (this.#classes.has(window2)) return;
|
|
6644
|
-
const classes2 = [];
|
|
6645
|
-
for (const component of this.components) {
|
|
6646
|
-
if (window2.customElements.get(component.tag)) throw new Error(`Custom element already registered: ${component.tag}`);
|
|
6647
|
-
let Base = component.base(window2.HTMLElement);
|
|
6648
|
-
for (const mixin of component.mixins) Base = mixin(Base);
|
|
6649
|
-
const Class = component.implementation(Base);
|
|
6650
|
-
Object.defineProperty(Class, "gramlotComponent", { value: component });
|
|
6651
|
-
classes2.push([component.tag, Class]);
|
|
6652
|
-
}
|
|
6653
|
-
for (const [tag2, Class] of classes2) window2.customElements.define(tag2, Class);
|
|
6654
|
-
this.#classes.set(window2, classes2);
|
|
6655
|
-
}
|
|
6656
|
-
};
|
|
6515
|
+
// collection-authoring:@gramlot/gramlot/components
|
|
6516
|
+
var components_exports = {};
|
|
6517
|
+
__export(components_exports, {
|
|
6518
|
+
defineCollection: () => defineCollection
|
|
6519
|
+
});
|
|
6520
|
+
__reExport(components_exports, components_star);
|
|
6521
|
+
import * as components_star from "@gramlot/gramlot/components";
|
|
6522
|
+
import { defineCollection as create } from "@gramlot/gramlot/components";
|
|
6657
6523
|
function defineCollection(options) {
|
|
6658
|
-
|
|
6524
|
+
if (options.name !== "inputs") throw new Error("Unexpected bundled collection");
|
|
6525
|
+
const css = [], assets = {};
|
|
6526
|
+
options.css?.forEach((url, index) => {
|
|
6527
|
+
url.href = css[index].href;
|
|
6528
|
+
});
|
|
6529
|
+
for (const [key, url] of Object.entries(options.assets ?? {})) url.href = assets[key].href;
|
|
6530
|
+
return create({ ...options, css, assets });
|
|
6659
6531
|
}
|
|
6660
6532
|
|
|
6661
6533
|
// src/components/parameters.js
|
|
@@ -6689,7 +6561,7 @@ function controlElement(HTMLElement) {
|
|
|
6689
6561
|
style.textContent = `:host{display:inline-block;font:inherit} *,*::before,*::after{box-sizing:border-box}
|
|
6690
6562
|
input,textarea{font:inherit;max-width:100%} .control-box{min-width:0;color:var(--gramlot-ink,CanvasText)}
|
|
6691
6563
|
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea{
|
|
6692
|
-
appearance:none;box-sizing:border-box;border:1px solid var(--gramlot-border-control,#7a8798);
|
|
6564
|
+
appearance:none;box-sizing:border-box;width:100%;border:1px solid var(--gramlot-border-control,#7a8798);
|
|
6693
6565
|
border-radius:var(--gramlot-radius-sm,4px);background:var(--gramlot-field-background,Canvas);color:var(--gramlot-ink,CanvasText);
|
|
6694
6566
|
min-height:var(--gramlot-field-height,28px);padding:var(--gramlot-field-padding,.25em .5em);font-size:var(--gramlot-field-font-size,1em);line-height:var(--gramlot-field-line-height,inherit)}
|
|
6695
6567
|
input:read-only:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),textarea:read-only{
|
|
@@ -9991,11 +9863,11 @@ var MAX_POWER = 1e6;
|
|
|
9991
9863
|
var NE = -7;
|
|
9992
9864
|
var PE = 21;
|
|
9993
9865
|
var STRICT = false;
|
|
9994
|
-
var
|
|
9995
|
-
var INVALID =
|
|
9866
|
+
var NAME = "[big.js] ";
|
|
9867
|
+
var INVALID = NAME + "Invalid ";
|
|
9996
9868
|
var INVALID_DP = INVALID + "decimal places";
|
|
9997
9869
|
var INVALID_RM = INVALID + "rounding mode";
|
|
9998
|
-
var DIV_BY_ZERO =
|
|
9870
|
+
var DIV_BY_ZERO = NAME + "Division by zero";
|
|
9999
9871
|
var P2 = {};
|
|
10000
9872
|
var UNDEFINED = void 0;
|
|
10001
9873
|
var NUMERIC = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;
|
|
@@ -10361,7 +10233,7 @@ P2.sqrt = function() {
|
|
|
10361
10233
|
var r, c, t, x = this, Big2 = x.constructor, s = x.s, e = x.e, half = new Big2("0.5");
|
|
10362
10234
|
if (!x.c[0]) return new Big2(x);
|
|
10363
10235
|
if (s < 0) {
|
|
10364
|
-
throw Error(
|
|
10236
|
+
throw Error(NAME + "No square root");
|
|
10365
10237
|
}
|
|
10366
10238
|
s = Math.sqrt(+stringify(x, true, true));
|
|
10367
10239
|
if (s === 0 || s === 1 / 0) {
|
|
@@ -10441,7 +10313,7 @@ P2[/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")] = P2.toJSON = P2.to
|
|
|
10441
10313
|
P2.toNumber = function() {
|
|
10442
10314
|
var n = +stringify(this, true, true);
|
|
10443
10315
|
if (this.constructor.strict === true && !this.eq(n.toString())) {
|
|
10444
|
-
throw Error(
|
|
10316
|
+
throw Error(NAME + "Imprecise conversion");
|
|
10445
10317
|
}
|
|
10446
10318
|
return n;
|
|
10447
10319
|
};
|
|
@@ -10459,7 +10331,7 @@ P2.toPrecision = function(sd, rm) {
|
|
|
10459
10331
|
P2.valueOf = function() {
|
|
10460
10332
|
var x = this, Big2 = x.constructor;
|
|
10461
10333
|
if (Big2.strict === true) {
|
|
10462
|
-
throw Error(
|
|
10334
|
+
throw Error(NAME + "valueOf disallowed");
|
|
10463
10335
|
}
|
|
10464
10336
|
return stringify(x, x.e <= Big2.NE || x.e >= Big2.PE, true);
|
|
10465
10337
|
};
|
|
@@ -16795,7 +16667,7 @@ function pythonRegexPattern(pattern, flags) {
|
|
|
16795
16667
|
}
|
|
16796
16668
|
return result;
|
|
16797
16669
|
}
|
|
16798
|
-
function
|
|
16670
|
+
function annotation(desc, path, nested = false, customTypes = null) {
|
|
16799
16671
|
if (desc === null) return null;
|
|
16800
16672
|
exactKeys(desc, ["kind", "dtype", "module", "name", "origin", "arguments", "items", "values", "base", "metadata", "pattern", "flags", "ge", "le", "gt", "lt", "value"], ["kind"], path);
|
|
16801
16673
|
switch (desc.kind) {
|
|
@@ -16834,7 +16706,7 @@ function annotation2(desc, path, nested = false, customTypes = null) {
|
|
|
16834
16706
|
}
|
|
16835
16707
|
case "union": {
|
|
16836
16708
|
if (!Array.isArray(desc.items) || !desc.items.length) fail2(path, "union items must be non-empty");
|
|
16837
|
-
const items = desc.items.map((v, i) =>
|
|
16709
|
+
const items = desc.items.map((v, i) => annotation(v, `${path}.items[${i}]`, true, customTypes));
|
|
16838
16710
|
return { ...desc, items, inputConstraint: items.some((x) => x.inputConstraint), test: (v) => items.some((x) => x.test && x.test(v)) };
|
|
16839
16711
|
}
|
|
16840
16712
|
case "literal":
|
|
@@ -16844,8 +16716,8 @@ function annotation2(desc, path, nested = false, customTypes = null) {
|
|
|
16844
16716
|
case "annotated": {
|
|
16845
16717
|
if (!Array.isArray(desc.metadata)) fail2(path, "annotated metadata must be an array");
|
|
16846
16718
|
if (desc.metadata.some((v) => !["regex", "range", "value"].includes(v?.kind))) fail2(path, "unsupported annotation metadata kind");
|
|
16847
|
-
const base =
|
|
16848
|
-
const metadata = desc.metadata.map((v, i) =>
|
|
16719
|
+
const base = annotation(desc.base, `${path}.base`, true, customTypes);
|
|
16720
|
+
const metadata = desc.metadata.map((v, i) => annotation(v, `${path}.metadata[${i}]`, true, customTypes));
|
|
16849
16721
|
return { ...desc, base, metadata, inputConstraint: base.inputConstraint, test: (v) => base.test(v) && metadata.every((x) => !x.test || x.test(v)) };
|
|
16850
16722
|
}
|
|
16851
16723
|
case "range": {
|
|
@@ -16877,12 +16749,12 @@ function annotation2(desc, path, nested = false, customTypes = null) {
|
|
|
16877
16749
|
jsonValue(desc.value, `${path}.value`);
|
|
16878
16750
|
return { ...desc };
|
|
16879
16751
|
case "generic": {
|
|
16880
|
-
const origin =
|
|
16752
|
+
const origin = annotation(desc.origin, `${path}.origin`, true, customTypes);
|
|
16881
16753
|
if (desc.origin?.kind !== "type" || desc.origin.module !== "builtins" || !["list", "dict", "tuple", "set"].includes(desc.origin.name)) {
|
|
16882
16754
|
fail2(path, "only list, dict, tuple and set generic origins are supported");
|
|
16883
16755
|
}
|
|
16884
16756
|
if (!Array.isArray(desc.arguments)) fail2(path, "generic arguments must be an array");
|
|
16885
|
-
const args = desc.arguments.map((v, i) =>
|
|
16757
|
+
const args = desc.arguments.map((v, i) => annotation(v, `${path}.arguments[${i}]`, true, customTypes));
|
|
16886
16758
|
return { ...desc, origin, arguments: args, inputConstraint: args.some((x) => x.inputConstraint), test: (v) => origin.test(v) && genericItems(desc.origin, args, v) };
|
|
16887
16759
|
}
|
|
16888
16760
|
case "arguments":
|
|
@@ -16967,7 +16839,7 @@ function parameters(value, path, customTypes) {
|
|
|
16967
16839
|
if (p.has_default) jsonValue(p.default, `${pp}.default`);
|
|
16968
16840
|
foundVarKeyword ||= p.kind === "var_keyword";
|
|
16969
16841
|
foundVarPositional ||= p.kind === "var_positional";
|
|
16970
|
-
return { ...p, annotation:
|
|
16842
|
+
return { ...p, annotation: annotation(p.annotation, `${pp}.annotation`, false, customTypes) };
|
|
16971
16843
|
});
|
|
16972
16844
|
if (foundVarKeyword !== value.accepts_var_keyword || foundVarPositional !== value.accepts_var_positional) {
|
|
16973
16845
|
fail2(path, "variadic summary flags do not match parameters");
|
|
@@ -17109,7 +16981,7 @@ var CustomTypes = class _CustomTypes {
|
|
|
17109
16981
|
}
|
|
17110
16982
|
jsonValue(definition, `custom_types.${name}`);
|
|
17111
16983
|
const copy = structuredClone(definition);
|
|
17112
|
-
const compiled =
|
|
16984
|
+
const compiled = annotation(copy, `custom_types.${name}`);
|
|
17113
16985
|
const reference = Object.freeze({ kind: "custom", name });
|
|
17114
16986
|
Object.defineProperty(this, name, { value: reference, enumerable: true });
|
|
17115
16987
|
this.#definitions.set(name, copy);
|
|
@@ -23128,14 +23000,26 @@ var SVG_NS = "http://www.w3.org/2000/svg";
|
|
|
23128
23000
|
// src/components/popup.js
|
|
23129
23001
|
var VIEWPORT_MARGIN = 8;
|
|
23130
23002
|
var ANCHOR_GAP = 3;
|
|
23131
|
-
function positionPopup(popup, anchor, { align = "start", matchWidth = false, inset = 0 } = {}) {
|
|
23003
|
+
function positionPopup(popup, anchor, { align = "start", matchWidth = false, inset = 0, placement = "bottom", point = null } = {}) {
|
|
23132
23004
|
const view = anchor.ownerDocument.defaultView;
|
|
23133
|
-
const field = anchor.getBoundingClientRect();
|
|
23005
|
+
const field = point ? { left: point.x, right: point.x, top: point.y, bottom: point.y, width: 0 } : anchor.getBoundingClientRect();
|
|
23134
23006
|
const availableWidth = Math.max(0, view.innerWidth - 2 * VIEWPORT_MARGIN);
|
|
23135
23007
|
popup.style.setProperty("--gramlot-popup-available-width", `${availableWidth}px`);
|
|
23136
23008
|
if (matchWidth) popup.style.width = `${Math.min(Math.max(0, field.width - 2 * inset), availableWidth)}px`;
|
|
23137
23009
|
popup.style.removeProperty("--gramlot-popup-available-height");
|
|
23138
23010
|
const natural = popup.getBoundingClientRect();
|
|
23011
|
+
if (placement === "side") {
|
|
23012
|
+
const right = Math.max(0, view.innerWidth - VIEWPORT_MARGIN - field.right - ANCHOR_GAP);
|
|
23013
|
+
const left2 = Math.max(0, field.left - VIEWPORT_MARGIN - ANCHOR_GAP);
|
|
23014
|
+
const opensLeft = natural.width > right && left2 > right;
|
|
23015
|
+
popup.style.setProperty("--gramlot-popup-available-width", `${opensLeft ? left2 : right}px`);
|
|
23016
|
+
popup.style.setProperty("--gramlot-popup-available-height", `${Math.max(0, view.innerHeight - 2 * VIEWPORT_MARGIN)}px`);
|
|
23017
|
+
const size2 = popup.getBoundingClientRect();
|
|
23018
|
+
const x = opensLeft ? field.left - size2.width - ANCHOR_GAP : field.right + ANCHOR_GAP;
|
|
23019
|
+
popup.style.left = `${Math.max(VIEWPORT_MARGIN, Math.min(x, view.innerWidth - size2.width - VIEWPORT_MARGIN))}px`;
|
|
23020
|
+
popup.style.top = `${Math.max(VIEWPORT_MARGIN, Math.min(field.top, view.innerHeight - size2.height - VIEWPORT_MARGIN))}px`;
|
|
23021
|
+
return;
|
|
23022
|
+
}
|
|
23139
23023
|
const below = Math.max(0, view.innerHeight - VIEWPORT_MARGIN - field.bottom - ANCHOR_GAP);
|
|
23140
23024
|
const above = Math.max(0, field.top - VIEWPORT_MARGIN - ANCHOR_GAP);
|
|
23141
23025
|
const upwards = natural.height > below && above > below;
|
|
@@ -23866,6 +23750,8 @@ function ChoiceEditor(HTMLElement) {
|
|
|
23866
23750
|
#source;
|
|
23867
23751
|
#separator;
|
|
23868
23752
|
#cleanup;
|
|
23753
|
+
#requestController;
|
|
23754
|
+
#searchTimer;
|
|
23869
23755
|
constructor() {
|
|
23870
23756
|
super();
|
|
23871
23757
|
const doc = this.ownerDocument;
|
|
@@ -23876,6 +23762,7 @@ function ChoiceEditor(HTMLElement) {
|
|
|
23876
23762
|
.choices{max-width:var(--gramlot-popup-available-width,100vw);position:fixed;inset:auto;margin:0;padding:var(--gramlot-popup-padding,4px);box-sizing:border-box;max-height:min(var(--gramlot-choice-max-height,12rem),var(--gramlot-popup-available-height,100vh));overflow:auto;
|
|
23877
23763
|
border:1px solid var(--gramlot-border-control,#aab4c2);border-radius:var(--gramlot-radius-sm,4px);background:var(--gramlot-surface,Canvas);color:var(--gramlot-ink,CanvasText);font:inherit;box-shadow:var(--gramlot-shadow,0 3px 9px #0002)}
|
|
23878
23764
|
.choices[hidden]{display:none} .choice{min-height:var(--gramlot-touch-target,0px);display:flex;align-items:center;padding:.25em .5em;cursor:pointer}
|
|
23765
|
+
.choice-detail{margin-inline-start:var(--gramlot-space-3,.75rem);color:var(--gramlot-text-secondary,GrayText)}
|
|
23879
23766
|
.choice[aria-selected=true]{background:var(--gramlot-selected,Highlight);color:var(--gramlot-ink,HighlightText)}`;
|
|
23880
23767
|
this.toggle = doc.createElement("button");
|
|
23881
23768
|
this.toggle.className = "toggle";
|
|
@@ -23902,9 +23789,9 @@ function ChoiceEditor(HTMLElement) {
|
|
|
23902
23789
|
this.control.addEventListener("input", (event) => {
|
|
23903
23790
|
this.#dirty = true;
|
|
23904
23791
|
this.#picked = null;
|
|
23905
|
-
if (!event.isComposing) this.
|
|
23792
|
+
if (!event.isComposing) this.scheduleSearch(this.control.value);
|
|
23906
23793
|
});
|
|
23907
|
-
this.control.addEventListener("compositionend", () => this.
|
|
23794
|
+
this.control.addEventListener("compositionend", () => this.scheduleSearch(this.control.value));
|
|
23908
23795
|
this.control.addEventListener("keydown", (event) => {
|
|
23909
23796
|
if (event.isComposing || this.locked) return;
|
|
23910
23797
|
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
@@ -23940,6 +23827,30 @@ function ChoiceEditor(HTMLElement) {
|
|
|
23940
23827
|
get constrained() {
|
|
23941
23828
|
return true;
|
|
23942
23829
|
}
|
|
23830
|
+
get choiceSource() {
|
|
23831
|
+
return this.parameters.store ?? this.parameters.callback ?? this.parameters.values;
|
|
23832
|
+
}
|
|
23833
|
+
get searchDelay() {
|
|
23834
|
+
return 0;
|
|
23835
|
+
}
|
|
23836
|
+
textValue(text2) {
|
|
23837
|
+
return text2;
|
|
23838
|
+
}
|
|
23839
|
+
selectionAccepted(row) {
|
|
23840
|
+
}
|
|
23841
|
+
selectionResolved(row) {
|
|
23842
|
+
}
|
|
23843
|
+
renderChoice(row, item) {
|
|
23844
|
+
item.textContent = row.caption;
|
|
23845
|
+
}
|
|
23846
|
+
scheduleSearch(query) {
|
|
23847
|
+
this.closeChoices();
|
|
23848
|
+
if (!this.searchDelay) return this.search(query);
|
|
23849
|
+
this.#searchTimer = setTimeout(() => {
|
|
23850
|
+
this.#searchTimer = null;
|
|
23851
|
+
this.search(query);
|
|
23852
|
+
}, this.searchDelay);
|
|
23853
|
+
}
|
|
23943
23854
|
get commitOnChange() {
|
|
23944
23855
|
return this.constrained;
|
|
23945
23856
|
}
|
|
@@ -23951,11 +23862,15 @@ function ChoiceEditor(HTMLElement) {
|
|
|
23951
23862
|
}
|
|
23952
23863
|
projectAttributes(attrs, adapt) {
|
|
23953
23864
|
const rest = super.projectAttributes(attrs, adapt);
|
|
23954
|
-
const source = this.
|
|
23865
|
+
const source = this.choiceSource;
|
|
23955
23866
|
const changed = source !== this.#source || this.parameters.separator !== this.#separator;
|
|
23956
23867
|
this.#separator = this.parameters.separator;
|
|
23957
23868
|
this.#source = source;
|
|
23958
23869
|
this.toggle.disabled = this.locked;
|
|
23870
|
+
if (changed) {
|
|
23871
|
+
this.#rows = [];
|
|
23872
|
+
this.#picked = null;
|
|
23873
|
+
}
|
|
23959
23874
|
if (changed || this.locked) this.closeChoices();
|
|
23960
23875
|
if (changed && this.active && !this.#dirty) this.resolveValue();
|
|
23961
23876
|
return rest;
|
|
@@ -23991,13 +23906,14 @@ function ChoiceEditor(HTMLElement) {
|
|
|
23991
23906
|
this.error("Choose a value from the list.");
|
|
23992
23907
|
return { ok: false };
|
|
23993
23908
|
}
|
|
23994
|
-
const value = this.constrained ? text2 === "" ? null : matches[0].id : text2;
|
|
23909
|
+
const value = this.constrained ? text2 === "" ? null : matches[0].id : this.textValue(text2);
|
|
23995
23910
|
return this.validateCandidate(value, (accepted) => {
|
|
23996
23911
|
if (accepted !== value && this.constrained) throw new Error("Validation cannot replace a selected code; update the Data explicitly.");
|
|
23997
23912
|
this.#value = accepted;
|
|
23998
23913
|
this.#dirty = false;
|
|
23999
23914
|
this.#picked = null;
|
|
24000
23915
|
if (!this.constrained) this.control.value = accepted ?? "";
|
|
23916
|
+
this.selectionAccepted(matches.length === 1 && accepted === value ? matches[0] : null);
|
|
24001
23917
|
});
|
|
24002
23918
|
}
|
|
24003
23919
|
commitDraft() {
|
|
@@ -24013,30 +23929,38 @@ function ChoiceEditor(HTMLElement) {
|
|
|
24013
23929
|
this.commitDraft();
|
|
24014
23930
|
}
|
|
24015
23931
|
async request(keywords) {
|
|
23932
|
+
this.#requestController?.abort();
|
|
23933
|
+
const controller = new AbortController();
|
|
23934
|
+
this.#requestController = controller;
|
|
24016
23935
|
const generation = ++this.#generation;
|
|
24017
23936
|
this.control.setAttribute("aria-busy", "true");
|
|
24018
23937
|
this.error("");
|
|
24019
23938
|
try {
|
|
24020
|
-
const rows = await this.loadChoices(keywords);
|
|
23939
|
+
const rows = await this.loadChoices(keywords, controller.signal);
|
|
24021
23940
|
if (generation !== this.#generation || !this.active) return null;
|
|
24022
23941
|
return rows;
|
|
24023
23942
|
} catch (error) {
|
|
24024
23943
|
if (generation === this.#generation && this.active) this.error(error.message);
|
|
24025
23944
|
return null;
|
|
24026
23945
|
} finally {
|
|
24027
|
-
if (generation === this.#generation)
|
|
23946
|
+
if (generation === this.#generation) {
|
|
23947
|
+
this.#requestController = null;
|
|
23948
|
+
this.control.setAttribute("aria-busy", "false");
|
|
23949
|
+
}
|
|
24028
23950
|
}
|
|
24029
23951
|
}
|
|
24030
23952
|
async resolveValue() {
|
|
24031
23953
|
if (this.#value == null || this.#value === "") {
|
|
24032
23954
|
this.control.value = "";
|
|
24033
23955
|
this.error("");
|
|
23956
|
+
if (this.active) this.selectionResolved(null);
|
|
24034
23957
|
return;
|
|
24035
23958
|
}
|
|
24036
23959
|
if (!this.active) return;
|
|
24037
23960
|
this.control.value = this.#value;
|
|
24038
23961
|
if (!this.constrained) {
|
|
24039
23962
|
this.error("");
|
|
23963
|
+
this.selectionResolved(null);
|
|
24040
23964
|
return;
|
|
24041
23965
|
}
|
|
24042
23966
|
const rows = await this.request({ _id: this.#value });
|
|
@@ -24045,6 +23969,7 @@ function ChoiceEditor(HTMLElement) {
|
|
|
24045
23969
|
this.#rows = rows;
|
|
24046
23970
|
this.control.value = row ? row.caption : this.#value;
|
|
24047
23971
|
this.error(row ? "" : "Value is not in the list.");
|
|
23972
|
+
this.selectionResolved(row ?? null);
|
|
24048
23973
|
}
|
|
24049
23974
|
async search(query) {
|
|
24050
23975
|
if (this.locked || !this.active) return;
|
|
@@ -24059,7 +23984,7 @@ function ChoiceEditor(HTMLElement) {
|
|
|
24059
23984
|
item.id = `choice-${index}`;
|
|
24060
23985
|
item.className = "choice";
|
|
24061
23986
|
item.setAttribute("role", "option");
|
|
24062
|
-
|
|
23987
|
+
this.renderChoice(row, item);
|
|
24063
23988
|
item.addEventListener("click", () => this.choose(row));
|
|
24064
23989
|
return item;
|
|
24065
23990
|
}));
|
|
@@ -24098,6 +24023,10 @@ function ChoiceEditor(HTMLElement) {
|
|
|
24098
24023
|
else this.control.setAttribute("aria-activedescendant", `choice-${this.#active}`);
|
|
24099
24024
|
}
|
|
24100
24025
|
closeChoices() {
|
|
24026
|
+
clearTimeout(this.#searchTimer);
|
|
24027
|
+
this.#searchTimer = null;
|
|
24028
|
+
this.#requestController?.abort();
|
|
24029
|
+
this.#requestController = null;
|
|
24101
24030
|
++this.#generation;
|
|
24102
24031
|
this.#cleanup?.();
|
|
24103
24032
|
this.#cleanup = null;
|
|
@@ -24158,8 +24087,136 @@ function callbackChoices(Base) {
|
|
|
24158
24087
|
};
|
|
24159
24088
|
}
|
|
24160
24089
|
|
|
24090
|
+
// src/components/database-choices.js
|
|
24091
|
+
var databaseParameters = {
|
|
24092
|
+
dbtable: { dtype: "T", binding: "read" },
|
|
24093
|
+
method: { dtype: "T", default: "dbSelect", binding: "read" },
|
|
24094
|
+
columns: { dtype: "T", binding: "read" },
|
|
24095
|
+
hiddenColumns: { dtype: "T", binding: "read" },
|
|
24096
|
+
order_by: { dtype: "T", binding: "read" },
|
|
24097
|
+
limit: { dtype: "L", default: 10, binding: "read" },
|
|
24098
|
+
searchDelay: { dtype: "L", default: 300, binding: "read" },
|
|
24099
|
+
ignoreCase: { dtype: "B", default: true, binding: "read" },
|
|
24100
|
+
hasDownArrow: { dtype: "B", default: true, binding: "read" },
|
|
24101
|
+
emptyLabel: { dtype: "T", default: "", binding: "read" },
|
|
24102
|
+
selectedCaption: { dtype: "T" },
|
|
24103
|
+
selectedRecord: { dtype: "T" },
|
|
24104
|
+
selectedCb: { dtype: "T" }
|
|
24105
|
+
};
|
|
24106
|
+
var requestParameters = ["dbtable", "method", "columns", "hiddenColumns", "order_by", "limit", "ignoreCase"];
|
|
24107
|
+
function databaseChoices(Base) {
|
|
24108
|
+
return class extends Base {
|
|
24109
|
+
#configuration = {};
|
|
24110
|
+
#outputs = {};
|
|
24111
|
+
#revision = 0;
|
|
24112
|
+
#acceptedRow;
|
|
24113
|
+
get choiceSource() {
|
|
24114
|
+
return this.#revision;
|
|
24115
|
+
}
|
|
24116
|
+
get searchDelay() {
|
|
24117
|
+
return this.parameters.searchDelay;
|
|
24118
|
+
}
|
|
24119
|
+
// Database writes wait for a complete choice/free-text edit, even with live=True.
|
|
24120
|
+
get commitOnChange() {
|
|
24121
|
+
return true;
|
|
24122
|
+
}
|
|
24123
|
+
textValue(text2) {
|
|
24124
|
+
return text2 === "" ? null : text2;
|
|
24125
|
+
}
|
|
24126
|
+
projectAttributes(attrs, adapt) {
|
|
24127
|
+
const configuration = Object.fromEntries(Object.entries(attrs).filter(([key]) => requestParameters.includes(key) || key === "autoSelect" || key.startsWith("condition_")));
|
|
24128
|
+
const keys = /* @__PURE__ */ new Set([...Object.keys(configuration), ...Object.keys(this.#configuration)]);
|
|
24129
|
+
if ([...keys].some((key) => !Object.is(configuration[key], this.#configuration[key]))) {
|
|
24130
|
+
this.cancelValidation();
|
|
24131
|
+
this.#acceptedRow = void 0;
|
|
24132
|
+
this.#configuration = configuration;
|
|
24133
|
+
this.#revision++;
|
|
24134
|
+
}
|
|
24135
|
+
this.#outputs = Object.fromEntries(Object.entries(attrs).filter(([key]) => key.startsWith("selected_")));
|
|
24136
|
+
const rest = super.projectAttributes(attrs, adapt);
|
|
24137
|
+
const { limit, searchDelay, hasDownArrow, emptyLabel } = this.parameters;
|
|
24138
|
+
if (!Number.isInteger(limit) || limit < 1) throw new TypeError("limit must be a positive integer.");
|
|
24139
|
+
if (!Number.isInteger(searchDelay) || searchDelay < 0) throw new TypeError("searchDelay must be a non-negative integer.");
|
|
24140
|
+
this.toggle.hidden = !hasDownArrow;
|
|
24141
|
+
this.control.style.paddingRight = hasDownArrow ? "" : "var(--gramlot-field-padding, .25em)";
|
|
24142
|
+
if (!this.parameters.placeholder) this.control.placeholder = emptyLabel;
|
|
24143
|
+
for (const key of Object.keys(rest)) if (key.startsWith("condition_") || key.startsWith("selected_")) delete rest[key];
|
|
24144
|
+
return rest;
|
|
24145
|
+
}
|
|
24146
|
+
async loadChoices(keywords, signal) {
|
|
24147
|
+
const parameters2 = Object.fromEntries(requestParameters.filter((key) => key !== "method" && this.parameters[key] != null).map((key) => [key, this.parameters[key]]));
|
|
24148
|
+
for (const [key, value] of Object.entries(this.#configuration)) {
|
|
24149
|
+
if (key.startsWith("condition_")) {
|
|
24150
|
+
const name = key.slice(10);
|
|
24151
|
+
if (!name || name.startsWith("_") || requestParameters.includes(name)) throw new TypeError("Invalid condition parameter.");
|
|
24152
|
+
parameters2[name] = value;
|
|
24153
|
+
}
|
|
24154
|
+
}
|
|
24155
|
+
const result = await this.pageContext.remote(this.parameters.method, { ...parameters2, ...keywords }, signal);
|
|
24156
|
+
if (!result || !Array.isArray(result.rows) || typeof result.identifier !== "string" || typeof result.caption !== "string") {
|
|
24157
|
+
throw new TypeError("Database selectors require {rows, identifier, caption}.");
|
|
24158
|
+
}
|
|
24159
|
+
const ids = /* @__PURE__ */ new Set();
|
|
24160
|
+
return result.rows.map((record2) => {
|
|
24161
|
+
const id = record2[result.identifier], caption = record2[result.caption];
|
|
24162
|
+
if (!(typeof id === "string" && id.length || Number.isSafeInteger(id)) || typeof caption !== "string" || ids.has(id)) {
|
|
24163
|
+
throw new TypeError("Invalid or duplicate database choice identity/caption.");
|
|
24164
|
+
}
|
|
24165
|
+
ids.add(id);
|
|
24166
|
+
return { id, caption, record: record2, captionField: result.caption };
|
|
24167
|
+
});
|
|
24168
|
+
}
|
|
24169
|
+
selectionAccepted(row) {
|
|
24170
|
+
this.#acceptedRow = row;
|
|
24171
|
+
}
|
|
24172
|
+
renderChoice(row, item) {
|
|
24173
|
+
super.renderChoice(row, item);
|
|
24174
|
+
for (const name of (this.parameters.columns ?? "").split(",").map((name2) => name2.trim()).filter((name2) => name2 && name2 !== row.captionField)) {
|
|
24175
|
+
const detail = this.ownerDocument.createElement("span");
|
|
24176
|
+
detail.className = "choice-detail";
|
|
24177
|
+
detail.textContent = row.record[name] ?? "";
|
|
24178
|
+
item.append(detail);
|
|
24179
|
+
}
|
|
24180
|
+
}
|
|
24181
|
+
selectionResolved(row) {
|
|
24182
|
+
this.#writeOutputs(row);
|
|
24183
|
+
}
|
|
24184
|
+
#writeOutputs(row) {
|
|
24185
|
+
const { selectedCaption, selectedRecord } = this.parameters;
|
|
24186
|
+
this.pageContext.selectionOutputs({ selectedCaption, selectedRecord, fields: this.#outputs }, row);
|
|
24187
|
+
}
|
|
24188
|
+
finishValidation(outcome) {
|
|
24189
|
+
if (outcome.ok && this.#acceptedRow !== void 0) {
|
|
24190
|
+
const row = this.#acceptedRow;
|
|
24191
|
+
this.#acceptedRow = void 0;
|
|
24192
|
+
this.#writeOutputs(row);
|
|
24193
|
+
if (this.parameters.selectedCb) {
|
|
24194
|
+
const report = (error) => console.error("Selection notification failed:", error);
|
|
24195
|
+
try {
|
|
24196
|
+
const result = this.pageContext.callLogic(
|
|
24197
|
+
this.parameters.selectedCb,
|
|
24198
|
+
{ value: outcome.value, record: row?.record ?? null }
|
|
24199
|
+
);
|
|
24200
|
+
if (result instanceof Promise) result.catch(report);
|
|
24201
|
+
} catch (error) {
|
|
24202
|
+
report(error);
|
|
24203
|
+
}
|
|
24204
|
+
}
|
|
24205
|
+
}
|
|
24206
|
+
super.finishValidation(outcome);
|
|
24207
|
+
}
|
|
24208
|
+
async resolveValue() {
|
|
24209
|
+
await super.resolveValue();
|
|
24210
|
+
if (this.active && !this.locked && this.parameters.autoSelect && this.readControlValue() == null) {
|
|
24211
|
+
const rows = await this.request({ _querystring: "", limit: 2 });
|
|
24212
|
+
if (rows?.length === 1 && this.readControlValue() == null && !this.locked) this.choose(rows[0]);
|
|
24213
|
+
}
|
|
24214
|
+
}
|
|
24215
|
+
};
|
|
24216
|
+
}
|
|
24217
|
+
|
|
24161
24218
|
// src/components/inputs.js
|
|
24162
|
-
var Textbox = defineComponent({
|
|
24219
|
+
var Textbox = (0, components_exports.defineComponent)({
|
|
24163
24220
|
name: "textbox",
|
|
24164
24221
|
tag: "gramlot-textbox",
|
|
24165
24222
|
base: NativeControl,
|
|
@@ -24170,7 +24227,7 @@ var Textbox = defineComponent({
|
|
|
24170
24227
|
},
|
|
24171
24228
|
implementation: textEditor("input", "text")
|
|
24172
24229
|
});
|
|
24173
|
-
var Checkbox = defineComponent({
|
|
24230
|
+
var Checkbox = (0, components_exports.defineComponent)({
|
|
24174
24231
|
name: "checkbox",
|
|
24175
24232
|
tag: "gramlot-checkbox",
|
|
24176
24233
|
base: NativeControl,
|
|
@@ -24224,7 +24281,7 @@ var Checkbox = defineComponent({
|
|
|
24224
24281
|
}
|
|
24225
24282
|
}
|
|
24226
24283
|
});
|
|
24227
|
-
var RadioButtonText = defineComponent({
|
|
24284
|
+
var RadioButtonText = (0, components_exports.defineComponent)({
|
|
24228
24285
|
name: "radioButtonText",
|
|
24229
24286
|
tag: "gramlot-radio-button-text",
|
|
24230
24287
|
base: ChoiceGroup,
|
|
@@ -24258,7 +24315,7 @@ function textEditor(tag2, type) {
|
|
|
24258
24315
|
}
|
|
24259
24316
|
};
|
|
24260
24317
|
}
|
|
24261
|
-
var TextBoxArea = defineComponent({
|
|
24318
|
+
var TextBoxArea = (0, components_exports.defineComponent)({
|
|
24262
24319
|
name: "textBoxArea",
|
|
24263
24320
|
tag: "gramlot-text-box-area",
|
|
24264
24321
|
base: NativeControl,
|
|
@@ -24271,7 +24328,7 @@ var TextBoxArea = defineComponent({
|
|
|
24271
24328
|
},
|
|
24272
24329
|
implementation: textEditor("textarea")
|
|
24273
24330
|
});
|
|
24274
|
-
var Passwordbox = defineComponent({
|
|
24331
|
+
var Passwordbox = (0, components_exports.defineComponent)({
|
|
24275
24332
|
name: "passwordbox",
|
|
24276
24333
|
tag: "gramlot-passwordbox",
|
|
24277
24334
|
base: NativeControl,
|
|
@@ -24282,7 +24339,7 @@ var Passwordbox = defineComponent({
|
|
|
24282
24339
|
},
|
|
24283
24340
|
implementation: textEditor("input", "password")
|
|
24284
24341
|
});
|
|
24285
|
-
var RadioButton = defineComponent({
|
|
24342
|
+
var RadioButton = (0, components_exports.defineComponent)({
|
|
24286
24343
|
name: "radioButton",
|
|
24287
24344
|
tag: "gramlot-radio-button",
|
|
24288
24345
|
base: NativeControl,
|
|
@@ -24306,7 +24363,7 @@ var RadioButton = defineComponent({
|
|
|
24306
24363
|
}
|
|
24307
24364
|
}
|
|
24308
24365
|
});
|
|
24309
|
-
var Colorpicker = defineComponent({
|
|
24366
|
+
var Colorpicker = (0, components_exports.defineComponent)({
|
|
24310
24367
|
name: "colorpicker",
|
|
24311
24368
|
tag: "gramlot-colorpicker",
|
|
24312
24369
|
base: NativeControl,
|
|
@@ -24361,7 +24418,7 @@ function rangeEditor(vertical) {
|
|
|
24361
24418
|
}
|
|
24362
24419
|
};
|
|
24363
24420
|
}
|
|
24364
|
-
var HorizontalSlider = defineComponent({
|
|
24421
|
+
var HorizontalSlider = (0, components_exports.defineComponent)({
|
|
24365
24422
|
name: "horizontalSlider",
|
|
24366
24423
|
tag: "gramlot-horizontal-slider",
|
|
24367
24424
|
base: NativeControl,
|
|
@@ -24370,7 +24427,7 @@ var HorizontalSlider = defineComponent({
|
|
|
24370
24427
|
sourceContext: true,
|
|
24371
24428
|
implementation: rangeEditor(false)
|
|
24372
24429
|
});
|
|
24373
|
-
var VerticalSlider = defineComponent({
|
|
24430
|
+
var VerticalSlider = (0, components_exports.defineComponent)({
|
|
24374
24431
|
name: "verticalSlider",
|
|
24375
24432
|
tag: "gramlot-vertical-slider",
|
|
24376
24433
|
base: NativeControl,
|
|
@@ -24379,7 +24436,7 @@ var VerticalSlider = defineComponent({
|
|
|
24379
24436
|
sourceContext: true,
|
|
24380
24437
|
implementation: rangeEditor(true)
|
|
24381
24438
|
});
|
|
24382
|
-
var NumberTextBox = defineComponent({
|
|
24439
|
+
var NumberTextBox = (0, components_exports.defineComponent)({
|
|
24383
24440
|
name: "numberTextBox",
|
|
24384
24441
|
tag: "gramlot-number-text-box",
|
|
24385
24442
|
base: TypedEditor,
|
|
@@ -24392,7 +24449,7 @@ var NumberTextBox = defineComponent({
|
|
|
24392
24449
|
},
|
|
24393
24450
|
implementation: numberEditor
|
|
24394
24451
|
});
|
|
24395
|
-
var DateTextBox = defineComponent({
|
|
24452
|
+
var DateTextBox = (0, components_exports.defineComponent)({
|
|
24396
24453
|
name: "dateTextBox",
|
|
24397
24454
|
tag: "gramlot-date-text-box",
|
|
24398
24455
|
base: TypedEditor,
|
|
@@ -24404,7 +24461,7 @@ var DateTextBox = defineComponent({
|
|
|
24404
24461
|
},
|
|
24405
24462
|
implementation: dateEditor
|
|
24406
24463
|
});
|
|
24407
|
-
var DateCalendar = defineComponent({
|
|
24464
|
+
var DateCalendar = (0, components_exports.defineComponent)({
|
|
24408
24465
|
name: "dateCalendar",
|
|
24409
24466
|
tag: "gramlot-date-calendar",
|
|
24410
24467
|
base: CalendarControl,
|
|
@@ -24413,7 +24470,7 @@ var DateCalendar = defineComponent({
|
|
|
24413
24470
|
implementation: (Base) => class extends Base {
|
|
24414
24471
|
}
|
|
24415
24472
|
});
|
|
24416
|
-
var TimeTextBox = defineComponent({
|
|
24473
|
+
var TimeTextBox = (0, components_exports.defineComponent)({
|
|
24417
24474
|
name: "timeTextBox",
|
|
24418
24475
|
tag: "gramlot-time-text-box",
|
|
24419
24476
|
base: TypedEditor,
|
|
@@ -24421,7 +24478,7 @@ var TimeTextBox = defineComponent({
|
|
|
24421
24478
|
parameters: { value: { dtype: "H", nullable: true, binding: "twoWay" } },
|
|
24422
24479
|
implementation: timeEditor
|
|
24423
24480
|
});
|
|
24424
|
-
var FilteringSelect = defineComponent({
|
|
24481
|
+
var FilteringSelect = (0, components_exports.defineComponent)({
|
|
24425
24482
|
name: "filteringSelect",
|
|
24426
24483
|
tag: "gramlot-filtering-select",
|
|
24427
24484
|
base: ChoiceEditor,
|
|
@@ -24429,7 +24486,7 @@ var FilteringSelect = defineComponent({
|
|
|
24429
24486
|
parameters: { values: { dtype: "T", default: "", binding: "read" }, separator: { dtype: "T", default: ",", binding: "read" } },
|
|
24430
24487
|
implementation: localChoices
|
|
24431
24488
|
});
|
|
24432
|
-
var CallbackSelect = defineComponent({
|
|
24489
|
+
var CallbackSelect = (0, components_exports.defineComponent)({
|
|
24433
24490
|
name: "callbackSelect",
|
|
24434
24491
|
tag: "gramlot-callback-select",
|
|
24435
24492
|
base: ChoiceEditor,
|
|
@@ -24437,19 +24494,47 @@ var CallbackSelect = defineComponent({
|
|
|
24437
24494
|
parameters: { callback: { dtype: "T" } },
|
|
24438
24495
|
implementation: callbackChoices
|
|
24439
24496
|
});
|
|
24440
|
-
var ComboBox = defineComponent({
|
|
24497
|
+
var ComboBox = (0, components_exports.defineComponent)({
|
|
24441
24498
|
name: "comboBox",
|
|
24442
24499
|
tag: "gramlot-combo-box",
|
|
24443
24500
|
base: ChoiceEditor,
|
|
24444
24501
|
mixins: [Labelbox, FieldState],
|
|
24445
|
-
parameters: {
|
|
24502
|
+
parameters: {
|
|
24503
|
+
values: { dtype: "T", default: "", binding: "read" },
|
|
24504
|
+
separator: { dtype: "T", default: ",", binding: "read" },
|
|
24505
|
+
store: { dtype: "X", nullable: true, default: null, binding: "read" }
|
|
24506
|
+
},
|
|
24446
24507
|
implementation: (Base) => class extends localChoices(Base) {
|
|
24447
24508
|
get constrained() {
|
|
24448
24509
|
return false;
|
|
24449
24510
|
}
|
|
24450
24511
|
}
|
|
24451
24512
|
});
|
|
24452
|
-
var
|
|
24513
|
+
var DbSelect = (0, components_exports.defineComponent)({
|
|
24514
|
+
name: "dbSelect",
|
|
24515
|
+
tag: "gramlot-db-select",
|
|
24516
|
+
base: ChoiceEditor,
|
|
24517
|
+
mixins: [Labelbox, FieldState],
|
|
24518
|
+
parameters: {
|
|
24519
|
+
...databaseParameters,
|
|
24520
|
+
value: { dtype: ["T", "L"], nullable: true, binding: "twoWay" },
|
|
24521
|
+
autoSelect: { dtype: "B", default: false, binding: "read" }
|
|
24522
|
+
},
|
|
24523
|
+
implementation: databaseChoices
|
|
24524
|
+
});
|
|
24525
|
+
var DbComboBox = (0, components_exports.defineComponent)({
|
|
24526
|
+
name: "dbComboBox",
|
|
24527
|
+
tag: "gramlot-db-combo-box",
|
|
24528
|
+
base: ChoiceEditor,
|
|
24529
|
+
mixins: [Labelbox, FieldState],
|
|
24530
|
+
parameters: databaseParameters,
|
|
24531
|
+
implementation: (Base) => class extends databaseChoices(Base) {
|
|
24532
|
+
get constrained() {
|
|
24533
|
+
return false;
|
|
24534
|
+
}
|
|
24535
|
+
}
|
|
24536
|
+
});
|
|
24537
|
+
var CheckBoxText = (0, components_exports.defineComponent)({
|
|
24453
24538
|
name: "checkBoxText",
|
|
24454
24539
|
tag: "gramlot-check-box-text",
|
|
24455
24540
|
base: ChoiceGroup,
|
|
@@ -24484,6 +24569,8 @@ var inputs_default = defineCollection({ name: "inputs", components: [
|
|
|
24484
24569
|
FilteringSelect,
|
|
24485
24570
|
CallbackSelect,
|
|
24486
24571
|
ComboBox,
|
|
24572
|
+
DbSelect,
|
|
24573
|
+
DbComboBox,
|
|
24487
24574
|
CheckBoxText,
|
|
24488
24575
|
DateCalendar
|
|
24489
24576
|
] });
|
|
@@ -24495,6 +24582,8 @@ export {
|
|
|
24495
24582
|
ComboBox,
|
|
24496
24583
|
DateCalendar,
|
|
24497
24584
|
DateTextBox,
|
|
24585
|
+
DbComboBox,
|
|
24586
|
+
DbSelect,
|
|
24498
24587
|
FilteringSelect,
|
|
24499
24588
|
HorizontalSlider,
|
|
24500
24589
|
NumberTextBox,
|