@gramlot/gramlot 0.3.27 → 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.
Files changed (194) hide show
  1. package/assets/icons/chart.svg +1 -0
  2. package/dist/components/audio/__init__.py +13 -0
  3. package/dist/components/audio/assets/collection.js +3 -0
  4. package/dist/components/audio/assets/index.js +3 -0
  5. package/dist/components/audio/commands.json +7 -0
  6. package/dist/components/audio/grammar.json +335 -0
  7. package/dist/components/charts/__init__.py +13 -0
  8. package/dist/components/charts/assets/collection.js +47 -0
  9. package/dist/components/charts/assets/files/55ea01207028f76d844678511f29fc800f8a1e67a8a0fe80470128677847ad32-echarts-gl.txt +29 -0
  10. package/dist/components/charts/assets/files/63727832aaf62004a2b249c933e327f3c90caf49e41a72f4bf436edf632cbda8-vega.txt +27 -0
  11. package/dist/components/charts/assets/files/8c45d9eaf50c2f72dd9c7ab9ef440788ba58a3538484b5c51c1f17d5128752e7-plotly.txt +21 -0
  12. package/dist/components/charts/assets/files/8f989229699b4fe2f1a0432d0e9edc338a8a911e250e2d1b01ecd770a5f5b1bd-uplot.txt +21 -0
  13. package/dist/components/charts/assets/files/c8fa058cba98f7f288b5d8fa4116f441d6dacb25b96da859e518c973fff41d0c-claygl.txt +23 -0
  14. package/dist/components/charts/assets/index.js +3 -0
  15. package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +76 -0
  16. package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +1 -0
  17. package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +4409 -0
  18. package/dist/components/charts/assets/modules/plotly.min-4LB7HE7P.js +3596 -0
  19. package/dist/components/charts/assets/modules/uPlot.esm-5JJNHHRF.js +3 -0
  20. package/dist/components/charts/assets/modules/uPlot.min-N3E3FA74.js +1 -0
  21. package/dist/components/charts/assets/modules/vega.module-2QCOVQ3A.js +13 -0
  22. package/dist/components/charts/commands.json +7 -0
  23. package/dist/components/charts/grammar.json +1113 -0
  24. package/dist/components/chat/__init__.py +1 -1
  25. package/dist/components/chat/assets/collection.js +3 -3
  26. package/dist/components/chat/assets/index.js +1 -1
  27. package/dist/components/drawing/__init__.py +15 -0
  28. package/dist/components/drawing/assets/collection.js +28 -0
  29. package/dist/components/drawing/assets/index.js +3 -0
  30. package/dist/components/drawing/commands.json +7 -0
  31. package/dist/components/drawing/grammar.json +110 -0
  32. package/dist/components/editors/__init__.py +2 -2
  33. package/dist/components/editors/assets/collection.js +18 -18
  34. package/dist/components/editors/assets/index.js +1 -1
  35. package/dist/components/editors/assets/modules/{prose-mirror-engine-GMZPJPNN.js → prose-mirror-engine-DQEAEIMV.js} +2 -2
  36. package/dist/components/editors/grammar.json +150 -0
  37. package/dist/components/grid/__init__.py +1 -1
  38. package/dist/components/grid/assets/collection.js +51 -30
  39. package/dist/components/grid/assets/index.js +1 -1
  40. package/dist/components/grid/grammar.json +258 -0
  41. package/dist/components/grouplets/__init__.py +1 -1
  42. package/dist/components/grouplets/assets/collection.js +3 -3
  43. package/dist/components/grouplets/assets/index.js +1 -1
  44. package/dist/components/inputs/__init__.py +3 -2
  45. package/dist/components/inputs/assets/collection.js +38 -23
  46. package/dist/components/inputs/assets/index.js +1 -1
  47. package/dist/components/inputs/grammar.json +1533 -321
  48. package/dist/components/layout/__init__.py +1 -1
  49. package/dist/components/layout/assets/collection.js +27 -23
  50. package/dist/components/layout/assets/index.js +1 -1
  51. package/dist/components/layout/grammar.json +85 -0
  52. package/dist/components/selection_trial/__init__.py +1 -1
  53. package/dist/components/selection_trial/assets/collection.js +3 -3
  54. package/dist/components/selection_trial/assets/index.js +1 -1
  55. package/dist/components/tree/__init__.py +1 -1
  56. package/dist/components/tree/assets/collection.js +11 -11
  57. package/dist/components/tree/assets/index.js +1 -1
  58. package/dist/components/tree/grammar.json +126 -0
  59. package/dist/components/typst/__init__.py +1 -1
  60. package/dist/components/typst/assets/collection.js +2 -2
  61. package/dist/components/typst/assets/index.js +1 -1
  62. package/dist/components/uploads/__init__.py +1 -1
  63. package/dist/components/uploads/assets/collection.js +8 -8
  64. package/dist/components/uploads/assets/index.js +1 -1
  65. package/dist/components/vizabi/__init__.py +13 -0
  66. package/dist/components/vizabi/assets/collection.js +22 -0
  67. package/dist/components/vizabi/assets/index.js +3 -0
  68. package/dist/components/vizabi/commands.json +7 -0
  69. package/dist/components/vizabi/grammar.json +128 -0
  70. package/dist/gramlot.js +572 -176
  71. package/dist/gramlot.min.js +85 -53
  72. package/dist/standard-collections.js +2 -0
  73. package/package.json +12 -4
  74. package/src/binding/grid-struct.js +2 -2
  75. package/src/binding/runtime.js +10 -0
  76. package/src/bootstrap.js +1 -1
  77. package/src/builder/gramlot-builder.d.ts +15 -2
  78. package/src/builder/gramlot-builder.js +22 -3
  79. package/src/builder/source.js +24 -1
  80. package/src/components/audio-analysis-session.js +65 -0
  81. package/src/components/audio.js +44 -0
  82. package/src/components/bases.js +6 -4
  83. package/src/components/border-container.js +6 -3
  84. package/src/components/buttons.js +47 -3
  85. package/src/components/chart-bar3d-options.js +30 -0
  86. package/src/components/chart-controls.js +83 -0
  87. package/src/components/chart-data-view.js +52 -0
  88. package/src/components/chart-data.js +42 -0
  89. package/src/components/chart-domains.js +46 -0
  90. package/src/components/chart-engines/echarts-options.js +50 -0
  91. package/src/components/chart-engines/echarts.js +82 -0
  92. package/src/components/chart-engines/index.js +22 -0
  93. package/src/components/chart-engines/plotly-map.js +34 -0
  94. package/src/components/chart-engines/plotly-spatial.js +35 -0
  95. package/src/components/chart-engines/plotly.js +138 -0
  96. package/src/components/chart-engines/uplot.js +57 -0
  97. package/src/components/chart-engines/vega.js +101 -0
  98. package/src/components/chart-fields.js +110 -0
  99. package/src/components/chart-geographic-options.js +47 -0
  100. package/src/components/chart-geojson.js +60 -0
  101. package/src/components/chart-geometry.js +11 -0
  102. package/src/components/chart-map-anchors.js +24 -0
  103. package/src/components/chart-map-bar3d-options.js +41 -0
  104. package/src/components/chart-map-data.js +25 -0
  105. package/src/components/chart-map-labels.js +8 -0
  106. package/src/components/chart-map-options.js +20 -0
  107. package/src/components/chart-pane.js +91 -0
  108. package/src/components/chart-renderer.js +58 -0
  109. package/src/components/chart-sample-view.js +32 -0
  110. package/src/components/chart-spatial-options.js +40 -0
  111. package/src/components/chart-time.js +84 -0
  112. package/src/components/chart-timeline.js +70 -0
  113. package/src/components/chart-types/area.js +2 -0
  114. package/src/components/chart-types/bar.js +2 -0
  115. package/src/components/chart-types/bar3D.js +2 -0
  116. package/src/components/chart-types/donut.js +2 -0
  117. package/src/components/chart-types/horizontalBar.js +2 -0
  118. package/src/components/chart-types/index.js +26 -0
  119. package/src/components/chart-types/line.js +2 -0
  120. package/src/components/chart-types/line3D.js +2 -0
  121. package/src/components/chart-types/lines3D.js +2 -0
  122. package/src/components/chart-types/map.js +2 -0
  123. package/src/components/chart-types/map3D.js +2 -0
  124. package/src/components/chart-types/mapBar3D.js +2 -0
  125. package/src/components/chart-types/pie.js +2 -0
  126. package/src/components/chart-types/polygons3D.js +2 -0
  127. package/src/components/chart-types/scatter.js +2 -0
  128. package/src/components/chart-types/scatter3D.js +2 -0
  129. package/src/components/chart-types/stackedArea.js +2 -0
  130. package/src/components/chart-types/stackedBar.js +2 -0
  131. package/src/components/chart-types/surface.js +2 -0
  132. package/src/components/charts.js +152 -0
  133. package/src/components/check-box-text-editor.js +88 -0
  134. package/src/components/check-box-text.js +193 -0
  135. package/src/components/check-box-tree.js +62 -0
  136. package/src/components/choice-editor.js +7 -5
  137. package/src/components/choice-field-styles.js +14 -0
  138. package/src/components/choices.js +5 -0
  139. package/src/components/drawing.js +199 -0
  140. package/src/components/grid-check-sets.js +98 -0
  141. package/src/components/grid-column-filters.js +198 -0
  142. package/src/components/grid-grammar.json +44 -0
  143. package/src/components/grid-header-interaction.js +3 -1
  144. package/src/components/grid-rows.js +2 -2
  145. package/src/components/grid-search-box.js +38 -22
  146. package/src/components/grid-search-styles.js +13 -14
  147. package/src/components/grid-search.js +8 -1
  148. package/src/components/grid-structure.js +10 -2
  149. package/src/components/grid-styles.js +23 -0
  150. package/src/components/grid.js +52 -10
  151. package/src/components/image-uploader.js +2 -2
  152. package/src/components/inputs.js +19 -10
  153. package/src/components/labelbox.js +5 -1
  154. package/src/components/licenses/claygl.txt +23 -0
  155. package/src/components/licenses/echarts-gl.txt +29 -0
  156. package/src/components/licenses/plotly.txt +21 -0
  157. package/src/components/licenses/uplot.txt +21 -0
  158. package/src/components/licenses/vega.txt +27 -0
  159. package/src/components/menus.js +19 -11
  160. package/src/components/toolbar-overflow.js +12 -8
  161. package/src/components/tree.js +30 -8
  162. package/src/components/typed-editor.js +14 -3
  163. package/src/components/vizabi-session.js +66 -0
  164. package/src/components/vizabi.js +66 -0
  165. package/src/components/window-surface.js +20 -9
  166. package/src/components/windows.js +1 -1
  167. package/src/gramlot.d.ts +1 -0
  168. package/src/gramlot.js +2 -0
  169. package/src/handlers/device-handler.js +32 -32
  170. package/src/handlers/source-handler.d.ts +2 -2
  171. package/src/ide-documents.js +19 -3
  172. package/src/ide-runtime.d.ts +1 -0
  173. package/src/ide-runtime.js +45 -31
  174. package/src/index.d.ts +1 -0
  175. package/src/renderer/drag-drop.js +1 -0
  176. package/src/renderer/gramlot-renderer.d.ts +2 -0
  177. package/src/renderer/gramlot-renderer.js +5 -4
  178. package/src/server/assets.d.ts +3 -0
  179. package/src/server/assets.js +9 -0
  180. package/src/server/gramlot-server.d.ts +1 -1
  181. package/src/server/gramlot-server.js +2 -1
  182. package/src/server/index.d.ts +1 -1
  183. package/src/server/index.js +1 -1
  184. package/src/server/visual-editor.js +17 -17
  185. package/src/stores/bag-collection-view.js +79 -17
  186. package/src/stores/collection-filter.js +2 -1
  187. package/src/stores/column-filter.js +49 -0
  188. package/src/stores/id-set.js +10 -0
  189. package/src/view/controls.js +8 -0
  190. package/src/view/html.js +10 -1
  191. package/src/view/label-menu.js +61 -0
  192. package/src/view/labelbox.js +15 -2
  193. package/themes/gramlot-base/theme.css +6 -0
  194. package/tools/gramlot-tools-inspector.js +169 -505
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[hidden]{display:none!important}
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([
@@ -23201,21 +23309,6 @@ function parameterValues(component, attrs) {
23201
23309
  return Object.fromEntries(Object.entries(component.parameters).map(([name, spec]) => [name, Object.hasOwn(attrs, name) ? attrs[name] : spec.default]));
23202
23310
  }
23203
23311
 
23204
- // src/components/choices.js
23205
- function parseChoices(values, separator = ",") {
23206
- if (typeof separator !== "string" || !separator) throw new TypeError("separator must be a nonempty string");
23207
- if (values === "") return [];
23208
- const ids = /* @__PURE__ */ new Set();
23209
- return values.split(separator).map((item) => {
23210
- const colon = item.indexOf(":");
23211
- const id = colon < 0 ? item : item.slice(0, colon);
23212
- const caption = colon < 0 ? item : item.slice(colon + 1);
23213
- if (!id || ids.has(id)) throw new Error("Invalid or duplicate choice code");
23214
- ids.add(id);
23215
- return { id, caption };
23216
- });
23217
- }
23218
-
23219
23312
  // src/components/bases.js
23220
23313
  function controlElement(HTMLElement) {
23221
23314
  return class extends HTMLElement {
@@ -23370,11 +23463,15 @@ function ChoiceGroup(HTMLElement) {
23370
23463
  items[next].focus();
23371
23464
  });
23372
23465
  }
23466
+ choiceOptions() {
23467
+ return parseChoices(this.parameters.values ?? "");
23468
+ }
23373
23469
  projectAttributes(attrs, adapt) {
23374
23470
  const rest = super.projectAttributes(attrs, adapt);
23375
- const values = this.parameters.values ?? "";
23376
- if (values !== this.#values) {
23377
- const options = parseChoices(values);
23471
+ const values = this.choiceOptions();
23472
+ const signature = JSON.stringify(values);
23473
+ if (signature !== this.#values) {
23474
+ const options = values;
23378
23475
  const retained = /* @__PURE__ */ new Set();
23379
23476
  let previous = null;
23380
23477
  for (const { id: code, caption } of options) {
@@ -23401,7 +23498,7 @@ function ChoiceGroup(HTMLElement) {
23401
23498
  item.label.remove();
23402
23499
  this.#options.delete(code);
23403
23500
  }
23404
- this.#values = values;
23501
+ this.#values = signature;
23405
23502
  }
23406
23503
  const cols = this.parameters.cols;
23407
23504
  if (!Number.isInteger(cols) || cols < 1) throw new TypeError("cols must be a positive integer");
@@ -23835,6 +23932,7 @@ var ToolbarOverflow = class {
23835
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}
23836
23933
  :host([role=toolbar][aria-orientation=vertical]) .toolbar-viewport{flex-direction:column;align-items:stretch;overflow-x:hidden;overflow-y:auto;width:100%}
23837
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}
23838
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}
23839
23937
  .toolbar-more svg{display:block;width:18px;height:18px;pointer-events:none}
23840
23938
  .toolbar-more:hover,.toolbar-more:focus-visible{background:var(--gramlot-selected,Highlight)}
@@ -23922,27 +24020,28 @@ var ToolbarOverflow = class {
23922
24020
  this.#overflow.clear();
23923
24021
  menu.refreshItems();
23924
24022
  for (const item of menu.items) item.refreshAvailability();
24023
+ this.#viewport.setAttribute("data-measuring", "");
23925
24024
  const gap = parseFloat(win.getComputedStyle(this.#viewport).gap) || 0;
23926
24025
  const lengths = new Map(units.map((unit) => {
23927
24026
  const css = win.getComputedStyle(unit);
23928
24027
  const length = labelboxContent(unit).localName === "gramlot-spacer" ? labelboxContent(unit).parameters.size ?? 0 : unit.getBoundingClientRect()[axis];
23929
24028
  return [unit, length + (parseFloat(css[vertical ? "marginTop" : "marginLeft"]) || 0) + (parseFloat(css[vertical ? "marginBottom" : "marginRight"]) || 0)];
23930
24029
  }));
24030
+ this.#viewport.removeAttribute("data-measuring");
23931
24031
  const separator = (unit) => labelboxContent(unit).getAttribute("role") === "separator";
23932
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")));
23933
24033
  const required = (remaining2) => remaining2.reduce((sum2, unit) => sum2 + lengths.get(unit), 0) + Math.max(0, remaining2.length - 1) * gap;
23934
24034
  let remaining = tidy(units);
23935
24035
  if (required(remaining) > available) {
23936
- const candidates = units.map((unit, index) => ({ unit, index })).filter(({ unit }) => labelboxContent(unit).localName === "gramlot-menu-line" && !separator(unit) && labelboxContent(unit).parameters.overflowable).sort((a, b) => labelboxContent(a.unit).parameters.priority - labelboxContent(b.unit).parameters.priority || b.index - a.index);
23937
- for (const { unit } of candidates) {
23938
- if (required(remaining) <= available - 32) break;
23939
- this.#overflow.add(unit);
23940
- 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));
23941
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);
23942
24043
  }
23943
- const overflowRows = tidy(units.filter((unit) => this.#overflow.has(unit) || separator(unit) && !remaining.includes(unit)));
23944
- for (const unit of overflowRows) this.#overflow.add(unit);
23945
- 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";
23946
24045
  for (const unit of this.#overflow) {
23947
24046
  unit.slot = "overflow";
23948
24047
  unit.setAttribute("data-menu-overflow", "");
@@ -24028,9 +24127,9 @@ function MenuContainer(HTMLElement) {
24028
24127
  const doc = this.ownerDocument, shadow = this.attachShadow({ mode: "open" });
24029
24128
  const style = doc.createElement("style");
24030
24129
  style.textContent = `:host{box-sizing:border-box;color:var(--gramlot-ink,CanvasText)}
24031
- :host([role=menu]){position:fixed;inset:auto;margin:0;padding:5px;min-width:min(16rem,var(--gramlot-popup-available-width));width:max-content;font:inherit;
24130
+ :host([role=menu]){position:fixed;inset:auto;margin:0;padding:3px;min-width:0;width:max-content;font:inherit;
24032
24131
  max-width:min(28rem,var(--gramlot-popup-available-width));max-height:var(--gramlot-popup-available-height);overflow:auto;
24033
- background:var(--gramlot-field-background,Canvas);border:1px solid var(--gramlot-border-control,#888);border-radius:var(--gramlot-radius-lg,9px);box-shadow:0 8px 28px #0004}
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}
24034
24133
  :host([role=toolbar][aria-orientation=vertical]){flex-direction:column;align-items:stretch}
24035
24134
  :host([role=toolbar]){display:flex;gap:var(--gramlot-toolbar-gap,4px);align-items:center}
24036
24135
  :host([role=menu]) ::slotted([role=separator]){margin:5px 7px 5px 2.5rem;border-top:1px solid var(--gramlot-border-control,#888)}
@@ -24074,8 +24173,11 @@ function MenuContainer(HTMLElement) {
24074
24173
  isOverflowed(item) {
24075
24174
  return this.#overflow.contains(item);
24076
24175
  }
24176
+ get visibleItems() {
24177
+ return this.items.filter((item) => labelboxPresentation(item).slot !== "suppressed" && !item.hidden && !item.closest("[hidden]") && item.getAttribute("role") !== "separator");
24178
+ }
24077
24179
  get usableItems() {
24078
- return this.items.filter((item) => labelboxPresentation(item).slot !== "suppressed" && !item.disabled && !item.hidden && !item.closest("[hidden]") && item.getAttribute("role") !== "separator");
24180
+ return this.visibleItems.filter((item) => !item.disabled);
24079
24181
  }
24080
24182
  get parentMenu() {
24081
24183
  return this.parentElement?.closest("gramlot-menu") ?? null;
@@ -24170,6 +24272,11 @@ function MenuContainer(HTMLElement) {
24170
24272
  for (const group of this.querySelectorAll("gramlot-menu-line")) if (group.menuOwner === this && group.parameters.group) group.refreshAvailability();
24171
24273
  for (const item of this.items) item.refreshAvailability();
24172
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");
24173
24280
  if (this.#active && !usable.includes(this.#active)) {
24174
24281
  const index = this.#previous.indexOf(this.#active);
24175
24282
  const next = this.#previous.slice(index + 1).find((item) => usable.includes(item)) ?? this.#previous.slice(0, index).reverse().find((item) => usable.includes(item));
@@ -24293,10 +24400,10 @@ function menuLine(Base) {
24293
24400
  const style = doc.createElement("style");
24294
24401
  style.textContent = `:host{color:var(--gramlot-ink,CanvasText)} .control-box{color:inherit;height:100%} :host button{color:inherit}
24295
24402
  .menu-check:empty,.menu-arrow:empty{display:none}
24296
- button.menu-row{display:grid;grid-template-columns:1em 1.15em minmax(0,1fr) .7em;column-gap:.5em;
24297
- align-items:center;width:100%;min-height:max(min(var(--gramlot-field-height,28px),28px),var(--gramlot-touch-target,0px));padding:var(--gramlot-button-padding,3px 8px);
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;
24298
24405
  line-height:1.3;text-align:left;border:0;border-radius:var(--gramlot-radius-sm,5px);background:transparent;cursor:default}
24299
- .menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:center;min-width:0}
24406
+ .menu-row .menu-check,.menu-row .icon,.menu-row .menu-arrow{display:flex;align-items:center;justify-content:start;min-width:0}
24300
24407
  .menu-row .menu-check{grid-column:1}.menu-row .icon{grid-column:2}
24301
24408
  .menu-row .menu-caption{grid-column:3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
24302
24409
  .menu-row .menu-arrow{grid-column:4;font-size:1.2em;line-height:1}
@@ -24308,6 +24415,7 @@ function menuLine(Base) {
24308
24415
  background:transparent;cursor:pointer;line-height:1.2;white-space:nowrap}
24309
24416
  :host button.toolbar-button .icon{display:inline-flex;align-items:center;justify-content:center;
24310
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)}
24311
24419
  :host button.toolbar-button .icon:empty{display:none}
24312
24420
  :host button.toolbar-button:hover:not(:disabled){background:color-mix(in srgb,currentColor 10%,transparent)}
24313
24421
  :host button.toolbar-button:focus-visible{outline:2px solid var(--gramlot-focus-ring,Highlight);outline-offset:-2px}
@@ -24317,7 +24425,7 @@ function menuLine(Base) {
24317
24425
  :host button.toolbar-below .menu-caption{font-size:11px;line-height:1.2}
24318
24426
  :host button.toolbar-tooltip .menu-caption{display:none}
24319
24427
  :host button.toolbar-button .menu-check{display:none}
24320
- :host button.toolbar-tooltip .menu-arrow{position:absolute;right:3px;top:50%;transform:translateY(-50%);font-size:12px}
24428
+ :host button.toolbar-tooltip .menu-arrow{position:static;flex:0 0 8px;margin-inline-start:2px;font-size:12px;line-height:1}
24321
24429
  :host button.toolbar-below .menu-arrow{position:absolute;inset:4px 3px auto auto;font-size:12px}`;
24322
24430
  style.textContent += `
24323
24431
  :host([role=group]){display:block;min-width:0}
@@ -24355,7 +24463,7 @@ function menuLine(Base) {
24355
24463
  return this.parentElement?.closest("gramlot-menu") ?? null;
24356
24464
  }
24357
24465
  get submenu() {
24358
- return [...this.children].map(labelboxContent).find((child) => child.localName === "gramlot-menu") ?? null;
24466
+ return [...this.children].map(labelboxContent).find((child) => child?.localName === "gramlot-menu") ?? null;
24359
24467
  }
24360
24468
  get entryCaption() {
24361
24469
  return this.parameters.caption ?? this.#registry?.label ?? "";
@@ -24378,9 +24486,9 @@ function menuLine(Base) {
24378
24486
  const rest = super.projectAttributes(attrs, adapt);
24379
24487
  this.#accessibleLabel = attrs["aria-label"];
24380
24488
  if (this.parameters.iconSize != null && (!Number.isFinite(this.parameters.iconSize) || this.parameters.iconSize <= 0)) throw new TypeError("menuline iconSize must be positive");
24381
- if (!Number.isFinite(this.parameters.priority)) throw new TypeError("menuline priority must be finite");
24382
24489
  this.#authoredDisabled = Boolean(this.parameters.disabled);
24383
24490
  this.#render();
24491
+ this.menuOwner?.refreshItems();
24384
24492
  this.menuOwner?.overflow.schedule();
24385
24493
  return rest;
24386
24494
  }
@@ -24425,9 +24533,10 @@ function menuLine(Base) {
24425
24533
  else this.control.style.removeProperty("--gramlot-toolbar-icon-size");
24426
24534
  this.toggleAttribute("data-menu-group-rows", Boolean(popup || owner?.parameters.orientation === "vertical"));
24427
24535
  this.control.classList.toggle("menu-row", popup);
24428
- 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" : "";
24429
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);
24430
24538
  if (this.control.disabled !== disabled) this.control.disabled = disabled;
24539
+ this.refreshIconOnly();
24431
24540
  }
24432
24541
  get disabled() {
24433
24542
  for (let p = this.parentElement; p && p !== this.menuOwner; p = p.parentElement) if (p.localName === "gramlot-menu-line" && p.parameters.disabled) return true;
@@ -24468,6 +24577,7 @@ function menuLine(Base) {
24468
24577
  function Command(HTMLElement) {
24469
24578
  return class extends controlElement(HTMLElement) {
24470
24579
  #actionPresentation = null;
24580
+ #captionObserver;
24471
24581
  constructor() {
24472
24582
  super();
24473
24583
  const doc = this.ownerDocument;
@@ -24509,7 +24619,42 @@ function Command(HTMLElement) {
24509
24619
  :host([role=separator]) button{display:none}
24510
24620
  @media(forced-colors:active){button,:host(.button--secondary) button,:host(.button--quiet) button{background:ButtonFace;color:ButtonText;border-color:ButtonText;filter:none}}
24511
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
+ `;
24512
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);
24513
24658
  }
24514
24659
  get disabled() {
24515
24660
  return this.control.disabled;
@@ -24530,6 +24675,7 @@ function Command(HTMLElement) {
24530
24675
  renderIcon(icon, iconSrc) {
24531
24676
  if (!iconSrc) {
24532
24677
  this.icon.textContent = icon ?? "";
24678
+ this.refreshIconOnly();
24533
24679
  return;
24534
24680
  }
24535
24681
  let image = this.icon.firstElementChild;
@@ -24540,6 +24686,7 @@ function Command(HTMLElement) {
24540
24686
  this.icon.replaceChildren(image);
24541
24687
  }
24542
24688
  if (image.getAttribute("src") !== iconSrc) image.setAttribute("src", iconSrc);
24689
+ this.refreshIconOnly();
24543
24690
  }
24544
24691
  get entryIcon() {
24545
24692
  return this.parameters.icon;
@@ -24553,6 +24700,7 @@ function Command(HTMLElement) {
24553
24700
  this.icon.textContent = presentation.icon;
24554
24701
  this.title = presentation.title;
24555
24702
  this.control.setAttribute("aria-label", presentation.title);
24703
+ this.refreshIconOnly();
24556
24704
  }
24557
24705
  attachCommand() {
24558
24706
  }
@@ -24652,8 +24800,6 @@ var MenuLine = defineComponent({
24652
24800
  labelPosition: { dtype: "T", binding: "read", nullable: true, enum: ["beside", "below", "tooltip"] },
24653
24801
  iconSize: { dtype: "R", binding: "read", nullable: true },
24654
24802
  group: { dtype: "B", default: false },
24655
- priority: { dtype: "R", default: 0 },
24656
- overflowable: { dtype: "B", default: true },
24657
24803
  parameters: { annotation: { kind: "type", module: "builtins", name: "dict" }, nullable: true },
24658
24804
  favorite: { dtype: "B", default: false }
24659
24805
  },
@@ -24687,13 +24833,16 @@ var DropDownButton = defineComponent({
24687
24833
  super();
24688
24834
  const doc = this.ownerDocument;
24689
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);
24690
24840
  this.#chosenCaption = doc.createElement("span");
24691
24841
  this.#chosenCaption.hidden = true;
24692
24842
  this.control.append(this.#chosenCaption);
24693
24843
  this.#arrow = doc.createElement("button");
24694
24844
  this.#arrow.type = "button";
24695
- this.#arrow.className = "arrow";
24696
- this.#arrow.textContent = "\u25BE";
24845
+ this.#arrow.className = "arrow choice-toggle";
24697
24846
  this.#arrow.setAttribute("aria-label", "Open menu");
24698
24847
  this.#arrow.setAttribute("aria-haspopup", "menu");
24699
24848
  this.#arrow.setAttribute("aria-expanded", "false");
@@ -25660,6 +25809,23 @@ function isExpression2(value) {
25660
25809
  }
25661
25810
  var GramlotBuilderBagNode = class extends SourceBagNode {
25662
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
+ }
25663
25829
  /** The local form lifecycle owned by the nearest marked Source ancestor. */
25664
25830
  get formState() {
25665
25831
  for (let owner = this; owner; owner = owner.parentNode) {
@@ -25703,6 +25869,12 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
25703
25869
  }
25704
25870
  return (attrs = {}) => this.builder.wrapSource(this.builder.commandOnNode(this, "grid", null, attrs));
25705
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
+ }
25706
25878
  get top() {
25707
25879
  return this.frameRegion("top");
25708
25880
  }
@@ -26880,10 +27052,21 @@ var GramlotBuilder = class _GramlotBuilder extends HtmlBuilder {
26880
27052
  this.defineGrammar(buttons_default.toDocument());
26881
27053
  }
26882
27054
  /** Compose real Source nodes; frame/grid/menu retain their existing runtime owners. */
26883
- frameGrid(parent, { storepath, rowMode, structpath, searchOn = false, ...attrs } = {}) {
27055
+ frameGrid(parent, { storepath, rowMode, structpath, searchOn = false, searchHelp = false, chart = false, ...attrs } = {}) {
26884
27056
  for (const tag2 of ["framePane", "grid"]) {
26885
27057
  if (!this.schemaTag(tag2)) throw new TypeError(`frameGrid requires the ${tag2} collection`);
26886
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");
26887
27070
  const gridAttrs = {
26888
27071
  storepath,
26889
27072
  rowMode,
@@ -26893,11 +27076,34 @@ var GramlotBuilder = class _GramlotBuilder extends HtmlBuilder {
26893
27076
  height: "100%",
26894
27077
  width: "100%"
26895
27078
  };
27079
+ if (chart !== false) gridAttrs.nodeId = randomId();
26896
27080
  this.validateNodeValues("grid", null, gridAttrs);
26897
- if (searchOn !== false) this.validateNodeValues("searchBox", null, { searchOn });
27081
+ if (searchOn !== false) this.validateNodeValues("searchBox", null, { searchOn, searchHelp });
26898
27082
  const frame = parent.framePane(attrs);
26899
27083
  frame.center.grid(gridAttrs);
26900
- if (searchOn !== false) frame.top.menu({ presentation: "bar", node_label: "search", aria_label: "Grid search", padding: "4px 8px", background: "var(--gramlot-surface-subtle)" }).menuline({ group: true }).searchBox({ searchOn });
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
+ }
26901
27107
  return frame;
26902
27108
  }
26903
27109
  /** Tag prefixes of the parent dialects, from the `_name` of the classes above GramlotBuilder. */
@@ -27715,6 +27921,14 @@ function componentContext(adapter) {
27715
27921
  callLogic: (name, keywords) => callLogic(binding.runtime, node, name, keywords),
27716
27922
  format: (value, options) => app.format(value, options),
27717
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),
27718
27932
  selectionOutputs: ({ selectedCaption, selectedRecord, fields }, row) => {
27719
27933
  if (binding.closed) return;
27720
27934
  if (selectedCaption) node.setRelativeData(selectedCaption, row?.caption ?? null);
@@ -27886,6 +28100,10 @@ var HtmlElement = class {
27886
28100
  const controlBox = document.createElement("div");
27887
28101
  controlBox.append(element);
27888
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
+ };
27889
28107
  record2.presentation = record2.labelbox.box;
27890
28108
  record2.labelId = `gramlot-label-${randomId()}`;
27891
28109
  record2.controlId = `gramlot-control-${randomId()}`;
@@ -27959,7 +28177,10 @@ var HtmlElement = class {
27959
28177
  }
27960
28178
  if (record2.labelbox) {
27961
28179
  record2.labelbox.box.style.visibility = "";
27962
- projectLabelbox(record2.labelbox, attrs, adapt);
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);
27963
28184
  }
27964
28185
  if (this.definition(node).meta.gramlot_component) {
27965
28186
  if (this.definition(node).meta.gramlot_component.bagStore) {
@@ -28604,6 +28825,53 @@ var NativeEventBinding = class {
28604
28825
  }
28605
28826
  };
28606
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
+
28607
28875
  // node_modules/@genrojs/toolbox/js/src/dates/civil.js
28608
28876
  function daysInMonth(year, month) {
28609
28877
  if (month === 2) return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28;
@@ -29112,7 +29380,8 @@ function compileFilter(filter) {
29112
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");
29113
29381
  if (!value.trim()) return null;
29114
29382
  if (dtype === "T") {
29115
- const expression = new RegExp(value, "i");
29383
+ const pattern = filter.literal === true ? value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") : value;
29384
+ const expression = new RegExp(pattern, "i");
29116
29385
  return (read) => expression.test(columns.map((field) => searchText(read(field), locale, filter.timeZone)).join(" "));
29117
29386
  }
29118
29387
  if (columns.length !== 1) throw new TypeError("Typed filters require one column");
@@ -29181,6 +29450,19 @@ function parseNumber(text3, locale) {
29181
29450
  return result;
29182
29451
  }
29183
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
+
29184
29466
  // src/stores/bag-collection-store.js
29185
29467
  var BagCollectionStore = class {
29186
29468
  #listeners = /* @__PURE__ */ new Set();
@@ -29240,8 +29522,7 @@ var BagCollectionView = class {
29240
29522
  #listeners = /* @__PURE__ */ new Set();
29241
29523
  #indices = /* @__PURE__ */ new Map();
29242
29524
  #sortedBy = "";
29243
- #filter = null;
29244
- #predicate = null;
29525
+ #filters = /* @__PURE__ */ new Map();
29245
29526
  #filtered = null;
29246
29527
  constructor(store) {
29247
29528
  this.bindStore(store);
@@ -29259,7 +29540,19 @@ var BagCollectionView = class {
29259
29540
  return parseSort(this.#sortedBy);
29260
29541
  }
29261
29542
  get filter() {
29262
- return this.#filter;
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));
29263
29556
  }
29264
29557
  get filtered() {
29265
29558
  return this.#filtered === null ? null : [...this.#filtered];
@@ -29300,39 +29593,88 @@ var BagCollectionView = class {
29300
29593
  return this.#store.getRows().toSorted((a, b) => (this.#indices.get(a) ?? Infinity) - (this.#indices.get(b) ?? Infinity));
29301
29594
  }
29302
29595
  synchronize(change = { full: true, rows: [] }) {
29303
- if (!change.full && !this.#sortedBy && !this.#predicate) {
29596
+ if (!change.full && !this.#sortedBy && !this.#filters.size) {
29304
29597
  publishCollection(this.#listeners, change);
29305
29598
  return;
29306
29599
  }
29307
- this.#commit(this.#sorted(this.#orderedNodes(), this.criteria), this.#sortedBy, this.#filter, this.#predicate, change);
29600
+ this.#commit(this.#sorted(this.#orderedNodes(), this.criteria), this.#sortedBy, this.#filters, change);
29308
29601
  }
29309
29602
  sort(sortedBy) {
29310
29603
  const nodes = this.#sorted(this.#orderedNodes(), parseSort(sortedBy));
29311
- this.#commit(nodes, sortedBy, this.#filter, this.#predicate);
29604
+ this.#commit(nodes, sortedBy, this.#filters);
29312
29605
  }
29313
29606
  moveRow(node, target, after = false) {
29314
29607
  if (node === target || node.parentBag !== this.bag || target.parentBag !== this.bag) return;
29315
29608
  const nodes = this.getRows(false);
29316
29609
  nodes.splice(nodes.indexOf(node), 1);
29317
29610
  nodes.splice(nodes.indexOf(target) + Number(after), 0, node);
29318
- this.#commit(nodes, "", this.#filter, this.#predicate);
29611
+ this.#commit(nodes, "", this.#filters);
29319
29612
  }
29320
- applyFilter(filter) {
29613
+ applyFilter(filter, contribution2 = "search") {
29614
+ if (!["base", "search"].includes(contribution2)) throw new TypeError("Unknown collection filter contribution");
29321
29615
  const definition = filter === null ? null : Object.freeze({ ...filter, columns: Object.freeze([...filter.columns]) });
29322
- const predicate = compileFilter(definition);
29323
- this.#commit(this.#orderedNodes(), this.#sortedBy, definition, predicate);
29616
+ this.#applyContribution(contribution2, definition, compileFilter(definition));
29324
29617
  }
29325
- #commit(nodes, sortedBy, filter, predicate, change = { full: false, rows: [] }) {
29326
- const filtered = predicate ? nodes.flatMap((node, index) => predicate((field) => this.value(node, field)) ? [index] : []) : null;
29327
- const full = change.full || sortedBy !== this.#sortedBy || JSON.stringify(filter) !== JSON.stringify(this.#filter) || nodes.length !== this.#indices.size || nodes.some((node, index) => this.#indices.get(node) !== index) || JSON.stringify(filtered) !== JSON.stringify(this.#filtered);
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);
29328
29671
  this.#indices = new Map(nodes.map((node, index) => [node, index]));
29329
29672
  this.#sortedBy = sortedBy;
29330
- this.#filter = filter;
29331
- this.#predicate = predicate;
29673
+ this.#filters = filters;
29332
29674
  this.#filtered = filtered;
29333
29675
  const visible = filtered === null ? null : new Set(filtered);
29334
29676
  const rows = full ? [] : change.rows.filter((node) => this.#indices.has(node) && (visible === null || visible.has(this.#indices.get(node))));
29335
- if (full || rows.length) publishCollection(this.#listeners, { full, rows });
29677
+ if (full || rows.length || change.rows.length) publishCollection(this.#listeners, { full, rows });
29336
29678
  }
29337
29679
  #sorted(nodes, criteria) {
29338
29680
  if (!criteria.length) return nodes;
@@ -29572,7 +29914,7 @@ var DataRouter = class {
29572
29914
 
29573
29915
  // src/components/grid-structure.js
29574
29916
  var TYPES = /* @__PURE__ */ new Set(["T", "B", "L", "R", "N", "D", "H", "DHZ"]);
29575
- var COLUMN_KEYS = /* @__PURE__ */ new Set(["tag", "field", "name", "dtype", "width", "align", "format", "columnset", "white_space", "max_height", "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"]);
29576
29918
  var GROUP_KEYS = /* @__PURE__ */ new Set(["tag", "code", "name", "background", "color"]);
29577
29919
  var GridStructure = class {
29578
29920
  #nodes = /* @__PURE__ */ new Map();
@@ -29613,8 +29955,15 @@ var GridStructure = class {
29613
29955
  throw new TypeError("grid max_height requires a nonnegative CSS length (px, em or rem)");
29614
29956
  }
29615
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");
29616
- 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`);
29617
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
+ }
29618
29967
  const column = Object.freeze({
29619
29968
  ...attrs,
29620
29969
  name: attrs.name ?? attrs.field,
@@ -29677,7 +30026,7 @@ function structureData(source) {
29677
30026
  node.builder.validateNode(node);
29678
30027
  if (node.nodeTag !== "column" || node.staticValue != null) throw new TypeError("grid column must be a scalar declaration");
29679
30028
  const attrs = { tag: "cell" };
29680
- for (const key2 of ["field", "name", "dtype", "width", "align", "format", "white_space", "max_height", "edit"]) {
30029
+ for (const key2 of ["field", "name", "title", "dtype", "width", "align", "format", "white_space", "max_height", "edit", "check", "checked", "checkedField"]) {
29681
30030
  if (node.getAttr(key2) != null) attrs[key2] = node.getAttr(key2);
29682
30031
  }
29683
30032
  const label = `cell_${attrs.field}`;
@@ -29716,7 +30065,7 @@ function validateGridDeclaration(node) {
29716
30065
  function installGridStruct(node, data) {
29717
30066
  const value = structureData(node.staticValue);
29718
30067
  new GridStructure(value);
29719
- const path = `gramlot.grid.${crypto.randomUUID().replaceAll("-", "")}.struct`;
30068
+ const path = `_gramlot.grid.${crypto.randomUUID().replaceAll("-", "")}.struct`;
29720
30069
  data.setItem(path, value, null, ">", false, true, node);
29721
30070
  node.parentNode.setAttr({ structpath: path }, false);
29722
30071
  node.setValue(null, false);
@@ -30975,6 +31324,7 @@ var BindingRuntime = class {
30975
31324
  }
30976
31325
  /** Resolve a tree store against the selected live root. */
30977
31326
  treeStore(node) {
31327
+ if (node.treeStore !== null) return node.treeStore;
30978
31328
  const path = node.getAttr("storepath");
30979
31329
  if (path === "*S" || path.startsWith("*S.")) {
30980
31330
  const root = this.renderer.source.getItem("main");
@@ -31408,6 +31758,15 @@ var NodeBinding = class {
31408
31758
  const component = node._getMeta("gramlot_component");
31409
31759
  for (const [capability, attribute] of [["bagStore", "storepath"], ["bagStruct", "structpath"]]) {
31410
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
+ }
31411
31770
  const value = node.getAttr(attribute);
31412
31771
  if (typeof value !== "string" || !value || /^[\^=]/.test(value) || value.includes("?")) {
31413
31772
  throw new TypeError(`${attribute} requires a plain Bag data path`);
@@ -31765,6 +32124,7 @@ var DragDrop = class {
31765
32124
  dropEffect: policy.dropEffect,
31766
32125
  dataAvailable: true
31767
32126
  };
32127
+ if (row.placement !== void 0) context.placement = row.placement;
31768
32128
  const accepted = policy.accepted && this.#renderer.checkDropTarget(record2.node, context) && this.#renderer.records.get(record2.node) === record2 && row.element.isConnected;
31769
32129
  return { record: record2, element: row.element, accepted, context };
31770
32130
  }
@@ -31940,26 +32300,26 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
31940
32300
  return this.dragPreparation.prepare(node, event);
31941
32301
  }
31942
32302
  /** Dynamic eligibility only; cannot replace the independent type/tag/effect policy. */
31943
- checkDropTarget(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }) {
32303
+ checkDropTarget(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, placement }) {
31944
32304
  const record2 = this.records.get(node);
31945
32305
  if (!record2) return false;
31946
32306
  if (!record2.resolved.dropTargetCb) return true;
31947
32307
  const allowed = this.html.callLogic(
31948
32308
  node,
31949
32309
  record2.resolved.dropTargetCb,
31950
- { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }
32310
+ { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, ...placement === void 0 ? {} : { placement } }
31951
32311
  );
31952
32312
  if (typeof allowed !== "boolean") throw new TypeError("dropTargetCb must return a boolean synchronously");
31953
32313
  return allowed;
31954
32314
  }
31955
32315
  /** Invoke only the general action, after acceptance and removal of data handled by typed actions. */
31956
- async invokeDrop(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }) {
32316
+ async invokeDrop(node, { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, placement }) {
31957
32317
  const record2 = this.records.get(node);
31958
32318
  if (!record2 || !record2.resolved.onDrop || Object.keys(dropValues).length === 0) return;
31959
32319
  await this.html.callLogic(
31960
32320
  node,
31961
32321
  record2.resolved.onDrop,
31962
- { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable }
32322
+ { dropValues, item, path, source, selfdrop, dropEffect, dataAvailable, ...placement === void 0 ? {} : { placement } }
31963
32323
  );
31964
32324
  }
31965
32325
  /** Notify origin completion independently of application-operation success. */
@@ -32084,6 +32444,7 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
32084
32444
  ...this.html.create(node, document, tag2, attrs, resolved2.visible ?? null)
32085
32445
  };
32086
32446
  this.html.compose(record2, text3, children);
32447
+ if (record2.labelbox) record2.cleanup.push(() => record2.labelbox.menu?.dispose());
32087
32448
  record2.shape = ControlAdapter.shape(record2.element, resolved2);
32088
32449
  this.records.set(node, record2);
32089
32450
  this.elements.set(record2.element, record2);
@@ -33243,23 +33604,23 @@ var DeviceHandler = class extends Handler {
33243
33604
  }
33244
33605
  installData() {
33245
33606
  const { gramlot } = this;
33246
- gramlot.data.setItem("gramlot.device.database", null, { status: "idle", error: null });
33247
- gramlot.data.setItem("gramlot.device.orientation", null, { status: "idle", error: null, listening: false });
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 });
33248
33609
  for (const name of ["gyroscope", "accelerometer"]) {
33249
33610
  gramlot.data.setItem(
33250
- `gramlot.device.${name}`,
33611
+ `_gramlot.device.${name}`,
33251
33612
  null,
33252
33613
  { enabled: false, watching: false, status: "idle", error: null }
33253
33614
  );
33254
- gramlot.data.getNode(`gramlot.device.${name}`).setAttr({ error: null }, false, true, false);
33615
+ gramlot.data.getNode(`_gramlot.device.${name}`).setAttr({ error: null }, false, true, false);
33255
33616
  this.#sensors.set(name, {
33256
- node: gramlot.data.getNode(`gramlot.device.${name}`),
33617
+ node: gramlot.data.getNode(`_gramlot.device.${name}`),
33257
33618
  stream: null,
33258
33619
  cleanup: Promise.resolve()
33259
33620
  });
33260
33621
  }
33261
33622
  for (const name of NAMES) {
33262
- const path = `gramlot.device.${name}`;
33623
+ const path = `_gramlot.device.${name}`;
33263
33624
  const attrs = { status: "idle", error: null, cacheTime: name === "appinfo" ? -1 : 5 };
33264
33625
  if (name === "location") Object.assign(attrs, { enabled: false, watching: false });
33265
33626
  gramlot.data.setItem(path, null);
@@ -33270,54 +33631,54 @@ var DeviceHandler = class extends Handler {
33270
33631
  this.resolvers.set(name, resolver);
33271
33632
  }
33272
33633
  gramlot.data.setItem(
33273
- "gramlot.device.clipboard",
33634
+ "_gramlot.device.clipboard",
33274
33635
  null,
33275
33636
  { status: "idle", error: null, text: "", copy: null, paste: null, operation: null }
33276
33637
  );
33277
- const clipboard = gramlot.data.getNode("gramlot.device.clipboard");
33278
- gramlot.data.setItem("gramlot.device.camera", null, { status: "idle", error: null, capture: null, choose: null });
33279
- const camera = gramlot.data.getNode("gramlot.device.camera");
33280
- gramlot.data.setItem("gramlot.device.barcode", null, { status: "idle", error: null, scan: null });
33281
- const barcode = gramlot.data.getNode("gramlot.device.barcode");
33282
- gramlot.data.setItem("gramlot.device.biometrics", null, { status: "idle", error: null, verify: null });
33283
- const biometrics = gramlot.data.getNode("gramlot.device.biometrics");
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");
33284
33645
  const notifications = new Bag();
33285
33646
  notifications.setItem("request", new Bag());
33286
33647
  for (const name of ["scheduled", "received", "action"]) notifications.setItem(name, null);
33287
33648
  gramlot.data.setItem(
33288
- "gramlot.device.notifications",
33649
+ "_gramlot.device.notifications",
33289
33650
  notifications,
33290
33651
  { status: "idle", error: null, schedule: null, listening: false, listenerError: null }
33291
33652
  );
33292
- const notificationNode = gramlot.data.getNode("gramlot.device.notifications");
33653
+ const notificationNode = gramlot.data.getNode("_gramlot.device.notifications");
33293
33654
  const push = new Bag();
33294
33655
  for (const name of ["registration", "received", "action"]) push.setItem(name, null);
33295
33656
  gramlot.data.setItem(
33296
- "gramlot.device.push",
33657
+ "_gramlot.device.push",
33297
33658
  push,
33298
33659
  { status: "idle", error: null, register: null, listening: false, listenerError: null }
33299
33660
  );
33300
- const pushNode = gramlot.data.getNode("gramlot.device.push");
33661
+ const pushNode = gramlot.data.getNode("_gramlot.device.push");
33301
33662
  const links = new Bag();
33302
33663
  links.setItem("request", null);
33303
- gramlot.data.setItem("gramlot.device.links", links, { listening: false, listenerError: null });
33664
+ gramlot.data.setItem("_gramlot.device.links", links, { listening: false, listenerError: null });
33304
33665
  const shortcuts = new Bag();
33305
33666
  shortcuts.setItem("request", null);
33306
- gramlot.data.setItem("gramlot.device.shortcuts", shortcuts, { listening: false, listenerError: null });
33307
- gramlot.data.setItem("gramlot.device.network", null, { status: "idle", error: null, listening: false });
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 });
33308
33669
  const lifecycle = new Bag();
33309
33670
  lifecycle.setItem("active", null);
33310
33671
  lifecycle.setItem("event", null);
33311
33672
  lifecycle.setItem("sequence", 0);
33312
- gramlot.data.setItem("gramlot.device.lifecycle", lifecycle, { status: "idle", error: null, listening: false });
33673
+ gramlot.data.setItem("_gramlot.device.lifecycle", lifecycle, { status: "idle", error: null, listening: false });
33313
33674
  gramlot.data.setItem(
33314
- "gramlot.device.haptics",
33675
+ "_gramlot.device.haptics",
33315
33676
  null,
33316
33677
  { status: "idle", error: null, impact: null, style: "medium", vibrate: null, duration: 600 }
33317
33678
  );
33318
- const haptics = gramlot.data.getNode("gramlot.device.haptics");
33679
+ const haptics = gramlot.data.getNode("_gramlot.device.haptics");
33319
33680
  gramlot.data.setItem(
33320
- "gramlot.device.audio",
33681
+ "_gramlot.device.audio",
33321
33682
  null,
33322
33683
  {
33323
33684
  status: "idle",
@@ -33332,7 +33693,7 @@ var DeviceHandler = class extends Handler {
33332
33693
  shareActivity: null
33333
33694
  }
33334
33695
  );
33335
- const audio = gramlot.data.getNode("gramlot.device.audio");
33696
+ const audio = gramlot.data.getNode("_gramlot.device.audio");
33336
33697
  gramlot.data.subscribe("gramlot.device", { update: (event) => {
33337
33698
  if (this.disposed) return;
33338
33699
  for (const [name, sensor] of this.#sensors) {
@@ -33428,16 +33789,16 @@ var DeviceHandler = class extends Handler {
33428
33789
  node.setAttr({ status: "success", error: null }, true, true, false);
33429
33790
  });
33430
33791
  if (provider.capabilities.includes("links")) {
33431
- this.#startLinkEvents(this.gramlot.data.getNode("gramlot.device.links"));
33792
+ this.#startLinkEvents(this.gramlot.data.getNode("_gramlot.device.links"));
33432
33793
  }
33433
33794
  if (provider.capabilities.includes("shortcuts")) {
33434
- this.#startShortcutEvents(this.gramlot.data.getNode("gramlot.device.shortcuts"));
33795
+ this.#startShortcutEvents(this.gramlot.data.getNode("_gramlot.device.shortcuts"));
33435
33796
  }
33436
33797
  if (provider.capabilities.includes("push")) {
33437
- this.#startPushEvents(this.gramlot.data.getNode("gramlot.device.push"));
33798
+ this.#startPushEvents(this.gramlot.data.getNode("_gramlot.device.push"));
33438
33799
  }
33439
33800
  if (provider.capabilities.includes("notifications")) {
33440
- this.#startNotificationEvents(this.gramlot.data.getNode("gramlot.device.notifications"));
33801
+ this.#startNotificationEvents(this.gramlot.data.getNode("_gramlot.device.notifications"));
33441
33802
  }
33442
33803
  }
33443
33804
  assertLive() {
@@ -33476,7 +33837,7 @@ var DeviceHandler = class extends Handler {
33476
33837
  }
33477
33838
  // Page-owned state streams share lifetime/error handling, never public dispatch.
33478
33839
  #startStateEvents(name, start, accept) {
33479
- const node = this.gramlot.data.getNode(`gramlot.device.${name}`);
33840
+ const node = this.gramlot.data.getNode(`_gramlot.device.${name}`);
33480
33841
  if (!this.provider.capabilities.includes(name)) {
33481
33842
  node.setAttr(failureAttributes({ code: "UNAVAILABLE", message: `${name} is unavailable` }), true, true, false);
33482
33843
  return;
@@ -34141,7 +34502,7 @@ var DeviceHandler = class extends Handler {
34141
34502
  this.assertLive();
34142
34503
  if (!/^[A-Za-z][A-Za-z0-9_]{0,63}$/.test(name) || typeof name !== "string") throw new TypeError("Invalid database name");
34143
34504
  if (this.#database) throw new Error("This page already owns a database connection");
34144
- const node = this.gramlot.data.getNode("gramlot.device.database");
34505
+ const node = this.gramlot.data.getNode("_gramlot.device.database");
34145
34506
  const state = (status, error = null) => {
34146
34507
  if (!this.disposed) node.setAttr({ status, error }, true, true, false);
34147
34508
  };
@@ -34498,6 +34859,10 @@ var Gramlot = class {
34498
34859
  registerDocument(document) {
34499
34860
  for (const collection of this.#collections) collection.register(document.defaultView);
34500
34861
  }
34862
+ /** The prepared collection already activated by this page. */
34863
+ getCollection(name) {
34864
+ return this.#collections.find((collection) => collection.name === name);
34865
+ }
34501
34866
  subscribe(topic, callback) {
34502
34867
  return this._subscriptions.subscribe(topic, callback);
34503
34868
  }
@@ -34658,7 +35023,7 @@ var PageBootstrap = class {
34658
35023
  ...config2,
34659
35024
  document,
34660
35025
  serverAdapter: this.serverAdapter,
34661
- collections: [...config2.collections ?? [], ...collections.map((c) => c.toDocument())]
35026
+ collections: [...config2.collections ?? [], ...collections]
34662
35027
  });
34663
35028
  window2.removeEventListener("pagehide", pagehide);
34664
35029
  for (const collection of collections) collection.registerCommands(app);
@@ -35250,6 +35615,7 @@ var IdeDocuments = class {
35250
35615
  return this.state.getItem("documents");
35251
35616
  }
35252
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;
35253
35619
  const key2 = documentKey(root, path);
35254
35620
  const existing = this.documents.getNodes().find((node) => !node.value.getItem("isNew") && node.value.getItem("root") === root && node.value.getItem("path") === path);
35255
35621
  if (existing) return existing.label;
@@ -35258,7 +35624,13 @@ var IdeDocuments = class {
35258
35624
  const promise = this.gramlot.rpc.call("data", "document_read", { root, path }, { signal: request.signal }).then((result) => {
35259
35625
  if (this.disposed || request.signal.aborted) return null;
35260
35626
  const document = new Bag();
35261
- for (const [name, value] of Object.entries({ ...result, root, saved: result.content, busy: false })) document.setItem(name, value);
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
+ }
35262
35634
  this.documents.setItem(key2, document);
35263
35635
  return key2;
35264
35636
  }).finally(() => this.pending.delete(key2));
@@ -35364,11 +35736,14 @@ var IdeDocuments = class {
35364
35736
  if (!doc || doc.getItem("isNew") || !this.dirty(key2) || !doc.getItem("writable") || this.pending.has(key2)) return false;
35365
35737
  const content = doc.getItem("content"), request = new AbortController();
35366
35738
  doc.setItem("busy", true);
35367
- const promise = this.gramlot.rpc.call("data", "document_save", {
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", {
35368
35743
  root: doc.getItem("root"),
35369
- path: doc.getItem("path"),
35370
- content,
35371
- revision: doc.getItem("revision")
35744
+ path,
35745
+ content: image ? Bag.fromTytx(content) : content,
35746
+ ...creating ? {} : { revision: doc.getItem("revision") }
35372
35747
  }, { signal: request.signal }).then((result) => {
35373
35748
  if (this.disposed || request.signal.aborted) return false;
35374
35749
  doc.setItem("revision", result.revision);
@@ -35385,6 +35760,10 @@ var IdeDocuments = class {
35385
35760
  const doc = this.documents.getItem(key2);
35386
35761
  if (!doc || !this.dirty(key2) || this.pending.has(key2)) return false;
35387
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
+ }
35388
35767
  return true;
35389
35768
  }
35390
35769
  canClose(key2, discard = false) {
@@ -35492,6 +35871,16 @@ var IdeLogic = class {
35492
35871
  const root = state.getItem("workspace");
35493
35872
  if (root && root !== state.getItem("browser.root")) state.setItem("browser.requestedRoot", root);
35494
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
+ }
35495
35884
  ideDocumentState(node, key2) {
35496
35885
  const context = ideContext(node), { documents } = context;
35497
35886
  const doc = documents.documents.getItem(key2);
@@ -35631,59 +36020,63 @@ var IdeLogic = class {
35631
36020
  form.button("Create file", { disabled: "^.busy" }).dataController({ func: "ideCreate", documentKey: key2 });
35632
36021
  form.button("Cancel", { disabled: "^.busy", class: "button--quiet" }).dataController({ func: "ideCancelCreate", documentKey: key2 });
35633
36022
  const editorArea = target.div({ flex: "1", min_height: 0 });
35634
- const html2 = doc.getItem("language") === "html";
35635
- const markdown = doc.getItem("language") === "markdown";
35636
- const rich = html2 || markdown;
35637
- const typst = doc.getItem("language") === "typst";
35638
- const preview = rich || typst || recipe;
35639
- const views = preview ? editorArea.tabContainer({ height: "100%", selectedPage: `^.documents.${key2}.view` }) : null;
35640
- const code = preview ? views.contentPane({ title: "Code", pageName: "code", height: "100%" }) : editorArea;
35641
- codeMirrorWithOptions(code, {
35642
- datapath: `.documents.${key2}`,
35643
- value: "^.content",
35644
- language: doc.getItem("language"),
35645
- height: "100%",
35646
- readonly: "^.readonly",
35647
- nodeId: `${context.editorPrefix}_editor_${key2}`,
35648
- editorView: "code",
35649
- selfsubscribe_historyChanged: "ideHistoryChanged"
35650
- });
35651
- target.dataController({ func: "ideSave", documentKey: key2, [`subscribe_${context.editorPrefix}_editor_${key2}_save`]: true });
35652
- if (typst) views.contentPane({ title: "Preview", pageName: "preview", height: "100%" }).typstPreview({ value: `^.documents.${key2}.content`, filename: `^.documents.${key2}.pdfFilename`, height: "100%" });
35653
- if (recipe) {
35654
- const output = views.contentPane({ title: "Preview", pageName: "preview", height: "100%", display: "flex", flex_direction: "column" });
35655
- output.div(`^.documents.${key2}.renderStatus`, { role: "status", padding: "8px 12px", white_space: "pre-wrap", overflow: "auto", max_height: "30%" });
35656
- output.typstPreview({
35657
- value: `^.documents.${key2}.typstSource`,
35658
- filename: `^.documents.${key2}.pdfFilename`,
35659
- hidden: `^.documents.${key2}.previewHidden`,
35660
- flex: "1",
35661
- min_height: 0
35662
- });
35663
- views.contentPane({ title: "Generated Typst", pageName: "generated", height: "100%" }).codeMirror({ value: `^.documents.${key2}.typstSource`, language: "typst", readonly: true, height: "100%" });
35664
- }
35665
- if (rich) {
35666
- const previewPane = views.contentPane({ title: "Preview", pageName: "preview", height: "100%", display: "flex", flex_direction: "column" });
35667
- if (markdown) {
35668
- doc.setItem("allowHtml", false);
35669
- previewPane.checkbox({ value: `^.documents.${key2}.allowHtml`, label: "Allow embedded HTML", class: "gramlot-ide-allow-html", padding: "8px 12px", flex_shrink: 0 });
35670
- }
35671
- previewPane[html2 ? "htmlPreview" : "markdownPreview"]({
35672
- value: `^.documents.${key2}.content`,
35673
- flex: "1",
35674
- min_height: 0,
35675
- ...markdown ? { allowHtml: `^.documents.${key2}.allowHtml` } : {}
35676
- });
35677
- 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, {
35678
36034
  datapath: `.documents.${key2}`,
35679
36035
  value: "^.content",
35680
- readonly: "^.readonly",
36036
+ language: doc.getItem("language"),
35681
36037
  height: "100%",
35682
- nodeId: `${context.editorPrefix}_rich_editor_${key2}`,
35683
- editorView: "rich",
36038
+ readonly: "^.readonly",
36039
+ nodeId: `${context.editorPrefix}_editor_${key2}`,
36040
+ editorView: "code",
35684
36041
  selfsubscribe_historyChanged: "ideHistoryChanged"
35685
36042
  });
35686
- target.dataController({ func: "ideSave", documentKey: key2, [`subscribe_${context.editorPrefix}_rich_editor_${key2}_save`]: true });
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
+ }
35687
36080
  }
35688
36081
  }
35689
36082
  }
@@ -36059,11 +36452,11 @@ var VisualEditor = class {
36059
36452
  pane.dataController({ func: "initializeEditorAppearance", _onBuilt: true });
36060
36453
  pane.dataController({ func: "applyEditorAppearance", profile: "^.appearanceProfile", palette: "^.appearancePalette", mode: "^.appearanceMode" });
36061
36454
  const rail = this.rail = pane.menu({ presentation: "bar", orientation: "vertical", aria_label: "Editor panels", class: "visual-editor-rail" });
36062
- this.toolButton(rail.menuline({ group: true, overflowable: false }), "Source / Data", "toggleNavigation", toolIcons.navigation);
36063
- this.toolButton(rail.menuline({ group: true, overflowable: false }), "Catalogue", "openCatalogue", toolIcons.catalogue);
36064
- this.toolButton(rail.menuline({ group: true, overflowable: false }), "Properties", "openProperties", toolIcons.properties);
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);
36065
36458
  this.toolButton(
36066
- rail.menuline({ group: true, overflowable: false }),
36459
+ rail.menuline({ group: true }),
36067
36460
  "Clipboard",
36068
36461
  "this.SET('.clipboardVisible', !this.GET('.clipboardVisible'))",
36069
36462
  toolIcons.paste,
@@ -36078,23 +36471,23 @@ var VisualEditor = class {
36078
36471
  }
36079
36472
  );
36080
36473
  rail.spacer({ flex: 1 });
36081
- this.toolButton(rail.menuline({ group: true, overflowable: false }), "Appearance", "this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))", toolIcons.appearance);
36474
+ this.toolButton(rail.menuline({ group: true }), "Appearance", "this.SET('.appearanceOpen', !this.GET('.appearanceOpen'))", toolIcons.appearance);
36082
36475
  const layoutRoot = pane.framePane({ node_label: "layout", height: "100%", id: `${editorId}-editor-frame`, class: "visual-editor-layout" });
36083
36476
  layoutRoot.top.setAttr({ height: "30px" });
36084
36477
  const toolbar = layoutRoot.top.menu({ presentation: "bar", aria_label: "Editor tools", class: "visual-editor-toolbar" });
36085
- toolbar.menuline({ group: true, overflowable: false }).span("Source editor", { class: "visual-editor-brand" });
36086
- const files = toolbar.menuline({ group: true, overflowable: false, gap: "4px", hidden: !fileCommands });
36478
+ toolbar.menuline({ group: true }).span("Source editor", { class: "visual-editor-brand" });
36479
+ const files = toolbar.menuline({ group: true, gap: "4px", hidden: !fileCommands });
36087
36480
  for (const [caption, action, icon] of [["New", "newPage", "new"], ["Open", "openUpload", "open"], ["Download", "downloadPage", "download"], ["Copy Source", "copySource", "copy"]])
36088
36481
  this.toolButton(files, caption, action, toolIcons[icon], { id: `${editorId}-${icon}` });
36089
- toolbar.menuline({ group: true, overflowable: false }).span({ class: "visual-toolbar-divider", aria_hidden: "true" });
36090
- const edit = toolbar.menuline({ group: true, overflowable: false, gap: "2px" });
36482
+ toolbar.menuline({ group: true }).span({ class: "visual-toolbar-divider", aria_hidden: "true" });
36483
+ const edit = toolbar.menuline({ group: true, gap: "2px" });
36091
36484
  this.toolButton(edit, "Cut branch", "cutBranch", toolIcons.cut, { title: "Cut branch (F8)" });
36092
36485
  this.toolButton(edit, "Copy branch", "copyBranch", toolIcons.copy);
36093
36486
  this.toolButton(edit, "Paste branch", "pasteBranch", toolIcons.paste, { title: "Paste branch (F9)" });
36094
36487
  toolbar.spacer({ flex: 1 });
36095
- toolbar.menuline({ group: true, overflowable: false, hidden: "^.modified:=!{}" }).span("Unsaved changes", { role: "status", class: "visual-editor-hint" });
36096
- toolbar.menuline({ group: true, overflowable: false }).span("^.fileStatus", { role: "status", class: "visual-editor-file-status" });
36097
- toolbar.menuline({ group: true, overflowable: false }).span("^.filename", { class: "visual-editor-filename" });
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" });
36098
36491
  const left = layoutRoot.left;
36099
36492
  left.setAttr({
36100
36493
  width: "min(240px, 34vw)",
@@ -36231,7 +36624,7 @@ var VisualEditor = class {
36231
36624
  naming.frame.center.p("^.error", { role: "alert", margin: "12px" });
36232
36625
  const namingBar = naming.frame.bottom.menu({ presentation: "bar", aria_label: "Clipboard commands", padding: "3px 6px" });
36233
36626
  namingBar.spacer({ flex: 1 });
36234
- const namingButtons = namingBar.menuline({ group: true, overflowable: false, gap: "8px" });
36627
+ const namingButtons = namingBar.menuline({ group: true, gap: "8px" });
36235
36628
  namingButtons.button("Cancel", { action: "this.SET('.clipboardOpen', false)" });
36236
36629
  namingButtons.button("Save branch", { action: "saveClipboard" });
36237
36630
  const dialog = pane.dialog({ class: "visual-editor-popup", title: "Required parameters", open: "^.insertionOpen", width: "400px", height: "280px", movable: true, resizable: true });
@@ -36239,7 +36632,7 @@ var VisualEditor = class {
36239
36632
  dialog.frame.center.p("^.error", { role: "alert" });
36240
36633
  const bar = dialog.frame.bottom.menu({ presentation: "bar", aria_label: "Insertion commands", padding: "3px 6px", border_top: "1px solid var(--gramlot-border)" });
36241
36634
  bar.spacer({ flex: 1 });
36242
- const buttons = bar.menuline({ group: true, overflowable: false, gap: "8px" });
36635
+ const buttons = bar.menuline({ group: true, gap: "8px" });
36243
36636
  buttons.button("Cancel", { action: "this.SET('.insertionOpen', false)" });
36244
36637
  buttons.button("Insert", { action: "insertWidget" });
36245
36638
  const settings = pane.floatingPane({ class: "visual-editor-popup", title: "Appearance", open: "^.appearanceOpen", default_open: false, width: "280px", height: "260px", movable: true, resizable: true });
@@ -36265,7 +36658,7 @@ var VisualEditor = class {
36265
36658
  pane.dataSetter({ destination_path: ".codeDocument", value: new Bag({ ...document, saved: document.content, busy: false, status: "" }) });
36266
36659
  const anchor = `#${pane.getAttr("visualEditorId")}Editor`;
36267
36660
  const opener = frame === this.frame ? this.toolbar : frame.top.menu({ presentation: "bar", aria_label: "Code drawer" });
36268
- opener.menuline({ group: true, overflowable: false }).button("Code", { action: "openCode", class: "button--quiet" });
36661
+ opener.menuline({ group: true }).button("Code", { action: "openCode", class: "button--quiet" });
36269
36662
  const drawer = frame.right;
36270
36663
  drawer.setAttr({
36271
36664
  class: "visual-editor-code",
@@ -36292,7 +36685,7 @@ var VisualEditor = class {
36292
36685
  code.bottom.div("^.codeDocument.status", { role: "status", font_size: "12px", padding: "4px 10px" });
36293
36686
  const bar = code.bottom.menu({ presentation: "bar", aria_label: "Page code commands", padding: "3px 6px" });
36294
36687
  bar.spacer({ flex: 1 });
36295
- const commands = bar.menuline({ group: true, overflowable: false, gap: "6px" });
36688
+ const commands = bar.menuline({ group: true, gap: "6px" });
36296
36689
  commands.button("Close", { action: "this.SET('.codeOpen', 'close')" });
36297
36690
  commands.button("Preview saved", { action: "codePreview", disabled: "^.codeDocument.busy" });
36298
36691
  commands.button("Save", { action: "codeSave", disabled: "^.codeSaveDisabled" });
@@ -36308,7 +36701,7 @@ var VisualEditor = class {
36308
36701
  }
36309
36702
  search(pane, path, label) {
36310
36703
  const bar = pane.menu({ presentation: "bar", aria_label: label, class: "visual-search-toolbar" });
36311
- const field = bar.menuline({ group: true, overflowable: false, flex: 1, min_width: 0 }).div({ class: "visual-search-field" });
36704
+ const field = bar.menuline({ group: true, flex: 1, min_width: 0 }).div({ class: "visual-search-field" });
36312
36705
  field.span({ class: "visual-search-icon", aria_hidden: "true" });
36313
36706
  field.input({ type: "search", value: `^.${path}`, default: "", live: true, placeholder: label, aria_label: label });
36314
36707
  field.html_button({
@@ -38499,7 +38892,8 @@ function Labelbox(Base) {
38499
38892
  }
38500
38893
  projectAttributes(attrs, adapt) {
38501
38894
  const rest = super.projectAttributes(attrs, adapt);
38502
- const label = this.parameters.lbl ?? "";
38895
+ const { lbl, lbl_value, lbl_values } = this.parameters;
38896
+ const label = lbl_values == null ? lbl ?? "" : choiceCaption(parseChoices(lbl_values), lbl_value, lbl);
38503
38897
  if (label) this.control.setAttribute("aria-label", label);
38504
38898
  else this.control.removeAttribute("aria-label");
38505
38899
  return rest;
@@ -38509,6 +38903,8 @@ function Labelbox(Base) {
38509
38903
  Labelbox.labelbox = true;
38510
38904
  Labelbox.parameters = {
38511
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" },
38512
38908
  lbl_position: { dtype: "T", default: "TL", binding: "read", enum: labelboxPositions }
38513
38909
  };
38514
38910