@weasel-js/forge 1.6.1 → 1.7.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.
- package/README.md +33 -0
- package/dist/{FrameController-BspC9Zr5.d.ts → FrameController-HEcTM04H.d.ts} +24 -1
- package/dist/{chunk-DIOLWCH7.js → chunk-7GQI2PDH.js} +7 -63
- package/dist/chunk-7GQI2PDH.js.map +1 -0
- package/dist/{chunk-CSAXZIMV.js → chunk-DDDCZ6XW.js} +98 -11
- package/dist/chunk-DDDCZ6XW.js.map +1 -0
- package/dist/{chunk-OLWZURU3.js → chunk-ERRLEH6S.js} +10 -11
- package/dist/chunk-ERRLEH6S.js.map +1 -0
- package/dist/chunk-LLGBNJAZ.js +77 -0
- package/dist/chunk-LLGBNJAZ.js.map +1 -0
- package/dist/chunk-WEQSLPKT.js +9 -0
- package/dist/chunk-WEQSLPKT.js.map +1 -0
- package/dist/{chunk-JXIWZFD4.js → chunk-YKN3IAEX.js} +12 -10
- package/dist/chunk-YKN3IAEX.js.map +1 -0
- package/dist/{config-C5Vq5Kjj.d.ts → config-pDbcbGco.d.ts} +15 -3
- package/dist/csf/preview-api.js +1 -1
- package/dist/frame/index.css +63 -7
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +4 -2
- package/dist/frame/index.js +10 -3
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/shell/index.css +162 -3
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +34 -31
- package/dist/shell/index.js +166 -188
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +4 -3
- package/dist/test/index.js.map +1 -1
- package/dist/vite/index.js +344 -18
- package/dist/vite/index.js.map +1 -1
- package/package.json +10 -10
- package/dist/chunk-CSAXZIMV.js.map +0 -1
- package/dist/chunk-DIOLWCH7.js.map +0 -1
- package/dist/chunk-JXIWZFD4.js.map +0 -1
- package/dist/chunk-OLWZURU3.js.map +0 -1
package/README.md
CHANGED
|
@@ -69,6 +69,18 @@ the component's row in the sidebar (its fold mark only folds it) and routed at
|
|
|
69
69
|
of the component's stories in one trial: each at its defaults, then once per
|
|
70
70
|
value of each of its boolean and enum controls, one control at a time.
|
|
71
71
|
|
|
72
|
+
Under its title, an index page lists the components it uses and the ones that
|
|
73
|
+
use it, each linking to that component's index page. The plugin reads these
|
|
74
|
+
from source, not from anything an author writes: a component is the binding its
|
|
75
|
+
meta's `component` names, followed through imports and re-exports (barrels
|
|
76
|
+
included) to the file declaring it. When `component` is declared in the story
|
|
77
|
+
file itself, or absent, the import the title's last segment names stands in.
|
|
78
|
+
What it uses is every listed component that declaration reaches, through that
|
|
79
|
+
file's local helpers and the relative imports in its own directory. A component
|
|
80
|
+
whose file forge cannot find says so on its page and lists nothing. The graph is
|
|
81
|
+
built the first time the workshop asks for it, after the page is up, and an edit
|
|
82
|
+
re-reads only the file it touched.
|
|
83
|
+
|
|
72
84
|
A component can supply its own page. A native meta takes `index`; a CSF meta
|
|
73
85
|
sets `parameters.forge.index`. Either is handed an `IndexContext` holding the
|
|
74
86
|
stories and the generated page's parts, `Story`, `Variants` and `DefaultIndex`,
|
|
@@ -86,6 +98,27 @@ export default meta({
|
|
|
86
98
|
});
|
|
87
99
|
```
|
|
88
100
|
|
|
101
|
+
A custom page gets the list as `Dependencies`, and `gallery` says whether the
|
|
102
|
+
component is one.
|
|
103
|
+
|
|
104
|
+
## Galleries
|
|
105
|
+
|
|
106
|
+
A story file that catalogs many components, or every permutation of one, tags
|
|
107
|
+
its meta `gallery`, CSF's own `tags` field; a single such story tags itself.
|
|
108
|
+
Tags must be string literals, since the index reads them without running the
|
|
109
|
+
file. A story's tags are its meta's plus its own, and `'!gallery'` on a story
|
|
110
|
+
drops the meta's.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const meta: Meta = { title: 'ui/Icons/Gallery', tags: ['gallery'] };
|
|
114
|
+
export const AllPermutations: Story = { tags: ['gallery'], render: … };
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
A gallery row carries a grid mark in the sidebar and a Gallery badge on its
|
|
118
|
+
index page. A component every one of whose stories is a gallery is left out of
|
|
119
|
+
the dependency lists entirely, so a catalog that imports everything does not
|
|
120
|
+
appear as a user of everything.
|
|
121
|
+
|
|
89
122
|
## Story tests
|
|
90
123
|
|
|
91
124
|
`forgeTest` from `@weasel-js/forge/vite` runs every story as a vitest browser
|
|
@@ -209,6 +209,9 @@ interface MetaSpec {
|
|
|
209
209
|
isolate?: string;
|
|
210
210
|
/** The component's own index page, in place of the generated one. A CSF file sets `parameters.forge.index`. */
|
|
211
211
|
index?: IndexRender;
|
|
212
|
+
/** As CSF's meta `tags`; `'gallery'` marks a catalog or showcase rather than one component. Read from the source,
|
|
213
|
+
* so each must be a string literal. */
|
|
214
|
+
tags?: readonly string[];
|
|
212
215
|
}
|
|
213
216
|
/** What an index page is given: its component's stories, and the parts the generated page is built from. */
|
|
214
217
|
interface IndexContext {
|
|
@@ -226,6 +229,10 @@ interface IndexContext {
|
|
|
226
229
|
}>;
|
|
227
230
|
/** The whole generated page. */
|
|
228
231
|
DefaultIndex: ComponentType;
|
|
232
|
+
/** The listed components this one uses and those that use it, as the generated page shows them. */
|
|
233
|
+
Dependencies: ComponentType;
|
|
234
|
+
/** Whether the meta is tagged `gallery`. */
|
|
235
|
+
gallery: boolean;
|
|
229
236
|
/** Shows story `id` in this page's trial in its place. */
|
|
230
237
|
open: (id: string) => void;
|
|
231
238
|
}
|
|
@@ -248,6 +255,8 @@ interface StorySpec<C = Record<string, never>, S = undefined> {
|
|
|
248
255
|
/** Renders this story in its own frame document, for a reason the value states. The default is the workshop document. */
|
|
249
256
|
isolate?: string;
|
|
250
257
|
play?: (ctx: PlayContext<C>) => void | Promise<void>;
|
|
258
|
+
/** Added to the meta's `tags`; `'!tag'` drops one. Read from the source, so each must be a string literal. */
|
|
259
|
+
tags?: readonly string[];
|
|
251
260
|
}
|
|
252
261
|
/** One story, normalized — what both the native and CSF loaders produce. */
|
|
253
262
|
interface LoadedStory {
|
|
@@ -281,7 +290,21 @@ interface IndexEntry {
|
|
|
281
290
|
componentName?: string;
|
|
282
291
|
/** Read statically from the source; a story with it renders in its own frame. */
|
|
283
292
|
isolate?: string;
|
|
293
|
+
/** The story's tags, read statically from the source: its meta's and its own. An index page's are those every
|
|
294
|
+
* story of its component carries. */
|
|
295
|
+
tags?: string[];
|
|
284
296
|
}
|
|
297
|
+
/** One component's place in the component graph. Every list holds story titles, sorted. */
|
|
298
|
+
interface ComponentDeps {
|
|
299
|
+
/** The file declaring the component, relative to the vite root; null when forge could not find one. */
|
|
300
|
+
source: string | null;
|
|
301
|
+
/** The listed components its own source imports. */
|
|
302
|
+
uses: string[];
|
|
303
|
+
/** The listed components whose own source imports it. */
|
|
304
|
+
usedBy: string[];
|
|
305
|
+
}
|
|
306
|
+
/** The component graph the vite plugin derives from source, by story title. A gallery has no entry. */
|
|
307
|
+
type DepGraph = Record<string, ComponentDeps>;
|
|
285
308
|
|
|
286
309
|
/** What a setup's `applyGlobals` is handed: the element the globals apply to, and a way to style it alone. */
|
|
287
310
|
interface GlobalsTarget {
|
|
@@ -323,4 +346,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
|
|
|
323
346
|
/** Reports an import failure — there is no story to start. */
|
|
324
347
|
declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
|
|
325
348
|
|
|
326
|
-
export { type A11yFinding as A, type
|
|
349
|
+
export { type A11yFinding as A, type ComponentDeps as C, type Decorator as D, type FrameSetup as F, type Globals as G, type IndexContext as I, type LoadedStory as L, type MetaSpec as M, type PlayContext as P, type StorySpec as S, type ToFrame as T, type Viewport as V, type A11yNode as a, type A11yReport as b, type DepGraph as c, type GlobalsTarget as d, type IndexRender as e, type IndexStoryProps as f, type StoryContext as g, type IndexEntry as h, type Layout as i, type FromFrame as j, type CssVarReport as k, type CapturedPicture as l, type StartFrameOptions as m, reportImportFault as r, startFrame as s };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GLOBALS_KEY, effectiveGlobals, storyConfig, isGlobalsPath } from './chunk-LLGBNJAZ.js';
|
|
2
|
+
import { createOverrides, createGlobalsTarget, StoryHost, scanCssVars, runAxe, captureElement } from './chunk-ERRLEH6S.js';
|
|
2
3
|
import { createContext, useContext, useCallback, useSyncExternalStore, useMemo, useId, useState, useRef, useLayoutEffect, useEffect } from 'react';
|
|
3
4
|
import { usePersistedState, TrialIdContext, LabBoundary } from '@weasel-js/labkit';
|
|
4
5
|
import { OverlayPortalProvider } from '@weasel-js/ui';
|
|
5
|
-
import { f } from '@weasel-js/labkit/config';
|
|
6
6
|
import { jsx } from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
var NO_FRAME = { send: null, vars: [], audit: null, a11y: null, capture: null, size: null };
|
|
@@ -73,62 +73,6 @@ var NONE = {};
|
|
|
73
73
|
function useCssOverrides() {
|
|
74
74
|
return usePersistedState("fg-css-overrides", NONE, { scope: "trial" });
|
|
75
75
|
}
|
|
76
|
-
var GLOBALS_KEY = "$globals";
|
|
77
|
-
var FOLLOW_LAB = "lab";
|
|
78
|
-
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
79
|
-
var isGlobalsPath = (path) => path === GLOBALS_KEY || path.startsWith(`${GLOBALS_KEY}.`);
|
|
80
|
-
function shownOptions(declaration, globals) {
|
|
81
|
-
const { shows } = declaration;
|
|
82
|
-
return shows ? declaration.options.filter((option) => shows(option.value, globals)) : declaration.options;
|
|
83
|
-
}
|
|
84
|
-
function labGlobals(declarations, stored) {
|
|
85
|
-
const from = isRecord(stored) ? stored : {};
|
|
86
|
-
const offered = Object.fromEntries(
|
|
87
|
-
Object.entries(declarations).map(([key, declaration]) => {
|
|
88
|
-
const value = from[key];
|
|
89
|
-
return [key, declaration.options.some((option) => option.value === value) ? value : declaration.default];
|
|
90
|
-
})
|
|
91
|
-
);
|
|
92
|
-
return Object.fromEntries(
|
|
93
|
-
Object.entries(declarations).map(([key, declaration]) => {
|
|
94
|
-
const shown = shownOptions(declaration, offered);
|
|
95
|
-
const value = offered[key];
|
|
96
|
-
if (!declaration.shows || shown.length === 0 || shown.some((option) => option.value === value)) return [key, value];
|
|
97
|
-
const at = (v) => declaration.options.findIndex((option) => option.value === v);
|
|
98
|
-
const from2 = at(value);
|
|
99
|
-
const nearest = shown.reduce(
|
|
100
|
-
(best, option) => Math.abs(at(option.value) - from2) < Math.abs(at(best.value) - from2) ? option : best
|
|
101
|
-
);
|
|
102
|
-
return [key, nearest.value];
|
|
103
|
-
})
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
function effectiveGlobals(lab, pins) {
|
|
107
|
-
if (!isRecord(pins)) return lab;
|
|
108
|
-
const pinned = Object.entries(pins).filter(([key, value]) => key in lab && value !== FOLLOW_LAB);
|
|
109
|
-
return pinned.length === 0 ? lab : { ...lab, ...Object.fromEntries(pinned) };
|
|
110
|
-
}
|
|
111
|
-
function storyConfig(config, previous) {
|
|
112
|
-
if (!isRecord(config) || !(GLOBALS_KEY in config)) return config;
|
|
113
|
-
const rest = Object.fromEntries(Object.entries(config).filter(([key]) => key !== GLOBALS_KEY));
|
|
114
|
-
if (isRecord(previous)) {
|
|
115
|
-
const keys = Object.keys(rest);
|
|
116
|
-
if (keys.length === Object.keys(previous).length && keys.every((key) => rest[key] === previous[key])) return previous;
|
|
117
|
-
}
|
|
118
|
-
return rest;
|
|
119
|
-
}
|
|
120
|
-
function withGlobals(schema, declarations) {
|
|
121
|
-
const entries = Object.entries(declarations);
|
|
122
|
-
if (entries.length === 0) return schema;
|
|
123
|
-
const leaves = Object.fromEntries(
|
|
124
|
-
entries.map(([key, declaration]) => [
|
|
125
|
-
key,
|
|
126
|
-
f.enum(FOLLOW_LAB, [{ value: FOLLOW_LAB, label: "Lab" }, ...declaration.options]).label(declaration.label)
|
|
127
|
-
])
|
|
128
|
-
);
|
|
129
|
-
const group = f.group(leaves).label("").section("Globals", { layout: "inline", pack: "pairs" });
|
|
130
|
-
return f.schema({ ...schema.nodes, [GLOBALS_KEY]: group });
|
|
131
|
-
}
|
|
132
76
|
var IN_VIEW_MARGIN = "50%";
|
|
133
77
|
var VARS_SETTLE_MS = 100;
|
|
134
78
|
function useInView(ref) {
|
|
@@ -152,9 +96,9 @@ var scopeOf = (id) => `[data-fg-host="${id}"]`;
|
|
|
152
96
|
function TrialHost({ layout, setup, config, children, hostRef, onRendered }) {
|
|
153
97
|
const trialId = useContext(TrialIdContext);
|
|
154
98
|
const frames = useContext(TrialFramesContext);
|
|
155
|
-
const
|
|
99
|
+
const labGlobals = useContext(StoryGlobalsContext);
|
|
156
100
|
const pins = config?.[GLOBALS_KEY];
|
|
157
|
-
const globals = useMemo(() => effectiveGlobals(
|
|
101
|
+
const globals = useMemo(() => effectiveGlobals(labGlobals, pins), [labGlobals, pins]);
|
|
158
102
|
const [persisted] = useCssOverrides();
|
|
159
103
|
const reactId = useId();
|
|
160
104
|
const hostId = trialId ?? reactId;
|
|
@@ -337,6 +281,6 @@ function StoryTrial({ story, setup, ctx, hostRef, onRendered, onError }) {
|
|
|
337
281
|
);
|
|
338
282
|
}
|
|
339
283
|
|
|
340
|
-
export {
|
|
341
|
-
//# sourceMappingURL=chunk-
|
|
342
|
-
//# sourceMappingURL=chunk-
|
|
284
|
+
export { StoryGlobalsContext, StoryTrial, TrialFramesContext, TrialHost, createTrialFrames, useCssOverrides, useTrialFrame };
|
|
285
|
+
//# sourceMappingURL=chunk-7GQI2PDH.js.map
|
|
286
|
+
//# sourceMappingURL=chunk-7GQI2PDH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/shell/trialFrames.ts","../src/shell/StoryGlobalsContext.ts","../src/shell/cssVars/overrides.ts","../src/shell/TrialHost.tsx","../src/shell/StoryTrial.tsx"],"names":["createContext","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;AAAA,MACX,GAAI,OAAA,GAAU,EAAE,OAAA,KAAY,EAAC;AAAA,MAC7B,GAAI,UAAA,GAAa,EAAE,UAAA,KAAe,EAAC;AAAA,MAEnC,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ","file":"chunk-7GQI2PDH.js","sourcesContent":["import { createContext, type RefObject, useCallback, useContext, useSyncExternalStore } from 'react';\nimport type { A11yReport, CapturedPicture, CssVarReport, ToFrame, Viewport } from '../protocol/messages';\n\ntype Send = (msg: ToFrame) => void;\n\n/** What an axe run in the frame came back with. */\nexport type A11yOutcome = { ok: true; report: A11yReport } | { ok: false; message: string };\n\n/** The half of a trial's frame that answers a request: each call is one round trip over the frame's channel. */\nexport interface TrialFrameCalls {\n send: Send;\n audit: () => Promise<A11yOutcome>;\n /** Rejects when the frame could not draw itself, or went away before it did. */\n capture: () => Promise<CapturedPicture>;\n}\n\n/** What trial chrome can reach of the frame its trial shows. */\nexport interface TrialFrame {\n /** Null while no frame is connected. */\n send: Send | null;\n /** The frame's latest `vars` report. */\n vars: readonly CssVarReport[];\n /** Runs axe over the story and records the answer as `a11y`. Null while no frame is connected. */\n audit: (() => Promise<A11yOutcome>) | null;\n /** What the last audit found; null until one has run against the connected frame. */\n a11y: A11yOutcome | null;\n /** The story's own picture, for an export to draw over. Null while no frame is connected. */\n capture: (() => Promise<CapturedPicture>) | null;\n /** The story's content box, as the frame last measured it; null until it has. */\n size: Viewport | null;\n}\n\n/** Each trial's frame, keyed by trial id: `FrameView` connects and reports, trial chrome reads. */\nexport interface TrialFrames {\n /** Returns a disconnect that does nothing once a newer connection replaced this one. */\n connect(trialId: string, calls: TrialFrameCalls): () => void;\n report(trialId: string, vars: readonly CssVarReport[]): void;\n reportA11y(trialId: string, outcome: A11yOutcome): void;\n reportSize(trialId: string, size: Viewport): void;\n /** The element a trial's frame is mounted in — stable across the frame reloads that replace the link,\n * because an annotation target's ref has to outlive them. */\n hostRef(trialId: string): RefObject<HTMLElement | null>;\n get(trialId: string): TrialFrame;\n subscribe(listener: () => void): () => void;\n}\n\nconst NO_FRAME: TrialFrame = { send: null, vars: [], audit: null, a11y: null, capture: null, size: null };\n\nexport function createTrialFrames(): TrialFrames {\n const frames = new Map<string, TrialFrame>();\n const hosts = new Map<string, RefObject<HTMLElement | null>>();\n const listeners = new Set<() => void>();\n const changed = () => {\n for (const listener of [...listeners]) listener();\n };\n const patch = (trialId: string, next: Partial<TrialFrame>) => {\n const frame = frames.get(trialId);\n if (!frame) return;\n frames.set(trialId, { ...frame, ...next });\n changed();\n };\n return {\n connect(trialId, calls) {\n const held = frames.get(trialId);\n frames.set(trialId, {\n send: calls.send,\n vars: [],\n audit: calls.audit,\n a11y: null,\n capture: calls.capture,\n size: held?.size ?? null,\n });\n changed();\n return () => {\n if (frames.get(trialId)?.send !== calls.send) return;\n frames.delete(trialId);\n changed();\n };\n },\n report: (trialId, vars) => patch(trialId, { vars }),\n reportA11y: (trialId, a11y) => patch(trialId, { a11y }),\n reportSize(trialId, size) {\n const frame = frames.get(trialId) ?? NO_FRAME;\n if (frame.size?.width === size.width && frame.size?.height === size.height) return;\n frames.set(trialId, { ...frame, size });\n changed();\n },\n hostRef(trialId) {\n let ref = hosts.get(trialId);\n if (!ref) {\n ref = { current: null };\n hosts.set(trialId, ref);\n }\n return ref;\n },\n get: (trialId) => frames.get(trialId) ?? NO_FRAME,\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\nexport const TrialFramesContext = createContext<TrialFrames | null>(null);\n\n/** The frame of the trial `trialId` names, re-read when it connects or reports. */\nexport function useTrialFrame(trialId: string): TrialFrame {\n const frames = useContext(TrialFramesContext);\n const subscribe = useCallback((listener: () => void) => frames?.subscribe(listener) ?? (() => {}), [frames]);\n const read = () => frames?.get(trialId) ?? NO_FRAME;\n return useSyncExternalStore(subscribe, read, read);\n}\n","import { createContext } from 'react';\nimport type { Globals } from '../protocol/messages';\n\n/** The lab's global values, which a trial's pins override. A change reaches open frames without replacing instruments. */\nexport const StoryGlobalsContext = createContext<Globals>({});\n","import { usePersistedState } from '@weasel-js/labkit';\n\nexport type CssOverrides = Readonly<Record<string, string>>;\n\nconst NONE: CssOverrides = {};\n\n/** The CSS variable overrides of the trial this is rendered inside, persisted with it. */\nexport function useCssOverrides() {\n return usePersistedState<CssOverrides>('fg-css-overrides', NONE, { scope: 'trial' });\n}\n","import { LabBoundary, TrialIdContext } from '@weasel-js/labkit';\nimport { OverlayPortalProvider } from '@weasel-js/ui';\nimport {\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useId,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { runAxe } from '../frame/a11y';\nimport { captureElement } from '../frame/capture';\nimport { createOverrides, type Overrides, scanCssVars } from '../frame/cssVars';\nimport type { FrameSetup } from '../frame/FrameController';\nimport { createGlobalsTarget } from '../frame/globalsTarget';\nimport type { CssVarReport, Globals, Layout, ToFrame } from '../protocol/messages';\nimport { useCssOverrides } from './cssVars/overrides';\nimport { effectiveGlobals, GLOBALS_KEY } from './globals';\nimport { StoryGlobalsContext } from './StoryGlobalsContext';\nimport { type A11yOutcome, TrialFramesContext } from './trialFrames';\n\nexport interface TrialHostProps {\n layout: Layout;\n setup: FrameSetup;\n /** The trial's config, read for its `$globals` pins. */\n config: unknown;\n /** Rendered once the host element exists, with the globals in force on it. */\n children: (globals: Globals) => ReactNode;\n /** Receives the host element, for a caller with no trial to reach it through. */\n hostRef?: RefObject<HTMLElement | null>;\n /** Called once the children's first commit has painted. */\n onRendered?: () => void;\n}\n\n/** How far past the viewport a story stays mounted, so a small scroll back does not remount it. */\nconst IN_VIEW_MARGIN = '50%';\nconst VARS_SETTLE_MS = 100;\n\n/** Whether `ref`'s element is near the viewport; true where the browser cannot say. */\nfunction useInView(ref: RefObject<Element | null>): boolean {\n const [inView, setInView] = useState(true);\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof IntersectionObserver === 'undefined') return;\n const observer = new IntersectionObserver(\n (entries) => {\n const last = entries.at(-1);\n if (last) setInView(last.isIntersecting);\n },\n { rootMargin: IN_VIEW_MARGIN },\n );\n observer.observe(el);\n return () => observer.disconnect();\n }, [ref]);\n return inView;\n}\n\n/** A selector matching only the element carrying `id`. */\nconst scopeOf = (id: string) => `[data-fg-host=\"${id}\"]`;\n\n/**\n * One story's box in the workshop document: what a frame document was, as an element. It applies the globals to\n * itself, keeps its CSS variable overrides on itself, contains fixed-position descendants and portals, reports its\n * vars, size and audits to the trial's frame registry, and unmounts its content while out of view.\n */\nexport function TrialHost({ layout, setup, config, children, hostRef, onRendered }: TrialHostProps) {\n const trialId = useContext(TrialIdContext);\n const frames = useContext(TrialFramesContext);\n const labGlobals = useContext(StoryGlobalsContext);\n const pins = (config as Record<string, unknown> | null | undefined)?.[GLOBALS_KEY];\n const globals = useMemo(() => effectiveGlobals(labGlobals, pins), [labGlobals, pins]);\n const [persisted] = useCssOverrides();\n const reactId = useId();\n const hostId = trialId ?? reactId;\n const [host, setHost] = useState<HTMLDivElement | null>(null);\n const elementRef = useRef<HTMLDivElement | null>(null);\n const inView = useInView(elementRef);\n const [pending, setPending] = useState(true);\n const overridesRef = useRef<Overrides | null>(null);\n const latest = useRef({ setup, onRendered });\n latest.current = { setup, onRendered };\n\n // Everything the host owns for its lifetime: the globals target, the overrides rule, the registry connection.\n useLayoutEffect(() => {\n if (!host) return;\n const doc = host.ownerDocument;\n const scope = scopeOf(hostId);\n const { cssVarsScope } = latest.current.setup;\n const overrides = createOverrides(doc, cssVarsScope ? `${scope}, ${scope} :is(${cssVarsScope})` : scope);\n overridesRef.current = overrides;\n let lastVars: CssVarReport[] | null = null;\n let reported: string | null = null;\n const publish = (vars: CssVarReport[]) => {\n lastVars = vars;\n const key = JSON.stringify(vars);\n if (key === reported) return;\n reported = key;\n if (trialId) frames?.report(trialId, vars);\n };\n const scan = () => publish(scanCssVars(doc, overrides.has, host));\n let settleTimer: ReturnType<typeof setTimeout> | undefined;\n const ownMutation = (record: MutationRecord) =>\n overrides.owns(record.target) ||\n (record.type === 'childList' &&\n [...record.addedNodes, ...record.removedNodes].length > 0 &&\n [...record.addedNodes, ...record.removedNodes].every(overrides.owns));\n const mutations =\n typeof MutationObserver === 'undefined'\n ? null\n : new MutationObserver((records) => {\n if (records.every(ownMutation)) return;\n clearTimeout(settleTimer);\n settleTimer = setTimeout(scan, VARS_SETTLE_MS);\n });\n mutations?.observe(host, { subtree: true, childList: true, characterData: true, attributes: true });\n\n const send = (msg: ToFrame) => {\n if (msg.type !== 'vars.set') return;\n overrides.set(msg.name, msg.value);\n const at = lastVars?.findIndex((v) => v.name === msg.name) ?? -1;\n if (!lastVars || at < 0) return;\n const vars = lastVars.slice();\n vars[at] = { ...vars[at]!, overridden: overrides.has(msg.name) };\n scan();\n };\n const audit = async (): Promise<A11yOutcome> => {\n let outcome: A11yOutcome;\n try {\n outcome = { ok: true, report: await runAxe(host, { page: false }) };\n } catch (error) {\n outcome = { ok: false, message: error instanceof Error ? error.message : String(error) };\n }\n if (trialId) frames?.reportA11y(trialId, outcome);\n return outcome;\n };\n const capture = async () => captureElement(host);\n const disconnect = frames && trialId ? frames.connect(trialId, { send, audit, capture }) : () => {};\n if (frames && trialId) frames.hostRef(trialId).current = host;\n\n const sizes =\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver(() => {\n const { width, height } = host.getBoundingClientRect();\n if (trialId) frames?.reportSize(trialId, { width: Math.ceil(width), height: Math.ceil(height) });\n });\n sizes?.observe(host);\n\n return () => {\n disconnect();\n sizes?.disconnect();\n mutations?.disconnect();\n clearTimeout(settleTimer);\n overrides.dispose();\n overridesRef.current = null;\n if (frames && trialId && frames.hostRef(trialId).current === host) frames.hostRef(trialId).current = null;\n };\n }, [host, hostId, trialId, frames]);\n\n // The overrides the trial persisted, put back on every mount and kept in step with the panel's edits.\n const applied = useRef<Record<string, string>>({});\n useLayoutEffect(() => {\n const overrides = overridesRef.current;\n if (!overrides) return;\n for (const name of Object.keys(applied.current)) if (!(name in persisted)) overrides.set(name, null);\n for (const [name, value] of Object.entries(persisted)) overrides.set(name, value);\n applied.current = { ...persisted };\n }, [host, persisted]);\n\n useLayoutEffect(() => {\n if (!host) return;\n const target = createGlobalsTarget(host, scopeOf(hostId));\n latest.current.setup.applyGlobals?.(globals, target);\n return () => target.dispose();\n }, [host, hostId, globals]);\n\n // The host is hidden until its first commit has painted with its fonts, so a new trial never shows a jump.\n const announced = useRef(false);\n useEffect(() => {\n if (!host || !inView || announced.current) return;\n announced.current = true;\n let canceled = false;\n const done = () => {\n if (canceled) return;\n setPending(false);\n latest.current.onRendered?.();\n };\n const { fonts } = host.ownerDocument;\n if (!fonts) {\n done();\n return;\n }\n const afterPaint = () => requestAnimationFrame(done);\n void fonts.ready.then(afterPaint, afterPaint);\n return () => {\n canceled = true;\n };\n }, [host, inView]);\n\n return (\n <div\n ref={(el) => {\n elementRef.current = el;\n if (hostRef) hostRef.current = el;\n setHost(el);\n }}\n className=\"fg-story\"\n data-fg-host={hostId}\n data-fg-layout={layout}\n data-pending={pending || undefined}\n >\n {host && inView ? (\n // The workshop is itself a lab; below the boundary a story sees no lab, trial or theme above it, as in a\n // document of its own.\n <LabBoundary>\n <OverlayPortalProvider container={host}>{children(globals)}</OverlayPortalProvider>\n </LabBoundary>\n ) : null}\n </div>\n );\n}\n","import type { RenderContext } from '@weasel-js/labkit';\nimport { type RefObject, useCallback, useEffect, useMemo, useRef } from 'react';\nimport type { FrameSetup } from '../frame/FrameController';\nimport { StoryHost } from '../frame/StoryHost';\nimport type { Globals } from '../protocol/messages';\nimport type { LoadedStory, StoryContext } from '../story/types';\nimport { isGlobalsPath, storyConfig } from './globals';\nimport { TrialHost } from './TrialHost';\n\nexport interface StoryTrialProps {\n story: LoadedStory;\n setup: FrameSetup;\n /** The trial's config and state; the story reads and writes them through its `StoryContext`. */\n ctx: Pick<RenderContext<unknown, unknown>, 'config' | 'state' | 'setConfig' | 'setState'>;\n hostRef?: RefObject<HTMLElement | null>;\n onRendered?: () => void;\n /** A render throw, after the boundary has shown it. */\n onError?: (error: unknown) => void;\n}\n\n/** A story rendered in the workshop document, inside a `TrialHost`, from the trial's own config and state. */\nexport function StoryTrial({ story, setup, ctx, hostRef, onRendered, onError }: StoryTrialProps) {\n const latest = useRef(ctx);\n latest.current = ctx;\n const config = useMemo(() => storyConfig(ctx.config), [ctx.config]);\n\n // A trial opened on the provisional instrument starts at `null`; the story's own initial state fills it once.\n const seeded = useRef(false);\n useEffect(() => {\n if (seeded.current || ctx.state !== null || !story.initialState) return;\n seeded.current = true;\n ctx.setState(story.initialState(config));\n }, [ctx, story, config]);\n\n // Each new input retries a render the boundary caught, as the frame did on each message.\n const input = useRef({ config, state: ctx.state, key: 0 });\n if (input.current.config !== config || input.current.state !== ctx.state) {\n input.current = { config, state: ctx.state, key: input.current.key + 1 };\n }\n const resetKey = input.current.key;\n\n // Stable, as the frame's were: a story may list them as effect dependencies.\n // The pins belong to the trial; a story cannot see them, so it cannot set them either.\n const setConfig = useCallback((path: string, value: unknown) => {\n if (!isGlobalsPath(path)) latest.current.setConfig(path, value);\n }, []);\n const setState = useCallback((next: unknown) => latest.current.setState(next), []);\n\n const decorators = setup.decorators ?? [];\n const render = (globals: Globals) => {\n const storyCtx: StoryContext = {\n config,\n setConfig,\n state: ctx.state,\n setState,\n globals,\n title: story.title,\n name: story.name,\n };\n return (\n <StoryHost\n story={story}\n ctx={storyCtx}\n decorators={decorators}\n resetKey={resetKey}\n onError={(error) => onError?.(error)}\n />\n );\n };\n\n return (\n <TrialHost\n layout={story.layout}\n setup={setup}\n config={ctx.config}\n {...(hostRef ? { hostRef } : {})}\n {...(onRendered ? { onRendered } : {})}\n >\n {render}\n </TrialHost>\n );\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { StoryHost
|
|
1
|
+
import { StoryHost } from './chunk-ERRLEH6S.js';
|
|
2
2
|
import { sanitize } from './chunk-HRGPFQBW.js';
|
|
3
|
-
import { PROTOCOL_VERSION } from './chunk-
|
|
3
|
+
import { PROTOCOL_VERSION, isPlainObject } from './chunk-YKN3IAEX.js';
|
|
4
4
|
import { f, isConfigBranch, resolveConfigSchema, schemaNodeAtPath, titleCase } from '@weasel-js/labkit/config';
|
|
5
|
+
import { Badge } from '@weasel-js/ui/components/Badge';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
5
7
|
import { Button } from '@weasel-js/ui/components/Button';
|
|
6
8
|
import { createContext, useMemo, useState, useRef, useEffect, useContext, useId } from 'react';
|
|
7
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
8
9
|
|
|
9
10
|
var joinPath = (at, key) => at === "" ? key : `${at}.${key}`;
|
|
10
11
|
function describeShape(shape) {
|
|
@@ -130,7 +131,15 @@ function isIndexId(id) {
|
|
|
130
131
|
function indexEntries(stories) {
|
|
131
132
|
const byTitle = /* @__PURE__ */ new Map();
|
|
132
133
|
for (const entry of stories) {
|
|
133
|
-
|
|
134
|
+
const page = byTitle.get(entry.title);
|
|
135
|
+
if (page) {
|
|
136
|
+
if (page.tags) {
|
|
137
|
+
const common = page.tags.filter((tag) => entry.tags?.includes(tag));
|
|
138
|
+
if (common.length > 0) page.tags = common;
|
|
139
|
+
else delete page.tags;
|
|
140
|
+
}
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
134
143
|
byTitle.set(entry.title, {
|
|
135
144
|
id: indexId(entry.title),
|
|
136
145
|
title: entry.title,
|
|
@@ -138,11 +147,38 @@ function indexEntries(stories) {
|
|
|
138
147
|
exportName: "",
|
|
139
148
|
file: entry.file,
|
|
140
149
|
...entry.componentDescription === void 0 ? {} : { componentDescription: entry.componentDescription },
|
|
141
|
-
...entry.componentName === void 0 ? {} : { componentName: entry.componentName }
|
|
150
|
+
...entry.componentName === void 0 ? {} : { componentName: entry.componentName },
|
|
151
|
+
...entry.tags === void 0 ? {} : { tags: entry.tags }
|
|
142
152
|
});
|
|
143
153
|
}
|
|
144
154
|
return [...byTitle.values()];
|
|
145
155
|
}
|
|
156
|
+
|
|
157
|
+
// src/story/library.ts
|
|
158
|
+
var LIBRARIES = [
|
|
159
|
+
["/packages/ui/", "ui"],
|
|
160
|
+
["/packages/labkit/", "labkit"],
|
|
161
|
+
["/packages/forge/", "forge"],
|
|
162
|
+
["/apps/draw/", "draw"],
|
|
163
|
+
["/apps/forge/", "forge"]
|
|
164
|
+
];
|
|
165
|
+
function libraryOf(entry) {
|
|
166
|
+
const file = entry.file.replaceAll("\\", "/");
|
|
167
|
+
for (const [marker, label] of LIBRARIES) {
|
|
168
|
+
if (file.includes(marker)) return label;
|
|
169
|
+
}
|
|
170
|
+
return entry.title.split("/")[0] ?? entry.title;
|
|
171
|
+
}
|
|
172
|
+
var tone = (swatch, light, dark) => `light-dark(color-mix(in oklab, var(--wzl-swatch-${swatch}), var(--wzl-fg) ${light}%), color-mix(in oklab, var(--wzl-swatch-${swatch}), var(--wzl-fg) ${dark}%))`;
|
|
173
|
+
var LIBRARY_TONES = {
|
|
174
|
+
ui: tone("amber", 55, 40),
|
|
175
|
+
labkit: tone("teal", 55, 45),
|
|
176
|
+
forge: tone("blue", 55, 35),
|
|
177
|
+
draw: tone("rose", 55, 35)
|
|
178
|
+
};
|
|
179
|
+
function LibraryBadge({ library, className }) {
|
|
180
|
+
return /* @__PURE__ */ jsx(Badge, { status: "muted", tone: LIBRARY_TONES[library], variant: "subtle", size: "sm", ...className ? { className } : {}, children: library });
|
|
181
|
+
}
|
|
146
182
|
var MAX_ENUM_OPTIONS = 8;
|
|
147
183
|
var MAX_ROWS = 6;
|
|
148
184
|
var labelOf = (key, name) => name ?? titleCase(key);
|
|
@@ -258,13 +294,53 @@ function IndexVariants({ story }) {
|
|
|
258
294
|
)) })
|
|
259
295
|
] }, row.path)) });
|
|
260
296
|
}
|
|
297
|
+
function GalleryBadge() {
|
|
298
|
+
return /* @__PURE__ */ jsx(Badge, { status: "accent", variant: "subtle", size: "sm", children: "Gallery" });
|
|
299
|
+
}
|
|
300
|
+
function DependencyList({ label, titles, empty }) {
|
|
301
|
+
const env = useEnv();
|
|
302
|
+
const labelId = useId();
|
|
303
|
+
const follow = (event, id) => {
|
|
304
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
305
|
+
event.preventDefault();
|
|
306
|
+
env.open(id);
|
|
307
|
+
};
|
|
308
|
+
return /* @__PURE__ */ jsxs("div", { className: "fg-index-deps__row", children: [
|
|
309
|
+
/* @__PURE__ */ jsx("dt", { id: labelId, className: "fg-index-deps__label", children: label }),
|
|
310
|
+
/* @__PURE__ */ jsx("dd", { className: "fg-index-deps__value", children: titles.length === 0 ? /* @__PURE__ */ jsx("span", { className: "fg-index-deps__empty", children: empty }) : /* @__PURE__ */ jsx("ul", { className: "fg-index-deps__list", "aria-labelledby": labelId, children: titles.map((title) => {
|
|
311
|
+
const cut = title.lastIndexOf("/") + 1;
|
|
312
|
+
const id = indexId(title);
|
|
313
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("a", { className: "fg-index-deps__link", href: `#/${encodeURIComponent(id)}`, onClick: (event) => follow(event, id), children: [
|
|
314
|
+
/* @__PURE__ */ jsx("span", { className: "fg-index-deps__prefix", children: title.slice(0, cut) }),
|
|
315
|
+
title.slice(cut)
|
|
316
|
+
] }) }, title);
|
|
317
|
+
}) }) })
|
|
318
|
+
] });
|
|
319
|
+
}
|
|
320
|
+
function IndexDependencies() {
|
|
321
|
+
const { gallery, dependencies } = useEnv();
|
|
322
|
+
if (gallery || !dependencies) return null;
|
|
323
|
+
if (dependencies.source === null) {
|
|
324
|
+
return /* @__PURE__ */ jsxs("p", { className: "fg-index-deps__none", children: [
|
|
325
|
+
"forge found no source file for this component, so it lists none of its dependencies. It looks for the import the meta\u2019s ",
|
|
326
|
+
/* @__PURE__ */ jsx("code", { children: "component" }),
|
|
327
|
+
" names, or else the one the title\u2019s last segment names."
|
|
328
|
+
] });
|
|
329
|
+
}
|
|
330
|
+
return /* @__PURE__ */ jsxs("dl", { className: "fg-index-deps", "aria-label": "Dependencies", children: [
|
|
331
|
+
/* @__PURE__ */ jsx(DependencyList, { label: "Uses", titles: dependencies.uses, empty: "No listed component." }),
|
|
332
|
+
/* @__PURE__ */ jsx(DependencyList, { label: "Used by", titles: dependencies.usedBy, empty: "No listed component uses it." })
|
|
333
|
+
] });
|
|
334
|
+
}
|
|
261
335
|
function StorySection({ story, variants }) {
|
|
262
336
|
const env = useEnv();
|
|
263
337
|
const headingId = useId();
|
|
264
338
|
const description = env.descriptions[story.id];
|
|
339
|
+
const gallery = !env.gallery && env.galleries?.includes(story.id);
|
|
265
340
|
return /* @__PURE__ */ jsxs("section", { className: "fg-index-story", "aria-labelledby": headingId, children: [
|
|
266
341
|
/* @__PURE__ */ jsxs("header", { className: "fg-index-story__head", children: [
|
|
267
342
|
/* @__PURE__ */ jsx("h2", { id: headingId, className: "fg-index-story__name", children: story.name }),
|
|
343
|
+
gallery ? /* @__PURE__ */ jsx(GalleryBadge, {}) : null,
|
|
268
344
|
/* @__PURE__ */ jsx(Button, { variant: "secondary", size: "sm", onClick: () => env.open(story.id), children: "Open" })
|
|
269
345
|
] }),
|
|
270
346
|
description ? /* @__PURE__ */ jsx("p", { className: "fg-index-story__description", children: description }) : null,
|
|
@@ -288,11 +364,20 @@ function DefaultIndex() {
|
|
|
288
364
|
const withVariants = useMemo(() => firstOfEachControlSet(env.stories), [env.stories]);
|
|
289
365
|
const segments = env.title.split("/");
|
|
290
366
|
const name = segments.pop();
|
|
367
|
+
const { library } = env;
|
|
368
|
+
if (library !== void 0 && segments[0] === library) segments.shift();
|
|
291
369
|
return /* @__PURE__ */ jsxs("article", { className: "fg-index", children: [
|
|
292
370
|
/* @__PURE__ */ jsxs("header", { className: "fg-index__head", children: [
|
|
293
|
-
segments.length > 0 ? /* @__PURE__ */
|
|
294
|
-
|
|
295
|
-
|
|
371
|
+
segments.length > 0 || library !== void 0 ? /* @__PURE__ */ jsxs("p", { className: "fg-index__path", children: [
|
|
372
|
+
library !== void 0 ? /* @__PURE__ */ jsx(LibraryBadge, { library, className: "fg-index__library" }) : null,
|
|
373
|
+
segments.join(" / ")
|
|
374
|
+
] }) : null,
|
|
375
|
+
/* @__PURE__ */ jsxs("div", { className: "fg-index__title-row", children: [
|
|
376
|
+
/* @__PURE__ */ jsx("h1", { className: "fg-index__title", children: name }),
|
|
377
|
+
env.gallery ? /* @__PURE__ */ jsx(GalleryBadge, {}) : null
|
|
378
|
+
] }),
|
|
379
|
+
env.description ? /* @__PURE__ */ jsx("p", { className: "fg-index__description", children: env.description }) : null,
|
|
380
|
+
/* @__PURE__ */ jsx(IndexDependencies, {})
|
|
296
381
|
] }),
|
|
297
382
|
env.stories.map((story) => /* @__PURE__ */ jsx(StorySection, { story, variants: withVariants.has(story.id) }, story.id))
|
|
298
383
|
] });
|
|
@@ -306,6 +391,8 @@ function indexContext(env) {
|
|
|
306
391
|
Story: IndexStory,
|
|
307
392
|
Variants: IndexVariants,
|
|
308
393
|
DefaultIndex,
|
|
394
|
+
Dependencies: IndexDependencies,
|
|
395
|
+
gallery: env.gallery ?? false,
|
|
309
396
|
open: env.open
|
|
310
397
|
};
|
|
311
398
|
}
|
|
@@ -313,6 +400,6 @@ function IndexPage({ env, render }) {
|
|
|
313
400
|
return /* @__PURE__ */ jsx(IndexEnvContext.Provider, { value: env, children: render ? render(indexContext(env)) : /* @__PURE__ */ jsx(DefaultIndex, {}) });
|
|
314
401
|
}
|
|
315
402
|
|
|
316
|
-
export { IndexPage, answerSchema, describeSchema, indexEntries, indexId, isIndexId, openChannel, schemaFromDescription };
|
|
317
|
-
//# sourceMappingURL=chunk-
|
|
318
|
-
//# sourceMappingURL=chunk-
|
|
403
|
+
export { IndexPage, LibraryBadge, answerSchema, describeSchema, indexEntries, indexId, isIndexId, libraryOf, openChannel, schemaFromDescription };
|
|
404
|
+
//# sourceMappingURL=chunk-DDDCZ6XW.js.map
|
|
405
|
+
//# sourceMappingURL=chunk-DDDCZ6XW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/protocol/schema.ts","../src/protocol/channel.ts","../src/story/indexPages.ts","../src/story/library.ts","../src/frame/index/LibraryBadge.tsx","../src/frame/index/variants.ts","../src/frame/index/IndexPage.tsx"],"names":["isConfigBranch","jsx","Badge"],"mappings":";;;;;;;;;AAqDA,IAAM,QAAA,GAAW,CAAC,EAAA,EAAY,GAAA,KAAyB,EAAA,KAAO,KAAK,GAAA,GAAM,CAAA,EAAG,EAAE,CAAA,CAAA,EAAI,GAAG,CAAA,CAAA;AAErF,SAAS,cAAc,KAAA,EAAoC;AACzD,EAAA,MAAM,MAAsB,EAAC;AAC7B,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,IAAA,MAAM,EAAE,OAAA,EAAS,MAAA,EAAO,GAAI,KAAA,CAAM,OAAA;AAClC,IAAA,MAAM,MAAA,GAAS;AAAA,MACb,WAAA,EAAa,EAAE,GAAG,KAAA,CAAM,WAAA,EAAY;AAAA,MACpC,GAAI,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,EAAE,GAAG,OAAA,EAAQ,EAAE;AAAA,MAC3D,aAAa,MAAA,KAAW;AAAA,KAC1B;AACA,IAAA,GAAA,CAAI,GAAG,CAAA,GAAI,cAAA,CAAe,KAAK,IAC3B,EAAE,MAAA,EAAQ,IAAA,EAAM,GAAG,QAAQ,QAAA,EAAU,aAAA,CAAc,KAAA,CAAM,QAAQ,GAAE,GACnE;AAAA,MACE,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,KAAA,CAAM,IAAA;AAAA,MACZ,SAAS,KAAA,CAAM,OAAA;AAAA,MACf,GAAG,MAAA;AAAA,MACH,SAAA,EAAW,KAAA,CAAM,OAAA,CAAQ,QAAA,KAAa,MAAA;AAAA,MACtC,aAAA,EAAe,KAAA,CAAM,OAAA,CAAQ,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IACxE,SAAS,GAAA,CAAI,OAAA;AAAA,IACb,SAAS,GAAA,CAAI,OAAA;AAAA,IACb,KAAA,EAAO,UAAA;AAAA,IACP,QAAA,EAAU,aAAA;AAAA,IACV,YAAA;AAAA,IACA,YAAA,EAAc,iBAAA;AAAA,IACd,OAAA,EAAS,IAAI,OAAA,IAAW,KAAA;AAAA,IACxB,MAAM,GAAA,CAAI;AAAA,GACZ;AACF;AAGO,SAAS,SAAA,CAAU,EAAE,GAAA,EAAK,MAAA,EAAO,EAAyE;AAC/G,EAAA,uBACEA,GAAAA,CAAC,eAAA,CAAgB,QAAA,EAAhB,EAAyB,OAAO,GAAA,EAAM,QAAA,EAAA,MAAA,GAAS,MAAA,CAAO,YAAA,CAAa,GAAG,CAAC,CAAA,mBAAIA,GAAAA,CAAC,gBAAa,CAAA,EAAG,CAAA;AAEjG","file":"chunk-DDDCZ6XW.js","sourcesContent":["import {\n f,\n isConfigBranch,\n resolveConfigSchema,\n schemaNodeAtPath,\n type Annotations,\n type BranchAnnotations,\n type ConfigBranch,\n type ConfigEntry,\n type ConfigNode,\n type ConfigSchema,\n type ConfigShape,\n type NodeOptions,\n} from '@weasel-js/labkit/config';\n\nexport interface SectionDescription {\n label: string;\n collapsed?: boolean;\n}\n\nexport type DescribedEntry =\n | {\n branch: true;\n annotations: BranchAnnotations;\n section?: SectionDescription;\n conditional: boolean;\n children: DescribedShape;\n }\n | {\n branch: false;\n kind: string | null;\n default: unknown;\n annotations: Annotations;\n section?: SectionDescription;\n conditional: boolean;\n validated: boolean;\n /** The node draws its own row with `.render`, which stays in the frame. */\n customControl: boolean;\n };\n\nexport type DescribedShape = { [key: string]: DescribedEntry };\n\n/** A story's `f.schema` as structured-clone data. */\nexport interface SchemaDescription {\n nodes: DescribedShape;\n}\n\n/** Answers the workshop has for the rebuilt schema's predicates. */\nexport interface SchemaAnswers {\n hidden(path: string, config: unknown): boolean;\n errors(path: string, config: unknown): string[];\n}\n\nconst joinPath = (at: string, key: string): string => (at === '' ? key : `${at}.${key}`);\n\nfunction describeShape(shape: ConfigShape): DescribedShape {\n const out: DescribedShape = {};\n for (const [key, entry] of Object.entries(shape)) {\n const { section, showIf } = entry.options;\n const common = {\n annotations: { ...entry.annotations },\n ...(section === undefined ? {} : { section: { ...section } }),\n conditional: showIf !== undefined,\n };\n out[key] = isConfigBranch(entry)\n ? { branch: true, ...common, children: describeShape(entry.children) }\n : {\n branch: false,\n kind: entry.kind,\n default: entry.default,\n ...common,\n validated: entry.options.validate !== undefined,\n customControl: entry.options.render !== undefined,\n };\n }\n return out;\n}\n\nexport function describeSchema(schema: ConfigSchema<unknown>): SchemaDescription {\n return { nodes: describeShape(schema.nodes) };\n}\n\nfunction rebuildShape(shape: DescribedShape, at: string, answers: SchemaAnswers): ConfigShape {\n const out: Record<string, ConfigEntry> = {};\n for (const [key, entry] of Object.entries(shape)) {\n const path = joinPath(at, key);\n const options: NodeOptions = {\n ...(entry.section === undefined ? {} : { section: entry.section }),\n ...(entry.conditional ? { showIf: (config) => !answers.hidden(path, config) } : {}),\n };\n if (entry.branch) {\n const branch: ConfigBranch = {\n children: rebuildShape(entry.children, path, answers),\n annotations: entry.annotations,\n options,\n };\n out[key] = branch;\n } else {\n const node: ConfigNode = {\n kind: entry.kind,\n default: entry.default,\n annotations: entry.annotations,\n options: entry.validated ? { ...options, validate: (_leaf, config) => answers.errors(path, config) } : options,\n };\n out[key] = node;\n }\n }\n return out;\n}\n\nexport function schemaFromDescription(\n description: SchemaDescription,\n answers: SchemaAnswers,\n): ConfigSchema<unknown> {\n return f.schema(rebuildShape(description.nodes, '', answers)) as ConfigSchema<unknown>;\n}\n\n/** Evaluate a schema's own predicates for one config — the frame's half of `answers`. */\nexport function answerSchema(\n schema: ConfigSchema<unknown>,\n config: unknown,\n): { hidden: string[]; errors: Record<string, string[]> } {\n const hidden: string[] = [];\n const errors: Record<string, string[]> = {};\n const record = config as Record<string, unknown>;\n let group: ReturnType<typeof resolveConfigSchema>['group'] | undefined;\n\n const walk = (shape: ConfigShape, at: string): void => {\n for (const [key, entry] of Object.entries(shape)) {\n const path = joinPath(at, key);\n if (entry.options.showIf && !entry.options.showIf(record)) hidden.push(path);\n if (isConfigBranch(entry)) {\n walk(entry.children, path);\n continue;\n }\n const { validate } = entry.options;\n if (!validate) continue;\n group ??= resolveConfigSchema(schema).group;\n const leaf = schemaNodeAtPath(group, path);\n if (!leaf || 'children' in leaf) continue;\n const found = validate(leaf, record);\n if (found.length > 0) errors[path] = found;\n }\n };\n walk(schema.nodes, '');\n return { hidden, errors };\n}\n","import { type Envelope, PROTOCOL_VERSION } from './messages';\n\nexport interface PortLike {\n postMessage(message: unknown): void;\n addEventListener(type: 'message', fn: (event: MessageEvent) => void): void;\n removeEventListener(type: 'message', fn: (event: MessageEvent) => void): void;\n start?(): void;\n close(): void;\n}\n\nexport interface Channel<In, Out> {\n send(msg: Out): void;\n on(fn: (msg: In) => void): () => void;\n close(): void;\n}\n\nexport type Mismatch = { reason: 'not-an-envelope' } | { reason: 'version'; version: unknown };\n\nexport interface ChannelOptions {\n onMismatch?: (mismatch: Mismatch) => void;\n}\n\nexport function openChannel<In, Out>(port: PortLike, options: ChannelOptions = {}): Channel<In, Out> {\n const listeners = new Set<(msg: In) => void>();\n const onMessage = (event: MessageEvent) => {\n const data: unknown = event.data;\n if (typeof data !== 'object' || data === null || !('msg' in data)) {\n options.onMismatch?.({ reason: 'not-an-envelope' });\n return;\n }\n const envelope = data as Partial<Envelope<In>>;\n if (envelope.v !== PROTOCOL_VERSION) {\n options.onMismatch?.({ reason: 'version', version: envelope.v });\n return;\n }\n for (const fn of listeners) fn(envelope.msg as In);\n };\n port.addEventListener('message', onMessage);\n port.start?.();\n return {\n send: (msg) => port.postMessage({ v: PROTOCOL_VERSION, msg } satisfies Envelope<Out>),\n on: (fn) => {\n listeners.add(fn);\n return () => listeners.delete(fn);\n },\n close: () => {\n port.removeEventListener('message', onMessage);\n listeners.clear();\n port.close();\n },\n };\n}\n","import { sanitize } from './ids';\nimport type { IndexEntry } from './types';\n\nconst SUFFIX = ':index';\n\n/** The name an index page goes by in the sidebar and in its trial's title. */\nexport const INDEX_NAME = 'Index';\n\n/** The id of `title`'s index page. A colon never survives `sanitize`, so no story id can collide with it. */\nexport function indexId(title: string): string {\n return `${sanitize(title)}${SUFFIX}`;\n}\n\nexport function isIndexId(id: string): boolean {\n return id.endsWith(SUFFIX);\n}\n\n/**\n * One index-page entry per title in `stories`, in the order titles first appear. It routes and runs like a story:\n * its `file` is the title's first story file, its descriptions are the title's own, and its tags are those every story\n * of the title carries.\n */\nexport function indexEntries(stories: readonly IndexEntry[]): IndexEntry[] {\n const byTitle = new Map<string, IndexEntry>();\n for (const entry of stories) {\n const page = byTitle.get(entry.title);\n if (page) {\n if (page.tags) {\n const common = page.tags.filter((tag) => entry.tags?.includes(tag));\n if (common.length > 0) page.tags = common;\n else delete page.tags;\n }\n continue;\n }\n byTitle.set(entry.title, {\n id: indexId(entry.title),\n title: entry.title,\n name: INDEX_NAME,\n exportName: '',\n file: entry.file,\n ...(entry.componentDescription === undefined ? {} : { componentDescription: entry.componentDescription }),\n ...(entry.componentName === undefined ? {} : { componentName: entry.componentName }),\n ...(entry.tags === undefined ? {} : { tags: entry.tags }),\n });\n }\n return [...byTitle.values()];\n}\n","/**\n * Which library a story file belongs to, by the package it lives in rather\n * than by its title's first segment. The title prefix is authored per story\n * and disagrees with itself — `packages/ui` alone declares both `Primitives/`\n * and `ui/` — so the path is the answer that cannot drift.\n */\nconst LIBRARIES: readonly (readonly [marker: string, label: string])[] = [\n ['/packages/ui/', 'ui'],\n ['/packages/labkit/', 'labkit'],\n ['/packages/forge/', 'forge'],\n ['/apps/draw/', 'draw'],\n ['/apps/forge/', 'forge'],\n];\n\n/** `entry`'s library, falling back to its title's first segment for a file\n * under none of the known packages. */\nexport function libraryOf(entry: { file: string; title: string }): string {\n const file = entry.file.replaceAll('\\\\', '/');\n for (const [marker, label] of LIBRARIES) {\n if (file.includes(marker)) return label;\n }\n return entry.title.split('/')[0] ?? entry.title;\n}\n","// The component's own entry, not the barrel: the barrel would bring every weasel-ui component into each frame.\nimport { Badge } from '@weasel-js/ui/components/Badge';\n\n/** `swatch` mixed toward the foreground, further in light mode: a bright swatch needs more of the dark foreground to\n * hold 4.5:1 as small text on its own tint, and a dark swatch less of the light one. */\nconst tone = (swatch: string, light: number, dark: number): string =>\n `light-dark(color-mix(in oklab, var(--wzl-swatch-${swatch}), var(--wzl-fg) ${light}%), ` +\n `color-mix(in oklab, var(--wzl-swatch-${swatch}), var(--wzl-fg) ${dark}%))`;\n\n/** Each package's peer tone. */\nconst LIBRARY_TONES: Readonly<Record<string, string>> = {\n ui: tone('amber', 55, 40),\n labkit: tone('teal', 55, 45),\n forge: tone('blue', 55, 35),\n draw: tone('rose', 55, 35),\n};\n\n/** A component's package, as a badge toned per package. */\nexport function LibraryBadge({ library, className }: { library: string; className?: string }) {\n return (\n <Badge status=\"muted\" tone={LIBRARY_TONES[library]} variant=\"subtle\" size=\"sm\" {...(className ? { className } : {})}>\n {library}\n </Badge>\n );\n}\n","import { type ConfigSchema, type ConfigShape, isConfigBranch, titleCase } from '@weasel-js/labkit/config';\nimport { isPlainObject } from '../../csf/isPlainObject';\n\nexport interface VariantValue {\n value: unknown;\n label: string;\n}\n\n/** One control a story is shown varying along, with every other control at its default. */\nexport interface VariantRow {\n /** Dotted, as `setConfig` takes it. */\n path: string;\n label: string;\n values: VariantValue[];\n}\n\n/** Above this many choices a row stops being something to scan. */\nexport const MAX_ENUM_OPTIONS = 8;\nexport const MAX_ROWS = 6;\n\nconst labelOf = (key: string, name: string | undefined): string => name ?? titleCase(key);\n\n/**\n * The boolean and enum controls of `schema` a story can be shown varying along, in schema order: skipped are\n * controls that draw their own row, controls hidden at the defaults, and enums with more than\n * `MAX_ENUM_OPTIONS` choices. At most `MAX_ROWS`.\n */\nexport function variantRows(schema: ConfigSchema<unknown>): VariantRow[] {\n const defaults = schema.defaults() as Record<string, unknown>;\n const rows: VariantRow[] = [];\n const walk = (shape: ConfigShape, at: string): void => {\n for (const [key, entry] of Object.entries(shape)) {\n if (rows.length >= MAX_ROWS) return;\n const path = at === '' ? key : `${at}.${key}`;\n if (entry.options.showIf && !entry.options.showIf(defaults)) continue;\n if (isConfigBranch(entry)) {\n walk(entry.children, path);\n continue;\n }\n if (entry.annotations.hidden || entry.options.render) continue;\n const label = labelOf(key, entry.annotations.name);\n if (entry.kind === 'boolean') {\n rows.push({ path, label, values: [false, true].map((value) => ({ value, label: String(value) })) });\n } else if (entry.kind === 'enum') {\n const options = entry.annotations.options ?? [];\n if (options.length < 2 || options.length > MAX_ENUM_OPTIONS) continue;\n rows.push({ path, label, values: options.map((o) => ({ value: o.value, label: o.label })) });\n }\n }\n };\n walk(schema.nodes, '');\n return rows;\n}\n\n/** `over` merged into `base`: nested plain objects merge, anything else replaces. */\nexport function mergeConfig(base: unknown, over: unknown): unknown {\n if (!isPlainObject(base) || !isPlainObject(over)) return over === undefined ? base : over;\n const out: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(over)) out[key] = mergeConfig(base[key], value);\n return out;\n}\n\n/** `config` with `value` at dotted `path`, copying each object along the way. */\nexport function withValueAt(config: unknown, path: string, value: unknown): unknown {\n const [head, ...rest] = path.split('.');\n if (head === undefined) return value;\n const record = isPlainObject(config) ? config : {};\n return { ...record, [head]: rest.length === 0 ? value : withValueAt(record[head], rest.join('.'), value) };\n}\n","// The components' own entries, not the barrel: the barrel would bring every weasel-ui component into each frame.\nimport { Badge } from '@weasel-js/ui/components/Badge';\nimport { Button } from '@weasel-js/ui/components/Button';\nimport {\n createContext,\n type MouseEvent,\n type ReactNode,\n type RefObject,\n useContext,\n useEffect,\n useId,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport type { Globals } from '../../protocol/messages';\nimport { indexId } from '../../story/indexPages';\nimport type { ComponentDeps, Decorator, IndexContext, IndexStoryProps, LoadedStory, StoryContext } from '../../story/types';\nimport { StoryHost } from '../StoryHost';\nimport { mergeConfig, variantRows, withValueAt } from './variants';\nimport './index.css';\nimport { LibraryBadge } from './LibraryBadge';\n\n/** What every cell on an index page shares with the frame that hosts it. */\nexport interface IndexEnv {\n title: string;\n /** The package the component ships in. */\n library?: string;\n description?: string;\n stories: readonly LoadedStory[];\n /** Per story id, the JSDoc above its export. */\n descriptions: Readonly<Record<string, string>>;\n /** A catalog or showcase rather than one component: every story of it is tagged `gallery`. */\n gallery?: boolean;\n /** The ids of the stories tagged `gallery`. */\n galleries?: readonly string[];\n /** The component's place in the component graph; absent until the graph arrives, and for a gallery. */\n dependencies?: ComponentDeps;\n globals: Globals;\n /** The frame config's, outermost. */\n decorators: readonly Decorator[];\n open: (id: string) => void;\n onError: (error: unknown) => void;\n}\n\nexport const IndexEnvContext = createContext<IndexEnv | null>(null);\n\nfunction useEnv(): IndexEnv {\n const env = useContext(IndexEnvContext);\n if (!env) throw new Error('An index page part rendered outside its index page');\n return env;\n}\n\n/** How far past the viewport a cell stays mounted. */\nconst NEAR_MARGIN = '100%';\n\n/** Whether `ref`'s element is near the viewport; true where the browser cannot say. */\nfunction useNearViewport(ref: RefObject<Element | null>): boolean {\n const [near, setNear] = useState(typeof IntersectionObserver === 'undefined');\n useEffect(() => {\n const el = ref.current;\n if (!el || typeof IntersectionObserver === 'undefined') return;\n const observer = new IntersectionObserver((entries) => {\n const last = entries.at(-1);\n if (last) setNear(last.isIntersecting);\n }, { rootMargin: NEAR_MARGIN });\n observer.observe(el);\n return () => observer.disconnect();\n }, [ref]);\n return near;\n}\n\n/**\n * One story at its defaults with `config` over them. It keeps its own config and state, so it stays interactive, and\n * it mounts only while near the viewport, so a page of canvas stories stays under the browser's WebGL context cap.\n */\nexport function IndexStory({ story, config: over, label }: IndexStoryProps) {\n const env = useEnv();\n const [config, setConfig] = useState(() => mergeConfig(story.config.defaults(), over));\n const [state, setState] = useState<unknown>(() => story.initialState?.(config) ?? null);\n const cell = useRef<HTMLElement>(null);\n const near = useNearViewport(cell);\n // Held while unmounted, so scrolling past a cell does not move everything after it.\n const [height, setHeight] = useState<number | null>(null);\n useEffect(() => {\n const el = cell.current;\n if (!near || !el || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => setHeight(el.getBoundingClientRect().height));\n observer.observe(el);\n return () => observer.disconnect();\n }, [near]);\n const ctx: StoryContext = {\n config,\n setConfig: (path, value) => setConfig((prev: unknown) => withValueAt(prev, path, value)),\n state,\n setState: (next) =>\n setState((prev: unknown) => (typeof next === 'function' ? (next as (p: unknown) => unknown)(prev) : next)),\n globals: env.globals,\n title: story.title,\n name: story.name,\n };\n return (\n <figure\n ref={cell}\n className={`fg-index-cell fg-index-cell--${story.layout}`}\n style={!near && height !== null ? { minHeight: height } : undefined}\n >\n <div className=\"fg-index-cell__stage\">\n {near ? (\n <StoryHost story={story} ctx={ctx} decorators={env.decorators} resetKey={0} onError={env.onError} />\n ) : null}\n </div>\n {label === undefined ? null : <figcaption className=\"fg-index-cell__label\">{label}</figcaption>}\n </figure>\n );\n}\n\n/** `story` once per value of each boolean and enum control, every other control at its default. */\nexport function IndexVariants({ story }: { story: LoadedStory }) {\n const rows = useMemo(() => variantRows(story.config), [story]);\n const defaults = useMemo(() => story.config.defaults(), [story]);\n if (rows.length === 0) return null;\n return (\n <div className=\"fg-index-variants\">\n {rows.map((row) => (\n <section key={row.path} className=\"fg-index-variants__row\" aria-label={row.label}>\n <h4 className=\"fg-index-variants__label\">{row.label}</h4>\n <div className=\"fg-index-variants__cells\">\n {row.values.map((v) => (\n <IndexStory\n key={String(v.value)}\n story={story}\n config={withValueAt(defaults, row.path, v.value) as Record<string, unknown>}\n label={v.label}\n />\n ))}\n </div>\n </section>\n ))}\n </div>\n );\n}\n\nfunction GalleryBadge() {\n return (\n <Badge status=\"accent\" variant=\"subtle\" size=\"sm\">\n Gallery\n </Badge>\n );\n}\n\nfunction DependencyList({ label, titles, empty }: { label: string; titles: readonly string[]; empty: string }) {\n const env = useEnv();\n const labelId = useId();\n const follow = (event: MouseEvent, id: string) => {\n if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;\n event.preventDefault();\n env.open(id);\n };\n return (\n <div className=\"fg-index-deps__row\">\n <dt id={labelId} className=\"fg-index-deps__label\">\n {label}\n </dt>\n <dd className=\"fg-index-deps__value\">\n {titles.length === 0 ? (\n <span className=\"fg-index-deps__empty\">{empty}</span>\n ) : (\n <ul className=\"fg-index-deps__list\" aria-labelledby={labelId}>\n {titles.map((title) => {\n const cut = title.lastIndexOf('/') + 1;\n const id = indexId(title);\n return (\n <li key={title}>\n <a className=\"fg-index-deps__link\" href={`#/${encodeURIComponent(id)}`} onClick={(event) => follow(event, id)}>\n <span className=\"fg-index-deps__prefix\">{title.slice(0, cut)}</span>\n {title.slice(cut)}\n </a>\n </li>\n );\n })}\n </ul>\n )}\n </dd>\n </div>\n );\n}\n\n/** The listed components this one uses and those that use it, read from source. Nothing for a gallery. */\nexport function IndexDependencies() {\n const { gallery, dependencies } = useEnv();\n if (gallery || !dependencies) return null;\n if (dependencies.source === null) {\n return (\n <p className=\"fg-index-deps__none\">\n forge found no source file for this component, so it lists none of its dependencies. It looks for the\n import the meta’s <code>component</code> names, or else the one the title’s last segment names.\n </p>\n );\n }\n return (\n <dl className=\"fg-index-deps\" aria-label=\"Dependencies\">\n <DependencyList label=\"Uses\" titles={dependencies.uses} empty=\"No listed component.\" />\n <DependencyList label=\"Used by\" titles={dependencies.usedBy} empty=\"No listed component uses it.\" />\n </dl>\n );\n}\n\nfunction StorySection({ story, variants }: { story: LoadedStory; variants: boolean }) {\n const env = useEnv();\n const headingId = useId();\n const description = env.descriptions[story.id];\n const gallery = !env.gallery && env.galleries?.includes(story.id);\n return (\n <section className=\"fg-index-story\" aria-labelledby={headingId}>\n <header className=\"fg-index-story__head\">\n <h2 id={headingId} className=\"fg-index-story__name\">\n {story.name}\n </h2>\n {gallery ? <GalleryBadge /> : null}\n <Button variant=\"secondary\" size=\"sm\" onClick={() => env.open(story.id)}>\n Open\n </Button>\n </header>\n {description ? <p className=\"fg-index-story__description\">{description}</p> : null}\n <IndexStory story={story} />\n {variants ? <IndexVariants story={story} /> : null}\n </section>\n );\n}\n\n/** Which of `stories` show their variants: the first of each set of controls. Stories of one CSF file share their\n * meta's controls, and the same rows under every story would only repeat. */\nfunction firstOfEachControlSet(stories: readonly LoadedStory[]): Set<string> {\n const seen = new Set<string>();\n const shown = new Set<string>();\n for (const story of stories) {\n const key = JSON.stringify(variantRows(story.config));\n if (seen.has(key)) continue;\n seen.add(key);\n shown.add(story.id);\n }\n return shown;\n}\n\n/** The generated page: the component's title and description, then each story, with the variants of the first of\n * each set of controls. */\nexport function DefaultIndex() {\n const env = useEnv();\n const withVariants = useMemo(() => firstOfEachControlSet(env.stories), [env.stories]);\n const segments = env.title.split('/');\n const name = segments.pop();\n const { library } = env;\n if (library !== undefined && segments[0] === library) segments.shift();\n return (\n <article className=\"fg-index\">\n <header className=\"fg-index__head\">\n {segments.length > 0 || library !== undefined ? (\n <p className=\"fg-index__path\">\n {library !== undefined ? <LibraryBadge library={library} className=\"fg-index__library\" /> : null}\n {segments.join(' / ')}\n </p>\n ) : null}\n <div className=\"fg-index__title-row\">\n <h1 className=\"fg-index__title\">{name}</h1>\n {env.gallery ? <GalleryBadge /> : null}\n </div>\n {env.description ? <p className=\"fg-index__description\">{env.description}</p> : null}\n <IndexDependencies />\n </header>\n {env.stories.map((story) => (\n <StorySection key={story.id} story={story} variants={withVariants.has(story.id)} />\n ))}\n </article>\n );\n}\n\n/** What a component's own index page is handed. */\nexport function indexContext(env: IndexEnv): IndexContext {\n return {\n title: env.title,\n ...(env.description === undefined ? {} : { description: env.description }),\n stories: env.stories,\n globals: env.globals,\n Story: IndexStory,\n Variants: IndexVariants,\n DefaultIndex,\n Dependencies: IndexDependencies,\n gallery: env.gallery ?? false,\n open: env.open,\n };\n}\n\n/** The page itself: the component's own, or the generated one. */\nexport function IndexPage({ env, render }: { env: IndexEnv; render: ((ctx: IndexContext) => ReactNode) | null }) {\n return (\n <IndexEnvContext.Provider value={env}>{render ? render(indexContext(env)) : <DefaultIndex />}</IndexEnvContext.Provider>\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isNative } from './chunk-2GXKNXTJ.js';
|
|
2
2
|
import { storyNameFromExport, storyId } from './chunk-HRGPFQBW.js';
|
|
3
|
-
import { portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-
|
|
3
|
+
import { isPlainObject, portSafePart, appliedLocal, withUnsent, coverOf, ArgsContext } from './chunk-YKN3IAEX.js';
|
|
4
4
|
import { createContext, Component, createElement, useContext, useState, useEffect } from 'react';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import { f } from '@weasel-js/labkit/config';
|
|
@@ -223,16 +223,11 @@ var StoryHost = class extends Component {
|
|
|
223
223
|
return /* @__PURE__ */ jsx(Decorated, { story, ctx, decorators });
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
|
-
|
|
227
|
-
// src/csf/isPlainObject.ts
|
|
228
|
-
var isPlainObject = (value) => !!value && typeof value === "object" && Object.getPrototypeOf(value) === Object.prototype;
|
|
229
|
-
|
|
230
|
-
// src/csf/argsToSchema.ts
|
|
231
226
|
function controlOf(argType) {
|
|
232
227
|
const { control } = argType;
|
|
233
228
|
if (control === false) return false;
|
|
234
229
|
if (typeof control === "string") return { type: control };
|
|
235
|
-
return { type: control?.type, min: control?.min, max: control?.max, step: control?.step };
|
|
230
|
+
return { type: control?.type, min: control?.min, max: control?.max, step: control?.step, icons: control?.icons };
|
|
236
231
|
}
|
|
237
232
|
function stringOptions(argType) {
|
|
238
233
|
const opts = argType.options;
|
|
@@ -279,7 +274,11 @@ function controlled(control, argType, has, value) {
|
|
|
279
274
|
case "inline-radio":
|
|
280
275
|
case void 0: {
|
|
281
276
|
if (!options) return control.type === void 0 && has ? inferred(value) : null;
|
|
282
|
-
const
|
|
277
|
+
const { icons } = control;
|
|
278
|
+
const node = f.enum(
|
|
279
|
+
def(),
|
|
280
|
+
icons ? options.map((value2) => ({ value: value2, label: value2, ...icons[value2] ? { icon: icons[value2] } : {} })) : options
|
|
281
|
+
);
|
|
283
282
|
return control.type === "radio" || control.type === "inline-radio" ? node.radio() : node;
|
|
284
283
|
}
|
|
285
284
|
case "object":
|
|
@@ -495,6 +494,6 @@ function indexRenderOf(mod) {
|
|
|
495
494
|
return typeof render === "function" ? render : null;
|
|
496
495
|
}
|
|
497
496
|
|
|
498
|
-
export { StoryHost, captureElement, createGlobalsTarget, createOverrides, indexRenderOf,
|
|
499
|
-
//# sourceMappingURL=chunk-
|
|
500
|
-
//# sourceMappingURL=chunk-
|
|
497
|
+
export { StoryHost, captureElement, createGlobalsTarget, createOverrides, indexRenderOf, loadStories, resolveCssVar, runAxe, scanCssVars };
|
|
498
|
+
//# sourceMappingURL=chunk-ERRLEH6S.js.map
|
|
499
|
+
//# sourceMappingURL=chunk-ERRLEH6S.js.map
|