@gramlot/gramlot 0.2.19 → 0.3.0

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 (66) hide show
  1. package/dist/gramlot.js +2145 -224
  2. package/dist/gramlot.min.js +363 -21
  3. package/package.json +6 -3
  4. package/src/binding/ask-dialog.js +2 -2
  5. package/src/binding/inline.js +11 -12
  6. package/src/binding/installation.js +4 -1
  7. package/src/binding/pointer.js +63 -0
  8. package/src/binding/providers.js +8 -4
  9. package/src/binding/runtime.js +11 -5
  10. package/src/bootstrap.d.ts +2 -0
  11. package/src/bootstrap.js +9 -2
  12. package/src/builder/gramlot-builder.js +24 -3
  13. package/src/builder/source.js +33 -9
  14. package/src/components/bases.js +182 -0
  15. package/src/components/buttons.js +254 -0
  16. package/src/components/choice-editor.js +221 -0
  17. package/src/components/choices.js +13 -0
  18. package/src/components/date-calendar.js +139 -0
  19. package/src/components/field-state.js +166 -0
  20. package/src/components/formlet-labels.js +80 -0
  21. package/src/components/index.js +5 -0
  22. package/src/components/inputs.js +196 -0
  23. package/src/components/labelbox.js +74 -0
  24. package/src/components/layout.js +190 -0
  25. package/src/components/parameters.js +6 -0
  26. package/src/components/popup.js +22 -0
  27. package/src/components/registry.js +83 -0
  28. package/src/components/typed-editor.js +260 -0
  29. package/src/components/validation.js +138 -0
  30. package/src/date-parser/civil.js +61 -0
  31. package/src/date-parser/index.d.ts +18 -0
  32. package/src/date-parser/index.js +196 -0
  33. package/src/date-parser/locales.js +257 -0
  34. package/src/format.js +128 -0
  35. package/src/gramlot.d.ts +25 -0
  36. package/src/gramlot.js +15 -1
  37. package/src/handlers/dom-handler.d.ts +1 -0
  38. package/src/handlers/dom-handler.js +7 -0
  39. package/src/index-page-runtime.js +78 -30
  40. package/src/index-page-styles.js +2 -2
  41. package/src/index-theme.js +1 -1
  42. package/src/index.d.ts +4 -1
  43. package/src/index.js +2 -0
  44. package/src/renderer/attributes.js +25 -50
  45. package/src/renderer/gramlot-html-renderer.js +4 -3
  46. package/src/renderer/gramlot-renderer.js +63 -3
  47. package/src/server/gramlot-server.d.ts +5 -0
  48. package/src/server/gramlot-server.js +14 -5
  49. package/src/server/index-page.d.ts +1 -0
  50. package/src/server/index-page.js +8 -3
  51. package/src/server/page-base.js +3 -0
  52. package/src/server/page.d.ts +3 -0
  53. package/src/server/resources.d.ts +2 -0
  54. package/src/view/button.js +17 -13
  55. package/src/view/controls.js +152 -4
  56. package/src/view/html.js +18 -0
  57. package/themes/gramlot-base/README.md +6 -0
  58. package/themes/gramlot-base/theme.css +34 -6
  59. package/themes/gramlot-compact/README.md +6 -0
  60. package/themes/gramlot-compact/theme.css +8 -4
  61. package/themes/joanna/README.md +23 -0
  62. package/themes/joanna/theme.css +89 -0
  63. package/themes/mimi/README.md +23 -0
  64. package/themes/mimi/theme.css +89 -0
  65. package/tools/gramlot-tools-inspector.js +42 -18
  66. package/tools/inspector-agent.js +8 -4
@@ -49,6 +49,9 @@ function parseScalar(type, text) {
49
49
  }
50
50
  throw new Error(`Invalid ${type} value: ${text || "(empty)"}`);
51
51
  }
52
+ function readParameterEnums(node) {
53
+ return Object.fromEntries(Object.entries(node._getMeta("gramlot_component")?.parameters ?? {}).filter(([, spec]) => spec.enum).map(([name, spec]) => [name, spec.enum]));
54
+ }
52
55
 
