@takazudo/zudo-sg 0.4.1 → 0.5.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 (63) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +48 -61
  3. package/dist/catalog/catalog-thumb.d.ts +1 -6
  4. package/dist/catalog/catalog-thumb.js +1 -2
  5. package/dist/catalog/component-thumb.d.ts +1 -6
  6. package/dist/catalog/component-thumb.js +8 -7
  7. package/dist/catalog/descriptor-thumb.d.ts +1 -6
  8. package/dist/catalog/descriptor-thumb.js +1 -2
  9. package/dist/chrome/_styleguide-layout.d.ts +8 -9
  10. package/dist/chrome/_styleguide-layout.js +3 -6
  11. package/dist/chrome/panel-scripts.d.ts +1 -3
  12. package/dist/chrome/panel-scripts.js +3 -3
  13. package/dist/cli/scaffold/component-scaffold.js +35 -16
  14. package/dist/code-panel/code-panel.d.ts +2 -8
  15. package/dist/code-panel/code-panel.js +34 -35
  16. package/dist/code-panel/copy-button.d.ts +1 -7
  17. package/dist/code-panel/copy-button.js +31 -48
  18. package/dist/code-panel/copy-text.d.ts +1 -0
  19. package/dist/code-panel/copy-text.js +26 -0
  20. package/dist/code-panel/source-editor.d.ts +1 -2
  21. package/dist/code-panel/source-editor.js +17 -18
  22. package/dist/config/index.d.ts +2 -0
  23. package/dist/config/index.js +6 -1
  24. package/dist/config/wind.d.ts +265 -0
  25. package/dist/config/wind.js +133 -0
  26. package/dist/plugins/preview-css.d.ts +9 -7
  27. package/dist/plugins/preview-css.js +58 -37
  28. package/dist/preview/detail-workbench.d.ts +2 -6
  29. package/dist/preview/detail-workbench.js +100 -65
  30. package/dist/preview/index.d.ts +4 -2
  31. package/dist/preview/index.js +7 -7
  32. package/dist/preview/preview-app.d.ts +2 -5
  33. package/dist/preview/preview-app.js +76 -46
  34. package/dist/preview/variant-frame-config.d.ts +47 -0
  35. package/dist/preview/variant-frame-config.js +50 -0
  36. package/dist/preview/variant-frame.d.ts +9 -53
  37. package/dist/preview/variant-frame.js +158 -149
  38. package/dist/preview-css/compile.d.ts +15 -29
  39. package/dist/preview-css/compile.js +183 -31
  40. package/dist/search/catalog-filter.d.ts +2 -6
  41. package/dist/search/catalog-filter.js +50 -42
  42. package/dist/stories/types.d.ts +5 -3
  43. package/dist/token-dashboard/create-token-dashboards.d.ts +3 -5
  44. package/dist/token-dashboard/create-token-dashboards.js +14 -44
  45. package/dist/token-dashboard/dashboard-inventory.d.ts +1 -1
  46. package/dist/token-dashboard/token-dashboard-adapter.d.ts +2 -0
  47. package/dist/token-dashboard/token-dashboard-adapter.js +9 -0
  48. package/dist/token-dashboard/token-dashboard-mount.d.ts +6 -0
  49. package/dist/token-dashboard/token-dashboard-mount.js +33 -0
  50. package/dist/token-tweak/preview-token-panel-bootstrap.d.ts +1 -6
  51. package/dist/token-tweak/preview-token-panel-bootstrap.js +4 -2
  52. package/dist/token-tweak/preview-tokens-button.d.ts +1 -5
  53. package/dist/token-tweak/preview-tokens-button.js +5 -4
  54. package/dist/wind.json +119 -0
  55. package/package.json +14 -18
  56. package/routes-src/_chrome.tsx +1 -3
  57. package/routes-src/_preview-app.tsx +3 -8
  58. package/routes-src/components-index.tsx +5 -10
  59. package/routes-src/components-preview.tsx +3 -9
  60. package/routes-src/components-slug.tsx +21 -24
  61. package/routes-src/tokens.tsx +4 -9
  62. package/styles.css +17 -11
  63. package/dist/safelist.css +0 -2
package/CHANGELOG.md CHANGED
@@ -4,6 +4,41 @@ All notable changes to `@takazudo/zudo-sg` are documented in this file.
4
4
 
5
5
  The format is based on Keep a Changelog, and release notes are generated from the changelog MDX pages.
6
6
 
