@tenphi/renderer 0.30.0 → 0.30.1
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.
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { dialog } from "@uniaria/core/dialog";
|
|
2
|
+
import { popover } from "@uniaria/core/popover";
|
|
3
|
+
import { UniElement } from "@uniaria/elements";
|
|
4
|
+
//#region src/client/elements.d.ts
|
|
5
|
+
declare global {
|
|
6
|
+
interface HTMLElementTagNameMap {
|
|
7
|
+
"cb-popover": UniElement<typeof popover>;
|
|
8
|
+
"cb-dialog": UniElement<typeof dialog>;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","names":[],"sources":["../../src/client/elements.ts"],"mappings":";;;;QAiBQ;YACI;IACR,cAAc,kBAAkB;IAChC,aAAa,kBAAkB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { dialog } from "@uniaria/core/dialog";
|
|
2
|
+
import { configure } from "@uniaria/core/dom";
|
|
3
|
+
import { popover } from "@uniaria/core/popover";
|
|
4
|
+
import { defineElement } from "@uniaria/elements";
|
|
5
|
+
//#region src/client/elements.ts
|
|
6
|
+
/**
|
|
7
|
+
* Register UniAria's behaviors as `cb-*` light-DOM elements on server-rendered
|
|
8
|
+
* markup. Cookbook's own elements keep the `cookbook-*` prefix.
|
|
9
|
+
*/
|
|
10
|
+
configure({ positioning: "css" });
|
|
11
|
+
defineElement(popover, { prefix: "cb" });
|
|
12
|
+
defineElement(dialog, { prefix: "cb" });
|
|
13
|
+
//#endregion
|
|
14
|
+
export {};
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=elements.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.js","names":[],"sources":["../../src/client/elements.ts"],"sourcesContent":["/**\n * Register UniAria's behaviors as `cb-*` light-DOM elements on server-rendered\n * markup. Cookbook's own elements keep the `cookbook-*` prefix.\n */\nimport { dialog } from \"@uniaria/core/dialog\";\nimport { configure } from \"@uniaria/core/dom\";\nimport { popover } from \"@uniaria/core/popover\";\nimport type { UniElement } from \"@uniaria/elements\";\nimport { defineElement } from \"@uniaria/elements\";\n\n// Panels keep the placement Cookbook's styles give them; UniAria only links\n// each one to its anchor and reads the side back.\nconfigure({ positioning: \"css\" });\n// Each returns undefined without `customElements` and skips a defined name.\ndefineElement(popover, { prefix: \"cb\" });\ndefineElement(dialog, { prefix: \"cb\" });\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"cb-popover\": UniElement<typeof popover>;\n \"cb-dialog\": UniElement<typeof dialog>;\n }\n}\n"],"mappings":";;;;;;;;;AAYA,UAAU,EAAE,aAAa,MAAM,CAAC;AAEhC,cAAc,SAAS,EAAE,QAAQ,KAAK,CAAC;AACvC,cAAc,QAAQ,EAAE,QAAQ,KAAK,CAAC"}
|
|
@@ -35,7 +35,7 @@ var CookbookSidebarPane = class extends HTMLElement {
|
|
|
35
35
|
this.#inert.set(element, element.inert);
|
|
36
36
|
element.inert = true;
|
|
37
37
|
}
|
|
38
|
-
this.querySelector("[autofocus]")?.focus({ preventScroll: true });
|
|
38
|
+
if (!this.contains(document.activeElement)) this.querySelector("[autofocus]")?.focus({ preventScroll: true });
|
|
39
39
|
} else {
|
|
40
40
|
const restoreFocus = this.contains(document.activeElement) || document.activeElement === document.body;
|
|
41
41
|
this.#release();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","names":[],"sources":["../../src/client/navigation.ts"],"sourcesContent":["import { initializePopoverMotion } from \"./popover-motion.js\";\n\nclass CookbookSidebarPane extends HTMLElement {\n #listeners?: AbortController;\n #inert = new Map<HTMLElement, boolean>();\n #trigger: HTMLButtonElement | undefined;\n\n connectedCallback() {\n this.#listeners?.abort();\n this.#listeners = new AbortController();\n const { signal } = this.#listeners;\n this.#trigger =\n document.querySelector<HTMLButtonElement>(\n '[data-element=MobileMenuToggle][popovertarget=\"cookbook__sidebar\"]',\n ) ?? undefined;\n const desktop = matchMedia(\"(min-width: 50rem)\");\n const syncViewport = () => {\n if (desktop.matches) {\n if (this.matches(\":popover-open\")) this.hidePopover();\n this.#release();\n this.popover = null;\n this.removeAttribute(\"role\");\n this.removeAttribute(\"aria-modal\");\n } else {\n this.popover = \"auto\";\n this.setAttribute(\"role\", \"dialog\");\n this.setAttribute(\"aria-modal\", \"true\");\n }\n };\n syncViewport();\n desktop.addEventListener(\"change\", syncViewport, { signal });\n this.addEventListener(\n \"toggle\",\n () => {\n const open = !desktop.matches && this.matches(\":popover-open\");\n this.#trigger?.setAttribute(\"aria-expanded\", String(open));\n if (open) {\n // Establish the closed position after the popover enters the top\n // layer so its attribute change transitions from an actual layout.\n // Tasty's global SSR renderer does not preserve @starting-style.\n this.getBoundingClientRect();\n this.setAttribute(\"data-open\", \"\");\n for (const element of document.querySelectorAll<HTMLElement>(\n \"[data-element=HeaderFrame], [data-element=MainFrame], [data-element=SkipLink]\",\n )) {\n this.#inert.set(element, element.inert);\n element.inert = true;\n }\n this.querySelector<HTMLElement>(\"[autofocus]\")?.focus({\n
|
|
1
|
+
{"version":3,"file":"navigation.js","names":[],"sources":["../../src/client/navigation.ts"],"sourcesContent":["import { initializePopoverMotion } from \"./popover-motion.js\";\n\nclass CookbookSidebarPane extends HTMLElement {\n #listeners?: AbortController;\n #inert = new Map<HTMLElement, boolean>();\n #trigger: HTMLButtonElement | undefined;\n\n connectedCallback() {\n this.#listeners?.abort();\n this.#listeners = new AbortController();\n const { signal } = this.#listeners;\n this.#trigger =\n document.querySelector<HTMLButtonElement>(\n '[data-element=MobileMenuToggle][popovertarget=\"cookbook__sidebar\"]',\n ) ?? undefined;\n const desktop = matchMedia(\"(min-width: 50rem)\");\n const syncViewport = () => {\n if (desktop.matches) {\n if (this.matches(\":popover-open\")) this.hidePopover();\n this.#release();\n this.popover = null;\n this.removeAttribute(\"role\");\n this.removeAttribute(\"aria-modal\");\n } else {\n this.popover = \"auto\";\n this.setAttribute(\"role\", \"dialog\");\n this.setAttribute(\"aria-modal\", \"true\");\n }\n };\n syncViewport();\n desktop.addEventListener(\"change\", syncViewport, { signal });\n this.addEventListener(\n \"toggle\",\n () => {\n const open = !desktop.matches && this.matches(\":popover-open\");\n this.#trigger?.setAttribute(\"aria-expanded\", String(open));\n if (open) {\n // Establish the closed position after the popover enters the top\n // layer so its attribute change transitions from an actual layout.\n // Tasty's global SSR renderer does not preserve @starting-style.\n this.getBoundingClientRect();\n this.setAttribute(\"data-open\", \"\");\n for (const element of document.querySelectorAll<HTMLElement>(\n \"[data-element=HeaderFrame], [data-element=MainFrame], [data-element=SkipLink]\",\n )) {\n this.#inert.set(element, element.inert);\n element.inert = true;\n }\n // The browser focuses [autofocus] as the popover opens, but this\n // event arrives later; never pull back focus that moved on since.\n if (!this.contains(document.activeElement))\n this.querySelector<HTMLElement>(\"[autofocus]\")?.focus({\n preventScroll: true,\n });\n } else {\n const restoreFocus =\n this.contains(document.activeElement) ||\n document.activeElement === document.body;\n this.#release();\n if (restoreFocus && !desktop.matches) this.#trigger?.focus();\n }\n },\n { signal },\n );\n this.addEventListener(\n \"keydown\",\n (event) => {\n if (desktop.matches || !this.matches(\":popover-open\")) return;\n const sections = this.querySelector<HTMLDetailsElement>(\n \"[data-element=MobileNavigationTabs] details[open]\",\n );\n if (event.key === \"Escape\" && sections) {\n event.preventDefault();\n sections.open = false;\n sections.querySelector(\"summary\")?.focus();\n return;\n }\n if (event.key !== \"Tab\") return;\n const focusable = Array.from(\n this.querySelectorAll<HTMLElement>(\n 'a[href], button:not([disabled]), select:not([disabled]), input:not([disabled]), summary, [tabindex=\"0\"]',\n ),\n ).filter(\n (element) =>\n element.tabIndex >= 0 && element.getClientRects().length > 0,\n );\n const first = focusable[0];\n const last = focusable.at(-1);\n if (!first || !last) {\n event.preventDefault();\n this.focus();\n return;\n }\n if (\n event.shiftKey &&\n (document.activeElement === first || document.activeElement === this)\n ) {\n event.preventDefault();\n last.focus();\n } else if (!event.shiftKey && document.activeElement === last) {\n event.preventDefault();\n first.focus();\n }\n },\n { signal },\n );\n this.addEventListener(\n \"click\",\n (event) => {\n if (\n !event.defaultPrevented &&\n event.target instanceof Element &&\n event.target.closest(\"a[href]\") &&\n this.matches(\":popover-open\")\n )\n this.hidePopover();\n },\n { signal },\n );\n }\n\n #release() {\n this.removeAttribute(\"data-open\");\n for (const [element, inert] of this.#inert) element.inert = inert;\n this.#inert.clear();\n this.#trigger?.setAttribute(\"aria-expanded\", \"false\");\n }\n\n disconnectedCallback() {\n this.#listeners?.abort();\n this.#release();\n }\n}\n\nclass CookbookHeaderLinks extends HTMLElement {\n #listeners?: AbortController;\n connectedCallback() {\n this.#listeners?.abort();\n this.#listeners = new AbortController();\n const { signal } = this.#listeners;\n const panel = this.querySelector<HTMLElement>(\"[popover]\");\n const desktop = matchMedia(\"(min-width: 50rem)\");\n const close = () => {\n if (panel?.matches(\":popover-open\")) panel.hidePopover();\n };\n if (panel) initializePopoverMotion(panel, signal);\n desktop.addEventListener(\n \"change\",\n () => {\n if (desktop.matches) close();\n },\n { signal },\n );\n panel?.addEventListener(\n \"click\",\n (event) => {\n if (event.target instanceof Element && event.target.closest(\"a[href]\"))\n close();\n },\n { signal },\n );\n }\n disconnectedCallback() {\n this.#listeners?.abort();\n }\n}\n\nif (!customElements.get(\"cookbook-sidebar-pane\"))\n customElements.define(\"cookbook-sidebar-pane\", CookbookSidebarPane);\nif (!customElements.get(\"cookbook-header-links\"))\n customElements.define(\"cookbook-header-links\", CookbookHeaderLinks);\n"],"mappings":";;AAEA,IAAM,sBAAN,cAAkC,YAAY;CAC5C;CACA,yBAAS,IAAI,IAA0B;CACvC;CAEA,oBAAoB;EAClB,KAAK,YAAY,MAAM;EACvB,KAAK,aAAa,IAAI,gBAAgB;EACtC,MAAM,EAAE,WAAW,KAAK;EACxB,KAAK,WACH,SAAS,cACP,sEACF,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AAM,YAAY;EACzD;EACA,IAAI,OAAO,wBAAwB,OAAO,MAAM;EAChD,QAAQ,iBACN,gBACM;GACJ,IAAI,QAAQ,SAAS,MAAM;EAC7B,GACA,EAAE,OAAO,CACX;EACA,OAAO,iBACL,UACC,UAAU;GACT,IAAI,MAAM,kBAAkB,WAAW,MAAM,OAAO,QAAQ,SAAS,GACnE,MAAM;EACV,GACA,EAAE,OAAO,CACX;CACF;CACA,uBAAuB;EACrB,KAAK,YAAY,MAAM;CACzB;AACF;AAEA,IAAI,CAAC,eAAe,IAAI,uBAAuB,GAC7C,eAAe,OAAO,yBAAyB,mBAAmB;AACpE,IAAI,CAAC,eAAe,IAAI,uBAAuB,GAC7C,eAAe,OAAO,yBAAyB,mBAAmB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tenphi/renderer",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.1",
|
|
4
4
|
"description": "Astro renderer and Tasty theme for Cookbook",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -61,10 +61,12 @@
|
|
|
61
61
|
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
|
62
62
|
"@fontsource-variable/onest": "^5.3.0",
|
|
63
63
|
"@pagefind/default-ui": "1.5.2",
|
|
64
|
-
"@tenphi/docs": "0.30.
|
|
64
|
+
"@tenphi/docs": "0.30.1",
|
|
65
65
|
"@tenphi/eslint-plugin-tasty": "1.12.0",
|
|
66
66
|
"@tenphi/glaze": "2.0.1",
|
|
67
67
|
"@tenphi/tasty": "3.14.0",
|
|
68
|
+
"@uniaria/core": "0.3.0",
|
|
69
|
+
"@uniaria/elements": "0.3.0",
|
|
68
70
|
"beautiful-mermaid": "^1.1.3",
|
|
69
71
|
"hast-util-from-html": "^2.0.3",
|
|
70
72
|
"pagefind": "1.5.2",
|