@gramlot/gramlot 0.3.2 → 0.3.3
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 +55 -14
- package/dist/gramlot.min.js +23 -23
- package/package.json +1 -1
- package/src/index-page-runtime.d.ts +2 -1
- package/src/index-page-runtime.js +54 -14
package/dist/gramlot.js
CHANGED
|
@@ -28878,7 +28878,9 @@ var APPEARANCES = /* @__PURE__ */ new Set(["base", "compact", "mimi", "joanna"])
|
|
|
28878
28878
|
// src/index-page-runtime.js
|
|
28879
28879
|
function mountIndexPage(renderer, root, onSelection = () => {
|
|
28880
28880
|
}, prepareEntry = () => {
|
|
28881
|
-
}, { containerLayout = false, state: suppliedState = null
|
|
28881
|
+
}, { containerLayout = false, state: suppliedState = null, createEntry = null, onLoad = () => {
|
|
28882
|
+
} } = {}) {
|
|
28883
|
+
if (createEntry && !containerLayout) throw new TypeError("Deferred index entries require containerLayout");
|
|
28882
28884
|
const shell = renderer.records.get(root).element;
|
|
28883
28885
|
const document = shell.ownerDocument;
|
|
28884
28886
|
const window2 = document.defaultView;
|
|
@@ -28986,17 +28988,53 @@ function mountIndexPage(renderer, root, onSelection = () => {
|
|
|
28986
28988
|
set(shell, { data_code_visible: String(visible) });
|
|
28987
28989
|
}
|
|
28988
28990
|
};
|
|
28991
|
+
const prepare = (entry) => {
|
|
28992
|
+
entry.panel = byId(`panel-${entry.key}`);
|
|
28993
|
+
entry.tab = containerLayout ? entry.panel : byId(`tab-${entry.key}`);
|
|
28994
|
+
entry.code = byId(`codepane-${entry.key}`);
|
|
28995
|
+
if (entry.key === "intro") return;
|
|
28996
|
+
prepareEntry(entry, { byId, node, set, listen });
|
|
28997
|
+
entry.frame = byId(`frame-${entry.key}`);
|
|
28998
|
+
if (entry.frame) listen(entry.frame, "load", () => send(entry.frame));
|
|
28999
|
+
};
|
|
29000
|
+
const openEntry = (entry) => {
|
|
29001
|
+
if (opened.getItem(entry.key)) return;
|
|
29002
|
+
opened.setItem(entry.key, true);
|
|
29003
|
+
set(containerLayout ? entry.panel : entry.tab, { hidden: false });
|
|
29004
|
+
if (entry.frame) set(entry.frame, { src: entry.open.getAttribute("href") });
|
|
29005
|
+
};
|
|
28989
29006
|
let selecting = false;
|
|
28990
29007
|
function select(key) {
|
|
28991
|
-
if (selecting) return;
|
|
29008
|
+
if (selecting || disposed) return;
|
|
29009
|
+
const requested = entries.get(key);
|
|
29010
|
+
if (!requested) return;
|
|
29011
|
+
state.setItem("requested", key);
|
|
29012
|
+
if (!requested.panel) {
|
|
29013
|
+
onLoad(key, "loading");
|
|
29014
|
+
if (!requested.loading) {
|
|
29015
|
+
requested.loading = Promise.resolve().then(() => {
|
|
29016
|
+
if (!disposed) return createEntry(requested);
|
|
29017
|
+
}).then(() => {
|
|
29018
|
+
if (disposed) return;
|
|
29019
|
+
prepare(requested);
|
|
29020
|
+
openEntry(requested);
|
|
29021
|
+
if (state.getItem("requested") === key) {
|
|
29022
|
+
onLoad(key, "ready");
|
|
29023
|
+
select(key);
|
|
29024
|
+
}
|
|
29025
|
+
}).catch((error) => {
|
|
29026
|
+
if (!disposed && state.getItem("requested") === key) onLoad(key, "error", error);
|
|
29027
|
+
}).finally(() => {
|
|
29028
|
+
requested.loading = null;
|
|
29029
|
+
});
|
|
29030
|
+
}
|
|
29031
|
+
return;
|
|
29032
|
+
}
|
|
29033
|
+
onLoad(key, "ready");
|
|
28992
29034
|
selecting = true;
|
|
28993
29035
|
try {
|
|
28994
29036
|
const entry = entries.get(key);
|
|
28995
|
-
|
|
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
|
-
}
|
|
29037
|
+
openEntry(entry);
|
|
29000
29038
|
if (entry.family) set(entry.family, { open: true });
|
|
29001
29039
|
for (const [current, item] of entries) {
|
|
29002
29040
|
const active = current === key;
|
|
@@ -29160,9 +29198,9 @@ function mountIndexPage(renderer, root, onSelection = () => {
|
|
|
29160
29198
|
});
|
|
29161
29199
|
listen(window2, "resize", () => setSidebarWidth(state.getItem("preferredSidebarWidth")));
|
|
29162
29200
|
}
|
|
29163
|
-
const choices = containerLayout ? byId("index-pages").children : shell.querySelectorAll(".index-tabs button");
|
|
29201
|
+
const choices = createEntry ? [byId("panel-intro"), ...shell.querySelectorAll('.index-sidebar a[id^="open-"]')] : containerLayout ? byId("index-pages").children : shell.querySelectorAll(".index-tabs button");
|
|
29164
29202
|
for (const tab of choices) {
|
|
29165
|
-
const key = tab.id.slice(containerLayout ? "panel-".length : "tab-".length);
|
|
29203
|
+
const key = tab.id.slice(createEntry && tab.id.startsWith("open-") ? "open-".length : containerLayout ? "panel-".length : "tab-".length);
|
|
29166
29204
|
const entry = {
|
|
29167
29205
|
key,
|
|
29168
29206
|
tab,
|
|
@@ -29171,7 +29209,7 @@ function mountIndexPage(renderer, root, onSelection = () => {
|
|
|
29171
29209
|
open: key === "intro" ? null : byId(`open-${key}`)
|
|
29172
29210
|
};
|
|
29173
29211
|
entries.set(key, entry);
|
|
29174
|
-
if (containerLayout ? node(
|
|
29212
|
+
if (entry.panel && (containerLayout ? node(entry.panel).getAttr("hidden") !== true : !tab.hidden)) opened.setItem(key, true);
|
|
29175
29213
|
if (!containerLayout && tab.getAttribute("aria-selected") === "true") state.setItem("active", key);
|
|
29176
29214
|
if (!containerLayout) listen(tab, "click", () => select(key));
|
|
29177
29215
|
if (entry.open) listen(entry.open, "click", (event) => {
|
|
@@ -29189,12 +29227,15 @@ function mountIndexPage(renderer, root, onSelection = () => {
|
|
|
29189
29227
|
});
|
|
29190
29228
|
if (key === "intro") continue;
|
|
29191
29229
|
entry.family = entry.open.closest("details");
|
|
29192
|
-
|
|
29193
|
-
if (entry.panel.classList.contains("index-category")) continue;
|
|
29194
|
-
entry.frame = byId(`frame-${key}`);
|
|
29195
|
-
listen(entry.frame, "load", () => send(entry.frame));
|
|
29230
|
+
if (entry.panel) prepare(entry);
|
|
29196
29231
|
}
|
|
29197
29232
|
if (containerLayout) {
|
|
29233
|
+
const pages2 = byId("index-pages");
|
|
29234
|
+
listen(pages2, "click", (event) => {
|
|
29235
|
+
if (event.target === pages2 && event.composedPath().some((element) => element instanceof window2.Element && element.getAttribute("role") === "tab")) {
|
|
29236
|
+
select(state.getItem("active"));
|
|
29237
|
+
}
|
|
29238
|
+
});
|
|
29198
29239
|
const subscription = `${shell.id}-selection`;
|
|
29199
29240
|
state.subscribe(subscription, { any: (event) => {
|
|
29200
29241
|
if (event.node === state.getNode("active")) select(state.getItem("active"));
|