@gramlot/gramlot 0.3.26 → 0.3.30
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/assets/icons/chart.svg +1 -0
- package/dist/components/audio/__init__.py +13 -0
- package/dist/components/audio/assets/collection.js +3 -0
- package/dist/components/audio/assets/index.js +3 -0
- package/dist/components/audio/commands.json +7 -0
- package/dist/components/audio/grammar.json +335 -0
- package/dist/components/charts/__init__.py +13 -0
- package/dist/components/charts/assets/collection.js +47 -0
- package/dist/components/charts/assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt +29 -0
- package/dist/components/charts/assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt +27 -0
- package/dist/components/charts/assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt +21 -0
- package/dist/components/charts/assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt +21 -0
- package/dist/components/charts/assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt +23 -0
- package/dist/components/charts/assets/index.js +3 -0
- package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +76 -0
- package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +1 -0
- package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +4409 -0
- package/dist/components/charts/assets/modules/plotly.min-4LB7HE7P.js +3596 -0
- package/dist/components/charts/assets/modules/uPlot.esm-5JJNHHRF.js +3 -0
- package/dist/components/charts/assets/modules/uPlot.min-N3E3FA74.js +1 -0
- package/dist/components/charts/assets/modules/vega.module-2QCOVQ3A.js +13 -0
- package/dist/components/charts/commands.json +7 -0
- package/dist/components/charts/grammar.json +1113 -0
- package/dist/components/chat/__init__.py +1 -1
- package/dist/components/chat/assets/collection.js +3 -3
- package/dist/components/chat/assets/index.js +1 -1
- package/dist/components/drawing/__init__.py +15 -0
- package/dist/components/drawing/assets/collection.js +28 -0
- package/dist/components/drawing/assets/index.js +3 -0
- package/dist/components/drawing/commands.json +7 -0
- package/dist/components/drawing/grammar.json +110 -0
- package/dist/components/editors/__init__.py +2 -2
- package/dist/components/editors/assets/collection.js +18 -18
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/modules/{prose-mirror-engine-GMZPJPNN.js → prose-mirror-engine-DQEAEIMV.js} +2 -2
- package/dist/components/editors/grammar.json +150 -0
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/collection.js +63 -33
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +279 -0
- package/dist/components/grouplets/__init__.py +1 -1
- package/dist/components/grouplets/assets/collection.js +3 -3
- package/dist/components/grouplets/assets/index.js +1 -1
- package/dist/components/inputs/__init__.py +3 -2
- package/dist/components/inputs/assets/collection.js +38 -23
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +1533 -321
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +27 -23
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +85 -0
- package/dist/components/selection_trial/__init__.py +1 -1
- package/dist/components/selection_trial/assets/collection.js +3 -3
- package/dist/components/selection_trial/assets/index.js +1 -1
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/collection.js +12 -12
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +126 -0
- package/dist/components/typst/__init__.py +1 -1
- package/dist/components/typst/assets/collection.js +3 -3
- package/dist/components/typst/assets/index.js +1 -1
- package/dist/components/uploads/__init__.py +1 -1
- package/dist/components/uploads/assets/collection.js +9 -9
- package/dist/components/uploads/assets/index.js +1 -1
- package/dist/components/vizabi/__init__.py +13 -0
- package/dist/components/vizabi/assets/collection.js +22 -0
- package/dist/components/vizabi/assets/index.js +3 -0
- package/dist/components/vizabi/commands.json +7 -0
- package/dist/components/vizabi/grammar.json +128 -0
- package/dist/gramlot.js +1190 -256
- package/dist/gramlot.min.js +85 -52
- package/dist/standard-collections.js +2 -0
- package/package.json +12 -4
- package/src/binding/grid-struct.js +2 -2
- package/src/binding/runtime.js +10 -0
- package/src/binding/validation-context.js +2 -1
- package/src/bootstrap.js +1 -1
- package/src/builder/gramlot-builder.d.ts +15 -2
- package/src/builder/gramlot-builder.js +22 -3
- package/src/builder/source.js +24 -1
- package/src/components/audio-analysis-session.js +65 -0
- package/src/components/audio.js +44 -0
- package/src/components/bases.js +11 -7
- package/src/components/border-container.js +6 -3
- package/src/components/buttons.js +47 -3
- package/src/components/chart-bar3d-options.js +30 -0
- package/src/components/chart-controls.js +83 -0
- package/src/components/chart-data-view.js +52 -0
- package/src/components/chart-data.js +42 -0
- package/src/components/chart-domains.js +46 -0
- package/src/components/chart-engines/echarts-options.js +50 -0
- package/src/components/chart-engines/echarts.js +82 -0
- package/src/components/chart-engines/index.js +22 -0
- package/src/components/chart-engines/plotly-map.js +34 -0
- package/src/components/chart-engines/plotly-spatial.js +35 -0
- package/src/components/chart-engines/plotly.js +138 -0
- package/src/components/chart-engines/uplot.js +57 -0
- package/src/components/chart-engines/vega.js +101 -0
- package/src/components/chart-fields.js +110 -0
- package/src/components/chart-geographic-options.js +47 -0
- package/src/components/chart-geojson.js +60 -0
- package/src/components/chart-geometry.js +11 -0
- package/src/components/chart-map-anchors.js +24 -0
- package/src/components/chart-map-bar3d-options.js +41 -0
- package/src/components/chart-map-data.js +25 -0
- package/src/components/chart-map-labels.js +8 -0
- package/src/components/chart-map-options.js +20 -0
- package/src/components/chart-pane.js +91 -0
- package/src/components/chart-renderer.js +58 -0
- package/src/components/chart-sample-view.js +32 -0
- package/src/components/chart-spatial-options.js +40 -0
- package/src/components/chart-time.js +84 -0
- package/src/components/chart-timeline.js +70 -0
- package/src/components/chart-types/area.js +2 -0
- package/src/components/chart-types/bar.js +2 -0
- package/src/components/chart-types/bar3D.js +2 -0
- package/src/components/chart-types/donut.js +2 -0
- package/src/components/chart-types/horizontalBar.js +2 -0
- package/src/components/chart-types/index.js +26 -0
- package/src/components/chart-types/line.js +2 -0
- package/src/components/chart-types/line3D.js +2 -0
- package/src/components/chart-types/lines3D.js +2 -0
- package/src/components/chart-types/map.js +2 -0
- package/src/components/chart-types/map3D.js +2 -0
- package/src/components/chart-types/mapBar3D.js +2 -0
- package/src/components/chart-types/pie.js +2 -0
- package/src/components/chart-types/polygons3D.js +2 -0
- package/src/components/chart-types/scatter.js +2 -0
- package/src/components/chart-types/scatter3D.js +2 -0
- package/src/components/chart-types/stackedArea.js +2 -0
- package/src/components/chart-types/stackedBar.js +2 -0
- package/src/components/chart-types/surface.js +2 -0
- package/src/components/charts.js +152 -0
- package/src/components/check-box-text-editor.js +88 -0
- package/src/components/check-box-text.js +193 -0
- package/src/components/check-box-tree.js +62 -0
- package/src/components/choice-editor.js +35 -18
- package/src/components/choice-field-styles.js +14 -0
- package/src/components/choices.js +5 -0
- package/src/components/database-choices.js +9 -6
- package/src/components/drawing.js +199 -0
- package/src/components/field-state.js +8 -1
- package/src/components/grid-cell-editor.js +83 -19
- package/src/components/grid-check-sets.js +98 -0
- package/src/components/grid-column-filters.js +198 -0
- package/src/components/grid-grammar.json +65 -0
- package/src/components/grid-header-interaction.js +3 -1
- package/src/components/grid-rows.js +2 -2
- package/src/components/grid-search-box.js +38 -22
- package/src/components/grid-search-styles.js +13 -14
- package/src/components/grid-search.js +8 -1
- package/src/components/grid-structure.js +13 -2
- package/src/components/grid-styles.js +34 -2
- package/src/components/grid.js +67 -10
- package/src/components/image-uploader.js +2 -2
- package/src/components/inputs.js +21 -12
- package/src/components/labelbox.js +5 -1
- package/src/components/licenses/claygl.txt +23 -0
- package/src/components/licenses/echarts-gl.txt +29 -0
- package/src/components/licenses/plotly.txt +21 -0
- package/src/components/licenses/uplot.txt +21 -0
- package/src/components/licenses/vega.txt +27 -0
- package/src/components/menus.js +19 -11
- package/src/components/parameters.js +6 -2
- package/src/components/toolbar-overflow.js +12 -8
- package/src/components/tree.js +31 -8
- package/src/components/typed-editor.js +18 -7
- package/src/components/validation.js +1 -1
- package/src/components/vizabi-session.js +66 -0
- package/src/components/vizabi.js +66 -0
- package/src/components/window-surface.js +20 -9
- package/src/components/windows.js +1 -1
- package/src/editing-session.d.ts +1 -0
- package/src/editing-session.js +113 -15
- package/src/editor-values.js +57 -0
- package/src/gramlot.d.ts +2 -0
- package/src/gramlot.js +9 -4
- package/src/handlers/device-handler.js +32 -32
- package/src/handlers/source-handler.d.ts +2 -2
- package/src/ide-documents.js +19 -3
- package/src/ide-runtime.d.ts +1 -0
- package/src/ide-runtime.js +45 -31
- package/src/index.d.ts +2 -1
- package/src/renderer/drag-drop.js +1 -0
- package/src/renderer/gramlot-renderer.d.ts +3 -0
- package/src/renderer/gramlot-renderer.js +16 -4
- package/src/server/assets.d.ts +3 -0
- package/src/server/assets.js +9 -0
- package/src/server/gramlot-server.d.ts +1 -1
- package/src/server/gramlot-server.js +2 -1
- package/src/server/index.d.ts +1 -1
- package/src/server/index.js +1 -1
- package/src/server/source-import.d.ts +1 -1
- package/src/server/source-import.js +5 -1
- package/src/server/visual-editor.d.ts +1 -1
- package/src/server/visual-editor.js +44 -34
- package/src/source-picker.d.ts +1 -1
- package/src/source-picker.js +1 -2
- package/src/stores/bag-collection-view.js +79 -17
- package/src/stores/collection-filter.js +2 -1
- package/src/stores/column-filter.js +49 -0
- package/src/stores/id-set.js +10 -0
- package/src/view/controls.js +8 -0
- package/src/view/html.js +10 -1
- package/src/view/label-menu.js +61 -0
- package/src/view/labelbox.js +15 -2
- package/src/visual-editor-canvas.js +29 -0
- package/src/visual-editor-catalogue.js +34 -0
- package/src/visual-editor.d.ts +5 -0
- package/src/visual-editor.js +244 -26
- package/themes/gramlot-base/theme.css +84 -36
- package/tools/gramlot-tools-inspector.js +170 -506
- package/tools/inspector-agent.js +1 -1
package/dist/gramlot.js
CHANGED
|
@@ -22927,9 +22927,95 @@ var NameSyntax = class _NameSyntax {
|
|
|
22927
22927
|
};
|
|
22928
22928
|
var NAME_SYNTAX = new NameSyntax(String.raw`[A-Za-z][A-Za-z0-9_]*(?:\.[A-Za-z][A-Za-z0-9_]*)*`);
|
|
22929
22929
|
|
|
22930
|
+
// src/components/choices.js
|
|
22931
|
+
function parseChoices(values, separator = ",") {
|
|
22932
|
+
if (typeof separator !== "string" || !separator) throw new TypeError("separator must be a nonempty string");
|
|
22933
|
+
if (values === "") return [];
|
|
22934
|
+
const ids = /* @__PURE__ */ new Set();
|
|
22935
|
+
return values.split(separator).map((item) => {
|
|
22936
|
+
const colon = item.indexOf(":");
|
|
22937
|
+
const id = colon < 0 ? item : item.slice(0, colon);
|
|
22938
|
+
const caption = colon < 0 ? item : item.slice(colon + 1);
|
|
22939
|
+
if (!id || ids.has(id)) throw new Error("Invalid or duplicate choice code");
|
|
22940
|
+
ids.add(id);
|
|
22941
|
+
return { id, caption };
|
|
22942
|
+
});
|
|
22943
|
+
}
|
|
22944
|
+
function choiceCaption(choices, value, placeholder = "") {
|
|
22945
|
+
return choices.find((choice) => choice.id === value)?.caption ?? placeholder ?? "";
|
|
22946
|
+
}
|
|
22947
|
+
|
|
22948
|
+
// src/view/label-menu.js
|
|
22949
|
+
var LabelMenu = class {
|
|
22950
|
+
constructor(layout, choose) {
|
|
22951
|
+
this.layout = layout;
|
|
22952
|
+
const doc = layout.box.ownerDocument;
|
|
22953
|
+
this.button = doc.createElement("button");
|
|
22954
|
+
this.button.type = "button";
|
|
22955
|
+
this.button.className = "label-menu-trigger";
|
|
22956
|
+
this.button.setAttribute("aria-haspopup", "menu");
|
|
22957
|
+
this.button.setAttribute("aria-expanded", "false");
|
|
22958
|
+
this.menu = doc.createElement("gramlot-menu");
|
|
22959
|
+
this.menu.projectAttributes({});
|
|
22960
|
+
layout.labelBox.append(this.button, this.menu);
|
|
22961
|
+
this.button.addEventListener("click", (event) => {
|
|
22962
|
+
event.preventDefault();
|
|
22963
|
+
event.stopPropagation();
|
|
22964
|
+
if (this.menu.opened) this.menu.close();
|
|
22965
|
+
else this.menu.open(this.button);
|
|
22966
|
+
});
|
|
22967
|
+
this.button.addEventListener("keydown", (event) => {
|
|
22968
|
+
if (!["ArrowDown", "ArrowUp"].includes(event.key)) return;
|
|
22969
|
+
event.preventDefault();
|
|
22970
|
+
event.stopPropagation();
|
|
22971
|
+
this.menu.open(this.button, event.key === "ArrowUp");
|
|
22972
|
+
});
|
|
22973
|
+
this.choose = choose;
|
|
22974
|
+
}
|
|
22975
|
+
project({ lbl, lbl_value, lbl_values, disabled, readonly }, adapt) {
|
|
22976
|
+
const choices = parseChoices(lbl_values);
|
|
22977
|
+
if (this.values !== lbl_values) {
|
|
22978
|
+
this.menu.close(false);
|
|
22979
|
+
for (const item of this.menu.items) item.releaseCommand();
|
|
22980
|
+
this.menu.replaceChildren(...choices.map(({ id, caption: caption2 }) => {
|
|
22981
|
+
const item = this.menu.ownerDocument.createElement("gramlot-menu-line");
|
|
22982
|
+
item.projectAttributes({ code: id, caption: caption2 }, adapt);
|
|
22983
|
+
item.activateCommand = (event) => {
|
|
22984
|
+
if (item.prepareCommand(event)) this.choose(id);
|
|
22985
|
+
};
|
|
22986
|
+
item.control.addEventListener("click", (event) => item.activateCommand(event));
|
|
22987
|
+
return item;
|
|
22988
|
+
}));
|
|
22989
|
+
this.values = lbl_values;
|
|
22990
|
+
}
|
|
22991
|
+
const caption = choiceCaption(choices, lbl_value, lbl);
|
|
22992
|
+
this.button.textContent = caption;
|
|
22993
|
+
this.button.disabled = Boolean(disabled || readonly || !choices.length);
|
|
22994
|
+
if (this.button.disabled) this.menu.close(false);
|
|
22995
|
+
for (const item of this.menu.items) {
|
|
22996
|
+
item.projectAttributes({ ...item.parameters, checked: item.parameters.code === lbl_value }, adapt);
|
|
22997
|
+
}
|
|
22998
|
+
this.layout.fieldLabel.textContent = caption;
|
|
22999
|
+
this.layout.fieldLabel.hidden = true;
|
|
23000
|
+
this.layout.labelBox.hidden = false;
|
|
23001
|
+
}
|
|
23002
|
+
dispose() {
|
|
23003
|
+
this.menu.close(false);
|
|
23004
|
+
for (const item of this.menu.items) item.releaseCommand();
|
|
23005
|
+
this.menu.remove();
|
|
23006
|
+
this.button.remove();
|
|
23007
|
+
this.layout.fieldLabel.hidden = false;
|
|
23008
|
+
}
|
|
23009
|
+
};
|
|
23010
|
+
|
|
22930
23011
|
// src/view/labelbox.js
|
|
22931
23012
|
var labelboxPositions = ["TL", "TC", "TR", "L", "R", "BL", "BC", "BR"];
|
|
22932
|
-
var labelboxStyle = `.gramlot-labelbox
|
|
23013
|
+
var labelboxStyle = `.gramlot-labelbox>.label-box>.label-menu-trigger{font:inherit;color:inherit;background:transparent;border:0;padding:0;min-width:0;min-height:var(--gramlot-touch-target,0px);height:auto;display:inline-flex;align-items:center;gap:.4em;cursor:pointer;text-align:inherit;line-height:inherit}
|
|
23014
|
+
.gramlot-labelbox>.label-box>.label-menu-trigger::after{content:'';width:.35em;height:.35em;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:translateY(-.1em) rotate(45deg);flex:none}
|
|
23015
|
+
.gramlot-labelbox>.label-box>.label-menu-trigger:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:3px;border-radius:2px}
|
|
23016
|
+
.gramlot-labelbox>.label-box>.label-menu-trigger:disabled{opacity:.5;cursor:default}
|
|
23017
|
+
.gramlot-labelbox>.label-box>label[hidden]{display:none}
|
|
23018
|
+
.gramlot-labelbox[hidden]{display:none!important}
|
|
22933
23019
|
.gramlot-labelbox{box-sizing:border-box;min-width:0;min-height:0;--gramlot-label-width:initial;--gramlot-formlet-label-width:initial;display:grid;gap:var(--gramlot-label-gap,.25em);grid-template-areas:'label' 'control';grid-template-columns:minmax(0,1fr);grid-template-rows:max-content minmax(0,1fr)}
|
|
22934
23020
|
.gramlot-labelbox>.label-box{grid-area:label;color:var(--gramlot-label-color,var(--gramlot-text-secondary,inherit));font-size:var(--gramlot-label-size,1em)} .gramlot-labelbox>.control-box{box-sizing:border-box;grid-area:control;min-width:0;min-height:0;display:grid;grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr)}
|
|
22935
23021
|
.gramlot-labelbox>.control-box>*{max-width:100%;box-sizing:border-box}
|
|
@@ -22987,7 +23073,7 @@ function createLabelbox(document, controlBox) {
|
|
|
22987
23073
|
return layout;
|
|
22988
23074
|
}
|
|
22989
23075
|
function projectLabelbox(layout, attrs, adapt) {
|
|
22990
|
-
const { lbl, lbl_variant, lbl_position = lbl_variant === "card" ? "TC" : "TL", ...rest } = attrs;
|
|
23076
|
+
const { lbl, lbl_value, lbl_values, lbl_variant, lbl_position = lbl_variant === "card" ? "TC" : "TL", ...rest } = attrs;
|
|
22991
23077
|
if (!labelboxPositions.includes(lbl_position)) throw new TypeError(`Invalid lbl_position: ${lbl_position}`);
|
|
22992
23078
|
const groups = { box: {}, label: {}, labelBox: {}, controlBox: {} };
|
|
22993
23079
|
const prefixes = [["box_l_", "labelBox"], ["box_c_", "controlBox"], ["lbl_", "label"], ["box_", "box"]];
|
|
@@ -23017,6 +23103,13 @@ function projectLabelbox(layout, attrs, adapt) {
|
|
|
23017
23103
|
else layout.box.dataset.variant = lbl_variant;
|
|
23018
23104
|
layout.fieldLabel.textContent = lbl ?? "";
|
|
23019
23105
|
layout.labelBox.hidden = lbl == null || lbl === "";
|
|
23106
|
+
if (lbl_values != null) {
|
|
23107
|
+
layout.menu ??= new LabelMenu(layout, (value) => layout.choose(value));
|
|
23108
|
+
layout.menu.project(attrs, adapt);
|
|
23109
|
+
} else if (layout.menu) {
|
|
23110
|
+
layout.menu.dispose();
|
|
23111
|
+
layout.menu = null;
|
|
23112
|
+
}
|
|
23020
23113
|
layout.box.dispatchEvent(new layout.box.ownerDocument.defaultView.Event("gramlot-label-layout", { bubbles: true }));
|
|
23021
23114
|
return rest;
|
|
23022
23115
|
}
|
|
@@ -23028,6 +23121,21 @@ function labelboxPresentation(content) {
|
|
|
23028
23121
|
return box?.labelbox && labelboxContent(box) === content ? box : content;
|
|
23029
23122
|
}
|
|
23030
23123
|
|
|
23124
|
+
// src/components/choice-field-styles.js
|
|
23125
|
+
var choiceFieldStyles = `
|
|
23126
|
+
.choice-field{position:relative;min-width:0}
|
|
23127
|
+
.choice-field>input{box-sizing:border-box;width:100%;padding-inline-end:calc(var(--gramlot-choice-toggle-width,1.6em) + .4em)}
|
|
23128
|
+
.choice-field>.choice-toggle{position:absolute;inset-inline-end:1px;inset-block:1px;
|
|
23129
|
+
width:var(--gramlot-choice-toggle-width,1.6em);min-width:0;min-height:0;
|
|
23130
|
+
display:grid;place-items:center;padding:0;border:0;border-radius:0;
|
|
23131
|
+
background:transparent;box-shadow:none;color:inherit;font:inherit;cursor:pointer}
|
|
23132
|
+
.choice-toggle::after{content:'';width:.4em;height:.4em;border-inline-end:1.5px solid currentColor;
|
|
23133
|
+
border-block-end:1.5px solid currentColor;transform:translateY(-.1em) rotate(45deg);pointer-events:none}
|
|
23134
|
+
.choice-toggle:disabled{opacity:.5;cursor:default}
|
|
23135
|
+
.choice-toggle:focus-visible{outline:1px solid var(--gramlot-focus-ring,Highlight);outline-offset:-3px}
|
|
23136
|
+
.choice-field>input::-webkit-calendar-picker-indicator{opacity:0}
|
|
23137
|
+
`;
|
|
23138
|
+
|
|
23031
23139
|
// src/webcomponent.js
|
|
23032
23140
|
var NAME2 = /^[a-z][.0-9_a-z\-\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u;
|
|
23033
23141
|
var RESERVED = /* @__PURE__ */ new Set([
|
|
@@ -23194,23 +23302,11 @@ function defineCollection(options) {
|
|
|
23194
23302
|
|
|
23195
23303
|
// src/components/parameters.js
|
|
23196
23304
|
function projectParameters(element, attrs) {
|
|
23197
|
-
element.parameters =
|
|
23305
|
+
element.parameters = parameterValues(element.constructor.gramlotComponent, attrs);
|
|
23198
23306
|
return Object.fromEntries(Object.entries(attrs).filter(([name]) => !Object.hasOwn(element.parameters, name)));
|
|
23199
23307
|
}
|
|
23200
|
-
|
|
23201
|
-
|
|
23202
|
-
function parseChoices(values, separator = ",") {
|
|
23203
|
-
if (typeof separator !== "string" || !separator) throw new TypeError("separator must be a nonempty string");
|
|
23204
|
-
if (values === "") return [];
|
|
23205
|
-
const ids = /* @__PURE__ */ new Set();
|
|
23206
|
-
return values.split(separator).map((item) => {
|
|
23207
|
-
const colon = item.indexOf(":");
|
|
23208
|
-
const id = colon < 0 ? item : item.slice(0, colon);
|
|
23209
|
-
const caption = colon < 0 ? item : item.slice(colon + 1);
|
|
23210
|
-
if (!id || ids.has(id)) throw new Error("Invalid or duplicate choice code");
|
|
23211
|
-
ids.add(id);
|
|
23212
|
-
return { id, caption };
|
|
23213
|
-
});
|
|
23308
|
+
function parameterValues(component, attrs) {
|
|
23309
|
+
return Object.fromEntries(Object.entries(component.parameters).map(([name, spec]) => [name, Object.hasOwn(attrs, name) ? attrs[name] : spec.default]));
|
|
23214
23310
|
}
|
|
23215
23311
|
|
|
23216
23312
|
// src/components/bases.js
|
|
@@ -23261,13 +23357,19 @@ function controlElement(HTMLElement) {
|
|
|
23261
23357
|
finishValidation() {
|
|
23262
23358
|
}
|
|
23263
23359
|
validationValueCheck() {
|
|
23264
|
-
|
|
23360
|
+
return this.constructor.validationValueCheck(this.pageContext);
|
|
23361
|
+
}
|
|
23362
|
+
static validationValueCheck() {
|
|
23363
|
+
const nullable = this.gramlotComponent.parameters.value.nullable;
|
|
23265
23364
|
return (value, original) => {
|
|
23266
23365
|
if (value == null && !nullable) throw new TypeError("This component requires a non-null value.");
|
|
23267
23366
|
if (value != null && original != null && typeof value !== typeof original) throw new TypeError("Validation must preserve the component value type.");
|
|
23268
23367
|
};
|
|
23269
23368
|
}
|
|
23270
23369
|
validationSelection() {
|
|
23370
|
+
return this.constructor.validationSelection(this.parameters, this.pageContext);
|
|
23371
|
+
}
|
|
23372
|
+
static validationSelection() {
|
|
23271
23373
|
return () => {
|
|
23272
23374
|
throw new TypeError("validate_select requires a constrained choice editor.");
|
|
23273
23375
|
};
|
|
@@ -23361,11 +23463,15 @@ function ChoiceGroup(HTMLElement) {
|
|
|
23361
23463
|
items[next].focus();
|
|
23362
23464
|
});
|
|
23363
23465
|
}
|
|
23466
|
+
choiceOptions() {
|
|
23467
|
+
return parseChoices(this.parameters.values ?? "");
|
|
23468
|
+
}
|
|
23364
23469
|
projectAttributes(attrs, adapt) {
|
|
23365
23470
|
const rest = super.projectAttributes(attrs, adapt);
|
|
23366
|
-
const values = this.
|
|
23367
|
-
|
|
23368
|
-
|
|
23471
|
+
const values = this.choiceOptions();
|
|
23472
|
+
const signature = JSON.stringify(values);
|
|
23473
|
+
if (signature !== this.#values) {
|
|
23474
|
+
const options = values;
|
|
23369
23475
|
const retained = /* @__PURE__ */ new Set();
|
|
23370
23476
|
let previous = null;
|
|
23371
23477
|
for (const { id: code, caption } of options) {
|
|
@@ -23392,7 +23498,7 @@ function ChoiceGroup(HTMLElement) {
|
|
|
23392
23498
|
item.label.remove();
|
|
23393
23499
|
this.#options.delete(code);
|
|
23394
23500
|
}
|
|
23395
|
-
this.#values =
|
|
23501
|
+
this.#values = signature;
|
|
23396
23502
|
}
|
|
23397
23503
|
const cols = this.parameters.cols;
|
|
23398
23504
|
if (!Number.isInteger(cols) || cols < 1) throw new TypeError("cols must be a positive integer");
|
|
@@ -23826,6 +23932,7 @@ var ToolbarOverflow = class {
|
|
|
23826
23932
|
:host([role=toolbar]) .toolbar-viewport{display:flex;align-items:center;gap:var(--gramlot-toolbar-gap,4px);flex:1 1 0%;min-width:0;min-height:0;overflow-x:auto;overflow-y:hidden}
|
|
23827
23933
|
:host([role=toolbar][aria-orientation=vertical]) .toolbar-viewport{flex-direction:column;align-items:stretch;overflow-x:hidden;overflow-y:auto;width:100%}
|
|
23828
23934
|
:host([role=toolbar]) ::slotted(*){flex-shrink:0}
|
|
23935
|
+
:host([role=toolbar]) .toolbar-viewport[data-measuring]{flex:none;width:max-content;height:max-content;overflow:visible}
|
|
23829
23936
|
.toolbar-more{flex:0 0 auto;width:max(var(--gramlot-field-height,32px),var(--gramlot-touch-target,0px));height:max(var(--gramlot-field-height,32px),var(--gramlot-touch-target,0px));padding:0;border:0;border-radius:4px;background:transparent;color:inherit;font:inherit;display:grid;place-items:center}
|
|
23830
23937
|
.toolbar-more svg{display:block;width:18px;height:18px;pointer-events:none}
|
|
23831
23938
|
.toolbar-more:hover,.toolbar-more:focus-visible{background:var(--gramlot-selected,Highlight)}
|
|
@@ -23913,27 +24020,28 @@ var ToolbarOverflow = class {
|
|
|
23913
24020
|
this.#overflow.clear();
|
|
23914
24021
|
menu.refreshItems();
|
|
23915
24022
|
for (const item of menu.items) item.refreshAvailability();
|
|
24023
|
+
this.#viewport.setAttribute("data-measuring", "");
|
|
23916
24024
|
const gap = parseFloat(win.getComputedStyle(this.#viewport).gap) || 0;
|
|
23917
24025
|
const lengths = new Map(units.map((unit) => {
|
|
23918
24026
|
const css = win.getComputedStyle(unit);
|
|
23919
24027
|
const length = labelboxContent(unit).localName === "gramlot-spacer" ? labelboxContent(unit).parameters.size ?? 0 : unit.getBoundingClientRect()[axis];
|
|
23920
24028
|
return [unit, length + (parseFloat(css[vertical ? "marginTop" : "marginLeft"]) || 0) + (parseFloat(css[vertical ? "marginBottom" : "marginRight"]) || 0)];
|
|
23921
24029
|
}));
|
|
24030
|
+
this.#viewport.removeAttribute("data-measuring");
|
|
23922
24031
|
const separator = (unit) => labelboxContent(unit).getAttribute("role") === "separator";
|
|
23923
24032
|
const tidy = (list) => list.filter((unit, index) => !separator(unit) || list.slice(0, index).some((item) => labelboxContent(item).localName !== "gramlot-spacer" && !separator(item)) && list.slice(index + 1).find((item) => labelboxContent(item).localName !== "gramlot-spacer") && !separator(list.slice(index + 1).find((item) => labelboxContent(item).localName !== "gramlot-spacer")));
|
|
23924
24033
|
const required = (remaining2) => remaining2.reduce((sum2, unit) => sum2 + lengths.get(unit), 0) + Math.max(0, remaining2.length - 1) * gap;
|
|
23925
24034
|
let remaining = tidy(units);
|
|
23926
24035
|
if (required(remaining) > available) {
|
|
23927
|
-
|
|
23928
|
-
|
|
23929
|
-
|
|
23930
|
-
|
|
23931
|
-
remaining = tidy(remaining.filter((item) => item !== unit));
|
|
24036
|
+
let cut = units.length;
|
|
24037
|
+
while (cut > 0 && required(remaining) > available - 32) {
|
|
24038
|
+
cut--;
|
|
24039
|
+
remaining = tidy(units.slice(0, cut));
|
|
23932
24040
|
}
|
|
24041
|
+
const suffix = tidy(units.slice(cut).filter((unit) => labelboxContent(unit).localName !== "gramlot-spacer"));
|
|
24042
|
+
for (const unit of suffix) this.#overflow.add(unit);
|
|
23933
24043
|
}
|
|
23934
|
-
const
|
|
23935
|
-
for (const unit of overflowRows) this.#overflow.add(unit);
|
|
23936
|
-
for (const unit of units) if (separator(unit) && !remaining.includes(unit) && !this.#overflow.has(unit)) unit.slot = "suppressed";
|
|
24044
|
+
for (const unit of units) if (!remaining.includes(unit) && !this.#overflow.has(unit)) unit.slot = "suppressed";
|
|
23937
24045
|
for (const unit of this.#overflow) {
|
|
23938
24046
|
unit.slot = "overflow";
|
|
23939
24047
|
unit.setAttribute("data-menu-overflow", "");
|
|
@@ -24019,9 +24127,9 @@ function MenuContainer(HTMLElement) {
|
|
|
24019
24127
|
const doc = this.ownerDocument, shadow = this.attachShadow({ mode: "open" });
|
|
24020
24128
|
const style = doc.createElement("style");
|
|
24021
24129
|
style.textContent = `:host{box-sizing:border-box;color:var(--gramlot-ink,CanvasText)}
|
|
24022
|
-
:host([role=menu]){position:fixed;inset:auto;margin:0;padding:
|
|
24130
|
+
:host([role=menu]){position:fixed;inset:auto;margin:0;padding:3px;min-width:0;width:max-content;font:inherit;
|
|
24023
24131
|
max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
|
|
24024
|
-
background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-
|
|
24132
|
+
background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-sm,5px);box-shadow:0 4px 14px #0003}
|
|
24025
24133
|
:host([role=toolbar][aria-orientation=vertical]){flex-direction:column;align-items:stretch}
|
|
24026
24134
|
:host([role=toolbar]){display:flex;gap:var(--gramlot-toolbar-gap,4px);align-items:center}
|
|
24027
24135
|
:host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
|
|
@@ -24065,8 +24173,11 @@ function MenuContainer(HTMLElement) {
|
|
|
24065
24173
|
isOverflowed(item) {
|
|
24066
24174
|
return this.#overflow.contains(item);
|
|
24067
24175
|
}
|
|
24176
|
+
get visibleItems() {
|
|
24177
|
+
return this.items.filter((item) => labelboxPresentation(item).slot !== "suppressed" && !item.hidden && !item.closest("[hidden]") && item.getAttribute("role") !== "separator");
|
|
24178
|
+
}
|
|
24068
24179
|
get usableItems() {
|
|
24069
|
-
return this.
|
|
24180
|
+
return this.visibleItems.filter((item) => !item.disabled);
|
|
24070
24181
|
}
|
|
24071
24182
|
get parentMenu() {
|
|
24072
24183
|
return this.parentElement?.closest("gramlot-menu") ?? null;
|
|
@@ -24161,6 +24272,11 @@ function MenuContainer(HTMLElement) {
|
|
|
24161
24272
|
for (const group of this.querySelectorAll("gramlot-menu-line")) if (group.menuOwner === this && group.parameters.group) group.refreshAvailability();
|
|
24162
24273
|
for (const item of this.items) item.refreshAvailability();
|
|
24163
24274
|
const usable = this.usableItems;
|
|
24275
|
+
for (const [part, present, width] of [
|
|
24276
|
+
["check", this.visibleItems.some((item) => item.parameters.checked != null), "1.4em"],
|
|
24277
|
+
["icon", this.visibleItems.some((item) => item.entryIcon || item.entryIconSrc), "1.5em"],
|
|
24278
|
+
["arrow", this.visibleItems.some((item) => item.submenu), ".9em"]
|
|
24279
|
+
]) this.style.setProperty(`--gramlot-menu-${part}-track`, present ? width : "0px");
|
|
24164
24280
|
if (this.#active && !usable.includes(this.#active)) {
|
|
24165
24281
|
const index = this.#previous.indexOf(this.#active);
|
|
24166
24282
|
const next = this.#previous.slice(index + 1).find((item) => usable.includes(item)) ?? this.#previous.slice(0, index).reverse().find((item) => usable.includes(item));
|
|
@@ -24284,10 +24400,10 @@ function menuLine(Base) {
|
|
|
24284
24400
|
const style = doc.createElement("style");
|
|
24285
24401
|
style.textContent = `:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
|
|
24286
24402
|
.menu-check:empty,.menu-arrow:empty{display:none}
|
|
24287
|
-
button.menu-row{display:grid;grid-template-columns:
|
|
24288
|
-
align-items:center;width:100%;min-height:max(
|
|
24403
|
+
button.menu-row{display:grid;grid-template-columns:var(--gramlot-menu-check-track,0px) var(--gramlot-menu-icon-track,0px) minmax(0,1fr) var(--gramlot-menu-arrow-track,0px);column-gap:0;
|
|
24404
|
+
align-items:center;width:100%;min-height:max(24px,var(--gramlot-touch-target,0px));padding:2px 7px;
|
|
24289
24405
|
line-height:1.3;text-align:left;border:0;border-radius:var(--gramlot-radius-sm,5px);background:transparent;cursor:default}
|
|
24290
|
-
.menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:
|
|
24406
|
+
.menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:start;min-width:0}
|
|
24291
24407
|
.menu-row .menu-check{grid-column:1}.menu-row .icon{grid-column:2}
|
|
24292
24408
|
.menu-row .menu-caption{grid-column:3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
24293
24409
|
.menu-row .menu-arrow{grid-column:4;font-size:1.2em;line-height:1}
|
|
@@ -24299,6 +24415,7 @@ function menuLine(Base) {
|
|
|
24299
24415
|
background:transparent;cursor:pointer;line-height:1.2;white-space:nowrap}
|
|
24300
24416
|
:host button.toolbar-button .icon{display:inline-flex;align-items:center;justify-content:center;
|
|
24301
24417
|
width:var(--gramlot-toolbar-icon-size);height:var(--gramlot-toolbar-icon-size);font-size:var(--gramlot-toolbar-icon-size);line-height:1}
|
|
24418
|
+
#control.toolbar-button.icon-only{--gramlot-button-icon-size:var(--gramlot-toolbar-icon-size)}
|
|
24302
24419
|
:host button.toolbar-button .icon:empty{display:none}
|
|
24303
24420
|
:host button.toolbar-button:hover:not(:disabled){background:color-mix(in srgb,currentColor 10%,transparent)}
|
|
24304
24421
|
:host button.toolbar-button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
|
|
@@ -24308,7 +24425,7 @@ function menuLine(Base) {
|
|
|
24308
24425
|
:host button.toolbar-below .menu-caption{font-size:11px;line-height:1.2}
|
|
24309
24426
|
:host button.toolbar-tooltip .menu-caption{display:none}
|
|
24310
24427
|
:host button.toolbar-button .menu-check{display:none}
|
|
24311
|
-
:host button.toolbar-tooltip .menu-arrow{position:
|
|
24428
|
+
:host button.toolbar-tooltip .menu-arrow{position:static;flex:0 0 8px;margin-inline-start:2px;font-size:12px;line-height:1}
|
|
24312
24429
|
:host button.toolbar-below .menu-arrow{position:absolute;inset:4px 3px auto auto;font-size:12px}`;
|
|
24313
24430
|
style.textContent += `
|
|
24314
24431
|
:host([role=group]){display:block;min-width:0}
|
|
@@ -24346,7 +24463,7 @@ function menuLine(Base) {
|
|
|
24346
24463
|
return this.parentElement?.closest("gramlot-menu") ?? null;
|
|
24347
24464
|
}
|
|
24348
24465
|
get submenu() {
|
|
24349
|
-
return [...this.children].map(labelboxContent).find((child) => child
|
|
24466
|
+
return [...this.children].map(labelboxContent).find((child) => child?.localName === "gramlot-menu") ?? null;
|
|
24350
24467
|
}
|
|
24351
24468
|
get entryCaption() {
|
|
24352
24469
|
return this.parameters.caption ?? this.#registry?.label ?? "";
|
|
@@ -24369,9 +24486,9 @@ function menuLine(Base) {
|
|
|
24369
24486
|
const rest = super.projectAttributes(attrs, adapt);
|
|
24370
24487
|
this.#accessibleLabel = attrs["aria-label"];
|
|
24371
24488
|
if (this.parameters.iconSize != null && (!Number.isFinite(this.parameters.iconSize) || this.parameters.iconSize <= 0)) throw new TypeError("menuline iconSize must be positive");
|
|
24372
|
-
if (!Number.isFinite(this.parameters.priority)) throw new TypeError("menuline priority must be finite");
|
|
24373
24489
|
this.#authoredDisabled = Boolean(this.parameters.disabled);
|
|
24374
24490
|
this.#render();
|
|
24491
|
+
this.menuOwner?.refreshItems();
|
|
24375
24492
|
this.menuOwner?.overflow.schedule();
|
|
24376
24493
|
return rest;
|
|
24377
24494
|
}
|
|
@@ -24416,9 +24533,10 @@ function menuLine(Base) {
|
|
|
24416
24533
|
else this.control.style.removeProperty("--gramlot-toolbar-icon-size");
|
|
24417
24534
|
this.toggleAttribute("data-menu-group-rows", Boolean(popup || owner?.parameters.orientation === "vertical"));
|
|
24418
24535
|
this.control.classList.toggle("menu-row", popup);
|
|
24419
|
-
this.#arrow.textContent = this.submenu ? popup || owner?.parameters.orientation === "vertical" ? "\u203A" : "\u25BE" : "";
|
|
24536
|
+
this.#arrow.textContent = this.submenu ? toolbar && labelPosition === "tooltip" ? "\u2304" : popup || owner?.parameters.orientation === "vertical" ? "\u203A" : "\u25BE" : "";
|
|
24420
24537
|
const disabled = this.#authoredDisabled || this.getAttribute("role") === "separator" || Boolean(this.parameters.command && !this.#registry) || ["loading", "error"].includes(owner?.status) || Boolean(this.closest("gramlot-drop-down-button")?.parameters.disabled);
|
|
24421
24538
|
if (this.control.disabled !== disabled) this.control.disabled = disabled;
|
|
24539
|
+
this.refreshIconOnly();
|
|
24422
24540
|
}
|
|
24423
24541
|
get disabled() {
|
|
24424
24542
|
for (let p = this.parentElement; p && p !== this.menuOwner; p = p.parentElement) if (p.localName === "gramlot-menu-line" && p.parameters.disabled) return true;
|
|
@@ -24459,6 +24577,7 @@ function menuLine(Base) {
|
|
|
24459
24577
|
function Command(HTMLElement) {
|
|
24460
24578
|
return class extends controlElement(HTMLElement) {
|
|
24461
24579
|
#actionPresentation = null;
|
|
24580
|
+
#captionObserver;
|
|
24462
24581
|
constructor() {
|
|
24463
24582
|
super();
|
|
24464
24583
|
const doc = this.ownerDocument;
|
|
@@ -24500,7 +24619,42 @@ function Command(HTMLElement) {
|
|
|
24500
24619
|
:host([role=separator]) button{display:none}
|
|
24501
24620
|
@media(forced-colors:active){button,:host(.button--secondary) button,:host(.button--quiet) button{background:ButtonFace;color:ButtonText;border-color:ButtonText;filter:none}}
|
|
24502
24621
|
`;
|
|
24622
|
+
style.textContent += `
|
|
24623
|
+
#control.icon-only{gap:0;padding:var(--gramlot-button-icon-padding,5px);
|
|
24624
|
+
min-width:max(calc(var(--gramlot-button-icon-size,24px) + 12px),var(--gramlot-touch-target,0px));
|
|
24625
|
+
min-height:max(calc(var(--gramlot-button-icon-size,24px) + 12px),var(--gramlot-touch-target,0px));
|
|
24626
|
+
background:transparent;border-color:transparent;line-height:1}
|
|
24627
|
+
#control.icon-only .icon{display:inline-flex;align-items:center;justify-content:center;flex:none;
|
|
24628
|
+
width:var(--gramlot-button-icon-size,24px);height:var(--gramlot-button-icon-size,24px);
|
|
24629
|
+
font-size:var(--gramlot-button-icon-size,24px);line-height:1}
|
|
24630
|
+
#control.icon-only:hover:not(:disabled){background:var(--gramlot-selected,Highlight)}
|
|
24631
|
+
#control.icon-only:is([aria-pressed=true],[aria-checked=true],[aria-expanded=true]){background:var(--gramlot-selected,Highlight);color:var(--gramlot-action,CanvasText)}
|
|
24632
|
+
#control.icon-only .led{display:none}
|
|
24633
|
+
@media(forced-colors:active){#control.icon-only{background:ButtonFace;color:ButtonText;border-color:ButtonText}
|
|
24634
|
+
#control.icon-only:is([aria-pressed=true],[aria-checked=true],[aria-expanded=true]){background:Highlight;color:HighlightText}}
|
|
24635
|
+
`;
|
|
24503
24636
|
this.shadowRoot.append(style);
|
|
24637
|
+
this.#captionObserver = new this.ownerDocument.defaultView.MutationObserver(() => this.refreshIconOnly());
|
|
24638
|
+
}
|
|
24639
|
+
connectedCallback() {
|
|
24640
|
+
super.connectedCallback();
|
|
24641
|
+
const options = { childList: true, subtree: true, characterData: true, attributes: true, attributeFilter: ["hidden", "slot"] };
|
|
24642
|
+
this.#captionObserver.observe(this, options);
|
|
24643
|
+
this.#captionObserver.observe(this.control, options);
|
|
24644
|
+
this.refreshIconOnly();
|
|
24645
|
+
}
|
|
24646
|
+
disconnectedCallback() {
|
|
24647
|
+
this.#captionObserver.disconnect();
|
|
24648
|
+
}
|
|
24649
|
+
releaseControl() {
|
|
24650
|
+
this.#captionObserver.disconnect();
|
|
24651
|
+
super.releaseControl();
|
|
24652
|
+
}
|
|
24653
|
+
refreshIconOnly() {
|
|
24654
|
+
const hasContent = (node) => node.nodeType === 3 ? Boolean(node.textContent.trim()) : node.nodeType === 1 && !node.hidden && node.getAttribute("slot") !== "menu";
|
|
24655
|
+
const slottedCaption = !this.caption.hidden && this.caption.assignedNodes().some(hasContent);
|
|
24656
|
+
const extraCaption = [...this.control.children].some((node) => node !== this.icon && node !== this.caption && !node.hidden && !node.matches(".led,.menu-check,.menu-arrow") && !(node.matches(".menu-caption") && this.control.classList.contains("toolbar-tooltip")) && Boolean(node.textContent.trim()));
|
|
24657
|
+
this.control.classList.toggle("icon-only", !this.control.classList.contains("menu-row") && Boolean(this.icon.textContent || this.icon.firstElementChild) && !slottedCaption && !extraCaption);
|
|
24504
24658
|
}
|
|
24505
24659
|
get disabled() {
|
|
24506
24660
|
return this.control.disabled;
|
|
@@ -24521,6 +24675,7 @@ function Command(HTMLElement) {
|
|
|
24521
24675
|
renderIcon(icon, iconSrc) {
|
|
24522
24676
|
if (!iconSrc) {
|
|
24523
24677
|
this.icon.textContent = icon ?? "";
|
|
24678
|
+
this.refreshIconOnly();
|
|
24524
24679
|
return;
|
|
24525
24680
|
}
|
|
24526
24681
|
let image = this.icon.firstElementChild;
|
|
@@ -24531,6 +24686,7 @@ function Command(HTMLElement) {
|
|
|
24531
24686
|
this.icon.replaceChildren(image);
|
|
24532
24687
|
}
|
|
24533
24688
|
if (image.getAttribute("src") !== iconSrc) image.setAttribute("src", iconSrc);
|
|
24689
|
+
this.refreshIconOnly();
|
|
24534
24690
|
}
|
|
24535
24691
|
get entryIcon() {
|
|
24536
24692
|
return this.parameters.icon;
|
|
@@ -24544,6 +24700,7 @@ function Command(HTMLElement) {
|
|
|
24544
24700
|
this.icon.textContent = presentation.icon;
|
|
24545
24701
|
this.title = presentation.title;
|
|
24546
24702
|
this.control.setAttribute("aria-label", presentation.title);
|
|
24703
|
+
this.refreshIconOnly();
|
|
24547
24704
|
}
|
|
24548
24705
|
attachCommand() {
|
|
24549
24706
|
}
|
|
@@ -24643,8 +24800,6 @@ var MenuLine = defineComponent({
|
|
|
24643
24800
|
labelPosition: { dtype: "T", binding: "read", nullable: true, enum: ["beside", "below", "tooltip"] },
|
|
24644
24801
|
iconSize: { dtype: "R", binding: "read", nullable: true },
|
|
24645
24802
|
group: { dtype: "B", default: false },
|
|
24646
|
-
priority: { dtype: "R", default: 0 },
|
|
24647
|
-
overflowable: { dtype: "B", default: true },
|
|
24648
24803
|
parameters: { annotation: { kind: "type", module: "builtins", name: "dict" }, nullable: true },
|
|
24649
24804
|
favorite: { dtype: "B", default: false }
|
|
24650
24805
|
},
|
|
@@ -24678,13 +24833,16 @@ var DropDownButton = defineComponent({
|
|
|
24678
24833
|
super();
|
|
24679
24834
|
const doc = this.ownerDocument;
|
|
24680
24835
|
this.control.classList.add("split");
|
|
24836
|
+
this.controlBox.classList.add("choice-field");
|
|
24837
|
+
const affordance = doc.createElement("style");
|
|
24838
|
+
affordance.textContent = choiceFieldStyles + ".split{border-radius:var(--gramlot-radius-sm,4px);padding-inline-end:calc(var(--gramlot-choice-toggle-width,1.6em) + .5em)}";
|
|
24839
|
+
this.shadowRoot.append(affordance);
|
|
24681
24840
|
this.#chosenCaption = doc.createElement("span");
|
|
24682
24841
|
this.#chosenCaption.hidden = true;
|
|
24683
24842
|
this.control.append(this.#chosenCaption);
|
|
24684
24843
|
this.#arrow = doc.createElement("button");
|
|
24685
24844
|
this.#arrow.type = "button";
|
|
24686
|
-
this.#arrow.className = "arrow";
|
|
24687
|
-
this.#arrow.textContent = "\u25BE";
|
|
24845
|
+
this.#arrow.className = "arrow choice-toggle";
|
|
24688
24846
|
this.#arrow.setAttribute("aria-label", "Open menu");
|
|
24689
24847
|
this.#arrow.setAttribute("aria-haspopup", "menu");
|
|
24690
24848
|
this.#arrow.setAttribute("aria-expanded", "false");
|
|
@@ -24860,6 +25018,7 @@ function validationContext(binding) {
|
|
|
24860
25018
|
return {
|
|
24861
25019
|
isDecimal: isDecimal2,
|
|
24862
25020
|
invoke,
|
|
25021
|
+
callLogic: (method, keywords) => callLogic(binding.runtime, node, method, keywords),
|
|
24863
25022
|
remote: (method, keywords, signal) => app.rpc.call("data", method, keywords, { signal }),
|
|
24864
25023
|
reportError: (error, title) => {
|
|
24865
25024
|
if (!binding.closed) binding.runtime.reportError(error, title);
|
|
@@ -24915,6 +25074,11 @@ var EditingSession = class {
|
|
|
24915
25074
|
this.retainedFields = /* @__PURE__ */ new Map();
|
|
24916
25075
|
this.listeners = /* @__PURE__ */ new Set();
|
|
24917
25076
|
this.navigators = /* @__PURE__ */ new Set();
|
|
25077
|
+
this.validationSources = /* @__PURE__ */ new Set();
|
|
25078
|
+
this.validationDependencies = /* @__PURE__ */ new Map();
|
|
25079
|
+
this.validationRevision = 0;
|
|
25080
|
+
this.validatedRevision = -1;
|
|
25081
|
+
this.fullValidation = null;
|
|
24918
25082
|
if (!(this.data instanceof Bag)) throw new TypeError("A form requires a Bag at its datapath.");
|
|
24919
25083
|
this.registers.setItem("baseline", copy(this.data));
|
|
24920
25084
|
for (const name of ["changes", "errors", "pending", "drafts"]) this.registers.setItem(name, new Bag());
|
|
@@ -25016,7 +25180,7 @@ var EditingSession = class {
|
|
|
25016
25180
|
}
|
|
25017
25181
|
get status() {
|
|
25018
25182
|
const dirty = this.registers.getItem("changes").length > 0;
|
|
25019
|
-
const pending = this.registers.getItem("pending").length > 0;
|
|
25183
|
+
const pending = this.fullValidation !== null || this.registers.getItem("pending").length > 0;
|
|
25020
25184
|
const invalid = this.registers.getItem("errors").length > 0;
|
|
25021
25185
|
const incomplete = this.registers.getItem("drafts").length > 0;
|
|
25022
25186
|
return {
|
|
@@ -25030,27 +25194,8 @@ var EditingSession = class {
|
|
|
25030
25194
|
register(adapter) {
|
|
25031
25195
|
const node = adapter.node;
|
|
25032
25196
|
this.fields.set(node, adapter);
|
|
25033
|
-
|
|
25034
|
-
|
|
25035
|
-
field = {
|
|
25036
|
-
node,
|
|
25037
|
-
binding: adapter.binding,
|
|
25038
|
-
context: validationContext(adapter.binding),
|
|
25039
|
-
run: new ValidationRun(),
|
|
25040
|
-
execute: adapter.element.validationExecutor,
|
|
25041
|
-
checkValue: adapter.element.validationValueCheck(),
|
|
25042
|
-
path: fieldPath(node),
|
|
25043
|
-
rules: null,
|
|
25044
|
-
value: void 0,
|
|
25045
|
-
target: null,
|
|
25046
|
-
result: null,
|
|
25047
|
-
selection: adapter.element.validationSelection()
|
|
25048
|
-
};
|
|
25049
|
-
this.validations.set(node, field);
|
|
25050
|
-
adapter.binding.editingSession = this;
|
|
25051
|
-
field.release = adapter.binding.track(() => this.forgetField(node));
|
|
25052
|
-
this.refreshField(node);
|
|
25053
|
-
}
|
|
25197
|
+
const field = this.registerField(node, adapter.element.constructor);
|
|
25198
|
+
field.selection = adapter.element.validationSelection();
|
|
25054
25199
|
this.schedule(() => {
|
|
25055
25200
|
if (this.fields.get(node) !== adapter) return;
|
|
25056
25201
|
const draft = this.registers.getItem("drafts").getNode(key(node));
|
|
@@ -25067,6 +25212,118 @@ var EditingSession = class {
|
|
|
25067
25212
|
this.fields.delete(node);
|
|
25068
25213
|
};
|
|
25069
25214
|
}
|
|
25215
|
+
/** A real Source declaration can validate without an element or ControlAdapter. */
|
|
25216
|
+
registerField(node, component, schedule = true) {
|
|
25217
|
+
let field = this.validations.get(node);
|
|
25218
|
+
if (field) return field;
|
|
25219
|
+
if (!component.validationExecutor) throw new TypeError("Grid editors require shared input validation.");
|
|
25220
|
+
const binding = this.runtime.bindingFor(node), context = validationContext(binding);
|
|
25221
|
+
field = {
|
|
25222
|
+
node,
|
|
25223
|
+
binding,
|
|
25224
|
+
context,
|
|
25225
|
+
component,
|
|
25226
|
+
run: new ValidationRun(),
|
|
25227
|
+
execute: component.validationExecutor,
|
|
25228
|
+
checkValue: component.validationValueCheck(context),
|
|
25229
|
+
path: fieldPath(node),
|
|
25230
|
+
rules: null,
|
|
25231
|
+
value: void 0,
|
|
25232
|
+
target: null,
|
|
25233
|
+
result: null,
|
|
25234
|
+
selection: null
|
|
25235
|
+
};
|
|
25236
|
+
this.validations.set(node, field);
|
|
25237
|
+
binding.editingSession = this;
|
|
25238
|
+
field.release = binding.track(() => this.forgetField(node));
|
|
25239
|
+
this.refreshField(node, schedule);
|
|
25240
|
+
return field;
|
|
25241
|
+
}
|
|
25242
|
+
registerValidationSource(fields) {
|
|
25243
|
+
this.validationSources.add(fields);
|
|
25244
|
+
this.invalidateValidation();
|
|
25245
|
+
return () => {
|
|
25246
|
+
this.validationSources.delete(fields);
|
|
25247
|
+
this.invalidateValidation();
|
|
25248
|
+
};
|
|
25249
|
+
}
|
|
25250
|
+
invalidateValidation() {
|
|
25251
|
+
this.validationRevision++;
|
|
25252
|
+
if (this.fullValidation) for (const node of this.fullValidation.active) this.cancelValidation(node);
|
|
25253
|
+
}
|
|
25254
|
+
trackValidationDependency(absolute) {
|
|
25255
|
+
if (absolute === null || this.validationDependencies.has(absolute)) return;
|
|
25256
|
+
const [path, attr = null] = absolute.split("?", 2);
|
|
25257
|
+
this.validationDependencies.set(absolute, this.runtime.router.register({
|
|
25258
|
+
path,
|
|
25259
|
+
attr,
|
|
25260
|
+
subtree: true,
|
|
25261
|
+
recipient: { receive: () => this.invalidateValidation() }
|
|
25262
|
+
}));
|
|
25263
|
+
}
|
|
25264
|
+
clearValidationDependencies() {
|
|
25265
|
+
for (const registration of this.validationDependencies.values()) registration.close();
|
|
25266
|
+
this.validationDependencies.clear();
|
|
25267
|
+
}
|
|
25268
|
+
/** Validate the complete declared scope. Bounded work keeps remote checks and UI responsive. */
|
|
25269
|
+
validate() {
|
|
25270
|
+
if (this.disposed) return Promise.resolve(false);
|
|
25271
|
+
if (this.fullValidation) return this.fullValidation.promise;
|
|
25272
|
+
for (const adapter of this.fields.values()) if (Object.hasOwn(adapter.node, "formDraft")) adapter.commit();
|
|
25273
|
+
this.clearValidationDependencies();
|
|
25274
|
+
const pass = { revision: this.validationRevision, promise: null, active: /* @__PURE__ */ new Set(), failed: false, complete: true };
|
|
25275
|
+
this.fullValidation = pass;
|
|
25276
|
+
this.notify();
|
|
25277
|
+
const fields = this.validationFields();
|
|
25278
|
+
const current = () => !this.disposed && !pass.failed && pass.revision === this.validationRevision;
|
|
25279
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
25280
|
+
const worker = async () => {
|
|
25281
|
+
let count = 0;
|
|
25282
|
+
while (current()) {
|
|
25283
|
+
const next = fields.next();
|
|
25284
|
+
if (next.done) return;
|
|
25285
|
+
const { node, release } = next.value;
|
|
25286
|
+
try {
|
|
25287
|
+
if (seen.has(node)) continue;
|
|
25288
|
+
seen.add(node);
|
|
25289
|
+
for (const [name, pointer] of node.pointers()) if (name !== "value") {
|
|
25290
|
+
this.trackValidationDependency((name === "datapath" ? node.parentNode : node).absDatapath(pointer));
|
|
25291
|
+
}
|
|
25292
|
+
pass.active.add(node);
|
|
25293
|
+
const outcome = await this.validateField(node);
|
|
25294
|
+
if (!outcome?.ok) pass.complete = false;
|
|
25295
|
+
} finally {
|
|
25296
|
+
pass.active.delete(node);
|
|
25297
|
+
release();
|
|
25298
|
+
}
|
|
25299
|
+
if (++count % 20 === 0) await new Promise((resolve) => setTimeout(resolve, 0));
|
|
25300
|
+
}
|
|
25301
|
+
};
|
|
25302
|
+
pass.promise = Promise.resolve().then(async () => {
|
|
25303
|
+
const outcomes = await Promise.allSettled(Array.from({ length: 8 }, () => worker().catch((error) => {
|
|
25304
|
+
pass.failed = true;
|
|
25305
|
+
for (const node of pass.active) this.cancelValidation(node);
|
|
25306
|
+
throw error;
|
|
25307
|
+
})));
|
|
25308
|
+
const failure2 = outcomes.find((outcome) => outcome.status === "rejected");
|
|
25309
|
+
if (failure2) throw failure2.reason;
|
|
25310
|
+
if (!current()) return false;
|
|
25311
|
+
const valid = pass.complete && this.status.valid && this.registers.getItem("pending").length === 0;
|
|
25312
|
+
if (valid) this.validatedRevision = this.validationRevision;
|
|
25313
|
+
return valid;
|
|
25314
|
+
}).finally(() => {
|
|
25315
|
+
fields.return();
|
|
25316
|
+
this.fullValidation = null;
|
|
25317
|
+
this.notify();
|
|
25318
|
+
});
|
|
25319
|
+
return pass.promise;
|
|
25320
|
+
}
|
|
25321
|
+
*validationFields() {
|
|
25322
|
+
const existing = [...this.validations.keys()];
|
|
25323
|
+
for (const fields of this.validationSources) yield* fields();
|
|
25324
|
+
for (const node of existing) if (this.validations.has(node)) yield { node, release: () => {
|
|
25325
|
+
} };
|
|
25326
|
+
}
|
|
25070
25327
|
forgetField(node) {
|
|
25071
25328
|
const field = this.validations.get(node);
|
|
25072
25329
|
if (!field) return;
|
|
@@ -25089,16 +25346,18 @@ var EditingSession = class {
|
|
|
25089
25346
|
delete node.formDraft;
|
|
25090
25347
|
this.notify();
|
|
25091
25348
|
}
|
|
25092
|
-
refreshField(node) {
|
|
25349
|
+
refreshField(node, schedule = true) {
|
|
25093
25350
|
const field = this.validations.get(node);
|
|
25094
25351
|
if (!field || this.disposed || this.writing) return;
|
|
25095
25352
|
const [, attrs] = node.rootBuilder.runtimeValues(node);
|
|
25096
|
-
const resolved2 = this.runtime.renderer.evaluateExpressions(node, attrs);
|
|
25353
|
+
const resolved2 = field.component.validationParameters(this.runtime.renderer.evaluateExpressions(node, attrs));
|
|
25097
25354
|
const rules = Object.fromEntries(Object.entries(resolved2).filter(([name]) => name.startsWith("validate_")));
|
|
25355
|
+
const configuration = toTytx(Object.fromEntries(Object.entries(resolved2).filter(([name]) => name !== "value")));
|
|
25098
25356
|
const path = fieldPath(node), target = this.runtime.gramlot.data.getNode(path.split("?")[0]);
|
|
25099
25357
|
const value = node.getRelativeData(node.getAttr("value"));
|
|
25100
25358
|
const dataChanged = field.path !== path || field.target !== target || !same(field.value, value);
|
|
25101
|
-
if (!dataChanged &&
|
|
25359
|
+
if (!dataChanged && field.configuration === configuration) return;
|
|
25360
|
+
if (field.rules !== null) this.invalidateValidation();
|
|
25102
25361
|
this.cancelValidation(node);
|
|
25103
25362
|
if (field.path !== path) {
|
|
25104
25363
|
for (const name of ["errors", "pending", "drafts"]) {
|
|
@@ -25106,9 +25365,17 @@ var EditingSession = class {
|
|
|
25106
25365
|
if (bag.getNode(encoded(field.path))) bag.popNode(encoded(field.path));
|
|
25107
25366
|
}
|
|
25108
25367
|
}
|
|
25109
|
-
Object.assign(field, {
|
|
25368
|
+
Object.assign(field, {
|
|
25369
|
+
path,
|
|
25370
|
+
target,
|
|
25371
|
+
value,
|
|
25372
|
+
rules,
|
|
25373
|
+
configuration,
|
|
25374
|
+
result: null,
|
|
25375
|
+
selection: field.component.validationSelection(resolved2, field.context)
|
|
25376
|
+
});
|
|
25110
25377
|
if (dataChanged) this.clearDraft(node);
|
|
25111
|
-
this.scheduleField(node);
|
|
25378
|
+
if (schedule) this.scheduleField(node);
|
|
25112
25379
|
}
|
|
25113
25380
|
cancelValidation(node) {
|
|
25114
25381
|
this.validations.get(node)?.run.cancel();
|
|
@@ -25131,6 +25398,7 @@ var EditingSession = class {
|
|
|
25131
25398
|
for (const other of this.validations.keys()) if (other !== node) this.refreshField(other);
|
|
25132
25399
|
}
|
|
25133
25400
|
validateCandidate(node, value, selection) {
|
|
25401
|
+
this.invalidateValidation();
|
|
25134
25402
|
this.cancelValidation(node);
|
|
25135
25403
|
this.writeCandidate(node, value);
|
|
25136
25404
|
const field = this.validations.get(node);
|
|
@@ -25197,6 +25465,7 @@ var EditingSession = class {
|
|
|
25197
25465
|
this.notify();
|
|
25198
25466
|
}
|
|
25199
25467
|
draft(node, text3) {
|
|
25468
|
+
this.invalidateValidation();
|
|
25200
25469
|
this.cancelValidation(node);
|
|
25201
25470
|
node.formDraft = text3;
|
|
25202
25471
|
this.set("drafts", node, text3);
|
|
@@ -25244,6 +25513,7 @@ var EditingSession = class {
|
|
|
25244
25513
|
if (this.disposed) return;
|
|
25245
25514
|
this.updateChanges(change.path);
|
|
25246
25515
|
if (this.writing) return;
|
|
25516
|
+
this.invalidateValidation();
|
|
25247
25517
|
for (const node of this.validations.keys()) this.refreshField(node);
|
|
25248
25518
|
}
|
|
25249
25519
|
updateChanges(changedPath = null) {
|
|
@@ -25311,6 +25581,7 @@ var EditingSession = class {
|
|
|
25311
25581
|
if (Object.hasOwn(adapter.node, "formDraft")) adapter.commit();
|
|
25312
25582
|
}
|
|
25313
25583
|
if (!this.status.valid || this.status.pending) return false;
|
|
25584
|
+
if (this.validationSources.size && this.validatedRevision !== this.validationRevision) return false;
|
|
25314
25585
|
this.registers.setItem("baseline", copy(this.data));
|
|
25315
25586
|
this.updateChanges();
|
|
25316
25587
|
return true;
|
|
@@ -25323,6 +25594,7 @@ var EditingSession = class {
|
|
|
25323
25594
|
}
|
|
25324
25595
|
restore() {
|
|
25325
25596
|
if (this.disposed) return;
|
|
25597
|
+
this.invalidateValidation();
|
|
25326
25598
|
for (const node of this.validations.keys()) this.cancelValidation(node);
|
|
25327
25599
|
for (const adapter of this.fields.values()) {
|
|
25328
25600
|
adapter.element.cancelValidation();
|
|
@@ -25346,6 +25618,8 @@ var EditingSession = class {
|
|
|
25346
25618
|
this.retainedFields.clear();
|
|
25347
25619
|
this.listeners.clear();
|
|
25348
25620
|
this.navigators.clear();
|
|
25621
|
+
this.validationSources.clear();
|
|
25622
|
+
this.clearValidationDependencies();
|
|
25349
25623
|
}
|
|
25350
25624
|
};
|
|
25351
25625
|
|
|
@@ -25535,6 +25809,23 @@ function isExpression2(value) {
|
|
|
25535
25809
|
}
|
|
25536
25810
|
var GramlotBuilderBagNode = class extends SourceBagNode {
|
|
25537
25811
|
#formState = null;
|
|
25812
|
+
#treeStore = null;
|
|
25813
|
+
/** An externally owned Bag attached to this tree's Source node. */
|
|
25814
|
+
get treeStore() {
|
|
25815
|
+
return this.#treeStore;
|
|
25816
|
+
}
|
|
25817
|
+
setTreeStore(bag) {
|
|
25818
|
+
if (this.nodeTag !== "tree") throw new TypeError("setTreeStore requires a tree Source node");
|
|
25819
|
+
if (bag !== null && !(bag instanceof Bag)) throw new TypeError("setTreeStore requires a Bag or null");
|
|
25820
|
+
if (bag === this.#treeStore) return;
|
|
25821
|
+
this.#treeStore = bag;
|
|
25822
|
+
const runtime = this.rootBuilder.binding;
|
|
25823
|
+
const binding = runtime?.bindingFor(this);
|
|
25824
|
+
if (binding && !binding.closed) {
|
|
25825
|
+
binding.rebind();
|
|
25826
|
+
if (runtime.renderer.attached(this)) runtime.renderer.project(this);
|
|
25827
|
+
}
|
|
25828
|
+
}
|
|
25538
25829
|
/** The local form lifecycle owned by the nearest marked Source ancestor. */
|
|
25539
25830
|
get formState() {
|
|
25540
25831
|
for (let owner = this; owner; owner = owner.parentNode) {
|
|
@@ -25578,6 +25869,12 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
|
|
|
25578
25869
|
}
|
|
25579
25870
|
return (attrs = {}) => this.builder.wrapSource(this.builder.commandOnNode(this, "grid", null, attrs));
|
|
25580
25871
|
}
|
|
25872
|
+
get toolbar() {
|
|
25873
|
+
if (this.nodeTag !== "framePane") throw new TypeError("toolbar accessor requires framePane");
|
|
25874
|
+
const bar = this.staticValue instanceof SourceBag ? this.staticValue.getNode("top.bar") : null;
|
|
25875
|
+
if (!bar || bar.nodeTag !== "menu") throw new TypeError("This frame has no toolbar");
|
|
25876
|
+
return this.builder.wrapSource(bar);
|
|
25877
|
+
}
|
|
25581
25878
|
get top() {
|
|
25582
25879
|
return this.frameRegion("top");
|
|
25583
25880
|
}
|
|
@@ -26755,10 +27052,21 @@ var GramlotBuilder = class _GramlotBuilder extends HtmlBuilder {
|
|
|
26755
27052
|
this.defineGrammar(buttons_default.toDocument());
|
|
26756
27053
|
}
|
|
26757
27054
|
/** Compose real Source nodes; frame/grid/menu retain their existing runtime owners. */
|
|
26758
|
-
frameGrid(parent, { storepath, rowMode, structpath, searchOn = false, ...attrs } = {}) {
|
|
27055
|
+
frameGrid(parent, { storepath, rowMode, structpath, searchOn = false, searchHelp = false, chart = false, ...attrs } = {}) {
|
|
26759
27056
|
for (const tag2 of ["framePane", "grid"]) {
|
|
26760
27057
|
if (!this.schemaTag(tag2)) throw new TypeError(`frameGrid requires the ${tag2} collection`);
|
|
26761
27058
|
}
|
|
27059
|
+
const chartOptions = {};
|
|
27060
|
+
for (const key2 of Object.keys(attrs)) if (key2.startsWith("chart_")) {
|
|
27061
|
+
chartOptions[key2.slice(6)] = attrs[key2];
|
|
27062
|
+
delete attrs[key2];
|
|
27063
|
+
}
|
|
27064
|
+
if (chart !== false) {
|
|
27065
|
+
if (chart !== true && (typeof chart !== "string" || !chart)) throw new TypeError("chart requires a boolean or chart type");
|
|
27066
|
+
if (!attrs.datapath) throw new TypeError("A chart frameGrid requires its own datapath");
|
|
27067
|
+
if (!this.schemaTag("chartPane")) throw new TypeError("frameGrid requires the chartPane collection");
|
|
27068
|
+
if (typeof chart === "string") chartOptions.chartType = chart;
|
|
27069
|
+
} else if (Object.keys(chartOptions).length) throw new TypeError("chart_* options require chart");
|
|
26762
27070
|
const gridAttrs = {
|
|
26763
27071
|
storepath,
|
|
26764
27072
|
rowMode,
|
|
@@ -26768,11 +27076,34 @@ var GramlotBuilder = class _GramlotBuilder extends HtmlBuilder {
|
|
|
26768
27076
|
height: "100%",
|
|
26769
27077
|
width: "100%"
|
|
26770
27078
|
};
|
|
27079
|
+
if (chart !== false) gridAttrs.nodeId = randomId();
|
|
26771
27080
|
this.validateNodeValues("grid", null, gridAttrs);
|
|
26772
|
-
if (searchOn !== false) this.validateNodeValues("searchBox", null, { searchOn });
|
|
27081
|
+
if (searchOn !== false) this.validateNodeValues("searchBox", null, { searchOn, searchHelp });
|
|
26773
27082
|
const frame = parent.framePane(attrs);
|
|
26774
27083
|
frame.center.grid(gridAttrs);
|
|
26775
|
-
|
|
27084
|
+
const bar = frame.top.menu({ presentation: "bar", node_label: "bar", aria_label: "Grid toolbar", class: "gramlot-grid-toolbar" });
|
|
27085
|
+
if (searchOn !== false) bar.menuline({ group: true, node_label: "search", class: "gramlot-grid-search" }).searchBox({ searchOn, searchHelp });
|
|
27086
|
+
if (chart !== false) {
|
|
27087
|
+
bar.menuline({ caption: "Chart", icon: "\u25A5", labelPosition: "tooltip", node_label: "chart", action: "this.SET('._chart.open',true)" });
|
|
27088
|
+
const window2 = frame.center.floatingPane({
|
|
27089
|
+
title: "Chart",
|
|
27090
|
+
open: "^._chart.open",
|
|
27091
|
+
width: "820px",
|
|
27092
|
+
height: "560px",
|
|
27093
|
+
movable: true,
|
|
27094
|
+
resizable: true,
|
|
27095
|
+
maximizable: true,
|
|
27096
|
+
node_label: "chartWindow"
|
|
27097
|
+
});
|
|
27098
|
+
window2.frame.center.chartPane({
|
|
27099
|
+
storepath,
|
|
27100
|
+
rowMode,
|
|
27101
|
+
gridId: gridAttrs.nodeId,
|
|
27102
|
+
configpath: "._chart",
|
|
27103
|
+
configDefaults: new Bag(chartOptions),
|
|
27104
|
+
height: "100%"
|
|
27105
|
+
});
|
|
27106
|
+
}
|
|
26776
27107
|
return frame;
|
|
26777
27108
|
}
|
|
26778
27109
|
/** Tag prefixes of the parent dialects, from the `_name` of the classes above GramlotBuilder. */
|
|
@@ -27590,6 +27921,14 @@ function componentContext(adapter) {
|
|
|
27590
27921
|
callLogic: (name, keywords) => callLogic(binding.runtime, node, name, keywords),
|
|
27591
27922
|
format: (value, options) => app.format(value, options),
|
|
27592
27923
|
...validationContext(binding),
|
|
27924
|
+
selectionDisplay: (caption, value) => {
|
|
27925
|
+
if (binding.closed) return;
|
|
27926
|
+
const pointer = node.getAttr("value");
|
|
27927
|
+
if (node.pointerType(pointer) !== "^" || pointer.includes("?") || !Object.is(node.getRelativeData(pointer), value)) return;
|
|
27928
|
+
const path = pointer.slice(1) + "?_displayedValue";
|
|
27929
|
+
if (node.getRelativeData(path) !== caption) node.setRelativeData(path, caption);
|
|
27930
|
+
},
|
|
27931
|
+
periodOutput: (path, value) => node.setRelativeData(path, value),
|
|
27593
27932
|
selectionOutputs: ({ selectedCaption, selectedRecord, fields }, row) => {
|
|
27594
27933
|
if (binding.closed) return;
|
|
27595
27934
|
if (selectedCaption) node.setRelativeData(selectedCaption, row?.caption ?? null);
|
|
@@ -27761,6 +28100,10 @@ var HtmlElement = class {
|
|
|
27761
28100
|
const controlBox = document.createElement("div");
|
|
27762
28101
|
controlBox.append(element);
|
|
27763
28102
|
record2.labelbox = createLabelbox(document, controlBox);
|
|
28103
|
+
record2.labelbox.choose = (value) => {
|
|
28104
|
+
if (node.pointerType(node.getAttr("lbl_value"))) this.writeParameter(node, "lbl_value", value);
|
|
28105
|
+
else node.setAttr({ lbl_value: value });
|
|
28106
|
+
};
|
|
27764
28107
|
record2.presentation = record2.labelbox.box;
|
|
27765
28108
|
record2.labelId = `gramlot-label-${randomId()}`;
|
|
27766
28109
|
record2.controlId = `gramlot-control-${randomId()}`;
|
|
@@ -27834,7 +28177,10 @@ var HtmlElement = class {
|
|
|
27834
28177
|
}
|
|
27835
28178
|
if (record2.labelbox) {
|
|
27836
28179
|
record2.labelbox.box.style.visibility = "";
|
|
27837
|
-
|
|
28180
|
+
const parameters2 = this.definition(node).meta.gramlot_component?.parameters ?? {};
|
|
28181
|
+
const defaults = Object.fromEntries(Object.entries(parameters2).filter(([name, spec]) => name.startsWith("lbl_") && Object.hasOwn(spec, "default")).map(([name, spec]) => [name, spec.default]));
|
|
28182
|
+
if (attrs.lbl_variant === "card" && attrs.lbl_position == null) delete defaults.lbl_position;
|
|
28183
|
+
projectLabelbox(record2.labelbox, { ...defaults, ...attrs }, adapt);
|
|
27838
28184
|
}
|
|
27839
28185
|
if (this.definition(node).meta.gramlot_component) {
|
|
27840
28186
|
if (this.definition(node).meta.gramlot_component.bagStore) {
|
|
@@ -28479,6 +28825,53 @@ var NativeEventBinding = class {
|
|
|
28479
28825
|
}
|
|
28480
28826
|
};
|
|
28481
28827
|
|
|
28828
|
+
// src/stores/column-filter.js
|
|
28829
|
+
function columnValue(value) {
|
|
28830
|
+
if (value == null || value === "") return null;
|
|
28831
|
+
if (typeof value === "string" || typeof value === "boolean" || typeof value === "number" && Number.isFinite(value) || value instanceof Date && Number.isFinite(value.getTime()) || isDecimal2(value) && value.isFinite()) return value;
|
|
28832
|
+
throw new TypeError("Column filters require loaded scalar values");
|
|
28833
|
+
}
|
|
28834
|
+
function columnValueKey(value) {
|
|
28835
|
+
return toTytx(columnValue(value));
|
|
28836
|
+
}
|
|
28837
|
+
function columnSelection(values) {
|
|
28838
|
+
if (!Array.isArray(values)) throw new TypeError("Column selection requires an array or null");
|
|
28839
|
+
return Object.freeze([...new Map(values.map((value) => {
|
|
28840
|
+
const key2 = columnValueKey(value);
|
|
28841
|
+
return [key2, fromTytx(key2)];
|
|
28842
|
+
})).values()]);
|
|
28843
|
+
}
|
|
28844
|
+
function columnDateRange(range) {
|
|
28845
|
+
if (range === null) return null;
|
|
28846
|
+
const { from, to, dtype, timeZone } = range;
|
|
28847
|
+
if (!["D", "DH", "DHZ"].includes(dtype)) throw new TypeError("Date range requires a date column");
|
|
28848
|
+
for (const value of [from, to]) {
|
|
28849
|
+
if (value !== null && (!(value instanceof Date) || !Number.isFinite(value.getTime()) || value.getUTCHours() || value.getUTCMinutes() || value.getUTCSeconds() || value.getUTCMilliseconds())) {
|
|
28850
|
+
throw new TypeError("Date bounds require civil dates");
|
|
28851
|
+
}
|
|
28852
|
+
}
|
|
28853
|
+
if (from && to && from > to) throw new RangeError("From must not be after To.");
|
|
28854
|
+
if (dtype === "DHZ" && !timeZone) throw new TypeError("DHZ requires a timeZone");
|
|
28855
|
+
return from || to ? Object.freeze({
|
|
28856
|
+
from: from?.toISOString().slice(0, 10) ?? null,
|
|
28857
|
+
to: to?.toISOString().slice(0, 10) ?? null,
|
|
28858
|
+
dtype,
|
|
28859
|
+
timeZone
|
|
28860
|
+
}) : null;
|
|
28861
|
+
}
|
|
28862
|
+
function columnDateMatches(value, range) {
|
|
28863
|
+
if (!range) return true;
|
|
28864
|
+
if (value == null || value === "") return false;
|
|
28865
|
+
if (!(value instanceof Date) || !Number.isFinite(value.getTime())) throw new TypeError("Date range requires date values");
|
|
28866
|
+
let day;
|
|
28867
|
+
if (range.dtype === "DHZ") {
|
|
28868
|
+
const parts2 = new Intl.DateTimeFormat("en", { timeZone: range.timeZone, year: "numeric", month: "2-digit", day: "2-digit" }).formatToParts(value);
|
|
28869
|
+
const part = (type) => parts2.find((item) => item.type === type).value;
|
|
28870
|
+
day = `${part("year")}-${part("month")}-${part("day")}`;
|
|
28871
|
+
} else day = value.toISOString().slice(0, 10);
|
|
28872
|
+
return (!range.from || day >= range.from) && (!range.to || day <= range.to);
|
|
28873
|
+
}
|
|
28874
|
+
|
|
28482
28875
|
// node_modules/@genrojs/toolbox/js/src/dates/civil.js
|
|
28483
28876
|
function daysInMonth(year, month) {
|
|
28484
28877
|
if (month === 2) return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28;
|
|
@@ -28987,7 +29380,8 @@ function compileFilter(filter) {
|
|
|
28987
29380
|
if (typeof value !== "string" || !Array.isArray(columns) || !columns.length || columns.some((field) => typeof field !== "string" || !field || field === "rowidx") || !["T", "L", "R", "N", "D"].includes(dtype)) throw new TypeError("Invalid collection filter");
|
|
28988
29381
|
if (!value.trim()) return null;
|
|
28989
29382
|
if (dtype === "T") {
|
|
28990
|
-
const
|
|
29383
|
+
const pattern = filter.literal === true ? value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : value;
|
|
29384
|
+
const expression = new RegExp(pattern, "i");
|
|
28991
29385
|
return (read) => expression.test(columns.map((field) => searchText(read(field), locale, filter.timeZone)).join(" "));
|
|
28992
29386
|
}
|
|
28993
29387
|
if (columns.length !== 1) throw new TypeError("Typed filters require one column");
|
|
@@ -29056,6 +29450,19 @@ function parseNumber(text3, locale) {
|
|
|
29056
29450
|
return result;
|
|
29057
29451
|
}
|
|
29058
29452
|
|
|
29453
|
+
// src/stores/id-set.js
|
|
29454
|
+
function containsId(value, id) {
|
|
29455
|
+
return ("," + value + ",").includes("," + id + ",");
|
|
29456
|
+
}
|
|
29457
|
+
function requireIdSet(value) {
|
|
29458
|
+
if (typeof value !== "string") throw new TypeError("grid checked must refer to a string (empty string for an empty set)");
|
|
29459
|
+
return value;
|
|
29460
|
+
}
|
|
29461
|
+
function requireId(id) {
|
|
29462
|
+
if (typeof id !== "string" || !id || id.includes(",")) throw new TypeError("grid checkedField requires nonempty text IDs without commas");
|
|
29463
|
+
return id;
|
|
29464
|
+
}
|
|
29465
|
+
|
|
29059
29466
|
// src/stores/bag-collection-store.js
|
|
29060
29467
|
var BagCollectionStore = class {
|
|
29061
29468
|
#listeners = /* @__PURE__ */ new Set();
|
|
@@ -29115,8 +29522,7 @@ var BagCollectionView = class {
|
|
|
29115
29522
|
#listeners = /* @__PURE__ */ new Set();
|
|
29116
29523
|
#indices = /* @__PURE__ */ new Map();
|
|
29117
29524
|
#sortedBy = "";
|
|
29118
|
-
#
|
|
29119
|
-
#predicate = null;
|
|
29525
|
+
#filters = /* @__PURE__ */ new Map();
|
|
29120
29526
|
#filtered = null;
|
|
29121
29527
|
constructor(store) {
|
|
29122
29528
|
this.bindStore(store);
|
|
@@ -29134,7 +29540,19 @@ var BagCollectionView = class {
|
|
|
29134
29540
|
return parseSort(this.#sortedBy);
|
|
29135
29541
|
}
|
|
29136
29542
|
get filter() {
|
|
29137
|
-
return this.#
|
|
29543
|
+
return this.#filters.get("search")?.definition ?? null;
|
|
29544
|
+
}
|
|
29545
|
+
get filterSignature() {
|
|
29546
|
+
return JSON.stringify([...this.#filters].map(([name, { definition }]) => [name, definition]));
|
|
29547
|
+
}
|
|
29548
|
+
/** Immutable accepted entries cross runtime/collection bundle boundaries. */
|
|
29549
|
+
get filterContributions() {
|
|
29550
|
+
return Object.freeze([...this.#filters].map(([name, entry]) => Object.freeze([name, Object.freeze({ ...entry })])));
|
|
29551
|
+
}
|
|
29552
|
+
/** Copy immutable accepted criteria into another Source-owned view, never rows. */
|
|
29553
|
+
copyFiltersFrom(view) {
|
|
29554
|
+
if (this.filterSignature === view.filterSignature) return;
|
|
29555
|
+
this.#commit(this.#orderedNodes(), this.#sortedBy, new Map(view.filterContributions));
|
|
29138
29556
|
}
|
|
29139
29557
|
get filtered() {
|
|
29140
29558
|
return this.#filtered === null ? null : [...this.#filtered];
|
|
@@ -29175,39 +29593,88 @@ var BagCollectionView = class {
|
|
|
29175
29593
|
return this.#store.getRows().toSorted((a, b) => (this.#indices.get(a) ?? Infinity) - (this.#indices.get(b) ?? Infinity));
|
|
29176
29594
|
}
|
|
29177
29595
|
synchronize(change = { full: true, rows: [] }) {
|
|
29178
|
-
if (!change.full && !this.#sortedBy && !this.#
|
|
29596
|
+
if (!change.full && !this.#sortedBy && !this.#filters.size) {
|
|
29179
29597
|
publishCollection(this.#listeners, change);
|
|
29180
29598
|
return;
|
|
29181
29599
|
}
|
|
29182
|
-
this.#commit(this.#sorted(this.#orderedNodes(), this.criteria), this.#sortedBy, this.#
|
|
29600
|
+
this.#commit(this.#sorted(this.#orderedNodes(), this.criteria), this.#sortedBy, this.#filters, change);
|
|
29183
29601
|
}
|
|
29184
29602
|
sort(sortedBy) {
|
|
29185
29603
|
const nodes = this.#sorted(this.#orderedNodes(), parseSort(sortedBy));
|
|
29186
|
-
this.#commit(nodes, sortedBy, this.#
|
|
29604
|
+
this.#commit(nodes, sortedBy, this.#filters);
|
|
29187
29605
|
}
|
|
29188
29606
|
moveRow(node, target, after = false) {
|
|
29189
29607
|
if (node === target || node.parentBag !== this.bag || target.parentBag !== this.bag) return;
|
|
29190
29608
|
const nodes = this.getRows(false);
|
|
29191
29609
|
nodes.splice(nodes.indexOf(node), 1);
|
|
29192
29610
|
nodes.splice(nodes.indexOf(target) + Number(after), 0, node);
|
|
29193
|
-
this.#commit(nodes, "", this.#
|
|
29611
|
+
this.#commit(nodes, "", this.#filters);
|
|
29194
29612
|
}
|
|
29195
|
-
applyFilter(filter) {
|
|
29613
|
+
applyFilter(filter, contribution2 = "search") {
|
|
29614
|
+
if (!["base", "search"].includes(contribution2)) throw new TypeError("Unknown collection filter contribution");
|
|
29196
29615
|
const definition = filter === null ? null : Object.freeze({ ...filter, columns: Object.freeze([...filter.columns]) });
|
|
29197
|
-
|
|
29198
|
-
this.#commit(this.#orderedNodes(), this.#sortedBy, definition, predicate);
|
|
29616
|
+
this.#applyContribution(contribution2, definition, compileFilter(definition));
|
|
29199
29617
|
}
|
|
29200
|
-
|
|
29201
|
-
const
|
|
29202
|
-
|
|
29618
|
+
applySetFilter(sets) {
|
|
29619
|
+
const definition = sets === null ? null : Object.freeze(sets.map(({ field, value }) => {
|
|
29620
|
+
if (typeof field !== "string" || !field) throw new TypeError("Set filter requires an identity field");
|
|
29621
|
+
requireIdSet(value);
|
|
29622
|
+
return Object.freeze({ field, value });
|
|
29623
|
+
}));
|
|
29624
|
+
const predicate = definition === null ? null : (read) => definition.every(({ field, value }) => containsId(value, requireId(read(field))));
|
|
29625
|
+
this.#applyContribution("sets", definition, predicate);
|
|
29626
|
+
}
|
|
29627
|
+
columnFilter(field) {
|
|
29628
|
+
return this.#filters.get(`column:${field}`)?.definition.values ?? null;
|
|
29629
|
+
}
|
|
29630
|
+
columnRange(field) {
|
|
29631
|
+
const range = this.#filters.get(`column:${field}`)?.definition.range;
|
|
29632
|
+
return range ? { ...range, from: range.from && /* @__PURE__ */ new Date(range.from + "T00:00:00Z"), to: range.to && /* @__PURE__ */ new Date(range.to + "T00:00:00Z") } : null;
|
|
29633
|
+
}
|
|
29634
|
+
applyColumnFilter(field, values, range = this.columnRange(field)) {
|
|
29635
|
+
range = columnDateRange(range);
|
|
29636
|
+
if (typeof field !== "string" || !field) throw new TypeError("Column filter requires a field");
|
|
29637
|
+
const selected = values === null ? null : columnSelection(values);
|
|
29638
|
+
const keys = selected?.map(columnValueKey);
|
|
29639
|
+
const definition = selected === null && range === null ? null : Object.freeze({ field, values: selected, keys: keys && Object.freeze(keys), range });
|
|
29640
|
+
const predicate = definition === null ? null : (read) => columnDateMatches(read(field), range) && (keys === void 0 || keys.includes(columnValueKey(read(field))));
|
|
29641
|
+
this.#applyContribution(`column:${field}`, definition, predicate);
|
|
29642
|
+
}
|
|
29643
|
+
columnFacets(field) {
|
|
29644
|
+
const facets = /* @__PURE__ */ new Map();
|
|
29645
|
+
const range = this.#filters.get(`column:${field}`)?.definition.range ?? null;
|
|
29646
|
+
const selected = this.columnFilter(field);
|
|
29647
|
+
const keys = selected?.map(columnValueKey);
|
|
29648
|
+
const predicates = [...this.#filters].filter(([name]) => name !== `column:${field}`).map(([, entry]) => entry.predicate).filter((predicate) => predicate !== null);
|
|
29649
|
+
for (const node of this.#orderedNodes()) {
|
|
29650
|
+
const value = columnValue(this.value(node, field)), key2 = columnValueKey(value);
|
|
29651
|
+
if (!facets.has(key2)) facets.set(key2, { key: key2, value, count: 0, selected: columnDateMatches(value, range) && (keys === void 0 || keys.includes(key2)) });
|
|
29652
|
+
if (predicates.every((predicate) => predicate((field2) => this.value(node, field2)))) facets.get(key2).count++;
|
|
29653
|
+
}
|
|
29654
|
+
for (const value of selected ?? []) {
|
|
29655
|
+
const key2 = columnValueKey(value);
|
|
29656
|
+
if (!facets.has(key2)) facets.set(key2, { key: key2, value, count: 0, selected: true });
|
|
29657
|
+
}
|
|
29658
|
+
return [...facets.values()].filter((entry) => columnDateMatches(entry.value, range));
|
|
29659
|
+
}
|
|
29660
|
+
#applyContribution(name, definition, predicate) {
|
|
29661
|
+
if (JSON.stringify(this.#filters.get(name)?.definition ?? null) === JSON.stringify(definition)) return;
|
|
29662
|
+
const filters = new Map(this.#filters);
|
|
29663
|
+
if (definition === null) filters.delete(name);
|
|
29664
|
+
else filters.set(name, { definition, predicate });
|
|
29665
|
+
this.#commit(this.#orderedNodes(), this.#sortedBy, filters);
|
|
29666
|
+
}
|
|
29667
|
+
#commit(nodes, sortedBy, filters, change = { full: false, rows: [] }) {
|
|
29668
|
+
const predicates = [...filters.values()].map((entry) => entry.predicate).filter((predicate) => predicate !== null);
|
|
29669
|
+
const filtered = predicates.length ? nodes.flatMap((node, index) => predicates.every((predicate) => predicate((field) => this.value(node, field))) ? [index] : []) : null;
|
|
29670
|
+
const full = change.full || sortedBy !== this.#sortedBy || filters !== this.#filters || nodes.length !== this.#indices.size || nodes.some((node, index) => this.#indices.get(node) !== index) || JSON.stringify(filtered) !== JSON.stringify(this.#filtered);
|
|
29203
29671
|
this.#indices = new Map(nodes.map((node, index) => [node, index]));
|
|
29204
29672
|
this.#sortedBy = sortedBy;
|
|
29205
|
-
this.#
|
|
29206
|
-
this.#predicate = predicate;
|
|
29673
|
+
this.#filters = filters;
|
|
29207
29674
|
this.#filtered = filtered;
|
|
29208
29675
|
const visible = filtered === null ? null : new Set(filtered);
|
|
29209
29676
|
const rows = full ? [] : change.rows.filter((node) => this.#indices.has(node) && (visible === null || visible.has(this.#indices.get(node))));
|
|
29210
|
-
if (full || rows.length) publishCollection(this.#listeners, { full, rows });
|
|
29677
|
+
if (full || rows.length || change.rows.length) publishCollection(this.#listeners, { full, rows });
|
|
29211
29678
|
}
|
|
29212
29679
|
#sorted(nodes, criteria) {
|
|
29213
29680
|
if (!criteria.length) return nodes;
|
|
@@ -29447,7 +29914,7 @@ var DataRouter = class {
|
|
|
29447
29914
|
|
|
29448
29915
|
// src/components/grid-structure.js
|
|
29449
29916
|
var TYPES = /* @__PURE__ */ new Set(["T", "B", "L", "R", "N", "D", "H", "DHZ"]);
|
|
29450
|
-
var COLUMN_KEYS = /* @__PURE__ */ new Set(["tag", "field", "name", "dtype", "width", "align", "format", "columnset", "white_space", "edit"]);
|
|
29917
|
+
var COLUMN_KEYS = /* @__PURE__ */ new Set(["tag", "field", "name", "title", "dtype", "width", "align", "format", "columnset", "white_space", "max_height", "edit", "check", "checked", "checkedField"]);
|
|
29451
29918
|
var GROUP_KEYS = /* @__PURE__ */ new Set(["tag", "code", "name", "background", "color"]);
|
|
29452
29919
|
var GridStructure = class {
|
|
29453
29920
|
#nodes = /* @__PURE__ */ new Map();
|
|
@@ -29484,9 +29951,19 @@ var GridStructure = class {
|
|
|
29484
29951
|
if (attrs.width != null && (typeof attrs.width !== "string" || !/^(?:\d+(?:\.\d+)?)(?:px|em|rem|ch|%)$/.test(attrs.width))) {
|
|
29485
29952
|
throw new TypeError("grid width requires a nonnegative CSS length (px, em, rem, ch or %)");
|
|
29486
29953
|
}
|
|
29954
|
+
if (attrs.max_height != null && (typeof attrs.max_height !== "string" || !/^(?:\d+(?:\.\d+)?)(?:px|em|rem)$/.test(attrs.max_height))) {
|
|
29955
|
+
throw new TypeError("grid max_height requires a nonnegative CSS length (px, em or rem)");
|
|
29956
|
+
}
|
|
29487
29957
|
if (attrs.white_space != null && !["normal", "nowrap", "pre-wrap"].includes(attrs.white_space)) throw new TypeError("grid white_space requires normal, nowrap or pre-wrap");
|
|
29488
|
-
for (const key2 of ["name", "format"]) if (attrs[key2] != null && typeof attrs[key2] !== "string") throw new TypeError(`grid ${key2} must be text`);
|
|
29958
|
+
for (const key2 of ["name", "title", "format"]) if (attrs[key2] != null && typeof attrs[key2] !== "string") throw new TypeError(`grid ${key2} must be text`);
|
|
29489
29959
|
if (attrs.edit != null && typeof attrs.edit !== "boolean" && (typeof attrs.edit !== "object" || Array.isArray(attrs.edit))) throw new TypeError("grid edit requires a boolean or editor options");
|
|
29960
|
+
if (attrs.check != null || attrs.checked != null || attrs.checkedField != null) {
|
|
29961
|
+
if (!["multiple", "single"].includes(attrs.check) || typeof attrs.checked !== "string" || !attrs.checked.startsWith("^") || attrs.checked.length < 2 || attrs.checked.includes("?")) {
|
|
29962
|
+
throw new TypeError("grid check requires single or multiple and checked=^DataPath");
|
|
29963
|
+
}
|
|
29964
|
+
requireIdentity(attrs.checkedField, "checkedField");
|
|
29965
|
+
if (attrs.edit) throw new TypeError("external check sets cannot edit row fields");
|
|
29966
|
+
}
|
|
29490
29967
|
const column = Object.freeze({
|
|
29491
29968
|
...attrs,
|
|
29492
29969
|
name: attrs.name ?? attrs.field,
|
|
@@ -29549,7 +30026,7 @@ function structureData(source) {
|
|
|
29549
30026
|
node.builder.validateNode(node);
|
|
29550
30027
|
if (node.nodeTag !== "column" || node.staticValue != null) throw new TypeError("grid column must be a scalar declaration");
|
|
29551
30028
|
const attrs = { tag: "cell" };
|
|
29552
|
-
for (const key2 of ["field", "name", "dtype", "width", "align", "format", "white_space", "edit"]) {
|
|
30029
|
+
for (const key2 of ["field", "name", "title", "dtype", "width", "align", "format", "white_space", "max_height", "edit", "check", "checked", "checkedField"]) {
|
|
29553
30030
|
if (node.getAttr(key2) != null) attrs[key2] = node.getAttr(key2);
|
|
29554
30031
|
}
|
|
29555
30032
|
const label = `cell_${attrs.field}`;
|
|
@@ -29588,7 +30065,7 @@ function validateGridDeclaration(node) {
|
|
|
29588
30065
|
function installGridStruct(node, data) {
|
|
29589
30066
|
const value = structureData(node.staticValue);
|
|
29590
30067
|
new GridStructure(value);
|
|
29591
|
-
const path = `
|
|
30068
|
+
const path = `_gramlot.grid.${crypto.randomUUID().replaceAll("-", "")}.struct`;
|
|
29592
30069
|
data.setItem(path, value, null, ">", false, true, node);
|
|
29593
30070
|
node.parentNode.setAttr({ structpath: path }, false);
|
|
29594
30071
|
node.setValue(null, false);
|
|
@@ -30847,6 +31324,7 @@ var BindingRuntime = class {
|
|
|
30847
31324
|
}
|
|
30848
31325
|
/** Resolve a tree store against the selected live root. */
|
|
30849
31326
|
treeStore(node) {
|
|
31327
|
+
if (node.treeStore !== null) return node.treeStore;
|
|
30850
31328
|
const path = node.getAttr("storepath");
|
|
30851
31329
|
if (path === "*S" || path.startsWith("*S.")) {
|
|
30852
31330
|
const root = this.renderer.source.getItem("main");
|
|
@@ -31280,6 +31758,15 @@ var NodeBinding = class {
|
|
|
31280
31758
|
const component = node._getMeta("gramlot_component");
|
|
31281
31759
|
for (const [capability, attribute] of [["bagStore", "storepath"], ["bagStruct", "structpath"]]) {
|
|
31282
31760
|
if (!component?.[capability]) continue;
|
|
31761
|
+
if (capability === "bagStore" && node.nodeTag === "tree" && node.treeStore !== null) {
|
|
31762
|
+
const store = node.treeStore;
|
|
31763
|
+
const subscription = `gramlot-tree-${randomId()}`;
|
|
31764
|
+
store.subscribe(subscription, { any: () => {
|
|
31765
|
+
if (!this.closed && this.runtime.renderer.attached(node)) this.runtime.renderer.project(node);
|
|
31766
|
+
} });
|
|
31767
|
+
this.#registrations.push({ close: () => store.unsubscribe(subscription, { any: true }) });
|
|
31768
|
+
continue;
|
|
31769
|
+
}
|
|
31283
31770
|
const value = node.getAttr(attribute);
|
|
31284
31771
|
if (typeof value !== "string" || !value || /^[\^=]/.test(value) || value.includes("?")) {
|
|
31285
31772
|
throw new TypeError(`${attribute} requires a plain Bag data path`);
|
|
@@ -31637,6 +32124,7 @@ var DragDrop = class {
|
|
|
31637
32124
|
dropEffect: policy.dropEffect,
|
|
31638
32125
|
dataAvailable: true
|
|
31639
32126
|
};
|
|
32127
|
+
if (row.placement !== void 0) context.placement = row.placement;
|
|
31640
32128
|
const accepted = policy.accepted && this.#renderer.checkDropTarget(record2.node, context) && this.#renderer.records.get(record2.node) === record2 && row.element.isConnected;
|
|
31641
32129
|
return { record: record2, element: row.element, accepted, context };
|
|
31642
32130
|
}
|
|
@@ -31812,26 +32300,26 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
|
|
|
31812
32300
|
return this.dragPreparation.prepare(node, event);
|
|
31813
32301
|
}
|
|
31814
32302
|
/** Dynamic eligibility only; cannot replace the independent type/tag/effect policy. */
|
|
31815
|
-
checkDropTarget(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }) {
|
|
32303
|
+
checkDropTarget(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, placement }) {
|
|
31816
32304
|
const record2 = this.records.get(node);
|
|
31817
32305
|
if (!record2) return false;
|
|
31818
32306
|
if (!record2.resolved.dropTargetCb) return true;
|
|
31819
32307
|
const allowed = this.html.callLogic(
|
|
31820
32308
|
node,
|
|
31821
32309
|
record2.resolved.dropTargetCb,
|
|
31822
|
-
{ dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }
|
|
32310
|
+
{ dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, ...placement === void 0 ? {} : { placement } }
|
|
31823
32311
|
);
|
|
31824
32312
|
if (typeof allowed !== "boolean") throw new TypeError("dropTargetCb must return a boolean synchronously");
|
|
31825
32313
|
return allowed;
|
|
31826
32314
|
}
|
|
31827
32315
|
/** Invoke only the general action, after acceptance and removal of data handled by typed actions. */
|
|
31828
|
-
async invokeDrop(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }) {
|
|
32316
|
+
async invokeDrop(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, placement }) {
|
|
31829
32317
|
const record2 = this.records.get(node);
|
|
31830
32318
|
if (!record2 || !record2.resolved.onDrop || Object.keys(dropValues).length === 0) return;
|
|
31831
32319
|
await this.html.callLogic(
|
|
31832
32320
|
node,
|
|
31833
32321
|
record2.resolved.onDrop,
|
|
31834
|
-
{ dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }
|
|
32322
|
+
{ dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, ...placement === void 0 ? {} : { placement } }
|
|
31835
32323
|
);
|
|
31836
32324
|
}
|
|
31837
32325
|
/** Notify origin completion independently of application-operation success. */
|
|
@@ -31956,6 +32444,7 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
|
|
|
31956
32444
|
...this.html.create(node, document, tag2, attrs, resolved2.visible ?? null)
|
|
31957
32445
|
};
|
|
31958
32446
|
this.html.compose(record2, text3, children);
|
|
32447
|
+
if (record2.labelbox) record2.cleanup.push(() => record2.labelbox.menu?.dispose());
|
|
31959
32448
|
record2.shape = ControlAdapter.shape(record2.element, resolved2);
|
|
31960
32449
|
this.records.set(node, record2);
|
|
31961
32450
|
this.elements.set(record2.element, record2);
|
|
@@ -32263,6 +32752,16 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
|
|
|
32263
32752
|
}
|
|
32264
32753
|
throw errors.length === 1 ? error : new AggregateError(errors, "Source build and cleanup failed");
|
|
32265
32754
|
}
|
|
32755
|
+
/** Mount the same Source and bindings in a new document's element realm. */
|
|
32756
|
+
mountDestination(node, destination) {
|
|
32757
|
+
const record2 = this.records.get(node);
|
|
32758
|
+
if (!record2?.presentation || destination?.nodeType !== 1)
|
|
32759
|
+
throw new TypeError("mountDestination requires a mounted element and an HTML destination");
|
|
32760
|
+
if (record2.presentation.contains(destination)) throw new Error("Destination cannot be inside the moved presentation");
|
|
32761
|
+
const parent = record2.parent;
|
|
32762
|
+
this.remove(node);
|
|
32763
|
+
return this.buildNode(node, destination, null, parent);
|
|
32764
|
+
}
|
|
32266
32765
|
assignContainer(record2, container) {
|
|
32267
32766
|
record2.container = container;
|
|
32268
32767
|
const childContainer = record2.element ?? container;
|
|
@@ -33105,23 +33604,23 @@ var DeviceHandler = class extends Handler {
|
|
|
33105
33604
|
}
|
|
33106
33605
|
installData() {
|
|
33107
33606
|
const { gramlot } = this;
|
|
33108
|
-
gramlot.data.setItem("
|
|
33109
|
-
gramlot.data.setItem("
|
|
33607
|
+
gramlot.data.setItem("_gramlot.device.database", null, { status: "idle", error: null });
|
|
33608
|
+
gramlot.data.setItem("_gramlot.device.orientation", null, { status: "idle", error: null, listening: false });
|
|
33110
33609
|
for (const name of ["gyroscope", "accelerometer"]) {
|
|
33111
33610
|
gramlot.data.setItem(
|
|
33112
|
-
`
|
|
33611
|
+
`_gramlot.device.${name}`,
|
|
33113
33612
|
null,
|
|
33114
33613
|
{ enabled: false, watching: false, status: "idle", error: null }
|
|
33115
33614
|
);
|
|
33116
|
-
gramlot.data.getNode(`
|
|
33615
|
+
gramlot.data.getNode(`_gramlot.device.${name}`).setAttr({ error: null }, false, true, false);
|
|
33117
33616
|
this.#sensors.set(name, {
|
|
33118
|
-
node: gramlot.data.getNode(`
|
|
33617
|
+
node: gramlot.data.getNode(`_gramlot.device.${name}`),
|
|
33119
33618
|
stream: null,
|
|
33120
33619
|
cleanup: Promise.resolve()
|
|
33121
33620
|
});
|
|
33122
33621
|
}
|
|
33123
33622
|
for (const name of NAMES) {
|
|
33124
|
-
const path = `
|
|
33623
|
+
const path = `_gramlot.device.${name}`;
|
|
33125
33624
|
const attrs = { status: "idle", error: null, cacheTime: name === "appinfo" ? -1 : 5 };
|
|
33126
33625
|
if (name === "location") Object.assign(attrs, { enabled: false, watching: false });
|
|
33127
33626
|
gramlot.data.setItem(path, null);
|
|
@@ -33132,54 +33631,54 @@ var DeviceHandler = class extends Handler {
|
|
|
33132
33631
|
this.resolvers.set(name, resolver);
|
|
33133
33632
|
}
|
|
33134
33633
|
gramlot.data.setItem(
|
|
33135
|
-
"
|
|
33634
|
+
"_gramlot.device.clipboard",
|
|
33136
33635
|
null,
|
|
33137
33636
|
{ status: "idle", error: null, text: "", copy: null, paste: null, operation: null }
|
|
33138
33637
|
);
|
|
33139
|
-
const clipboard = gramlot.data.getNode("
|
|
33140
|
-
gramlot.data.setItem("
|
|
33141
|
-
const camera = gramlot.data.getNode("
|
|
33142
|
-
gramlot.data.setItem("
|
|
33143
|
-
const barcode = gramlot.data.getNode("
|
|
33144
|
-
gramlot.data.setItem("
|
|
33145
|
-
const biometrics = gramlot.data.getNode("
|
|
33638
|
+
const clipboard = gramlot.data.getNode("_gramlot.device.clipboard");
|
|
33639
|
+
gramlot.data.setItem("_gramlot.device.camera", null, { status: "idle", error: null, capture: null, choose: null });
|
|
33640
|
+
const camera = gramlot.data.getNode("_gramlot.device.camera");
|
|
33641
|
+
gramlot.data.setItem("_gramlot.device.barcode", null, { status: "idle", error: null, scan: null });
|
|
33642
|
+
const barcode = gramlot.data.getNode("_gramlot.device.barcode");
|
|
33643
|
+
gramlot.data.setItem("_gramlot.device.biometrics", null, { status: "idle", error: null, verify: null });
|
|
33644
|
+
const biometrics = gramlot.data.getNode("_gramlot.device.biometrics");
|
|
33146
33645
|
const notifications = new Bag();
|
|
33147
33646
|
notifications.setItem("request", new Bag());
|
|
33148
33647
|
for (const name of ["scheduled", "received", "action"]) notifications.setItem(name, null);
|
|
33149
33648
|
gramlot.data.setItem(
|
|
33150
|
-
"
|
|
33649
|
+
"_gramlot.device.notifications",
|
|
33151
33650
|
notifications,
|
|
33152
33651
|
{ status: "idle", error: null, schedule: null, listening: false, listenerError: null }
|
|
33153
33652
|
);
|
|
33154
|
-
const notificationNode = gramlot.data.getNode("
|
|
33653
|
+
const notificationNode = gramlot.data.getNode("_gramlot.device.notifications");
|
|
33155
33654
|
const push = new Bag();
|
|
33156
33655
|
for (const name of ["registration", "received", "action"]) push.setItem(name, null);
|
|
33157
33656
|
gramlot.data.setItem(
|
|
33158
|
-
"
|
|
33657
|
+
"_gramlot.device.push",
|
|
33159
33658
|
push,
|
|
33160
33659
|
{ status: "idle", error: null, register: null, listening: false, listenerError: null }
|
|
33161
33660
|
);
|
|
33162
|
-
const pushNode = gramlot.data.getNode("
|
|
33661
|
+
const pushNode = gramlot.data.getNode("_gramlot.device.push");
|
|
33163
33662
|
const links = new Bag();
|
|
33164
33663
|
links.setItem("request", null);
|
|
33165
|
-
gramlot.data.setItem("
|
|
33664
|
+
gramlot.data.setItem("_gramlot.device.links", links, { listening: false, listenerError: null });
|
|
33166
33665
|
const shortcuts = new Bag();
|
|
33167
33666
|
shortcuts.setItem("request", null);
|
|
33168
|
-
gramlot.data.setItem("
|
|
33169
|
-
gramlot.data.setItem("
|
|
33667
|
+
gramlot.data.setItem("_gramlot.device.shortcuts", shortcuts, { listening: false, listenerError: null });
|
|
33668
|
+
gramlot.data.setItem("_gramlot.device.network", null, { status: "idle", error: null, listening: false });
|
|
33170
33669
|
const lifecycle = new Bag();
|
|
33171
33670
|
lifecycle.setItem("active", null);
|
|
33172
33671
|
lifecycle.setItem("event", null);
|
|
33173
33672
|
lifecycle.setItem("sequence", 0);
|
|
33174
|
-
gramlot.data.setItem("
|
|
33673
|
+
gramlot.data.setItem("_gramlot.device.lifecycle", lifecycle, { status: "idle", error: null, listening: false });
|
|
33175
33674
|
gramlot.data.setItem(
|
|
33176
|
-
"
|
|
33675
|
+
"_gramlot.device.haptics",
|
|
33177
33676
|
null,
|
|
33178
33677
|
{ status: "idle", error: null, impact: null, style: "medium", vibrate: null, duration: 600 }
|
|
33179
33678
|
);
|
|
33180
|
-
const haptics = gramlot.data.getNode("
|
|
33679
|
+
const haptics = gramlot.data.getNode("_gramlot.device.haptics");
|
|
33181
33680
|
gramlot.data.setItem(
|
|
33182
|
-
"
|
|
33681
|
+
"_gramlot.device.audio",
|
|
33183
33682
|
null,
|
|
33184
33683
|
{
|
|
33185
33684
|
status: "idle",
|
|
@@ -33194,7 +33693,7 @@ var DeviceHandler = class extends Handler {
|
|
|
33194
33693
|
shareActivity: null
|
|
33195
33694
|
}
|
|
33196
33695
|
);
|
|
33197
|
-
const audio = gramlot.data.getNode("
|
|
33696
|
+
const audio = gramlot.data.getNode("_gramlot.device.audio");
|
|
33198
33697
|
gramlot.data.subscribe("gramlot.device", { update: (event) => {
|
|
33199
33698
|
if (this.disposed) return;
|
|
33200
33699
|
for (const [name, sensor] of this.#sensors) {
|
|
@@ -33290,16 +33789,16 @@ var DeviceHandler = class extends Handler {
|
|
|
33290
33789
|
node.setAttr({ status: "success", error: null }, true, true, false);
|
|
33291
33790
|
});
|
|
33292
33791
|
if (provider.capabilities.includes("links")) {
|
|
33293
|
-
this.#startLinkEvents(this.gramlot.data.getNode("
|
|
33792
|
+
this.#startLinkEvents(this.gramlot.data.getNode("_gramlot.device.links"));
|
|
33294
33793
|
}
|
|
33295
33794
|
if (provider.capabilities.includes("shortcuts")) {
|
|
33296
|
-
this.#startShortcutEvents(this.gramlot.data.getNode("
|
|
33795
|
+
this.#startShortcutEvents(this.gramlot.data.getNode("_gramlot.device.shortcuts"));
|
|
33297
33796
|
}
|
|
33298
33797
|
if (provider.capabilities.includes("push")) {
|
|
33299
|
-
this.#startPushEvents(this.gramlot.data.getNode("
|
|
33798
|
+
this.#startPushEvents(this.gramlot.data.getNode("_gramlot.device.push"));
|
|
33300
33799
|
}
|
|
33301
33800
|
if (provider.capabilities.includes("notifications")) {
|
|
33302
|
-
this.#startNotificationEvents(this.gramlot.data.getNode("
|
|
33801
|
+
this.#startNotificationEvents(this.gramlot.data.getNode("_gramlot.device.notifications"));
|
|
33303
33802
|
}
|
|
33304
33803
|
}
|
|
33305
33804
|
assertLive() {
|
|
@@ -33338,7 +33837,7 @@ var DeviceHandler = class extends Handler {
|
|
|
33338
33837
|
}
|
|
33339
33838
|
// Page-owned state streams share lifetime/error handling, never public dispatch.
|
|
33340
33839
|
#startStateEvents(name, start, accept) {
|
|
33341
|
-
const node = this.gramlot.data.getNode(`
|
|
33840
|
+
const node = this.gramlot.data.getNode(`_gramlot.device.${name}`);
|
|
33342
33841
|
if (!this.provider.capabilities.includes(name)) {
|
|
33343
33842
|
node.setAttr(failureAttributes({ code: "UNAVAILABLE", message: `${name} is unavailable` }), true, true, false);
|
|
33344
33843
|
return;
|
|
@@ -34003,7 +34502,7 @@ var DeviceHandler = class extends Handler {
|
|
|
34003
34502
|
this.assertLive();
|
|
34004
34503
|
if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) || typeof name !== "string") throw new TypeError("Invalid database name");
|
|
34005
34504
|
if (this.#database) throw new Error("This page already owns a database connection");
|
|
34006
|
-
const node = this.gramlot.data.getNode("
|
|
34505
|
+
const node = this.gramlot.data.getNode("_gramlot.device.database");
|
|
34007
34506
|
const state = (status, error = null) => {
|
|
34008
34507
|
if (!this.disposed) node.setAttr({ status, error }, true, true, false);
|
|
34009
34508
|
};
|
|
@@ -34297,6 +34796,7 @@ var UtilitiesHandler = class extends Handler {
|
|
|
34297
34796
|
// src/gramlot.js
|
|
34298
34797
|
var Gramlot = class {
|
|
34299
34798
|
#mobileEnvironment;
|
|
34799
|
+
#collections;
|
|
34300
34800
|
constructor({
|
|
34301
34801
|
pageId,
|
|
34302
34802
|
uploadUrl = null,
|
|
@@ -34315,10 +34815,8 @@ var Gramlot = class {
|
|
|
34315
34815
|
nameSyntax = null,
|
|
34316
34816
|
websocketUrl = null
|
|
34317
34817
|
} = {}) {
|
|
34318
|
-
buttons_default.
|
|
34319
|
-
|
|
34320
|
-
if (collection instanceof ComponentCollection) collection.register(document.defaultView);
|
|
34321
|
-
}
|
|
34818
|
+
this.#collections = [buttons_default, ...collections.filter((collection) => collection instanceof ComponentCollection)];
|
|
34819
|
+
this.registerDocument(document);
|
|
34322
34820
|
this.commands = new CommandRegistry();
|
|
34323
34821
|
this.pageId = pageId;
|
|
34324
34822
|
this.uploadUrl = uploadUrl;
|
|
@@ -34357,6 +34855,14 @@ var Gramlot = class {
|
|
|
34357
34855
|
publish(topic, payload = {}) {
|
|
34358
34856
|
return this._subscriptions.publish(topic, payload);
|
|
34359
34857
|
}
|
|
34858
|
+
/** Register this page's activated collections in an additional rendering realm. */
|
|
34859
|
+
registerDocument(document) {
|
|
34860
|
+
for (const collection of this.#collections) collection.register(document.defaultView);
|
|
34861
|
+
}
|
|
34862
|
+
/** The prepared collection already activated by this page. */
|
|
34863
|
+
getCollection(name) {
|
|
34864
|
+
return this.#collections.find((collection) => collection.name === name);
|
|
34865
|
+
}
|
|
34360
34866
|
subscribe(topic, callback) {
|
|
34361
34867
|
return this._subscriptions.subscribe(topic, callback);
|
|
34362
34868
|
}
|
|
@@ -34517,7 +35023,7 @@ var PageBootstrap = class {
|
|
|
34517
35023
|
...config2,
|
|
34518
35024
|
document,
|
|
34519
35025
|
serverAdapter: this.serverAdapter,
|
|
34520
|
-
collections: [...config2.collections ?? [], ...collections
|
|
35026
|
+
collections: [...config2.collections ?? [], ...collections]
|
|
34521
35027
|
});
|
|
34522
35028
|
window2.removeEventListener("pagehide", pagehide);
|
|
34523
35029
|
for (const collection of collections) collection.registerCommands(app);
|
|
@@ -35109,6 +35615,7 @@ var IdeDocuments = class {
|
|
|
35109
35615
|
return this.state.getItem("documents");
|
|
35110
35616
|
}
|
|
35111
35617
|
async open(root, path) {
|
|
35618
|
+
if (!/\.(?:py|js|mjs|ts|json|html|css|xml|md|markdown|sql|typ|txt|png|jpg|jpeg|webp)$/i.test(path)) return null;
|
|
35112
35619
|
const key2 = documentKey(root, path);
|
|
35113
35620
|
const existing = this.documents.getNodes().find((node) => !node.value.getItem("isNew") && node.value.getItem("root") === root && node.value.getItem("path") === path);
|
|
35114
35621
|
if (existing) return existing.label;
|
|
@@ -35117,7 +35624,13 @@ var IdeDocuments = class {
|
|
|
35117
35624
|
const promise = this.gramlot.rpc.call("data", "document_read", { root, path }, { signal: request.signal }).then((result) => {
|
|
35118
35625
|
if (this.disposed || request.signal.aborted) return null;
|
|
35119
35626
|
const document = new Bag();
|
|
35120
|
-
|
|
35627
|
+
const content = result.language === "image" ? result.content.toTytx() : result.content;
|
|
35628
|
+
for (const [name, value] of Object.entries({ ...result, content, root, saved: content, busy: false })) document.setItem(name, value);
|
|
35629
|
+
if (result.language === "image") {
|
|
35630
|
+
const annotations = result.content;
|
|
35631
|
+
document.setItem("annotations", annotations);
|
|
35632
|
+
annotations.subscribe("ide-annotations", { any: () => document.setItem("content", annotations.toTytx()) });
|
|
35633
|
+
}
|
|
35121
35634
|
this.documents.setItem(key2, document);
|
|
35122
35635
|
return key2;
|
|
35123
35636
|
}).finally(() => this.pending.delete(key2));
|
|
@@ -35223,11 +35736,14 @@ var IdeDocuments = class {
|
|
|
35223
35736
|
if (!doc || doc.getItem("isNew") || !this.dirty(key2) || !doc.getItem("writable") || this.pending.has(key2)) return false;
|
|
35224
35737
|
const content = doc.getItem("content"), request = new AbortController();
|
|
35225
35738
|
doc.setItem("busy", true);
|
|
35226
|
-
const
|
|
35739
|
+
const image = doc.getItem("language") === "image";
|
|
35740
|
+
const path = image ? doc.getItem("annotationPath") : doc.getItem("path");
|
|
35741
|
+
const creating = image && doc.getItem("revision") === null;
|
|
35742
|
+
const promise = this.gramlot.rpc.call("data", creating ? "document_create" : "document_save", {
|
|
35227
35743
|
root: doc.getItem("root"),
|
|
35228
|
-
path
|
|
35229
|
-
content,
|
|
35230
|
-
revision: doc.getItem("revision")
|
|
35744
|
+
path,
|
|
35745
|
+
content: image ? Bag.fromTytx(content) : content,
|
|
35746
|
+
...creating ? {} : { revision: doc.getItem("revision") }
|
|
35231
35747
|
}, { signal: request.signal }).then((result) => {
|
|
35232
35748
|
if (this.disposed || request.signal.aborted) return false;
|
|
35233
35749
|
doc.setItem("revision", result.revision);
|
|
@@ -35244,6 +35760,10 @@ var IdeDocuments = class {
|
|
|
35244
35760
|
const doc = this.documents.getItem(key2);
|
|
35245
35761
|
if (!doc || !this.dirty(key2) || this.pending.has(key2)) return false;
|
|
35246
35762
|
doc.setItem("content", doc.getItem("saved"));
|
|
35763
|
+
if (doc.getItem("language") === "image") {
|
|
35764
|
+
doc.getItem("annotations").replace(Bag.fromTytx(doc.getItem("saved")));
|
|
35765
|
+
doc.setItem("content", doc.getItem("saved"));
|
|
35766
|
+
}
|
|
35247
35767
|
return true;
|
|
35248
35768
|
}
|
|
35249
35769
|
canClose(key2, discard = false) {
|
|
@@ -35351,6 +35871,16 @@ var IdeLogic = class {
|
|
|
35351
35871
|
const root = state.getItem("workspace");
|
|
35352
35872
|
if (root && root !== state.getItem("browser.root")) state.setItem("browser.requestedRoot", root);
|
|
35353
35873
|
}
|
|
35874
|
+
async ideUploadCompleted(node, { result }) {
|
|
35875
|
+
const context = ideContext(node), state = context.scope.getRelativeData(".");
|
|
35876
|
+
if (state.getItem("browser.root") !== result.root) return;
|
|
35877
|
+
state.setItem("upload.open", false);
|
|
35878
|
+
const controller = context.scope.value.getNode("frame.left.browser").fileSystemController;
|
|
35879
|
+
if (controller.request) return;
|
|
35880
|
+
const opened = await controller.open(result.root);
|
|
35881
|
+
if (opened === result.root && !context.documents.disposed && state.getItem("browser.root") === result.root)
|
|
35882
|
+
await this.ideOpenDocument(context.scope, result.root, result.path);
|
|
35883
|
+
}
|
|
35354
35884
|
ideDocumentState(node, key2) {
|
|
35355
35885
|
const context = ideContext(node), { documents } = context;
|
|
35356
35886
|
const doc = documents.documents.getItem(key2);
|
|
@@ -35490,59 +36020,63 @@ var IdeLogic = class {
|
|
|
35490
36020
|
form.button("Create file", { disabled: "^.busy" }).dataController({ func: "ideCreate", documentKey: key2 });
|
|
35491
36021
|
form.button("Cancel", { disabled: "^.busy", class: "button--quiet" }).dataController({ func: "ideCancelCreate", documentKey: key2 });
|
|
35492
36022
|
const editorArea = target.div({ flex: "1", min_height: 0 });
|
|
35493
|
-
|
|
35494
|
-
|
|
35495
|
-
|
|
35496
|
-
|
|
35497
|
-
|
|
35498
|
-
|
|
35499
|
-
|
|
35500
|
-
|
|
35501
|
-
|
|
35502
|
-
|
|
35503
|
-
|
|
35504
|
-
height: "100%",
|
|
35505
|
-
readonly: "^.readonly",
|
|
35506
|
-
nodeId: `${context.editorPrefix}_editor_${key2}`,
|
|
35507
|
-
editorView: "code",
|
|
35508
|
-
selfsubscribe_historyChanged: "ideHistoryChanged"
|
|
35509
|
-
});
|
|
35510
|
-
target.dataController({ func: "ideSave", documentKey: key2, [`subscribe_${context.editorPrefix}_editor_${key2}_save`]: true });
|
|
35511
|
-
if (typst) views.contentPane({ title: "Preview", pageName: "preview", height: "100%" }).typstPreview({ value: `^.documents.${key2}.content`, filename: `^.documents.${key2}.pdfFilename`, height: "100%" });
|
|
35512
|
-
if (recipe) {
|
|
35513
|
-
const output = views.contentPane({ title: "Preview", pageName: "preview", height: "100%", display: "flex", flex_direction: "column" });
|
|
35514
|
-
output.div(`^.documents.${key2}.renderStatus`, { role: "status", padding: "8px 12px", white_space: "pre-wrap", overflow: "auto", max_height: "30%" });
|
|
35515
|
-
output.typstPreview({
|
|
35516
|
-
value: `^.documents.${key2}.typstSource`,
|
|
35517
|
-
filename: `^.documents.${key2}.pdfFilename`,
|
|
35518
|
-
hidden: `^.documents.${key2}.previewHidden`,
|
|
35519
|
-
flex: "1",
|
|
35520
|
-
min_height: 0
|
|
35521
|
-
});
|
|
35522
|
-
views.contentPane({ title: "Generated Typst", pageName: "generated", height: "100%" }).codeMirror({ value: `^.documents.${key2}.typstSource`, language: "typst", readonly: true, height: "100%" });
|
|
35523
|
-
}
|
|
35524
|
-
if (rich) {
|
|
35525
|
-
const previewPane = views.contentPane({ title: "Preview", pageName: "preview", height: "100%", display: "flex", flex_direction: "column" });
|
|
35526
|
-
if (markdown) {
|
|
35527
|
-
doc.setItem("allowHtml", false);
|
|
35528
|
-
previewPane.checkbox({ value: `^.documents.${key2}.allowHtml`, label: "Allow embedded HTML", class: "gramlot-ide-allow-html", padding: "8px 12px", flex_shrink: 0 });
|
|
35529
|
-
}
|
|
35530
|
-
previewPane[html2 ? "htmlPreview" : "markdownPreview"]({
|
|
35531
|
-
value: `^.documents.${key2}.content`,
|
|
35532
|
-
flex: "1",
|
|
35533
|
-
min_height: 0,
|
|
35534
|
-
...markdown ? { allowHtml: `^.documents.${key2}.allowHtml` } : {}
|
|
35535
|
-
});
|
|
35536
|
-
views.contentPane({ title: "Rich text", pageName: "rich", height: "100%" })[html2 ? "htmlEditor" : "markdownEditor"]({
|
|
36023
|
+
if (doc.getItem("language") === "image") {
|
|
36024
|
+
editorArea.drawingPane({ image: `^.documents.${key2}.image`, annotations: `^.documents.${key2}.annotations`, height: "100%" });
|
|
36025
|
+
} else {
|
|
36026
|
+
const html2 = doc.getItem("language") === "html";
|
|
36027
|
+
const markdown = doc.getItem("language") === "markdown";
|
|
36028
|
+
const rich = html2 || markdown;
|
|
36029
|
+
const typst = doc.getItem("language") === "typst";
|
|
36030
|
+
const preview = rich || typst || recipe;
|
|
36031
|
+
const views = preview ? editorArea.tabContainer({ height: "100%", selectedPage: `^.documents.${key2}.view` }) : null;
|
|
36032
|
+
const code = preview ? views.contentPane({ title: "Code", pageName: "code", height: "100%" }) : editorArea;
|
|
36033
|
+
codeMirrorWithOptions(code, {
|
|
35537
36034
|
datapath: `.documents.${key2}`,
|
|
35538
36035
|
value: "^.content",
|
|
35539
|
-
|
|
36036
|
+
language: doc.getItem("language"),
|
|
35540
36037
|
height: "100%",
|
|
35541
|
-
|
|
35542
|
-
|
|
36038
|
+
readonly: "^.readonly",
|
|
36039
|
+
nodeId: `${context.editorPrefix}_editor_${key2}`,
|
|
36040
|
+
editorView: "code",
|
|
35543
36041
|
selfsubscribe_historyChanged: "ideHistoryChanged"
|
|
35544
36042
|
});
|
|
35545
|
-
target.dataController({ func: "ideSave", documentKey: key2, [`subscribe_${context.editorPrefix}
|
|
36043
|
+
target.dataController({ func: "ideSave", documentKey: key2, [`subscribe_${context.editorPrefix}_editor_${key2}_save`]: true });
|
|
36044
|
+
if (typst) views.contentPane({ title: "Preview", pageName: "preview", height: "100%" }).typstPreview({ value: `^.documents.${key2}.content`, filename: `^.documents.${key2}.pdfFilename`, height: "100%" });
|
|
36045
|
+
if (recipe) {
|
|
36046
|
+
const output = views.contentPane({ title: "Preview", pageName: "preview", height: "100%", display: "flex", flex_direction: "column" });
|
|
36047
|
+
output.div(`^.documents.${key2}.renderStatus`, { role: "status", padding: "8px 12px", white_space: "pre-wrap", overflow: "auto", max_height: "30%" });
|
|
36048
|
+
output.typstPreview({
|
|
36049
|
+
value: `^.documents.${key2}.typstSource`,
|
|
36050
|
+
filename: `^.documents.${key2}.pdfFilename`,
|
|
36051
|
+
hidden: `^.documents.${key2}.previewHidden`,
|
|
36052
|
+
flex: "1",
|
|
36053
|
+
min_height: 0
|
|
36054
|
+
});
|
|
36055
|
+
views.contentPane({ title: "Generated Typst", pageName: "generated", height: "100%" }).codeMirror({ value: `^.documents.${key2}.typstSource`, language: "typst", readonly: true, height: "100%" });
|
|
36056
|
+
}
|
|
36057
|
+
if (rich) {
|
|
36058
|
+
const previewPane = views.contentPane({ title: "Preview", pageName: "preview", height: "100%", display: "flex", flex_direction: "column" });
|
|
36059
|
+
if (markdown) {
|
|
36060
|
+
doc.setItem("allowHtml", false);
|
|
36061
|
+
previewPane.checkbox({ value: `^.documents.${key2}.allowHtml`, label: "Allow embedded HTML", class: "gramlot-ide-allow-html", padding: "8px 12px", flex_shrink: 0 });
|
|
36062
|
+
}
|
|
36063
|
+
previewPane[html2 ? "htmlPreview" : "markdownPreview"]({
|
|
36064
|
+
value: `^.documents.${key2}.content`,
|
|
36065
|
+
flex: "1",
|
|
36066
|
+
min_height: 0,
|
|
36067
|
+
...markdown ? { allowHtml: `^.documents.${key2}.allowHtml` } : {}
|
|
36068
|
+
});
|
|
36069
|
+
views.contentPane({ title: "Rich text", pageName: "rich", height: "100%" })[html2 ? "htmlEditor" : "markdownEditor"]({
|
|
36070
|
+
datapath: `.documents.${key2}`,
|
|
36071
|
+
value: "^.content",
|
|
36072
|
+
readonly: "^.readonly",
|
|
36073
|
+
height: "100%",
|
|
36074
|
+
nodeId: `${context.editorPrefix}_rich_editor_${key2}`,
|
|
36075
|
+
editorView: "rich",
|
|
36076
|
+
selfsubscribe_historyChanged: "ideHistoryChanged"
|
|
36077
|
+
});
|
|
36078
|
+
target.dataController({ func: "ideSave", documentKey: key2, [`subscribe_${context.editorPrefix}_rich_editor_${key2}_save`]: true });
|
|
36079
|
+
}
|
|
35546
36080
|
}
|
|
35547
36081
|
}
|
|
35548
36082
|
}
|
|
@@ -35861,6 +36395,34 @@ var UploadTarget = class {
|
|
|
35861
36395
|
}
|
|
35862
36396
|
};
|
|
35863
36397
|
|
|
36398
|
+
// src/visual-editor-catalogue.js
|
|
36399
|
+
var htmlTags = new Set(Object.entries(new HtmlBuilder().schema).filter(([, info]) => !info._meta?.data_element && !info._meta?.subbuilder && !info._meta?.container).map(([tag2]) => tag2));
|
|
36400
|
+
function validateCatalogue(catalogue) {
|
|
36401
|
+
if (catalogue == null || catalogue === "html") return;
|
|
36402
|
+
if (!Array.isArray(catalogue) || catalogue.some((tag2) => typeof tag2 !== "string" || !tag2 || tag2.trim() !== tag2))
|
|
36403
|
+
throw new TypeError('catalogue must be "html" or a list of tag names');
|
|
36404
|
+
if (!catalogue.includes("div")) throw new Error("catalogue must include div for pageRoot");
|
|
36405
|
+
}
|
|
36406
|
+
function catalogueAllows(catalogue, tag2, meta = {}) {
|
|
36407
|
+
if (catalogue == null) return true;
|
|
36408
|
+
if (Array.isArray(catalogue)) return catalogue.includes(tag2);
|
|
36409
|
+
return !meta.gramlot_component && !meta.data_element && !meta.subbuilder && !meta.container && htmlTags.has(meta.render_tag ?? tag2);
|
|
36410
|
+
}
|
|
36411
|
+
function validateCatalogueSource(catalogue, source) {
|
|
36412
|
+
if (catalogue == null) return;
|
|
36413
|
+
const visit = (bag, prefix) => {
|
|
36414
|
+
for (const node of bag.getNodes()) {
|
|
36415
|
+
const path = prefix ? `${prefix}.${node.label}` : node.label;
|
|
36416
|
+
if (!catalogueAllows(catalogue, node.nodeTag, node.getAttr("_meta") ?? {}))
|
|
36417
|
+
throw new Error(`Tag ${node.nodeTag} is outside the editor catalogue at ${path}`);
|
|
36418
|
+
if (node.resolver) throw new Error(`Catalogue scope requires materialized Source at ${path}`);
|
|
36419
|
+
const value = node.getValue(true);
|
|
36420
|
+
if (value instanceof SourceBag) visit(value, path);
|
|
36421
|
+
}
|
|
36422
|
+
};
|
|
36423
|
+
visit(source, "");
|
|
36424
|
+
}
|
|
36425
|
+
|
|
35864
36426
|
// src/visual-editor-icons.js
|
|
35865
36427
|
var toolIcons = { "navigation": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%224%22%20width%3D%2218%22%20height%3D%2216%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M9%204v16M5.5%208h1M5.5%2012h1%22%2F%3E%3C%2Fsvg%3E", "catalogue": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%223%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%2214%22%20y%3D%223%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2214%22%20width%3D%227%22%20height%3D%227%22%20rx%3D%221%22%2F%3E%3Cpath%20d%3D%22M14%2017.5h7M17.5%2014v7%22%2F%3E%3C%2Fsvg%3E", "properties": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M4%206h16M4%2012h16M4%2018h16%22%2F%3E%3Ccircle%20cx%3D%228%22%20cy%3D%226%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2216%22%20cy%3D%2212%22%20r%3D%222%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2218%22%20r%3D%222%22%2F%3E%3C%2Fsvg%3E", "new": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M14%202H6a2%202%200%200%200-2%202v16a2%202%200%200%200%202%202h12a2%202%200%200%200%202-2V8Z%20M14%202v6h6%20M8%2015h8%20M12%2011v8%22%2F%3E%3C%2Fsvg%3E", "download": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M12%203v12m-5-5%205%205%205-5%20M4%2016v4a1%201%200%200%200%201%201h14a1%201%200%200%200%201-1v-4%22%2F%3E%3C%2Fsvg%3E", "copy": "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Crect%20x%3D%228%22%20y%3D%228%22%20width%3D%2212%22%20height%3D%2213%22%20rx%3D%222%22%2F%3E%3Cpath%20d%3D%22M16%208V5a2%202%200%200%200-2-2H5a2%202%200%200%200-2%202v9a2%202%200%200%200%202%202h3%22%2F%3E%3C%2Fsvg%3E" };
|
|
35866
36428
|
toolIcons.open = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%237b8795%22%20stroke-width%3D%221.7%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M3%207V5a2%202%200%200%201%202-2h5l2%202h7a2%202%200%200%201%202%202v2M3%209h18l-2%2011H4z%22%2F%3E%3C%2Fsvg%3E";
|
|
@@ -35870,44 +36432,65 @@ toolIcons.appearance = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.
|
|
|
35870
36432
|
|
|
35871
36433
|
// src/server/visual-editor.js
|
|
35872
36434
|
var VisualEditor = class {
|
|
35873
|
-
constructor(root, { datapath = "__editor", dataRoot = "", editorId = "visual", uploadOperation = "import_source", codeDocument = null, ...attributes } = {}) {
|
|
36435
|
+
constructor(root, { datapath = "__editor", dataRoot = "", editorId = "visual", uploadOperation = "import_source", codeDocument = null, catalogue = null, fileCommands = true, canvasCss = null, ...attributes } = {}) {
|
|
35874
36436
|
if (!/^[A-Za-z][A-Za-z0-9_]*$/.test(editorId)) throw new Error("editorId must be a literal identifier");
|
|
35875
36437
|
if (!dataRoot && datapath !== "__editor" && !datapath.startsWith("__editor.")) throw new Error("Root Data editing requires an __editor datapath");
|
|
36438
|
+
validateCatalogue(catalogue);
|
|
36439
|
+
if (canvasCss != null && (!Array.isArray(canvasCss) || canvasCss.some((text3) => typeof text3 !== "string")))
|
|
36440
|
+
throw new TypeError("canvasCss must be a list of CSS texts");
|
|
35876
36441
|
this.dataRoot = dataRoot;
|
|
35877
36442
|
const pane = this.pane = root.main({ node_label: editorId, datapath, visualEditorId: editorId, ...attributes, nodeId: `${editorId}Editor`, class: `visual-editor-shell ${attributes.class ?? ""}`, overflow: "hidden", tabindex: 0, connect_onkeydown: "clipboardShortcut" });
|
|
36443
|
+
pane.dataSetter({ destination_path: ".catalogueScope", value: catalogue });
|
|
36444
|
+
pane.dataSetter({ destination_path: ".canvasCss", value: canvasCss });
|
|
35878
36445
|
pane.dataSetter({ destination_path: ".uploadQueue", value: new Bag() });
|
|
35879
36446
|
pane.dataController({ func: "initializeEditor", dataRoot: this.dataRoot, _init: true });
|
|
35880
36447
|
pane.dataController({ func: "showProperties", path: "^.selection", _init: true });
|
|
35881
36448
|
pane.dataController({ func: "initializeCanvasSelection", _onBuilt: true });
|
|
36449
|
+
pane.dataController({ func: "initializeDocument", _onBuilt: true });
|
|
35882
36450
|
pane.dataController({ func: "highlightSelection", path: "^.selection", _init: true });
|
|
35883
36451
|
pane.style("^.appearanceCss");
|
|
35884
36452
|
pane.dataController({ func: "initializeEditorAppearance", _onBuilt: true });
|
|
35885
36453
|
pane.dataController({ func: "applyEditorAppearance", profile: "^.appearanceProfile", palette: "^.appearancePalette", mode: "^.appearanceMode" });
|
|
35886
36454
|
const rail = this.rail = pane.menu({ presentation: "bar", orientation: "vertical", aria_label: "Editor panels", class: "visual-editor-rail" });
|
|
35887
|
-
this.toolButton(rail.menuline({ group: true
|
|
35888
|
-
this.toolButton(rail.menuline({ group: true
|
|
35889
|
-
this.toolButton(rail.menuline({ group: true
|
|
35890
|
-
this.toolButton(
|
|
36455
|
+
this.toolButton(rail.menuline({ group: true }), "Source / Data", "toggleNavigation", toolIcons.navigation);
|
|
36456
|
+
this.toolButton(rail.menuline({ group: true }), "Catalogue", "openCatalogue", toolIcons.catalogue);
|
|
36457
|
+
this.toolButton(rail.menuline({ group: true }), "Properties", "openProperties", toolIcons.properties);
|
|
36458
|
+
this.toolButton(
|
|
36459
|
+
rail.menuline({ group: true }),
|
|
36460
|
+
"Clipboard",
|
|
36461
|
+
"this.SET('.clipboardVisible', !this.GET('.clipboardVisible'))",
|
|
36462
|
+
toolIcons.paste,
|
|
36463
|
+
{
|
|
36464
|
+
dropTarget: true,
|
|
36465
|
+
dropTypes: "app/source",
|
|
36466
|
+
dropTags: `${editorId}Source`,
|
|
36467
|
+
dropEffect: "^.clipboardDropEffect",
|
|
36468
|
+
connect_ondragover: "clipboardModifiers",
|
|
36469
|
+
connect_ondrop: "clipboardModifiers",
|
|
36470
|
+
onDrop: "dropClipboard"
|
|
36471
|
+
}
|
|
36472
|
+
);
|
|
35891
36473
|
rail.spacer({ flex: 1 });
|
|
35892
|
-
this.toolButton(rail.menuline({ group: true
|
|
36474
|
+
this.toolButton(rail.menuline({ group: true }), "Appearance", "this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))", toolIcons.appearance);
|
|
35893
36475
|
const layoutRoot = pane.framePane({ node_label: "layout", height: "100%", id: `${editorId}-editor-frame`, class: "visual-editor-layout" });
|
|
35894
|
-
layoutRoot.top.setAttr({ height: "
|
|
36476
|
+
layoutRoot.top.setAttr({ height: "30px" });
|
|
35895
36477
|
const toolbar = layoutRoot.top.menu({ presentation: "bar", aria_label: "Editor tools", class: "visual-editor-toolbar" });
|
|
35896
|
-
toolbar.menuline({ group: true
|
|
35897
|
-
const files = toolbar.menuline({ group: true,
|
|
36478
|
+
toolbar.menuline({ group: true }).span("Source editor", { class: "visual-editor-brand" });
|
|
36479
|
+
const files = toolbar.menuline({ group: true, gap: "4px", hidden: !fileCommands });
|
|
35898
36480
|
for (const [caption, action, icon] of [["New", "newPage", "new"], ["Open", "openUpload", "open"], ["Download", "downloadPage", "download"], ["Copy Source", "copySource", "copy"]])
|
|
35899
36481
|
this.toolButton(files, caption, action, toolIcons[icon], { id: `${editorId}-${icon}` });
|
|
35900
|
-
toolbar.menuline({ group: true
|
|
35901
|
-
const edit = toolbar.menuline({ group: true,
|
|
36482
|
+
toolbar.menuline({ group: true }).span({ class: "visual-toolbar-divider", aria_hidden: "true" });
|
|
36483
|
+
const edit = toolbar.menuline({ group: true, gap: "2px" });
|
|
35902
36484
|
this.toolButton(edit, "Cut branch", "cutBranch", toolIcons.cut, { title: "Cut branch (F8)" });
|
|
35903
36485
|
this.toolButton(edit, "Copy branch", "copyBranch", toolIcons.copy);
|
|
35904
36486
|
this.toolButton(edit, "Paste branch", "pasteBranch", toolIcons.paste, { title: "Paste branch (F9)" });
|
|
35905
36487
|
toolbar.spacer({ flex: 1 });
|
|
35906
|
-
toolbar.menuline({ group: true,
|
|
35907
|
-
toolbar.menuline({ group: true
|
|
36488
|
+
toolbar.menuline({ group: true, hidden: "^.modified:=!{}" }).span("Unsaved changes", { role: "status", class: "visual-editor-hint" });
|
|
36489
|
+
toolbar.menuline({ group: true }).span("^.fileStatus", { role: "status", class: "visual-editor-file-status" });
|
|
36490
|
+
toolbar.menuline({ group: true }).span("^.filename", { class: "visual-editor-filename" });
|
|
35908
36491
|
const left = layoutRoot.left;
|
|
35909
36492
|
left.setAttr({
|
|
35910
|
-
width: "min(
|
|
36493
|
+
width: "min(240px, 34vw)",
|
|
35911
36494
|
splitter: true,
|
|
35912
36495
|
drawer: "^.navigationOpen",
|
|
35913
36496
|
default_drawer: true,
|
|
@@ -35997,7 +36580,7 @@ var VisualEditor = class {
|
|
|
35997
36580
|
center.setAttr({ overflow: "auto", class: "visual-editor-workspace" });
|
|
35998
36581
|
const design = center.div({ node_label: "design", class: "visual-editor-canvas" });
|
|
35999
36582
|
design.div({ node_label: "pageRoot", ...this.dataRoot ? { datapath: this.dataRoot } : {} });
|
|
36000
|
-
const window2 = pane.floatingPane({ title: "Widget catalogue", open: "^.catalogueOpen", default_open: false, width: "
|
|
36583
|
+
const window2 = pane.floatingPane({ title: "Widget catalogue", open: "^.catalogueOpen", default_open: false, width: "280px", height: "400px", class: "visual-editor-popup", movable: true, resizable: true });
|
|
36001
36584
|
this.search(window2.frame.top, "catalogueSearch", "Search widgets");
|
|
36002
36585
|
window2.frame.center.tree({
|
|
36003
36586
|
storepath: ".catalogue",
|
|
@@ -36013,7 +36596,7 @@ var VisualEditor = class {
|
|
|
36013
36596
|
const properties = sidebar.contentPane({
|
|
36014
36597
|
region: "bottom",
|
|
36015
36598
|
height: "^.propertiesHeight",
|
|
36016
|
-
default_height: "
|
|
36599
|
+
default_height: "200px",
|
|
36017
36600
|
minSize: 140,
|
|
36018
36601
|
splitter: true,
|
|
36019
36602
|
title: "^.propertiesTitle",
|
|
@@ -36025,8 +36608,8 @@ var VisualEditor = class {
|
|
|
36025
36608
|
min_height: 0
|
|
36026
36609
|
});
|
|
36027
36610
|
properties.div({ nodeId: `${editorId}EditorFields`, class: "visual-editor-fields", display: "flex", flex_direction: "column", flex: 1, min_height: 0 }).span("");
|
|
36028
|
-
properties.p("^.propertyError", { role: "alert", class: "visual-editor-hint", margin: "
|
|
36029
|
-
const uploader = pane.dialog({ title: "Open Source", open: "^.uploadOpen", width: "480px", height: "300px", movable: true, resizable: true });
|
|
36611
|
+
properties.p("^.propertyError", { role: "alert", class: "visual-editor-hint", margin: "3px" });
|
|
36612
|
+
const uploader = pane.dialog({ class: "visual-editor-popup", title: "Open Source", open: "^.uploadOpen", width: "480px", height: "300px", movable: true, resizable: true });
|
|
36030
36613
|
uploader.frame.center.uploader({
|
|
36031
36614
|
operation: uploadOperation,
|
|
36032
36615
|
storepath: ".uploadQueue",
|
|
@@ -36036,24 +36619,24 @@ var VisualEditor = class {
|
|
|
36036
36619
|
onComplete: "sourceUploaded",
|
|
36037
36620
|
id: `${editorId}-uploader`
|
|
36038
36621
|
});
|
|
36039
|
-
const naming = pane.dialog({ title: "Save branch to clipboard", open: "^.clipboardOpen", width: "380px", height: "210px" });
|
|
36622
|
+
const naming = pane.dialog({ class: "visual-editor-popup", title: "Save branch to clipboard", open: "^.clipboardOpen", width: "380px", height: "210px" });
|
|
36040
36623
|
naming.frame.center.textbox({ value: "^.clipboardDraft.name", lbl: "Name", margin: "12px" });
|
|
36041
36624
|
naming.frame.center.p("^.error", { role: "alert", margin: "12px" });
|
|
36042
|
-
const namingBar = naming.frame.bottom.menu({ presentation: "bar", aria_label: "Clipboard commands", padding: "
|
|
36625
|
+
const namingBar = naming.frame.bottom.menu({ presentation: "bar", aria_label: "Clipboard commands", padding: "3px 6px" });
|
|
36043
36626
|
namingBar.spacer({ flex: 1 });
|
|
36044
|
-
const namingButtons = namingBar.menuline({ group: true,
|
|
36627
|
+
const namingButtons = namingBar.menuline({ group: true, gap: "8px" });
|
|
36045
36628
|
namingButtons.button("Cancel", { action: "this.SET('.clipboardOpen', false)" });
|
|
36046
36629
|
namingButtons.button("Save branch", { action: "saveClipboard" });
|
|
36047
|
-
const dialog = pane.dialog({ title: "Required parameters", open: "^.insertionOpen", width: "400px", height: "280px", movable: true, resizable: true });
|
|
36048
|
-
dialog.frame.center.div({ nodeId: `${editorId}InsertFields`, class: "visual-editor-fields", padding: "
|
|
36630
|
+
const dialog = pane.dialog({ class: "visual-editor-popup", title: "Required parameters", open: "^.insertionOpen", width: "400px", height: "280px", movable: true, resizable: true });
|
|
36631
|
+
dialog.frame.center.div({ nodeId: `${editorId}InsertFields`, class: "visual-editor-fields", padding: "6px" }).span("");
|
|
36049
36632
|
dialog.frame.center.p("^.error", { role: "alert" });
|
|
36050
|
-
const bar = dialog.frame.bottom.menu({ presentation: "bar", aria_label: "Insertion commands", padding: "
|
|
36633
|
+
const bar = dialog.frame.bottom.menu({ presentation: "bar", aria_label: "Insertion commands", padding: "3px 6px", border_top: "1px solid var(--gramlot-border)" });
|
|
36051
36634
|
bar.spacer({ flex: 1 });
|
|
36052
|
-
const buttons = bar.menuline({ group: true,
|
|
36635
|
+
const buttons = bar.menuline({ group: true, gap: "8px" });
|
|
36053
36636
|
buttons.button("Cancel", { action: "this.SET('.insertionOpen', false)" });
|
|
36054
36637
|
buttons.button("Insert", { action: "insertWidget" });
|
|
36055
|
-
const settings = pane.floatingPane({ title: "Appearance", open: "^.appearanceOpen", default_open: false, width: "280px", height: "260px", movable: true, resizable: true });
|
|
36056
|
-
const form = settings.frame.center.formlet({ columns: 1, lbl_position: "TL", gap: "
|
|
36638
|
+
const settings = pane.floatingPane({ class: "visual-editor-popup", title: "Appearance", open: "^.appearanceOpen", default_open: false, width: "280px", height: "260px", movable: true, resizable: true });
|
|
36639
|
+
const form = settings.frame.center.formlet({ columns: 1, lbl_position: "TL", gap: "4px", padding: "6px" });
|
|
36057
36640
|
form.filteringSelect({ validate_notnull: true, lbl: "Theme", value: "^.appearanceProfile", values: "base:Base,compact:Compact,mimi:Mimi,joanna:Joanna,mela:Mela" });
|
|
36058
36641
|
form.filteringSelect({ validate_notnull: true, lbl: "Colors", value: "^.appearancePalette", values: "default:Theme default,compact:Blue & slate,mimi:Sage & green,joanna:Warm gray & blue" });
|
|
36059
36642
|
form.filteringSelect({ validate_notnull: true, lbl: "Mode", value: "^.appearanceMode", values: "light:Light,dark:Dark" });
|
|
@@ -36075,9 +36658,10 @@ var VisualEditor = class {
|
|
|
36075
36658
|
pane.dataSetter({ destination_path: ".codeDocument", value: new Bag({ ...document, saved: document.content, busy: false, status: "" }) });
|
|
36076
36659
|
const anchor = `#${pane.getAttr("visualEditorId")}Editor`;
|
|
36077
36660
|
const opener = frame === this.frame ? this.toolbar : frame.top.menu({ presentation: "bar", aria_label: "Code drawer" });
|
|
36078
|
-
opener.menuline({ group: true
|
|
36661
|
+
opener.menuline({ group: true }).button("Code", { action: "openCode", class: "button--quiet" });
|
|
36079
36662
|
const drawer = frame.right;
|
|
36080
36663
|
drawer.setAttr({
|
|
36664
|
+
class: "visual-editor-code",
|
|
36081
36665
|
datapath: anchor,
|
|
36082
36666
|
title: "Page code",
|
|
36083
36667
|
detachable: true,
|
|
@@ -36093,15 +36677,15 @@ var VisualEditor = class {
|
|
|
36093
36677
|
overflow: "hidden"
|
|
36094
36678
|
});
|
|
36095
36679
|
const code = drawer.framePane({ height: "100%", width: "100%", min_width: 0, flex: 1 });
|
|
36096
|
-
code.top.setAttr({ height: "
|
|
36097
|
-
code.bottom.setAttr({ height: "
|
|
36680
|
+
code.top.setAttr({ height: "26px" });
|
|
36681
|
+
code.bottom.setAttr({ height: "48px" });
|
|
36098
36682
|
code.center.setAttr({ display: "flex", flex_direction: "column", min_height: 0, overflow: "hidden" });
|
|
36099
|
-
code.top.div(document.path, { padding: "
|
|
36683
|
+
code.top.div(document.path, { padding: "3px 6px", font_size: "12px", overflow: "hidden", text_overflow: "ellipsis", white_space: "nowrap" });
|
|
36100
36684
|
code.center.codeMirror({ value: "^.codeDocument.content", language: document.language, live: true, readonly: "^.codeDocument.writable:=!{}", height: "100%", box_height: "100%", box_c_height: "100%", box_min_height: 0, box_c_min_height: 0, fontSize: 13, flex: 1, min_height: 0 });
|
|
36101
36685
|
code.bottom.div("^.codeDocument.status", { role: "status", font_size: "12px", padding: "4px 10px" });
|
|
36102
|
-
const bar = code.bottom.menu({ presentation: "bar", aria_label: "Page code commands", padding: "6px
|
|
36686
|
+
const bar = code.bottom.menu({ presentation: "bar", aria_label: "Page code commands", padding: "3px 6px" });
|
|
36103
36687
|
bar.spacer({ flex: 1 });
|
|
36104
|
-
const commands = bar.menuline({ group: true,
|
|
36688
|
+
const commands = bar.menuline({ group: true, gap: "6px" });
|
|
36105
36689
|
commands.button("Close", { action: "this.SET('.codeOpen', 'close')" });
|
|
36106
36690
|
commands.button("Preview saved", { action: "codePreview", disabled: "^.codeDocument.busy" });
|
|
36107
36691
|
commands.button("Save", { action: "codeSave", disabled: "^.codeSaveDisabled" });
|
|
@@ -36117,7 +36701,7 @@ var VisualEditor = class {
|
|
|
36117
36701
|
}
|
|
36118
36702
|
search(pane, path, label) {
|
|
36119
36703
|
const bar = pane.menu({ presentation: "bar", aria_label: label, class: "visual-search-toolbar" });
|
|
36120
|
-
const field = bar.menuline({ group: true,
|
|
36704
|
+
const field = bar.menuline({ group: true, flex: 1, min_width: 0 }).div({ class: "visual-search-field" });
|
|
36121
36705
|
field.span({ class: "visual-search-icon", aria_hidden: "true" });
|
|
36122
36706
|
field.input({ type: "search", value: `^.${path}`, default: "", live: true, placeholder: label, aria_label: label });
|
|
36123
36707
|
field.html_button({
|
|
@@ -36132,8 +36716,10 @@ var VisualEditor = class {
|
|
|
36132
36716
|
|
|
36133
36717
|
// src/server/source-import.js
|
|
36134
36718
|
var SourceImport = class extends UploadTarget {
|
|
36135
|
-
constructor() {
|
|
36719
|
+
constructor({ catalogue = null } = {}) {
|
|
36136
36720
|
super({ maxBytes: 5 * 1024 * 1024 });
|
|
36721
|
+
validateCatalogue(catalogue);
|
|
36722
|
+
this.catalogue = catalogue;
|
|
36137
36723
|
this.decoder = new TextDecoder("utf-8", { fatal: true });
|
|
36138
36724
|
this.parts = [];
|
|
36139
36725
|
this.outcome = { state: "pending" };
|
|
@@ -36149,6 +36735,7 @@ var SourceImport = class extends UploadTarget {
|
|
|
36149
36735
|
if (!(source instanceof SourceBag) || source.length !== 1 || source.getNodes()[0].label !== "pageRoot") {
|
|
36150
36736
|
throw new TypeError("Expected one pageRoot Source");
|
|
36151
36737
|
}
|
|
36738
|
+
validateCatalogueSource(this.catalogue, source);
|
|
36152
36739
|
this.outcome = { state: "completed", result: wire };
|
|
36153
36740
|
return this.outcome;
|
|
36154
36741
|
}
|
|
@@ -38305,7 +38892,8 @@ function Labelbox(Base) {
|
|
|
38305
38892
|
}
|
|
38306
38893
|
projectAttributes(attrs, adapt) {
|
|
38307
38894
|
const rest = super.projectAttributes(attrs, adapt);
|
|
38308
|
-
const
|
|
38895
|
+
const { lbl, lbl_value, lbl_values } = this.parameters;
|
|
38896
|
+
const label = lbl_values == null ? lbl ?? "" : choiceCaption(parseChoices(lbl_values), lbl_value, lbl);
|
|
38309
38897
|
if (label) this.control.setAttribute("aria-label", label);
|
|
38310
38898
|
else this.control.removeAttribute("aria-label");
|
|
38311
38899
|
return rest;
|
|
@@ -38315,6 +38903,8 @@ function Labelbox(Base) {
|
|
|
38315
38903
|
Labelbox.labelbox = true;
|
|
38316
38904
|
Labelbox.parameters = {
|
|
38317
38905
|
lbl: { dtype: "T", qualification: "intl_str", nullable: true, binding: "read" },
|
|
38906
|
+
lbl_value: { dtype: "T", nullable: true, binding: "twoWay" },
|
|
38907
|
+
lbl_values: { dtype: "T", nullable: true, binding: "read" },
|
|
38318
38908
|
lbl_position: { dtype: "T", default: "TL", binding: "read", enum: labelboxPositions }
|
|
38319
38909
|
};
|
|
38320
38910
|
|
|
@@ -38401,7 +38991,7 @@ function fail3(errorcode, message, extra = {}) {
|
|
|
38401
38991
|
return { errorcode, message, ...extra };
|
|
38402
38992
|
}
|
|
38403
38993
|
function localRule(rule, param, value, context) {
|
|
38404
|
-
if (rule === "select") return context.selection(value);
|
|
38994
|
+
if (rule === "select") return context.selection(value, context.signal);
|
|
38405
38995
|
if (rule === "notnull") return empty(value) && param ? fail3("notnull", "A value is required.", { required: true }) : null;
|
|
38406
38996
|
if (rule === "empty") return empty(value) ? { value: param } : null;
|
|
38407
38997
|
if (rule === "len") {
|
|
@@ -38490,9 +39080,17 @@ function FieldState(Base) {
|
|
|
38490
39080
|
get supportsFormValidation() {
|
|
38491
39081
|
return true;
|
|
38492
39082
|
}
|
|
38493
|
-
|
|
39083
|
+
static validationParameters(attrs) {
|
|
39084
|
+
const parameters2 = { ...parameterValues(this.gramlotComponent, attrs), ...attrs };
|
|
39085
|
+
if (this.constrained && parameters2.validate_select == null) parameters2.validate_select = true;
|
|
39086
|
+
return parameters2;
|
|
39087
|
+
}
|
|
39088
|
+
static get validationExecutor() {
|
|
38494
39089
|
return validateInput;
|
|
38495
39090
|
}
|
|
39091
|
+
get validationExecutor() {
|
|
39092
|
+
return this.constructor.validationExecutor;
|
|
39093
|
+
}
|
|
38496
39094
|
connectedCallback() {
|
|
38497
39095
|
super.connectedCallback();
|
|
38498
39096
|
if (this.pageContext?.form) this.pageContext.formValidate();
|
|
@@ -39137,6 +39735,85 @@ function chatRenderAttachments(page, node, { attachments }) {
|
|
|
39137
39735
|
for (const child of prepared.getNodes()) page.src.builder.setChild(target.value, child.nodeTag, child.value, { ...child.attr, node_label: child.label });
|
|
39138
39736
|
}
|
|
39139
39737
|
|
|
39738
|
+
// src/visual-editor-canvas.js
|
|
39739
|
+
var VisualEditorCanvas = class {
|
|
39740
|
+
constructor({ app, editor, design }) {
|
|
39741
|
+
this.renderer = app.src.renderer;
|
|
39742
|
+
this.design = design;
|
|
39743
|
+
const presentation = this.renderer.records.get(design).presentation;
|
|
39744
|
+
this.frame = presentation.ownerDocument.createElement("iframe");
|
|
39745
|
+
this.frame.title = "Page canvas";
|
|
39746
|
+
this.frame.className = "visual-editor-canvas-frame";
|
|
39747
|
+
this.frame.style.cssText = "display:block;width:100%;height:100%;min-height:240px;border:0;background:white";
|
|
39748
|
+
presentation.before(this.frame);
|
|
39749
|
+
const document = this.frame.contentDocument;
|
|
39750
|
+
app.registerDocument(document);
|
|
39751
|
+
const base = document.createElement("style");
|
|
39752
|
+
base.textContent = "html,body{margin:0;min-height:100%;} .visual-editor-canvas{min-height:100vh;}";
|
|
39753
|
+
this.styles = document.createElement("style");
|
|
39754
|
+
const selection = document.createElement("style");
|
|
39755
|
+
selection.textContent = ".gramlot-source-selected{outline:2px solid #8ab4f8!important;outline-offset:-2px!important;}";
|
|
39756
|
+
document.head.append(base, this.styles, selection);
|
|
39757
|
+
this.body = document.body;
|
|
39758
|
+
this.renderer.mountDestination(design, this.body);
|
|
39759
|
+
this.release = this.renderer.onDispose(editor, () => this.dispose());
|
|
39760
|
+
}
|
|
39761
|
+
setCss(texts) {
|
|
39762
|
+
this.styles.textContent = texts.join("\n");
|
|
39763
|
+
}
|
|
39764
|
+
dispose() {
|
|
39765
|
+
this.release?.();
|
|
39766
|
+
this.release = null;
|
|
39767
|
+
this.frame.remove();
|
|
39768
|
+
}
|
|
39769
|
+
};
|
|
39770
|
+
|
|
39771
|
+
// src/editor-values.js
|
|
39772
|
+
var editorTypes = ["string", "number", "integer", "boolean", "date", "time", "datetime", "null"];
|
|
39773
|
+
function scalarType(value) {
|
|
39774
|
+
if (value === null) return "null";
|
|
39775
|
+
if (["string", "boolean"].includes(typeof value)) return typeof value;
|
|
39776
|
+
if (typeof value === "number" && Number.isFinite(value)) return Number.isSafeInteger(value) ? "integer" : "number";
|
|
39777
|
+
if (value instanceof Date && Number.isFinite(value.getTime())) {
|
|
39778
|
+
const iso = value.toISOString();
|
|
39779
|
+
return iso.slice(0, 10) === "1970-01-01" ? "time" : iso.endsWith("T00:00:00.000Z") ? "date" : "datetime";
|
|
39780
|
+
}
|
|
39781
|
+
return null;
|
|
39782
|
+
}
|
|
39783
|
+
function scalarText(value, type) {
|
|
39784
|
+
if (type === "null") return "";
|
|
39785
|
+
if (value instanceof Date) {
|
|
39786
|
+
const iso = value.toISOString();
|
|
39787
|
+
return type === "date" ? iso.slice(0, 10) : type === "time" ? iso.slice(11, 23) : iso;
|
|
39788
|
+
}
|
|
39789
|
+
return String(value);
|
|
39790
|
+
}
|
|
39791
|
+
function parseScalar(type, text3) {
|
|
39792
|
+
if (type === "string") return text3;
|
|
39793
|
+
if (type === "null") return null;
|
|
39794
|
+
if (type === "boolean" && ["true", "false"].includes(text3)) return text3 === "true";
|
|
39795
|
+
if (type === "number" || type === "integer") {
|
|
39796
|
+
if (/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(text3.trim())) {
|
|
39797
|
+
const value = Number(text3);
|
|
39798
|
+
if (Number.isFinite(value) && (type !== "integer" || Number.isSafeInteger(value))) return value;
|
|
39799
|
+
}
|
|
39800
|
+
}
|
|
39801
|
+
if (["date", "time", "datetime"].includes(type)) {
|
|
39802
|
+
const pattern = type === "date" ? /^\d{4}-\d{2}-\d{2}$/ : type === "time" ? /^\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?$/ : /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,3})?)?Z$/;
|
|
39803
|
+
if (pattern.test(text3)) {
|
|
39804
|
+
const input = type === "date" ? `${text3}T00:00:00Z` : type === "time" ? `1970-01-01T${text3}Z` : text3;
|
|
39805
|
+
const date = new Date(input);
|
|
39806
|
+
if (Number.isFinite(date.getTime())) {
|
|
39807
|
+
const iso = date.toISOString();
|
|
39808
|
+
const supplied = input.replace(/Z$/, "").split(/[T:.]/);
|
|
39809
|
+
const actual = iso.replace(/Z$/, "").split(/[T:.]/);
|
|
39810
|
+
if (supplied.every((part, index) => index === 4 ? Number(part.padEnd(3, "0")) === Number(actual[index]) : part === actual[index])) return date;
|
|
39811
|
+
}
|
|
39812
|
+
}
|
|
39813
|
+
}
|
|
39814
|
+
throw new Error(`Invalid ${type} value: ${text3 || "(empty)"}`);
|
|
39815
|
+
}
|
|
39816
|
+
|
|
39140
39817
|
// src/source-picker.js
|
|
39141
39818
|
var SourcePicker = class {
|
|
39142
39819
|
#renderer;
|
|
@@ -39148,9 +39825,8 @@ var SourcePicker = class {
|
|
|
39148
39825
|
#highlighted = null;
|
|
39149
39826
|
#release = null;
|
|
39150
39827
|
#disposed = false;
|
|
39151
|
-
constructor({ renderer, root, onSelect }) {
|
|
39828
|
+
constructor({ renderer, root, onSelect, canvas = renderer.records.get(root.parentNode)?.presentation }) {
|
|
39152
39829
|
if (!root?.parentNode || typeof onSelect !== "function") throw new TypeError("SourcePicker requires a mounted Source root and onSelect");
|
|
39153
|
-
const canvas = renderer.records.get(root.parentNode)?.presentation;
|
|
39154
39830
|
if (!canvas || canvas.nodeType !== 1) throw new TypeError("SourcePicker requires a mounted preview");
|
|
39155
39831
|
this.#renderer = renderer;
|
|
39156
39832
|
this.#root = root;
|
|
@@ -39281,6 +39957,7 @@ var specifications = (node, tag2, current = null) => {
|
|
|
39281
39957
|
};
|
|
39282
39958
|
};
|
|
39283
39959
|
var canvasSelections = /* @__PURE__ */ new WeakMap();
|
|
39960
|
+
var canvasDocuments = /* @__PURE__ */ new WeakMap();
|
|
39284
39961
|
var VisualEditorLogic = class {
|
|
39285
39962
|
chatRender(node, params) {
|
|
39286
39963
|
return chatRender(this.page, node, params);
|
|
@@ -39315,8 +39992,10 @@ var VisualEditorLogic = class {
|
|
|
39315
39992
|
return;
|
|
39316
39993
|
}
|
|
39317
39994
|
const run = (editor.GET(".assistantRun.run") ?? 0) + 1;
|
|
39995
|
+
const scope = editor.GET(".catalogueScope");
|
|
39318
39996
|
const schema = { commonParameters: styleParameters, labelboxParameters, widgets: {} };
|
|
39319
39997
|
for (const [tag2, info] of Object.entries(node.builder.schema)) {
|
|
39998
|
+
if (!catalogueAllows(scope, tag2, info._meta ?? {})) continue;
|
|
39320
39999
|
if (info._meta?.data_element || info._meta?.subbuilder || info._meta?.container) continue;
|
|
39321
40000
|
const component = info._meta?.gramlot_component;
|
|
39322
40001
|
schema.widgets[tag2] = {
|
|
@@ -39440,6 +40119,7 @@ var VisualEditorLogic = class {
|
|
|
39440
40119
|
}
|
|
39441
40120
|
};
|
|
39442
40121
|
candidate.getNodes().forEach(validateChildren);
|
|
40122
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), candidate);
|
|
39443
40123
|
app.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
39444
40124
|
const current = node.builder.source.getNode(`${sourceRoot(node)}.${path}`);
|
|
39445
40125
|
let selected = path;
|
|
@@ -39466,14 +40146,43 @@ var VisualEditorLogic = class {
|
|
|
39466
40146
|
initializeCanvasSelection(node) {
|
|
39467
40147
|
const renderer = node.rootBuilder.binding.renderer;
|
|
39468
40148
|
const design = node.builder.source.getNode(sourceRoot(node));
|
|
39469
|
-
const
|
|
39470
|
-
|
|
39471
|
-
|
|
39472
|
-
|
|
40149
|
+
const editor = visualEditorScope(node), css = editor.GET(".canvasCss");
|
|
40150
|
+
if (css != null) this.applyCanvasCss(editor, css);
|
|
40151
|
+
const previous = canvasSelections.get(design);
|
|
40152
|
+
previous?.dispose();
|
|
40153
|
+
const picker = new SourcePicker({
|
|
40154
|
+
renderer,
|
|
40155
|
+
root: design,
|
|
40156
|
+
...canvasDocuments.has(design) ? { canvas: canvasDocuments.get(design).body } : {},
|
|
40157
|
+
onSelect: (selected) => {
|
|
40158
|
+
node.SET(".sourceSearch", "");
|
|
40159
|
+
node.SET(".selection", selected.fullpath.slice(design.fullpath.length + 1));
|
|
40160
|
+
}
|
|
40161
|
+
});
|
|
39473
40162
|
canvasSelections.set(design, picker);
|
|
39474
|
-
renderer.onDispose(design.parentNode, () =>
|
|
40163
|
+
if (!previous) renderer.onDispose(design.parentNode, () => {
|
|
40164
|
+
canvasSelections.delete(design);
|
|
40165
|
+
canvasDocuments.delete(design);
|
|
40166
|
+
});
|
|
39475
40167
|
this.highlightSelection(node);
|
|
39476
40168
|
}
|
|
40169
|
+
applyCanvasCss(node, texts) {
|
|
40170
|
+
if (!Array.isArray(texts) || texts.some((text3) => typeof text3 !== "string"))
|
|
40171
|
+
throw new TypeError("canvas CSS must be a list of CSS texts");
|
|
40172
|
+
const editor = visualEditorScope(node), design = editor.builder.source.getNode(sourceRoot(editor));
|
|
40173
|
+
let canvas = canvasDocuments.get(design);
|
|
40174
|
+
if (!canvas) {
|
|
40175
|
+
canvas = new VisualEditorCanvas({ app: editor.rootBuilder.binding.gramlot, editor, design });
|
|
40176
|
+
canvasDocuments.set(design, canvas);
|
|
40177
|
+
}
|
|
40178
|
+
canvas.setCss(texts);
|
|
40179
|
+
}
|
|
40180
|
+
setCanvasCss(node, texts) {
|
|
40181
|
+
const editor = visualEditorScope(node);
|
|
40182
|
+
this.applyCanvasCss(editor, texts);
|
|
40183
|
+
editor.SET(".canvasCss", texts);
|
|
40184
|
+
this.initializeCanvasSelection(editor);
|
|
40185
|
+
}
|
|
39477
40186
|
highlightSelection(node) {
|
|
39478
40187
|
const design = node.builder.source.getNode(sourceRoot(node));
|
|
39479
40188
|
const path = node.GET(".selection");
|
|
@@ -39592,6 +40301,7 @@ var VisualEditorLogic = class {
|
|
|
39592
40301
|
const parent = path ? node.builder.source.getNode(`${sourceRoot(node)}.${path}`) : null;
|
|
39593
40302
|
if (!parent) throw new Error("Choose a destination in the Source tree");
|
|
39594
40303
|
const source = node.rootBuilder.binding.gramlot.src.prepareSource(saved.getValue(true), parent.builder);
|
|
40304
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), source);
|
|
39595
40305
|
const branch2 = source.getNodes()[0];
|
|
39596
40306
|
parent.builder.validateParent(branch2.nodeTag, parent.nodeTag);
|
|
39597
40307
|
const body = parent.getValue(true);
|
|
@@ -39612,7 +40322,7 @@ var VisualEditorLogic = class {
|
|
|
39612
40322
|
fields.getValue(true).clear();
|
|
39613
40323
|
const root = node.builder.wrapSource(fields);
|
|
39614
40324
|
root.p(`Paste ${saved.getAttr("name")} into ${parent.label} [${parent.nodeTag}]`, { class: "visual-editor-hint" });
|
|
39615
|
-
const form = root.formlet({ columns: 2, gap: "
|
|
40325
|
+
const form = root.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
39616
40326
|
for (const [name, spec] of required) this.parameterField(node, form, branch2.nodeTag, name, spec, "insertion", spec.default);
|
|
39617
40327
|
node.SET(".insertionOpen", true);
|
|
39618
40328
|
}
|
|
@@ -39646,6 +40356,7 @@ var VisualEditorLogic = class {
|
|
|
39646
40356
|
if (!parent) throw new Error("The destination no longer exists");
|
|
39647
40357
|
const app = node.rootBuilder.binding.gramlot;
|
|
39648
40358
|
const source = app.src.prepareSource(node.GET(".insertion.clipboard"), parent.builder);
|
|
40359
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), source);
|
|
39649
40360
|
const branch2 = source.getNodes()[0];
|
|
39650
40361
|
const attrs = { ...branch2.getAttr() };
|
|
39651
40362
|
for (const [name, spec] of Object.entries(specifications(parent, branch2.nodeTag))) {
|
|
@@ -39666,6 +40377,7 @@ var VisualEditorLogic = class {
|
|
|
39666
40377
|
const children = candidateParent.getValue(true);
|
|
39667
40378
|
candidateParent.builder.validateChildren(candidateParent.nodeTag, [...children instanceof node.builder.source.constructor ? children.getNodes().map((child) => child.nodeTag) : [], branch2.nodeTag]);
|
|
39668
40379
|
const inserted = this.appendBranch(candidateParent, branch2, label);
|
|
40380
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), candidate);
|
|
39669
40381
|
app.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
39670
40382
|
this.appendBranch(parent, inserted, label);
|
|
39671
40383
|
node.SET(".insertionOpen", false);
|
|
@@ -39736,6 +40448,7 @@ var VisualEditorLogic = class {
|
|
|
39736
40448
|
if (request.signal.aborted) return;
|
|
39737
40449
|
if (design.value.toTytx() !== before) throw new Error("Source changed while preparing preview; it was retained");
|
|
39738
40450
|
const candidate = this.page.src.prepareSource(wire, design.builder);
|
|
40451
|
+
validateCatalogueSource(editor.GET(".catalogueScope"), candidate);
|
|
39739
40452
|
this.page.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
39740
40453
|
if (editor.GET(".assistantRun")) editor.SET(".assistantRun.blocked", true);
|
|
39741
40454
|
editor.SET(".selection", null);
|
|
@@ -39765,32 +40478,21 @@ var VisualEditorLogic = class {
|
|
|
39765
40478
|
async copySource(node) {
|
|
39766
40479
|
node.SET(".fileStatus", "");
|
|
39767
40480
|
try {
|
|
39768
|
-
|
|
39769
|
-
await node.rootBuilder.binding.gramlot.utl.inout.copyText(page.toTytx());
|
|
40481
|
+
await node.rootBuilder.binding.gramlot.utl.inout.copyText(this.currentSource(node));
|
|
39770
40482
|
node.SET(".fileStatus", "Source copied");
|
|
39771
40483
|
} catch (error) {
|
|
39772
40484
|
node.SET(".fileStatus", `Copy failed: ${error.message}`);
|
|
39773
40485
|
}
|
|
39774
40486
|
}
|
|
39775
40487
|
downloadPage(node) {
|
|
39776
|
-
|
|
39777
|
-
node.rootBuilder.binding.gramlot.utl.inout.saveText(page.toTytx(), node.GET(".filename"), "application/json");
|
|
40488
|
+
node.rootBuilder.binding.gramlot.utl.inout.saveText(this.currentSource(node), node.GET(".filename"), "application/json");
|
|
39778
40489
|
}
|
|
39779
40490
|
openUpload(node) {
|
|
39780
40491
|
node.SET(".uploadOpen", true);
|
|
39781
40492
|
}
|
|
39782
40493
|
sourceUploaded(node, { item, result }) {
|
|
39783
40494
|
try {
|
|
39784
|
-
|
|
39785
|
-
const target = node.builder.source.getNode(sourceRoot(node));
|
|
39786
|
-
const source = app.src.prepareSource(result, target.builder);
|
|
39787
|
-
const roots = source.getNodes();
|
|
39788
|
-
if (roots.length !== 1 || roots[0].label !== "pageRoot") throw new Error("Expected one pageRoot Source");
|
|
39789
|
-
app.src.renderer.validateCandidate(source, { replacingNode: target });
|
|
39790
|
-
if (node.GET(".assistantRun")) node.SET(".assistantRun.blocked", true);
|
|
39791
|
-
target.setValue(source, true, { _text: null }, true);
|
|
39792
|
-
node.SET(".filename", item.value.getItem("name"));
|
|
39793
|
-
node.SET(".selection", "pageRoot");
|
|
40495
|
+
this.loadSource(node, { source: result, filename: item.value.getItem("name") });
|
|
39794
40496
|
node.SET(".fileStatus", "Source opened");
|
|
39795
40497
|
node.SET(".uploadOpen", false);
|
|
39796
40498
|
} catch (error) {
|
|
@@ -39798,6 +40500,43 @@ var VisualEditorLogic = class {
|
|
|
39798
40500
|
throw error;
|
|
39799
40501
|
}
|
|
39800
40502
|
}
|
|
40503
|
+
initializeDocument(node) {
|
|
40504
|
+
const editor = visualEditorScope(node), source = editor.builder.source;
|
|
40505
|
+
const prefix = sourceRoot(editor).split(".");
|
|
40506
|
+
const subscription = `${editor.getAttr("visualEditorId")}-document`;
|
|
40507
|
+
editor.SET(".modified", false);
|
|
40508
|
+
source.subscribe(subscription, { any: (event) => {
|
|
40509
|
+
if (prefix.every((part, index) => event.pathlist[index] === part)) editor.SET(".modified", true);
|
|
40510
|
+
} });
|
|
40511
|
+
editor.rootBuilder.binding.renderer.onDispose(editor, () => source.unsubscribe(subscription, { any: true }));
|
|
40512
|
+
}
|
|
40513
|
+
currentSource(node) {
|
|
40514
|
+
const editor = visualEditorScope(node);
|
|
40515
|
+
return editor.builder.source.getNode(sourceRoot(editor)).getValue(true).toTytx();
|
|
40516
|
+
}
|
|
40517
|
+
markSaved(node) {
|
|
40518
|
+
visualEditorScope(node).SET(".modified", false);
|
|
40519
|
+
}
|
|
40520
|
+
loadSource(node, { source, filename }) {
|
|
40521
|
+
const editor = visualEditorScope(node);
|
|
40522
|
+
if (typeof source !== "string") throw new TypeError("source must be Source TYTX");
|
|
40523
|
+
if (typeof filename !== "string" || !filename.trim()) throw new TypeError("filename must be a non-empty string");
|
|
40524
|
+
const app = editor.rootBuilder.binding.gramlot;
|
|
40525
|
+
const target = editor.builder.source.getNode(sourceRoot(editor));
|
|
40526
|
+
const candidate = app.src.prepareSource(source, target.builder);
|
|
40527
|
+
const roots = candidate.getNodes();
|
|
40528
|
+
if (roots.length !== 1 || roots[0].label !== "pageRoot") throw new Error("Expected one pageRoot Source");
|
|
40529
|
+
validateCatalogueSource(editor.GET(".catalogueScope"), candidate);
|
|
40530
|
+
app.src.renderer.validateCandidate(candidate, { replacingNode: target });
|
|
40531
|
+
if (editor.GET(".assistantRun")) editor.SET(".assistantRun.blocked", true);
|
|
40532
|
+
editor.SET(".selection", null);
|
|
40533
|
+
target.setValue(candidate, true, { _text: null }, true);
|
|
40534
|
+
editor.SET(".filename", filename);
|
|
40535
|
+
editor.SET(".insertionOpen", false);
|
|
40536
|
+
editor.SET(".sourceSearch", "");
|
|
40537
|
+
editor.SET(".selection", "pageRoot");
|
|
40538
|
+
this.markSaved(editor);
|
|
40539
|
+
}
|
|
39801
40540
|
toggleNavigation(node) {
|
|
39802
40541
|
node.SET(".navigationOpen", node.GET(".navigationOpen") === "close" ? true : "close");
|
|
39803
40542
|
}
|
|
@@ -39842,6 +40581,11 @@ var VisualEditorLogic = class {
|
|
|
39842
40581
|
node.rootBuilder.binding.renderer.destination.ownerDocument.documentElement.setAttribute("data-theme", mode);
|
|
39843
40582
|
}
|
|
39844
40583
|
initializeEditor(node, { dataRoot }) {
|
|
40584
|
+
const scope = node.GET(".catalogueScope");
|
|
40585
|
+
validateCatalogue(scope);
|
|
40586
|
+
if (Array.isArray(scope)) for (const tag2 of scope) {
|
|
40587
|
+
if (!node.builder.schema[tag2]) throw new Error(`Unknown catalogue tag: ${tag2}`);
|
|
40588
|
+
}
|
|
39845
40589
|
node.SET(".editingMode", "source");
|
|
39846
40590
|
node.SET(".clipboard", new Bag());
|
|
39847
40591
|
node.SET(".clipboardVisible", false);
|
|
@@ -39870,9 +40614,10 @@ var VisualEditorLogic = class {
|
|
|
39870
40614
|
return bag;
|
|
39871
40615
|
};
|
|
39872
40616
|
for (const [path, caption, tags] of catalogueSections) {
|
|
39873
|
-
if (tags.split(" ").some((tag2) => node.builder.schema[tag2])) ensureGroup(path, caption);
|
|
40617
|
+
if (tags.split(" ").some((tag2) => node.builder.schema[tag2] && catalogueAllows(scope, tag2, node.builder.schema[tag2]._meta ?? {}))) ensureGroup(path, caption);
|
|
39874
40618
|
}
|
|
39875
40619
|
for (const [tag2, info] of Object.entries(node.builder.schema).sort(([a], [b]) => a.localeCompare(b))) {
|
|
40620
|
+
if (!catalogueAllows(scope, tag2, info._meta ?? {})) continue;
|
|
39876
40621
|
if (info._meta?.data_element || info._meta?.subbuilder || info._meta?.container) continue;
|
|
39877
40622
|
const root = info._meta?.gramlot_component ? "components" : "html";
|
|
39878
40623
|
const section = catalogueSections.find(([path2, , tags]) => path2.startsWith(root + ".") && tags.split(" ").includes(tag2));
|
|
@@ -39900,6 +40645,7 @@ var VisualEditorLogic = class {
|
|
|
39900
40645
|
const targetPath = `${sourceRoot(node)}.${path}`;
|
|
39901
40646
|
const moving = node.builder.source.getNode(sourcePath);
|
|
39902
40647
|
if (!moving || sourcePath === `${sourceRoot(node)}.pageRoot`) throw new Error("The page root cannot be moved");
|
|
40648
|
+
validateCatalogueSource(visualEditorScope(node).GET(".catalogueScope"), moving.parentBag);
|
|
39903
40649
|
if (moving.resolver) throw new Error("Resolver-backed Source nodes cannot be moved in this trial");
|
|
39904
40650
|
if (sourcePath === targetPath || targetPath.startsWith(sourcePath + ".")) throw new Error("A node cannot be moved into itself");
|
|
39905
40651
|
const parent = item, origin = moving.parentBag, Source = node.builder.source.constructor;
|
|
@@ -39940,6 +40686,7 @@ var VisualEditorLogic = class {
|
|
|
39940
40686
|
return;
|
|
39941
40687
|
}
|
|
39942
40688
|
const tag2 = dropValues["app/widget"].tag;
|
|
40689
|
+
this.validateCatalogueTag(node, tag2);
|
|
39943
40690
|
item.builder.validateParent(tag2, item.nodeTag);
|
|
39944
40691
|
const body = item.getValue(true);
|
|
39945
40692
|
item.builder.validateChildren(item.nodeTag, [...body instanceof node.builder.source.constructor ? body.getNodes().map((child) => child.nodeTag) : [], tag2]);
|
|
@@ -39956,7 +40703,7 @@ var VisualEditorLogic = class {
|
|
|
39956
40703
|
fields.getValue(true).clear();
|
|
39957
40704
|
const root = node.builder.wrapSource(fields);
|
|
39958
40705
|
root.p(`Insert ${tag2} into ${item.label} [${item.nodeTag}]`, { class: "visual-editor-hint" });
|
|
39959
|
-
const form = root.formlet({ columns: 2, gap: "
|
|
40706
|
+
const form = root.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
39960
40707
|
for (const [name, spec] of required) this.parameterField(node, form, tag2, name, spec, "insertion", spec.default);
|
|
39961
40708
|
node.SET(".insertionOpen", true);
|
|
39962
40709
|
}
|
|
@@ -39977,8 +40724,9 @@ var VisualEditorLogic = class {
|
|
|
39977
40724
|
const parent = current.parentNode;
|
|
39978
40725
|
const entries3 = specifications(parent, current.nodeTag, current);
|
|
39979
40726
|
node.SET(".properties.path", path);
|
|
40727
|
+
this.attributeRows(node, current);
|
|
39980
40728
|
node.SET(".propertiesTitle", `${current.label} [${current.nodeTag}]`);
|
|
39981
|
-
node.SET(".propertiesHeight", `${Math.min(
|
|
40729
|
+
node.SET(".propertiesHeight", `${Math.min(300, Math.max(180, 80 + Math.ceil(Object.keys(entries3).filter((name) => parameterTheme(name, /* @__PURE__ */ new Set()) === "general").length / 2) * 38))}px`);
|
|
39982
40730
|
const root = node.builder.wrapSource(fields);
|
|
39983
40731
|
if (path !== "pageRoot") root.p(path, { class: "visual-editor-destination" });
|
|
39984
40732
|
const parentFields = new Set(Object.keys(parent._getMeta("gramlot_component")?.childParameters ?? {}));
|
|
@@ -39995,11 +40743,22 @@ var VisualEditorLogic = class {
|
|
|
39995
40743
|
});
|
|
39996
40744
|
for (const [key2, title] of parameterThemes) {
|
|
39997
40745
|
if (!groups.get(key2).length) continue;
|
|
39998
|
-
const panel = tabs.contentPane({
|
|
40746
|
+
const panel = tabs.contentPane({
|
|
40747
|
+
pageName: key2,
|
|
40748
|
+
title,
|
|
40749
|
+
overflow: "auto",
|
|
40750
|
+
padding: "4px",
|
|
40751
|
+
min_height: 0,
|
|
40752
|
+
...key2 === "styles" ? { nodeId: visualEditorScope(node).getAttr("visualEditorId") + "StyleAttributes" } : {}
|
|
40753
|
+
});
|
|
40754
|
+
if (key2 === "styles") {
|
|
40755
|
+
this.attributeFields(node, panel, current, "styles");
|
|
40756
|
+
continue;
|
|
40757
|
+
}
|
|
39999
40758
|
if (key2 === "container") panel.p(`Child parameters of ${parent.nodeTag}`, { class: "visual-editor-hint" });
|
|
40000
40759
|
if (key2 === "behaviour" && Object.hasOwn(entries3, "action")) panel.p("action: use a named Logic method, for example openCatalogue.", { class: "visual-editor-hint" });
|
|
40001
40760
|
if (key2 === "behaviour" && current.nodeTag === "borderContainer") panel.p("persist remembers splitter sizes and requires a stable container id.", { class: "visual-editor-hint" });
|
|
40002
|
-
const form = panel.formlet({ columns: 2, gap: "
|
|
40761
|
+
const form = panel.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
40003
40762
|
if (key2 === "general" && current._getMeta("gramlot_component")?.labelbox) {
|
|
40004
40763
|
this.labelboxFields(node, form, current, entries3);
|
|
40005
40764
|
}
|
|
@@ -40016,7 +40775,7 @@ var VisualEditorLogic = class {
|
|
|
40016
40775
|
if (!advanced) {
|
|
40017
40776
|
const details = panel.details({ class: "visual-validation-advanced" });
|
|
40018
40777
|
details.summary("Conditions and messages");
|
|
40019
|
-
advanced = details.formlet({ columns: 2, gap: "
|
|
40778
|
+
advanced = details.formlet({ columns: 2, gap: "4px 6px", lbl_position: "TL", box_c_width: "100%", align_items: "start" });
|
|
40020
40779
|
}
|
|
40021
40780
|
target = advanced;
|
|
40022
40781
|
}
|
|
@@ -40024,8 +40783,170 @@ var VisualEditorLogic = class {
|
|
|
40024
40783
|
this.parameterField(node, target, current.nodeTag, name, spec, "properties", value ?? spec.default);
|
|
40025
40784
|
}
|
|
40026
40785
|
}
|
|
40786
|
+
const more = tabs.contentPane({ nodeId: visualEditorScope(node).getAttr("visualEditorId") + "MoreAttributes", pageName: "attributes", title: "More attributes", overflow: "auto", padding: "4px", min_height: 0 });
|
|
40787
|
+
this.attributeFields(node, more, current);
|
|
40027
40788
|
node.SET(".propertiesOpen", true);
|
|
40028
40789
|
}
|
|
40790
|
+
attributeRows(node, current) {
|
|
40791
|
+
const rows = new Bag();
|
|
40792
|
+
for (const [name, value] of Object.entries(current.getAttr())) {
|
|
40793
|
+
if (name === "_meta") continue;
|
|
40794
|
+
const type = scalarType(value);
|
|
40795
|
+
const text3 = type ? scalarText(value, type) : "[non-scalar value]";
|
|
40796
|
+
rows.setItem(`r${rows.length}`, new Bag({ name, type: type ?? "readonly", text: text3, original: text3 }));
|
|
40797
|
+
}
|
|
40798
|
+
node.SET(".properties.attributeRows", rows);
|
|
40799
|
+
node.SET(".properties.attributeDraft", new Bag({ name: "", type: "string", text: "" }));
|
|
40800
|
+
node.SET(".properties.attributeDraftHidden", true);
|
|
40801
|
+
}
|
|
40802
|
+
attributeFields(node, panel, current, scope = "attributes") {
|
|
40803
|
+
const path = node.GET(".properties.path");
|
|
40804
|
+
const base = `${editorData(node)}.properties`;
|
|
40805
|
+
const renderer = node.rootBuilder.binding.gramlot.src.renderer;
|
|
40806
|
+
const parentFields = new Set(Object.keys(current.parentNode._getMeta("gramlot_component")?.childParameters ?? {}));
|
|
40807
|
+
const list = panel.div({ class: "visual-editor-attribute-list", "aria-label": scope === "styles" ? "Style attributes" : "Node attributes" });
|
|
40808
|
+
const heading = list.div({ class: "visual-editor-attribute-row visual-editor-attribute-heading" });
|
|
40809
|
+
heading.span("Attribute", { class: "visual-editor-attribute-name" });
|
|
40810
|
+
const headingValue = heading.div({ class: "visual-editor-attribute-value" });
|
|
40811
|
+
headingValue.span("Value");
|
|
40812
|
+
headingValue.button("+", {
|
|
40813
|
+
action: "beginAttribute",
|
|
40814
|
+
editingPath: path,
|
|
40815
|
+
"aria-label": scope === "styles" ? "Add style attribute" : "Add attribute",
|
|
40816
|
+
title: "Add attribute",
|
|
40817
|
+
class: "visual-editor-attribute-command"
|
|
40818
|
+
});
|
|
40819
|
+
for (const row of node.GET(".properties.attributeRows").getNodes()) {
|
|
40820
|
+
const name = row.value.getItem("name"), type = row.value.getItem("type"), key2 = row.label;
|
|
40821
|
+
if (scope === "styles" && parameterTheme(name, parentFields) !== "styles" && !renderer._isStyleContribution(name)) continue;
|
|
40822
|
+
const editable = type !== "readonly";
|
|
40823
|
+
const line = list.div({ class: "visual-editor-attribute-row" });
|
|
40824
|
+
line.span(name, { class: "visual-editor-attribute-name", title: name });
|
|
40825
|
+
const cell = line.div({ class: "visual-editor-attribute-value" });
|
|
40826
|
+
cell.input({
|
|
40827
|
+
value: `^${base}.attributeRows.${key2}.text`,
|
|
40828
|
+
disabled: !editable,
|
|
40829
|
+
"aria-label": `${name} attribute value`,
|
|
40830
|
+
title: editable ? type : "Non-scalar values are read-only"
|
|
40831
|
+
});
|
|
40832
|
+
cell.button("\xD7", {
|
|
40833
|
+
action: "removeAttribute",
|
|
40834
|
+
attributeRow: key2,
|
|
40835
|
+
editingPath: path,
|
|
40836
|
+
disabled: !editable,
|
|
40837
|
+
"aria-label": `Remove ${name} attribute`,
|
|
40838
|
+
title: `Remove ${name}`,
|
|
40839
|
+
class: "visual-editor-attribute-command"
|
|
40840
|
+
});
|
|
40841
|
+
if (editable && scope === "attributes") line.dataController({
|
|
40842
|
+
func: "changeAttribute",
|
|
40843
|
+
value: `^${base}.attributeRows.${key2}.text`,
|
|
40844
|
+
attributeRow: key2,
|
|
40845
|
+
editingPath: path,
|
|
40846
|
+
_userChanges: true
|
|
40847
|
+
});
|
|
40848
|
+
}
|
|
40849
|
+
const add2 = list.div({
|
|
40850
|
+
class: "visual-editor-attribute-row",
|
|
40851
|
+
hidden: `^${base}.attributeDraftHidden`,
|
|
40852
|
+
connect_onkeydown: "attributeDraftKey"
|
|
40853
|
+
});
|
|
40854
|
+
const nameCell = add2.div({ class: "visual-editor-attribute-name" });
|
|
40855
|
+
nameCell.input({ value: `^${base}.attributeDraft.name`, live: true, "aria-label": "New attribute name", placeholder: "Attribute name" });
|
|
40856
|
+
const valueCell = add2.div({ class: "visual-editor-attribute-value" });
|
|
40857
|
+
valueCell.input({ value: `^${base}.attributeDraft.text`, live: true, "aria-label": "New attribute value", placeholder: "Value" });
|
|
40858
|
+
const types = valueCell.select({ value: `^${base}.attributeDraft.type`, "aria-label": "New attribute type" });
|
|
40859
|
+
for (const type of editorTypes) types.option(type, { value: type });
|
|
40860
|
+
valueCell.button("\u2713", { action: "addAttribute", editingPath: path, "aria-label": "Apply new attribute", title: "Apply (Enter)", class: "visual-editor-attribute-command" });
|
|
40861
|
+
valueCell.button("\xD7", { action: "cancelAttribute", "aria-label": "Cancel new attribute", title: "Cancel (Escape)", class: "visual-editor-attribute-command" });
|
|
40862
|
+
}
|
|
40863
|
+
beginAttribute(node, { editingPath }) {
|
|
40864
|
+
const editor = visualEditorScope(node);
|
|
40865
|
+
if (editingPath !== editor.GET(".selection")) return;
|
|
40866
|
+
editor.SET(".properties.attributeDraft", new Bag({ name: "", type: "string", text: "" }));
|
|
40867
|
+
editor.SET(".properties.attributeDraftHidden", false);
|
|
40868
|
+
editor.SET(".propertyError", "");
|
|
40869
|
+
}
|
|
40870
|
+
cancelAttribute(node) {
|
|
40871
|
+
visualEditorScope(node).SET(".properties.attributeDraftHidden", true);
|
|
40872
|
+
}
|
|
40873
|
+
attributeDraftKey(node, event) {
|
|
40874
|
+
if (event.isComposing || !["Enter", "Escape"].includes(event.key)) return;
|
|
40875
|
+
event.preventDefault();
|
|
40876
|
+
event.stopPropagation();
|
|
40877
|
+
const editor = visualEditorScope(node);
|
|
40878
|
+
if (event.key === "Escape") this.cancelAttribute(editor);
|
|
40879
|
+
else this.addAttribute(editor, { editingPath: editor.GET(".properties.path") });
|
|
40880
|
+
}
|
|
40881
|
+
addAttribute(node, { editingPath }) {
|
|
40882
|
+
const editor = visualEditorScope(node);
|
|
40883
|
+
if (editingPath !== editor.GET(".selection")) return;
|
|
40884
|
+
editor.SET(".propertyError", "");
|
|
40885
|
+
try {
|
|
40886
|
+
const draft = editor.GET(".properties.attributeDraft");
|
|
40887
|
+
const name = draft.getItem("name");
|
|
40888
|
+
if (!name || !/^[^\s"'<>/=]+$/.test(name)) throw new Error("Enter a valid attribute name.");
|
|
40889
|
+
if (["_meta", "__proto__", "constructor", "prototype"].includes(name)) throw new Error("Unsupported attribute name.");
|
|
40890
|
+
const current = editor.builder.source.getNode(`${sourceRoot(editor)}.${editingPath}`);
|
|
40891
|
+
if (!current) throw new Error("The selected Source node no longer exists");
|
|
40892
|
+
if (Object.hasOwn(current.getAttr(), name)) throw new Error(`Duplicate attribute: ${name}`);
|
|
40893
|
+
const value = parseScalar(draft.getItem("type"), String(draft.getItem("text") ?? ""));
|
|
40894
|
+
this.writeAttribute(editor, current, editingPath, name, value, false);
|
|
40895
|
+
} catch (error) {
|
|
40896
|
+
editor.SET(".propertyError", error.message);
|
|
40897
|
+
}
|
|
40898
|
+
}
|
|
40899
|
+
changeAttribute(node, { attributeRow, editingPath, value }) {
|
|
40900
|
+
this.editAttribute(node, { attributeRow, editingPath, value, remove: false });
|
|
40901
|
+
}
|
|
40902
|
+
removeAttribute(node, { attributeRow, editingPath }) {
|
|
40903
|
+
this.editAttribute(node, { attributeRow, editingPath, remove: true });
|
|
40904
|
+
}
|
|
40905
|
+
editAttribute(node, { attributeRow, editingPath, value, remove }) {
|
|
40906
|
+
const editor = visualEditorScope(node);
|
|
40907
|
+
if (editingPath !== editor.GET(".selection")) return;
|
|
40908
|
+
editor.SET(".propertyError", "");
|
|
40909
|
+
try {
|
|
40910
|
+
const row = editor.GET(".properties.attributeRows").getItem(attributeRow);
|
|
40911
|
+
if (!row || row.getItem("type") === "readonly") throw new Error("This attribute is not editable");
|
|
40912
|
+
const name = row.getItem("name");
|
|
40913
|
+
if (["_meta", "__proto__", "constructor", "prototype"].includes(name)) throw new Error("Unsupported attribute name.");
|
|
40914
|
+
const current = editor.builder.source.getNode(`${sourceRoot(editor)}.${editingPath}`);
|
|
40915
|
+
if (!current) throw new Error("The selected Source node no longer exists");
|
|
40916
|
+
const attrs = current.getAttr(), type = scalarType(attrs[name]);
|
|
40917
|
+
if (!Object.hasOwn(attrs, name) || type !== row.getItem("type") || scalarText(attrs[name], type) !== row.getItem("original"))
|
|
40918
|
+
throw new Error("Attribute changed; select the node again before editing.");
|
|
40919
|
+
const parsed = remove ? null : parseScalar(type, String(value ?? ""));
|
|
40920
|
+
this.writeAttribute(editor, current, editingPath, name, parsed, remove, row);
|
|
40921
|
+
} catch (error) {
|
|
40922
|
+
editor.SET(".propertyError", error.message);
|
|
40923
|
+
}
|
|
40924
|
+
}
|
|
40925
|
+
writeAttribute(editor, current, path, name, value, remove, row = null) {
|
|
40926
|
+
const attrs = { ...current.getAttr() };
|
|
40927
|
+
if (remove) delete attrs[name];
|
|
40928
|
+
else attrs[name] = value;
|
|
40929
|
+
const specs = specifications(current.parentNode, current.nodeTag, current);
|
|
40930
|
+
if (specs[name]) this.validateParameter(current.parentNode, current, name, specs[name], remove ? null : value);
|
|
40931
|
+
const design = editor.builder.source.getNode(sourceRoot(editor)), app = editor.rootBuilder.binding.gramlot;
|
|
40932
|
+
const candidate = app.src.prepareSource(design.getValue(true).toTytx(), design.builder);
|
|
40933
|
+
candidate.getNode(path).setAttr(attrs, true, false, false);
|
|
40934
|
+
validateCatalogueSource(editor.GET(".catalogueScope"), candidate);
|
|
40935
|
+
app.src.renderer.validateCandidate(candidate, { replacingNode: design });
|
|
40936
|
+
current.setAttr(attrs, true, false, false);
|
|
40937
|
+
if (row && !remove) {
|
|
40938
|
+
const text3 = scalarText(value, row.getItem("type"));
|
|
40939
|
+
row.setItem("original", text3);
|
|
40940
|
+
row.setItem("text", text3);
|
|
40941
|
+
const type = editor.GET(`.properties.types.${name}`);
|
|
40942
|
+
if (specs[name]?.enum) editor.SET(`.properties.parameters.${name}`, value);
|
|
40943
|
+
else if (type) editor.SET(`.properties.parameters.${name}.${type}`, value);
|
|
40944
|
+
} else {
|
|
40945
|
+
const tab = editor.GET(".parameterTab") === "styles" ? "styles" : "attributes";
|
|
40946
|
+
this.showProperties(editor, { path });
|
|
40947
|
+
editor.SET(".parameterTab", tab);
|
|
40948
|
+
}
|
|
40949
|
+
}
|
|
40029
40950
|
toggleLabelboxAttributes(node, { prefix }) {
|
|
40030
40951
|
node.SET(`.properties.${prefix}Hidden`, !node.GET(`.properties.${prefix}Hidden`));
|
|
40031
40952
|
}
|
|
@@ -40184,6 +41105,7 @@ var VisualEditorLogic = class {
|
|
|
40184
41105
|
try {
|
|
40185
41106
|
const current = node.builder.source.getNode(`${sourceRoot(node)}.${editingPath}`);
|
|
40186
41107
|
if (!current) throw new Error("The selected Source node no longer exists");
|
|
41108
|
+
if (parameterName !== "_text" && Object.is(current.getAttr(parameterName), value)) return;
|
|
40187
41109
|
const specs = specifications(current.parentNode, current.nodeTag, current);
|
|
40188
41110
|
const spec = specs[parameterName];
|
|
40189
41111
|
if (!spec) throw new Error(`Unknown parameter: ${parameterName}`);
|
|
@@ -40195,6 +41117,12 @@ var VisualEditorLogic = class {
|
|
|
40195
41117
|
else attrs[parameterName] = value;
|
|
40196
41118
|
current.setAttr(attrs, true, false, false);
|
|
40197
41119
|
}
|
|
41120
|
+
this.attributeRows(node, current);
|
|
41121
|
+
for (const [field, scope] of [["MoreAttributes", "attributes"], ["StyleAttributes", "styles"]]) {
|
|
41122
|
+
const panel = editorField(node, field);
|
|
41123
|
+
panel.getValue(true).clear();
|
|
41124
|
+
this.attributeFields(node, node.builder.wrapSource(panel), current, scope);
|
|
41125
|
+
}
|
|
40198
41126
|
} catch (error) {
|
|
40199
41127
|
node.SET(".propertyError", error.message);
|
|
40200
41128
|
}
|
|
@@ -40206,6 +41134,11 @@ var VisualEditorLogic = class {
|
|
|
40206
41134
|
const children = parent.getValue(true);
|
|
40207
41135
|
if (!empty2 && spec.unique && children instanceof parent.builder.source.constructor && children.getNodes().some((child) => child !== current && child.getAttr(name) === value)) throw new Error(`${name} is already in use`);
|
|
40208
41136
|
}
|
|
41137
|
+
validateCatalogueTag(node, tag2) {
|
|
41138
|
+
const scope = visualEditorScope(node).GET(".catalogueScope");
|
|
41139
|
+
if (!catalogueAllows(scope, tag2, node.builder.schema[tag2]?._meta ?? {}))
|
|
41140
|
+
throw new Error(`Tag ${tag2} is outside the editor catalogue`);
|
|
41141
|
+
}
|
|
40209
41142
|
applyInsert(node) {
|
|
40210
41143
|
if (node.GET(".insertion.clipboard")) {
|
|
40211
41144
|
this.finishPaste(node);
|
|
@@ -40215,6 +41148,7 @@ var VisualEditorLogic = class {
|
|
|
40215
41148
|
const parent = node.builder.source.getNode(`${sourceRoot(node)}.${path}`);
|
|
40216
41149
|
if (!parent) throw new Error("The target Source node is no longer available");
|
|
40217
41150
|
const tag2 = node.GET(".insertion.tag");
|
|
41151
|
+
this.validateCatalogueTag(node, tag2);
|
|
40218
41152
|
const attrs = {};
|
|
40219
41153
|
for (const [name, spec] of Object.entries(specifications(parent, tag2)).filter(([, spec2]) => spec2.required)) {
|
|
40220
41154
|
const type = node.GET(`.insertion.types.${name}`);
|