7
+ ## [0.5.0] - 2026-10-12
8
+
9
+ This release ports the styleguide engine to zfb 4.3.1 and zudo-doc 6.0.0.
10
+ Catalog, preview, descriptor mode, and token editing remain available on the
11
+ new renderer and CSS pipeline.
12
+
13
+ ### Breaking Changes
14
+
15
+ - Hosts must use zfb 4.3.1 or later in the 4.x line, zudo-doc 6.0.0 or later in
16
+ the 6.x line, and zdtp 0.8.6 or later in the 0.8.x line. Story renderers and
17
+ engine route components use zudo-react instead of Preact. Hosts should follow
18
+ the zfb 4 and zudo-doc 6 migration guides before upgrading.
19
+ - The engine now publishes a `wind.json` utility manifest in place of its
20
+ Tailwind safelist stylesheet. Host wind configuration must include the engine
21
+ manifest and its declared CSS variables; the old Tailwind source and theme
22
+ directives no longer generate engine utilities.
23
+
24
+ ### Features
25
+
26
+ - Render the catalog, thumbnails, detail workbench, preview frames, and search
27
+ islands with zudo-react. Descriptor mode and external preview routes retain
28
+ their framework-free data and message contracts.
29
+ - Compile the isolated preview stylesheet through the `zfb css` CLI with
30
+ preview-root scoping, preserving the preview URL and host override behavior.
31
+ - Keep `/tokens` available through a client-mounted zdtp dashboard adapter with
32
+ a truthful server-rendered loading shell. The engine owns the adapter's
33
+ Preact dependency; hosts do not need a Preact renderer.
34
+
35
+ ### Bug Fixes
36
+
37
+ - Serve preview CSS correctly from a host mounted under a non-root base path in
38
+ both development and preview mode.
39
+ - Activate the engine-route preview token panel after hydration so early clicks
40
+ and SPA navigation keep working in packed foreign hosts.
41
+
7
42
  ## [0.4.1] - 2026-09-27
8
43
 
9
44
  This release replaces the code panel's fixed dark editor theme with an
package/README.md CHANGED
@@ -22,13 +22,13 @@ dogfoods the engine as its own styleguide host — see
22
22
  `Story<P>`, `StoryControl<P>`, `StoryModule`, `defineStory`. Categories are
23
23
  open, host-ordered data (`categoryOrder: string[]`), never a closed type.
24
24
  - A standalone preview stylesheet compiler
25
- (`@takazudo/zudo-sg/plugins/preview-css`) that compiles the host's own token
26
- CSS with `@tailwindcss/node` and rescopes it under
27
- `:root[data-sg-preview-doc]` so it coexists with the host's global
28
- stylesheet.
29
- - Generated safelist and chrome styles (`@takazudo/zudo-sg/safelist.css`,
30
- `@takazudo/zudo-sg/styles.css`) so the catalog UI ships its own Tailwind
31
- utilities without depending on the host's content scan.
25
+ (`@takazudo/zudo-sg/plugins/preview-css`) that invokes the host-installed
26
+ `zfb css` command with the composed wind config and component sources, then
27
+ scopes the output under `:root[data-sg-preview-doc]` so it coexists with the
28
+ host's global stylesheet.
29
+ - Generated wind manifest and chrome styles (`@takazudo/zudo-sg/wind.json`,
30
+ `@takazudo/zudo-sg/styles.css`) so zfb includes the catalog's utility
31
+ candidates without depending on the host's source scan.
32
32
  - Token dashboards and a preview design-token panel, driven by a
33
33
  `gen-token-manifest`-produced manifest.
34
34
 
@@ -96,9 +96,11 @@ inside detail-page iframes.
96
96
 
97
97
  ## Framework scope
98
98
 
99
- Preact + zfb hosts only. React 19 hosts are an explicit non-goal for this
100
- release (see the ADR's "Framework scope" decision for the seam that would
101
- enable them later).
99
+ Module-mode stories use zfb's zudo-react runtime. Hosts using another
100
+ framework can use descriptor mode with an external preview document; see the
101
+ ADR's "Framework scope" decision. The `/tokens` dashboard is the one renderer
102
+ exception: its opaque adapter mounts zdtp's Preact widget internally, with
103
+ Preact installed as an engine dependency rather than a host peer.
102
104
 
103
105
  ## Quick start with the initializer
104
106
 
@@ -113,7 +115,7 @@ pnpm gen-token-manifest
113
115
  pnpm dev
114
116
  ```
115
117
 
116
- It copies a private starter with three example Preact components, stories,
118
+ It copies a private starter with three example zudo-react components, stories,
117
119
  token CSS, a preview entry, and the zfb/zudo-doc composition already wired.
118
120
  The CLI prints the same next steps after scaffolding.
119
121
 
@@ -130,20 +132,20 @@ output as drift and never writes it.
130
132
  ## Installation
131
133
 
132
134
  ```sh
