@takazudo/zudo-sg 0.1.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 (138) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/LICENSE +21 -0
  3. package/README.md +99 -0
  4. package/bin/zudo-sg.js +6 -0
  5. package/dist/catalog/component-thumb.d.ts +78 -0
  6. package/dist/catalog/component-thumb.js +110 -0
  7. package/dist/catalog/index.d.ts +4 -0
  8. package/dist/catalog/index.js +40 -0
  9. package/dist/catalog/tile-size.d.ts +28 -0
  10. package/dist/catalog/tile-size.js +42 -0
  11. package/dist/chrome/_styleguide-layout.d.ts +59 -0
  12. package/dist/chrome/_styleguide-layout.js +69 -0
  13. package/dist/chrome/index.d.ts +4 -0
  14. package/dist/chrome/index.js +39 -0
  15. package/dist/chrome/panel-contract.d.ts +15 -0
  16. package/dist/chrome/panel-contract.js +65 -0
  17. package/dist/chrome/panel-scripts-source.d.ts +2 -0
  18. package/dist/chrome/panel-scripts-source.js +121 -0
  19. package/dist/chrome/panel-scripts.d.ts +5 -0
  20. package/dist/chrome/panel-scripts.js +12 -0
  21. package/dist/cli/bin.d.ts +1 -0
  22. package/dist/cli/bin.js +74 -0
  23. package/dist/cli/config.d.ts +54 -0
  24. package/dist/cli/config.js +14 -0
  25. package/dist/cli/registry/build-registry-source.d.ts +27 -0
  26. package/dist/cli/registry/build-registry-source.js +77 -0
  27. package/dist/cli/registry/discover-stories.d.ts +36 -0
  28. package/dist/cli/registry/discover-stories.js +61 -0
  29. package/dist/cli/registry/gen-registry.d.ts +23 -0
  30. package/dist/cli/registry/gen-registry.js +74 -0
  31. package/dist/cli/scaffold/component-scaffold.d.ts +64 -0
  32. package/dist/cli/scaffold/component-scaffold.js +233 -0
  33. package/dist/cli/scaffold/new-component.d.ts +17 -0
  34. package/dist/cli/scaffold/new-component.js +119 -0
  35. package/dist/cli/token-manifest/css-var-parser.d.ts +9 -0
  36. package/dist/cli/token-manifest/css-var-parser.js +23 -0
  37. package/dist/cli/token-manifest/gen-token-manifest.d.ts +16 -0
  38. package/dist/cli/token-manifest/gen-token-manifest.js +49 -0
  39. package/dist/cli/token-manifest/ui-token-manifest.d.ts +78 -0
  40. package/dist/cli/token-manifest/ui-token-manifest.js +340 -0
  41. package/dist/code-panel/code-panel.d.ts +18 -0
  42. package/dist/code-panel/code-panel.js +76 -0
  43. package/dist/code-panel/copy-button.d.ts +15 -0
  44. package/dist/code-panel/copy-button.js +92 -0
  45. package/dist/code-panel/css-injection.d.ts +6 -0
  46. package/dist/code-panel/css-injection.js +37 -0
  47. package/dist/code-panel/editor-setup.d.ts +10 -0
  48. package/dist/code-panel/editor-setup.js +33 -0
  49. package/dist/code-panel/index.d.ts +6 -0
  50. package/dist/code-panel/index.js +10 -0
  51. package/dist/code-panel/source-editor.d.ts +8 -0
  52. package/dist/code-panel/source-editor.js +39 -0
  53. package/dist/config/index.d.ts +73 -0
  54. package/dist/config/index.js +68 -0
  55. package/dist/host-paths.d.ts +19 -0
  56. package/dist/host-paths.js +41 -0
  57. package/dist/index.d.ts +6 -0
  58. package/dist/index.js +18 -0
  59. package/dist/islands.d.ts +2 -0
  60. package/dist/islands.js +6 -0
  61. package/dist/plugins/preview-css.d.ts +53 -0
  62. package/dist/plugins/preview-css.js +183 -0
  63. package/dist/plugins/routes.d.ts +84 -0
  64. package/dist/plugins/routes.js +237 -0
  65. package/dist/plugins/zdtp-apply-proxy.d.ts +58 -0
  66. package/dist/plugins/zdtp-apply-proxy.js +171 -0
  67. package/dist/preview/detail-workbench.d.ts +22 -0
  68. package/dist/preview/detail-workbench.js +179 -0
  69. package/dist/preview/index.d.ts +8 -0
  70. package/dist/preview/index.js +21 -0
  71. package/dist/preview/messages.d.ts +34 -0
  72. package/dist/preview/messages.js +32 -0
  73. package/dist/preview/preview-app.d.ts +11 -0
  74. package/dist/preview/preview-app.js +87 -0
  75. package/dist/preview/route.d.ts +1 -0
  76. package/dist/preview/route.js +5 -0
  77. package/dist/preview/variant-frame.d.ts +42 -0
  78. package/dist/preview/variant-frame.js +289 -0
  79. package/dist/preview-css/compile.d.ts +40 -0
  80. package/dist/preview-css/compile.js +42 -0
  81. package/dist/preview-css/index.d.ts +2 -0
  82. package/dist/preview-css/index.js +10 -0
  83. package/dist/registry/component-docs.d.ts +38 -0
  84. package/dist/registry/component-docs.js +34 -0
  85. package/dist/registry/index.d.ts +6 -0
  86. package/dist/registry/index.js +28 -0
  87. package/dist/registry/nav-nodes.d.ts +22 -0
  88. package/dist/registry/nav-nodes.js +36 -0
  89. package/dist/registry/registry.d.ts +68 -0
  90. package/dist/registry/registry.js +91 -0
  91. package/dist/safelist.css +2 -0
  92. package/dist/search/catalog-filter.d.ts +12 -0
  93. package/dist/search/catalog-filter.js +175 -0
  94. package/dist/search/index.d.ts +2 -0
  95. package/dist/search/index.js +4 -0
  96. package/dist/sg-context.d.ts +24 -0
  97. package/dist/sg-context.js +6 -0
  98. package/dist/sg-routes.d.ts +12 -0
  99. package/dist/sg-routes.js +17 -0
  100. package/dist/stories/index.d.ts +2 -0
  101. package/dist/stories/index.js +4 -0
  102. package/dist/stories/types.d.ts +164 -0
  103. package/dist/stories/types.js +6 -0
  104. package/dist/token-dashboard/create-token-dashboards.d.ts +24 -0
  105. package/dist/token-dashboard/create-token-dashboards.js +57 -0
  106. package/dist/token-dashboard/dashboard-inventory.d.ts +11 -0
  107. package/dist/token-dashboard/dashboard-inventory.js +13 -0
  108. package/dist/token-dashboard/index.d.ts +5 -0
  109. package/dist/token-dashboard/index.js +20 -0
  110. package/dist/token-dashboard/ui-token-tabs.d.ts +53 -0
  111. package/dist/token-dashboard/ui-token-tabs.js +159 -0
  112. package/dist/token-tweak/bootstrap-preview-token-panel.d.ts +12 -0
  113. package/dist/token-tweak/bootstrap-preview-token-panel.js +18 -0
  114. package/dist/token-tweak/iframe-css-vars-bridge.d.ts +35 -0
  115. package/dist/token-tweak/iframe-css-vars-bridge.js +73 -0
  116. package/dist/token-tweak/index.d.ts +6 -0
  117. package/dist/token-tweak/index.js +36 -0
  118. package/dist/token-tweak/preview-iframe-registry.d.ts +16 -0
  119. package/dist/token-tweak/preview-iframe-registry.js +48 -0
  120. package/dist/token-tweak/preview-token-panel-bootstrap.d.ts +6 -0
  121. package/dist/token-tweak/preview-token-panel-bootstrap.js +17 -0
  122. package/dist/token-tweak/preview-token-panel-config.d.ts +42 -0
  123. package/dist/token-tweak/preview-token-panel-config.js +37 -0
  124. package/dist/token-tweak/preview-tokens-button.d.ts +5 -0
  125. package/dist/token-tweak/preview-tokens-button.js +17 -0
  126. package/dist/token-tweak/token-panel-native-bootstrap.d.ts +17 -0
  127. package/dist/token-tweak/token-panel-native-bootstrap.js +49 -0
  128. package/package.json +172 -0
  129. package/routes-src/_chrome.tsx +83 -0
  130. package/routes-src/_context.ts +15 -0
  131. package/routes-src/_preview-app.tsx +32 -0
  132. package/routes-src/_registry.ts +12 -0
  133. package/routes-src/components-index.tsx +95 -0
  134. package/routes-src/components-preview.tsx +55 -0
  135. package/routes-src/components-slug.tsx +145 -0
  136. package/routes-src/tokens.tsx +76 -0
  137. package/styles.css +612 -0
  138. package/virtual-modules.d.ts +25 -0
