@weasel-js/forge 1.6.1 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/dist/{FrameController-BspC9Zr5.d.ts → FrameController-RdGggdGA.d.ts} +34 -1
- package/dist/chunk-JNJGIUYU.js +77 -0
- package/dist/chunk-JNJGIUYU.js.map +1 -0
- package/dist/{chunk-CSAXZIMV.js → chunk-KIFCYY4F.js} +98 -11
- package/dist/chunk-KIFCYY4F.js.map +1 -0
- package/dist/{chunk-OLWZURU3.js → chunk-NYBMOSSR.js} +11 -12
- package/dist/chunk-NYBMOSSR.js.map +1 -0
- package/dist/{chunk-DIOLWCH7.js → chunk-SEK6EKHO.js} +38 -94
- package/dist/chunk-SEK6EKHO.js.map +1 -0
- package/dist/chunk-WEQSLPKT.js +9 -0
- package/dist/chunk-WEQSLPKT.js.map +1 -0
- package/dist/{chunk-2GXKNXTJ.js → chunk-Y3WZ2EWR.js} +2 -2
- package/dist/chunk-Y3WZ2EWR.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-BJIgUhiI.d.ts} +16 -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 +7 -2
- package/dist/frame/index.js +11 -4
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +14 -4
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/shell/index.css +165 -3
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +44 -31
- package/dist/shell/index.js +178 -202
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.d.ts +2 -1
- package/dist/test/index.js +5 -4
- package/dist/test/index.js.map +1 -1
- package/dist/vite/index.d.ts +7 -1
- package/dist/vite/index.js +367 -32
- package/dist/vite/index.js.map +1 -1
- package/package.json +10 -10
- package/dist/chunk-2GXKNXTJ.js.map +0 -1
- 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
|
@@ -19,8 +19,8 @@ with a `viewport` renders as a fixed-size box the trial pans and zooms.
|
|
|
19
19
|
A story that needs a document of its own says so, with the reason:
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
export const Interactive = story({ isolate: '
|
|
23
|
-
// CSF: parameters: { forge: { isolate: '
|
|
22
|
+
export const Interactive = story({ isolate: 'asserts placement against the window edge', render: … });
|
|
23
|
+
// CSF: parameters: { forge: { isolate: 'asserts placement against the window edge' } }
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
It then renders in an iframe, as every story once did. The frame path is kept
|
|
@@ -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
|
|
@@ -186,6 +186,8 @@ type FromFrame = {
|
|
|
186
186
|
seq?: number;
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
+
/** What a story's `render` and its decorators receive: the trial's config and state, the globals in force, and the
|
|
190
|
+
* story's own title and name. */
|
|
189
191
|
interface StoryContext<C = unknown, S = unknown> {
|
|
190
192
|
config: C;
|
|
191
193
|
setConfig: (path: string, value: unknown) => void;
|
|
@@ -195,12 +197,15 @@ interface StoryContext<C = unknown, S = unknown> {
|
|
|
195
197
|
title: string;
|
|
196
198
|
name: string;
|
|
197
199
|
}
|
|
200
|
+
/** What a story's `play` receives. `canvasElement` is the element the story rendered into. */
|
|
198
201
|
interface PlayContext<C = unknown> {
|
|
199
202
|
canvasElement: HTMLElement;
|
|
200
203
|
config: C;
|
|
201
204
|
globals: Globals;
|
|
202
205
|
}
|
|
206
|
+
/** Wraps a story: `story()` renders what it wraps, and the decorator returns that inside whatever it adds. */
|
|
203
207
|
type Decorator = (story: () => ReactNode, ctx: StoryContext) => ReactNode;
|
|
208
|
+
/** What `meta()` takes: settings every story in the file shares. */
|
|
204
209
|
interface MetaSpec {
|
|
205
210
|
title?: string;
|
|
206
211
|
decorators?: Decorator[];
|
|
@@ -209,6 +214,9 @@ interface MetaSpec {
|
|
|
209
214
|
isolate?: string;
|
|
210
215
|
/** The component's own index page, in place of the generated one. A CSF file sets `parameters.forge.index`. */
|
|
211
216
|
index?: IndexRender;
|
|
217
|
+
/** As CSF's meta `tags`; `'gallery'` marks a catalog or showcase rather than one component. Read from the source,
|
|
218
|
+
* so each must be a string literal. */
|
|
219
|
+
tags?: readonly string[];
|
|
212
220
|
}
|
|
213
221
|
/** What an index page is given: its component's stories, and the parts the generated page is built from. */
|
|
214
222
|
interface IndexContext {
|
|
@@ -226,9 +234,14 @@ interface IndexContext {
|
|
|
226
234
|
}>;
|
|
227
235
|
/** The whole generated page. */
|
|
228
236
|
DefaultIndex: ComponentType;
|
|
237
|
+
/** The listed components this one uses and those that use it, as the generated page shows them. */
|
|
238
|
+
Dependencies: ComponentType;
|
|
239
|
+
/** Whether the meta is tagged `gallery`. */
|
|
240
|
+
gallery: boolean;
|
|
229
241
|
/** Shows story `id` in this page's trial in its place. */
|
|
230
242
|
open: (id: string) => void;
|
|
231
243
|
}
|
|
244
|
+
/** Props for `IndexContext.Story`. */
|
|
232
245
|
interface IndexStoryProps {
|
|
233
246
|
story: LoadedStory;
|
|
234
247
|
/** Merged over the story's defaults; nested groups merge rather than replace. */
|
|
@@ -236,7 +249,9 @@ interface IndexStoryProps {
|
|
|
236
249
|
/** Shown under the story. */
|
|
237
250
|
label?: string;
|
|
238
251
|
}
|
|
252
|
+
/** A custom index page for a component, given as `MetaSpec.index`. */
|
|
239
253
|
type IndexRender = (ctx: IndexContext) => ReactNode;
|
|
254
|
+
/** What `story()` takes. `config` declares the story's controls; `state`, given, seeds its state from the config. */
|
|
240
255
|
interface StorySpec<C = Record<string, never>, S = undefined> {
|
|
241
256
|
name?: string;
|
|
242
257
|
config?: ConfigSchema<C>;
|
|
@@ -248,6 +263,8 @@ interface StorySpec<C = Record<string, never>, S = undefined> {
|
|
|
248
263
|
/** Renders this story in its own frame document, for a reason the value states. The default is the workshop document. */
|
|
249
264
|
isolate?: string;
|
|
250
265
|
play?: (ctx: PlayContext<C>) => void | Promise<void>;
|
|
266
|
+
/** Added to the meta's `tags`; `'!tag'` drops one. Read from the source, so each must be a string literal. */
|
|
267
|
+
tags?: readonly string[];
|
|
251
268
|
}
|
|
252
269
|
/** One story, normalized — what both the native and CSF loaders produce. */
|
|
253
270
|
interface LoadedStory {
|
|
@@ -281,7 +298,21 @@ interface IndexEntry {
|
|
|
281
298
|
componentName?: string;
|
|
282
299
|
/** Read statically from the source; a story with it renders in its own frame. */
|
|
283
300
|
isolate?: string;
|
|
301
|
+
/** The story's tags, read statically from the source: its meta's and its own. An index page's are those every
|
|
302
|
+
* story of its component carries. */
|
|
303
|
+
tags?: string[];
|
|
284
304
|
}
|
|
305
|
+
/** One component's place in the component graph. Every list holds story titles, sorted. */
|
|
306
|
+
interface ComponentDeps {
|
|
307
|
+
/** The file declaring the component, relative to the vite root; null when forge could not find one. */
|
|
308
|
+
source: string | null;
|
|
309
|
+
/** The listed components its own source imports. */
|
|
310
|
+
uses: string[];
|
|
311
|
+
/** The listed components whose own source imports it. */
|
|
312
|
+
usedBy: string[];
|
|
313
|
+
}
|
|
314
|
+
/** The component graph the vite plugin derives from source, by story title. A gallery has no entry. */
|
|
315
|
+
type DepGraph = Record<string, ComponentDeps>;
|
|
285
316
|
|
|
286
317
|
/** What a setup's `applyGlobals` is handed: the element the globals apply to, and a way to style it alone. */
|
|
287
318
|
interface GlobalsTarget {
|
|
@@ -293,6 +324,7 @@ interface GlobalsTarget {
|
|
|
293
324
|
style: (css: string) => void;
|
|
294
325
|
}
|
|
295
326
|
|
|
327
|
+
/** The frame config: what `defineFrameConfig` returns and the `frameConfig` module default-exports. */
|
|
296
328
|
interface FrameSetup {
|
|
297
329
|
/** Wraps every story, outermost; receives the globals. From the frame config (`frameConfig`). */
|
|
298
330
|
decorators?: Decorator[];
|
|
@@ -312,6 +344,7 @@ interface FrameSetup {
|
|
|
312
344
|
*/
|
|
313
345
|
prepare?: (story: LoadedStory) => void | Promise<void>;
|
|
314
346
|
}
|
|
347
|
+
/** Inputs to `startFrame`: the story, the channel to the shell, and the element to render into. */
|
|
315
348
|
interface StartFrameOptions {
|
|
316
349
|
story: LoadedStory;
|
|
317
350
|
channel: Channel<ToFrame, FromFrame>;
|
|
@@ -323,4 +356,4 @@ declare function startFrame({ story, channel, container, setup }: StartFrameOpti
|
|
|
323
356
|
/** Reports an import failure — there is no story to start. */
|
|
324
357
|
declare function reportImportFault(channel: Channel<ToFrame, FromFrame>, error: unknown): void;
|
|
325
358
|
|
|
326
|
-
export { type A11yFinding as A, type
|
|
359
|
+
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 };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { f } from '@weasel-js/labkit/config';
|
|
2
|
+
|
|
3
|
+
// src/shell/globals.ts
|
|
4
|
+
var GLOBALS_KEY = "$globals";
|
|
5
|
+
var FOLLOW_LAB = "lab";
|
|
6
|
+
var FOLLOW_APP = "app";
|
|
7
|
+
var APP_OPTION = { value: FOLLOW_APP, label: "App" };
|
|
8
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
var isGlobalsPath = (path) => path === GLOBALS_KEY || path.startsWith(`${GLOBALS_KEY}.`);
|
|
10
|
+
function shownOptions(declaration, globals) {
|
|
11
|
+
const { shows } = declaration;
|
|
12
|
+
return shows ? declaration.options.filter((option) => shows(option.value, globals)) : declaration.options;
|
|
13
|
+
}
|
|
14
|
+
function labOptions(declaration, globals) {
|
|
15
|
+
const shown = shownOptions(declaration, globals);
|
|
16
|
+
return declaration.follows ? [APP_OPTION, ...shown] : shown;
|
|
17
|
+
}
|
|
18
|
+
function followApp(declarations, values, chrome) {
|
|
19
|
+
const followed = Object.entries(declarations).flatMap(
|
|
20
|
+
([key, { follows }]) => follows && values[key] === FOLLOW_APP ? [[key, follows(chrome)]] : []
|
|
21
|
+
);
|
|
22
|
+
return followed.length === 0 ? values : { ...values, ...Object.fromEntries(followed) };
|
|
23
|
+
}
|
|
24
|
+
function labGlobals(declarations, stored) {
|
|
25
|
+
const from = isRecord(stored) ? stored : {};
|
|
26
|
+
const offered = Object.fromEntries(
|
|
27
|
+
Object.entries(declarations).map(([key, declaration]) => {
|
|
28
|
+
const value = from[key];
|
|
29
|
+
const known = declaration.options.some((option) => option.value === value) || declaration.follows && value === FOLLOW_APP;
|
|
30
|
+
return [key, known ? value : declaration.default];
|
|
31
|
+
})
|
|
32
|
+
);
|
|
33
|
+
return Object.fromEntries(
|
|
34
|
+
Object.entries(declarations).map(([key, declaration]) => {
|
|
35
|
+
const shown = shownOptions(declaration, offered);
|
|
36
|
+
const value = offered[key];
|
|
37
|
+
if (value === FOLLOW_APP && declaration.follows) return [key, value];
|
|
38
|
+
if (!declaration.shows || shown.length === 0 || shown.some((option) => option.value === value)) return [key, value];
|
|
39
|
+
const at = (v) => declaration.options.findIndex((option) => option.value === v);
|
|
40
|
+
const from2 = at(value);
|
|
41
|
+
const nearest = shown.reduce(
|
|
42
|
+
(best, option) => Math.abs(at(option.value) - from2) < Math.abs(at(best.value) - from2) ? option : best
|
|
43
|
+
);
|
|
44
|
+
return [key, nearest.value];
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
function effectiveGlobals(lab, pins) {
|
|
49
|
+
if (!isRecord(pins)) return lab;
|
|
50
|
+
const pinned = Object.entries(pins).filter(([key, value]) => key in lab && value !== FOLLOW_LAB);
|
|
51
|
+
return pinned.length === 0 ? lab : { ...lab, ...Object.fromEntries(pinned) };
|
|
52
|
+
}
|
|
53
|
+
function storyConfig(config, previous) {
|
|
54
|
+
if (!isRecord(config) || !(GLOBALS_KEY in config)) return config;
|
|
55
|
+
const rest = Object.fromEntries(Object.entries(config).filter(([key]) => key !== GLOBALS_KEY));
|
|
56
|
+
if (isRecord(previous)) {
|
|
57
|
+
const keys = Object.keys(rest);
|
|
58
|
+
if (keys.length === Object.keys(previous).length && keys.every((key) => rest[key] === previous[key])) return previous;
|
|
59
|
+
}
|
|
60
|
+
return rest;
|
|
61
|
+
}
|
|
62
|
+
function withGlobals(schema, declarations) {
|
|
63
|
+
const entries = Object.entries(declarations);
|
|
64
|
+
if (entries.length === 0) return schema;
|
|
65
|
+
const leaves = Object.fromEntries(
|
|
66
|
+
entries.map(([key, declaration]) => [
|
|
67
|
+
key,
|
|
68
|
+
f.enum(FOLLOW_LAB, [{ value: FOLLOW_LAB, label: "Lab" }, ...declaration.options]).label(declaration.label)
|
|
69
|
+
])
|
|
70
|
+
);
|
|
71
|
+
const group = f.group(leaves).label("").section("Globals", { layout: "inline", pack: "pairs" });
|
|
72
|
+
return f.schema({ ...schema.nodes, [GLOBALS_KEY]: group });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { FOLLOW_APP, GLOBALS_KEY, effectiveGlobals, followApp, isGlobalsPath, labGlobals, labOptions, storyConfig, withGlobals };
|
|
76
|
+
//# sourceMapp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,GAAG,MAAA,CAAO,OAAO,CAAC,WAAW,GAAG,KAAA,EAAO,CAAA;AAC3D","file":"chunk-JNJGIUYU.js","sourcesContent":["import type { LabMode } from '@weasel-js/labkit';\nimport { type ConfigSchema, f } from '@weasel-js/labkit/config';\nimport type { Globals } from '../protocol/messages';\n\n/** One global the workshop's toolbar sets for every story, and a trial may pin for its own. */\nexport interface GlobalDeclaration {\n label: string;\n options: readonly { value: string; label: string }[];\n default: string;\n /** Another global's key: the toolbar shows this one in a popover beside that one rather than in the bar itself. */\n under?: string;\n /**\n * Whether the toolbar offers `value` given the lab's other values; every option shows when absent. `globals` is\n * resolved without any declaration's `shows`, so one `shows` cannot depend on another's outcome.\n */\n shows?: (value: string, globals: Globals) => boolean;\n /**\n * What this global reads from the lab's own chrome. Given, the lab's value may be `App` (`FOLLOW_APP`), offered\n * first, and while it is the global follows that chrome control, as the header's mode switch sets it. A trial's\n * pin follows the lab or names a value; it cannot follow the app on its own.\n */\n follows?: (chrome: LabChrome) => string;\n}\n\n/** The lab chrome's own settings a global can follow. */\nexport interface LabChrome {\n mode: LabMode;\n}\n\n/** The shell config's `globals`: each declaration by the key stories read it under. */\nexport type GlobalDeclarations = Readonly<Record<string, GlobalDeclaration>>;\n\n/** The config group every story schema gains, holding the trial's pins. A story never sees it. */\nexport const GLOBALS_KEY = '$globals';\n/** A pin's value when the trial follows the lab. */\nexport const FOLLOW_LAB = 'lab';\n/** A lab value, for a declaration that `follows` the app, meaning whatever the app's chrome is set to. */\nexport const FOLLOW_APP = 'app';\n\nconst APP_OPTION = { value: FOLLOW_APP, label: 'App' } as const;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nexport const isGlobalsPath = (path: string): boolean => path === GLOBALS_KEY || path.startsWith(`${GLOBALS_KEY}.`);\n\n/** The options the toolbar offers for `declaration` at `globals`. */\nexport function shownOptions(declaration: GlobalDeclaration, globals: Globals): GlobalDeclaration['options'] {\n const { shows } = declaration;\n return shows ? declaration.options.filter((option) => shows(option.value, globals)) : declaration.options;\n}\n\n/** The options the lab's own control offers: `shownOptions`, after `App` where the declaration follows the app. */\nexport function labOptions(declaration: GlobalDeclaration, globals: Globals): GlobalDeclaration['options'] {\n const shown = shownOptions(declaration, globals);\n return declaration.follows ? [APP_OPTION, ...shown] : shown;\n}\n\n/** `values` with each `App` replaced by what its declaration reads from `chrome`; `values` itself when none is. */\nexport function followApp(declarations: GlobalDeclarations, values: Globals, chrome: LabChrome): Globals {\n const followed = Object.entries(declarations).flatMap(([key, { follows }]) =>\n follows && values[key] === FOLLOW_APP ? [[key, follows(chrome)] as const] : [],\n );\n return followed.length === 0 ? values : { ...values, ...Object.fromEntries(followed) };\n}\n\n/**\n * The lab's values from what was stored: declared keys only. A value no option offers falls back to the default, and\n * one its declaration's `shows` hides falls back to the shown option nearest it in `options`, the earlier on a tie.\n */\nexport function labGlobals(declarations: GlobalDeclarations, stored: unknown): Globals {\n const from = isRecord(stored) ? stored : {};\n const offered: Globals = Object.fromEntries(\n Object.entries(declarations).map(([key, declaration]) => {\n const value = from[key];\n const known =\n declaration.options.some((option) => option.value === value) || (declaration.follows && value === FOLLOW_APP);\n return [key, known ? value : declaration.default];\n }),\n );\n return Object.fromEntries(\n Object.entries(declarations).map(([key, declaration]) => {\n const shown = shownOptions(declaration, offered);\n const value = offered[key];\n if (value === FOLLOW_APP && declaration.follows) return [key, value];\n if (!declaration.shows || shown.length === 0 || shown.some((option) => option.value === value)) return [key, value];\n const at = (v: unknown) => declaration.options.findIndex((option) => option.value === v);\n const from = at(value);\n const nearest = shown.reduce((best, option) =>\n Math.abs(at(option.value) - from) < Math.abs(at(best.value) - from) ? option : best,\n );\n return [key, nearest.value];\n }),\n );\n}\n\n/** The lab's values, overridden by the pins in a trial's config that do not follow the lab. */\nexport function effectiveGlobals(lab: Globals, pins: unknown): Globals {\n if (!isRecord(pins)) return lab;\n const pinned = Object.entries(pins).filter(([key, value]) => key in lab && value !== FOLLOW_LAB);\n return pinned.length === 0 ? lab : { ...lab, ...Object.fromEntries(pinned) };\n}\n\n/**\n * The config a story receives: the trial's, without its pins. Returns `previous` when every other entry is the same,\n * so a change to a pin alone is not a change to the story's config.\n */\nexport function storyConfig(config: unknown, previous?: unknown): unknown {\n if (!isRecord(config) || !(GLOBALS_KEY in config)) return config;\n const rest = Object.fromEntries(Object.entries(config).filter(([key]) => key !== GLOBALS_KEY));\n if (isRecord(previous)) {\n const keys = Object.keys(rest);\n if (keys.length === Object.keys(previous).length && keys.every((key) => rest[key] === previous[key])) return previous;\n }\n return rest;\n}\n\n/** `schema` with a `$globals` group appended: one leaf per declaration, following the lab until pinned. */\nexport function withGlobals(schema: ConfigSchema<unknown>, declarations: GlobalDeclarations): ConfigSchema<unknown> {\n const entries = Object.entries(declarations);\n if (entries.length === 0) return schema;\n const leaves = Object.fromEntries(\n entries.map(([key, declaration]) => [\n key,\n f.enum(FOLLOW_LAB, [{ value: FOLLOW_LAB, label: 'Lab' }, ...declaration.options]).label(declaration.label),\n ]),\n );\n // An empty group name contributes rows without a heading of its own, under the section's.\n const group = f.group(leaves).label('').section('Globals', { layout: 'inline', pack: 'pairs' });\n return f.schema({ ...schema.nodes, [GLOBALS_KEY]: group }) as ConfigSchema<unknown>;\n}\n"]}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { StoryHost
|
|
1
|
+
import { StoryHost } from './chunk-NYBMOSSR.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-KIFCYY4F.js.map
|
|
405
|
+
//# sourceMappingURL=chunk-KIFCYY4F.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,KAAy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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-KIFCYY4F.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
|
-
import { isNative } from './chunk-
|
|
1
|
+
import { isNative } from './chunk-Y3WZ2EWR.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-NYBMOSSR.js.map
|
|
499
|
+
//# sourceMappingURL=chunk-NYBMOSSR.js.map
|