133
- pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^2.20.3 @takazudo/zfb-md-wasm@^2.20.3 @takazudo/zfb-runtime@^2.20.3 @takazudo/zudo-doc@^5.27.0 @takazudo/zdtp@^0.8.5 diff@^8.0.4 katex@^0.16.38 preact@^10.29.8 preact-render-to-string@^6.6.6 tailwindcss@^4.2.0 zod@^4.3.6
135
+ pnpm add @takazudo/zudo-sg@latest @takazudo/zfb@^4.3.1 @takazudo/zfb-md-wasm@^4.3.1 @takazudo/zfb-runtime@^4.3.1 @takazudo/zudo-doc@^6.0.0 @takazudo/zdtp@^0.8.6 diff@^8.0.4 katex@^0.16.38 zod@^4.3.6
134
136
  ```
135
137
 
136
- The engine peers are `@takazudo/zfb ^2.20.3`, `@takazudo/zudo-doc ^5.27.0`,
137
- `@takazudo/zdtp ^0.8.5`, and `preact ^10.29.8`. `@takazudo/zdtp` is required:
138
- the injected `/tokens` route imports its dashboard at build time. The
138
+ The engine peers are `@takazudo/zfb ^4.3.1`, `@takazudo/zudo-doc ^6.0.0`,
139
+ and `@takazudo/zdtp ^0.8.6`. `@takazudo/zdtp` is required:
140
+ the injected `/tokens` route loads its dashboard through the engine-owned
141
+ opaque Preact adapter. Preact is a regular engine dependency, not a host peer. The
139
142
  `@takazudo/zfb-md-wasm`, `@takazudo/zfb-runtime`, `diff`, `katex`, and `zod`
140
143
  entries are prerequisites inherited from zfb/zudo-doc; zudo-doc's published
141
144
  route dist imports `diff` and `katex` even when those features are disabled
142
145
  (see [zudolab/zudo-doc#4206](https://github.com/zudolab/zudo-doc/issues/4206)).
143
- `preact-render-to-string` and `tailwindcss` are host-specific dependencies used
144
- by the fixture's component and preview-style setup, respectively; add them
145
- when your host uses those same pieces. The command above reproduces the full
146
- fixture dependency set.
146
+ The host renders components with zudo-react and compiles preview utilities with
147
+ zfb's zudo-wind compiler. The command above reproduces the full fixture
148
+ dependency set.
147
149
 
148
150
  Keep the `tokens` block in `zudo-sg.config.mjs`: the initializer's config
149
151
  typing treats it as required, and `gen-token-manifest` needs its two CSS paths
@@ -180,11 +182,11 @@ control. Any non-empty host navigation stays authoritative; set
180
182
  `chromeDefaults: false` in the second argument to keep an intentionally empty
181
183
  header. The engine requires `packageOwnedRoutes: true` on the host (its
182
184
  routes import zudo-doc's route-context virtual modules). On the engine's zfb
183
- peer floor (≥ 2.18.0) nothing else is needed: `zfb dev` seeds its island
185
+ peer floor (4.3.1) nothing else is needed: `zfb dev` seeds its island
184
186
  scanner from the injected routes. `@takazudo/zudo-sg/islands` remains
185
187
  exported as a side-effect module that statically imports every engine
186
188
  island — importing it once from a host `pages/` file is optional and
187
- harmless (it was required on zfb < 2.18.0).
189
+ harmless (it was required before zfb 2.18.0).
188
190
 
189
191
  `uiPackageName` is optional. When set, it names the package used in generated
190
192
  usage snippets and catalog labels; when omitted, scaffolded usage snippets
@@ -208,25 +210,15 @@ this entry already. Use this import order, replacing `ui-tokens.css` with
208
210
  your own token stylesheet as needed:
209
211
 
210
212
  ```css
211
- @layer zd-preflight, zd-flow;
212
- /* One element reset: theme.css resets color tokens, not elements. */
213
- @import "tailwindcss/preflight" layer(zd-preflight);
214
- @import "tailwindcss/utilities";
213
+ @layer zw-reset, zd-flow;
215
214
  @import "@takazudo/zudo-doc/theme.css";
216
215
  @import "./ui-tokens.css";
217
216
  /* Add your component package stylesheet here. */
218
- @import "@takazudo/zudo-doc/safelist.css";
219
217
  @import "@takazudo/zudo-doc/content.css";
220
218
  @import "@takazudo/zudo-doc/features.css";