@@ -0,0 +1,34 @@
1
+ const COMPONENT_DOCS_COLLECTION = "componentDocs";
2
+ const STORY_PATH_SUFFIX = ".stories.tsx";
3
+ function deriveMapKeyPrefix(dir) {
4
+ return dir.replace(/^(\.\/)+/, "").replace(/^packages\//, "").replace(/\/+$/, "");
5
+ }
6
+ function componentDocsCollectionName(index) {
7
+ return index === 0 ? COMPONENT_DOCS_COLLECTION : `${COMPONENT_DOCS_COLLECTION}${index}`;
8
+ }
9
+ function componentDocsRoots(roots) {
10
+ return roots.map((root, i) => ({
11
+ keyPrefix: deriveMapKeyPrefix(root.dir),
12
+ collection: componentDocsCollectionName(i)
13
+ }));
14
+ }
15
+ function resolveComponentDoc(storyPath, roots) {
16
+ if (!storyPath.endsWith(STORY_PATH_SUFFIX)) return null;
17
+ let best = null;
18
+ for (const root of roots) {
19
+ const prefix = `./${root.keyPrefix}/`;
20
+ if (storyPath.startsWith(prefix) && (best === null || prefix.length > best.prefix.length)) {
21
+ best = { root, prefix };
22
+ }
23
+ }
24
+ if (best === null) return null;
25
+ const slug = storyPath.slice(best.prefix.length, storyPath.length - STORY_PATH_SUFFIX.length);
26
+ return slug.length > 0 ? { collection: best.root.collection, slug } : null;
27
+ }
28
+ export {
29
+ COMPONENT_DOCS_COLLECTION,
30
+ componentDocsCollectionName,
31
+ componentDocsRoots,
32
+ deriveMapKeyPrefix,
33
+ resolveComponentDoc
34
+ };
@@ -0,0 +1,6 @@
1
+ export { computeCategoryOrder, createRegistry, OVERVIEW_SLUG, slugify, TOKENS_SLUG, } from "./registry.js";
2
+ export type { CategoryGroup, CreateRegistryOptions, Registry, StoryEntry, VariantEntry, } from "./registry.js";
3
+ export { buildNavNodes } from "./nav-nodes.js";
4
+ export type { BuildNavNodesOptions, NavNode } from "./nav-nodes.js";
5
+ export { COMPONENT_DOCS_COLLECTION, componentDocsCollectionName, componentDocsRoots, deriveMapKeyPrefix, resolveComponentDoc, } from "./component-docs.js";
6
+ export type { ComponentDocRef, ComponentDocsRoot } from "./component-docs.js";
@@ -0,0 +1,28 @@
1
+ import {
2
+ computeCategoryOrder,
3
+ createRegistry,
4
+ OVERVIEW_SLUG,
5
+ slugify,
6
+ TOKENS_SLUG
7
+ } from "./registry.js";
8
+ import { buildNavNodes } from "./nav-nodes.js";
9
+ import {
10
+ COMPONENT_DOCS_COLLECTION,
11
+ componentDocsCollectionName,
12
+ componentDocsRoots,
13
+ deriveMapKeyPrefix,
14
+ resolveComponentDoc
15
+ } from "./component-docs.js";
16
+ export {
17
+ COMPONENT_DOCS_COLLECTION,
18
+ OVERVIEW_SLUG,
19
+ TOKENS_SLUG,
20
+ buildNavNodes,
21
+ componentDocsCollectionName,
22
+ componentDocsRoots,
23
+ computeCategoryOrder,
24
+ createRegistry,
25
+ deriveMapKeyPrefix,
26
+ resolveComponentDoc,
27
+ slugify
28
+ };
@@ -0,0 +1,22 @@
1
+ import { type SgRoutes } from "../sg-routes.js";
2
+ import { type Registry } from "./registry.js";
3
+ /** Structural copy of zudo-doc's sidebar `NavNode`. */
4
+ export interface NavNode {
5
+ slug: string;
6
+ label: string;
7
+ description?: string;
8
+ position: number;
9
+ href?: string;
10
+ hasPage: boolean;
11
+ children: NavNode[];
12
+ sortOrder?: "asc" | "desc";
13
+ collapsed?: boolean;
14
+ }
15
+ export interface BuildNavNodesOptions {
16
+ /** The host's base-path helper (e.g. zudo-doc's `withBase`). */
17
+ withBase: (path: string) => string;
18
+ routes?: Partial<SgRoutes>;
19
+ /** Label of the leading index leaf. Default `"Overview"`. */
20
+ overviewLabel?: string;
21
+ }
22
+ export declare function buildNavNodes(registry: Pick<Registry, "getCategoryGroups">, options: BuildNavNodesOptions): NavNode[];
@@ -0,0 +1,36 @@
1
+ import { componentHref, resolveSgRoutes } from "../sg-routes.js";
2
+ import { OVERVIEW_SLUG } from "./registry.js";
3
+ function buildNavNodes(registry, options) {
4
+ const { withBase } = options;
5
+ const routes = resolveSgRoutes(options.routes);
6
+ let position = 0;
7
+ const next = () => position++;
8
+ const overview = {
9
+ slug: OVERVIEW_SLUG,
10
+ label: options.overviewLabel ?? "Overview",
11
+ position: next(),
12
+ href: withBase(routes.componentsIndex),
13
+ hasPage: true,
14
+ children: []
15
+ };
16
+ const categoryNodes = registry.getCategoryGroups().map((group) => ({
17
+ // Category parents have no page; the prefixed slug is a stable identity
18
+ // for open-set / active-subtree logic that cannot collide with a story slug.
19
+ slug: `category:${group.category}`,
20
+ label: group.category,
21
+ position: next(),
22
+ hasPage: false,
23
+ children: group.stories.map((story) => ({
24
+ slug: story.slug,
25
+ label: story.meta.title,
26
+ position: next(),
27
+ href: withBase(componentHref(routes, story.slug)),
28
+ hasPage: true,
29
+ children: []
30
+ }))
31
+ }));
32
+ return [overview, ...categoryNodes];
33
+ }
34
+ export {
35
+ buildNavNodes
36
+ };
@@ -0,0 +1,68 @@
1
+ import type { Story, StoryMeta, StoryModule } from "../stories/types.js";
2
+ /**
3
+ * Slugs reserved by the styleguide chrome — Overview (the components index
4
+ * route) and Design Tokens (the tokens route). They are NOT story slugs: a
5
+ * story whose title slugifies to one of them is auto-suffixed (`tokens-2`).
6
+ * Keep "tokens" reserved so the retired component URL stays unavailable.
7
+ */
8
+ export declare const OVERVIEW_SLUG = "";
9
+ export declare const TOKENS_SLUG = "tokens";
10
+ /** One discovered story file, normalised. */
11
+ export interface StoryEntry {
12
+ /** URL slug, derived from meta.title (kebab-cased). Unique. */
13
+ slug: string;
14
+ /** Registry path key (e.g. `./ui/src/button/button.stories.tsx`). */
15
+ path: string;
16
+ meta: StoryMeta;
17
+ /**
18
+ * Variants (named Story exports) in SOURCE order — sorted by the codegen-
19
+ * emitted `storyExportOrder`, NOT by `Object.entries(mod)` (an ES-module
20
+ * namespace enumerates keys alphabetically per spec). `variants[0]` is the
21
+ * first-authored story, which drives the default-selected code-panel tab.
22
+ */
23
+ variants: VariantEntry[];
24
+ }
25
+ /** One variant (named Story export) of a story file. */
26
+ export interface VariantEntry {
27
+ /** Export name (e.g. `Variants`) — stable id used in the preview URL. */
28
+ exportName: string;
29
+ /** Human label from `Story.name`. */
30
+ name: string;
31
+ story: Story;
32
+ }
33
+ /** A category bucket for the catalog landing + sidebar. */
34
+ export interface CategoryGroup {
35
+ category: string;
36
+ stories: StoryEntry[];
37
+ }
38
+ export interface CreateRegistryOptions {
39
+ /**
40
+ * Host-declared category order. Listed categories render first in this
41
+ * order; categories used by a story but not listed are appended
42
+ * alphabetically (never dropped).
43
+ */
44
+ categoryOrder?: readonly string[];
45
+ /** Codegen-emitted source order of each story file's exports, keyed like `storyModules`. */
46
+ storyExportOrder?: Readonly<Record<string, readonly string[]>>;
47
+ }
48
+ export interface Registry {
49
+ /** Full group order: `categoryOrder` (deduped) + unlisted used categories, alphabetical. */
50
+ categoryOrder: string[];
51
+ /** All discovered stories, in registry-map order. */
52
+ storyEntries: StoryEntry[];
53
+ getStoryBySlug(slug: string): StoryEntry | undefined;
54
+ getAllSlugs(): string[];
55
+ /**
56
+ * Stories grouped by category in `categoryOrder`; within a category sorted
57
+ * by `meta.order` (ascending) then title. Empty categories are omitted.
58
+ */
59
+ getCategoryGroups(): CategoryGroup[];
60
+ }
61
+ export declare function slugify(input: string): string;
62
+ export declare function computeCategoryOrder(storyModules: Readonly<Record<string, StoryModule>>, declared?: readonly string[]): string[];
63
+ /**
64
+ * Builds a registry from the host's generated story-modules map. Call once
65
+ * per module graph (the result is immutable data plus lookups); the returned
66
+ * functions do not rely on `this`, so they can be destructured.
67
+ */
68
+ export declare function createRegistry(storyModules: Readonly<Record<string, StoryModule>>, options?: CreateRegistryOptions): Registry;
@@ -0,0 +1,91 @@
1
+ const OVERVIEW_SLUG = "";
2
+ const TOKENS_SLUG = "tokens";
3
+ const RESERVED_NAV_SLUGS = [OVERVIEW_SLUG, TOKENS_SLUG];
4
+ function slugify(input) {
5
+ return input.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
6
+ }
7
+ function isStory(value) {
8
+ return typeof value === "object" && value !== null && typeof value.name === "string" && typeof value.render === "function";
9
+ }
10
+ function readMeta(mod) {
11
+ const meta = mod.default;
12
+ return meta && typeof meta.title === "string" ? meta : void 0;
13
+ }
14
+ function computeCategoryOrder(storyModules, declared = []) {
15
+ const listed = [...new Set(declared)];
16
+ const listedSet = new Set(listed);
17
+ const unlisted = /* @__PURE__ */ new Set();
18
+ for (const mod of Object.values(storyModules)) {
19
+ const category = readMeta(mod)?.category;
20
+ if (typeof category === "string" && !listedSet.has(category)) unlisted.add(category);
21
+ }
22
+ return [...listed, ...[...unlisted].sort((a, b) => a.localeCompare(b))];
23
+ }
24
+ function buildEntries(storyModules, storyExportOrder) {
25
+ const entries = [];
26
+ const seenSlugs = new Set(RESERVED_NAV_SLUGS);
27
+ for (const [path, mod] of Object.entries(storyModules)) {
28
+ const meta = readMeta(mod);
29
+ if (!meta) continue;
30
+ const variants = [];
31
+ for (const [exportName, value] of Object.entries(mod)) {
32
+ if (exportName === "default") continue;
33
+ if (!isStory(value)) continue;
34
+ variants.push({ exportName, name: value.name, story: value });
35
+ }
36
+ if (variants.length === 0) continue;
37
+ const order = storyExportOrder[path] ?? [];
38
+ const rank = (name) => {
39
+ const i = order.indexOf(name);
40
+ return i === -1 ? order.length : i;
41
+ };
42
+ variants.sort((a, b) => rank(a.exportName) - rank(b.exportName));
43
+ const base = slugify(meta.title);
44
+ let slug = base;
45
+ let n = 2;
46
+ while (seenSlugs.has(slug)) slug = `${base}-${n++}`;
47
+ seenSlugs.add(slug);
48
+ entries.push({ slug, path, meta, variants });
49
+ }
50
+ return entries;
51
+ }
52
+ function createRegistry(storyModules, options = {}) {
53
+ const categoryOrder = computeCategoryOrder(storyModules, options.categoryOrder);
54
+ const storyEntries = buildEntries(storyModules, options.storyExportOrder ?? {});
55
+ const entryBySlug = new Map(storyEntries.map((e) => [e.slug, e]));
56
+ function getCategoryGroups() {
57
+ const byCategory = /* @__PURE__ */ new Map();
58
+ for (const entry of storyEntries) {
59
+ const list = byCategory.get(entry.meta.category) ?? [];
60
+ list.push(entry);
61
+ byCategory.set(entry.meta.category, list);
62
+ }
63
+ const groups = [];
64
+ for (const category of categoryOrder) {
65
+ const stories = byCategory.get(category);
66
+ if (!stories || stories.length === 0) continue;
67
+ stories.sort((a, b) => {
68
+ const oa = a.meta.order ?? Number.POSITIVE_INFINITY;
69
+ const ob = b.meta.order ?? Number.POSITIVE_INFINITY;
70
+ if (oa !== ob) return oa - ob;
71
+ return a.meta.title.localeCompare(b.meta.title);
72
+ });
73
+ groups.push({ category, stories });
74
+ }
75
+ return groups;
76
+ }
77
+ return {
78
+ categoryOrder,
79
+ storyEntries,
80
+ getStoryBySlug: (slug) => entryBySlug.get(slug),
81
+ getAllSlugs: () => storyEntries.map((e) => e.slug),
82
+ getCategoryGroups
83
+ };
84
+ }
85
+ export {
86
+ OVERVIEW_SLUG,
87
+ TOKENS_SLUG,
88
+ computeCategoryOrder,
89
+ createRegistry,
90
+ slugify
91
+ };
@@ -0,0 +1,2 @@
1
+ /* generated by gen-safelist.mjs — do not edit by hand */
2
+ @source inline("-components [--check] [--nested] [--skip-barrel] [data-sg-card] [data-sg-catalog] [data-sg-empty] [data-sg-section] [data-sg-tile] [options] [slug] [zudo-sg] a accent accent-0 accent-1 accent-2 accent-3 accent/state across add adjusted after alias allow-forms allow-same-origin allow-scripts alphabetical alphabetically already always among an and any anything appear application/json apply-css-vars are aria-activedescendant aria-controls aria-describedby aria-details aria-expanded aria-hidden aria-label aria-labelledby aria-live aria-orientation aria-owns aria-pressed aria-selected array as aside assumes at authored back bar barrel barrel-export base be because before below beneath bg bg-accent bg-bg bg-surface bg-surface-2 block body bogus boolean border border-accent border-b border-border border-border-strong border-t border-transparent both build builds but button by cache-control cannot canvas carries cascading catalog categories category caution change changing check:token-manifest checkbox children circle clamp classes clear-css-vars clickable client code codegen collapsing collection color colors command commit compact compare compile compiled component components components2026 config configured confirm const contain content-type copy count counts css cursor-pointer custom-property cx danger dark dashboard dashboards data-category data-copied data-keywords data-name data-sg-card data-sg-catalog data-sg-catalog-intro data-sg-code-panel-hidden data-sg-code-panel-resizer data-sg-empty data-sg-injected-css data-sg-preview-css data-sg-preview-doc data-sg-preview-loading data-sg-preview-scope data-sg-section data-sg-stage-grid data-sg-tile data-sg-tile-size data-sg-variant-root data-theme data-zudo-sg-tokens-empty date declaration declarations declared default defaults demo derive derived describe description descriptors design design-token desktop detail dev different differs digit directories directory disabled discovered display div do doc doc-chrome drift driven dual-scheme each edit editing edits el element else empty en endpoint engine entry entrypoint equivalent every exists expected export exported exports exposes expressions failed fails family fg file files filled find first first-authored fixed flag flex flex-1 flex-col flex-wrap focus-visible:-outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-focus focus-visible:outline-offset-2 follow follows font font-bold font-family font-medium font-semibold font-size font-size-lh font-weight for form found frame frames free-form from frost full function g gap-hsp-2xs gap-hsp-3xs gap-hsp-md gap-hsp-sm gap-hsp-xs gap-vsp-2xs gap-vsp-lg gap-vsp-md gap-x-hsp-xl gap-y-vsp-xl gate gen-registry gen-token-manifest gen:sg-registry gen:token-manifest generated give glob-relative grid grid-cols-1 grid-cols-[repeat(auto-fit,minmax(min(18rem,100%),1fr))] group guards h-[1.5rem] h-full h1 h2 h3 hand handle hands has have head header headers height here hex hidden hold host hover:text-fg hsp html human-friendly identifier identifiers if iframe iframes import important in include including inert info init inject inline-block inline-flex input inserting inserts inside installed instead interface into intro inventory is isolated it items-center items-start its itself justify-between kebab-case keeps key key-enumeration keyboard keydown keyed known label large layout lazy leading leading-normal left length lh light like line line-beauty-accent line-beauty-accent-dark line-beauty-hover line-beauty-hover-dark line-height line-laser-accent line-laser-accent-dark line-laser-hover line-laser-hover-dark line-meeting-accent line-meeting-accent-dark line-meeting-hover line-meeting-hover-dark line-process-accent line-process-accent-dark line-process-hover line-process-hover-dark line-vacuum-accent line-vacuum-accent-dark line-vacuum-hover line-vacuum-hover-dark link lint:tokens list listed lists live load loading m-0 m21 makes manifest marker markers match matching material max-w-[56rem] may mb-vsp-2xs mb-vsp-lg mb-vsp-sm mb-vsp-xl message meta metadata min-h-0 mirroring missing mobile mode mode-dependent mode-independent model module ms-auto mt-vsp-2xs mt-vsp-3xs mt-vsp-xl mt-vsp-xs must mx-auto name name/value named named-export namespace navigation needs neutral-0 neutral-1 neutral-2 neutral-3 never new new-component new:component no no-store node:crypto node:fs node:fs/promises node:module node:path node:url noindex non-empty none not note nowhere number object of off oklch on once one one-sentence only option options opts or order other out outline-none overflow-auto overflow-hidden overflow-x-auto overriding p p-hsp-2xs p-hsp-md p-hsp-sm pages pairs palette palette- panel panels parse parsed parser pass passes path per-element per-variant pick pill placeholders plain plugin plugins pnpm polite polyline postcss pre preact-render-to-string preact/hooks preact/jsx-runtime presentation preview previews primary property pt-vsp-xl pushes px px-hsp-2xs px-hsp-md px-hsp-sm px-hsp-xs py-vsp-2xs py-vsp-3xs py-vsp-xs radius rail ramp ramps range raw re-executed re-run read-only readonly ready real recover rect reference references regenerated region registration relative rem rem-aware rem-based rename renamed/removed render rendered renders replace required requires resolve resolved return returns rhythm robots root-absolute round rounded rounded-full rounded-md rounded-sm route router routes routes-src rows run runtime s same saved scaffold scaffolds screen scrim script search secondary section segment segments select semantic separator settings sg-catalog-tile-size sg-chip sg-chip-row sg-code-panel sg-code-panel-hidden sg-code-panel-resizer sg-code-panel-width sg-copy-btn sg-filter sg-filter-row sg-gallery-section sg-grid sg-injected- sg-preview-design-token-panel-modal sg-preview-design-tokens sg-preview-design-tokens/v1 sg-preview-tweak sg-registry sg-search-clear sg-search-field sg-search-input sg-seg sg-seg-btn sg-thumb sg-thumb-inner sg-thumb-note sg-tile sg-tile-count sg-tile-desc sg-tile-meta sg-tile-title sg-workbench-toolbar sg:height sg:ready sgt- shadow shape shared show shown shrink-0 sidebar sidebar- single-axis site size skipped skips slug so solid sorts source spacing span spec specimen stacked starting state state-danger state-danger-dark state-info state-info-dark state-success state-success-dark state-warning state-warning-dark stay step still story string strings stroke-linecap stroke-linejoin stroke-width style stylesheet supported surface surfaces svg swaps swatch tab tablet tablist tabs tabular-nums target-website text text-2xl text-accent text-caption text-fg text-heading text-muted text-on-accent text-right text-sm text-small text-xl text-xs text/icons textarea that the their them theme then these this three-tier tier tile time tip title to toggle toggle-design-token-panel toggle-preview-token-panel token tokens total tracking-wide transition-colors true tsx tweaks twice two type typechecks ui- ui-color ui-defaults-dark ui-defaults-light ui-defaults-shared undefined under underline underline-offset-2 unknown unwired up uppercase us use used uses utf-8 utf8 valid value values var variant variants vertical via viewport views virtual:zudo-doc-chrome-bindings virtual:zudo-doc-route-context virtual:zudo-sg-context virtual:zudo-sg-preview-token-panel virtual:zudo-sg-registry virtual:zudo-sg-tokens visible visit vs vsp w-[2.5rem] w-[5rem] warning was weight were what when which while whole whose will window with without would written yield you your zd-content zdtp-preview-prehydrate zfb zudo-doc zudo-doc-sidebar-width zudo-sg zudo-sg-token-tweak-bridge");
@@ -0,0 +1,12 @@
1
+ import type { JSX } from "preact";
2
+ export interface CatalogFilterProps {
3
+ /** Category labels in display order (drives the chip row). */
4
+ categories: string[];
5
+ /** Total component count, for the result summary. */
6
+ total: number;
7
+ }
8
+ declare function CatalogFilter({ categories, total, }: CatalogFilterProps): JSX.Element;
9
+ declare namespace CatalogFilter {
10
+ var displayName: string;
11
+ }
12
+ export default CatalogFilter;
@@ -0,0 +1,175 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "preact/jsx-runtime";
3
+ import { useEffect, useMemo, useRef, useState } from "preact/hooks";
4
+ import {
5
+ ATTR_TILE_SIZE,
6
+ DEFAULT_TILE_SIZE,
7
+ TILE_SIZES,
8
+ applyTileSize,
9
+ isTileSize,
10
+ readTileSize
11
+ } from "../catalog/tile-size.js";
12
+ function normalize(s) {
13
+ return s.trim().toLowerCase();
14
+ }
15
+ function tileOf(card) {
16
+ return card.closest("[data-sg-tile]") ?? card;
17
+ }
18
+ function CatalogFilter({
19
+ categories,
20
+ total
21
+ }) {
22
+ const [query, setQuery] = useState("");
23
+ const [activeCategory, setActiveCategory] = useState(null);
24
+ const [visibleCount, setVisibleCount] = useState(total);
25
+ const [tileSize, setTileSize] = useState(DEFAULT_TILE_SIZE);
26
+ const inputRef = useRef(null);
27
+ useEffect(() => {
28
+ const current = document.documentElement.getAttribute(ATTR_TILE_SIZE);
29
+ setTileSize(isTileSize(current) ? current : readTileSize());
30
+ }, []);
31
+ useEffect(() => {
32
+ const q = normalize(query);
33
+ const root = document.querySelector("[data-sg-catalog]");
34
+ if (!root) return;
35
+ const cards = root.querySelectorAll("[data-sg-card]");
36
+ let shown = 0;
37
+ for (const card of cards) {
38
+ const name = card.dataset.name ?? "";
39
+ const category = card.dataset.category ?? "";
40
+ const keywords = card.dataset.keywords ?? "";
41
+ const matchesQuery = q === "" || name.includes(q) || keywords.includes(q);
42
+ const matchesCategory = activeCategory === null || category === activeCategory;
43
+ const visible = matchesQuery && matchesCategory;
44
+ tileOf(card).hidden = !visible;
45
+ if (visible) shown++;
46
+ }
47
+ const sections = root.querySelectorAll("[data-sg-section]");
48
+ for (const section of sections) {
49
+ const anyVisible = [
50
+ ...section.querySelectorAll("[data-sg-card]")
51
+ ].some((card) => !tileOf(card).hidden);
52
+ section.hidden = !anyVisible;
53
+ }
54
+ const empty = root.querySelector("[data-sg-empty]");
55
+ if (empty) empty.hidden = shown !== 0;
56
+ setVisibleCount(shown);
57
+ }, [query, activeCategory]);
58
+ useEffect(() => {
59
+ function onKey(e) {
60
+ if (e.key !== "/" || e.metaKey || e.ctrlKey || e.altKey) return;
61
+ const target = e.target;
62
+ const tag = target?.tagName;
63
+ if (tag === "INPUT" || tag === "TEXTAREA" || target?.isContentEditable) {
64
+ return;
65
+ }
66
+ e.preventDefault();
67
+ inputRef.current?.focus();
68
+ }
69
+ window.addEventListener("keydown", onKey);
70
+ return () => window.removeEventListener("keydown", onKey);
71
+ }, []);
72
+ const summary = useMemo(() => {
73
+ if (query === "" && activeCategory === null) {
74
+ return `${total} component${total === 1 ? "" : "s"}`;
75
+ }
76
+ return `${visibleCount} of ${total} shown`;
77
+ }, [query, activeCategory, visibleCount, total]);
78
+ return /* @__PURE__ */ jsxs("div", { class: "sg-filter", children: [
79
+ /* @__PURE__ */ jsxs("div", { class: "sg-filter-row", children: [
80
+ /* @__PURE__ */ jsxs("div", { class: "sg-search-field", children: [
81
+ /* @__PURE__ */ jsxs(
82
+ "svg",
83
+ {
84
+ width: "18",
85
+ height: "18",
86
+ viewBox: "0 0 24 24",
87
+ fill: "none",
88
+ stroke: "currentColor",
89
+ "stroke-width": "2",
90
+ "stroke-linecap": "round",
91
+ "stroke-linejoin": "round",
92
+ "aria-hidden": "true",
93
+ class: "text-muted",
94
+ children: [
95
+ /* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
96
+ /* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })
97
+ ]
98
+ }
99
+ ),
100
+ /* @__PURE__ */ jsx(
101
+ "input",
102
+ {
103
+ ref: inputRef,
104
+ type: "search",
105
+ value: query,
106
+ onInput: (e) => {
107
+ if (!(e.target instanceof HTMLInputElement)) return;
108
+ setQuery(e.target.value);
109
+ },
110
+ placeholder: "Search components\u2026 ( / )",
111
+ "aria-label": "Search components by name",
112
+ class: "sg-search-input",
113
+ autocomplete: "off",
114
+ spellcheck: false
115
+ }
116
+ ),
117
+ query !== "" && /* @__PURE__ */ jsx(
118
+ "button",
119
+ {
120
+ type: "button",
121
+ class: "sg-search-clear",
122
+ onClick: () => {
123
+ setQuery("");
124
+ inputRef.current?.focus();
125
+ },
126
+ "aria-label": "Clear search",
127
+ children: "\xD7"
128
+ }
129
+ )
130
+ ] }),
131
+ /* @__PURE__ */ jsx("span", { class: "text-xs text-muted", "aria-live": "polite", children: summary }),
132
+ /* @__PURE__ */ jsx("div", { class: "sg-seg", role: "group", "aria-label": "Tile size", children: TILE_SIZES.map((option) => /* @__PURE__ */ jsx(
133
+ "button",
134
+ {
135
+ type: "button",
136
+ class: "sg-seg-btn",
137
+ "aria-pressed": tileSize === option.id,
138
+ onClick: () => {
139
+ setTileSize(option.id);
140
+ applyTileSize(option.id);
141
+ },
142
+ children: option.label
143
+ },
144
+ option.id
145
+ )) })
146
+ ] }),
147
+ /* @__PURE__ */ jsxs("div", { class: "sg-chip-row", role: "group", "aria-label": "Filter by category", children: [
148
+ /* @__PURE__ */ jsx(
149
+ "button",
150
+ {
151
+ type: "button",
152
+ class: "sg-chip",
153
+ "aria-pressed": activeCategory === null,
154
+ onClick: () => setActiveCategory(null),
155
+ children: "All"
156
+ }
157
+ ),
158
+ categories.map((cat) => /* @__PURE__ */ jsx(
159
+ "button",
160
+ {
161
+ type: "button",
162
+ class: "sg-chip",
163
+ "aria-pressed": activeCategory === cat,
164
+ onClick: () => setActiveCategory((prev) => prev === cat ? null : cat),
165
+ children: cat
166
+ },
167
+ cat
168
+ ))
169
+ ] })
170
+ ] });
171
+ }
172
+ CatalogFilter.displayName = "CatalogFilter";
173
+ export {
174
+ CatalogFilter as default
175
+ };
@@ -0,0 +1,2 @@
1
+ export { default as CatalogFilter } from "./catalog-filter.js";
2
+ export type { CatalogFilterProps } from "./catalog-filter.js";
@@ -0,0 +1,4 @@
1
+ import { default as default2 } from "./catalog-filter.js";
2
+ export {
3
+ default2 as CatalogFilter
4
+ };
@@ -0,0 +1,24 @@
1
+ import type { ComponentDocsRoot } from "./registry/component-docs.js";
2
+ import type { SgRoutes } from "./sg-routes.js";
3
+ /** Default URL of the standalone-compiled preview stylesheet (ADR decision 4). */
4
+ export declare const DEFAULT_PREVIEW_CSS_URL = "/_zudo-sg/preview.css";
5
+ /** Default catalog landing heading. */
6
+ export declare const DEFAULT_CATALOG_TITLE = "Component catalog";
7
+ export interface SgCatalogText {
8
+ title: string;
9
+ /** Host intro paragraph; `null` lets the catalog route render its built-in intro. */
10
+ intro: string | null;
11
+ }
12
+ export interface SgContext {
13
+ /** zfb `config.base` (`"/"` when unset). */
14
+ base: string;
15
+ routes: SgRoutes;
16
+ categoryOrder: string[];
17
+ /** Package name shown in code-panel import snippets; `null` when the host did not set one. */
18
+ uiPackageName: string | null;
19
+ /** Root-absolute preview stylesheet URL, before the base prefix. */
20
+ previewCssUrl: string;
21
+ catalog: SgCatalogText;
22
+ /** One entry per components root: its registry key prefix + MDX docs collection (`[]` = no docs). */
23
+ componentDocs: ComponentDocsRoot[];
24
+ }
@@ -0,0 +1,6 @@
1
+ const DEFAULT_PREVIEW_CSS_URL = "/_zudo-sg/preview.css";
2
+ const DEFAULT_CATALOG_TITLE = "Component catalog";
3
+ export {
4
+ DEFAULT_CATALOG_TITLE,
5
+ DEFAULT_PREVIEW_CSS_URL
6
+ };
@@ -0,0 +1,12 @@
1
+ export interface SgRoutes {
2
+ componentsIndex: string;
3
+ /** Must contain the `[slug]` segment. */
4
+ componentsSlug: string;
5
+ componentsPreview: string;
6
+ tokens: string;
7
+ }
8
+ export declare const DEFAULT_SG_ROUTES: Readonly<SgRoutes>;
9
+ /** Fills unset route patterns with the defaults. */
10
+ export declare function resolveSgRoutes(routes?: Partial<SgRoutes>): SgRoutes;
11
+ /** Substitutes `[slug]` in `routes.componentsSlug` (`"/components/[slug]"` + `"button"` → `"/components/button"`). */
12
+ export declare function componentHref(routes: Pick<SgRoutes, "componentsSlug">, slug: string): string;
@@ -0,0 +1,17 @@
1
+ const DEFAULT_SG_ROUTES = Object.freeze({
2
+ componentsIndex: "/components",
3
+ componentsSlug: "/components/[slug]",
4
+ componentsPreview: "/components/preview",
5
+ tokens: "/tokens"
6
+ });
7
+ function resolveSgRoutes(routes = {}) {
8
+ return { ...DEFAULT_SG_ROUTES, ...routes };
9
+ }
10
+ function componentHref(routes, slug) {
11
+ return routes.componentsSlug.replace("[slug]", slug);
12
+ }
13
+ export {
14
+ DEFAULT_SG_ROUTES,
15
+ componentHref,
16
+ resolveSgRoutes
17
+ };
@@ -0,0 +1,2 @@
1
+ export type { Story, StoryCategory, StoryControl, StoryMeta, StoryModule, } from "./types.js";
2
+ export { defineStory } from "./types.js";
@@ -0,0 +1,4 @@
1
+ import { defineStory } from "./types.js";
2
+ export {
3
+ defineStory
4
+ };