@tenphi/renderer 0.27.0 → 0.30.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 (71) hide show
  1. package/README.md +6 -4
  2. package/dist/client/preview-height.d.ts +16 -0
  3. package/dist/client/preview-height.d.ts.map +1 -0
  4. package/dist/client/preview-height.js +31 -0
  5. package/dist/client/preview-height.js.map +1 -0
  6. package/dist/components/Banner.styles.js +1 -1
  7. package/dist/components/Button.styles.js +1 -1
  8. package/dist/components/Card.astro +3 -4
  9. package/dist/components/Card.styles.js +16 -25
  10. package/dist/components/Document.styles.js +19 -40
  11. package/dist/components/Footer.styles.js +5 -5
  12. package/dist/components/Header.styles.js +2 -2
  13. package/dist/components/HeaderFrame.styles.js +1 -1
  14. package/dist/components/HeaderLinks.styles.js +25 -15
  15. package/dist/components/Hero.styles.js +8 -8
  16. package/dist/components/LanguageSelect.styles.js +5 -6
  17. package/dist/components/MainContent.styles.js +6 -8
  18. package/dist/components/MainPane.styles.js +2 -2
  19. package/dist/components/MarkdownAlert.styles.js +13 -13
  20. package/dist/components/MarkdownCodeBlock.styles.js +7 -10
  21. package/dist/components/MarkdownContent.styles.js +11 -17
  22. package/dist/components/MarkdownHeading.styles.js +4 -6
  23. package/dist/components/MarkdownInlineCode.styles.js +1 -1
  24. package/dist/components/MarkdownTable.styles.js +7 -10
  25. package/dist/components/Mermaid.styles.js +2 -2
  26. package/dist/components/MermaidSource.styles.js +1 -1
  27. package/dist/components/MobileMenuFooter.styles.js +5 -5
  28. package/dist/components/MobileMenuToggle.styles.js +2 -2
  29. package/dist/components/MobileNavigationTabs.styles.js +9 -10
  30. package/dist/components/MobileTableOfContents.styles.js +7 -7
  31. package/dist/components/PackageVersion.styles.js +1 -1
  32. package/dist/components/PageActions.styles.js +3 -3
  33. package/dist/components/PageFrame.styles.js +1 -1
  34. package/dist/components/Pagination.styles.js +13 -18
  35. package/dist/components/Preview.astro +7 -0
  36. package/dist/components/Preview.styles.js +10 -4
  37. package/dist/components/Search.styles.js +7 -8
  38. package/dist/components/SearchButton.styles.js +13 -5
  39. package/dist/components/SearchResults.styles.js +20 -20
  40. package/dist/components/Sidebar.styles.js +17 -19
  41. package/dist/components/SkipLink.styles.js +4 -3
  42. package/dist/components/SocialIcons.styles.js +1 -1
  43. package/dist/components/Steps.styles.js +3 -3
  44. package/dist/components/TableOfContents.styles.js +3 -3
  45. package/dist/components/TableOfContentsLayout.styles.js +2 -2
  46. package/dist/components/ThemeSelect.styles.js +16 -16
  47. package/dist/components/TopNavigation.styles.js +1 -3
  48. package/dist/components/VersionSwitcher.styles.js +4 -4
  49. package/dist/components/props.d.ts +2 -0
  50. package/dist/components/props.d.ts.map +1 -1
  51. package/dist/components/props.ts +2 -0
  52. package/dist/components/select-popover-styles.js +14 -14
  53. package/dist/define-component.d.ts.map +1 -1
  54. package/dist/define-component.js +20 -1
  55. package/dist/define-component.js.map +1 -0
  56. package/dist/eslint-plugin.d.ts +0 -5
  57. package/dist/eslint-plugin.d.ts.map +1 -1
  58. package/dist/eslint-plugin.js +0 -5
  59. package/dist/eslint-plugin.js.map +1 -1
  60. package/dist/index.js.map +1 -1
  61. package/dist/preview-document.d.ts +16 -3
  62. package/dist/preview-document.d.ts.map +1 -1
  63. package/dist/preview-document.js +31 -9
  64. package/dist/preview-document.js.map +1 -1
  65. package/dist/styling.js +2 -2
  66. package/dist/styling.js.map +1 -1
  67. package/package.json +4 -4
  68. package/dist/components/inherit-component-parts.d.ts +0 -1
  69. package/dist/components/inherit-component-parts.js +0 -7
  70. package/dist/define-component-BP4YwMak.js +0 -28
  71. package/dist/define-component-BP4YwMak.js.map +0 -1