221
219
  @import "@takazudo/zudo-doc/page-loading.css";
222
220
  @import "@takazudo/zdtp/dashboard/styles.css";
223
221
  @import "@takazudo/zudo-sg/styles.css";
224
- @import "@takazudo/zudo-sg/safelist.css";
225
-
226
- /* zfb global-entry paths are project-root-relative; add your UI package here. */
227
- @source "pages/**/*.{tsx,ts,jsx,js}";
228
- @source "ui/**/*.{tsx,ts,jsx,js,mdx,md}";
229
- @source "src/content/**/*.{mdx,md}";
230
222
  ```
231
223
 
232
224
  ### Three token worlds and the engine override hook
@@ -235,15 +227,15 @@ The host contains three independent color-token worlds:
235
227
 
236
228
  - zudo-doc's `--zd-*` roles style the documentation shell and doc chrome.
237
229
  - zudo-sg's raw `--sg-*` roles style the catalog engine chrome.
238
- - The host component library owns its own `@theme` color tokens, usually the
230
+ - The host component library owns its own `:root` color tokens, usually the
239
231
  `--color-*` semantic roles used by previews.
240
232
 
241
233
  The engine's eleven public chrome roles are `--sg-bg`, `--sg-fg`, `--sg-surface`,
242
234
  `--sg-surface-2`, `--sg-border`, `--sg-border-strong`, `--sg-muted`, `--sg-accent`,
243
235
  `--sg-on-accent`, `--sg-focus`, and `--sg-success`. They are plain properties in a
244
- zero-specificity `:where(:root)` block, not an engine `@theme` color tier. zudo-doc's
245
- `theme.css` resets `--color-*`, so these raw properties survive regardless of whether
246
- the engine stylesheet is imported before or after that reset.
236
+ zero-specificity `:where(:root)` block, not an engine color tier. zudo-doc 6's
237
+ `theme.css` supplies package token values without resetting host `--color-*`
238
+ properties; the engine's raw `--sg-*` namespace remains separate.
247
239
 
248
240
  Override engine chrome from the host with an ordinary, unlayered root rule:
249
241
 
@@ -270,31 +262,26 @@ since island props must be JSON-serializable. See
270
262
  [Tokens and preview CSS](../../src/content/docs/architecture/tokens-and-preview-css.mdx)
271
263
  for the full token list and override example.
272
264
 
273
- The zudo-doc theme supplies framework defaults, including the breakpoints
274
- needed by responsive sidebar utilities. Its color-token reset precedes your
275
- tokens so they survive. Use `theme-no-reset.css` instead to preserve
276
- consumer-only color tokens imported earlier; tokens defined by both
277
- stylesheets still follow source order. Do not import both variants or add
278
- another preflight/full `tailwindcss` import. A host that already defines the
279
- full zudo-doc token contract can keep its own theme.
280
-
281
- Those zudo-doc namespace and import-order rules still apply to the host's own `@theme`
282
- colors: place
283
- `@takazudo/zudo-doc/theme.css` before the host component token stylesheet, or use
284
- `@takazudo/zudo-doc/theme-no-reset.css` when preserving consumer-only tokens declared
285
- earlier is intentional. The order-proof `--sg-*` hook does not remove this requirement
286
- for host-owned `--color-*` tokens.
287
-
288
- Keep utilities and engine styles unlayered. The `zd-flow` layer must beat
289
- preflight's margin reset while allowing utility margins to win, and catalog
290
- chrome overrides must compete with utilities. The zdtp dashboard stylesheet
291
- belongs after zudo-doc content CSS so dashboard rules win ties with prose.
292
- Safelists cover package chrome; your `@source` globs cover consumer code.
293
-
294
- Add the component package's CSS and source scan to your `previewStyles` entry
295
- as well; that standalone entry compiles separately and resolves `@source`
296
- paths relative to its stylesheet. Dashboard and catalog CSS stay in the
297
- host entry.
265
+ Declare host tokens as ordinary `:root` custom properties and map utilities to
266
+ those live variables in `wind.tokens`. Pass the host's `wind` configuration in
267
+ the preset fragment given to `withZudoSg()`. The helper deep-merges engine tokens
268
+ with explicit host entries last, preserves host source controls, and registers
269
+ `@takazudo/zudo-sg/wind.json` automatically. Hosts need no manual manifest import.
270
+ The defaults declare sm/md/lg/xl at 640/768/1024/1280px, strict compilation,
271
+ `dark: false`, `reset: "owned-v1"` and utilities placed before authored CSS.
272
+
273
+ Keep utility overrides and engine styles unlayered. The `zw-reset` layer precedes
274
+ `zd-flow`; the dashboard stylesheet belongs after zudo-doc content CSS.
275
+ Configure consumer source roots in `wind.sources`; the engine manifest covers
276
+ only engine utility candidates.
277
+
278
+ `previewStyles` remains an independent CSS entry containing your component
279
+ tokens and authored component styles. The preview plugin invokes the host's
280
+ installed `zfb css` with composed wind configuration and component roots, then
281
+ scopes token roots to `:root[data-sg-preview-doc]`. CSS imports and component
282
+ source changes refresh without a restart. Host config or imported token-config
283
+ changes require zfb config reload/restart so the snapshot contains fresh data.
284
+ This token precedence rule does not isolate every host stylesheet selector.
298
285
 
299
286
  ## Release scheme
300
287
 
@@ -1,6 +1,4 @@
1
- /** @jsxRuntime automatic */
2
- /** @jsxImportSource preact */
3
- import type { JSX } from "preact";
1
+ import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
4
2
  import type { CatalogEntry } from "../registry/catalog.js";
5
3
  export interface CatalogThumbProps {
6
4
  entry: CatalogEntry;
@@ -14,6 +12,3 @@ export interface CatalogThumbProps {
14
12
  * through `DescriptorThumb`.
15
13
  */
16
14
  export declare function CatalogThumb({ entry, base }: CatalogThumbProps): JSX.Element;
17
- export declare namespace CatalogThumb {
18
- var displayName: string;
19
- }
@@ -1,11 +1,10 @@
1
- import { jsx } from "preact/jsx-runtime";
1
+ import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
2
2
  import { ComponentThumb } from "./component-thumb.js";
3
3
  import { DescriptorThumb } from "./descriptor-thumb.js";
4
4
  function CatalogThumb({ entry, base }) {
5
5
  if (entry.source === "module") return /* @__PURE__ */ jsx(ComponentThumb, { entry: entry.storyEntry });
6
6
  return /* @__PURE__ */ jsx(DescriptorThumb, { entry, base });
7
7
  }
8
- CatalogThumb.displayName = "CatalogThumb";
9
8
  export {
10
9
  CatalogThumb
11
10
  };
@@ -1,6 +1,4 @@
1
- /** @jsxRuntime automatic */
2
- /** @jsxImportSource preact */
3
- import type { JSX } from "preact";
1
+ import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
4
2
  import type { StoryEntry } from "../registry/registry.js";
5
3
  /** Virtual-viewport width (CSS px) a thumbnail lays its component out at. */
6
4
  export declare const THUMB_VIEWPORT_W = 720;
@@ -73,6 +71,3 @@ export interface ComponentThumbProps {
73
71
  * `aria-hidden` subtree is an accessibility defect, not just noise.
74
72
  */
75
73
  export declare function ComponentThumb({ entry }: ComponentThumbProps): JSX.Element;
76
- export declare namespace ComponentThumb {
77
- var displayName: string;
78
- }
@@ -1,5 +1,5 @@
1
- import { Fragment, jsx } from "preact/jsx-runtime";
2
- import { render as renderToStaticHtml } from "preact-render-to-string";
1
+ import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
2
+ import { renderToString as renderToStaticHtml } from "@takazudo/zfb/zudo-react/server";
3
3
  const THUMB_VIEWPORT_W = 720;
4
4
  const THUMB_VIEWPORT_W_ATOM = 400;
5
5
  const ATOM_SCALE_CATEGORIES = [
@@ -56,9 +56,11 @@ function buildThumb(entry) {
56
56
  const variant = entry.variants[0];
57
57
  if (!variant) return { kind: "note", reason: "No variants declared" };
58
58
  try {
59
- const html = renderToStaticHtml(
60
- /* @__PURE__ */ jsx(Fragment, { children: variant.story.render(defaultsFromControls(variant.story.controls)) })
61
- );
59
+ let StorySnapshot2 = function() {
60
+ return variant.story.render(defaultsFromControls(variant.story.controls));
61
+ };
62
+ var StorySnapshot = StorySnapshot2;
63
+ const html = renderToStaticHtml(/* @__PURE__ */ jsx(StorySnapshot2, {}));
62
64
  return { kind: "html", html: scopeThumbHtml(html, thumbIdPrefix(entry.slug)) };
63
65
  } catch (error) {
64
66
  return {
@@ -90,13 +92,12 @@ function ComponentThumb({ entry }) {
90
92
  "div",
91
93
  {
92
94
  class: "sg-thumb-inner",
93
- dangerouslySetInnerHTML: { __html: thumb.html }
95
+ rawHtml: thumb.html
94
96
  }
95
97
  )
96
98
  }
97
99
  );
98
100
  }
99
- ComponentThumb.displayName = "ComponentThumb";
100
101
  export {
101
102
  ATOM_SCALE_CATEGORIES,
102
103
  ComponentThumb,
@@ -1,6 +1,4 @@
1
- /** @jsxRuntime automatic */
2
- /** @jsxImportSource preact */
3
- import type { JSX } from "preact";
1
+ import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
4
2
  import type { DescriptorCatalogEntry } from "../registry/catalog.js";
5
3
  /** Note shown when a descriptor declares no `thumbnail` at all. */
6
4
  export declare const DESCRIPTOR_THUMB_MISSING_NOTE = "No thumbnail provided";
@@ -15,6 +13,3 @@ export interface DescriptorThumbProps {
15
13
  * snapshots out of the tab order and the accessibility tree the same way.
16
14
  */
17
15
  export declare function DescriptorThumb({ entry, base }: DescriptorThumbProps): JSX.Element;
18
- export declare namespace DescriptorThumb {
19
- var displayName: string;
20
- }
@@ -1,4 +1,4 @@
1
- import { jsx } from "preact/jsx-runtime";
1
+ import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
2
2
  const DESCRIPTOR_THUMB_MISSING_NOTE = "No thumbnail provided";
3
3
  function withThumbBase(base, src) {
4
4
  if (!src.startsWith("/")) return src;
@@ -24,7 +24,6 @@ function DescriptorThumb({ entry, base = "" }) {
24
24
  }
25
25
  ) });
26
26
  }
27
- DescriptorThumb.displayName = "DescriptorThumb";
28
27
  export {
29
28
  DESCRIPTOR_THUMB_MISSING_NOTE,
30
29
  DescriptorThumb
@@ -1,6 +1,5 @@
1
- /** @jsxRuntime automatic */
2
- /** @jsxImportSource preact */
3
- import type { ComponentChildren, JSX, VNode } from "preact";
1
+ import type { Child, Description } from "@takazudo/zfb/zudo-react";
2
+ import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
4
3
  import type { NavNode } from "../registry/nav-nodes.js";
5
4
  export interface StyleguideLayoutProps {
6
5
  /**
@@ -21,19 +20,19 @@ export interface StyleguideLayoutProps {
21
20
  /** Hide the component sidebar for standalone pages such as /tokens. */
22
21
  hideSidebar?: boolean;
23
22
  /** `<head>` content — the host passes its `HeadWithDefaults` output. */
24
- head: ComponentChildren;
23
+ head: Child;
25
24
  /** Header region — the host passes its `HeaderWithDefaults` output. */
26
- header: ComponentChildren;
25
+ header: Child;
27
26
  /** Footer region — the host passes its `FooterWithDefaults` output. */
28
- footer: ComponentChildren;
27
+ footer: Child;
29
28
  /** Body-end islands — the host passes its `BodyEndIslands` output. */
30
- bodyEnd: ComponentChildren;
29
+ bodyEnd: Child;
31
30
  /**
32
31
  * Right-region code panel content (detail pages only, #49). When present the
33
32
  * TOC slot hosts it; when absent the slot is empty and `hideToc` frees the
34
33
  * width.
35
34
  */
36
- codePanel?: VNode | null;
35
+ codePanel?: Description | null;
37
36
  /**
38
37
  * Opt the content band into the DocLayout **wide** layout — forwarded
39
38
  * verbatim to `DocLayoutWithDefaults contentWide`. Defaults to `false`.
@@ -54,6 +53,6 @@ export interface StyleguideLayoutProps {
54
53
  enableClientRouter: boolean;
55
54
  /** Mirrors the host's `settings.noindex`. */
56
55
  noindex: boolean;
57
- children: JSX.Element | JSX.Element[];
56
+ children: Child;
58
57
  }
59
58
  export declare function StyleguideLayout({ title, activeSlug, lang, hideSidebar, head, header, footer, bodyEnd, codePanel, contentWide, navNodes, sidebarToggle, enableClientRouter, noindex, children, }: StyleguideLayoutProps): JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Fragment, jsx, jsxs } from "preact/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "@takazudo/zfb/zudo-react/jsx-runtime";
2
2
  import { Island } from "@takazudo/zfb";
3
3
  import { DocLayoutWithDefaults } from "@takazudo/zudo-doc/doclayout";
4
4
  import { SidebarTree } from "@takazudo/zudo-doc/sidebar-tree-island";
@@ -28,11 +28,8 @@ function StyleguideLayout({
28
28
  const sidebarToggleSettings = { sidebarToggle };
29
29
  const SidebarPrepaint = createSidebarPrepaint(sidebarToggleSettings);
30
30
  const SidebarVisibilityPrepaint = createSidebarVisibilityPrepaint(sidebarToggleSettings);
31
- const sidebarOverride = hideSidebar ? /* @__PURE__ */ jsx(Fragment, {}) : Island({
32
- when: "load",
33
- children: /* @__PURE__ */ jsx(SidebarTree, { nodes: navNodes, currentSlug: activeSlug })
34
- });
35
- const tocOverride = showCodePanel ? codePanel : /* @__PURE__ */ jsx(Fragment, {});
31
+ const sidebarOverride = hideSidebar ? /* @__PURE__ */ jsx(Fragment, {}) : /* @__PURE__ */ jsx(Island, { when: "load", children: /* @__PURE__ */ jsx(SidebarTree, { nodes: navNodes, ...activeSlug !== void 0 ? { currentSlug: activeSlug } : {} }) });
32
+ const tocOverride = codePanel ?? /* @__PURE__ */ jsx(Fragment, {});
36
33
  const composedHead = /* @__PURE__ */ jsxs(Fragment, { children: [
37
34
  head,
38
35
  /* @__PURE__ */ jsx(SidebarVisibilityPrepaint, { hideSidebar }),
@@ -1,5 +1,3 @@
1
- /** @jsxRuntime automatic */
2
- /** @jsxImportSource preact */
3
- import type { JSX } from "preact";
1
+ import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";
4
2
  export declare function PanelStateHeadScript(): JSX.Element;
5
3
  export declare function PanelResizersInitScript(): JSX.Element;
@@ -1,10 +1,10 @@
1
- import { jsx } from "preact/jsx-runtime";
1
+ import { jsx } from "@takazudo/zfb/zudo-react/jsx-runtime";
2
2
  import { RESIZER_SCRIPT, RESTORE_SCRIPT } from "./panel-scripts-source";
3
3
  function PanelStateHeadScript() {
4
- return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: RESTORE_SCRIPT } });
4
+ return /* @__PURE__ */ jsx("script", { rawHtml: RESTORE_SCRIPT });
5
5
  }
6
6
  function PanelResizersInitScript() {
7
- return /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: RESIZER_SCRIPT } });
7
+ return /* @__PURE__ */ jsx("script", { rawHtml: RESIZER_SCRIPT });
8
8
  }
9
9
  export {
10
10
  PanelResizersInitScript,
@@ -29,14 +29,15 @@ function toPascalCase(kebabName) {
29
29
  }
30
30
  function componentTemplate({ pascalName }) {
31
31
  const lines = [
32
- `import type { ComponentChildren } from "preact";`,
32
+ `import type { Child } from "@takazudo/zfb/zudo-react";`,
33
+ `import type { JSX } from "@takazudo/zfb/zudo-react/jsx-runtime";`,
33
34
  ``,
34
35
  `export type ${pascalName}Variant = "primary" | "secondary";`,
35
36
  ``,
36
37
  `export type ${pascalName}Props = {`,
37
38
  ` variant?: ${pascalName}Variant;`,
38
39
  ` class?: string;`,
39
- ` children?: ComponentChildren;`,
40
+ ` children?: Child;`,
40
41
  `};`,
41
42
  ``,
42
43
  `const base =`,
@@ -53,7 +54,7 @@ function componentTemplate({ pascalName }) {
53
54
  `/**`,
54
55
  ` * TODO: describe ${pascalName} \u2014 what it renders and when to use it.`,
55
56
  ` */`,
56
- `export function ${pascalName}({ variant = "primary", class: cls, children }: ${pascalName}Props) {`,
57
+ `export function ${pascalName}({ variant = "primary", class: cls, children }: ${pascalName}Props): JSX.Element {`,
57
58
  ` const className = [base, variants[variant], cls].filter(Boolean).join(" ");`,
58
59
  ` return <div class={className}>{children}</div>;`,
59
60
  `}`
@@ -68,6 +69,7 @@ function storiesTemplate({
68
69
  }) {
69
70
  const usageImport = uiPackageName ?? `./${kebabName}`;
70
71
  const lines = [
72
+ `import type { Child } from "@takazudo/zfb/zudo-react";`,
71
73
  `import type { StoryMeta, Story } from "@takazudo/zudo-sg/stories";`,
72
74
  `import { ${pascalName}, type ${pascalName}Props } from "./${kebabName}";`,
73
75
  ``,
@@ -100,7 +102,7 @@ function storiesTemplate({
100
102
  ` defaultValue: "Content",`,
101
103
  ` },`,
102
104
  ` ],`,
103
- ` render: (args = {}) => (`,
105
+ ` render: (args = {}): Child => (`,
104
106
  ` <${pascalName} variant={args.variant}>{args.children}</${pascalName}>`,
105
107
  ` ),`,
106
108
  `};`
@@ -109,26 +111,43 @@ function storiesTemplate({
109
111
  }
110
112
  function testTemplate({ pascalName, kebabName }) {
111
113
  const lines = [
112
- `import { render, screen } from "@testing-library/preact";`,
114
+ `// @vitest-environment happy-dom`,
115
+ `import { renderToString } from "@takazudo/zfb/zudo-react/server";`,
116
+ `import { createIslandTest } from "@takazudo/zfb/zudo-react/testing";`,
113
117
  `import { describe, expect, it } from "vitest";`,
