@forgebook/story-format 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ensiria
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,39 @@
1
- # Temporary Holding Version
1
+ # @forgebook/story-format
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The story format of [Forgebook](https://www.npmjs.com/package/forgebook), as types: Component Story Format 3, generic
4
+ over a framework, and the `StorySource` a package hands a catalogue. It has no dependencies, so a component library's
5
+ stories depend on it and never on the catalogue that shows them.
6
+
7
+ **Requirements:** none: no dependencies, types and a few small helpers ·
8
+ [MIT licence](https://github.com/Ensiria/forgebook/blob/develop/packages/story-format/LICENSE)
9
+
10
+ Most projects never install it themselves: `@forgebook/react` brings it, and its `Meta` and `Story` are this format
11
+ typed for React. A library installs it to publish its stories for other catalogues:
12
+
13
+ ```ts
14
+ // stories.ts, exported by the library as "@acme/ui/stories"
15
+ /// <reference types="@forgebook/story-format/client" />
16
+ import type { StorySource } from "@forgebook/story-format/source";
17
+
18
+ import files from "./src/*.stories.tsx?forgebook-files";
19
+
20
+ export const source: StorySource = {
21
+ id: "acme-ui",
22
+ name: "Acme UI",
23
+ files: [files],
24
+ sheets: { required: [], theme: [], restyled: [] }
25
+ };
26
+ ```
27
+
28
+ An app's `forgebook.config.ts` then lists it: `sources: ["@acme/ui/stories"]`.
29
+
30
+ | Import | What it is |
31
+ |---|---|
32
+ | `@forgebook/story-format/csf` | The CSF 3 types, generic over a framework |
33
+ | `@forgebook/story-format/source` | `StorySource`: a package's story files, style sheets, texts and home page |
34
+ | `@forgebook/story-format/client` | The types of the `?forgebook-files` and `?forgebook-markdown` imports |
35
+ | `@forgebook/story-format/texts` | Texts inside the stories, by key, in the catalogue's language |
36
+ | `@forgebook/story-format/clock` | The story clock a live story reads |
37
+ | `@forgebook/story-format/testing-library` | `canvas` and `userEvent` in every `play`, once Testing Library is installed |
38
+
39
+ More: [Forgebook's README](https://github.com/Ensiria/forgebook/blob/develop/packages/forgebook/README.md).
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The types of the `?forgebook-files` and `?forgebook-markdown` imports, for the module that declares a source: add
3
+ * `@forgebook/story-format/client` to that folder's `compilerOptions.types`, beside `vite/client`.
4
+ *
5
+ * @remarks
6
+ * A script, not a module (no top-level import or export), so the wildcard declaration is global; the catalogue's Vite
7
+ * plugin answers each import with one module (D-438).
8
+ *
9
+ * @module
10
+ */
11
+
12
+ declare module "*?forgebook-files" {
13
+ /** The story files the pattern before `?forgebook-files` matches. */
14
+ const files: import("./source").StoryFiles;
15
+ // the source imports the files as a default (`import files from "…?forgebook-files"`), so the module has one
16
+ // biome-ignore lint/style/noDefaultExport: see above
17
+ export default files;
18
+ }
19
+
20
+ declare module "*?forgebook-markdown" {
21
+ /** The Markdown file before `?forgebook-markdown`, as HTML (the source's introduction on the catalogue's home). */
22
+ const markdown: import("./source").StoryMarkdown;
23
+ // the source imports it as a default (`() => import("./home.md?forgebook-markdown")`), so the module has one
24
+ // biome-ignore lint/style/noDefaultExport: see above
25
+ export default markdown;
26
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The story clock: the time a Live story reads, which the catalogue starts at a fixed moment and then runs, holds,
3
+ * restarts and speeds up (D-504).
4
+ *
5
+ * @remarks
6
+ * A component that counts (a countdown, a stream, a toast's wait) never reads the time itself: it takes a clock from
7
+ * its owner. In a story, that owner is the story, and the story's time comes from here: `context.clock` in a render
8
+ * or a play function; a framework's package gives components their own access (`useStoryClock()`, `useStoryNow()` in
9
+ * `@forgebook/react/clock`). The catalogue
10
+ * provides the clock; the library shown converts its milliseconds into its own time type, so this package names no
11
+ * date library and the catalogue none of the libraries it shows (D-67).
12
+ *
13
+ * The clock is stepped: `now()` is the moment of its last tick, the same value until the next one, so a render reads
14
+ * one moment throughout and a component can subscribe to it. A story that reads the clock declares
15
+ * `parameters.clock` with its start; the visual and generated tests hold the clock at that start, and a play
16
+ * function moves it with `advance` ("30 s later it says Expired"), never with a real wait. Without a catalogue (a
17
+ * story rendered on its own) the clock is held at the Unix epoch.
18
+ *
19
+ * @module
20
+ */
21
+ /** The time a story reads. */
22
+ export type StoryClock = {
23
+ /**
24
+ * The story's current moment, in whole milliseconds since the Unix epoch (what a date library takes as is): the
25
+ * moment of the clock's last tick.
26
+ */
27
+ readonly now: () => number;
28
+ /**
29
+ * Calls `onTick` at each tick and on every jump (advanced, restarted); returns what stops it.
30
+ *
31
+ * @param onTick - called once the clock moved.
32
+ */
33
+ readonly subscribe: (onTick: () => void) => () => void;
34
+ /**
35
+ * Moves the clock forward at once, whether it runs or is held: what a play function does instead of waiting.
36
+ *
37
+ * @param ms - how far, in milliseconds; a negative or non-finite value moves nothing.
38
+ */
39
+ readonly advance: (ms: number) => void;
40
+ };
41
+ /** A story's clock setting (`parameters.clock`): the story reads the clock, from this moment. */
42
+ export type StoryClockSetting = {
43
+ /**
44
+ * The moment the clock starts at, and comes back to on Restart: an ISO 8601 instant with its offset
45
+ * (`2026-03-02T10:00:00Z`), so the story draws the same at its start every time.
46
+ */
47
+ readonly start: string;
48
+ };
49
+ /**
50
+ * A clock held at a moment: it moves only when advanced.
51
+ *
52
+ * @param start - its moment, in milliseconds since the Unix epoch.
53
+ * @returns the clock.
54
+ */
55
+ export declare const heldStoryClock: (start: number) => StoryClock;
56
+ //# sourceMappingURL=clock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../src/clock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,8BAA8B;AAC9B,MAAM,MAAM,UAAU,GAAG;IACvB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IACvD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,iGAAiG;AACjG,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,UAAW,MAAM,KAAG,UAiB9C,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A clock held at a moment: it moves only when advanced.
3
+ *
4
+ * @param start - its moment, in milliseconds since the Unix epoch.
5
+ * @returns the clock.
6
+ */
7
+ export const heldStoryClock = (start) => {
8
+ let current = start;
9
+ const listeners = new Set();
10
+ return {
11
+ now: () => Math.floor(current),
12
+ subscribe: (onTick) => {
13
+ listeners.add(onTick);
14
+ return () => {
15
+ listeners.delete(onTick);
16
+ };
17
+ },
18
+ advance: (ms) => {
19
+ if (!Number.isFinite(ms) || ms <= 0)
20
+ return;
21
+ current += ms;
22
+ for (const listener of listeners)
23
+ listener();
24
+ }
25
+ };
26
+ };
27
+ //# sourceMappingURL=clock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clock.js","sourceRoot":"","sources":["../../src/clock.ts"],"names":[],"mappings":"AAkDA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAa,EAAc,EAAE;IAC1D,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IACxC,OAAO;QACL,GAAG,EAAE,GAAW,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;QACtC,SAAS,EAAE,CAAC,MAAkB,EAAgB,EAAE;YAC9C,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YACtB,OAAO,GAAS,EAAE;gBAChB,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,CAAC,EAAU,EAAQ,EAAE;YAC5B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;gBAAE,OAAO;YAC5C,OAAO,IAAI,EAAE,CAAC;YACd,KAAK,MAAM,QAAQ,IAAI,SAAS;gBAAE,QAAQ,EAAE,CAAC;QAC/C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,332 @@
1
+ /**
2
+ * The story format: Component Story Format 3, the subset the Ensiria catalogue reads.
3
+ *
4
+ * @remarks
5
+ * A story file exports its meta as the default export and each story as a named export, as CSF requires, so
6
+ * Storybook or Ladle could read the same files (D-54). The types cover only what the catalogue reads; anything else
7
+ * in a story file is left alone. The format is its own package so the packages that write stories depend on it, not
8
+ * on the catalogue that shows them. Parameters the catalogue adds (`forceState`, `replay`) sit under `parameters`, where CSF
9
+ * keeps tool-specific settings.
10
+ * A Live story (`parameters.clock`) reads the story clock the catalogue runs (`./clock`, D-504).
11
+ *
12
+ * The types are generic over a renderer, as Storybook's are: what a framework's component is and what a render
13
+ * returns. A framework's package names them for its own (`Meta<typeof Button>` in `@forgebook/react`), and story
14
+ * files import them from there; nothing here depends on a framework.
15
+ *
16
+ * @module
17
+ */
18
+ import type { StoryClock, StoryClockSetting } from "./clock.ts";
19
+ import type { StoryTextArg, StoryTextFunction } from "./texts.ts";
20
+ /**
21
+ * A framework, as the story types read it: what a meta names as its component, and what a render, a decorator and a
22
+ * language's provider return.
23
+ */
24
+ export type Renderer = {
25
+ /** A component of the framework. */
26
+ readonly component: unknown;
27
+ /** What a story draws (`ReactNode` in React). */
28
+ readonly storyResult: unknown;
29
+ };
30
+ /** A value a story's args may write for a prop: the prop's own, or, where it takes a text, a text named by its key. */
31
+ export type WrittenArg<TValue> = string extends TValue ? TValue | StoryTextArg : TValue;
32
+ /** An interaction state the catalogue can show without the pointer or the keyboard (`parameters.forceState`). */
33
+ export type ForcedState = "hover" | "active" | "focus" | "focus-visible" | "focus-within";
34
+ /**
35
+ * How the Replay control replays a story: `remount` mounts it again (an entrance), `{ toggle }` sets that boolean arg
36
+ * to false and, once the exit has played, back to true (an exit and an entrance).
37
+ */
38
+ export type ReplayMode = "remount" | {
39
+ /** The boolean arg turned false then true again. */
40
+ readonly toggle: string;
41
+ /** How long the arg stays false once the exit has played, in ms (a loading phase to watch); none by default. */
42
+ readonly hold?: number;
43
+ };
44
+ /**
45
+ * A group of stories in the sidebar (`states`, `in-context`): its order and heading come from the catalogue's
46
+ * configuration (or a library's preset); a group it does not name sits after the named ones.
47
+ */
48
+ export type StoryGroup = string;
49
+ /** The controls an arg can have in the props panel, as Storybook names them. */
50
+ export type ArgControlType = "select" | "radio" | "inline-radio" | "check" | "inline-check" | "multi-select" | "boolean" | "text" | "number" | "range" | "color" | "date" | "object" | "file";
51
+ /** An arg's control: its type, or `false` for none, or the type with its settings. */
52
+ export type ArgControl = ArgControlType | false | {
53
+ /** The control; from the arg's type when left out. */
54
+ readonly type?: ArgControlType;
55
+ /** The names the panel shows for the options, by option. */
56
+ readonly labels?: Readonly<Record<string, string>>;
57
+ /** A range's or a number's lowest value. */
58
+ readonly min?: number;
59
+ /** A range's or a number's highest value. */
60
+ readonly max?: number;
61
+ /** A range's or a number's step. */
62
+ readonly step?: number;
63
+ /** Whether the control is off: the arg is shown, not set. */
64
+ readonly disable?: boolean;
65
+ };
66
+ /**
67
+ * How the props panel shows one arg (Storybook's `argTypes`): over what the component's types say, or alone for an
68
+ * arg the types do not name. The story's entry is laid over the meta's.
69
+ */
70
+ export type ArgType = {
71
+ /** The name the panel shows; the arg's by default. */
72
+ readonly name?: string;
73
+ /** What the arg does, over its TSDoc. */
74
+ readonly description?: string;
75
+ /** Its control. */
76
+ readonly control?: ArgControl;
77
+ /** The values a choice offers: texts or numbers, or keys of `mapping`. */
78
+ readonly options?: readonly unknown[];
79
+ /** The value each option stands for, by option: the panel sends the option, the story receives the value. */
80
+ readonly mapping?: Readonly<Record<string, unknown>>;
81
+ /** The table's settings: `disable` hides the arg from the panel. */
82
+ readonly table?: {
83
+ readonly disable?: boolean;
84
+ };
85
+ /** Records the arg's calls in the Events tab, under this name (Storybook's actions); a spy (`fn()`) is recorded too. */
86
+ readonly action?: string;
87
+ };
88
+ /** A story's or a meta's `argTypes`, by arg. */
89
+ export type ArgTypes<TArgs> = {
90
+ readonly [Name in keyof TArgs]?: ArgType;
91
+ } & Readonly<Record<string, ArgType>>;
92
+ /** The settings the catalogue reads from a meta or a story; anything else under `parameters` is left alone. */
93
+ export type StoryParameters = {
94
+ /** The states forced on the whole story; a part can force its own with `data-forgebook-force`. */
95
+ readonly forceState?: ForcedState | readonly ForcedState[];
96
+ /** Shows the Replay control and says what it does. */
97
+ readonly replay?: ReplayMode;
98
+ /**
99
+ * The props the panel can set for the story: every adjustable prop by default, only the listed ones, or none
100
+ * (`false`) for a story that draws fixed examples and ignores its args, which then shows no props (its column stays, empty, so the story keeps its width). With a list, the
101
+ * others are listed without a control. Storybook's `{ include, exclude }` is read too: `include` as the list,
102
+ * `exclude` hiding those args.
103
+ */
104
+ readonly controls?: false | readonly string[] | {
105
+ readonly include?: readonly string[];
106
+ readonly exclude?: readonly string[];
107
+ };
108
+ /** The story's group in the sidebar, a plain string (the index reads it); none puts it above the groups. */
109
+ readonly group?: StoryGroup;
110
+ /**
111
+ * Whether the story is the component's demo, drawn at the top of its page: one real, well-made use of it, not a
112
+ * matrix of its values. Written plainly (`main: true`, the index reads it); without one, the page shows `Overview`.
113
+ */
114
+ readonly main?: boolean;
115
+ /**
116
+ * The height the story's scene needs, in CSS px: the frame has it from the start, so an overlay the story opens is
117
+ * placed once, as in a window of that size, instead of flipping or scrolling in a frame only as tall as the story's
118
+ * own content. The frame still grows past it with its content (D-469). Written plainly (`height: 320`, the index
119
+ * reads it).
120
+ */
121
+ readonly height?: number;
122
+ /**
123
+ * The story reads the story clock (`context.clock`, `useStoryNow`): a Live story, which starts at this moment and
124
+ * then runs; the catalogue shows pause, resume, restart and the speed, and the tests hold it at its start (D-504).
125
+ * None by default: the clock is held at the Unix epoch and the catalogue shows no clock controls.
126
+ */
127
+ readonly clock?: StoryClockSetting;
128
+ /** How the story sits in its frame: padded (default), centred, or the whole frame. */
129
+ readonly layout?: "padded" | "centered" | "fullscreen";
130
+ /** CSF's documentation block; the catalogue reads the component's one-line description from it. */
131
+ readonly docs?: {
132
+ readonly description?: {
133
+ readonly component?: string;
134
+ };
135
+ };
136
+ };
137
+ /**
138
+ * Names a part of a play function: the catalogue's Interactions tab lists each step with its status and time, so a
139
+ * failing play shows where it stopped. Outside a play, it only runs the part.
140
+ */
141
+ export type StepFunction = (label: string, run: () => Promise<void> | void) => Promise<void>;
142
+ /** What a story's render, play and decorators receive. */
143
+ export type StoryContext<TArgs> = {
144
+ /** The args: the meta's, the story's and the props panel's, merged in that order. */
145
+ readonly args: TArgs;
146
+ /** The element the story renders into. */
147
+ readonly canvasElement: HTMLElement;
148
+ /** Names a part of the play function (CSF's `step`). */
149
+ readonly step: StepFunction;
150
+ /** The text of a key in the shown language (`stories/locales/<id>.json`), its `{name}` placeholders filled. */
151
+ readonly text: StoryTextFunction;
152
+ /**
153
+ * The story clock: the time a Live story reads, and what its play function advances instead of waiting; held at
154
+ * the Unix epoch when the story declares no `parameters.clock` (D-504).
155
+ */
156
+ readonly clock: StoryClock;
157
+ /**
158
+ * The values of the catalogue's switches applied by code, by the switch's id (CSF's name): what a decorator reads
159
+ * to pick a provider's theme, a density, a locale. Empty outside a catalogue.
160
+ */
161
+ readonly globals: Readonly<Record<string, string>>;
162
+ /** What the story's loaders returned, merged: the preview's, then the meta's, then the story's (CSF's `loaded`). */
163
+ readonly loaded: Readonly<Record<string, unknown>>;
164
+ /** The story's id in the catalogue (`kit:inputs-select--overview`). */
165
+ readonly id: string;
166
+ /** The story's name as the catalogue shows it (`Keyboard open`). */
167
+ readonly name: string;
168
+ /** The title of its file's meta (`Inputs/Select`). */
169
+ readonly title: string;
170
+ /** The story's parameters: the preview's, under the meta's, under its own. */
171
+ readonly parameters: Readonly<Record<string, unknown>>;
172
+ };
173
+ /**
174
+ * What a play function receives besides the story's context, filled in by the libraries the project installs.
175
+ *
176
+ * @remarks
177
+ * Empty here: Forgebook depends on no testing library. A project that installs `@testing-library/dom` and
178
+ * `@testing-library/user-event` gets `canvas` and `userEvent` in every play, and imports
179
+ * `@forgebook/story-format/testing-library` once to type them (it adds them to this interface).
180
+ */
181
+ export interface StoryPlayTools {
182
+ }
183
+ /** What a play function receives: the story's context, its `step`, and the play tools the project installed. */
184
+ export type StoryPlayContext<TArgs> = StoryContext<TArgs> & StoryPlayTools;
185
+ /**
186
+ * What a loader and a `beforeEach` receive: the story's args and what it is shown with, before it is drawn. No canvas:
187
+ * they also run before a story is drawn on the server, where there is none.
188
+ */
189
+ export type StoryHookContext<TArgs> = Pick<StoryContext<TArgs>, "args" | "text" | "clock" | "globals" | "loaded" | "id" | "name" | "title" | "parameters">;
190
+ /**
191
+ * Fetches what a story needs before it is drawn (CSF's loader): what it returns reaches the story's render, play and
192
+ * decorators as `context.loaded`. Every loader of a story runs at once; a later one's key wins (the story's over the
193
+ * meta's over the preview's). It receives an empty `loaded`.
194
+ */
195
+ export type StoryLoader<TArgs> = (context: StoryHookContext<TArgs>) => Promise<Readonly<Record<string, unknown>> | undefined> | Readonly<Record<string, unknown>> | undefined;
196
+ /** Undoes what a `beforeEach` set up: run when the story is mounted again or its frame is left. */
197
+ export type StoryCleanup = () => Promise<void> | void;
198
+ /**
199
+ * Sets up what a story needs before it is drawn, after its loaders (CSF's `beforeEach`: a mocked date, a stored
200
+ * value), one after another: the preview's, the meta's, the story's. It may return the cleanup that undoes it.
201
+ */
202
+ export type StoryBeforeEach<TArgs> = (context: StoryHookContext<TArgs>) => Promise<StoryCleanup | undefined> | StoryCleanup | undefined;
203
+ /** One function of a kind, or a list of them, as CSF lets a meta, a story or a preview write it. */
204
+ export type OneOrMany<TFunction> = TFunction | readonly TFunction[];
205
+ /** Wraps a story: a provider, a container of a given width. */
206
+ export type Decorator<TRenderer extends Renderer, TArgs> = (story: () => TRenderer["storyResult"], context: StoryContext<TArgs>) => TRenderer["storyResult"];
207
+ /**
208
+ * A story file's default export, for a framework: `TComponent` is the component it shows, `TArgs` what its render
209
+ * receives and `TWrittenArgs` what its args may write (a framework's package derives both from the component's props).
210
+ */
211
+ export type CsfMeta<TRenderer extends Renderer, TComponent, TArgs, TWrittenArgs> = {
212
+ /**
213
+ * Where it sits in the catalogue: `Family/Name` or `Family/Group/Name` (`Inputs/Selection/Select`); any depth is
214
+ * placed. Written plainly; without one, the file's path from its pattern's folder is the title.
215
+ */
216
+ readonly title?: string;
217
+ /** The component the stories show; their args are its props. */
218
+ readonly component?: TComponent;
219
+ /**
220
+ * The parts the component is used with that have no story file of their own (`{ ChipList }` beside `Chip`), by the
221
+ * name the catalogue shows: the component's page lists each one's props under its own. Storybook's
222
+ * `subcomponents`, so the stories stay readable by it. Written in the meta as an object of imported components: the
223
+ * catalogue reads it without running the file.
224
+ */
225
+ readonly subcomponents?: Readonly<Record<string, TRenderer["component"]>>;
226
+ /** Args every story of the file starts from. */
227
+ readonly args?: TWrittenArgs;
228
+ /** How the props panel shows the args (Storybook's `argTypes`). */
229
+ readonly argTypes?: ArgTypes<TWrittenArgs>;
230
+ /**
231
+ * The catalogue's switches the story fixes, by the switch's id (`{ theme: "dark" }`), and Storybook's
232
+ * `backgrounds` and `viewport` (`{ backgrounds: { value: "dark" } }`): drawn so whatever the toolbar says, which
233
+ * shows them as set by the story.
234
+ */
235
+ readonly globals?: Readonly<Record<string, unknown>>;
236
+ /**
237
+ * Other places the catalogue lists the component in, besides its title's, as `Family` or `Family/Group`
238
+ * (`["Data/Tables"]`): a component that belongs to one family but is looked for in another. Each place shows an
239
+ * entry marked as living elsewhere that opens the same page, so nothing is duplicated: no second story, test or
240
+ * image (D-492). Written plainly, a list of string literals: the catalogue reads it without running the file.
241
+ */
242
+ readonly alsoIn?: readonly string[];
243
+ /**
244
+ * The titles of related components of the same source (`["Layout/Inline"]`): each page names the other at its top,
245
+ * both ways, so writing the link in one meta is enough (D-492). Written plainly, a list of string literals.
246
+ */
247
+ readonly related?: readonly string[];
248
+ /**
249
+ * Other words the catalogue's search finds the component by, besides its name and title: the names other libraries
250
+ * give it (`["horizontal", "row", "hstack"]` for `Inline`). Written plainly, a list of string literals (D-603).
251
+ */
252
+ readonly keywords?: readonly string[];
253
+ /** Settings for every story of the file. */
254
+ readonly parameters?: StoryParameters;
255
+ /** Wrappers for every story of the file, outermost last. */
256
+ readonly decorators?: readonly Decorator<TRenderer, TArgs>[];
257
+ /** What every story of the file renders when it writes no render of its own. */
258
+ readonly render?: (args: TArgs, context: StoryContext<TArgs>) => TRenderer["storyResult"];
259
+ /** The play function of every story of the file that writes none of its own. */
260
+ readonly play?: (context: StoryPlayContext<TArgs>) => Promise<void> | void;
261
+ /** Loaders for every story of the file, after the preview's. */
262
+ readonly loaders?: OneOrMany<StoryLoader<TArgs>>;
263
+ /** Set-ups for every story of the file, after the preview's. */
264
+ readonly beforeEach?: OneOrMany<StoryBeforeEach<TArgs>>;
265
+ /** Tags of every story of the file (`["autodocs"]`); a story's `!name` takes one away. Written plainly. */
266
+ readonly tags?: readonly string[];
267
+ /** The named exports that are stories: a list of names or a regular expression; every one by default. */
268
+ readonly includeStories?: readonly string[] | RegExp;
269
+ /** The named exports that are not stories (shared data): a list of names or a regular expression. */
270
+ readonly excludeStories?: readonly string[] | RegExp;
271
+ };
272
+ /** A story, a named export of a story file, for a framework: its args as in `CsfMeta`. */
273
+ export type CsfStory<TRenderer extends Renderer, TArgs, TWrittenArgs> = {
274
+ /** The name in the catalogue; by default the export's name in sentence case (`KeyboardOpen` → "Keyboard open"). */
275
+ readonly name?: string;
276
+ /** Args over the meta's. */
277
+ readonly args?: TWrittenArgs;
278
+ /** How the props panel shows the args (Storybook's `argTypes`). */
279
+ readonly argTypes?: ArgTypes<TWrittenArgs>;
280
+ /**
281
+ * The catalogue's switches the story fixes, by the switch's id (`{ theme: "dark" }`), and Storybook's
282
+ * `backgrounds` and `viewport` (`{ backgrounds: { value: "dark" } }`): drawn so whatever the toolbar says, which
283
+ * shows them as set by the story.
284
+ */
285
+ readonly globals?: Readonly<Record<string, unknown>>;
286
+ /** What the story renders; by default the meta's component with the args. */
287
+ readonly render?: (args: TArgs, context: StoryContext<TArgs>) => TRenderer["storyResult"];
288
+ /** Runs after the story renders: a keyboard flow, an async path (the tests run it too). */
289
+ readonly play?: (context: StoryPlayContext<TArgs>) => Promise<void> | void;
290
+ /** Settings over the meta's. */
291
+ readonly parameters?: StoryParameters;
292
+ /** Wrappers inside the meta's. */
293
+ readonly decorators?: readonly Decorator<TRenderer, TArgs>[];
294
+ /** Loaders after the meta's. */
295
+ readonly loaders?: OneOrMany<StoryLoader<TArgs>>;
296
+ /** Set-ups after the meta's. */
297
+ readonly beforeEach?: OneOrMany<StoryBeforeEach<TArgs>>;
298
+ /** Tags over the meta's: `!name` takes one of the meta's away. Written plainly. */
299
+ readonly tags?: readonly string[];
300
+ };
301
+ /**
302
+ * A catalogue's preview (`forgebook.preview.ts`), for a framework: what applies to every story in the frames. Its
303
+ * decorators wrap every story outside the meta's and the story's own (a provider, the language's provider reading
304
+ * `context.globals.lang`), its parameters sit under every meta's, its setup runs once before any story renders, and
305
+ * its loaders and set-ups run before every story's own.
306
+ */
307
+ export type CsfPreview<TRenderer extends Renderer> = {
308
+ /** Wrappers for every story, outermost last. */
309
+ readonly decorators?: readonly Decorator<TRenderer, Readonly<Record<string, unknown>>>[];
310
+ /** Settings every story starts from, under its meta's and its own. */
311
+ readonly parameters?: StoryParameters;
312
+ /** What the stories need before any renders (a polyfill to load); nothing by default. */
313
+ readonly setup?: () => Promise<void>;
314
+ /** Loaders for every story, before the meta's and the story's. */
315
+ readonly loaders?: OneOrMany<StoryLoader<Readonly<Record<string, unknown>>>>;
316
+ /** Set-ups for every story, before the meta's and the story's. */
317
+ readonly beforeEach?: OneOrMany<StoryBeforeEach<Readonly<Record<string, unknown>>>>;
318
+ /** Args every story starts from, under its meta's (Storybook's project args). */
319
+ readonly args?: Readonly<Record<string, unknown>>;
320
+ /** How the props panel shows args of every story, under the meta's and the story's. */
321
+ readonly argTypes?: Readonly<Record<string, ArgType>>;
322
+ /**
323
+ * Storybook's toolbar of the preview's own globals: read by the configuration on Node, through
324
+ * `switchesFromGlobalTypes`, never by the frames.
325
+ */
326
+ readonly globalTypes?: Readonly<Record<string, unknown>>;
327
+ /** The globals' first values, for `switchesFromGlobalTypes`. */
328
+ readonly initialGlobals?: Readonly<Record<string, unknown>>;
329
+ /** Tags of every story, under the meta's. */
330
+ readonly tags?: readonly string[];
331
+ };
332
+ //# sourceMappingURL=csf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csf.d.ts","s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* @remarks
5
+ * A story file exports its meta as the default export and each story as a named export, as CSF requires, so
6
+ * Storybook or Ladle could read the same files (D-54). The types cover only what the catalogue reads; anything else
7
+ * in a story file is left alone. The format is its own package so the packages that write stories depend on it, not
8
+ * on the catalogue that shows them. Parameters the catalogue adds (`forceState`, `replay`) sit under `parameters`, where CSF
9
+ * keeps tool-specific settings.
10
+ * A Live story (`parameters.clock`) reads the story clock the catalogue runs (`./clock`, D-504).
11
+ *
12
+ * The types are generic over a renderer, as Storybook's are: what a framework's component is and what a render
13
+ * returns. A framework's package names them for its own (`Meta<typeof Button>` in `@forgebook/react`), and story
14
+ * files import them from there; nothing here depends on a framework.
15
+ *
16
+ * @module
17
+ */
18
+ // a story draws in a page (`canvasElement`): code on Node that reads these types (the catalogue's plugin) gets the DOM's
19
+ // types from here
20
+ /// <reference lib="dom" />
21
+ //# sourceMappingURL=csf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csf.js","sourceRoot":"","sources":["../../src/csf.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,yHAAyH;AACzH,kBAAkB;AAClB,2BAA2B"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * What a package hands a catalogue: its story files, its style sheets, its texts.
3
+ *
4
+ * @remarks
5
+ * Every package with stories exports one `StorySource` from a development-only `./stories` subpath, never published;
6
+ * an app lists the sources it shows (D-57). A source names its story files once per pattern, with an import the
7
+ * catalogue's Vite plugin answers (`import files from "../src/**\/*.stories.tsx?forgebook-files"`, typed by
8
+ * `@forgebook/story-format/client`): one module with every file's index (read without running the files), and the loaders
9
+ * of its stories, its component's docs and its code (D-438). The style sheets are the URLs the frame loads for each
10
+ * Styles setting.
11
+ *
12
+ * @module
13
+ */
14
+ import type { StoryGroup } from "./csf.ts";
15
+ /** The props the panel can set for a story: every adjustable one, or only the named ones (none for fixed examples). */
16
+ export type StoryControlsSetting = "all" | readonly string[];
17
+ /** One story of a file, as the index lists it. */
18
+ export type StoryIndexEntry = {
19
+ /** The named export (`KeyboardOpen`). */
20
+ readonly exportName: string;
21
+ /** The name written in the story, when it has one (`name: "Keyboard · open"`). */
22
+ readonly name?: string;
23
+ /** The story's own `parameters.controls`, when it sets one: `[]` for `false`. */
24
+ readonly controls?: StoryControlsSetting;
25
+ /** The story's `parameters.group`, when it sets one. */
26
+ readonly group?: StoryGroup;
27
+ /** The story's own `parameters.height`, when it sets one, in CSS px (D-469). */
28
+ readonly height?: number;
29
+ /** Whether the story sets `parameters.main: true`: the component's demo. */
30
+ readonly isMain?: boolean;
31
+ /**
32
+ * The first sentence of the story's TSDoc, or its `parameters.docs.description.story`: what it shows and what to
33
+ * notice.
34
+ */
35
+ readonly description?: string;
36
+ /** The story's tags, the meta's then its own, a `!name` taking `name` away (Storybook's tags). */
37
+ readonly tags?: readonly string[];
38
+ };
39
+ /** One story file, read statically: what the catalogue shows before loading it. */
40
+ export type StoryFileIndex = {
41
+ /** The meta's title (`Inputs/Selection/Select`). */
42
+ readonly title: string;
43
+ /** The meta's `parameters.controls`, when it sets one: `[]` for `false`. */
44
+ readonly controls?: StoryControlsSetting;
45
+ /** The meta's `parameters.height`, when it sets one: every story's frame height, in CSS px (D-469). */
46
+ readonly height?: number;
47
+ /** The meta's `alsoIn`, when it sets one: the other places the component is listed in (D-492). */
48
+ readonly alsoIn?: readonly string[];
49
+ /** The meta's `related`, when it sets one: the titles of the components its page names at its top (D-492). */
50
+ readonly related?: readonly string[];
51
+ /** The meta's `keywords`, when it sets one: other words the search finds the component by (D-603). */
52
+ readonly keywords?: readonly string[];
53
+ /** The meta's `parameters.docs.description.component`, when written plainly. */
54
+ readonly description?: string;
55
+ /** What the index noticed without refusing the file (a title written by code, placed by its path). */
56
+ readonly notes?: readonly string[];
57
+ /** Its stories, in the order of the file (or of its `__namedExportsOrder`). */
58
+ readonly stories: readonly StoryIndexEntry[];
59
+ };
60
+ /** The style sheets of a package, as URLs, for each Styles setting of the toolbar. */
61
+ export type StorySheets = {
62
+ /** Always loaded: the tokens and the structure. */
63
+ readonly required: readonly string[];
64
+ /** Loaded with Styles › Full: the theme. */
65
+ readonly theme: readonly string[];
66
+ /** Loaded with Styles › Restyled, instead of the theme: a consumer's own look through the public hooks. */
67
+ readonly restyled: readonly string[];
68
+ };
69
+ /**
70
+ * A language a catalogue offers (the View menu's Language row): its id and name, and whether its texts are a
71
+ * pseudo-translation. Data only: the provider that draws a story in a language is a decorator of the catalogue's
72
+ * preview, which reads the language as `context.globals.lang`.
73
+ */
74
+ export type StoryLanguage = {
75
+ /** A stable id, written in the address (`pseudo`). */
76
+ readonly id: string;
77
+ /** The name in the View menu (`Pseudo`). */
78
+ readonly label: string;
79
+ /**
80
+ * Whether the stories' own texts are drawn as a pseudo-translation of the English ones (accented, longer, in
81
+ * brackets) instead of a table of their own; `false` by default.
82
+ */
83
+ readonly isPseudo?: boolean;
84
+ };
85
+ /** A story's `render` as written in its file. */
86
+ export type StoryCode = {
87
+ /** The text, as copied. */
88
+ readonly text: string;
89
+ /** The same text as HTML, coloured by the catalogue's plugin at build time. */
90
+ readonly html: string;
91
+ };
92
+ /** Each story's `render` as written in its file, by export name; a story without one is left out. */
93
+ export type StoryFileCode = Readonly<Record<string, StoryCode>>;
94
+ /**
95
+ * A group of story files, as the catalogue's plugin answers a `?forgebook-files` import: each file's index, and the
96
+ * loaders of its module, of its component's docs and of its code, all by the file's path relative to the importing
97
+ * module (`../src/inputs/select/Select.stories.tsx`).
98
+ */
99
+ export type StoryFiles = {
100
+ /** Each file's index: its title and stories, read without running it. */
101
+ readonly index: Readonly<Record<string, StoryFileIndex>>;
102
+ /** Each file's module, loaded when a frame shows one of its stories. */
103
+ readonly stories: Readonly<Record<string, () => Promise<unknown>>>;
104
+ /** Each file's component docs, for the props panel (`{ error }` when they cannot be read, `{ name: null }` for none). */
105
+ readonly docs: Readonly<Record<string, () => Promise<unknown>>>;
106
+ /** Each file's code: each story's `render` as written, for the Code tab. */
107
+ readonly code: Readonly<Record<string, () => Promise<unknown>>>;
108
+ /** Each file's component page: its Markdown documentation, beside the story file, as HTML (`{ none: true }` without). */
109
+ readonly pages: Readonly<Record<string, () => Promise<unknown>>>;
110
+ };
111
+ /**
112
+ * The colour of the page a source's stories open on, by theme and contrast: the catalogue paints a story's box with it
113
+ * while the story loads, so the box is not white before a dark story and does not change colour when the story shows.
114
+ * A CSS colour each; the more-contrast ones fall back to their scheme's.
115
+ */
116
+ export type StoryBackground = {
117
+ /** The light theme's. */
118
+ readonly light: string;
119
+ /** The dark theme's. */
120
+ readonly dark: string;
121
+ /** The light theme's with more contrast; `light` when left out. */
122
+ readonly lightMore?: string;
123
+ /** The dark theme's with more contrast; `dark` when left out. */
124
+ readonly darkMore?: string;
125
+ };
126
+ /** A Markdown file as the catalogue's plugin answers a `?forgebook-markdown` import: its text as HTML. */
127
+ export type StoryMarkdown = {
128
+ /** The file as HTML, its first `#` title left out (the catalogue shows the source's name). */
129
+ readonly html: string;
130
+ };
131
+ /** A package's stories, as the catalogue reads them. */
132
+ export type StorySource = {
133
+ /** A stable id, part of every story id's URL (`acme-ui`). */
134
+ readonly id: string;
135
+ /** The name in the sidebar (`Acme UI`). */
136
+ readonly name: string;
137
+ /**
138
+ * The package's logo, shown beside its name in the sidebar and on the home: the URL of a square image, drawn for a
139
+ * light surface (`import logoUrl from "./logo.svg?url"`). None by default.
140
+ */
141
+ readonly logo?: string;
142
+ /**
143
+ * The colour the stories' page has (the frame's `body`, as the source's frame style sheet sets it), by theme and
144
+ * contrast, for the box a story loads in. None by default: the box waits on the catalogue's own surface.
145
+ */
146
+ readonly background?: StoryBackground;
147
+ /** The families in the order the sidebar lists them; families not listed follow, alphabetically. */
148
+ readonly families?: readonly string[];
149
+ /**
150
+ * The groups of a family in the order the sidebar lists them, by family (`{ Inputs: ["Text", "Choice"] }`): a
151
+ * family's own components without a group come first, then its groups as listed, then the groups not listed,
152
+ * alphabetically. None by default: every family's groups alphabetically.
153
+ */
154
+ readonly familyGroups?: Readonly<Record<string, readonly string[]>>;
155
+ /** Its story files: one group per `?forgebook-files` import, the keys unique across the groups. */
156
+ readonly files: readonly StoryFiles[];
157
+ /** The style sheets. */
158
+ readonly sheets: StorySheets;
159
+ /**
160
+ * Values the props panel offers by name for a type it cannot write (a component, a function), keyed by the type as
161
+ * TypeScript writes it in the props (`IconComponent`), then by the name shown and written in the JSX
162
+ * (`IconFolder`): `{ IconComponent: { IconFolder, IconBell } }`. None by default.
163
+ */
164
+ readonly namedValues?: Readonly<Record<string, Readonly<Record<string, unknown>>>>;
165
+ /**
166
+ * The texts inside the stories, by language id (the ids of the catalogue's languages; `en` the one every key is in):
167
+ * the package's `stories/locales/<id>.json`. A story reads them with `useStoryText()` or `context.text()`; none by
168
+ * default.
169
+ */
170
+ readonly texts?: Readonly<Record<string, Readonly<Record<string, string>>>>;
171
+ /**
172
+ * What the source needs before any of its stories renders (a polyfill to load), awaited by the frame and by the
173
+ * server tests; nothing by default.
174
+ */
175
+ readonly setup?: () => Promise<void>;
176
+ /**
177
+ * The source's introduction on the catalogue's home, written by the package: what it is, how to start
178
+ * (`home: () => import("./home.md?forgebook-markdown")`). None by default: the home then shows only its families.
179
+ */
180
+ readonly home?: () => Promise<{
181
+ readonly default: StoryMarkdown;
182
+ }>;
183
+ };
184
+ //# sourceMappingURL=source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,uHAAuH;AACvH,MAAM,MAAM,oBAAoB,GAAG,KAAK,GAAG,SAAS,MAAM,EAAE,CAAC;AAE7D,kDAAkD;AAClD,MAAM,MAAM,eAAe,GAAG;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,kFAAkF;IAClF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,iFAAiF;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AAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;CACpE,CAAC"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/source.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The types of the play tools a project gets by installing Testing Library: imported once, as
3
+ * `import "@forgebook/story-format/testing-library"`, it adds `canvas` and `userEvent` to every play function's
4
+ * context.
5
+ *
6
+ * @remarks
7
+ * Forgebook depends on no testing library; when the project installs `@testing-library/dom` and
8
+ * `@testing-library/user-event`, the catalogue's frame hands every play `canvas` (Testing Library's queries bound to the
9
+ * story's canvas, as Storybook's) and `userEvent`. Without them, importing this module fails to type-check, as the
10
+ * frame would have nothing to hand.
11
+ *
12
+ * @module
13
+ */
14
+ import type { BoundFunctions, queries } from "@testing-library/dom";
15
+ import type { UserEvent } from "@testing-library/user-event";
16
+ declare module "./csf.ts" {
17
+ /** The play tools Testing Library gives. */
18
+ interface StoryPlayTools {
19
+ /** Testing Library's queries, bound to the story's canvas (`canvas.getByRole("button")`). */
20
+ readonly canvas: BoundFunctions<typeof queries>;
21
+ /** Testing Library's user events (`await userEvent.click(button)`). */
22
+ readonly userEvent: UserEvent;
23
+ }
24
+ }
25
+ //# sourceMappingURL=testingLibrary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testingLibrary.d.ts","sourceRoot":"","sources":["../../src/testingLibrary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,QAAQ,UAAU,CAAC;IACxB,4CAA4C;IAC5C,UAAU,cAAc;QACtB,6FAA6F;QAC7F,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,OAAO,CAAC,CAAC;QAChD,uEAAuE;QACvE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;KAC/B;CACF"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=testingLibrary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testingLibrary.js","sourceRoot":"","sources":["../../src/testingLibrary.ts"],"names":[],"mappings":""}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The texts inside the stories (a card's title, a row's sample name), in the language the catalogue shows: a story
3
+ * names a text by its key, and the package's locale files hold the words (`stories/locales/en.json`, `it.json`, …).
4
+ *
5
+ * @remarks
6
+ * The catalogue provides the texts of the shown language, English where a language lacks a key; a story reads them
7
+ * with `context.text()` in a render or a play function, or a framework's own access in a component (`useStoryText()`
8
+ * in `@forgebook/react/texts`), and an
9
+ * arg names one with `storyText("key")`: args are plain data, written before any language is known, so the catalogue
10
+ * gives the story the text in the shown language and the props panel shows it with its key. A key is written as a
11
+ * plain string literal (`text("skeleton.dashboard.title")`, `storyText("button.save")`), so `forgebook-texts` can find
12
+ * every key the stories use. Values may hold `{name}` placeholders, filled from the second argument. Without a provider (a test
13
+ * rendering a story on its own) a text is its key in brackets, never an empty string.
14
+ *
15
+ * @module
16
+ */
17
+ /** One language's texts, by key. */
18
+ export type StoryTextTable = Readonly<Record<string, string>>;
19
+ /** The values a text's `{name}` placeholders take. */
20
+ export type StoryTextValues = Readonly<Record<string, string | number>>;
21
+ /** Gives the text of a key in the shown language, its placeholders filled. */
22
+ export type StoryTextFunction = (key: string, values?: StoryTextValues) => string;
23
+ /**
24
+ * A text with its `{name}` placeholders filled; a placeholder without a value stays as it is.
25
+ *
26
+ * @param text - the text.
27
+ * @param values - the placeholders' values; none by default.
28
+ */
29
+ export declare const filledText: (text: string, values?: StoryTextValues) => string;
30
+ /**
31
+ * The text function over a table: a key the table lacks is the key in brackets, so a missing text shows.
32
+ *
33
+ * @param table - the texts of the shown language, English filled in.
34
+ */
35
+ export declare const storyTextOf: (table: StoryTextTable) => StoryTextFunction;
36
+ /** An arg that names a text: the story receives the text of the key in the shown language, its placeholders filled. */
37
+ export type StoryTextArg = {
38
+ /** The text's key. */
39
+ readonly storyText: string;
40
+ /** The values of its `{name}` placeholders; none by default. */
41
+ readonly values?: StoryTextValues;
42
+ };
43
+ /**
44
+ * An arg that names a text, for a prop that takes one: `args: { children: storyText("button.save") }`.
45
+ *
46
+ * @param key - the text's key, a plain string literal.
47
+ * @param values - the values of its `{name}` placeholders; none by default.
48
+ */
49
+ export declare const storyText: (key: string, values?: StoryTextValues) => StoryTextArg;
50
+ /**
51
+ * Whether an arg names a text.
52
+ *
53
+ * @param value - a story's arg.
54
+ */
55
+ export declare const isStoryTextArg: (value: unknown) => value is StoryTextArg;
56
+ //# sourceMappingURL=texts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texts.d.ts","sourceRoot":"","sources":["../../src/texts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,oCAAoC;AACpC,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE9D,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;AAExE,8EAA8E;AAC9E,MAAM,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,eAAe,KAAK,MAAM,CAAC;AAElF;;;;;GAKG;AACH,eAAO,MAAM,UAAU,SAAU,MAAM,WAAU,eAAe,KAAQ,MAIpE,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,WAAW,UACd,cAAc,KAAG,iBAIxB,CAAC;AAEJ,uHAAuH;AACvH,MAAM,MAAM,YAAY,GAAG;IACzB,sBAAsB;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,QAAS,MAAM,WAAW,eAAe,KAAG,YACM,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAW,OAAO,KAAG,KAAK,IAAI,YACmD,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * A text with its `{name}` placeholders filled; a placeholder without a value stays as it is.
3
+ *
4
+ * @param text - the text.
5
+ * @param values - the placeholders' values; none by default.
6
+ */
7
+ export const filledText = (text, values = {}) => text.replace(/\{(\w+)\}/g, (placeholder, name) => {
8
+ const value = values[name];
9
+ return value === undefined ? placeholder : String(value);
10
+ });
11
+ /**
12
+ * The text function over a table: a key the table lacks is the key in brackets, so a missing text shows.
13
+ *
14
+ * @param table - the texts of the shown language, English filled in.
15
+ */
16
+ export const storyTextOf = (table) => (key, values) => {
17
+ const text = table[key];
18
+ return text === undefined ? `[${key}]` : filledText(text, values);
19
+ };
20
+ /**
21
+ * An arg that names a text, for a prop that takes one: `args: { children: storyText("button.save") }`.
22
+ *
23
+ * @param key - the text's key, a plain string literal.
24
+ * @param values - the values of its `{name}` placeholders; none by default.
25
+ */
26
+ export const storyText = (key, values) => values === undefined ? { storyText: key } : { storyText: key, values };
27
+ /**
28
+ * Whether an arg names a text.
29
+ *
30
+ * @param value - a story's arg.
31
+ */
32
+ export const isStoryTextArg = (value) => typeof value === "object" && value !== null && "storyText" in value && typeof value.storyText === "string";
33
+ //# sourceMappingURL=texts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texts.js","sourceRoot":"","sources":["../../src/texts.ts"],"names":[],"mappings":"AAyBA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,MAAM,GAAoB,EAAE,EAAU,EAAE,CAC/E,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,WAAmB,EAAE,IAAY,EAAU,EAAE;IACvE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3D,CAAC,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,CAAC,KAAqB,EAAqB,EAAE,CAC7C,CAAC,GAAW,EAAE,MAAwB,EAAU,EAAE;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACxB,OAAO,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACpE,CAAC,CAAC;AAUJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAW,EAAE,MAAwB,EAAgB,EAAE,CAC/E,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AAEzE;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CACtE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,SAAS,KAAK,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,75 @@
1
1
  {
2
2
  "name": "@forgebook/story-format",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "The story format of Forgebook: the CSF 3 types a story file is written with, generic over a framework, the StorySource a package hands a catalogue, the texts inside the stories in the shown language, and the story clock a Live story reads. No dependency: a library's stories depend on their framework's package, never on the catalogue that shows them.",
5
+ "keywords": [
6
+ "stories",
7
+ "csf",
8
+ "design-system"
9
+ ],
10
+ "license": "MIT",
11
+ "author": "Jason Scoppetta",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/Ensiria/forgebook.git",
15
+ "directory": "packages/story-format"
16
+ },
17
+ "type": "module",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "engines": {
22
+ "node": ">=22.18"
23
+ },
24
+ "exports": {
25
+ "./csf": {
26
+ "types": "./dist/src/csf.d.ts",
27
+ "default": "./dist/src/csf.js"
28
+ },
29
+ "./clock": {
30
+ "types": "./dist/src/clock.d.ts",
31
+ "default": "./dist/src/clock.js"
32
+ },
33
+ "./source": {
34
+ "types": "./dist/src/source.d.ts",
35
+ "default": "./dist/src/source.js"
36
+ },
37
+ "./client": {
38
+ "types": "./dist/src/client.d.ts"
39
+ },
40
+ "./texts": {
41
+ "types": "./dist/src/texts.d.ts",
42
+ "default": "./dist/src/texts.js"
43
+ },
44
+ "./testing-library": {
45
+ "types": "./dist/src/testingLibrary.d.ts",
46
+ "default": "./dist/src/testingLibrary.js"
47
+ }
48
+ },
49
+ "devDependencies": {
50
+ "@testing-library/dom": "10.4.2",
51
+ "@testing-library/user-event": "14.6.8",
52
+ "@forgebook/tools": "0.0.0",
53
+ "@forgebook/typescript-config": "0.0.0"
54
+ },
55
+ "peerDependencies": {
56
+ "@testing-library/dom": "^10.4.0",
57
+ "@testing-library/user-event": "^14.6.0"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "@testing-library/dom": {
61
+ "optional": true
62
+ },
63
+ "@testing-library/user-event": {
64
+ "optional": true
65
+ }
66
+ },
67
+ "publishConfig": {
68
+ "access": "public"
69
+ },
70
+ "scripts": {
71
+ "build": "package-build build",
72
+ "manifest": "package-build manifest",
73
+ "typecheck": "tsc -p src"
74
+ }
6
75
  }