@@ -1,16 +1,29 @@
1
1
  import { PreviewProps } from "./components/props.js";
2
2
  //#region src/preview-document.d.ts
3
+ /**
4
+ * Runs first in a preview frame that allows scripts, so it keeps `parent` even
5
+ * if authored code declares its own. It measures the root element's box rather
6
+ * than `scrollHeight`, which never drops below the frame's own height: the
7
+ * root's height follows the content, so the frame can shrink, and growing the
8
+ * frame doesn't change the measurement. A horizontal scrollbar, if any, is
9
+ * added so that it doesn't overflow the content vertically. The frame's origin
10
+ * is opaque, so the message is posted to any origin.
11
+ */
12
+ declare const previewHeightReporter = "{\nconst root = document.documentElement;\nconst page = parent;\nconst report = () => page.postMessage({ type: \"cookbook:preview-height\", height: root.getBoundingClientRect().height + window.innerHeight - root.clientHeight }, \"*\");\nnew ResizeObserver(report).observe(root);\naddEventListener(\"message\", (event) => { if (event.data?.type === \"cookbook:preview-height\") report(); });\n}";
3
13
  /**
4
14
  * Build a Preview's frame document, its "View source" text and the frame's
5
15
  * settings. Public scripts are inlined so they run in the opaque-origin sandbox
6
- * without a request.
16
+ * without a request. A frame that runs scripts also reports its content height
17
+ * so the page can size it, adding the buffer; a frame without scripts keeps its
18
+ * minimum height, and nothing measures its content to add a buffer to.
7
19
  */
