@gramlot/gramlot 0.3.26 → 0.3.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) 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 +63 -33
  39. package/dist/components/grid/assets/index.js +1 -1
  40. package/dist/components/grid/grammar.json +279 -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 +12 -12
  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 +3 -3
  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 +9 -9
  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 +1190 -256
  71. package/dist/gramlot.min.js +85 -52
  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/binding/validation-context.js +2 -1
  77. package/src/bootstrap.js +1 -1
  78. package/src/builder/gramlot-builder.d.ts +15 -2
  79. package/src/builder/gramlot-builder.js +22 -3
  80. package/src/builder/source.js +24 -1
  81. package/src/components/audio-analysis-session.js +65 -0
  82. package/src/components/audio.js +44 -0
  83. package/src/components/bases.js +11 -7
  84. package/src/components/border-container.js +6 -3
  85. package/src/components/buttons.js +47 -3
  86. package/src/components/chart-bar3d-options.js +30 -0
  87. package/src/components/chart-controls.js +83 -0
  88. package/src/components/chart-data-view.js +52 -0
  89. package/src/components/chart-data.js +42 -0
  90. package/src/components/chart-domains.js +46 -0
  91. package/src/components/chart-engines/echarts-options.js +50 -0
  92. package/src/components/chart-engines/echarts.js +82 -0
  93. package/src/components/chart-engines/index.js +22 -0
  94. package/src/components/chart-engines/plotly-map.js +34 -0
  95. package/src/components/chart-engines/plotly-spatial.js +35 -0
  96. package/src/components/chart-engines/plotly.js +138 -0
  97. package/src/components/chart-engines/uplot.js +57 -0
  98. package/src/components/chart-engines/vega.js +101 -0
  99. package/src/components/chart-fields.js +110 -0
  100. package/src/components/chart-geographic-options.js +47 -0
  101. package/src/components/chart-geojson.js +60 -0
  102. package/src/components/chart-geometry.js +11 -0
  103. package/src/components/chart-map-anchors.js +24 -0
  104. package/src/components/chart-map-bar3d-options.js +41 -0
  105. package/src/components/chart-map-data.js +25 -0
  106. package/src/components/chart-map-labels.js +8 -0
  107. package/src/components/chart-map-options.js +20 -0
  108. package/src/components/chart-pane.js +91 -0
  109. package/src/components/chart-renderer.js +58 -0
  110. package/src/components/chart-sample-view.js +32 -0
  111. package/src/components/chart-spatial-options.js +40 -0
  112. package/src/components/chart-time.js +84 -0
  113. package/src/components/chart-timeline.js +70 -0
  114. package/src/components/chart-types/area.js +2 -0
  115. package/src/components/chart-types/bar.js +2 -0
  116. package/src/components/chart-types/bar3D.js +2 -0
  117. package/src/components/chart-types/donut.js +2 -0
  118. package/src/components/chart-types/horizontalBar.js +2 -0
  119. package/src/components/chart-types/index.js +26 -0
  120. package/src/components/chart-types/line.js +2 -0
  121. package/src/components/chart-types/line3D.js +2 -0
  122. package/src/components/chart-types/lines3D.js +2 -0
  123. package/src/components/chart-types/map.js +2 -0
  124. package/src/components/chart-types/map3D.js +2 -0
  125. package/src/components/chart-types/mapBar3D.js +2 -0
  126. package/src/components/chart-types/pie.js +2 -0
  127. package/src/components/chart-types/polygons3D.js +2 -0
  128. package/src/components/chart-types/scatter.js +2 -0
  129. package/src/components/chart-types/scatter3D.js +2 -0
  130. package/src/components/chart-types/stackedArea.js +2 -0
  131. package/src/components/chart-types/stackedBar.js +2 -0
  132. package/src/components/chart-types/surface.js +2 -0
  133. package/src/components/charts.js +152 -0
  134. package/src/components/check-box-text-editor.js +88 -0
  135. package/src/components/check-box-text.js +193 -0
  136. package/src/components/check-box-tree.js +62 -0
  137. package/src/components/choice-editor.js +35 -18
  138. package/src/components/choice-field-styles.js +14 -0
  139. package/src/components/choices.js +5 -0
  140. package/src/components/database-choices.js +9 -6
  141. package/src/components/drawing.js +199 -0
  142. package/src/components/field-state.js +8 -1
  143. package/src/components/grid-cell-editor.js +83 -19
  144. package/src/components/grid-check-sets.js +98 -0
  145. package/src/components/grid-column-filters.js +198 -0
  146. package/src/components/grid-grammar.json +65 -0
  147. package/src/components/grid-header-interaction.js +3 -1
  148. package/src/components/grid-rows.js +2 -2
  149. package/src/components/grid-search-box.js +38 -22
  150. package/src/components/grid-search-styles.js +13 -14
  151. package/src/components/grid-search.js +8 -1
  152. package/src/components/grid-structure.js +13 -2
  153. package/src/components/grid-styles.js +34 -2
  154. package/src/components/grid.js +67 -10
  155. package/src/components/image-uploader.js +2 -2
  156. package/src/components/inputs.js +21 -12
  157. package/src/components/labelbox.js +5 -1
  158. package/src/components/licenses/claygl.txt +23 -0
  159. package/src/components/licenses/echarts-gl.txt +29 -0
  160. package/src/components/licenses/plotly.txt +21 -0
  161. package/src/components/licenses/uplot.txt +21 -0
  162. package/src/components/licenses/vega.txt +27 -0
  163. package/src/components/menus.js +19 -11
  164. package/src/components/parameters.js +6 -2
  165. package/src/components/toolbar-overflow.js +12 -8
  166. package/src/components/tree.js +31 -8
  167. package/src/components/typed-editor.js +18 -7
  168. package/src/components/validation.js +1 -1
  169. package/src/components/vizabi-session.js +66 -0
  170. package/src/components/vizabi.js +66 -0
  171. package/src/components/window-surface.js +20 -9
  172. package/src/components/windows.js +1 -1
  173. package/src/editing-session.d.ts +1 -0
  174. package/src/editing-session.js +113 -15
  175. package/src/editor-values.js +57 -0
  176. package/src/gramlot.d.ts +2 -0
  177. package/src/gramlot.js +9 -4
  178. package/src/handlers/device-handler.js +32 -32
  179. package/src/handlers/source-handler.d.ts +2 -2
  180. package/src/ide-documents.js +19 -3
  181. package/src/ide-runtime.d.ts +1 -0
  182. package/src/ide-runtime.js +45 -31
  183. package/src/index.d.ts +2 -1
  184. package/src/renderer/drag-drop.js +1 -0
  185. package/src/renderer/gramlot-renderer.d.ts +3 -0
  186. package/src/renderer/gramlot-renderer.js +16 -4
  187. package/src/server/assets.d.ts +3 -0
  188. package/src/server/assets.js +9 -0
  189. package/src/server/gramlot-server.d.ts +1 -1
  190. package/src/server/gramlot-server.js +2 -1
  191. package/src/server/index.d.ts +1 -1
  192. package/src/server/index.js +1 -1
  193. package/src/server/source-import.d.ts +1 -1
  194. package/src/server/source-import.js +5 -1
  195. package/src/server/visual-editor.d.ts +1 -1
  196. package/src/server/visual-editor.js +44 -34
  197. package/src/source-picker.d.ts +1 -1
  198. package/src/source-picker.js +1 -2
  199. package/src/stores/bag-collection-view.js +79 -17
  200. package/src/stores/collection-filter.js +2 -1
  201. package/src/stores/column-filter.js +49 -0
  202. package/src/stores/id-set.js +10 -0
  203. package/src/view/controls.js +8 -0
  204. package/src/view/html.js +10 -1
  205. package/src/view/label-menu.js +61 -0
  206. package/src/view/labelbox.js +15 -2
  207. package/src/visual-editor-canvas.js +29 -0
  208. package/src/visual-editor-catalogue.js +34 -0
  209. package/src/visual-editor.d.ts +5 -0
  210. package/src/visual-editor.js +244 -26
  211. package/themes/gramlot-base/theme.css +84 -36
  212. package/tools/gramlot-tools-inspector.js +170 -506
  213. package/tools/inspector-agent.js +1 -1
@@ -1,10 +1,12 @@
1
1
  // ../tools/gramlot-tools-inspector/src/gramlot-tools-inspector.js
2
- import { Bag as Bag3, Gramlot, GramlotBuilder } from "@gramlot/gramlot";
2
+ import { Bag as Bag2, Gramlot, GramlotBuilder } from "@gramlot/gramlot";
3
+ import layout from "@gramlot/collections/layout";
4
+ import tree from "@gramlot/collections/tree";
3
5
 
4
6
  // ../tools/gramlot-tools-inspector/src/inspector-bridge.js
5
7
  import { Bag } from "@gramlot/gramlot";
6
8
 
7
- // ../tools/gramlot-tools-inspector/src/editor-values.js
9
+ // src/editor-values.js
8
10
  var editorTypes = ["string", "number", "integer", "boolean", "date", "time", "datetime", "null"];
