@scaffold-ui-kit/preview 0.0.0-stage → 2.3.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 +21 -0
- package/README.md +1868 -2
- package/application/host/bootstrap.ts +43 -0
- package/application/host/main.ts +31 -0
- package/application/host/shell-host.ts +47 -0
- package/application/index.html +12 -0
- package/application/lib/base-url.ts +15 -0
- package/application/lib/no-code-block.ts +7 -0
- package/application/lib/no-setup.ts +3 -0
- package/application/lib/no-views.ts +6 -0
- package/application/preview/code/code.html +12 -0
- package/application/preview/code/main.ts +89 -0
- package/application/preview/globals.ts +254 -0
- package/application/preview/html/main.ts +93 -0
- package/application/preview/html/preview.html +12 -0
- package/application/preview/react/main.tsx +146 -0
- package/application/preview/react/preview.html +12 -0
- package/application/preview/svelte/Preview.svelte +104 -0
- package/application/preview/svelte/main.ts +13 -0
- package/application/preview/svelte/preview.html +12 -0
- package/application/preview/svelte/story-props.ts +172 -0
- package/application/preview/view/main.ts +124 -0
- package/application/preview/view/view.html +12 -0
- package/application/preview/vue/main.ts +145 -0
- package/application/preview/vue/preview.html +12 -0
- package/application/shells/charcell/components/Application/index.css +37 -0
- package/application/shells/charcell/components/Application/index.tsx +65 -0
- package/application/shells/charcell/components/Bar/index.css +68 -0
- package/application/shells/charcell/components/Bar/index.tsx +60 -0
- package/application/shells/charcell/components/CodePane/index.css +60 -0
- package/application/shells/charcell/components/CodePane/index.tsx +113 -0
- package/application/shells/charcell/components/ComponentStage/index.css +26 -0
- package/application/shells/charcell/components/ComponentStage/index.tsx +110 -0
- package/application/shells/charcell/components/Control/index.css +20 -0
- package/application/shells/charcell/components/Control/index.tsx +118 -0
- package/application/shells/charcell/components/CopyLink/index.tsx +35 -0
- package/application/shells/charcell/components/Description/index.css +6 -0
- package/application/shells/charcell/components/Description/index.tsx +24 -0
- package/application/shells/charcell/components/EditorAddDialog/index.css +9 -0
- package/application/shells/charcell/components/EditorAddDialog/index.tsx +158 -0
- package/application/shells/charcell/components/EditorPanel/index.css +48 -0
- package/application/shells/charcell/components/EditorPanel/index.tsx +496 -0
- package/application/shells/charcell/components/EventsRow/index.css +42 -0
- package/application/shells/charcell/components/EventsRow/index.tsx +68 -0
- package/application/shells/charcell/components/HeadingRow/index.css +11 -0
- package/application/shells/charcell/components/HeadingRow/index.tsx +16 -0
- package/application/shells/charcell/components/Hint/index.css +16 -0
- package/application/shells/charcell/components/Hint/index.tsx +81 -0
- package/application/shells/charcell/components/HtmlWarnings/index.tsx +45 -0
- package/application/shells/charcell/components/KeyHints/index.css +27 -0
- package/application/shells/charcell/components/KeyHints/index.tsx +106 -0
- package/application/shells/charcell/components/KitCodeBlock/index.css +55 -0
- package/application/shells/charcell/components/KitCodeBlock/index.tsx +18 -0
- package/application/shells/charcell/components/Markdown/index.tsx +16 -0
- package/application/shells/charcell/components/Navigation/index.css +13 -0
- package/application/shells/charcell/components/Navigation/index.tsx +98 -0
- package/application/shells/charcell/components/NavigationSplit/index.css +16 -0
- package/application/shells/charcell/components/NavigationSplit/index.tsx +82 -0
- package/application/shells/charcell/components/OptionControls/index.tsx +93 -0
- package/application/shells/charcell/components/PaneStatus/index.css +7 -0
- package/application/shells/charcell/components/PaneStatus/index.tsx +47 -0
- package/application/shells/charcell/components/PaneWidth/index.tsx +45 -0
- package/application/shells/charcell/components/PreviewGrid/index.css +39 -0
- package/application/shells/charcell/components/PreviewGrid/index.tsx +344 -0
- package/application/shells/charcell/components/PreviewPane/index.css +127 -0
- package/application/shells/charcell/components/PreviewPane/index.tsx +182 -0
- package/application/shells/charcell/components/PromptBar/index.tsx +133 -0
- package/application/shells/charcell/components/ScenarioRow/index.css +36 -0
- package/application/shells/charcell/components/ScenarioRow/index.tsx +71 -0
- package/application/shells/charcell/components/Select/index.tsx +48 -0
- package/application/shells/charcell/components/SlotOutlet/index.css +7 -0
- package/application/shells/charcell/components/SlotOutlet/index.tsx +25 -0
- package/application/shells/charcell/components/StageBar/index.css +7 -0
- package/application/shells/charcell/components/StageBar/index.tsx +109 -0
- package/application/shells/charcell/components/StageSplit/index.css +11 -0
- package/application/shells/charcell/components/StageSplit/index.tsx +99 -0
- package/application/shells/charcell/components/StatusBar/index.tsx +30 -0
- package/application/shells/charcell/components/ViewControls/index.css +15 -0
- package/application/shells/charcell/components/ViewControls/index.tsx +58 -0
- package/application/shells/charcell/components/ViewHeading/index.css +13 -0
- package/application/shells/charcell/components/ViewHeading/index.tsx +8 -0
- package/application/shells/charcell/components/ViewStage/index.css +9 -0
- package/application/shells/charcell/components/ViewStage/index.tsx +25 -0
- package/application/shells/charcell/components/WrapToggle/index.tsx +27 -0
- package/application/shells/charcell/configuration.ts +45 -0
- package/application/shells/charcell/controller-context.ts +27 -0
- package/application/shells/charcell/fit-labels.ts +42 -0
- package/application/shells/charcell/html-warnings.ts +18 -0
- package/application/shells/charcell/index.tsx +82 -0
- package/application/shells/charcell/page-loading.html +57 -0
- package/application/shells/charcell/placement.ts +24 -0
- package/application/shells/charcell/shell-options.ts +23 -0
- package/application/shells/charcell/shell.css +37 -0
- package/application/shells/charcell/shell.tsx +25 -0
- package/application/shells/charcell/split-reset.ts +47 -0
- package/application/shells/charcell/stacked-rows.ts +117 -0
- package/application/shells/charcell/stage-toggles.ts +93 -0
- package/application/types/manifest.d.ts +6 -0
- package/application/types/preview-configuration.d.ts +10 -0
- package/application/types/preview-shell.d.ts +7 -0
- package/application/types/react-registry.d.ts +15 -0
- package/application/types/vue-registry.d.ts +6 -0
- package/dist/build.d.ts +24 -0
- package/dist/build.js +34 -0
- package/dist/check.d.ts +48 -0
- package/dist/check.js +781 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +88 -0
- package/dist/context.d.ts +179 -0
- package/dist/context.js +783 -0
- package/dist/controller/catalog.d.ts +339 -0
- package/dist/controller/catalog.js +367 -0
- package/dist/controller/create-preview-controller.d.ts +532 -0
- package/dist/controller/create-preview-controller.js +1707 -0
- package/dist/controller/editor-tree.d.ts +161 -0
- package/dist/controller/editor-tree.js +373 -0
- package/dist/controller/html-source.d.ts +62 -0
- package/dist/controller/html-source.js +61 -0
- package/dist/controller/index.d.ts +9 -0
- package/dist/controller/index.js +12 -0
- package/dist/controller/persistence.d.ts +191 -0
- package/dist/controller/persistence.js +315 -0
- package/dist/controller/regeneration.d.ts +30 -0
- package/dist/controller/regeneration.js +27 -0
- package/dist/controller/source.d.ts +80 -0
- package/dist/controller/source.js +236 -0
- package/dist/controller/store.d.ts +27 -0
- package/dist/controller/store.js +40 -0
- package/dist/declarations/application/shells/charcell/components/Application/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/Bar/index.d.ts +11 -0
- package/dist/declarations/application/shells/charcell/components/CodePane/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/ComponentStage/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/Control/index.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/components/CopyLink/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/components/Description/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/EditorAddDialog/index.d.ts +6 -0
- package/dist/declarations/application/shells/charcell/components/EditorPanel/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/EventsRow/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/HeadingRow/index.d.ts +6 -0
- package/dist/declarations/application/shells/charcell/components/Hint/index.d.ts +11 -0
- package/dist/declarations/application/shells/charcell/components/HtmlWarnings/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/KeyHints/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/KitCodeBlock/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/Markdown/index.d.ts +3 -0
- package/dist/declarations/application/shells/charcell/components/Navigation/index.d.ts +8 -0
- package/dist/declarations/application/shells/charcell/components/NavigationSplit/index.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/components/OptionControls/index.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/components/PaneStatus/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/PaneWidth/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/PreviewGrid/index.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/components/PreviewPane/index.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/components/PromptBar/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/components/ScenarioRow/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/Select/index.d.ts +16 -0
- package/dist/declarations/application/shells/charcell/components/SlotOutlet/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/StageBar/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/StageSplit/index.d.ts +17 -0
- package/dist/declarations/application/shells/charcell/components/StatusBar/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/components/ViewControls/index.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/components/ViewHeading/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/ViewStage/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/WrapToggle/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/configuration.d.ts +31 -0
- package/dist/declarations/application/shells/charcell/controller-context.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/fit-labels.d.ts +18 -0
- package/dist/declarations/application/shells/charcell/html-warnings.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/index.d.ts +39 -0
- package/dist/declarations/application/shells/charcell/placement.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/shell-options.d.ts +15 -0
- package/dist/declarations/application/shells/charcell/shell.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/split-reset.d.ts +30 -0
- package/dist/declarations/application/shells/charcell/stacked-rows.d.ts +58 -0
- package/dist/declarations/application/shells/charcell/stage-toggles.d.ts +28 -0
- package/dist/declarations/src/controller/catalog.d.ts +339 -0
- package/dist/declarations/src/controller/create-preview-controller.d.ts +532 -0
- package/dist/declarations/src/controller/editor-tree.d.ts +161 -0
- package/dist/declarations/src/controller/html-source.d.ts +62 -0
- package/dist/declarations/src/controller/index.d.ts +9 -0
- package/dist/declarations/src/controller/persistence.d.ts +191 -0
- package/dist/declarations/src/controller/regeneration.d.ts +30 -0
- package/dist/declarations/src/controller/source.d.ts +80 -0
- package/dist/declarations/src/controller/store.d.ts +27 -0
- package/dist/declarations/src/emit/common.d.ts +103 -0
- package/dist/declarations/src/emit/manifest.d.ts +138 -0
- package/dist/declarations/src/emit/source.d.ts +87 -0
- package/dist/declarations/src/lib/jsx-roots.d.ts +22 -0
- package/dist/declarations/src/lib/module-of-source.d.ts +18 -0
- package/dist/declarations/src/lib/naming.d.ts +29 -0
- package/dist/declarations/src/lib/react-spelling.d.ts +68 -0
- package/dist/declarations/src/lib/scenario-story.d.ts +41 -0
- package/dist/declarations/src/lib/slot-fill.d.ts +15 -0
- package/dist/declarations/src/lib/types.d.ts +741 -0
- package/dist/declarations/src/options.d.ts +224 -0
- package/dist/declarations/src/protocol.d.ts +541 -0
- package/dist/declarations/src/react-view.d.ts +22 -0
- package/dist/declarations/src/react.d.ts +17 -0
- package/dist/declarations/src/shell.d.ts +99 -0
- package/dist/declarations/src/views.d.ts +152 -0
- package/dist/development-server.d.ts +121 -0
- package/dist/development-server.js +331 -0
- package/dist/emit/common.d.ts +103 -0
- package/dist/emit/common.js +170 -0
- package/dist/emit/html-source.d.ts +46 -0
- package/dist/emit/html-source.js +322 -0
- package/dist/emit/manifest.d.ts +138 -0
- package/dist/emit/manifest.js +74 -0
- package/dist/emit/react.d.ts +16 -0
- package/dist/emit/react.js +210 -0
- package/dist/emit/scratch.d.ts +40 -0
- package/dist/emit/scratch.js +116 -0
- package/dist/emit/source.d.ts +87 -0
- package/dist/emit/source.js +789 -0
- package/dist/emit/svelte.d.ts +9 -0
- package/dist/emit/svelte.js +177 -0
- package/dist/emit/vue.d.ts +2 -0
- package/dist/emit/vue.js +152 -0
- package/dist/enumerate.d.ts +2 -0
- package/dist/enumerate.js +162 -0
- package/dist/generate.d.ts +43 -0
- package/dist/generate.js +302 -0
- package/dist/html-stylesheet.d.ts +43 -0
- package/dist/html-stylesheet.js +145 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +21 -0
- package/dist/landing.d.ts +16 -0
- package/dist/landing.js +45 -0
- package/dist/lib/exported-types.d.ts +42 -0
- package/dist/lib/exported-types.js +86 -0
- package/dist/lib/html-attributes.d.ts +2 -0
- package/dist/lib/html-attributes.js +111 -0
- package/dist/lib/html-warnings.d.ts +19 -0
- package/dist/lib/html-warnings.js +79 -0
- package/dist/lib/jsx-roots.d.ts +22 -0
- package/dist/lib/jsx-roots.js +243 -0
- package/dist/lib/module-of-source.d.ts +18 -0
- package/dist/lib/module-of-source.js +24 -0
- package/dist/lib/naming.d.ts +29 -0
- package/dist/lib/naming.js +56 -0
- package/dist/lib/parse-type.d.ts +32 -0
- package/dist/lib/parse-type.js +103 -0
- package/dist/lib/react-spelling.d.ts +68 -0
- package/dist/lib/react-spelling.js +197 -0
- package/dist/lib/scenario-story.d.ts +41 -0
- package/dist/lib/scenario-story.js +84 -0
- package/dist/lib/slot-fill.d.ts +15 -0
- package/dist/lib/slot-fill.js +92 -0
- package/dist/lib/template-files.d.ts +14 -0
- package/dist/lib/template-files.js +25 -0
- package/dist/lib/types.d.ts +741 -0
- package/dist/lib/types.js +13 -0
- package/dist/lib/void-elements.d.ts +7 -0
- package/dist/lib/void-elements.js +13 -0
- package/dist/load.d.ts +37 -0
- package/dist/load.js +82 -0
- package/dist/model.d.ts +44 -0
- package/dist/model.js +464 -0
- package/dist/options.d.ts +224 -0
- package/dist/options.js +223 -0
- package/dist/prop-types.d.ts +26 -0
- package/dist/prop-types.js +102 -0
- package/dist/props-from.d.ts +84 -0
- package/dist/props-from.js +510 -0
- package/dist/protocol.d.ts +541 -0
- package/dist/protocol.js +819 -0
- package/dist/react-view.d.ts +22 -0
- package/dist/react-view.js +36 -0
- package/dist/react.d.ts +17 -0
- package/dist/react.js +23 -0
- package/dist/sass-importers.d.ts +26 -0
- package/dist/sass-importers.js +32 -0
- package/dist/shell-acceptance.d.ts +21 -0
- package/dist/shell-acceptance.js +37 -0
- package/dist/shell-page.d.ts +36 -0
- package/dist/shell-page.js +90 -0
- package/dist/shell-peers.d.ts +38 -0
- package/dist/shell-peers.js +61 -0
- package/dist/shell.d.ts +99 -0
- package/dist/shell.js +52 -0
- package/dist/shells/charcell/page.d.ts +8 -0
- package/dist/shells/charcell/page.js +69 -0
- package/dist/story-source.d.ts +113 -0
- package/dist/story-source.js +271 -0
- package/dist/story.d.ts +5 -0
- package/dist/story.js +28 -0
- package/dist/testing.d.ts +218 -0
- package/dist/testing.js +284 -0
- package/dist/views.d.ts +152 -0
- package/dist/views.js +7 -0
- package/dist/vite-configuration.d.ts +114 -0
- package/dist/vite-configuration.js +578 -0
- package/package.json +123 -3
- package/src/build.ts +51 -0
- package/src/check.ts +1062 -0
- package/src/cli.ts +123 -0
- package/src/context.ts +1168 -0
- package/src/controller/catalog.ts +719 -0
- package/src/controller/create-preview-controller.ts +2683 -0
- package/src/controller/editor-tree.ts +530 -0
- package/src/controller/html-source.ts +114 -0
- package/src/controller/index.ts +105 -0
- package/src/controller/persistence.ts +403 -0
- package/src/controller/regeneration.ts +55 -0
- package/src/controller/source.ts +333 -0
- package/src/controller/store.ts +55 -0
- package/src/development-server.ts +442 -0
- package/src/emit/common.ts +201 -0
- package/src/emit/html-source.ts +402 -0
- package/src/emit/manifest.ts +241 -0
- package/src/emit/react.ts +263 -0
- package/src/emit/scratch.ts +175 -0
- package/src/emit/source.ts +1094 -0
- package/src/emit/svelte.ts +230 -0
- package/src/emit/vue.ts +194 -0
- package/src/enumerate.ts +220 -0
- package/src/generate.ts +443 -0
- package/src/html-stylesheet.ts +173 -0
- package/src/index.ts +60 -0
- package/src/landing.ts +58 -0
- package/src/lib/exported-types.ts +114 -0
- package/src/lib/html-attributes.ts +113 -0
- package/src/lib/html-warnings.ts +81 -0
- package/src/lib/jsx-roots.ts +238 -0
- package/src/lib/module-of-source.ts +26 -0
- package/src/lib/naming.ts +65 -0
- package/src/lib/parse-type.ts +143 -0
- package/src/lib/react-spelling.ts +235 -0
- package/src/lib/scenario-story.ts +97 -0
- package/src/lib/slot-fill.ts +102 -0
- package/src/lib/template-files.ts +31 -0
- package/src/lib/types.ts +778 -0
- package/src/lib/void-elements.ts +15 -0
- package/src/load.ts +144 -0
- package/src/model.ts +568 -0
- package/src/options.ts +435 -0
- package/src/prop-types.ts +133 -0
- package/src/props-from.ts +678 -0
- package/src/protocol.ts +1135 -0
- package/src/react-view.ts +45 -0
- package/src/react.ts +34 -0
- package/src/sass-importers.ts +45 -0
- package/src/shell-acceptance.ts +45 -0
- package/src/shell-page.ts +133 -0
- package/src/shell-peers.ts +70 -0
- package/src/shell.ts +194 -0
- package/src/shells/charcell/page.ts +82 -0
- package/src/story-source.ts +391 -0
- package/src/story.ts +42 -0
- package/src/testing.ts +497 -0
- package/src/views.ts +183 -0
- package/src/vite-configuration.ts +675 -0
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import type { Manifest } from '../emit/manifest.js';
|
|
2
|
+
import type { PreviewBinding, PreviewPaneWidth, PreviewPropType, StoryAround } from '../lib/types.js';
|
|
3
|
+
import type { OptionValue } from '../options.js';
|
|
4
|
+
import { type PreviewScriptedTarget, type PreviewTarget } from '../protocol.js';
|
|
5
|
+
import type { PreviewView, ViewFramework } from '../views.js';
|
|
6
|
+
import { type EditorNode, type EditorState, type SlotPlan } from './editor-tree.js';
|
|
7
|
+
export type { PreviewBinding, PreviewPropType } from '../lib/types.js';
|
|
8
|
+
/** One scenario of a component: a named set of root props, and the option
|
|
9
|
+
* values it shows them under. */
|
|
10
|
+
export interface PreviewScenario {
|
|
11
|
+
id: string;
|
|
12
|
+
/** The picker label. */
|
|
13
|
+
label: string;
|
|
14
|
+
/** What the scenario shows, from the component's story file; markdown allowed.
|
|
15
|
+
* Absent when the story file gives none. */
|
|
16
|
+
description?: string;
|
|
17
|
+
/** The props the scenario lays over the component's defaults. */
|
|
18
|
+
props: Record<string, unknown>;
|
|
19
|
+
/** The option values picking the scenario sets, by option id: the setting
|
|
20
|
+
* it shows the component in, such as a color mode or a surface. Absent
|
|
21
|
+
* when it sets none. */
|
|
22
|
+
options?: Record<string, OptionValue>;
|
|
23
|
+
/** The component's baseline: selected first and shown as the default. */
|
|
24
|
+
default?: boolean;
|
|
25
|
+
/** The preview's own Empty scenario: the story's props with no slot content.
|
|
26
|
+
* Only a component that accepts slot content has one. */
|
|
27
|
+
empty?: boolean;
|
|
28
|
+
/** Generated from one enum value or boolean, listed after the curated ones. */
|
|
29
|
+
generated?: boolean;
|
|
30
|
+
/** The slot content the scenario shows, when its story file gives it
|
|
31
|
+
* content of its own: its fills over the story's, slot by slot. Absent
|
|
32
|
+
* when it shows the story's content. */
|
|
33
|
+
content?: SlotPlan;
|
|
34
|
+
/** The id the panes mount the scenario by, when it has content of its
|
|
35
|
+
* own. The preview's to use: a shell names a scenario by its `id`. */
|
|
36
|
+
story?: string;
|
|
37
|
+
}
|
|
38
|
+
/** A component of the kit, with its stories' data. */
|
|
39
|
+
export interface PreviewComponent {
|
|
40
|
+
/** The story's id, unique across the kit: its title in lower case with
|
|
41
|
+
* every run of other characters a hyphen, `components-layout-card` for
|
|
42
|
+
* `Components/Layout/Card`. The selection, the address (`?component=`) and
|
|
43
|
+
* the testing helpers name the story by it. */
|
|
44
|
+
id: string;
|
|
45
|
+
/** The component's export name, as the editor's tree refers to it. */
|
|
46
|
+
name: string;
|
|
47
|
+
/** What the component is and when to reach for it, from its template's
|
|
48
|
+
* `description`; markdown allowed. Absent when the template gives none. */
|
|
49
|
+
description?: string;
|
|
50
|
+
/** The full title, the source label included: `Components/Layout/Card`. */
|
|
51
|
+
title: string;
|
|
52
|
+
/** The title without its source label: `Layout/Card`. */
|
|
53
|
+
shortTitle: string;
|
|
54
|
+
/** The source the component belongs to (`PreviewSource.id`). */
|
|
55
|
+
source: string;
|
|
56
|
+
/** Whether the component has a story of its own. One that is not (a
|
|
57
|
+
* compound's part, a shared building block) is offered to the editor,
|
|
58
|
+
* not browseable as a story. */
|
|
59
|
+
standalone: boolean;
|
|
60
|
+
/** A story left out of what a reader browses - the navigation, an
|
|
61
|
+
* editor's component picker, the component count - but generated and
|
|
62
|
+
* reachable as any other: by its id, at its address, and through the
|
|
63
|
+
* testing helpers. A shell that lists components leaves these out. */
|
|
64
|
+
unlisted: boolean;
|
|
65
|
+
/** Each prop's control and declaration. */
|
|
66
|
+
propTypes: PreviewPropType[];
|
|
67
|
+
/** The component's events: the props it declares as functions that
|
|
68
|
+
* return nothing, such as `onSelect: (value: string) => void`, which it
|
|
69
|
+
* calls as things happen. A function prop that returns something, such as
|
|
70
|
+
* a `highlight` or a `getPageUrl`, is not one, and is left as given.
|
|
71
|
+
* A story's panes record each call (`state.events`). */
|
|
72
|
+
events: string[];
|
|
73
|
+
/** The component's two-way props, in prop order. A story that gives one
|
|
74
|
+
* takes each value its change prop reports, so a click in any pane
|
|
75
|
+
* changes the story's props (`state.props`), as `actions.setProps`
|
|
76
|
+
* does. A story that leaves it out lets the component keep its own. */
|
|
77
|
+
bindings: PreviewBinding[];
|
|
78
|
+
/** The props the story starts from: the component's declared defaults,
|
|
79
|
+
* with the kit's hints and the story file's `defaultProps` over them. */
|
|
80
|
+
defaultProps: Record<string, unknown>;
|
|
81
|
+
/** The values in `defaultProps` the preview starts from on its own, from
|
|
82
|
+
* the kit's control hints, which neither the component declares nor its
|
|
83
|
+
* story file sets. A consumer's source leaves a prop out while it holds this
|
|
84
|
+
* value and the scenario does not set it. */
|
|
85
|
+
previewDefaults: Record<string, unknown>;
|
|
86
|
+
scenarios: PreviewScenario[];
|
|
87
|
+
/** The slots the component accepts content into, and those among them
|
|
88
|
+
* (`default` for the default slot) whose content must take their scope. */
|
|
89
|
+
slots: {
|
|
90
|
+
default: boolean;
|
|
91
|
+
named: string[];
|
|
92
|
+
scopeRequired?: string[];
|
|
93
|
+
};
|
|
94
|
+
/** The curated slot content a story renders with; the editor seeds its tree from it. */
|
|
95
|
+
content?: SlotPlan;
|
|
96
|
+
/** The content the story renders beside the component, as its siblings:
|
|
97
|
+
* `before` and `after` it. The editor holds it unchanged, outside its root. */
|
|
98
|
+
around?: StoryAround;
|
|
99
|
+
/** Story option defaults, keyed by option id; `false` marks the option unavailable. */
|
|
100
|
+
options?: Record<string, OptionValue | false>;
|
|
101
|
+
/** The targets the component renders in, within the catalog's
|
|
102
|
+
* `targets`. Html is not listed: where the kit builds html, every
|
|
103
|
+
* story has an html pane, which says so when the story has no markup. */
|
|
104
|
+
targets: PreviewScriptedTarget[];
|
|
105
|
+
}
|
|
106
|
+
/** A source: the kit's own components or another package's, in `order`. */
|
|
107
|
+
export interface PreviewSource {
|
|
108
|
+
id: string;
|
|
109
|
+
label: string;
|
|
110
|
+
order: number;
|
|
111
|
+
/** The package the source's components are imported from, as
|
|
112
|
+
* `<moduleBase>/<target>`, or `<moduleBase>` with `{target}` replaced by
|
|
113
|
+
* the target when it names one, when known. */
|
|
114
|
+
moduleBase?: string;
|
|
115
|
+
}
|
|
116
|
+
/** How a consumer imports one of the kit's components. */
|
|
117
|
+
export interface PreviewImport {
|
|
118
|
+
/** The name the component is exported under. */
|
|
119
|
+
exportName: string;
|
|
120
|
+
/** The names it declares that React would otherwise respell (`class`,
|
|
121
|
+
* `style`, an attribute React renames, such as `tabindex`), which React
|
|
122
|
+
* takes as they are; any other attribute a story gives it is spelled as
|
|
123
|
+
* React takes it. Absent when it declares none. */
|
|
124
|
+
declaredAttributes?: string[];
|
|
125
|
+
/** The module it is imported from, per target the kit builds. */
|
|
126
|
+
modules: Partial<Record<PreviewScriptedTarget, string>>;
|
|
127
|
+
/** The type names its module exports, per target, which the module a
|
|
128
|
+
* consumer imports it from exports too: a story's source names a prop's
|
|
129
|
+
* type by one of them. Absent where it exports none. */
|
|
130
|
+
types?: Partial<Record<PreviewScriptedTarget, string[]>>;
|
|
131
|
+
}
|
|
132
|
+
/** A custom view a kit registers, as the catalog lists it. */
|
|
133
|
+
export interface PreviewCatalogView {
|
|
134
|
+
/** The selection id. */
|
|
135
|
+
id: string;
|
|
136
|
+
label: string;
|
|
137
|
+
/** The source whose entries list the view. */
|
|
138
|
+
source: string;
|
|
139
|
+
order: number;
|
|
140
|
+
/** The framework the view mounts with. */
|
|
141
|
+
framework: ViewFramework;
|
|
142
|
+
}
|
|
143
|
+
/** One entry of the navigation tree: a view, a component story, or a group of entries. */
|
|
144
|
+
export type PreviewNavigationNode = {
|
|
145
|
+
kind: 'view';
|
|
146
|
+
id: string;
|
|
147
|
+
label: string;
|
|
148
|
+
} | {
|
|
149
|
+
kind: 'component';
|
|
150
|
+
id: string;
|
|
151
|
+
label: string;
|
|
152
|
+
title: string;
|
|
153
|
+
} | {
|
|
154
|
+
kind: 'group';
|
|
155
|
+
key: string;
|
|
156
|
+
label: string;
|
|
157
|
+
children: PreviewNavigationNode[];
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Everything static about a kit's preview. A controller is created with one
|
|
161
|
+
* and never changes it; a shell renders its navigation and reads its
|
|
162
|
+
* components, views and option vocabulary.
|
|
163
|
+
*/
|
|
164
|
+
export interface PreviewCatalog {
|
|
165
|
+
/** The kit's name. */
|
|
166
|
+
kitName: string;
|
|
167
|
+
/** The kit's package version, when known. */
|
|
168
|
+
kitVersion?: string;
|
|
169
|
+
/** What the kit builds, in order: its targets, then `html` when it
|
|
170
|
+
* builds html. A shell offers a pane and a toggle for these alone. */
|
|
171
|
+
targets: PreviewTarget[];
|
|
172
|
+
/** The sources, in order; the first is the kit's own. */
|
|
173
|
+
sources: PreviewSource[];
|
|
174
|
+
/** Every component, those with no story of their own and unlisted stories included, with its
|
|
175
|
+
* scenarios (the Empty one in place). */
|
|
176
|
+
components: PreviewComponent[];
|
|
177
|
+
/** The custom views, in order. */
|
|
178
|
+
views: PreviewCatalogView[];
|
|
179
|
+
/** The kit's own code block, when it names one: the framework it mounts
|
|
180
|
+
* with. A shell mounts it (`frames.mountCode`) in place of its own code
|
|
181
|
+
* view. */
|
|
182
|
+
codeBlock?: {
|
|
183
|
+
framework: ViewFramework;
|
|
184
|
+
};
|
|
185
|
+
/** The navigation tree: the kit's own source hoisted, other sources grouped. */
|
|
186
|
+
navigation: PreviewNavigationNode[];
|
|
187
|
+
/** The plain HTML tags an editor may offer for a wrapper node. */
|
|
188
|
+
htmlTags: string[];
|
|
189
|
+
/** The color tokens a color control offers; `null` is the unset choice. */
|
|
190
|
+
colorTokens: (string | null)[];
|
|
191
|
+
/** The widths a shell offers to lay the story panes out at, besides
|
|
192
|
+
* fitting them to its own space (`state.paneWidth`), narrowest first:
|
|
193
|
+
* the kit's `paneWidths`, or `DEFAULT_PANE_WIDTHS`. */
|
|
194
|
+
paneWidths: PreviewPaneWidth[];
|
|
195
|
+
/** The entry the preview opens on when its address names none, as the
|
|
196
|
+
* kit names it (`landing`); absent, the first listed story. */
|
|
197
|
+
landing?: PreviewLanding;
|
|
198
|
+
/** The mode the kit builds its Svelte target in (`svelte.mode` in
|
|
199
|
+
* the kit configuration): what a story's Svelte source holds a
|
|
200
|
+
* bound prop's state in, `$state` in runes mode and a plain `let` in
|
|
201
|
+
* legacy mode. */
|
|
202
|
+
svelteMode: 'legacy' | 'runes';
|
|
203
|
+
/** How a consumer imports each of the kit's components, by component name,
|
|
204
|
+
* those with no story of their own included: what a story's source
|
|
205
|
+
* imports. A component missing here is imported by its own name from the
|
|
206
|
+
* first source's `moduleBase`. */
|
|
207
|
+
imports: Record<string, PreviewImport>;
|
|
208
|
+
/** How React spells the HTML attributes it renames (`tabindex` as
|
|
209
|
+
* `tabIndex`, `for` as `htmlFor`), by their HTML names: a story's React
|
|
210
|
+
* source spells the attributes it gives a component with them. */
|
|
211
|
+
reactAttributeNames: Record<string, string>;
|
|
212
|
+
}
|
|
213
|
+
/** The manifest fields `catalogFromManifest` reads. */
|
|
214
|
+
export type CatalogManifest = Pick<Manifest, 'components'> & Partial<Pick<Manifest, 'kitName' | 'kitVersion' | 'targets' | 'sources' | 'colorOptions' | 'labels' | 'imports' | 'codeBlock' | 'paneWidths' | 'landing' | 'svelteMode' | 'reactAttributeNames'>>;
|
|
215
|
+
/** The entry the preview opens on when its address names none: a custom
|
|
216
|
+
* view, or a component's story on one of its scenarios (by id) or, without
|
|
217
|
+
* one, on its baseline. */
|
|
218
|
+
export type PreviewLanding = {
|
|
219
|
+
kind: 'view';
|
|
220
|
+
id: string;
|
|
221
|
+
} | {
|
|
222
|
+
kind: 'component';
|
|
223
|
+
id: string;
|
|
224
|
+
scenario?: string;
|
|
225
|
+
};
|
|
226
|
+
/** The widths a shell offers to lay the story panes out at when the kit
|
|
227
|
+
* names none: a small screen's, a medium one's and a large one's. */
|
|
228
|
+
export declare const DEFAULT_PANE_WIDTHS: readonly PreviewPaneWidth[];
|
|
229
|
+
/**
|
|
230
|
+
* Build a catalog from the generated manifest and the kit's registered views.
|
|
231
|
+
*
|
|
232
|
+
* Components that accept slot content get the Empty scenario ahead of their
|
|
233
|
+
* own, labeled as the manifest says. Each component's `shortTitle` drops its
|
|
234
|
+
* source's label prefix. The navigation lists each source's views and its
|
|
235
|
+
* component tree interleaved by `order`; a source whose views set no
|
|
236
|
+
* component tree lists its components under `Components`, first among the
|
|
237
|
+
* entries of order 0. Components that are not standalone and unlisted stories stay in
|
|
238
|
+
* `components` but out of the navigation. The kit's targets are the manifest's,
|
|
239
|
+
* the three targets when it names none, with `html` only where it names
|
|
240
|
+
* it, and each component's targets are narrowed to the targets among them.
|
|
241
|
+
* The pane widths are the manifest's, narrowest first, or
|
|
242
|
+
* `DEFAULT_PANE_WIDTHS` when it names none, the Svelte mode the
|
|
243
|
+
* manifest's, `legacy` when it names none, and the landing entry the
|
|
244
|
+
* manifest's.
|
|
245
|
+
*
|
|
246
|
+
* @param manifest - The generated manifest.
|
|
247
|
+
* @param views - The kit's registered views (rendered views and component-tree markers).
|
|
248
|
+
* @returns The catalog.
|
|
249
|
+
*/
|
|
250
|
+
export declare function catalogFromManifest(manifest: CatalogManifest, views?: PreviewView[]): PreviewCatalog;
|
|
251
|
+
/** One choice of a scenario picker. */
|
|
252
|
+
export interface ScenarioChoice {
|
|
253
|
+
/** The scenario id; `''` is the anonymous default. */
|
|
254
|
+
value: string;
|
|
255
|
+
label: string;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* The scenario picker's choices for a component: its baseline first, labeled
|
|
259
|
+
* as the default, then the rest. The Empty scenario renders through a
|
|
260
|
+
* regeneration, so it is left out where the preview cannot regenerate, as in
|
|
261
|
+
* a static build. Empty when the component offers no choice beyond its
|
|
262
|
+
* default, so a shell can leave the picker out.
|
|
263
|
+
*
|
|
264
|
+
* @param component - The component.
|
|
265
|
+
* @param capabilities - What the preview can do: the controller's
|
|
266
|
+
* `capabilities`.
|
|
267
|
+
* @returns The choices, or an empty list.
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* const choices = scenarioChoices(component, controller.capabilities);
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
export declare function scenarioChoices(component: PreviewComponent | undefined, capabilities: {
|
|
274
|
+
regeneration: boolean;
|
|
275
|
+
}): ScenarioChoice[];
|
|
276
|
+
/** A story to mount in a detached pane: a component, a scenario and props. */
|
|
277
|
+
export interface PreviewStoryReference {
|
|
278
|
+
/** The component's story id (`PreviewComponent.id`). */
|
|
279
|
+
component: string;
|
|
280
|
+
/** The scenario's id; `''` is the anonymous default. Omitted, the story's
|
|
281
|
+
* starting scenario, as selecting the story picks it. */
|
|
282
|
+
scenario?: string;
|
|
283
|
+
/** Props laid over the scenario's. */
|
|
284
|
+
props?: Record<string, unknown>;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* The key a detached story pane's readiness is reported under in the
|
|
288
|
+
* state's `storyFrames`: the target, the component, then the scenario and
|
|
289
|
+
* the props as given. Two panes of the same story, scenario and props share
|
|
290
|
+
* a key, and it reads `ready` once either has loaded.
|
|
291
|
+
*
|
|
292
|
+
* @param target - The target the pane renders in.
|
|
293
|
+
* @param story - The story, as passed to `frames.mountStory`.
|
|
294
|
+
* @returns The key, such as `react:components-button:ghost`.
|
|
295
|
+
* @example
|
|
296
|
+
* ```ts
|
|
297
|
+
* const ready = state.storyFrames[storyFrameKey('vue', { component: id, scenario: 'ghost' })] === 'ready';
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
export declare function storyFrameKey(target: PreviewScriptedTarget, story: PreviewStoryReference): string;
|
|
301
|
+
/**
|
|
302
|
+
* The scenario a component starts on: its default-flagged one, else `''`,
|
|
303
|
+
* the anonymous default.
|
|
304
|
+
*
|
|
305
|
+
* @param component - The component.
|
|
306
|
+
* @returns The scenario id.
|
|
307
|
+
*/
|
|
308
|
+
export declare function defaultScenarioId(component: PreviewComponent | undefined): string;
|
|
309
|
+
/**
|
|
310
|
+
* The slots a node of the editor's tree holds content in: a component's
|
|
311
|
+
* default slot (when it has one) and then its named slots, as the catalog
|
|
312
|
+
* records them; an HTML tag's default slot; nothing for text or an opaque
|
|
313
|
+
* fill. The tree itself counts as its root component's node.
|
|
314
|
+
*
|
|
315
|
+
* @param catalog - The catalog the node's component is looked up in.
|
|
316
|
+
* @param node - A node of the tree, or the tree itself for its root.
|
|
317
|
+
* @returns The slot names, the default slot first.
|
|
318
|
+
* @example
|
|
319
|
+
* ```ts
|
|
320
|
+
* const tree = controller.getState().editor.tree!;
|
|
321
|
+
* for (const slot of nodeSlots(controller.catalog, tree)) render(slot, tree.slots[slot] ?? []);
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
export declare function nodeSlots(catalog: Pick<PreviewCatalog, 'components'>, node: EditorNode | EditorState): string[];
|
|
325
|
+
/**
|
|
326
|
+
* The slots the editor can add plain content to in a node of its tree: the
|
|
327
|
+
* node's slots ({@link nodeSlots}) without those whose content must take
|
|
328
|
+
* their scope, which take only a scoped fill the editor cannot author. Such a
|
|
329
|
+
* slot still holds and shows the fill a story gives it.
|
|
330
|
+
*
|
|
331
|
+
* @param catalog - The catalog the node's component is looked up in.
|
|
332
|
+
* @param node - A node of the tree, or the tree itself for its root.
|
|
333
|
+
* @returns The slot names, the default slot first.
|
|
334
|
+
* @example
|
|
335
|
+
* ```ts
|
|
336
|
+
* const targets = nodeAddSlots(controller.catalog, controller.getState().editor.tree!);
|
|
337
|
+
* ```
|
|
338
|
+
*/
|
|
339
|
+
export declare function nodeAddSlots(catalog: Pick<PreviewCatalog, 'components'>, node: EditorNode | EditorState): string[];
|