@gramlot/gramlot 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/gramlot.js CHANGED
@@ -22095,7 +22095,7 @@ function annotation2(parameter) {
22095
22095
  });
22096
22096
  return alternatives.length === 1 ? alternatives[0] : { kind: "union", items: alternatives };
22097
22097
  }
22098
- function defineComponent({ name, tag: tag2, base, mixins = [], parameters: parameters2 = {}, subTags = "", presentationDefaults = [], dataScope = false, command = false, implementation }) {
22098
+ function defineComponent({ name, tag: tag2, base, mixins = [], parameters: parameters2 = {}, subTags = "", presentationDefaults = [], dataScope = false, command = false, childParameters = {}, sourceContext = false, implementation }) {
22099
22099
  webcomponentCode({ code: tag2 });
22100
22100
  if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(name)) throw new TypeError("Invalid component authoring name");
22101
22101
  const effective = { ...base.parameters };
@@ -22117,6 +22117,8 @@ function defineComponent({ name, tag: tag2, base, mixins = [], parameters: param
22117
22117
  command,
22118
22118
  mixins: Object.freeze([...mixins]),
22119
22119
  parameters: freeze(structuredClone(effective)),
22120
+ childParameters: freeze(structuredClone(childParameters)),
22121
+ sourceContext,
22120
22122
  implementation
22121
22123
  });
22122
22124
  }
@@ -22173,7 +22175,9 @@ var ComponentCollection = class {
22173
22175
  parameters: structuredClone(component.parameters),
22174
22176
  presentationDefaults: [...component.presentationDefaults],
22175
22177
  dataScope: component.dataScope,
22176
- command: component.command
22178
+ command: component.command,
22179
+ ...Object.keys(component.childParameters).length ? { childParameters: structuredClone(component.childParameters) } : {},
22180
+ ...component.sourceContext ? { sourceContext: true } : {}
22177
22181
  } }
22178
22182
  }]))
22179
22183
  };