53
56
  // ../tools/gramlot-tools-inspector/src/inspector-styles.js
54
57
  var InspectorStyles = class {
@@ -141,7 +144,7 @@ function attachInspectorAgent(gramlot, port) {
141
144
  if (!identities.has(node)) identities.set(node, ++nextNode);
142
145
  return identities.get(node);
143
146
  };
144
- const describe = (store, ancestors = /* @__PURE__ */ new Set()) => {
147
+ const describe = (store, root, ancestors = /* @__PURE__ */ new Set()) => {
145
148
  if (ancestors.has(store)) throw new Error("Inspector snapshots require an acyclic Bag");
146
149
  const next = /* @__PURE__ */ new Set([...ancestors, store]);
147
150
  return store.getNodes().map((node) => {
@@ -152,15 +155,16 @@ function attachInspectorAgent(gramlot, port) {
152
155
  label: node.label,
153
156
  revision: versions.get(node) ?? 0,
154
157
  value: branch ? null : cell(value),
155
- children: branch ? describe(value, next) : null,
158
+ children: branch ? describe(value, root, next) : null,
156
159
  readonly: !!node.resolver,
160
+ parameterEnums: root === "source" ? readParameterEnums(node) : {},
157
161
  attrs: Object.entries(node.getAttr()).filter(([name]) => name !== "_meta").map(([name, value2]) => [name, cell(value2)])
158
162
  };
159
163
  });
160
164
  };
161
165
  const snapshot = () => ({
162
- data: describe(bag("data")),
163
- source: describe(bag("source")),
166
+ data: describe(bag("data"), "data"),
167
+ source: describe(bag("source"), "source"),
164
168
  breakpoints: [...breakpoints.values()].map(({ test, ...record }) => record)
165
169
  });
166
170
  const send = (data) => {
@@ -382,6 +386,7 @@ var InspectorConnection = class {
382
386
  id: row.id,
383
387
  revision: row.revision,
384
388
  branch,
389
+ parameterEnums: row.parameterEnums,
385
390
  readonly: row.readonly || !!row.value?.readonly,
386
391
  readonlyAttrs: new Set(row.attrs.filter(([, descriptor]) => descriptor.readonly).map(([name]) => name)),
387
392
  valueWire: JSON.stringify(row.value),
@@ -413,7 +418,7 @@ var InspectorConnection = class {
413
418
  };
414
419
 
415
420
  // ../tools/gramlot-tools-inspector/src/gramlot-tools-inspector.css
416
- var gramlot_tools_inspector_default = ":host { all: initial; color-scheme: light; font: 12px/1.4 system-ui, sans-serif; color: #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 #3574cb; outline-offset: -1px; }\n.tree { padding: 7px 3px; }\n.properties { background: white; }\n.properties-heading { font-size: 11px; display: flex; align-items: center; justify-content: space-between; height: 29px; padding: 0 8px; background: #f1f3f5; color: #6d7989; border-bottom: 1px solid #d1d7df; }\n.properties-heading button { background: white; border: 1px solid #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 #d1d7df; font-size: 11px; }\n.property-name { display: flex; align-items: center; justify-content: flex-end; background: #888; color: white; font-weight: 700; padding: 1px 6px; border-right: 1px solid #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: white; 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 #d1d7df; background: #f1f3f5; font-size: 10px; }\n.remove { margin-left: auto; flex: none; width: 22px; height: 20px; padding: 3px; border: 0; background: transparent; color: #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: #b82323; background: #fbe9e9; }\n:disabled { cursor: default; opacity: .65; }\n.path { flex: none; padding: 5px 9px; border-top: 1px solid #c9cfd6; background: #f5f7f9; color: #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: #a12121; }\n.breakpoint-line { background: #fff2ed; color: #854127; border-bottom: 1px solid #d1d7df; }\n.error:empty, .edit-status:empty, .breakpoint-status:empty, .breakpoint-line:empty { display: none; }\n.breakpoint-dialog { width: min(340px, 90vw); color: #38414b; border: 1px solid #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 #bbc3cf; padding: 4px; margin: 0 0 7px; background: 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 #bbc3cf; border-radius: 3px; background: #f1f3f5; }\n.heading-label { flex: 1; }\n.properties-heading .breakpoint-count { width: auto; padding: 0 5px; margin-right: 5px; font-size: 11px; color: #b04a35; }\n.breakpoint-entry { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid #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: #edf2fa; border-bottom: 1px solid #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: #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: #f1f3f5; border-bottom: 1px solid #d1d7df; }\n.styles-toolbar span { flex: 1; font-weight: 600; }\n.styles-toolbar button, .styles-toolbar a { padding: 3px 7px; border: 1px solid #c5cdda; border-radius: 3px; background: 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 #3574cb; outline-offset: -1px; }\n.styles-help, .styles-empty, .styles-status { margin: 0; padding: 7px 9px; color: #697687; }\n.styles-status { color: #a12121; }\n.styles-status:empty { display: none; }\n.styles-group h3 { margin: 0; padding: 6px 9px; font-size: 11px; background: #edf2fa; border-block: 1px solid #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 #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 #c5cdda; border-radius: 3px; background: 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 #c5cdda; border-radius: 3px; background: #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";
421
+ var gramlot_tools_inspector_default = ":host { all: initial; color-scheme: light; font: 12px/1.4 system-ui, sans-serif; color: #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 #3574cb; outline-offset: -1px; }\n.tree { padding: 7px 3px; }\n.properties { background: white; }\n.properties-heading { font-size: 11px; display: flex; align-items: center; justify-content: space-between; height: 29px; padding: 0 8px; background: #f1f3f5; color: #6d7989; border-bottom: 1px solid #d1d7df; }\n.properties-heading button { background: white; border: 1px solid #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 #d1d7df; font-size: 11px; }\n.property-name { display: flex; align-items: center; justify-content: flex-end; background: #888; color: white; font-weight: 700; padding: 1px 6px; border-right: 1px solid #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: white; 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 #d1d7df; background: #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: #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: #b82323; background: #fbe9e9; }\n:disabled { cursor: default; opacity: .65; }\n.path { flex: none; padding: 5px 9px; border-top: 1px solid #c9cfd6; background: #f5f7f9; color: #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: #a12121; }\n.breakpoint-line { background: #fff2ed; color: #854127; border-bottom: 1px solid #d1d7df; }\n.error:empty, .edit-status:empty, .breakpoint-status:empty, .breakpoint-line:empty { display: none; }\n.breakpoint-dialog { width: min(340px, 90vw); color: #38414b; border: 1px solid #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 #bbc3cf; padding: 4px; margin: 0 0 7px; background: 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 #bbc3cf; border-radius: 3px; background: #f1f3f5; }\n.heading-label { flex: 1; }\n.properties-heading .breakpoint-count { width: auto; padding: 0 5px; margin-right: 5px; font-size: 11px; color: #b04a35; }\n.breakpoint-entry { display: flex; align-items: center; gap: 6px; padding: 4px 0; border-bottom: 1px solid #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: #edf2fa; border-bottom: 1px solid #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: #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: #f1f3f5; border-bottom: 1px solid #d1d7df; }\n.styles-toolbar span { flex: 1; font-weight: 600; }\n.styles-toolbar button, .styles-toolbar a { padding: 3px 7px; border: 1px solid #c5cdda; border-radius: 3px; background: 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 #3574cb; outline-offset: -1px; }\n.styles-help, .styles-empty, .styles-status { margin: 0; padding: 7px 9px; color: #697687; }\n.styles-status { color: #a12121; }\n.styles-status:empty { display: none; }\n.styles-group h3 { margin: 0; padding: 6px 9px; font-size: 11px; background: #edf2fa; border-block: 1px solid #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 #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 #c5cdda; border-radius: 3px; background: 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 #c5cdda; border-radius: 3px; background: #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: white; font: inherit; padding: 1px 5px; }\n";
417
422
 
418
423
  // ../tools/poc/gramlot-poc-tree.js
419
424
  import { Bag as Bag2 } from "@gramlot/gramlot";
@@ -878,6 +883,10 @@ var GramlotToolsInspector = class extends HTMLElement {
878
883
  ui.data.setItem("editor.dirty", true);
879
884
  ui.data.setItem("editor.status", "Unsaved changes");
880
885
  }
886
+ enumChanged(node) {
887
+ this.editChanged(node);
888
+ inspector.#applyEdit();
889
+ }
881
890
  typeChanged(node) {
882
891
  const row = ui.data.getItem(`editor.rows.${node.getAttr("data-row")}`);
883
892
  row.setItem("inputType", inspector.#inputType(row.getItem("type")));
@@ -1064,7 +1073,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1064
1073
  const targetbar = palette.div({ node_label: "targetbar", class: "targetbar", hidden: "^singleTarget" });
1065
1074
  targetbar.select({ node_label: "targets", value: "^targetId", disabled: "^busy", "aria-label": "Inspected page", connect_onchange: "inspector.selectTarget" });
1066
1075
  const toolbar = palette.webcomponent({ code: "gramlot-poc-tabs", node_label: "tabs", role: "tablist", "aria-label": "Inspected root" });
1067
- for (const name of ["Data", "Source", "Styles"]) toolbar.button(name, {
1076
+ for (const name of ["Data", "Source", "Styles"]) toolbar.html_button(name, {
1068
1077
  node_label: name.toLowerCase(),
1069
1078
  type: "button",
1070
1079
  role: "tab",
@@ -1086,7 +1095,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1086
1095
  const properties = content.section({ node_label: "properties", slot: "bottom", class: "properties", "aria-label": "Selected node properties" });
1087
1096
  const heading = properties.div({ class: "properties-heading" });
1088
1097
  heading.span("Properties", { class: "heading-label" });
1089
- heading.button("^breakpointCount", {
1098
+ heading.html_button("^breakpointCount", {
1090
1099
  type: "button",
1091
1100
  class: "breakpoint-count",
1092
1101
  hidden: "^noBreakpoints",
@@ -1094,7 +1103,7 @@ var GramlotToolsInspector = class extends HTMLElement {
1094
1103
  title: "Active breakpoints",
1095
1104
  connect_onclick: "inspector.showBreakpoints"
1096
1105
  });
1097
- heading.button("+", {
1106
+ heading.html_button("+", {
1098
1107
  type: "button",
1099
1108
  "aria-label": "Add attribute",
1100
1109
  title: "Add attribute",
@@ -1110,8 +1119,8 @@ var GramlotToolsInspector = class extends HTMLElement {
1110
1119
  const styles = palette.section({ node_label: "styles", class: "styles-panel", hidden: "^treeActive", "aria-label": "CSS variables" });
1111
1120
  const stylebar = styles.div({ class: "styles-toolbar" });
1112
1121
  stylebar.span("Document variables");
1113
- stylebar.button("Refresh", { type: "button", disabled: "^styles.busy", connect_onclick: "inspector.refreshStyles" });
1114
- stylebar.button("Reset all", { type: "button", disabled: "^styles.noChanges", connect_onclick: "inspector.resetStyles" });
1122
+ stylebar.html_button("Refresh", { type: "button", disabled: "^styles.busy", connect_onclick: "inspector.refreshStyles" });
1123
+ stylebar.html_button("Reset all", { type: "button", disabled: "^styles.noChanges", connect_onclick: "inspector.resetStyles" });
1115
1124
  stylebar.a("Download CSS", { href: "^styles.downloadUrl", download: "theme-overrides.css", "aria-disabled": "^styles.noDownload" });
1116
1125
  styles.p("Temporary preview \xB7 Enter or leave a field to apply. Closing the connection clears previews.", { class: "styles-help" });
1117
1126
  styles.p("^styles.status", { role: "status", class: "styles-status" });
@@ -1127,12 +1136,12 @@ var GramlotToolsInspector = class extends HTMLElement {
1127
1136
  breakpoint.input({ value: "^editor.condition", live: true, connect_oninput: "inspector.breakpointChanged", "aria-label": "Breakpoint condition", placeholder: "Condition (optional)" });
1128
1137
  breakpoint.p("^breakpointStatus", { role: "status", class: "breakpoint-status" });
1129
1138
  const actions = breakpoint.div({ class: "dialog-actions" });
1130
- actions.button("Cancel", { type: "button", connect_onclick: "inspector.closeBreakpoint" });
1131
- actions.button("Save", { type: "button", connect_onclick: "inspector.setBreakpoint" });
1139
+ actions.html_button("Cancel", { type: "button", connect_onclick: "inspector.closeBreakpoint" });
1140
+ actions.html_button("Save", { type: "button", connect_onclick: "inspector.setBreakpoint" });
1132
1141
  const list = palette.dialog({ node_label: "breakpoints", "aria-label": "Active breakpoints", class: "breakpoint-dialog" });
1133
1142
  list.h2("Active breakpoints");
1134
1143
  list.div({ node_label: "entries" });
1135
- list.div({ class: "dialog-actions" }).button("Close", { type: "button", connect_onclick: "inspector.closeBreakpoints" });
1144
+ list.div({ class: "dialog-actions" }).html_button("Close", { type: "button", connect_onclick: "inspector.closeBreakpoints" });
1136
1145
  ui.src.startSource(builder.source);
1137
1146
  for (const name of ["data", "source"]) this.#trees[name] = ui.dom.getDomNode(ui.src.source.getNode(`main.palette.content.tree.${name}`));
1138
1147
  this.#renderTargets();
@@ -1349,7 +1358,7 @@ ${declarations}
1349
1358
  "data-field": "color",
1350
1359
  connect_onchange: "inspector.setStyle"
1351
1360
  });
1352
- row.button("\u21B6", {
1361
+ row.html_button("\u21B6", {
1353
1362
  type: "button",
1354
1363
  "aria-label": `Reset ${record.name}`,
1355
1364
  title: "Reset variable",
@@ -1419,6 +1428,7 @@ ${declarations}
1419
1428
  this.#snapshot = entry ? {
1420
1429
  node: entry.node,
1421
1430
  value: entry.node.getValue(true),
1431
+ parameterEnums: ui.data.getItem("root") !== "source" ? {} : this.#connection ? this.#connection.nodeInfo(entry.node).parameterEnums : readParameterEnums(entry.node),
1422
1432
  attrs: { ...entry.node.getAttr() },
1423
1433
  resolver: entry.node.resolver,
1424
1434
  revision: this.#connection?.nodeInfo(entry.node)?.revision
@@ -1456,7 +1466,20 @@ ${declarations}
1456
1466
  if (fresh) label.input({ value: "^.name", live: true, "aria-label": "New attribute name", "data-row": row.label, connect_oninput: "inspector.editChanged" });
1457
1467
  else label.span(name);
1458
1468
  const cell = line.div({ class: "property-value" });
1459
- cell.input({
1469
+ const choices = !primary && this.#snapshot.parameterEnums[name];
1470
+ const value = data.getItem("text");
1471
+ if (choices && choices.includes(value)) {
1472
+ const select = cell.select({
1473
+ value: "^.text",
1474
+ class: "enum-value",
1475
+ disabled: locked,
1476
+ "aria-label": `${name} value`,
1477
+ "data-row": row.label,
1478
+ connect_onchange: "inspector.enumChanged",
1479
+ connect_onkeydown: "inspector.editKey"
1480
+ });
1481
+ for (const choice of choices) select.option(choice, { value: choice });
1482
+ } else cell.input({
1460
1483
  value: "^.text",
1461
1484
  type: "^.inputType",
1462
1485
  live: true,
@@ -1470,10 +1493,10 @@ ${declarations}
1470
1493
  });
1471
1494
  if (fresh) {
1472
1495
  const type = cell.select({ value: "^.type", "aria-label": "New attribute type", "data-row": row.label, connect_onchange: "inspector.typeChanged" });
1473
- for (const value of editorTypes) type.option(value, { value });
1496
+ for (const value2 of editorTypes) type.option(value2, { value: value2 });
1474
1497
  }
1475
1498
  if (!primary) {
1476
- const button = cell.button({
1499
+ const button = cell.html_button({
1477
1500
  type: "button",
1478
1501
  disabled: locked,
1479
1502
  "aria-label": `Remove ${name || "new attribute"}`,
@@ -1509,6 +1532,7 @@ ${declarations}
1509
1532
  this.#loadEditor(this.#selected());
1510
1533
  } else {
1511
1534
  this.#snapshot = {
1535
+ ...this.#snapshot,
1512
1536
  node: target,
1513
1537
  value: target.getValue(true),
1514
1538
  attrs: { ...target.getAttr() },
@@ -1668,7 +1692,7 @@ ${declarations}
1668
1692
  const config = node.value;
1669
1693
  const row = builder.root.div({ class: "breakpoint-entry" });
1670
1694
  row.span(`${config.getItem("root")}: ${config.getItem("path")} \xB7 ${config.getItem("mode")} \xB7 ${config.getItem("hits")} hits`);
1671
- row.button("\xD7", {
1695
+ row.html_button("\xD7", {
1672
1696
  type: "button",
1673
1697
  "aria-label": `Remove breakpoint ${config.getItem("root")}: ${config.getItem("path")}`,
1674
1698
  "data-breakpoint": node.label,
@@ -9,6 +9,9 @@ function scalarType(value) {
9
9
  }
10
10
  return null;
11
11
  }
12
+ function readParameterEnums(node) {
13
+ return Object.fromEntries(Object.entries(node._getMeta("gramlot_component")?.parameters ?? {}).filter(([, spec]) => spec.enum).map(([name, spec]) => [name, spec.enum]));
14
+ }
12
15
 
13
16
  // ../tools/gramlot-tools-inspector/src/inspector-styles.js
14
17
  var InspectorStyles = class {
@@ -101,7 +104,7 @@ function attachInspectorAgent(gramlot, port) {
101
104
  if (!identities.has(node)) identities.set(node, ++nextNode);
102
105
  return identities.get(node);
103
106
  };
104
- const describe = (store, ancestors = /* @__PURE__ */ new Set()) => {
107
+ const describe = (store, root, ancestors = /* @__PURE__ */ new Set()) => {
105
108
  if (ancestors.has(store)) throw new Error("Inspector snapshots require an acyclic Bag");
106
109
  const next = /* @__PURE__ */ new Set([...ancestors, store]);
107
110
  return store.getNodes().map((node) => {
@@ -112,15 +115,16 @@ function attachInspectorAgent(gramlot, port) {
112
115
  label: node.label,
113
116
  revision: versions.get(node) ?? 0,
114
117
  value: branch ? null : cell(value),
115
- children: branch ? describe(value, next) : null,
118
+ children: branch ? describe(value, root, next) : null,
116
119
  readonly: !!node.resolver,
120
+ parameterEnums: root === "source" ? readParameterEnums(node) : {},
117
121
  attrs: Object.entries(node.getAttr()).filter(([name]) => name !== "_meta").map(([name, value2]) => [name, cell(value2)])
118
122
  };
119
123
  });
120
124
  };
121
125
  const snapshot = () => ({
122
- data: describe(bag("data")),
123
- source: describe(bag("source")),
126
+ data: describe(bag("data"), "data"),
127
+ source: describe(bag("source"), "source"),
124
128
  breakpoints: [...breakpoints.values()].map(({ test, ...record }) => record)
125
129
  });
126
130
  const send = (data) => {