9
11
  function scalarType(value) {
10
12
  if (value === null) return "null";
@@ -347,20 +349,20 @@ var roots = ["data", "source"];
347
349
  var forbidden = /* @__PURE__ */ new Set(["_meta", "__proto__", "prototype", "constructor"]);
348
350
  function attachInspectorAgent(gramlot, port) {
349
351
  if (!gramlot || gramlot.state === "disposed") throw new TypeError("Expected a live Gramlot instance");
350
- const Bag4 = gramlot.data.constructor;
352
+ const Bag3 = gramlot.data.constructor;
351
353
  const encodeScalar2 = (value) => {
352
- const wrapper = new Bag4();
354
+ const wrapper = new Bag3();
353
355
  wrapper.setItem("value", value);
354
356
  return wrapper.toTytx("json");
355
357
  };
356
358
  const decodeScalar2 = (text) => {
357
- const value = Bag4.fromTytx(text, "json").getItem("value");
359
+ const value = Bag3.fromTytx(text, "json").getItem("value");
358
360
  if (!scalarType(value)) throw new TypeError("The inspector edits scalar values only");
359
361
  return value;
360
362
  };
361
363
  function cell(value) {
362
364
  if (scalarType(value)) return { encoded: encodeScalar2(value) };
363
- const display = value instanceof Bag4 ? `Bag (${value.getNodes().length} nodes)` : value === void 0 ? "undefined" : typeof value === "function" ? "[Function]" : typeof value === "bigint" || typeof value === "symbol" ? String(value) : JSON.stringify(value);
365
+ const display = value instanceof Bag3 ? `Bag (${value.getNodes().length} nodes)` : value === void 0 ? "undefined" : typeof value === "function" ? "[Function]" : typeof value === "bigint" || typeof value === "symbol" ? String(value) : JSON.stringify(value);
364
366
  return { display, readonly: true };
365
367
  }
366
368
  const document = gramlot.src.renderer.destination.ownerDocument;
@@ -385,7 +387,7 @@ function attachInspectorAgent(gramlot, port) {
385
387
  const next = /* @__PURE__ */ new Set([...ancestors, store]);
386
388
  return store.getNodes().map((node) => {
387
389
  const value = node.getValue(true);
388
- const branch = !node.resolver && value instanceof Bag4;
390
+ const branch = !node.resolver && value instanceof Bag3;
389
391
  return {
390
392
  id: identity(node),
391
393
  label: node.label,
@@ -674,411 +676,7 @@ var InspectorConnection = class {
674
676
  };
675
677
 
676
678
  // ../tools/gramlot-tools-inspector/src/gramlot-tools-inspector.css
677
- var gramlot_tools_inspector_default = ":host { all: initial; background: var(--gramlot-surface, white); color-scheme: inherit; font: 12px/1.4 system-ui, sans-serif; color: var(--gramlot-ink, #38414b); }\n* { box-sizing: border-box; }\nbutton, input, select { font: inherit; color: inherit; }\nbutton { cursor: pointer; }\nbutton:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid var(--gramlot-focus-ring, #3574cb); outline-offset: -1px; }\n.tree { padding: 7px 3px; }\n.properties { background: var(--gramlot-surface, white); }\n.properties-heading { font-size: 11px; display: flex; align-items: center; justify-content: space-between; height: 29px; padding: 0 8px; background: var(--gramlot-surface-subtle, #f1f3f5); color: var(--gramlot-text-secondary, #6d7989); border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.properties-heading button { background: var(--gramlot-surface, white); border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 2px; width: 23px; height: 23px; padding: 0; font-size: 18px; line-height: 20px; }\nfieldset { border: 0; margin: 0; padding: 0; min-width: 0; }\n.property-row { display: grid; grid-template-columns: minmax(95px, 30%) minmax(0, 1fr); min-height: 20px; border-bottom: 1px solid var(--gramlot-border, #d1d7df); font-size: 11px; }\n.property-name { display: flex; align-items: center; justify-content: flex-end; background: var(--gramlot-surface-subtle, #f1f3f5); color: var(--gramlot-ink, #38414b); font-weight: 700; padding: 1px 6px; border-right: 1px solid var(--gramlot-border, #d1d7df); overflow-wrap: anywhere; text-align: right; }\n.property-value { display: flex; align-items: center; min-width: 0; }\n.property-row input { border: 0; border-radius: 0; min-width: 0; width: 100%; height: 19px; padding: 1px 5px; background: transparent; }\n.property-name input { color: var(--gramlot-ink, #38414b); text-align: right; padding: 0; }\n.property-value input { flex: 1; }\n.property-value input[type=checkbox] { flex: none; width: 14px; height: 14px; margin: 2px 6px; }\n.property-value select { max-width: 82px; height: 20px; padding: 0; border: 0; border-left: 1px solid var(--gramlot-border, #d1d7df); background: var(--gramlot-surface-subtle, #f1f3f5); font-size: 10px; }\n.remove { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; flex: none; width: 22px; height: 20px; padding: 3px; border: 0; background: transparent; color: var(--gramlot-text-secondary, #7c8797); opacity: 0; }\n.remove svg { width: 13px; height: 13px; }\n.property-row:hover .remove, .property-row:focus-within .remove { opacity: 1; }\n.remove:hover { color: var(--gramlot-error, #b82323); background: var(--gramlot-error-background, #fbe9e9); }\n:disabled { cursor: default; opacity: .65; }\n.path { flex: none; padding: 5px 9px; border-top: 1px solid var(--gramlot-border, #c9cfd6); background: var(--gramlot-surface-subtle, #f5f7f9); color: var(--gramlot-text-secondary, #697687); font-size: 11px; min-height: 27px; overflow-wrap: anywhere; }\n.error, .edit-status, .breakpoint-status, .breakpoint-line { font-size: 11px; margin: 0; padding: 3px 8px; overflow-wrap: anywhere; }\n.error, .edit-status, .breakpoint-status { color: var(--gramlot-error, #a12121); }\n.breakpoint-line { background: var(--gramlot-warning-background, #fff2ed); color: var(--gramlot-warning, #854127); border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.error:empty, .edit-status:empty, .breakpoint-status:empty, .breakpoint-line:empty { display: none; }\n.breakpoint-dialog { background: var(--gramlot-surface, white); width: min(340px, 90vw); color: var(--gramlot-ink, #38414b); border: 1px solid var(--gramlot-border-control, #bbc3cf); border-radius: 4px; padding: 12px; box-shadow: 0 8px 28px #0003; font: 12px/1.4 system-ui, sans-serif; }\n.breakpoint-dialog::backdrop { background: #0002; }\n.breakpoint-dialog h2 { font-size: 13px; margin: 0 0 10px; overflow-wrap: anywhere; }\n.breakpoint-dialog select, .breakpoint-dialog input { width: 100%; border: 1px solid var(--gramlot-border-control, #bbc3cf); padding: 4px; margin: 0 0 7px; background: var(--gramlot-surface, white); }\n.dialog-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 7px; }\n.dialog-actions button { padding: 3px 10px; border: 1px solid var(--gramlot-border-control, #bbc3cf); border-radius: 3px; background: var(--gramlot-surface-subtle, #f1f3f5); }\n.heading-label { flex: 1; }\n.properties-heading .breakpoint-count { width: auto; padding: 0 5px; margin-right: 5px; font-size: 11px; color: var(--gramlot-error, #b04a35); }\n.breakpoint-entry { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.breakpoint-entry span { flex: 1; overflow-wrap: anywhere; }\n.breakpoint-entry button { background: transparent; border: 0; font-size: 17px; }\n[hidden] { display: none !important; }\n.targetbar { flex: none; height: 28px; padding: 2px 6px; background: var(--gramlot-surface-subtle, #edf2fa); border-bottom: 1px solid var(--gramlot-border, #dadce0); }\n.targetbar select { width: 100%; height: 23px; border: 0; background: transparent; font-size: 11px; }\n.styles-panel { flex: 1; min-height: 0; overflow: auto; background: var(--gramlot-surface, #fff); font-size: 11px; }\n.styles-toolbar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; background: var(--gramlot-surface-subtle, #f1f3f5); border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.styles-toolbar span { flex: 1; font-weight: 600; }\n.styles-toolbar button, .styles-toolbar a { padding: 3px 7px; border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 3px; background: var(--gramlot-surface, white); }\n.styles-toolbar a { color: inherit; text-decoration: none; }\n.styles-toolbar a[aria-disabled=true] { cursor: default; opacity: .65; }\n.styles-toolbar a:focus-visible { outline: 1px solid var(--gramlot-focus-ring, #3574cb); outline-offset: -1px; }\n.styles-help, .styles-empty, .styles-status { margin: 0; padding: 7px 9px; color: var(--gramlot-text-secondary, #697687); }\n.styles-status { color: var(--gramlot-error, #a12121); }\n.styles-status:empty { display: none; }\n.styles-group h3 { margin: 0; padding: 6px 9px; font-size: 11px; background: var(--gramlot-surface-subtle, #edf2fa); border-block: 1px solid var(--gramlot-border, #d1d7df); }\n.style-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 25px 23px; align-items: center; gap: 8px; min-width: 0; padding: 3px 9px; border-bottom: 1px solid var(--gramlot-border, #e8ebef); }\n.style-row label { min-width: 0; font: 11px/1.4 ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.style-row input { min-width: 0; width: 100%; height: 23px; padding: 2px 5px; border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 3px; background: var(--gramlot-surface, white); }\n.style-row input[type=color] { width: 25px; padding: 1px; cursor: pointer; }\n.style-row button { grid-column: 4; width: 23px; height: 23px; padding: 0; border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 3px; background: var(--gramlot-surface-subtle, #f5f7f9); font-size: 15px; }\n\n:host([embedded]) { display: block; height: 100%; min-height: 0; }\n:host([embedded]) > div { height: 100%; }\n.embedded-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }\n\n.property-value select.enum-value { flex: 1; min-width: 0; max-width: none; width: 100%; border: 0; background: var(--gramlot-surface, white); font: inherit; padding: 1px 5px; }\n\n/* Presentation changes preserve the inspector runtime and selection. */\n:host([hidden]) { display: none; }\n:host([docked]) { display: block; height: 100%; min-height: 0; }\n:host([docked][hidden]) { display: none; }\n:host([docked]) > div { height: 100%; }\n:host([docked]) .targetbar select { min-height: 40px; font-size: 16px; }\n:host([docked]) .property-row { min-height: 36px; font-size: 13px; }\n:host([docked]) .property-row input { min-height: 35px; font-size: 16px; }\n:host([docked]) .remove { opacity: 1; min-height: 35px; width: 32px; }\n\n:host([docked]) { --tree-action-size: 28px; --tree-font-size: 14px; --tree-row-height: 40px; --separator-size: 14px; }\n:host([docked]) .targetbar { height: 44px; }\n:host([docked]) gramlot-poc-tabs > button { height: 44px; font-size: 14px; }\n:host([docked]) .properties-heading { height: 40px; font-size: 13px; }\n:host([docked]) .properties-heading button { width: 36px; height: 36px; }\n:host([docked]) .property-value select { height: 35px; font-size: 14px; }\n\n.history-toolbar { flex:none; display:flex; align-items:center; gap:6px; padding:4px 8px; border-bottom:1px solid var(--gramlot-border, #d1d7df); background:var(--gramlot-surface-subtle, #f6f8fb); font:11px/1.4 system-ui,sans-serif; }\n.history-toolbar button { flex:none; padding:3px 6px; border:1px solid var(--gramlot-border-control, #c5cdda); border-radius:3px; background:var(--gramlot-surface, white); cursor:pointer; }\n.history-toolbar button:disabled { opacity:.45; cursor:default; }\n.history-toolbar span { min-width:0; color:var(--gramlot-error, #a12121); overflow-wrap:anywhere; }\n";
678
-
679
- // ../tools/poc/gramlot-poc-tree.js
680
- import { Bag as Bag2 } from "@gramlot/gramlot";
681
-
682
- // ../tools/poc/gramlot-poc-tree.css
683
- var gramlot_poc_tree_default = "/* Copyright 2025-2026 Softwell S.r.l. - SPDX-License-Identifier: Apache-2.0\n * Inspector subset of the DevTools storeTree stylesheet and inspector.css variables. */\n:host { display:block; font:var(--tree-font-size,11px)/var(--tree-row-height,18px) -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; color:var(--gramlot-ink, #38414b); }\n:host([hidden]) { display:none; }\nul { list-style:none; margin:0; padding-left:17px; }\n.tree-root { padding-left:calc(var(--tree-action-size,14px) + 2px); }\n.tree-root > ul { padding-left:2px; }\nsummary, .leaf { position:relative; }\nli { line-height:var(--tree-row-height,18px); }\nsummary { display:flex; align-items:center; gap:7px; padding:0 5px; cursor:pointer; user-select:none; list-style:none; }\nsummary::-webkit-details-marker { display:none; }\nsummary::before { content:''; width:5px; height:5px; border-right:1.5px solid var(--gramlot-text-secondary, #78818a); border-bottom:1.5px solid var(--gramlot-text-secondary, #78818a); transform:rotate(-45deg); flex:none; margin:0 3px; }\ndetails[open] > summary::before { transform:rotate(45deg); }\n.leaf { display:flex; align-items:center; gap:7px; padding:0 5px 0 23px; cursor:pointer; }\nsummary:hover,.leaf:hover { background:var(--gramlot-surface-subtle, #f0f3f6); }\n.selected,.selected:hover { background:transparent; color:var(--gramlot-action, #315dbd); font-weight:700; border-radius:2px; }\n.caption { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }\n/* Reserve a left gutter; showing an action must not shift the node label. */\n.actions { position:absolute; left:calc(-1 * var(--tree-action-size,14px)); top:0; display:inline-flex; opacity:0; pointer-events:none; }\nsummary:hover > .actions,.leaf:hover > .actions,summary:focus-visible > .actions,.leaf:focus-visible > .actions,\n.actions:has(button:focus-visible),.actions:has(button.active) { opacity:1; pointer-events:auto; }\n.actions button { border:0; background:transparent; color:var(--gramlot-text-secondary, #80868b); font:inherit; font-size:11px; line-height:var(--tree-row-height,18px); width:var(--tree-action-size,14px); height:var(--tree-row-height,18px); padding:0; cursor:pointer; border-radius:3px; }\n.actions button:hover { background:var(--gramlot-selected, #e1e5ed); }\n.actions button[data-action=breakpoint] { font-size:0; }\n.actions button[data-action=breakpoint]::before { content:''; display:inline-block; box-sizing:border-box; width:8px; height:8px; border:1.5px solid currentColor; border-radius:50%; vertical-align:middle; }\n.actions button.active { color:var(--gramlot-error, #b3261e); }\n.actions button.active.conditional { color:var(--gramlot-warning, #f9ab00); }\n.actions button.active[data-action=breakpoint]::before { background:currentColor; }\n.actions button:focus-visible,summary:focus-visible,.leaf:focus-visible { outline:2px solid var(--gramlot-focus-ring, #356f9f); outline-offset:-2px; }\n\n@media (hover: none) { .actions { opacity:1; pointer-events:auto; } }\n\n.actions-end { position:static; margin-left:auto; flex:none; }\n[data-drop=inside] { outline:2px solid var(--gramlot-focus-ring, #356f9f); outline-offset:-2px; background:var(--gramlot-selected, #e7f0fc); }\n[data-drop=before] { box-shadow:inset 0 2px var(--gramlot-focus-ring, #356f9f); }\n[data-drop=after] { box-shadow:inset 0 -2px var(--gramlot-focus-ring, #356f9f); }\n";
684
-
685
- // ../tools/poc/gramlot-poc-tree.js
686
- var sequence = 0;
687
- var GramlotPocTree = class extends HTMLElement {
688
- constructor() {
689
- super();
690
- const shadow = this.attachShadow({ mode: "open" });
691
- const style = this.ownerDocument.createElement("style");
692
- style.textContent = gramlot_poc_tree_default;
693
- this._root = this.ownerDocument.createElement("div");
694
- this._root.className = "tree-root";
695
- shadow.append(style, this._root);
696
- this._store = null;
697
- this._selectedPath = null;
698
- this._expanded = /* @__PURE__ */ new Set();
699
- this._nodes = /* @__PURE__ */ new Map();
700
- this._rowActions = [];
701
- this.dragEnabled = false;
702
- this.fixedPaths = [];
703
- this._drag = null;
704
- this._pendingRender = null;
705
- this._subId = `gramlot-poc-tree-${++sequence}`;
706
- }
707
- get storeBag() {
708
- return this._store;
709
- }
710
- set storeBag(bag) {
711
- if (bag !== null && !(bag instanceof Bag2)) throw new TypeError("storeBag requires a Bag or null");
712
- if (bag === this._store) return;
713
- if (this.isConnected && this._store) this._store.unsubscribe(this._subId, { any: true });
714
- this._store = bag;
715
- this._selectedPath = null;
716
- this._expanded.clear();
717
- this._root.replaceChildren();
718
- if (this.isConnected) {
719
- this._subscribe();
720
- this._render();
721
- }
722
- }
723
- get selectedPath() {
724
- return this._selectedPath;
725
- }
726
- set selectedPath(path) {
727
- if (path !== null && typeof path !== "string") throw new TypeError("selectedPath requires a string or null");
728
- this._selectedPath = path;
729
- if (this.isConnected) this._markSelection();
730
- }
731
- revealPath(path) {
732
- for (const details of this._root.querySelectorAll("details")) {
733
- if (path.startsWith(details.dataset.path + ".")) details.open = true;
734
- }
735
- this.selectedPath = path;
736
- }
737
- get rowActions() {
738
- return this._rowActions;
739
- }
740
- set rowActions(actions) {
741
- if (!Array.isArray(actions) || actions.some((action) => !action || typeof action.id !== "string" || !action.id || typeof action.label !== "string" || !action.label)) {
742
- throw new TypeError("rowActions requires actions with id and label");
743
- }
744
- this._rowActions = actions.map((action) => ({ ...action }));
745
- if (this.isConnected) this._render();
746
- }
747
- connectedCallback() {
748
- this._subscribe();
749
- this._render();
750
- }
751
- disconnectedCallback() {
752
- this._pendingRender = null;
753
- if (this._store) this._store.unsubscribe(this._subId, { any: true });
754
- }
755
- _subscribe() {
756
- if (this._store) this._store.subscribe(this._subId, { any: () => {
757
- if (this._pendingRender) return;
758
- const pending = this._pendingRender = {};
759
- queueMicrotask(() => {
760
- if (this._pendingRender === pending && this.isConnected) this._render();
761
- });
762
- } });
763
- }
764
- _render() {
765
- this._pendingRender = null;
766
- const focused = this.shadowRoot.activeElement;
767
- const focusedPath = focused?.closest("[data-node-path]")?.dataset.nodePath;
768
- const focusedAction = focused?.dataset.action;
769
- for (const details of this._root.querySelectorAll("details")) {
770
- if (details.open) this._expanded.add(details.dataset.path);
771
- else this._expanded.delete(details.dataset.path);
772
- }
773
- this._nodes.clear();
774
- this._root.replaceChildren(...this._store ? [this._buildLevel(this._store, "", /* @__PURE__ */ new Set())] : []);
775
- if (focusedPath) {
776
- let path = focusedPath;
777
- while (path && !this._nodes.has(path)) path = path.includes(".") ? path.slice(0, path.lastIndexOf(".")) : "";
778
- const row = [...this._root.querySelectorAll("[data-node-path]")].find((item) => item.dataset.nodePath === path);
779
- const action = focusedAction && row && [...row.querySelectorAll("button")].find((button) => button.dataset.action === focusedAction);
780
- (action || row)?.focus({ preventScroll: true });
781
- }
782
- if (this._selectedPath !== null && !this._nodes.has(this._selectedPath)) {
783
- this._selectedPath = null;
784
- this._notifySelection();
785
- }
786
- }
787
- _buildLevel(bag, prefix, ancestors) {
788
- if (ancestors.has(bag)) throw new TypeError("gramlot-poc-tree requires an acyclic Bag");
789
- const nextAncestors = /* @__PURE__ */ new Set([...ancestors, bag]);
790
- const document = this.ownerDocument;
791
- const list = document.createElement("ul");
792
- for (const node of bag.getNodes()) {
793
- const path = prefix ? `${prefix}.${node.label}` : node.label;
794
- this._nodes.set(path, node);
795
- const value = node.getValue(true);
796
- const item = document.createElement("li");
797
- let row;
798
- if (!node.resolver && value instanceof Bag2) {
799
- const details = document.createElement("details");
800
- details.dataset.path = path;
801
- details.open = this._expanded.has(path);
802
- row = document.createElement("summary");
803
- details.append(row, this._buildLevel(value, path, nextAncestors));
804
- item.append(details);
805
- } else {
806
- row = item;
807
- row.className = "leaf";
808
- row.tabIndex = 0;
809
- row.addEventListener("keydown", (event) => {
810
- if (event.key === "Enter" || event.key === " ") {
811
- event.preventDefault();
812
- this._select(path);
813
- }
814
- });
815
- }
816
- row.dataset.nodePath = path;
817
- row.classList.toggle("selected", path === this._selectedPath);
818
- const caption = document.createElement("span");
819
- caption.className = "caption";
820
- caption.textContent = node.label;
821
- row.append(caption);
822
- row.addEventListener("click", () => this._select(path));
823
- this._actions(row, path, node);
824
- this._dragEvents(row, path, node);
825
- list.append(item);
826
- }
827
- return list;
828
- }
829
- _actions(row, path, node) {
830
- if (!this._rowActions.length) return;
831
- for (const position of ["start", "end"]) {
832
- const actions = this.ownerDocument.createElement("span");
833
- actions.className = `actions actions-${position}`;
834
- for (const action of this._rowActions) {
835
- if ((action.position ?? "start") !== position || action.hiddenPaths?.includes(path)) continue;
836
- const button = this.ownerDocument.createElement("button");
837
- button.type = "button";
838
- button.textContent = action.icon ?? action.label;
839
- button.title = action.label;
840
- button.setAttribute("aria-label", action.label);
841
- button.dataset.action = action.id;
842
- button.classList.toggle("active", action.activePaths?.includes(path) ?? false);
843
- button.classList.toggle("conditional", action.conditionalPaths?.includes(path) ?? false);
844
- button.addEventListener("click", (event) => {
845
- event.preventDefault();
846
- event.stopPropagation();
847
- this.dispatchEvent(new this.ownerDocument.defaultView.CustomEvent("tree-action", {
848
- bubbles: true,
849
- composed: true,
850
- detail: { action: action.id, path, node }
851
- }));
852
- });
853
- actions.append(button);
854
- }
855
- if (actions.childElementCount) row.append(actions);
856
- }
857
- }
858
- _clearDrop() {
859
- for (const row of this._root.querySelectorAll("[data-drop]")) delete row.dataset.drop;
860
- }
861
- _dragEvents(row, path, node) {
862
- if (!this.dragEnabled) return;
863
- row.draggable = !this.fixedPaths.includes(path);
864
- row.addEventListener("dragstart", (event) => {
865
- if (!row.draggable || event.target.closest("button")) {
866
- event.preventDefault();
867
- return;
868
- }
869
- event.stopPropagation();
870
- this._drag = { path, node };
871
- event.dataTransfer.effectAllowed = "move";
872
- event.dataTransfer.setData("application/x-gramlot-source", this._subId);
873
- });
874
- const placement = (event) => {
875
- const rect = row.getBoundingClientRect();
876
- const fraction = (event.clientY - rect.top) / rect.height;
877
- return this.fixedPaths.includes(path) ? "inside" : fraction < 0.25 ? "before" : fraction > 0.75 ? "after" : "inside";
878
- };
879
- const valid = () => this._drag && this._drag.path !== path && !path.startsWith(this._drag.path + ".");
880
- row.addEventListener("dragover", (event) => {
881
- if (!valid()) return;
882
- event.preventDefault();
883
- event.stopPropagation();
884
- event.dataTransfer.dropEffect = "move";
885
- this._clearDrop();
886
- row.dataset.drop = placement(event);
887
- });
888
- row.addEventListener("dragleave", () => {
889
- delete row.dataset.drop;
890
- });
891
- row.addEventListener("drop", (event) => {
892
- event.preventDefault();
893
- event.stopPropagation();
894
- this._clearDrop();
895
- if (!valid() || event.dataTransfer.getData("application/x-gramlot-source") !== this._subId) return;
896
- const source = this._drag;
897
- this._drag = null;
898
- if (this._store.getNode(source.path) !== source.node) return;
899
- this.dispatchEvent(new this.ownerDocument.defaultView.CustomEvent("tree-drop", {
900
- bubbles: true,
901
- composed: true,
902
- detail: { path: source.path, destination: path, placement: placement(event) }
903
- }));
904
- });
905
- row.addEventListener("dragend", () => {
906
- this._drag = null;
907
- this._clearDrop();
908
- });
909
- }
910
- _markSelection() {
911
- for (const row of this._root.querySelectorAll("[data-node-path]")) {
912
- row.classList.toggle("selected", row.dataset.nodePath === this._selectedPath);
913
- }
914
- }
915
- _select(path) {
916
- this._selectedPath = path;
917
- this._markSelection();
918
- this._notifySelection();
919
- }
920
- _notifySelection() {
921
- this.dispatchEvent(new this.ownerDocument.defaultView.CustomEvent("change", {
922
- bubbles: true,
923
- composed: true,
924
- detail: { path: this._selectedPath, node: this._nodes.get(this._selectedPath) ?? null }
925
- }));
926
- }
927
- };
928
- customElements.define("gramlot-poc-tree", GramlotPocTree);
929
-
930
- // ../tools/poc/gramlot-poc-palette.js
931
- var GramlotPocPalette = class extends HTMLElement {
932
- static observedAttributes = ["title", "collapsed"];
933
- constructor() {
934
- super();
935
- this.attachShadow({ mode: "open" }).innerHTML = `<style>
936
- :host{box-sizing:border-box;position:fixed;z-index:2147483647;left:16px;top:16px;width:480px;height:620px;min-width:min(280px,100vw);min-height:200px;max-width:calc(100vw - 16px);max-height:calc(100vh - 16px);display:block;font:11px/1.45 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;background:var(--gramlot-surface, white);color:var(--gramlot-ink, #38414b);border:1px solid var(--gramlot-border, #b9bec5);border-radius:4px;box-shadow:0 6px 22px #20283026;overflow:hidden}
937
- *{box-sizing:border-box}.frame{height:100%;display:flex;flex-direction:column}.bar{display:flex;align-items:center;height:25px;min-height:25px;padding:0 4px;border-bottom:1px solid var(--gramlot-border, #d8d8dc);background:var(--gramlot-surface-subtle, #eceef1);cursor:move;touch-action:none;user-select:none}.title{flex:1;min-width:0;text-align:left;padding-left:5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;font-weight:600}.body{flex:1;min-height:0;display:flex;flex-direction:column}.resize{position:absolute;right:2px;bottom:2px;width:14px;height:14px;cursor:nwse-resize;touch-action:none;background:repeating-linear-gradient(135deg,transparent 0 3px,var(--gramlot-border-control, #aab0b8) 3px 4px,transparent 4px 6px);clip-path:polygon(100% 0,100% 100%,0 100%)}button{font:inherit;color:var(--gramlot-text-secondary, #69727c);background:transparent;border:0;cursor:pointer}.close,.collapse{width:22px;flex:none;height:22px;font-size:18px;line-height:18px;padding:0}.close:hover,.collapse:hover{background:var(--gramlot-selected, #dce1e7)}.bar:focus-visible,button:focus-visible{outline:2px solid var(--gramlot-focus-ring, #356f9f);outline-offset:-2px}.resize:focus-visible{clip-path:none}::slotted(*){min-height:0}
938
- :host([docked]){position:relative!important;inset:0!important;width:100%!important;height:100%!important;min-width:0;min-height:0;max-width:none;max-height:none;border:0;border-radius:0;box-shadow:none}
939
- :host([docked]) .bar,:host([docked]) .resize{display:none}
940
- :host([docked][collapsed]) .body{display:flex}
941
- :host([collapsed]:not([docked])){height:27px!important;min-height:27px}:host([collapsed]:not([docked])) .body,:host([collapsed]:not([docked])) .resize{display:none}
942
- </style><div class="frame" role="dialog" aria-modal="false" aria-labelledby="title"><div class="bar" tabindex="0" aria-label="Move inspector: arrow keys, Home to reset"><span class="title" id="title"></span><button class="collapse" type="button" aria-label="Collapse inspector" aria-expanded="true" aria-controls="palette-body">\u2212</button><button class="close" type="button" aria-label="Close inspector">\xD7</button></div><div class="body" id="palette-body"><slot></slot></div><button class="resize" type="button" aria-label="Resize inspector: arrow keys"></button></div>`;
943
- this._bar = this.shadowRoot.querySelector(".bar");
944
- this._grip = this.shadowRoot.querySelector(".resize");
945
- this._collapse = this.shadowRoot.querySelector(".collapse");
946
- this._collapse.addEventListener("click", () => {
947
- this.collapsed = !this.collapsed;
948
- });
949
- this.shadowRoot.querySelector(".close").addEventListener("click", () => this.dispatchEvent(
950
- new this.ownerDocument.defaultView.CustomEvent("close", { bubbles: true, composed: true })
951
- ));
952
- for (const handle of [this._bar, this._grip]) {
953
- handle.addEventListener("pointerdown", (event) => {
954
- if (event.button !== 0 || handle === this._bar && event.target.closest("button")) return;
955
- this._gesture = { x: event.clientX, y: event.clientY, rect: this.getBoundingClientRect(), resize: handle === this._grip };
956
- handle.setPointerCapture(event.pointerId);
957
- event.preventDefault();
958
- });
959
- handle.addEventListener("pointermove", (event) => {
960
- if (this._gesture) this._adjust(this._gesture.rect, event.clientX - this._gesture.x, event.clientY - this._gesture.y, this._gesture.resize);
961
- });
962
- for (const name of ["pointerup", "pointercancel", "lostpointercapture"]) handle.addEventListener(name, () => {
963
- this._gesture = null;
964
- });
965
- handle.addEventListener("keydown", (event) => {
966
- if (event.target !== handle) return;
967
- if (event.key === "Home" && handle === this._bar) {
968
- this.style.left = "16px";
969
- this.style.top = "16px";
970
- event.preventDefault();
971
- return;
972
- }
973
- const step = event.shiftKey ? 1 : 10;
974
- const delta = { ArrowLeft: [-step, 0], ArrowRight: [step, 0], ArrowUp: [0, -step], ArrowDown: [0, step] }[event.key];
975
- if (delta) {
976
- event.preventDefault();
977
- this._adjust(this.getBoundingClientRect(), ...delta, handle === this._grip);
978
- }
979
- });
980
- }
981
- this._fit = () => !this.hasAttribute("docked") && this._adjust(this.getBoundingClientRect(), 0, 0, false);
982
- }
983
- get collapsed() {
984
- return this.hasAttribute("collapsed");
985
- }
986
- set collapsed(value) {
987
- this.toggleAttribute("collapsed", value);
988
- }
989
- attributeChangedCallback(name) {
990
- if (name === "title") this.shadowRoot.querySelector(".title").textContent = this.getAttribute("title") ?? "";
991
- else {
992
- this._collapse.textContent = this.collapsed ? "\uFF0B" : "\u2212";
993
- this._collapse.setAttribute("aria-expanded", String(!this.collapsed));
994
- this._collapse.setAttribute("aria-label", this.collapsed ? "Expand inspector" : "Collapse inspector");
995
- }
996
- }
997
- connectedCallback() {
998
- this.ownerDocument.defaultView.addEventListener("resize", this._fit);
999
- }
1000
- disconnectedCallback() {
1001
- this.ownerDocument.defaultView.removeEventListener("resize", this._fit);
1002
- this._gesture = null;
1003
- }
1004
- _adjust(rect, dx, dy, resize) {
1005
- const win = this.ownerDocument.defaultView;
1006
- if (resize && this.collapsed) return;
1007
- if (resize) {
1008
- this.style.width = Math.max(Math.min(280, win.innerWidth - 16), Math.min(win.innerWidth - 16, rect.width + dx)) + "px";
1009
- this.style.height = Math.max(Math.min(200, win.innerHeight - 16), Math.min(win.innerHeight - 16, rect.height + dy)) + "px";
1010
- } else {
1011
- this.style.left = Math.max(0, Math.min(win.innerWidth - Math.min(rect.width, win.innerWidth), rect.left + dx)) + "px";
1012
- this.style.top = Math.max(0, Math.min(win.innerHeight - 25, rect.top + dy)) + "px";
1013
- }
1014
- }
1015
- };
1016
- customElements.define("gramlot-poc-palette", GramlotPocPalette);
1017
-
1018
- // ../tools/poc/gramlot-poc-tabs.js
1019
- var GramlotPocTabs = class extends HTMLElement {
1020
- constructor() {
1021
- super();
1022
- this.attachShadow({ mode: "open" }).innerHTML = `<style>
1023
- :host{display:flex;flex:none;background:var(--gramlot-surface-subtle, #edf2fa);border-bottom:1px solid var(--gramlot-border, #d3e3fd)}
1024
- ::slotted(button){height:25px;padding:0 10px;border:0;border-radius:0;border-bottom:2px solid transparent;background:transparent;color:var(--gramlot-ink, #474747);font:500 11px/23px system-ui,sans-serif;cursor:pointer}
1025
- ::slotted(button:hover){background:var(--gramlot-selected, #e1e5ed)}::slotted(button[aria-selected=true]){color:var(--gramlot-action, #0b57d0);border-bottom-color:var(--gramlot-action, #0b57d0)}::slotted(button:focus-visible){outline:2px solid var(--gramlot-action, #0b57d0);outline-offset:-2px}
1026
- </style><slot></slot>`;
1027
- this.addEventListener("keydown", (event) => {
1028
- if (!["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
1029
- const tabs = [...this.children].filter((element) => element.getAttribute("role") === "tab");
1030
- const index = tabs.indexOf(event.target);
1031
- if (index < 0) return;
1032
- const next = event.key === "Home" ? 0 : event.key === "End" ? tabs.length - 1 : (index + (event.key === "ArrowRight" ? 1 : -1) + tabs.length) % tabs.length;
1033
- event.preventDefault();
1034
- tabs[next].focus();
1035
- tabs[next].click();
1036
- });
1037
- }
1038
- };
1039
- customElements.define("gramlot-poc-tabs", GramlotPocTabs);
1040
-
1041
- // ../tools/poc/gramlot-poc-splitter.js
1042
- var GramlotPocSplitter = class extends HTMLElement {
1043
- constructor() {
1044
- super();
1045
- this.attachShadow({ mode: "open" }).innerHTML = `<style>
1046
- :host{display:grid;grid-template-rows:minmax(60px,var(--top-size,45%)) var(--separator-size,6px) minmax(60px,1fr);min-height:126px;flex:1;overflow:hidden}
1047
- .region{overflow:auto;min-height:0;min-width:0}.handle{position:relative;background:var(--gramlot-surface-subtle, #e4e7eb);cursor:row-resize;touch-action:none;user-select:none}.handle:after{content:'';position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);height:1px;width:28px;background:var(--gramlot-border, #c2c9d3)}.handle:hover{background:var(--gramlot-selected, #c4d9ef)}.handle:focus-visible{outline:2px solid var(--gramlot-focus-ring, #356f9f);outline-offset:-2px}::slotted(*){min-height:0}
1048
- </style><div class="region"><slot name="top"></slot></div><div class="handle" role="separator" aria-label="Resize tree and properties" aria-orientation="horizontal" tabindex="0" aria-valuemin="10" aria-valuemax="90" aria-valuenow="45"></div><div class="region"><slot name="bottom"></slot></div>`;
1049
- const handle = this.shadowRoot.querySelector(".handle");
1050
- handle.addEventListener("pointerdown", (event) => {
1051
- if (event.button !== 0) return;
1052
- this._dragging = true;
1053
- handle.setPointerCapture(event.pointerId);
1054
- event.preventDefault();
1055
- });
1056
- handle.addEventListener("pointermove", (event) => {
1057
- if (this._dragging) {
1058
- const rect = this.getBoundingClientRect();
1059
- this._resize(100 * (event.clientY - rect.top) / rect.height);
1060
- }
1061
- });
1062
- for (const name of ["pointerup", "pointercancel", "lostpointercapture"]) handle.addEventListener(name, () => {
1063
- this._dragging = false;
1064
- });
1065
- handle.addEventListener("keydown", (event) => {
1066
- if (!["ArrowUp", "ArrowDown", "Home", "End"].includes(event.key)) return;
1067
- event.preventDefault();
1068
- const value = Number(handle.getAttribute("aria-valuenow"));
1069
- this._resize(event.key === "Home" ? 10 : event.key === "End" ? 90 : value + (event.key === "ArrowUp" ? -5 : 5));
1070
- });
1071
- }
1072
- _resize(value) {
1073
- value = Math.max(10, Math.min(90, value));
1074
- this.style.setProperty("--top-size", `${value}%`);
1075
- this.shadowRoot.querySelector(".handle").setAttribute("aria-valuenow", String(Math.round(value)));
1076
- }
1077
- disconnectedCallback() {
1078
- this._dragging = false;
1079
- }
1080
- };
1081
- customElements.define("gramlot-poc-splitter", GramlotPocSplitter);
679
+ var gramlot_tools_inspector_default = ":host { all: initial; background: var(--gramlot-surface, white); color-scheme: inherit; font: 12px/1.4 system-ui, sans-serif; color: var(--gramlot-ink, #38414b); }\n* { box-sizing: border-box; }\nbutton, input, select { font: inherit; color: inherit; }\nbutton { cursor: pointer; }\nbutton:focus-visible, input:focus-visible, select:focus-visible { outline: 1px solid var(--gramlot-focus-ring, #3574cb); outline-offset: -1px; }\n.tree { padding: 7px 3px; }\ngramlot-tree::part(inspector-breakpoint) { color: var(--gramlot-error, #b3261e); }\ngramlot-tree::part(inspector-breakpoint-conditional) { color: var(--gramlot-warning, #a56600); }\n.inspector-content { flex: 1; min-height: 126px; min-width: 0; --gramlot-splitter-size: var(--separator-size, 6px); }\n.properties { background: var(--gramlot-surface, white); }\n.properties-heading { font-size: 11px; display: flex; align-items: center; justify-content: space-between; height: 29px; padding: 0 8px; background: var(--gramlot-surface-subtle, #f1f3f5); color: var(--gramlot-text-secondary, #6d7989); border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.properties-heading button { background: var(--gramlot-surface, white); border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 2px; width: 23px; height: 23px; padding: 0; font-size: 18px; line-height: 20px; }\nfieldset { border: 0; margin: 0; padding: 0; min-width: 0; }\n.property-row { display: grid; grid-template-columns: minmax(95px, 30%) minmax(0, 1fr); min-height: 20px; border-bottom: 1px solid var(--gramlot-border, #d1d7df); font-size: 11px; }\n.property-name { display: flex; align-items: center; justify-content: flex-end; background: var(--gramlot-surface-subtle, #f1f3f5); color: var(--gramlot-ink, #38414b); font-weight: 700; padding: 1px 6px; border-right: 1px solid var(--gramlot-border, #d1d7df); overflow-wrap: anywhere; text-align: right; }\n.property-value { display: flex; align-items: center; min-width: 0; }\n.property-row input { border: 0; border-radius: 0; min-width: 0; width: 100%; height: 19px; padding: 1px 5px; background: transparent; }\n.property-name input { color: var(--gramlot-ink, #38414b); text-align: right; padding: 0; }\n.property-value input { flex: 1; }\n.property-value input[type=checkbox] { flex: none; width: 14px; height: 14px; margin: 2px 6px; }\n.property-value select { max-width: 82px; height: 20px; padding: 0; border: 0; border-left: 1px solid var(--gramlot-border, #d1d7df); background: var(--gramlot-surface-subtle, #f1f3f5); font-size: 10px; }\n.remove { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; flex: none; width: 22px; height: 20px; padding: 3px; border: 0; background: transparent; color: var(--gramlot-text-secondary, #7c8797); opacity: 0; }\n.remove svg { width: 13px; height: 13px; }\n.property-row:hover .remove, .property-row:focus-within .remove { opacity: 1; }\n.remove:hover { color: var(--gramlot-error, #b82323); background: var(--gramlot-error-background, #fbe9e9); }\n:disabled { cursor: default; opacity: .65; }\n.path { flex: none; padding: 5px 9px; border-top: 1px solid var(--gramlot-border, #c9cfd6); background: var(--gramlot-surface-subtle, #f5f7f9); color: var(--gramlot-text-secondary, #697687); font-size: 11px; min-height: 27px; overflow-wrap: anywhere; }\n.error, .edit-status, .breakpoint-status, .breakpoint-line { font-size: 11px; margin: 0; padding: 3px 8px; overflow-wrap: anywhere; }\n.error, .edit-status, .breakpoint-status { color: var(--gramlot-error, #a12121); }\n.breakpoint-line { background: var(--gramlot-warning-background, #fff2ed); color: var(--gramlot-warning, #854127); border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.error:empty, .edit-status:empty, .breakpoint-status:empty, .breakpoint-line:empty { display: none; }\n.breakpoint-dialog { background: var(--gramlot-surface, white); width: min(340px, 90vw); color: var(--gramlot-ink, #38414b); border: 1px solid var(--gramlot-border-control, #bbc3cf); border-radius: 4px; padding: 12px; box-shadow: 0 8px 28px #0003; font: 12px/1.4 system-ui, sans-serif; }\n.breakpoint-dialog::backdrop { background: #0002; }\n.breakpoint-dialog h2 { font-size: 13px; margin: 0 0 10px; overflow-wrap: anywhere; }\n.breakpoint-dialog select, .breakpoint-dialog input { width: 100%; border: 1px solid var(--gramlot-border-control, #bbc3cf); padding: 4px; margin: 0 0 7px; background: var(--gramlot-surface, white); }\n.dialog-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 7px; }\n.dialog-actions button { padding: 3px 10px; border: 1px solid var(--gramlot-border-control, #bbc3cf); border-radius: 3px; background: var(--gramlot-surface-subtle, #f1f3f5); }\n.heading-label { flex: 1; }\n.properties-heading .breakpoint-count { width: auto; padding: 0 5px; margin-right: 5px; font-size: 11px; color: var(--gramlot-error, #b04a35); }\n.breakpoint-entry { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.breakpoint-entry span { flex: 1; overflow-wrap: anywhere; }\n.breakpoint-entry button { background: transparent; border: 0; font-size: 17px; }\n[hidden] { display: none !important; }\n.targetbar { flex: none; height: 28px; padding: 2px 6px; background: var(--gramlot-surface-subtle, #edf2fa); border-bottom: 1px solid var(--gramlot-border, #dadce0); }\n.targetbar select { width: 100%; height: 23px; border: 0; background: transparent; font-size: 11px; }\n.styles-panel { flex: 1; min-height: 0; overflow: auto; background: var(--gramlot-surface, #fff); font-size: 11px; }\n.styles-toolbar { position: sticky; top: 0; z-index: 1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; background: var(--gramlot-surface-subtle, #f1f3f5); border-bottom: 1px solid var(--gramlot-border, #d1d7df); }\n.styles-toolbar span { flex: 1; font-weight: 600; }\n.styles-toolbar button, .styles-toolbar a { padding: 3px 7px; border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 3px; background: var(--gramlot-surface, white); }\n.styles-toolbar a { color: inherit; text-decoration: none; }\n.styles-toolbar a[aria-disabled=true] { cursor: default; opacity: .65; }\n.styles-toolbar a:focus-visible { outline: 1px solid var(--gramlot-focus-ring, #3574cb); outline-offset: -1px; }\n.styles-help, .styles-empty, .styles-status { margin: 0; padding: 7px 9px; color: var(--gramlot-text-secondary, #697687); }\n.styles-status { color: var(--gramlot-error, #a12121); }\n.styles-status:empty { display: none; }\n.styles-group h3 { margin: 0; padding: 6px 9px; font-size: 11px; background: var(--gramlot-surface-subtle, #edf2fa); border-block: 1px solid var(--gramlot-border, #d1d7df); }\n.style-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 25px 23px; align-items: center; gap: 8px; min-width: 0; padding: 3px 9px; border-bottom: 1px solid var(--gramlot-border, #e8ebef); }\n.style-row label { min-width: 0; font: 11px/1.4 ui-monospace, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.style-row input { min-width: 0; width: 100%; height: 23px; padding: 2px 5px; border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 3px; background: var(--gramlot-surface, white); }\n.style-row input[type=color] { width: 25px; padding: 1px; cursor: pointer; }\n.style-row button { grid-column: 4; width: 23px; height: 23px; padding: 0; border: 1px solid var(--gramlot-border-control, #c5cdda); border-radius: 3px; background: var(--gramlot-surface-subtle, #f5f7f9); font-size: 15px; }\n\n:host([embedded]) { display: block; height: 100%; min-height: 0; }\n:host([embedded]) > div { height: 100%; }\n.embedded-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; overflow: hidden; }\n\n.property-value select.enum-value { flex: 1; min-width: 0; max-width: none; width: 100%; border: 0; background: var(--gramlot-surface, white); font: inherit; padding: 1px 5px; }\n\n/* Presentation changes preserve the inspector runtime and selection. */\n:host([hidden]) { display: none; }\n:host([docked]) { display: block; height: 100%; min-height: 0; }\n:host([docked][hidden]) { display: none; }\n:host([docked]) > div { height: 100%; }\n:host([docked]) .targetbar select { min-height: 40px; font-size: 16px; }\n:host([docked]) .property-row { min-height: 36px; font-size: 13px; }\n:host([docked]) .property-row input { min-height: 35px; font-size: 16px; }\n:host([docked]) .remove { opacity: 1; min-height: 35px; width: 32px; }\n\n:host([docked]) { --tree-action-size: 28px; --tree-font-size: 14px; --tree-row-height: 40px; --separator-size: 14px; }\n:host([docked]) .targetbar { height: 44px; }\n:host([docked]) .inspector-tabs { height: 44px; }\n:host([docked]) .properties-heading { height: 40px; font-size: 13px; }\n:host([docked]) .properties-heading button { width: 36px; height: 36px; }\n:host([docked]) .property-value select { height: 35px; font-size: 14px; }\n\n.history-toolbar { flex:none; display:flex; align-items:center; gap:6px; padding:4px 8px; border-bottom:1px solid var(--gramlot-border, #d1d7df); background:var(--gramlot-surface-subtle, #f6f8fb); font:11px/1.4 system-ui,sans-serif; }\n.history-toolbar button { flex:none; padding:3px 6px; border:1px solid var(--gramlot-border-control, #c5cdda); border-radius:3px; background:var(--gramlot-surface, white); cursor:pointer; }\n.history-toolbar button:disabled { opacity:.45; cursor:default; }\n.history-toolbar span { min-width:0; color:var(--gramlot-error, #a12121); overflow-wrap:anywhere; }\n\n.inspector-tabs { flex: none; height: 30px; min-height: 0; }\n";
1082
680
 
1083
681
  // ../tools/gramlot-tools-inspector/src/gramlot-tools-inspector.js
1084
682
  var nextId = 0;
@@ -1086,7 +684,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1086
684
  static observedAttributes = ["docked"];
1087
685
  attributeChangedCallback() {
1088
686
  if (this.#ui && !this.hasAttribute("embedded")) {
1089
- this.#ui.src.source.getNode("main.palette").setAttr({ docked: this.hasAttribute("docked") ? "" : null });
687
+ this.#ui.src.source.getNode("main.window").setAttr({ docked: this.hasAttribute("docked") });
1090
688
  }
1091
689
  }
1092
690
  #target = null;
@@ -1143,7 +741,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1143
741
  this.#ui.data.setItem("breakpointError", "");
1144
742
  this.#ui.data.setItem("selection", null);
1145
743
  this.#ui.data.setItem("busy", false);
1146
- this.#ui.data.setItem("breakpoints", new Bag3());
744
+ this.#ui.data.setItem("breakpoints", new Bag2());
1147
745
  this.#ui.data.setItem("editor.dirty", false);
1148
746
  this.#ui.data.setItem("breakpointDirty", false);
1149
747
  this.#ui.data.setItem("breakpointStatus", "");
@@ -1199,7 +797,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1199
797
  if (!this.#ui) return;
1200
798
  const builder = new GramlotBuilder();
1201
799
  for (const entry of this.#targets) builder.root.option(entry.title, { value: entry.id });
1202
- this.#ui.src.source.getNode("main.palette.targetbar.targets").setValue(this.#ui.src.prepareSource(builder.source));
800
+ this.#ui.src.source.getNode("main.window.frame.center.palette.targetbar.targets").setValue(this.#ui.src.prepareSource(builder.source));
1203
801
  this.#ui.data.setItem("singleTarget", this.#targets.length < 2);
1204
802
  this.#ui.data.setItem("targetId", this.#selectedTarget ?? this.#targets[0]?.id ?? "");
1205
803
  }
@@ -1212,11 +810,11 @@ var GramlotToolsInspector = class extends HTMLElement {
1212
810
  connectedCallback() {
1213
811
  if (this.#ui) return;
1214
812
  const inspector = this;
1215
- const ui = new Gramlot({ document: this.ownerDocument, element: this.#mount, transport: false });
813
+ const ui = new Gramlot({ document: this.ownerDocument, element: this.#mount, transport: false, collections: [layout, tree] });
1216
814
  this.#ui = ui;
1217
815
  class Logic {
1218
- close(node, event) {
1219
- event.stopPropagation();
816
+ close(node, { open }) {
817
+ if (open) return;
1220
818
  inspector.remove();
1221
819
  inspector.dispatchEvent(new inspector.ownerDocument.defaultView.CustomEvent("close"));
1222
820
  }
@@ -1287,10 +885,13 @@ var GramlotToolsInspector = class extends HTMLElement {
1287
885
  ui.data.setItem("editor.dirty", true);
1288
886
  inspector.#applyEdit();
1289
887
  }
1290
- selectRoot(node) {
888
+ selectRoot(node, { tab }) {
889
+ if (ui.data.getItem("tabSync") || tab === ui.data.getItem("tab")) return;
1291
890
  const choose = () => {
1292
- const tab = node.getAttr("data-root");
891
+ ui.data.setItem("tabSync", true);
892
+ ui.data.setItem("requestedTab", tab);
1293
893
  ui.data.setItem("tab", tab);
894
+ ui.data.setItem("tabSync", false);
1294
895
  if (tab !== "styles") {
1295
896
  ui.data.setItem("root", tab);
1296
897
  ui.data.setItem("selection", null);
@@ -1299,8 +900,16 @@ var GramlotToolsInspector = class extends HTMLElement {
1299
900
  inspector.#refresh();
1300
901
  if (tab === "styles") inspector.#loadStyles();
1301
902
  };
1302
- if (ui.data.getItem("editor.dirty")) inspector.#applyEdit(choose);
1303
- else choose();
903
+ if (ui.data.getItem("editor.dirty")) {
904
+ const previous = ui.data.getItem("tab");
905
+ inspector.#applyEdit(choose);
906
+ queueMicrotask(() => {
907
+ if (!inspector.#ui || ui.data.getItem("tab") !== previous) return;
908
+ ui.data.setItem("tabSync", true);
909
+ ui.data.setItem("requestedTab", previous);
910
+ ui.data.setItem("tabSync", false);
911
+ });
912
+ } else choose();
1304
913
  }
1305
914
  refreshStyles() {
1306
915
  inspector.#loadStyles();
@@ -1330,28 +939,51 @@ var GramlotToolsInspector = class extends HTMLElement {
1330
939
  resetStyles() {
1331
940
  inspector.#loadStyles("resetStyles");
1332
941
  }
1333
- selectNode(node, event) {
942
+ selectNode(node, { path, root: root2 }) {
943
+ if (ui.data.getItem("selectionSync") || root2 !== ui.data.getItem("root")) return;
1334
944
  const choose = () => {
1335
- const entry = inspector.#nodes.find((item) => item.node === event.detail.node);
945
+ const entry = inspector.#nodes.find((item) => item.path.join(".") === path);
946
+ ui.data.setItem("selectionSync", true);
947
+ ui.data.setItem(`treeSelection.${root2}`, entry ? path : null);
948
+ ui.data.setItem("selectionSync", false);
1336
949
  ui.data.setItem("selection", entry?.id ?? null);
1337
950
  inspector.#loadEditor(entry);
1338
951
  inspector.#details();
1339
952
  };
1340
953
  if (ui.data.getItem("editor.dirty")) {
1341
- inspector.#trees[ui.data.getItem("root")].selectedPath = inspector.#selected()?.path.join(".") ?? null;
954
+ ui.data.setItem("selectionSync", true);
955
+ ui.data.setItem(`treeSelection.${root2}`, inspector.#selected()?.path.join(".") ?? null);
956
+ ui.data.setItem("selectionSync", false);
1342
957
  inspector.#applyEdit(choose);
1343
958
  } else choose();
1344
959
  }
1345
- sourceAction(node, event) {
1346
- if (event.detail.action === "breakpoint") {
1347
- this.openBreakpoint(node, event);
960
+ actionState(node, { path, action }) {
961
+ const root2 = node.parentNode.getAttr("data-root");
962
+ const breakpoint2 = inspector.#findBreakpoint(root2, path)?.value;
963
+ if (action === "breakpoint") return { hidden: false, icon: breakpoint2 ? breakpoint2.getItem("condition") ? "\u25C9" : "\u25CF" : "\u25CB", title: "Breakpoint" };
964
+ if (action === "insert") return { hidden: root2 !== "source", icon: "+", title: "Add child element" };
965
+ return { hidden: root2 !== "source" || !path.includes("."), icon: "\u2212", title: "Remove branch" };
966
+ }
967
+ treeLabel(node, { item, path }) {
968
+ const breakpoint2 = inspector.#findBreakpoint(node.getAttr("data-root"), path)?.value;
969
+ return { text: item.label + (breakpoint2 ? breakpoint2.getItem("condition") ? " \u25C9" : " \u25CF" : "") };
970
+ }
971
+ treeLabelClass(node, { path }) {
972
+ const breakpoint2 = inspector.#findBreakpoint(node.getAttr("data-root"), path)?.value;
973
+ return !breakpoint2 ? "" : breakpoint2.getItem("condition") ? "inspector-breakpoint-conditional" : "inspector-breakpoint";
974
+ }
975
+ sourceAction(node, { path }) {
976
+ const root2 = node.parentNode.parentNode.getAttr("data-root");
977
+ const action = node.getAttr("rowAction");
978
+ if (action === "breakpoint") {
979
+ this.openBreakpoint(root2, path);
1348
980
  return;
1349
981
  }
1350
982
  const run = () => {
1351
- if (event.detail.action === "insert") inspector.#openInsert(event.detail.path);
1352
- if (event.detail.action === "remove") {
983
+ if (action === "insert") inspector.#openInsert(path);
984
+ if (action === "remove") {
1353
985
  try {
1354
- inspector.#runCommand("remove", inspector.#sourceCommand(event.detail.path));
986
+ inspector.#runCommand("remove", inspector.#sourceCommand(path));
1355
987
  } catch (error) {
1356
988
  ui.data.setItem("status", error.message);
1357
989
  }
@@ -1360,13 +992,19 @@ var GramlotToolsInspector = class extends HTMLElement {
1360
992
  if (ui.data.getItem("editor.dirty")) inspector.#applyEdit(run);
1361
993
  else run();
1362
994
  }
1363
- sourceDrop(node, event) {
995
+ sourceDrag(node, { path }) {
996
+ return path.includes(".");
997
+ }
998
+ sourceDropAllowed(node, { path, source, selfdrop }) {
999
+ return selfdrop && source.itemPath !== path && !path.startsWith(source.itemPath + ".");
1000
+ }
1001
+ sourceDrop(node, { path: destination, source, placement }) {
1364
1002
  const run = () => {
1365
1003
  try {
1366
- const { path, destination, placement } = event.detail;
1004
+ const path = source.itemPath;
1367
1005
  const command = inspector.#sourceCommand(path);
1368
1006
  const target = inspector.#sourceCommand(destination);
1369
- inspector.#runCommand("move", { ...command, destination, placement, targetId: target.nodeId, targetRevision: target.revision });
1007
+ inspector.#runCommand("move", { ...command, destination, placement: destination.includes(".") ? placement : "inside", targetId: target.nodeId, targetRevision: target.revision });
1370
1008
  } catch (error) {
1371
1009
  ui.data.setItem("status", error.message);
1372
1010
  }
@@ -1403,14 +1041,13 @@ var GramlotToolsInspector = class extends HTMLElement {
1403
1041
  this.redo();
1404
1042
  }
1405
1043
  }
1406
- openBreakpoint(node, event) {
1407
- if (event.detail.action !== "breakpoint") return;
1044
+ openBreakpoint(root2, path) {
1408
1045
  ui.data.setItem("breakpointDirty", false);
1409
1046
  ui.data.setItem("breakpointStatus", "");
1410
- inspector.#breakpointTarget = { root: node.getAttr("data-root"), path: event.detail.path };
1047
+ inspector.#breakpointTarget = { root: root2, path };
1411
1048
  inspector.#loadBreakpoint();
1412
- if (!inspector.#findBreakpoint(inspector.#breakpointTarget.root, event.detail.path)) ui.data.setItem("editor.mode", "debugger");
1413
- ui.data.setItem("breakpointWhere", `${inspector.#breakpointTarget.root}: ${event.detail.path}`);
1049
+ if (!inspector.#findBreakpoint(root2, path)) ui.data.setItem("editor.mode", "debugger");
1050
+ ui.data.setItem("breakpointWhere", `${root2}: ${path}`);
1414
1051
  inspector.#dialog().showModal();
1415
1052
  }
1416
1053
  closeBreakpoint() {
@@ -1452,8 +1089,11 @@ var GramlotToolsInspector = class extends HTMLElement {
1452
1089
  }
1453
1090
  ui.src.logicRegistry.register(Logic, { group: "inspector", resource: "gramlot-tools-inspector" });
1454
1091
  for (const [key, value] of Object.entries({
1092
+ inspectorOpen: true,
1455
1093
  root: "data",
1456
1094
  tab: "data",
1095
+ requestedTab: "data",
1096
+ tabSync: false,
1457
1097
  stylesActive: false,
1458
1098
  treeActive: true,
1459
1099
  dataActive: true,
@@ -1461,6 +1101,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1461
1101
  targetId: "",
1462
1102
  singleTarget: true,
1463
1103
  busy: false,
1104
+ selectionSync: false,
1464
1105
  selection: null,
1465
1106
  path: "",
1466
1107
  error: "",
@@ -1472,44 +1113,79 @@ var GramlotToolsInspector = class extends HTMLElement {
1472
1113
  breakpointCount: "\u25CF 0",
1473
1114
  noBreakpoints: true
1474
1115
  })) ui.data.setItem(key, value);
1475
- ui.data.setItem("history", new Bag3({ noUndo: true, noRedo: true, undo: "", redo: "" }));
1476
- ui.data.setItem("insert", new Bag3({ kind: "html", tag: "", html: true, component: false, status: "" }));
1477
- ui.data.setItem("editor", new Bag3({ dirty: false, disabled: true, status: "", mode: "", condition: "" }));
1478
- ui.data.setItem("breakpoints", new Bag3());
1116
+ ui.data.setItem("history", new Bag2({ noUndo: true, noRedo: true, undo: "", redo: "" }));
1117
+ ui.data.setItem("insert", new Bag2({ kind: "html", tag: "", html: true, component: false, status: "" }));
1118
+ ui.data.setItem("editor", new Bag2({ dirty: false, disabled: true, status: "", mode: "", condition: "" }));
1119
+ ui.data.setItem("breakpoints", new Bag2());
1120
+ ui.data.setItem("emptyTree", new Bag2());
1121
+ ui.data.setItem("treeSelection", new Bag2({ data: null, source: null }));
1479
1122
  ui.data.setItem("breakpointDirty", false);
1480
- ui.data.setItem("styles", new Bag3({ status: "", busy: false, noChanges: true, noDownload: true, downloadUrl: null, rows: new Bag3() }));
1481
- const builder = new GramlotBuilder();
1123
+ ui.data.setItem("styles", new Bag2({ status: "", busy: false, noChanges: true, noDownload: true, downloadUrl: null, rows: new Bag2() }));
1124
+ const builder = new GramlotBuilder(null, { collections: [layout, tree] });
1482
1125
  const root = builder.root;
1483
1126
  root.style(gramlot_tools_inspector_default);
1484
- const palette = this.hasAttribute("embedded") ? root.section({ node_label: "palette", class: "embedded-panel", "aria-label": "Gramlot inspector", connect_onkeydown: "inspector.historyKey" }) : root.webcomponent({ code: "gramlot-poc-palette", node_label: "palette", title: "Gramlot inspector", docked: this.hasAttribute("docked") ? "" : null, connect_onclose: "inspector.close", connect_onkeydown: "inspector.historyKey" });
1127
+ const window = root.floatingPane({
1128
+ node_label: "window",
1129
+ title: "Gramlot inspector",
1130
+ open: "^inspectorOpen",
1131
+ docked: this.hasAttribute("embedded") || this.hasAttribute("docked"),
1132
+ width: "480px",
1133
+ height: "620px",
1134
+ left: "16px",
1135
+ top: "16px",
1136
+ minWidth: "min(280px, calc(100vw - 16px))",
1137
+ minHeight: "min(200px, calc(100dvh - 16px))"
1138
+ });
1139
+ const palette = window.frame.center.section({ node_label: "palette", class: "embedded-panel", "aria-label": "Gramlot inspector", connect_onkeydown: "inspector.historyKey" });
1140
+ root.dataController({ func: "inspector.close", open: "^inspectorOpen" });
1485
1141
  const targetbar = palette.div({ node_label: "targetbar", class: "targetbar", hidden: "^singleTarget" });
1486
1142
  targetbar.select({ node_label: "targets", value: "^targetId", disabled: "^busy", "aria-label": "Inspected page", connect_onchange: "inspector.selectTarget" });
1487
- const toolbar = palette.webcomponent({ code: "gramlot-poc-tabs", node_label: "tabs", role: "tablist", "aria-label": "Inspected root" });
1488
- for (const name of ["Data", "Source", "Styles"]) toolbar.html_button(name, {
1489
- node_label: name.toLowerCase(),
1490
- type: "button",
1491
- role: "tab",
1492
- "data-root": name.toLowerCase(),
1493
- "aria-selected": "false",
1494
- connect_onclick: "inspector.selectRoot"
1495
- });
1143
+ const toolbar = palette.tabContainer({ node_label: "tabs", class: "inspector-tabs", tabMode: "underline", selectedPage: "^requestedTab" });
1144
+ for (const name of ["Data", "Source", "Styles"]) toolbar.div({ node_label: name.toLowerCase(), pageName: name.toLowerCase(), title: name });
1145
+ palette.dataController({ func: "inspector.selectRoot", tab: "^requestedTab" });
1496
1146
  const historybar = palette.div({ class: "history-toolbar", hidden: "^stylesActive" });
1497
1147
  historybar.html_button("\u21B6 Undo", { type: "button", disabled: "^history.noUndo", title: "^history.undo", connect_onclick: "inspector.undo" });
1498
1148
  historybar.html_button("\u21B7 Redo", { type: "button", disabled: "^history.noRedo", title: "^history.redo", connect_onclick: "inspector.redo" });
1499
1149
  historybar.span("^status", { role: "status" });
1500
1150
  palette.p("^error", { role: "alert", class: "error" });
1501
- const content = palette.webcomponent({ code: "gramlot-poc-splitter", node_label: "content", hidden: "^stylesActive" });
1502
- const trees = content.div({ node_label: "tree", slot: "top", class: "tree" });
1503
- for (const name of ["data", "source"]) trees.webcomponent({
1504
- code: "gramlot-poc-tree",
1505
- node_label: name,
1506
- "data-root": name,
1507
- hidden: name === "data" ? "^sourceActive" : "^dataActive",
1508
- connect_onchange: "inspector.selectNode",
1509
- "connect_ontree-action": "inspector.sourceAction",
1510
- "connect_ontree-drop": "inspector.sourceDrop"
1151
+ const content = palette.borderContainer({ node_label: "content", hidden: "^stylesActive", class: "inspector-content" });
1152
+ const trees = content.contentPane({
1153
+ node_label: "tree",
1154
+ region: "top",
1155
+ height: "45%",
1156
+ minSize: 60,
1157
+ splitter: true,
1158
+ splitter_aria_label: "Resize tree and properties",
1159
+ class: "tree"
1511
1160
  });
1512
- const properties = content.section({ node_label: "properties", slot: "bottom", class: "properties", "aria-label": "Selected node properties" });
1161
+ for (const name of ["data", "source"]) {
1162
+ const sourceTree = trees.tree({
1163
+ node_label: name,
1164
+ "data-root": name,
1165
+ storepath: "emptyTree",
1166
+ hideValues: true,
1167
+ resolveLazy: false,
1168
+ getLabel: "inspector.treeLabel",
1169
+ getLabelClass: "inspector.treeLabelClass",
1170
+ labelState: "^breakpoints",
1171
+ selectedPath: `^treeSelection.${name}`,
1172
+ hidden: name === "data" ? "^sourceActive" : "^dataActive",
1173
+ ...name === "source" ? {
1174
+ draggable: true,
1175
+ dropTarget: true,
1176
+ dropTypes: "treenode",
1177
+ effectAllowed: "move",
1178
+ dropEffect: "move",
1179
+ onDrag: "inspector.sourceDrag",
1180
+ dropTargetCb: "inspector.sourceDropAllowed",
1181
+ onDrop: "inspector.sourceDrop"
1182
+ } : {}
1183
+ });
1184
+ const actions2 = sourceTree.rowActions({ position: "end", actionState: "inspector.actionState", state: "^breakpoints" });
1185
+ for (const action of ["breakpoint", "insert", "remove"]) actions2.button({ rowAction: action, action: "inspector.sourceAction" });
1186
+ trees.dataController({ func: "inspector.selectNode", root: name, path: `^treeSelection.${name}` });
1187
+ }
1188
+ const properties = content.contentPane({ node_label: "properties", region: "center", minSize: 60, class: "properties", "aria-label": "Selected node properties" });
1513
1189
  const heading = properties.div({ class: "properties-heading" });
1514
1190
  heading.span("Properties", { class: "heading-label" });
1515
1191
  heading.html_button("^breakpointCount", {
@@ -1573,13 +1249,13 @@ var GramlotToolsInspector = class extends HTMLElement {
1573
1249
  insertActions.html_button("Cancel", { type: "button", connect_onclick: "inspector.closeInsert" });
1574
1250
  insertActions.html_button("Add", { type: "button", disabled: "^busy", connect_onclick: "inspector.addElement" });
1575
1251
  ui.src.startSource(builder.source);
1576
- for (const name of ["data", "source"]) this.#trees[name] = ui.dom.getDomNode(ui.src.source.getNode(`main.palette.content.tree.${name}`));
1252
+ for (const name of ["data", "source"]) this.#trees[name] = ui.dom.getDomNode(ui.src.source.getNode(`main.window.frame.center.palette.content.tree.${name}`));
1577
1253
  this.#renderTargets();
1578
1254
  this.#subscribe();
1579
1255
  this.#refresh();
1580
1256
  }
1581
1257
  #dialog(name = "breakpoint") {
1582
- return this.#ui.dom.getDomNode(this.#ui.src.source.getNode(`main.palette.${name}`));
1258
+ return this.#ui.dom.getDomNode(this.#ui.src.source.getNode(`main.window.frame.center.palette.${name}`));
1583
1259
  }
1584
1260
  disconnectedCallback() {
1585
1261
  this.#unsubscribe();
@@ -1646,12 +1322,9 @@ var GramlotToolsInspector = class extends HTMLElement {
1646
1322
  const tab = ui.data.getItem("tab");
1647
1323
  ui.data.setItem("stylesActive", tab === "styles");
1648
1324
  ui.data.setItem("treeActive", tab !== "styles");
1649
- for (const name of ["data", "source", "styles"]) {
1650
- ui.src.source.getNode(`main.palette.tabs.${name}`).setAttr({ "aria-selected": String(tab === name) });
1651
- }
1652
1325
  if (this.#connection) {
1653
- const configurations = new Bag3();
1654
- for (const [index, record] of this.#connection.breakpoints.entries()) configurations.setItem(`b${index}`, new Bag3(record));
1326
+ const configurations = new Bag2();
1327
+ for (const [index, record] of this.#connection.breakpoints.entries()) configurations.setItem(`b${index}`, new Bag2(record));
1655
1328
  ui.data.setItem("breakpoints", configurations);
1656
1329
  ui.data.setItem("breakpointError", this.#connection.breakpoints.filter((record) => record.error).map((record) => `${record.root}: ${record.path}: ${record.error}`).join("; "));
1657
1330
  }
@@ -1666,24 +1339,13 @@ var GramlotToolsInspector = class extends HTMLElement {
1666
1339
  ui.data.setItem("dataActive", root === "data");
1667
1340
  ui.data.setItem("sourceActive", root === "source");
1668
1341
  for (const name of ["data", "source"]) {
1669
- const tree = this.#trees[name];
1670
- tree.storeBag = this.#connection || this.#target ? this.#targetBag(name) : null;
1671
- const breakpoints = ui.data.getItem("breakpoints").getNodes().filter((node) => node.value.getItem("root") === name);
1672
- tree.dragEnabled = name === "source";
1673
- tree.fixedPaths = tree.storeBag?.getNodes().map((node) => node.label) ?? [];
1674
- tree.rowActions = [{
1675
- id: "breakpoint",
1676
- icon: "\u25CB",
1677
- label: "Breakpoint",
1678
- activePaths: breakpoints.map((node) => node.value.getItem("path")),
1679
- conditionalPaths: breakpoints.filter((node) => node.value.getItem("condition").trim()).map((node) => node.value.getItem("path"))
1680
- }, ...name === "source" ? [
1681
- { id: "insert", icon: "+", label: "Add child element", position: "end" },
1682
- { id: "remove", icon: "\u2212", label: "Remove branch", position: "end", hiddenPaths: tree.fixedPaths }
1683
- ] : []];
1342
+ const sourceTree = ui.src.source.getNode(`main.window.frame.center.palette.content.tree.${name}`);
1343
+ sourceTree.setTreeStore(this.#connection || this.#target ? this.#targetBag(name) : null);
1684
1344
  }
1685
1345
  if (this.#target || this.#connection) this.#index(this.#bag(), []);
1686
- this.#trees[root].selectedPath = this.#selected()?.path.join(".") ?? null;
1346
+ ui.data.setItem("selectionSync", true);
1347
+ ui.data.setItem(`treeSelection.${root}`, this.#selected()?.path.join(".") ?? null);
1348
+ ui.data.setItem("selectionSync", false);
1687
1349
  ui.data.setItem("error", this.#connection ? this.#connection.error || (this.#state() === "disposed" ? "Inspected page disconnected." : this.#state() === "connecting" ? "Connecting\u2026" : "") : this.#target ? "" : "No Gramlot instance selected.");
1688
1350
  this.#details();
1689
1351
  } catch (error) {
@@ -1748,8 +1410,8 @@ ${declarations}
1748
1410
  const builder = rebuild ? new GramlotBuilder() : null;
1749
1411
  const groups = /* @__PURE__ */ new Map();
1750
1412
  if (rebuild) {
1751
- ui.src.source.getNode("main.palette.styles.rows").setValue(ui.src.prepareSource(new GramlotBuilder().source));
1752
- ui.data.setItem("styles.rows", new Bag3());
1413
+ ui.src.source.getNode("main.window.frame.center.palette.styles.rows").setValue(ui.src.prepareSource(new GramlotBuilder().source));
1414
+ ui.data.setItem("styles.rows", new Bag2());
1753
1415
  }
1754
1416
  for (const [index, record] of rows.entries()) {
1755
1417
  const id = `v${index}`, path = `styles.rows.${id}`;
@@ -1770,7 +1432,7 @@ ${declarations}
1770
1432
  delete fields.dirty;
1771
1433
  }
1772
1434
  }
1773
- if (rebuild) ui.data.setItem(path, new Bag3(fields));
1435
+ if (rebuild) ui.data.setItem(path, new Bag2(fields));
1774
1436
  else for (const [key, value] of Object.entries(fields)) ui.data.setItem(`${path}.${key}`, value);
1775
1437
  if (!rebuild) continue;
1776
1438
  const group = record.name.includes("-font-") ? "Typography" : record.name.includes("-space-") ? "Spacing" : /-(radius|page-width)/.test(record.name) ? "Dimensions" : record.name.endsWith("-shadow") ? "Effects" : color ? "Colors" : "Other";
@@ -1812,9 +1474,9 @@ ${declarations}
1812
1474
  connect_onclick: "inspector.resetStyle"
1813
1475
  });
1814
1476
  }
1815
- if (rebuild) ui.src.source.getNode("main.palette.styles.rows").setValue(ui.src.prepareSource(builder.source));
1477
+ if (rebuild) ui.src.source.getNode("main.window.frame.center.palette.styles.rows").setValue(ui.src.prepareSource(builder.source));
1816
1478
  ui.data.setItem("styles.noChanges", !rows.some((row) => row.override));
1817
- ui.src.source.getNode("main.palette.styles.empty").setAttr({ hidden: rows.length !== 0 });
1479
+ ui.src.source.getNode("main.window.frame.center.palette.styles.empty").setAttr({ hidden: rows.length !== 0 });
1818
1480
  }
1819
1481
  #index(bag, labels) {
1820
1482
  for (const node of bag.getNodes()) {
@@ -1822,7 +1484,7 @@ ${declarations}
1822
1484
  if (!this.#nodeIds.has(node)) this.#nodeIds.set(node, String(++this.#nextNodeId));
1823
1485
  this.#nodes.push({ id: this.#nodeIds.get(node), node, path });
1824
1486
  const value = node.getValue(true);
1825
- if (!node.resolver && value instanceof Bag3) this.#index(value, path);
1487
+ if (!node.resolver && value instanceof Bag2) this.#index(value, path);
1826
1488
  }
1827
1489
  }
1828
1490
  #details() {
@@ -1854,7 +1516,7 @@ ${declarations}
1854
1516
  const type = scalar === "null" ? "string" : scalar;
1855
1517
  let text = value === null ? "" : type === "boolean" ? value : type ? scalarText(value, type) : this.#format(value);
1856
1518
  if (type === "datetime") text = text.replace(/Z$/, "");
1857
- return new Bag3({
1519
+ return new Bag2({
1858
1520
  name,
1859
1521
  initialName: name,
1860
1522
  initialText: text,
@@ -1878,9 +1540,9 @@ ${declarations}
1878
1540
  resolver: entry.node.resolver,
1879
1541
  revision: this.#connection?.nodeInfo(entry.node)?.revision
1880
1542
  } : null;
1881
- const rows = new Bag3();
1543
+ const rows = new Bag2();
1882
1544
  if (entry) {
1883
- if (!(this.#snapshot.value instanceof Bag3)) rows.setItem(`r${++this.#nextRow}`, this.#row("value", this.#snapshot.value, true, !!entry.node.resolver || !!this.#connection?.nodeInfo(entry.node)?.readonly));
1545
+ if (!(this.#snapshot.value instanceof Bag2)) rows.setItem(`r${++this.#nextRow}`, this.#row("value", this.#snapshot.value, true, !!entry.node.resolver || !!this.#connection?.nodeInfo(entry.node)?.readonly));
1884
1546
  for (const [name, value] of Object.entries(this.#snapshot.attrs)) {
1885
1547
  if (name !== "_meta") rows.setItem(`r${++this.#nextRow}`, this.#row(name, value, false, !!this.#connection?.nodeInfo(entry.node)?.readonlyAttrs.has(name)));
1886
1548
  }
@@ -1962,7 +1624,7 @@ ${declarations}
1962
1624
  }).path({ d: "M3 6h18M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2M5 6l1 14a1 1 0 0 0 1 1h10a1 1 0 0 0 1-1l1-14M10 10v7M14 10v7" });
1963
1625
  }
1964
1626
  }
1965
- this.#ui.src.source.getNode("main.palette.content.properties.editor.rows").setValue(this.#ui.src.prepareSource(builder.source));
1627
+ this.#ui.src.source.getNode("main.window.frame.center.palette.content.properties.editor.rows").setValue(this.#ui.src.prepareSource(builder.source));
1966
1628
  }
1967
1629
  #addAttribute() {
1968
1630
  if (!this.#snapshot) return;
@@ -2079,7 +1741,7 @@ ${declarations}
2079
1741
  this.#ui.data.setItem("insert.status", "");
2080
1742
  this.#insertChoices();
2081
1743
  const builder = new GramlotBuilder();
2082
- this.#ui.data.setItem("insert.attrs", new Bag3());
1744
+ this.#ui.data.setItem("insert.attrs", new Bag2());
2083
1745
  for (const { name, choices } of this.#catalog[0]?.fields ?? []) {
2084
1746
  builder.root.html_label(name);
2085
1747
  const field = builder.root.select({ value: `^insert.attrs.${name}`, "aria-label": name });
@@ -2087,7 +1749,7 @@ ${declarations}
2087
1749
  for (const value of choices) field.option(value, { value });
2088
1750
  this.#ui.data.setItem(`insert.attrs.${name}`, "");
2089
1751
  }
2090
- this.#ui.src.source.getNode("main.palette.insert.fields").setValue(this.#ui.src.prepareSource(builder.source));
1752
+ this.#ui.src.source.getNode("main.window.frame.center.palette.insert.fields").setValue(this.#ui.src.prepareSource(builder.source));
2091
1753
  this.#dialog("insert").showModal();
2092
1754
  } catch (error) {
2093
1755
  if (this.#ui && generation === this.#generation) this.#ui.data.setItem("status", error.message);
@@ -2100,7 +1762,7 @@ ${declarations}
2100
1762
  const choices = this.#catalog.filter((item) => item.kind === (html ? "html" : "component"));
2101
1763
  const builder = new GramlotBuilder();
2102
1764
  for (const item of choices) builder.root.option(item.tag, { value: item.tag });
2103
- this.#ui.src.source.getNode(`main.palette.insert.${html ? "tags" : "components"}`).setValue(this.#ui.src.prepareSource(builder.source));
1765
+ this.#ui.src.source.getNode(`main.window.frame.center.palette.insert.${html ? "tags" : "components"}`).setValue(this.#ui.src.prepareSource(builder.source));
2104
1766
  this.#ui.data.setItem("insert.tag", html ? "" : choices[0]?.tag ?? "");
2105
1767
  }
2106
1768
  async #runCommand(type, command = {}) {
@@ -2128,11 +1790,13 @@ ${declarations}
2128
1790
  this.#refresh();
2129
1791
  if (selection) {
2130
1792
  ui.data.setItem("root", "source");
1793
+ ui.data.setItem("tabSync", true);
2131
1794
  ui.data.setItem("tab", "source");
1795
+ ui.data.setItem("requestedTab", "source");
1796
+ ui.data.setItem("tabSync", false);
2132
1797
  this.#refresh();
2133
1798
  const entry = this.#nodes.find((item) => item.path.join(".") === selection);
2134
1799
  ui.data.setItem("selection", entry?.id ?? null);
2135
- this.#trees.source.revealPath(selection);
2136
1800
  this.#refresh();
2137
1801
  }
2138
1802
  } catch (error) {
@@ -2202,7 +1866,7 @@ ${declarations}
2202
1866
  }
2203
1867
  if (mode) {
2204
1868
  const id = `b${++this.#nextBreakpoint}`;
2205
- ui.data.getItem("breakpoints").setItem(id, new Bag3({ root, path, mode, condition, hits: 0 }));
1869
+ ui.data.getItem("breakpoints").setItem(id, new Bag2({ root, path, mode, condition, hits: 0 }));
2206
1870
  if (test) this.#breakpointTests.set(id, test);
2207
1871
  }
2208
1872
  ui.data.setItem("breakpointDirty", false);
@@ -2229,7 +1893,7 @@ ${declarations}
2229
1893
  connect_onclick: "inspector.removeBreakpoint"
2230
1894
  });
2231
1895
  }
2232
- this.#ui.src.source.getNode("main.palette.breakpoints.entries").setValue(this.#ui.src.prepareSource(builder.source));
1896
+ this.#ui.src.source.getNode("main.window.frame.center.palette.breakpoints.entries").setValue(this.#ui.src.prepareSource(builder.source));
2233
1897
  }
2234
1898
  #checkBreakpoints(root, event) {
2235
1899
  if (!this.#ui) return;
@@ -2270,7 +1934,7 @@ ${declarations}
2270
1934
  } else this.ownerDocument.defaultView.console.log("** Gramlot breakpoint **", root, fields);
2271
1935
  }
2272
1936
  #format(value) {
2273
- if (value instanceof Bag3) return `${value.constructor.name} (${value.getNodes().length} nodes)`;
1937
+ if (value instanceof Bag2) return `${value.constructor.name} (${value.getNodes().length} nodes)`;
2274
1938
  if (typeof value === "string") return value;
2275
1939
  if (value === void 0) return "undefined";
2276
1940
  if (typeof value === "number" || typeof value === "boolean" || value === null) return String(value);