@@ -22417,12 +22421,12 @@ ChoiceGroup.parameters = {
22417
22421
  // src/components/popup.js
22418
22422
  var VIEWPORT_MARGIN = 8;
22419
22423
  var ANCHOR_GAP = 3;
22420
- function positionPopup(popup, anchor, { align = "start", matchWidth = false } = {}) {
22424
+ function positionPopup(popup, anchor, { align = "start", matchWidth = false, inset = 0 } = {}) {
22421
22425
  const view = anchor.ownerDocument.defaultView;
22422
22426
  const field = anchor.getBoundingClientRect();
22423
22427
  const availableWidth = Math.max(0, view.innerWidth - 2 * VIEWPORT_MARGIN);
22424
22428
  popup.style.setProperty("--gramlot-popup-available-width", `${availableWidth}px`);
22425
- if (matchWidth) popup.style.width = `${Math.min(field.width, availableWidth)}px`;
22429
+ if (matchWidth) popup.style.width = `${Math.min(Math.max(0, field.width - 2 * inset), availableWidth)}px`;
22426
22430
  popup.style.removeProperty("--gramlot-popup-available-height");
22427
22431
  const natural = popup.getBoundingClientRect();
22428
22432
  const below = Math.max(0, view.innerHeight - VIEWPORT_MARGIN - field.bottom - ANCHOR_GAP);
@@ -22430,7 +22434,7 @@ function positionPopup(popup, anchor, { align = "start", matchWidth = false } =
22430
22434
  const upwards = natural.height > below && above > below;
22431
22435
  popup.style.setProperty("--gramlot-popup-available-height", `${upwards ? above : below}px`);
22432
22436
  const size = popup.getBoundingClientRect();
22433
- const left = align === "end" ? field.right - size.width : field.left;
22437
+ const left = align === "end" ? field.right - size.width - inset : field.left + inset;
22434
22438
  const top = upwards ? field.top - size.height - ANCHOR_GAP : field.bottom + ANCHOR_GAP;
22435
22439
  popup.style.left = `${Math.max(VIEWPORT_MARGIN, Math.min(left, view.innerWidth - size.width - VIEWPORT_MARGIN))}px`;
22436
22440
  popup.style.top = `${Math.max(VIEWPORT_MARGIN, Math.min(top, view.innerHeight - size.height - VIEWPORT_MARGIN))}px`;
@@ -22851,6 +22855,7 @@ var GramlotBuilderBagNode = class extends SourceBagNode {
22851
22855
  codeAttributes() {
22852
22856
  const own2 = [
22853
22857
  ...CODE_ATTRIBUTES[this.nodeTag] ?? [],
22858
+ ...Object.entries(this.parentNode?._getMeta("gramlot_component")?.childParameters ?? {}).filter(([, spec]) => spec.inline).map(([name]) => name),
22854
22859
  ...this._getMeta("gramlot_component")?.command ? ["action", "_ask_if"] : [],
22855
22860
  ...typeof this.getAttr("remote") === "string" ? REMOTE_CODE_ATTRIBUTES : []
22856
22861
  ];
@@ -23309,7 +23314,8 @@ var BINDING_ATTRIBUTES = /* @__PURE__ */ new Set([
23309
23314
  "_userChanges",
23310
23315
  "remote",
23311
23316
  "_cachedRemote",
23312
- "_onRemote"
23317
+ "_onRemote",
23318
+ "onClose"
23313
23319
  ]);
23314
23320
  var BINDING_ATTRIBUTE_PREFIXES = ["default_", "attr_", "fire_", "connect_on", "subscribe_", "selfsubscribe_", "formsubscribe_", "remote_"];
23315
23321
  var NATIVE_ATTRIBUTES = {
@@ -23334,6 +23340,9 @@ function requireStyleClassAttributes(node, attrs, prefixes = []) {
23334
23340
  }
23335
23341
  }
23336
23342
  function requireNoScriptAttributes(node, attrs, prefixes = []) {
23343
+ if (attrs.onClose != null && !node.parentNode?._getMeta("gramlot_component")?.childParameters?.onClose) {
23344
+ throw new Error("onClose is only supported on a tab/stack panel");
23345
+ }
23337
23346
  for (const [name, value] of Object.entries(withoutNullValues(withoutBindingAttributes(attrs)))) {
23338
23347
  const prefix = prefixes.find((candidate) => name.startsWith(candidate));
23339
23348
  const bare = prefix ? name.slice(prefix.length) : name;
@@ -24918,7 +24927,8 @@ function domPropertyName(name) {
24918
24927
  return PROPERTY_NAMES.get(camel.toLowerCase()) ?? camel;
24919
24928
  }
24920
24929
  var HtmlElement = class {
24921
- constructor({ metadataAttributes = [] } = {}) {
24930
+ constructor({ metadataAttributes = [], invokeScript = null } = {}) {
24931
+ this.invokeScript = invokeScript;
24922
24932
  this.metadataAttributes = /* @__PURE__ */ new Set([...META_ATTRS, "_text", ...metadataAttributes]);
24923
24933
  }
24924
24934
  definition(node) {
@@ -24963,6 +24973,17 @@ var HtmlElement = class {
24963
24973
  return node.getRelativeData(".");
24964
24974
  };
24965
24975
  }
24976
+ if (meta.gramlot_component?.sourceContext) {
24977
+ element.setSourceContext({
24978
+ publish: (topic, payload) => node.publish(topic, payload),
24979
+ writeParameter: (name, value) => {
24980
+ const pointer = node.getAttr(name);
24981
+ if (node.pointerType(pointer) === "^" && !Object.is(node.getRelativeData(pointer.slice(1)), value)) {
24982
+ node.setRelativeData(pointer.slice(1), value);
24983
+ }
24984
+ }
24985
+ });
24986
+ }
24966
24987
  const text = document.createTextNode(this.text(node));
24967
24988
  if (namespace !== XHTML_NS || !meta.void) element.append(text);
24968
24989
  const record2 = { element, text, tag: tag2 };
@@ -24988,13 +25009,25 @@ var HtmlElement = class {
24988
25009
  const isHtml = element.namespaceURI === XHTML_NS;
24989
25010
  const renderAttributes = this.definition(node).meta.render_attributes ?? {};
24990
25011
  const previous = record2.attrs ?? {};
24991
- if (this.definition(node).meta.gramlot_component) {
24992
- attrs = element.projectAttributes(attrs, (values) => {
24993
- requireNoScriptAttributes(node, values, node.builder.constructor.dialectPrefixes);
24994
- requireStyleClassAttributes(node, values, node.builder.constructor.dialectPrefixes);
24995
- return node.builder.renderer_html.adaptAttrs(values);
25012
+ const adapt = (values) => {
25013
+ requireNoScriptAttributes(node, values, node.builder.constructor.dialectPrefixes);
25014
+ requireStyleClassAttributes(node, values, node.builder.constructor.dialectPrefixes);
25015
+ return node.builder.renderer_html.adaptAttrs(values);
25016
+ };
25017
+ const parent = node.parentNode;
25018
+ if (parent?._getMeta("gramlot_component")?.childParameters) {
25019
+ const Parent = element.ownerDocument.defaultView.customElements.get(parent._getMeta("render_tag"));
25020
+ attrs = Parent.projectChild(element, attrs, {
25021
+ adapt,
25022
+ invoke: (name, code, keywords) => this.invokeScript(node, name, code, keywords),
25023
+ publish: (topic, payload) => node.publish(topic, payload),
25024
+ publishParent: (topic, payload) => parent.publish(topic, payload),
25025
+ remove: () => node.parentBag.popNode(node.label)
24996
25026
  });
24997
25027
  }
25028
+ if (this.definition(node).meta.gramlot_component) {
25029
+ attrs = element.projectAttributes(attrs, adapt);
25030
+ }
24998
25031
  attrs = Object.fromEntries(sourceAttributeItems({ ...attrs, ...renderAttributes }));
24999
25032
  const controlled = ControlAdapter.classFor(element, attrs) !== null;
25000
25033
  if (textValue2 === DEFAULT_TEXT) textValue2 = this.text(node);
@@ -27045,7 +27078,15 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
27045
27078
  this._binding = binding;
27046
27079
  this.source = source;
27047
27080
  this.destination = destination;
27048
- this.html = new HtmlElement({ metadataAttributes: ["__ref"] });
27081
+ this.html = new HtmlElement({
27082
+ metadataAttributes: ["__ref"],
27083
+ invokeScript: (node, name, code, keywords) => this.inlineCompiler.compile(
27084
+ node,
27085
+ name,
27086
+ code,
27087
+ node.parentNode._getMeta("gramlot_component").childParameters[name].inline
27088
+ )(keywords)
27089
+ });
27049
27090
  this.records = /* @__PURE__ */ new Map();
27050
27091
  this.references = new References(source);
27051
27092
  this.pending = [];
@@ -27534,9 +27575,10 @@ var GramlotRenderer = class extends GramlotHtmlRenderer {
27534
27575
  /** Component parameters use resolved Source values, before HTML-only filtering (e.g. validate_*). */
27535
27576
  componentAttributes(node, attrs) {
27536
27577
  const component = node._getMeta("gramlot_component");
27537
- if (!component) return attrs;
27578
+ const childParameters = node.parentNode?._getMeta("gramlot_component")?.childParameters;
27579
+ if (!component && !childParameters) return attrs;
27538
27580
  const resolved2 = this.#resolvedAttributes.get(node);
27539
- const parameters2 = Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(component.parameters), ...Object.keys(resolved2).filter((name) => name.startsWith("validate_"))])].filter((name) => Object.hasOwn(resolved2, name)).map((name) => [name, resolved2[name]]));
27581
+ const parameters2 = Object.fromEntries([.../* @__PURE__ */ new Set([...Object.keys(component?.parameters ?? {}), ...Object.keys(childParameters ?? {}), ...Object.keys(resolved2).filter((name) => name.startsWith("validate_"))])].filter((name) => Object.hasOwn(resolved2, name)).map((name) => [name, resolved2[name]]));
27540
27582
  return { ...attrs, ...parameters2 };
27541
27583
  }
27542
27584
  /**
@@ -28825,7 +28867,7 @@ var IndexPage = class extends Page {
28825
28867
  };
28826
28868
 
28827
28869
  // src/index-page-styles.js
28828
- var appearanceStyles = { "base": "", "compact": '/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type="color"]) { min-block-size: 28px; }\n :where(input[type="file"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n', "mimi": '/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type="color"]) { min-block-size: 28px; }\n :where(input[type="file"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n\n/* Gramlot adaptation of legacy mimi; load after Base and Compact. */\n@layer gramlot.tokens {\n :root {\n --gramlot-background: #EDEEF0;\n --gramlot-surface: #F5F5F6;\n --gramlot-surface-subtle: #E0E1E3;\n --gramlot-ink: #3C3D40;\n --gramlot-text-secondary: #6B6E72;\n --gramlot-border: #BDBFC2;\n --gramlot-border-control: #9EA0A3;\n --gramlot-navigation: #48494C;\n --gramlot-navigation-text: #FFFFFF;\n --gramlot-action: #0071E3;\n --gramlot-action-hover: #005BBB;\n --gramlot-brand-blue: #0071E3;\n --gramlot-brand-yellow: #9EA0A3;\n --gramlot-selected: #E8F1FC;\n --gramlot-focus-ring: #0071E3;\n --gramlot-field-background: #FFFFFF;\n --gramlot-field-readonly-background: #E0E1E3;\n --gramlot-error: #B3261E;\n --gramlot-error-background: #FFF1F0;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);\n --gramlot-radius-sm: 4px;\n --gramlot-radius: 3px;\n --gramlot-radius-lg: 3px;\n --gramlot-field-height: 18px;\n --gramlot-field-padding: 1px 3px;\n --gramlot-field-line-height: 1.15;\n --gramlot-field-font-size: 1rem;\n --gramlot-label-size: .9em;\n --gramlot-label-gap: 2px;\n --gramlot-label-color: var(--gramlot-text-secondary);\n --gramlot-space-4: 6px;\n --gramlot-font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;\n }\n @media (prefers-color-scheme: dark) {\n :root:not([data-theme="light"]) {\n --gramlot-background: #242527;\n --gramlot-surface: #303134;\n --gramlot-surface-subtle: #3C3D40;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #6B6E72;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3C3D40;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n }\n :root[data-theme="dark"] {\n --gramlot-background: #242527;\n --gramlot-surface: #303134;\n --gramlot-surface-subtle: #3C3D40;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #6B6E72;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3C3D40;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n}\n@layer gramlot.base {\n html { font-size: 12px; }\n}\n@layer gramlot.components {\n :where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) { min-block-size: 24px; padding: 2px 8px; font-weight: 500; }\n}\n@layer gramlot.utilities {\n .card { box-shadow: var(--gramlot-shadow); }\n}\n', "joanna": '/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type="color"]) { min-block-size: 28px; }\n :where(input[type="file"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n\n/* Gramlot adaptation of legacy joanna; load after Base and Compact. */\n@layer gramlot.tokens {\n :root {\n --gramlot-background: #F2F2F7;\n --gramlot-surface: #FFFFFF;\n --gramlot-surface-subtle: #F2F2F7;\n --gramlot-ink: #3A3A3C;\n --gramlot-text-secondary: #636366;\n --gramlot-border: #D1D1D6;\n --gramlot-border-control: #AEAEB2;\n --gramlot-navigation: #3A3A3C;\n --gramlot-navigation-text: #FFFFFF;\n --gramlot-action: #007AFF;\n --gramlot-action-hover: #0061CC;\n --gramlot-brand-blue: #007AFF;\n --gramlot-brand-yellow: #AEAEB2;\n --gramlot-selected: #E0EFFF;\n --gramlot-focus-ring: #007AFF;\n --gramlot-field-background: #FFFFFF;\n --gramlot-field-readonly-background: #F2F2F7;\n --gramlot-error: #B3261E;\n --gramlot-error-background: #FFF1F0;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);\n --gramlot-radius-sm: 6px;\n --gramlot-radius: 6px;\n --gramlot-radius-lg: 6px;\n --gramlot-field-height: 20px;\n --gramlot-field-padding: 1px 3px;\n --gramlot-field-line-height: 1.15;\n --gramlot-field-font-size: 1rem;\n --gramlot-label-size: .8em;\n --gramlot-label-gap: 2px;\n --gramlot-label-color: var(--gramlot-text-secondary);\n --gramlot-space-4: 6px;\n --gramlot-font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;\n }\n @media (prefers-color-scheme: dark) {\n :root:not([data-theme="light"]) {\n --gramlot-background: #1C1C1E;\n --gramlot-surface: #2C2C2E;\n --gramlot-surface-subtle: #3A3A3C;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #636366;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3A3A3C;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n }\n :root[data-theme="dark"] {\n --gramlot-background: #1C1C1E;\n --gramlot-surface: #2C2C2E;\n --gramlot-surface-subtle: #3A3A3C;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #636366;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3A3A3C;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n}\n@layer gramlot.base {\n html { font-size: 13px; }\n}\n@layer gramlot.components {\n :where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) { min-block-size: 26px; padding: 2px 8px; font-weight: 500; }\n}\n@layer gramlot.utilities {\n .card { box-shadow: var(--gramlot-shadow); }\n}\n' };
28870
+ var appearanceStyles = { "base": "", "compact": '/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type="color"]) { min-block-size: 28px; }\n :where(input[type="file"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n', "mimi": '/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type="color"]) { min-block-size: 28px; }\n :where(input[type="file"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n\n/* Gramlot adaptation of legacy mimi; load after Base and Compact. */\n@layer gramlot.tokens {\n :root {\n --gramlot-tab-height: 24px;\n --gramlot-tab-padding: 3px 10px;\n --gramlot-tab-radius: 3px;\n --gramlot-tab-gap: 2px;\n --gramlot-tab-strip-padding: 3px;\n --gramlot-tab-background: var(--gramlot-background);\n --gramlot-tab-selected-background: var(--gramlot-surface);\n --gramlot-tab-selected-color: var(--gramlot-ink);\n --gramlot-tab-border: var(--gramlot-border);\n --gramlot-background: #EDEEF0;\n --gramlot-surface: #F5F5F6;\n --gramlot-surface-subtle: #E0E1E3;\n --gramlot-ink: #3C3D40;\n --gramlot-text-secondary: #6B6E72;\n --gramlot-border: #BDBFC2;\n --gramlot-border-control: #9EA0A3;\n --gramlot-navigation: #48494C;\n --gramlot-navigation-text: #FFFFFF;\n --gramlot-action: #0071E3;\n --gramlot-action-hover: #005BBB;\n --gramlot-brand-blue: #0071E3;\n --gramlot-brand-yellow: #9EA0A3;\n --gramlot-selected: #E8F1FC;\n --gramlot-focus-ring: #0071E3;\n --gramlot-field-background: #FFFFFF;\n --gramlot-field-readonly-background: #E0E1E3;\n --gramlot-error: #B3261E;\n --gramlot-error-background: #FFF1F0;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);\n --gramlot-radius-sm: 4px;\n --gramlot-radius: 3px;\n --gramlot-radius-lg: 3px;\n --gramlot-field-height: 18px;\n --gramlot-field-padding: 1px 3px;\n --gramlot-field-line-height: 1.15;\n --gramlot-field-font-size: 1rem;\n --gramlot-label-size: .9em;\n --gramlot-label-gap: 2px;\n --gramlot-label-color: var(--gramlot-text-secondary);\n --gramlot-space-4: 6px;\n --gramlot-font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;\n }\n @media (prefers-color-scheme: dark) {\n :root:not([data-theme="light"]) {\n --gramlot-background: #242527;\n --gramlot-surface: #303134;\n --gramlot-surface-subtle: #3C3D40;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #6B6E72;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3C3D40;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n }\n :root[data-theme="dark"] {\n --gramlot-background: #242527;\n --gramlot-surface: #303134;\n --gramlot-surface-subtle: #3C3D40;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #6B6E72;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3C3D40;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n}\n@layer gramlot.base {\n html { font-size: 12px; }\n}\n@layer gramlot.components {\n :where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) { min-block-size: 24px; padding: 2px 8px; font-weight: 500; }\n}\n@layer gramlot.utilities {\n .card { box-shadow: var(--gramlot-shadow); }\n}\n', "joanna": '/* Gramlot Compact: load after gramlot-base/theme.css. Colors and behavior stay in Base. */\n@layer gramlot.tokens {\n :root {\n --gramlot-field-height: 28px;\n --gramlot-field-line-height: 1.35;\n --gramlot-field-padding: .25rem .5rem;\n --gramlot-field-font-size: 1rem;\n --gramlot-space-1: .2rem;\n --gramlot-space-2: .4rem;\n --gramlot-space-3: .5rem;\n --gramlot-space-4: .6rem;\n --gramlot-space-6: .9rem;\n --gramlot-space-8: 1.2rem;\n --gramlot-space-12: 1.8rem;\n --gramlot-radius-sm: .25rem;\n --gramlot-radius: .35rem;\n --gramlot-radius-lg: .4rem;\n }\n}\n\n@layer gramlot.base {\n html { font-size: 13px; }\n body { line-height: 1.35; }\n :where(h1, h2, h3, h4, h5, h6, p, ul, ol, dl, blockquote, pre, figure) { margin-block: 0 .5rem; }\n h1 { font-size: 1.35rem; }\n h2 { font-size: 1.15rem; }\n h3 { font-size: 1.05rem; }\n pre { padding: .5rem; }\n blockquote { padding-inline-start: .6rem; }\n hr { margin-block: 1rem; }\n}\n\n@layer gramlot.components {\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) {\n min-block-size: 28px;\n padding: .25rem .5rem;\n font-size: 1rem;\n line-height: 1.35;\n }\n :where(label) { font-size: .95rem; }\n :where(input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]), select, textarea) {\n min-block-size: var(--gramlot-field-height);\n padding: var(--gramlot-field-padding);\n font-size: var(--gramlot-field-font-size);\n line-height: var(--gramlot-field-line-height);\n }\n :where(textarea) { min-block-size: 5rem; }\n :where(input[type="color"]) { min-block-size: 28px; }\n :where(input[type="file"])::file-selector-button { margin-inline-end: .5rem; padding: .25rem .5rem; }\n :where(fieldset) { margin-block-end: .6rem; padding: .5rem; }\n :where(table) { font-size: 1rem; }\n :where(th, td) { padding: .4rem .5rem; }\n :where(details) { padding: .4rem .5rem; }\n :where(details[open] > summary) { margin-block-end: .5rem; }\n :where(dialog) { padding: .75rem; }\n}\n\n@layer gramlot.utilities {\n .example-page { inline-size: min(100% - 1.2rem, var(--gramlot-page-width)); padding-block: .6rem; }\n .card { padding: .6rem; box-shadow: none; }\n}\n\n/* Gramlot adaptation of legacy joanna; load after Base and Compact. */\n@layer gramlot.tokens {\n :root {\n --gramlot-tab-height: 26px;\n --gramlot-tab-padding: 3px 10px;\n --gramlot-tab-radius: 6px;\n --gramlot-tab-gap: 2px;\n --gramlot-tab-strip-padding: 3px;\n --gramlot-tab-background: var(--gramlot-background);\n --gramlot-tab-selected-background: var(--gramlot-surface);\n --gramlot-tab-selected-color: var(--gramlot-ink);\n --gramlot-tab-border: var(--gramlot-border);\n --gramlot-background: #F2F2F7;\n --gramlot-surface: #FFFFFF;\n --gramlot-surface-subtle: #F2F2F7;\n --gramlot-ink: #3A3A3C;\n --gramlot-text-secondary: #636366;\n --gramlot-border: #D1D1D6;\n --gramlot-border-control: #AEAEB2;\n --gramlot-navigation: #3A3A3C;\n --gramlot-navigation-text: #FFFFFF;\n --gramlot-action: #007AFF;\n --gramlot-action-hover: #0061CC;\n --gramlot-brand-blue: #007AFF;\n --gramlot-brand-yellow: #AEAEB2;\n --gramlot-selected: #E0EFFF;\n --gramlot-focus-ring: #007AFF;\n --gramlot-field-background: #FFFFFF;\n --gramlot-field-readonly-background: #F2F2F7;\n --gramlot-error: #B3261E;\n --gramlot-error-background: #FFF1F0;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 6%);\n --gramlot-radius-sm: 6px;\n --gramlot-radius: 6px;\n --gramlot-radius-lg: 6px;\n --gramlot-field-height: 20px;\n --gramlot-field-padding: 1px 3px;\n --gramlot-field-line-height: 1.15;\n --gramlot-field-font-size: 1rem;\n --gramlot-label-size: .8em;\n --gramlot-label-gap: 2px;\n --gramlot-label-color: var(--gramlot-text-secondary);\n --gramlot-space-4: 6px;\n --gramlot-font-ui: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;\n }\n @media (prefers-color-scheme: dark) {\n :root:not([data-theme="light"]) {\n --gramlot-background: #1C1C1E;\n --gramlot-surface: #2C2C2E;\n --gramlot-surface-subtle: #3A3A3C;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #636366;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3A3A3C;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n }\n :root[data-theme="dark"] {\n --gramlot-background: #1C1C1E;\n --gramlot-surface: #2C2C2E;\n --gramlot-surface-subtle: #3A3A3C;\n --gramlot-ink: #F2F2F7;\n --gramlot-text-secondary: #C7C7CC;\n --gramlot-border: #636366;\n --gramlot-border-control: #8E8E93;\n --gramlot-navigation: #1C1C1E;\n --gramlot-action: #78B7FF;\n --gramlot-action-hover: #A6CFFF;\n --gramlot-brand-blue: #3478CA;\n --gramlot-selected: #254163;\n --gramlot-focus-ring: #78B7FF;\n --gramlot-field-background: #202124;\n --gramlot-field-readonly-background: #3A3A3C;\n --gramlot-error: #FFB4AB;\n --gramlot-error-background: #482524;\n --gramlot-shadow: 0 1px 4px rgb(0 0 0 / 20%);\n }\n}\n@layer gramlot.base {\n html { font-size: 13px; }\n}\n@layer gramlot.components {\n :where(label) { font-size: var(--gramlot-label-size); font-weight: normal; color: var(--gramlot-label-color); margin-block-end: var(--gramlot-label-gap); }\n :where(button, input[type="button"], input[type="submit"], input[type="reset"], .button) { min-block-size: 26px; padding: 2px 8px; font-weight: 500; }\n}\n@layer gramlot.utilities {\n .card { box-shadow: var(--gramlot-shadow); }\n}\n' };
28829
28871
 
28830
28872
  // src/index-theme.js
28831
28873
  var THEME_READY = "index:theme-ready";
@@ -28836,7 +28878,7 @@ var APPEARANCES = /* @__PURE__ */ new Set(["base", "compact", "mimi", "joanna"])
28836
28878
  // src/index-page-runtime.js
28837
28879
  function mountIndexPage(renderer, root, onSelection = () => {
28838
28880
  }, prepareEntry = () => {
28839
- }) {
28881
+ }, { containerLayout = false, state: suppliedState = null } = {}) {
28840
28882
  const shell = renderer.records.get(root).element;
28841
28883
  const document = shell.ownerDocument;
28842
28884
  const window2 = document.defaultView;
@@ -28869,7 +28911,7 @@ function mountIndexPage(renderer, root, onSelection = () => {
28869
28911
  restoreChoice(appearance, preferences.appearance, APPEARANCES);
28870
28912
  const families = [...shell.querySelectorAll(".index-sidebar details")];
28871
28913
  const Bag2 = root.builder.data.constructor;
28872
- const state = new Bag2();
28914
+ const state = suppliedState ?? new Bag2();
28873
28915
  const opened = new Bag2();
28874
28916
  state.setItem("opened", opened);
28875
28917
  state.setItem("keyboard", keyboard?.checked ?? false);
@@ -28930,38 +28972,47 @@ function mountIndexPage(renderer, root, onSelection = () => {
28930
28972
  const updatePanels = () => {
28931
28973
  if (navigationToggle) {
28932
28974
  const visible = state.getItem("navigationVisible");
28933
- set(sidebar, { hidden: !visible });
28934
- set(sidebarHandle, { hidden: !visible });
28975
+ set(sidebar, containerLayout ? { drawer: visible ? true : "close" } : { hidden: !visible });
28976
+ if (!containerLayout) set(sidebarHandle, { hidden: !visible });
28935
28977
  set(navigationToggle, { aria_expanded: String(visible) });
28936
28978
  set(shell, { data_navigation_hidden: String(!visible) });
28937
28979
  }
28938
28980
  if (codeSidebar) {
28939
28981
  const available = Boolean(entries.get(state.getItem("active"))?.code);
28940
28982
  const visible = available && state.getItem("codeVisible");
28941
- set(codeSidebar, { hidden: !visible });
28942
- set(codeHandle, { hidden: !visible });
28983
+ set(codeSidebar, containerLayout ? { hidden: !available, drawer: visible ? true : "close" } : { hidden: !visible });
28984
+ if (!containerLayout) set(codeHandle, { hidden: !visible });
28943
28985
  set(codeToggle, { disabled: !available, aria_expanded: String(visible) });
28944
28986
  set(shell, { data_code_visible: String(visible) });
28945
28987
  }
28946
28988
  };
28989
+ let selecting = false;
28947
28990
  function select(key) {
28948
- const entry = entries.get(key);
28949
- if (!opened.getItem(key)) {
28950
- opened.setItem(key, true);
28951
- set(entry.tab, { hidden: false });
28952
- if (entry.frame) set(entry.frame, { src: entry.open.getAttribute("href") });
28953
- }
28954
- if (entry.family) set(entry.family, { open: true });
28955
- for (const [current, item] of entries) {
28956
- const active = current === key;
28957
- set(item.tab, { aria_selected: String(active), tabindex: active && state.getItem("keyboard") ? 0 : -1 });
28958
- set(item.panel, { hidden: !active });
28959
- if (item.code) set(item.code, { hidden: !active });
28960
- if (item.open) set(item.open, { aria_current: active ? "page" : null });
28961
- }
28962
- state.setItem("active", key);
28963
- updatePanels();
28964
- updateInspector();
28991
+ if (selecting) return;
28992
+ selecting = true;
28993
+ try {
28994
+ const entry = entries.get(key);
28995
+ if (!opened.getItem(key)) {
28996
+ opened.setItem(key, true);
28997
+ set(containerLayout ? entry.panel : entry.tab, { hidden: false });
28998
+ if (entry.frame) set(entry.frame, { src: entry.open.getAttribute("href") });
28999
+ }
29000
+ if (entry.family) set(entry.family, { open: true });
29001
+ for (const [current, item] of entries) {
29002
+ const active = current === key;
29003
+ if (!containerLayout) {
29004
+ set(item.tab, { aria_selected: String(active), tabindex: active && state.getItem("keyboard") ? 0 : -1 });
29005
+ set(item.panel, { hidden: !active });
29006
+ }
29007
+ if (item.code) set(item.code, { hidden: !active });
29008
+ if (item.open) set(item.open, { aria_current: active ? "page" : null });
29009
+ }
29010
+ if (state.getItem("active") !== key) state.setItem("active", key);
29011
+ updatePanels();
29012
+ updateInspector();
29013
+ } finally {
29014
+ selecting = false;
29015
+ }
28965
29016
  }
28966
29017
  const sidebarMaximum = () => Math.max(120, Math.min(460, Math.floor(window2.innerWidth * 0.6)));
28967
29018
  const applyWidths = () => set(shell, { style: `--sidebar-width: ${state.getItem("sidebarWidth")}px; --code-width: ${state.getItem("codeWidth") ?? 420}px` });
@@ -29028,10 +29079,37 @@ function mountIndexPage(renderer, root, onSelection = () => {
29028
29079
  });
29029
29080
  }
29030
29081
  set(shell, { data_resizing: null });
29031
- const savedWidth = preferences.sidebarWidth;
29032
- const width = typeof savedWidth === "number" && Number.isFinite(savedWidth) && savedWidth >= 120 && savedWidth <= 460 ? savedWidth : sidebar.getBoundingClientRect().width || Number(sidebarHandle.getAttribute("aria-valuenow"));
29033
- state.setItem("preferredSidebarWidth", width);
29034
- setSidebarWidth(width);
29082
+ if (!containerLayout) {
29083
+ const savedWidth = preferences.sidebarWidth;
29084
+ const width = typeof savedWidth === "number" && Number.isFinite(savedWidth) && savedWidth >= 120 && savedWidth <= 460 ? savedWidth : sidebar.getBoundingClientRect().width || Number(sidebarHandle.getAttribute("aria-valuenow"));
29085
+ state.setItem("preferredSidebarWidth", width);
29086
+ setSidebarWidth(width);
29087
+ } else {
29088
+ const gramlot = renderer.binding.gramlot;
29089
+ for (const [pane, property, widthProperty] of [[sidebar, "navigationVisible", "sidebarWidth"], [codeSidebar, "codeVisible", "codeWidth"]]) {
29090
+ const source = node(pane);
29091
+ const savedWidth = preferences[widthProperty];
29092
+ if (typeof savedWidth === "number" && Number.isFinite(savedWidth) && savedWidth > 0) set(pane, { width: `${savedWidth}px` });
29093
+ const handle2 = gramlot.subscribe(`${source.getAttr("node_id")}_closable_change`, ({ open }) => {
29094
+ if (source.getAttr("hidden") === true || source.getAttr("drawer") === false) return;
29095
+ state.setItem(property, open);
29096
+ set(pane, { drawer: open ? true : "close" });
29097
+ set(property === "navigationVisible" ? navigationToggle : codeToggle, { aria_expanded: String(open) });
29098
+ set(shell, { [property === "navigationVisible" ? "data_navigation_hidden" : "data_code_visible"]: String(property === "navigationVisible" ? !open : open) });
29099
+ savePreferences();
29100
+ });
29101
+ releases.push(() => gramlot.unsubscribe(handle2));
29102
+ }
29103
+ const border = shell.querySelector("[data-index-regions]");
29104
+ const handle = gramlot.subscribe(`${node(border).getAttr("node_id")}_splitter_resize`, ({ region, size }) => {
29105
+ set(region === "left" ? sidebar : codeSidebar, { width: size });
29106
+ state.setItem(region === "left" ? "preferredSidebarWidth" : "preferredCodeWidth", Number.parseFloat(size));
29107
+ savePreferences();
29108
+ });
29109
+ releases.push(() => gramlot.unsubscribe(handle));
29110
+ state.setItem("preferredSidebarWidth", preferences.sidebarWidth);
29111
+ state.setItem("preferredCodeWidth", preferences.codeWidth);
29112
+ }
29035
29113
  listen(navigationToggle, "click", () => {
29036
29114
  state.setItem("navigationVisible", !state.getItem("navigationVisible"));
29037
29115
  updatePanels();
@@ -29042,11 +29120,11 @@ function mountIndexPage(renderer, root, onSelection = () => {
29042
29120
  updatePanels();
29043
29121
  savePreferences();
29044
29122
  });
29045
- if (codeHandle) {
29123
+ if (!containerLayout && codeHandle) {
29046
29124
  const saved = preferences.codeWidth;
29047
- const width2 = typeof saved === "number" && Number.isFinite(saved) && saved >= 200 ? saved : 420;
29048
- state.setItem("preferredCodeWidth", width2);
29049
- setCodeWidth(width2);
29125
+ const width = typeof saved === "number" && Number.isFinite(saved) && saved >= 200 ? saved : 420;
29126
+ state.setItem("preferredCodeWidth", width);
29127
+ setCodeWidth(width);
29050
29128
  listen(codeHandle, "keydown", (event) => {
29051
29129
  const current = state.getItem("codeWidth");
29052
29130
  const value = event.key === "ArrowLeft" ? current + 10 : event.key === "ArrowRight" ? current - 10 : event.key === "Home" ? 200 : event.key === "End" ? codeMaximum() : null;
@@ -29064,24 +29142,27 @@ function mountIndexPage(renderer, root, onSelection = () => {
29064
29142
  });
29065
29143
  listen(window2, "resize", () => setCodeWidth(state.getItem("preferredCodeWidth")));
29066
29144
  }
29067
- listen(sidebarHandle, "keydown", (event) => {
29068
- const current = state.getItem("sidebarWidth");
29069
- const value = event.key === "ArrowLeft" ? current - 10 : event.key === "ArrowRight" ? current + 10 : event.key === "Home" ? 120 : event.key === "End" ? sidebarMaximum() : null;
29070
- if (value == null) return;
29071
- event.preventDefault();
29072
- setSidebarWidth(value, true);
29073
- });
29074
- listen(sidebarHandle, "pointerdown", (event) => beginDrag(
29075
- sidebarHandle,
29076
- event,
29077
- (x) => setSidebarWidth(Math.round(x - shell.getBoundingClientRect().left), true)
29078
- ));
29079
- listen(sidebarHandle, "lostpointercapture", () => {
29080
- if (drag?.handle === sidebarHandle) stopDrag();
29081
- });
29082
- listen(window2, "resize", () => setSidebarWidth(state.getItem("preferredSidebarWidth")));
29083
- for (const tab of shell.querySelectorAll(".index-tabs button")) {
29084
- const key = tab.id.slice("tab-".length);
29145
+ if (!containerLayout) {
29146
+ listen(sidebarHandle, "keydown", (event) => {
29147
+ const current = state.getItem("sidebarWidth");
29148
+ const value = event.key === "ArrowLeft" ? current - 10 : event.key === "ArrowRight" ? current + 10 : event.key === "Home" ? 120 : event.key === "End" ? sidebarMaximum() : null;
29149
+ if (value == null) return;
29150
+ event.preventDefault();
29151
+ setSidebarWidth(value, true);
29152
+ });
29153
+ listen(sidebarHandle, "pointerdown", (event) => beginDrag(
29154
+ sidebarHandle,
29155
+ event,
29156
+ (x) => setSidebarWidth(Math.round(x - shell.getBoundingClientRect().left), true)
29157
+ ));
29158
+ listen(sidebarHandle, "lostpointercapture", () => {
29159
+ if (drag?.handle === sidebarHandle) stopDrag();
29160
+ });
29161
+ listen(window2, "resize", () => setSidebarWidth(state.getItem("preferredSidebarWidth")));
29162
+ }
29163
+ const choices = containerLayout ? byId("index-pages").children : shell.querySelectorAll(".index-tabs button");
29164
+ for (const tab of choices) {
29165
+ const key = tab.id.slice(containerLayout ? "panel-".length : "tab-".length);
29085
29166
  const entry = {
29086
29167
  key,
29087
29168
  tab,
@@ -29090,14 +29171,14 @@ function mountIndexPage(renderer, root, onSelection = () => {
29090
29171
  open: key === "intro" ? null : byId(`open-${key}`)
29091
29172
  };
29092
29173
  entries.set(key, entry);
29093
- if (!tab.hidden) opened.setItem(key, true);
29094
- if (tab.getAttribute("aria-selected") === "true") state.setItem("active", key);
29095
- listen(tab, "click", () => select(key));
29174
+ if (containerLayout ? node(tab).getAttr("hidden") !== true : !tab.hidden) opened.setItem(key, true);
29175
+ if (!containerLayout && tab.getAttribute("aria-selected") === "true") state.setItem("active", key);
29176
+ if (!containerLayout) listen(tab, "click", () => select(key));
29096
29177
  if (entry.open) listen(entry.open, "click", (event) => {
29097
29178
  event.preventDefault();
29098
29179
  select(key);
29099
29180
  });
29100
- listen(tab, "keydown", (event) => {
29181
+ if (!containerLayout) listen(tab, "keydown", (event) => {
29101
29182
  if (!state.getItem("keyboard") || !["ArrowLeft", "ArrowRight", "Home", "End"].includes(event.key)) return;
29102
29183
  const keys = [...entries.keys()].filter((key2) => opened.getItem(key2));
29103
29184
  const index = keys.indexOf(key);
@@ -29113,6 +29194,13 @@ function mountIndexPage(renderer, root, onSelection = () => {
29113
29194
  entry.frame = byId(`frame-${key}`);
29114
29195
  listen(entry.frame, "load", () => send(entry.frame));
29115
29196
  }
29197
+ if (containerLayout) {
29198
+ const subscription = `${shell.id}-selection`;
29199
+ state.subscribe(subscription, { any: (event) => {
29200
+ if (event.node === state.getNode("active")) select(state.getItem("active"));
29201
+ } });
29202
+ releases.push(() => state.unsubscribe(subscription, { any: true }));
29203
+ }
29116
29204
  listen(document, "pointermove", (event) => {
29117
29205
  if (!drag || event.pointerId !== drag.pointerId) return;
29118
29206
  drag.move(event.clientX);
@@ -29126,7 +29214,7 @@ function mountIndexPage(renderer, root, onSelection = () => {
29126
29214
  set(keyboard, { checked: keyboard?.checked ?? false });
29127
29215
  for (const [key, entry] of entries) {
29128
29216
  if (entry.open) set(entry.open, { tabindex: keyboard?.checked ?? false ? 0 : -1 });
29129
- set(entry.tab, { tabindex: (keyboard?.checked ?? false) && key === state.getItem("active") ? 0 : -1 });
29217
+ if (!containerLayout) set(entry.tab, { tabindex: (keyboard?.checked ?? false) && key === state.getItem("active") ? 0 : -1 });
29130
29218
  }
29131
29219
  });
29132
29220
  listen(appearance, "change", () => {