114
- `import { ${pascalName} } from "../${kebabName}";`,
118
+ `import { ${pascalName}, type ${pascalName}Props } from "../${kebabName}";`,
119
+ ``,
120
+ `function ${pascalName}Fixture({ variant }: Pick<${pascalName}Props, "variant">) {`,
121
+ ` return <${pascalName} variant={variant}>Content</${pascalName}>;`,
122
+ `}`,
115
123
  ``,
116
124
  `describe("${pascalName}", () => {`,
117
125
  ` it("renders its children", () => {`,
118
- ` render(<${pascalName}>Content</${pascalName}>);`,
119
- ` expect(screen.getByText("Content")).toBeInTheDocument();`,
126
+ ` expect(renderToString(<${pascalName}>Content</${pascalName}>)).toContain("Content");`,
120
127
  ` });`,
121
128
  ``,
122
- ` it("defaults to the primary variant", () => {`,
123
- ` render(<${pascalName}>Content</${pascalName}>);`,
124
- ` const el = screen.getByText("Content");`,
125
- ` expect(el.className).toContain("bg-accent");`,
129
+ ` it("defaults to the primary variant", async () => {`,
130
+ ` const test = createIslandTest(${pascalName}Fixture, {}, { document });`,
131
+ ` try {`,
132
+ ` test.hydrate();`,
133
+ ` await test.flush();`,
134
+ ` expect(test.host.querySelector("div")?.classList.contains("bg-accent")).toBe(true);`,
135
+ ` } finally {`,
136
+ ` test.dispose();`,
137
+ ` expect(test.diagnostics).toEqual([]);`,
138
+ ` }`,
126
139
  ` });`,