8
- declare function buildPreview({ html, css, javascript, scripts, height }: Omit<PreviewProps, "title">, publicDir: string, page: string): Promise<{
20
+ declare function buildPreview({ html, css, javascript, scripts, height, buffer }: Omit<PreviewProps, "title">, publicDir: string, page: string): Promise<{
9
21
  document: string;
10
22
  source: string;
11
23
  sandbox: string;
12
24
  height: string | undefined;
25
+ buffer: string | undefined;
13
26
  }>;
14
27
  //#endregion
15
- export { buildPreview };
28
+ export { buildPreview, previewHeightReporter };
16
29
  //# sourceMappingURL=preview-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-document.d.ts","names":[],"sources":["../src/preview-document.ts"],"mappings":";;;;;;;iBAcsB,eAElB,MACA,KACA,YACA,SACA,UACC,KAAK,wBACR,mBACA,eAAY"}
1
+ {"version":3,"file":"preview-document.d.ts","names":[],"sources":["../src/preview-document.ts"],"mappings":";;;;;;;;;;;cAmBa;;;;;;;;iBAeS,eAElB,MACA,KACA,YACA,SACA,QACA,UACC,KAAK,wBACR,mBACA,eAAY"}
@@ -1,22 +1,44 @@
1
+ import { PREVIEW_HEIGHT_MESSAGE } from "./client/preview-height.js";
1
2
  import { readFile } from "node:fs/promises";
2
3
  import { join } from "node:path";
3
4
  //#region src/preview-document.ts
4
5
  const CSS_LENGTH = /^(?:\d+|\d*\.\d+)(?:px|r?em|ch|ex|r?lh|[dls]?v(?:h|w|min|max)|cm|mm|in|pt|pc)$/;
5
6
  /**
7
+ * Runs first in a preview frame that allows scripts, so it keeps `parent` even
8
+ * if authored code declares its own. It measures the root element's box rather
9
+ * than `scrollHeight`, which never drops below the frame's own height: the
10
+ * root's height follows the content, so the frame can shrink, and growing the
11
+ * frame doesn't change the measurement. A horizontal scrollbar, if any, is
12
+ * added so that it doesn't overflow the content vertically. The frame's origin
13
+ * is opaque, so the message is posted to any origin.
14
+ */
15
+ const previewHeightReporter = `{
16
+ const root = document.documentElement;
17
+ const page = parent;
18
+ const report = () => page.postMessage({ type: "${PREVIEW_HEIGHT_MESSAGE}", height: root.getBoundingClientRect().height + window.innerHeight - root.clientHeight }, "*");
19
+ new ResizeObserver(report).observe(root);
20
+ addEventListener("message", (event) => { if (event.data?.type === "${PREVIEW_HEIGHT_MESSAGE}") report(); });
21
+ }`;
22
+ /**
6
23
  * Build a Preview's frame document, its "View source" text and the frame's
7
24
  * settings. Public scripts are inlined so they run in the opaque-origin sandbox
8
- * without a request.
25
+ * without a request. A frame that runs scripts also reports its content height
26
+ * so the page can size it, adding the buffer; a frame without scripts keeps its
27
+ * minimum height, and nothing measures its content to add a buffer to.
9
28
  */
10
- async function buildPreview({ html = "", css = "", javascript, scripts = [], height }, publicDir, page) {
11
- if (height !== void 0 && !CSS_LENGTH.test(height)) throw Error(`Preview on ${page}: height ${height} must be a CSS length, such as 18rem or 320px.`);
29
+ async function buildPreview({ html = "", css = "", javascript, scripts = [], height, buffer }, publicDir, page) {
30
+ for (const [name, value] of [["height", height], ["buffer", buffer]]) if (value !== void 0 && !CSS_LENGTH.test(value)) throw Error(`Preview on ${page}: ${name} ${value} must be a CSS length, such as 18rem or 320px.`);
12
31
  const files = await Promise.all(scripts.map((src) => readPublicScript(src, publicDir, page)));
13
- const markup = `<!doctype html><meta charset="utf-8"><style>${css}</style>${html}`;
32
+ const head = "<!doctype html><meta charset=\"utf-8\">";
33
+ const body = `<style>${css}</style>${html}`;
14
34
  const authored = javascript ? inlineScript(javascript) : "";
35
+ const runsScripts = Boolean(scripts.length || javascript);
15
36
  return {
16
- document: markup + files.map(inlineScript).join("") + authored,
17
- source: markup + scripts.map((src) => `<script src="${src}"><\/script>`).join("") + authored,
18
- sandbox: scripts.length || javascript ? "allow-forms allow-scripts" : "allow-forms",
19
- height
37
+ document: head + (runsScripts ? inlineScript(previewHeightReporter) : "") + body + files.map(inlineScript).join("") + authored,
38
+ source: head + body + scripts.map((src) => `<script src="${src}"><\/script>`).join("") + authored,
39
+ sandbox: runsScripts ? "allow-forms allow-scripts" : "allow-forms",
40
+ height,
41
+ buffer: runsScripts ? buffer : void 0
20
42
  };
21
43
  }
22
44
  function inlineScript(code) {
@@ -32,6 +54,6 @@ async function readPublicScript(src, publicDir, page) {
32
54
  }
33
55
  }
34
56
  //#endregion
35
- export { buildPreview };
57
+ export { buildPreview, previewHeightReporter };
36
58
 
37
59
  //# sourceMappingURL=preview-document.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview-document.js","names":[],"sources":["../src/preview-document.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { PreviewProps } from \"./components/props.js\";\n\n// The frame's height becomes generated CSS, so accept only a plain length.\n// Percentages are rejected because the frame's container has no fixed height.\nconst CSS_LENGTH =\n /^(?:\\d+|\\d*\\.\\d+)(?:px|r?em|ch|ex|r?lh|[dls]?v(?:h|w|min|max)|cm|mm|in|pt|pc)$/;\n\n/**\n * Build a Preview's frame document, its \"View source\" text and the frame's\n * settings. Public scripts are inlined so they run in the opaque-origin sandbox\n * without a request.\n */\nexport async function buildPreview(\n {\n html = \"\",\n css = \"\",\n javascript,\n scripts = [],\n height,\n }: Omit<PreviewProps, \"title\">,\n publicDir: string,\n page: string,\n) {\n if (height !== undefined && !CSS_LENGTH.test(height))\n throw Error(\n `Preview on ${page}: height ${height} must be a CSS length, such as 18rem or 320px.`,\n );\n const files = await Promise.all(\n scripts.map((src) => readPublicScript(src, publicDir, page)),\n );\n const markup = `<!doctype html><meta charset=\"utf-8\"><style>${css}</style>${html}`;\n const authored = javascript ? inlineScript(javascript) : \"\";\n return {\n document: markup + files.map(inlineScript).join(\"\") + authored,\n source:\n markup +\n scripts.map((src) => `<script src=\"${src}\"></script>`).join(\"\") +\n authored,\n // A submitted form can navigate only the frame itself, as a link can.\n sandbox:\n scripts.length || javascript\n ? \"allow-forms allow-scripts\"\n : \"allow-forms\",\n height,\n };\n}\n\n// The HTML parser ends a script at the first `</script`, even inside a string.\nfunction inlineScript(code: string) {\n return `<script>${code.replace(/<\\/(script)/gi, \"<\\\\/$1\")}</script>`;\n}\n\nasync function readPublicScript(src: string, publicDir: string, page: string) {\n const error = `Preview on ${page}: script ${src} must be a readable file in the site's public directory, such as /demo/button.js.`;\n if (!/^\\/(?!\\/)/.test(src) || src.split(/[\\\\/]/).includes(\"..\"))\n throw Error(error);\n try {\n return await readFile(join(publicDir, src), \"utf8\");\n } catch {\n throw Error(error);\n }\n}\n"],"mappings":";;;AAMA,MAAM,aACJ;;;;;;AAOF,eAAsB,aACpB,EACE,OAAO,IACP,MAAM,IACN,YACA,UAAU,CAAC,GACX,UAEF,WACA,MACA;CACA,IAAI,WAAW,KAAA,KAAa,CAAC,WAAW,KAAK,MAAM,GACjD,MAAM,MACJ,cAAc,KAAK,WAAW,OAAO,+CACvC;CACF,MAAM,QAAQ,MAAM,QAAQ,IAC1B,QAAQ,KAAK,QAAQ,iBAAiB,KAAK,WAAW,IAAI,CAAC,CAC7D;CACA,MAAM,SAAS,+CAA+C,IAAI,UAAU;CAC5E,MAAM,WAAW,aAAa,aAAa,UAAU,IAAI;CACzD,OAAO;EACL,UAAU,SAAS,MAAM,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,IAAI;EACtD,QACE,SACA,QAAQ,KAAK,QAAQ,gBAAgB,IAAI,aAAY,CAAC,CAAC,KAAK,EAAE,IAC9D;EAEF,SACE,QAAQ,UAAU,aACd,8BACA;EACN;CACF;AACF;AAGA,SAAS,aAAa,MAAc;CAClC,OAAO,WAAW,KAAK,QAAQ,iBAAiB,QAAQ,EAAE;AAC5D;AAEA,eAAe,iBAAiB,KAAa,WAAmB,MAAc;CAC5E,MAAM,QAAQ,cAAc,KAAK,WAAW,IAAI;CAChD,IAAI,CAAC,YAAY,KAAK,GAAG,KAAK,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAC5D,MAAM,MAAM,KAAK;CACnB,IAAI;EACF,OAAO,MAAM,SAAS,KAAK,WAAW,GAAG,GAAG,MAAM;CACpD,QAAQ;EACN,MAAM,MAAM,KAAK;CACnB;AACF"}
1
+ {"version":3,"file":"preview-document.js","names":[],"sources":["../src/preview-document.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { PREVIEW_HEIGHT_MESSAGE } from \"./client/preview-height.js\";\nimport type { PreviewProps } from \"./components/props.js\";\n\n// The frame's height and buffer become CSS, so accept only a plain length.\n// Percentages are rejected because the frame's container has no fixed height.\nconst CSS_LENGTH =\n /^(?:\\d+|\\d*\\.\\d+)(?:px|r?em|ch|ex|r?lh|[dls]?v(?:h|w|min|max)|cm|mm|in|pt|pc)$/;\n\n/**\n * Runs first in a preview frame that allows scripts, so it keeps `parent` even\n * if authored code declares its own. It measures the root element's box rather\n * than `scrollHeight`, which never drops below the frame's own height: the\n * root's height follows the content, so the frame can shrink, and growing the\n * frame doesn't change the measurement. A horizontal scrollbar, if any, is\n * added so that it doesn't overflow the content vertically. The frame's origin\n * is opaque, so the message is posted to any origin.\n */\nexport const previewHeightReporter = `{\nconst root = document.documentElement;\nconst page = parent;\nconst report = () => page.postMessage({ type: \"${PREVIEW_HEIGHT_MESSAGE}\", height: root.getBoundingClientRect().height + window.innerHeight - root.clientHeight }, \"*\");\nnew ResizeObserver(report).observe(root);\naddEventListener(\"message\", (event) => { if (event.data?.type === \"${PREVIEW_HEIGHT_MESSAGE}\") report(); });\n}`;\n\n/**\n * Build a Preview's frame document, its \"View source\" text and the frame's\n * settings. Public scripts are inlined so they run in the opaque-origin sandbox\n * without a request. A frame that runs scripts also reports its content height\n * so the page can size it, adding the buffer; a frame without scripts keeps its\n * minimum height, and nothing measures its content to add a buffer to.\n */\nexport async function buildPreview(\n {\n html = \"\",\n css = \"\",\n javascript,\n scripts = [],\n height,\n buffer,\n }: Omit<PreviewProps, \"title\">,\n publicDir: string,\n page: string,\n) {\n for (const [name, value] of [\n [\"height\", height],\n [\"buffer\", buffer],\n ])\n if (value !== undefined && !CSS_LENGTH.test(value))\n throw Error(\n `Preview on ${page}: ${name} ${value} must be a CSS length, such as 18rem or 320px.`,\n );\n const files = await Promise.all(\n scripts.map((src) => readPublicScript(src, publicDir, page)),\n );\n const head = '<!doctype html><meta charset=\"utf-8\">';\n const body = `<style>${css}</style>${html}`;\n const authored = javascript ? inlineScript(javascript) : \"\";\n const runsScripts = Boolean(scripts.length || javascript);\n return {\n // The height reporter runs first, before authored code can shadow `parent`.\n document:\n head +\n (runsScripts ? inlineScript(previewHeightReporter) : \"\") +\n body +\n files.map(inlineScript).join(\"\") +\n authored,\n source:\n head +\n body +\n scripts.map((src) => `<script src=\"${src}\"></script>`).join(\"\") +\n authored,\n // A submitted form can navigate only the frame itself, as a link can.\n sandbox: runsScripts ? \"allow-forms allow-scripts\" : \"allow-forms\",\n height,\n buffer: runsScripts ? buffer : undefined,\n };\n}\n\n// The HTML parser ends a script at the first `</script`, even inside a string.\nfunction inlineScript(code: string) {\n return `<script>${code.replace(/<\\/(script)/gi, \"<\\\\/$1\")}</script>`;\n}\n\nasync function readPublicScript(src: string, publicDir: string, page: string) {\n const error = `Preview on ${page}: script ${src} must be a readable file in the site's public directory, such as /demo/button.js.`;\n if (!/^\\/(?!\\/)/.test(src) || src.split(/[\\\\/]/).includes(\"..\"))\n throw Error(error);\n try {\n return await readFile(join(publicDir, src), \"utf8\");\n } catch {\n throw Error(error);\n }\n}\n"],"mappings":";;;;AAOA,MAAM,aACJ;;;;;;;;;;AAWF,MAAa,wBAAwB;;;iDAGY,uBAAuB;;qEAEH,uBAAuB;;;;;;;;;AAU5F,eAAsB,aACpB,EACE,OAAO,IACP,MAAM,IACN,YACA,UAAU,CAAC,GACX,QACA,UAEF,WACA,MACA;CACA,KAAK,MAAM,CAAC,MAAM,UAAU,CAC1B,CAAC,UAAU,MAAM,GACjB,CAAC,UAAU,MAAM,CACnB,GACE,IAAI,UAAU,KAAA,KAAa,CAAC,WAAW,KAAK,KAAK,GAC/C,MAAM,MACJ,cAAc,KAAK,IAAI,KAAK,GAAG,MAAM,+CACvC;CACJ,MAAM,QAAQ,MAAM,QAAQ,IAC1B,QAAQ,KAAK,QAAQ,iBAAiB,KAAK,WAAW,IAAI,CAAC,CAC7D;CACA,MAAM,OAAO;CACb,MAAM,OAAO,UAAU,IAAI,UAAU;CACrC,MAAM,WAAW,aAAa,aAAa,UAAU,IAAI;CACzD,MAAM,cAAc,QAAQ,QAAQ,UAAU,UAAU;CACxD,OAAO;EAEL,UACE,QACC,cAAc,aAAa,qBAAqB,IAAI,MACrD,OACA,MAAM,IAAI,YAAY,CAAC,CAAC,KAAK,EAAE,IAC/B;EACF,QACE,OACA,OACA,QAAQ,KAAK,QAAQ,gBAAgB,IAAI,aAAY,CAAC,CAAC,KAAK,EAAE,IAC9D;EAEF,SAAS,cAAc,8BAA8B;EACrD;EACA,QAAQ,cAAc,SAAS,KAAA;CACjC;AACF;AAGA,SAAS,aAAa,MAAc;CAClC,OAAO,WAAW,KAAK,QAAQ,iBAAiB,QAAQ,EAAE;AAC5D;AAEA,eAAe,iBAAiB,KAAa,WAAmB,MAAc;CAC5E,MAAM,QAAQ,cAAc,KAAK,WAAW,IAAI;CAChD,IAAI,CAAC,YAAY,KAAK,GAAG,KAAK,IAAI,MAAM,OAAO,CAAC,CAAC,SAAS,IAAI,GAC5D,MAAM,MAAM,KAAK;CACnB,IAAI;EACF,OAAO,MAAM,SAAS,KAAK,WAAW,GAAG,GAAG,MAAM;CACpD,QAAQ;EACN,MAAM,MAAM,KAAK;CACnB;AACF"}
package/dist/styling.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as resolveComponentStyles } from "./component-styles-DstqPFf3.js";
2
2
  import { t as configureCookbookStates } from "./tasty-states-BIgiJQ3N.js";
3
- import { n as extendComponent, t as defineComponent } from "./define-component-BP4YwMak.js";
3
+ import { defineComponent, extendComponent } from "./define-component.js";
4
4
  import { mergeStyles, tasty, useGlobalStyles } from "@tenphi/tasty";
5
5
  //#region src/components/Button.styles.js
6
6
  /** Shared button foundation; descendants own their layout and interaction anatomy. */
@@ -9,7 +9,7 @@ const Button = defineComponent("Button", {
9
9
  styles: {
10
10
  display: "flex",
11
11
  alignItems: "center",
12
- gap: "$gap",
12
+ gap: "1x",
13
13
  blockSize: "min 0",
14
14
  color: "#text-soft",
15
15
  cursor: "pointer"
@@ -1 +1 @@
1
- {"version":3,"file":"styling.js","names":[],"sources":["../src/components/Button.styles.js","../src/styling.ts"],"sourcesContent":["import { defineComponent } from \"../define-component.js\";\n\n/** Shared button foundation; descendants own their layout and interaction anatomy. */\nexport const Button = defineComponent(\"Button\", {\n as: \"button\",\n styles: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"$gap\",\n blockSize: \"min 0\",\n color: \"#text-soft\",\n cursor: \"pointer\",\n },\n});\n","import { configureCookbookStates } from \"./components/tasty-states.js\";\n\n// Consumer components can be evaluated before Cookbook's own components.\nconfigureCookbookStates();\n\nexport { tasty, useGlobalStyles, mergeStyles } from \"@tenphi/tasty\";\nexport type { Styles } from \"@tenphi/tasty\";\nexport { defineComponent, extendComponent } from \"./define-component.js\";\nexport { Button } from \"./components/Button.styles.js\";\nexport { resolveComponentStyles } from \"./components/component-styles.js\";\n"],"mappings":";;;;;;AAGA,MAAa,SAAS,gBAAgB,UAAU;CAC9C,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,KAAK;EACL,WAAW;EACX,OAAO;EACP,QAAQ;CACV;AACF,CAAC;;;ACVD,wBAAwB"}
1
+ {"version":3,"file":"styling.js","names":[],"sources":["../src/components/Button.styles.js","../src/styling.ts"],"sourcesContent":["import { defineComponent } from \"../define-component.js\";\n\n/** Shared button foundation; descendants own their layout and interaction anatomy. */\nexport const Button = defineComponent(\"Button\", {\n as: \"button\",\n styles: {\n display: \"flex\",\n alignItems: \"center\",\n gap: \"1x\",\n blockSize: \"min 0\",\n color: \"#text-soft\",\n cursor: \"pointer\",\n },\n});\n","import { configureCookbookStates } from \"./components/tasty-states.js\";\n\n// Consumer components can be evaluated before Cookbook's own components.\nconfigureCookbookStates();\n\nexport { tasty, useGlobalStyles, mergeStyles } from \"@tenphi/tasty\";\nexport type { Styles } from \"@tenphi/tasty\";\nexport { defineComponent, extendComponent } from \"./define-component.js\";\nexport { Button } from \"./components/Button.styles.js\";\nexport { resolveComponentStyles } from \"./components/component-styles.js\";\n"],"mappings":";;;;;;AAGA,MAAa,SAAS,gBAAgB,UAAU;CAC9C,IAAI;CACJ,QAAQ;EACN,SAAS;EACT,YAAY;EACZ,KAAK;EACL,WAAW;EACX,OAAO;EACP,QAAQ;CACV;AACF,CAAC;;;ACVD,wBAAwB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tenphi/renderer",
3
- "version": "0.27.0",
3
+ "version": "0.30.0",
4
4
  "description": "Astro renderer and Tasty theme for Cookbook",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -61,10 +61,10 @@
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.27.0",
65
- "@tenphi/eslint-plugin-tasty": "1.6.0",
64
+ "@tenphi/docs": "0.30.0",
65
+ "@tenphi/eslint-plugin-tasty": "1.12.0",
66
66
  "@tenphi/glaze": "2.0.1",
67
- "@tenphi/tasty": "3.9.10",
67
+ "@tenphi/tasty": "3.14.0",
68
68
  "beautiful-mermaid": "^1.1.3",
69
69
  "hast-util-from-html": "^2.0.3",
70
70
  "pagefind": "1.5.2",
@@ -1 +0,0 @@
1
- export function inheritComponentParts<T>(base: object, extended: T): T;
@@ -1,7 +0,0 @@
1
- /** Tasty wrappers forward styles but do not copy compound component exports. */
2
- export function inheritComponentParts(base, extended) {
3
- for (const [name, part] of Object.entries(base)) {
4
- if (/^[A-Z]/.test(name)) extended[name] = part;
5
- }
6
- return extended;
7
- }
@@ -1,28 +0,0 @@
1
- import { n as resolveComponentStyles } from "./component-styles-DstqPFf3.js";
2
- import { tasty } from "@tenphi/tasty";
3
- //#region src/components/inherit-component-parts.js
4
- /** Tasty wrappers forward styles but do not copy compound component exports. */
5
- function inheritComponentParts(base, extended) {
6
- for (const [name, part] of Object.entries(base)) if (/^[A-Z]/.test(name)) extended[name] = part;
7
- return extended;
8
- }
9
- //#endregion
10
- //#region src/define-component.ts
11
- /** Extend a component's styles and defaults, preserving its props and compound parts. */
12
- function extendComponent(name, base, options) {
13
- return inheritComponentParts(base, tasty(base, {
14
- ...options,
15
- styles: resolveComponentStyles(name, options.styles ?? {})
16
- }));
17
- }
18
- /** Create a named component with its built-in or custom theme styles merged into its defaults. */
19
- function defineComponent(name, options) {
20
- return tasty({
21
- ...options,
22
- styles: resolveComponentStyles(name, options.styles ?? {})
23
- });
24
- }
25
- //#endregion
26
- export { extendComponent as n, defineComponent as t };
27
-
28
- //# sourceMappingURL=define-component-BP4YwMak.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"define-component-BP4YwMak.js","names":[],"sources":["../src/components/inherit-component-parts.js","../src/define-component.ts"],"sourcesContent":["/** Tasty wrappers forward styles but do not copy compound component exports. */\nexport function inheritComponentParts(base, extended) {\n for (const [name, part] of Object.entries(base)) {\n if (/^[A-Z]/.test(name)) extended[name] = part;\n }\n return extended;\n}\n","import {\n tasty,\n type ElementsDefinition,\n type ModPropsInput,\n type StylesInterface,\n type Styles,\n type SubElementProps,\n type TastyElementOptions,\n type TastyPolymorphicComponent,\n type TokenPropsInput,\n type VariantMap,\n} from \"@tenphi/tasty\";\nimport type {\n ComponentProps,\n ComponentType,\n ElementType,\n ForwardRefExoticComponent,\n JSX,\n PropsWithoutRef,\n RefAttributes,\n} from \"react\";\nimport { resolveComponentStyles } from \"./components/component-styles.js\";\nimport { inheritComponentParts } from \"./components/inherit-component-parts.js\";\n\ntype InheritedParts<C> = {\n [\n Name in keyof C as Name extends string\n ? Name extends Capitalize<Name>\n ? C[Name] extends ComponentType<any>\n ? Name\n : never\n : never\n : never\n ]: C[Name];\n};\n\ntype SubElementTag<Definition extends ElementsDefinition[string]> =\n Definition extends string\n ? Definition\n : Definition extends { as?: infer Tag }\n ? Tag extends keyof JSX.IntrinsicElements\n ? Tag\n : \"div\"\n : \"div\";\n\n// Use public Tasty types so declarations do not leak its private sub-element aliases.\ntype SubElements<E extends ElementsDefinition> = {\n [Name in keyof E]: ForwardRefExoticComponent<\n PropsWithoutRef<SubElementProps<SubElementTag<E[Name]>>> &\n RefAttributes<\n SubElementTag<E[Name]> extends keyof HTMLElementTagNameMap\n ? HTMLElementTagNameMap[SubElementTag<E[Name]>]\n : unknown\n >\n >;\n};\n\n/** Extend a component's styles and defaults, preserving its props and compound parts. */\nexport function extendComponent<C extends ComponentType<any>>(\n name: string,\n base: C,\n options: Partial<Omit<ComponentProps<C>, \"as\" | \"styles\">> & {\n styles?: Styles;\n },\n): ComponentType<ComponentProps<C>> & InheritedParts<C> {\n const extended = tasty(base, {\n ...options,\n styles: resolveComponentStyles(name, options.styles ?? {}),\n });\n // Tasty's wrapper type erases compound exports and makes every prop optional.\n // Restore the copied parts and conservatively keep the base's required props.\n return inheritComponentParts(base, extended) as unknown as ComponentType<\n ComponentProps<C>\n > &\n InheritedParts<C>;\n}\n\n/** Create a named component with its built-in or custom theme styles merged into its defaults. */\nexport function defineComponent<\n K extends readonly (keyof StylesInterface)[],\n V extends VariantMap,\n E extends ElementsDefinition = Record<string, never>,\n AsType extends ElementType = \"div\",\n M extends ModPropsInput = readonly never[],\n TP extends TokenPropsInput = readonly never[],\n>(\n name: string,\n options: TastyElementOptions<K, V, E, AsType, M, TP>,\n): TastyPolymorphicComponent<AsType, K, V, M, TP> & SubElements<E> {\n return tasty<K, V, E, AsType, M, TP>({\n ...options,\n styles: resolveComponentStyles(name, options.styles ?? {}),\n }) as TastyPolymorphicComponent<AsType, K, V, M, TP> & SubElements<E>;\n}\n"],"mappings":";;;;AACA,SAAgB,sBAAsB,MAAM,UAAU;CACpD,KAAK,MAAM,CAAC,MAAM,SAAS,OAAO,QAAQ,IAAI,GAC5C,IAAI,SAAS,KAAK,IAAI,GAAG,SAAS,QAAQ;CAE5C,OAAO;AACT;;;;ACoDA,SAAgB,gBACd,MACA,MACA,SAGsD;CAOtD,OAAO,sBAAsB,MANZ,MAAM,MAAM;EAC3B,GAAG;EACH,QAAQ,uBAAuB,MAAM,QAAQ,UAAU,CAAC,CAAC;CAC3D,CAGmC,CAAQ;AAI7C;;AAGA,SAAgB,gBAQd,MACA,SACiE;CACjE,OAAO,MAA8B;EACnC,GAAG;EACH,QAAQ,uBAAuB,MAAM,QAAQ,UAAU,CAAC,CAAC;CAC3D,CAAC;AACH"}