127
140
  ``,
128
- ` it("applies the secondary variant classes", () => {`,
129
- ` render(<${pascalName} variant="secondary">Content</${pascalName}>);`,
130
- ` const el = screen.getByText("Content");`,
131
- ` expect(el.className).toContain("border-border");`,
141
+ ` it("applies the secondary variant classes", async () => {`,
142
+ ` const test = createIslandTest(${pascalName}Fixture, { variant: "secondary" }, { document });`,
143
+ ` try {`,
144
+ ` test.hydrate();`,
145
+ ` await test.flush();`,
146
+ ` expect(test.host.querySelector("div")?.classList.contains("border-border")).toBe(true);`,
147
+ ` } finally {`,
148
+ ` test.dispose();`,
149
+ ` expect(test.diagnostics).toEqual([]);`,
150
+ ` }`,
132
151
  ` });`,
133
152
  `});`
134
153
  ];
@@ -1,4 +1,3 @@
1
- import type { JSX } from "preact";
2
1
  export interface CodePanelVariant {
3
2
  exportName: string;
4
3
  name: string;
@@ -13,13 +12,8 @@ export interface CodePanelProps {
13
12
  /**
14
13
  * Story slug, used to build stable variant-tab/tabpanel ids that match
15
14
  * SSR output (mirrors `DetailWorkbench`'s `tabsId`). Falls back to
16
- * `useId()` when the host doesn't pass one — still unique per page, just
17
- * not stable across an SSR/hydration boundary.
15
+ * a deterministic title-derived id when the host does not pass one.
18
16
  */
19
17
  slug?: string;
20
18
  }
21
- declare function CodePanel({ storyTitle, variants, previewUrl, slug, }: CodePanelProps): JSX.Element;
22
- declare namespace CodePanel {
23
- var displayName: string;
24
- }
25
- export default CodePanel;
19
+ export default function CodePanel({ storyTitle, variants, previewUrl, slug, }: CodePanelProps): import("@takazudo/zfb").Description;