@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,138 @@
|
|
|
1
|
+
import type { ContentSlots, JsonValue, PreviewLabels, PreviewLandingConfiguration, PreviewPaneWidth, PreviewPersistence, SlotPlan, StoryAround, PreviewBinding, ResolvedStory, PreviewPropType, Target } from '../lib/types.js';
|
|
2
|
+
import type { PreviewTarget } from '../protocol.js';
|
|
3
|
+
import type { ViewFramework } from '../views.js';
|
|
4
|
+
export interface ManifestComponent {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
title: string;
|
|
8
|
+
/** What the component is, from its template. Absent when it has none. */
|
|
9
|
+
description?: string;
|
|
10
|
+
category: string;
|
|
11
|
+
/** Each prop's control and its declaration (type as written, whether it is
|
|
12
|
+
* required, the component's own default). */
|
|
13
|
+
propTypes: PreviewPropType[];
|
|
14
|
+
/** The props that are events: functions returning nothing, which the
|
|
15
|
+
* component calls as things happen. Absent when there are none. */
|
|
16
|
+
events?: string[];
|
|
17
|
+
/** The component's two-way props. Absent when there are none. */
|
|
18
|
+
bindings?: PreviewBinding[];
|
|
19
|
+
defaultProps: Record<string, JsonValue>;
|
|
20
|
+
/** The values in `defaultProps` the preview starts from on its own (a kit
|
|
21
|
+
* hint's), which a consumer's source leaves out. Absent when there are none. */
|
|
22
|
+
previewDefaults?: Record<string, JsonValue>;
|
|
23
|
+
scenarios: {
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
/** What the scenario shows, from the story file. Absent when it has none. */
|
|
27
|
+
description?: string;
|
|
28
|
+
props: Record<string, JsonValue>;
|
|
29
|
+
/** The option values picking the scenario sets. Absent when it sets none. */
|
|
30
|
+
options?: Record<string, string | boolean>;
|
|
31
|
+
default?: boolean;
|
|
32
|
+
generated?: boolean;
|
|
33
|
+
/** The slot content the scenario shows, when it has content of its own:
|
|
34
|
+
* its fills over the story's. Absent when it shows the story's. */
|
|
35
|
+
content?: SlotPlan;
|
|
36
|
+
/** The id the panes mount the scenario's story by, when it has content
|
|
37
|
+
* of its own. Absent when the panes mount the component's story. */
|
|
38
|
+
story?: string;
|
|
39
|
+
}[];
|
|
40
|
+
/** The slots this component accepts - the editor's add-content targets. */
|
|
41
|
+
slots: ContentSlots;
|
|
42
|
+
/** `false` for a component with no story of its own: present for the
|
|
43
|
+
* editor's picker, hidden from the story navigation (see
|
|
44
|
+
* Story.standalone). Absent ⇒ a normal browseable story. */
|
|
45
|
+
standalone?: boolean;
|
|
46
|
+
/** A story reachable at its address but left out of the navigation, the
|
|
47
|
+
* editor's picker and the counts (see Story.unlisted). Absent ⇒ listed. */
|
|
48
|
+
unlisted?: boolean;
|
|
49
|
+
/** The story file's curated slot content, so the per-story editor seeds its tree
|
|
50
|
+
* from what the browse view already renders. Absent
|
|
51
|
+
* when the component has no story file slot plan. */
|
|
52
|
+
content?: SlotPlan;
|
|
53
|
+
/** The content the story renders beside the component (see Story.around).
|
|
54
|
+
* Absent when it has none. */
|
|
55
|
+
around?: StoryAround;
|
|
56
|
+
/** Per-story preview-option defaults / availability (see Story.options). Absent
|
|
57
|
+
* when the component curates none. */
|
|
58
|
+
options?: Record<string, JsonValue | false>;
|
|
59
|
+
/** The preview source this component belongs to (`ManifestSource.id`). The host groups
|
|
60
|
+
* the navigation by source; core components are `'core'`. */
|
|
61
|
+
source: string;
|
|
62
|
+
/** The targets this component renders into, within the kit's own. The host shows
|
|
63
|
+
* a pane + toggle per kit target and disables the rest; a React-only fixture of
|
|
64
|
+
* another package's components lists just `react`. */
|
|
65
|
+
targets: Target[];
|
|
66
|
+
}
|
|
67
|
+
/** A navigation source - the kit's own components or another package's. The host renders one
|
|
68
|
+
* collapsible section per source, in `order`, its `label` the heading. */
|
|
69
|
+
export interface ManifestSource {
|
|
70
|
+
id: string;
|
|
71
|
+
label: string;
|
|
72
|
+
order: number;
|
|
73
|
+
/** The package the source's components import from, per target
|
|
74
|
+
* `<moduleBase>/<target>`, or `<moduleBase>` with `{target}` replaced by
|
|
75
|
+
* the target when it names one. */
|
|
76
|
+
moduleBase?: string;
|
|
77
|
+
}
|
|
78
|
+
/** How a consumer imports one of the kit's components. */
|
|
79
|
+
export interface ManifestImport {
|
|
80
|
+
/** The name the component is exported under. */
|
|
81
|
+
exportName: string;
|
|
82
|
+
/** The names it declares that React would otherwise respell (`class`,
|
|
83
|
+
* `style`, an attribute React renames, such as `tabindex`), which React
|
|
84
|
+
* takes as they are; any other attribute a story gives it is spelled as
|
|
85
|
+
* React takes it. Absent when it declares none. */
|
|
86
|
+
declaredAttributes?: string[];
|
|
87
|
+
/** The module it is imported from, per target the kit builds. */
|
|
88
|
+
modules: Partial<Record<Target, string>>;
|
|
89
|
+
/** The type names its module exports, per target the kit builds, which
|
|
90
|
+
* the module a consumer imports it from exports too. Absent where it
|
|
91
|
+
* exports none. */
|
|
92
|
+
types?: Partial<Record<Target, string[]>>;
|
|
93
|
+
}
|
|
94
|
+
export interface Manifest {
|
|
95
|
+
/** The kit's name (the kit configuration's `name`) - the host's kit selector. */
|
|
96
|
+
kitName: string;
|
|
97
|
+
/** The kit's version (its package.json `version`) - the host's version label. */
|
|
98
|
+
kitVersion?: string;
|
|
99
|
+
colorOptions: (string | null)[];
|
|
100
|
+
/** What the kit builds that the host offers a pane for, and for these
|
|
101
|
+
* alone: its targets, and `html` when it builds html. */
|
|
102
|
+
targets: PreviewTarget[];
|
|
103
|
+
/** The sources, for the navigation's per-source sections (ordered by the host). */
|
|
104
|
+
sources: ManifestSource[];
|
|
105
|
+
/** The kit's own code block, when it names one: the framework it mounts
|
|
106
|
+
* with. A shell mounts it in place of its own code view. */
|
|
107
|
+
codeBlock?: {
|
|
108
|
+
framework: ViewFramework;
|
|
109
|
+
};
|
|
110
|
+
components: ManifestComponent[];
|
|
111
|
+
/** How a consumer imports each of the kit's components, by name: every
|
|
112
|
+
* component, those with no story of their own included, so a story's
|
|
113
|
+
* source can import what its slot content names. */
|
|
114
|
+
imports?: Record<string, ManifestImport>;
|
|
115
|
+
/** The host's own copy (the synthetic empty scenario's label), in the kit's casing. */
|
|
116
|
+
labels: {
|
|
117
|
+
emptyScenario: string;
|
|
118
|
+
};
|
|
119
|
+
/** Where the host remembers what a person chose (`preview.persistence`).
|
|
120
|
+
* Absent means `'url'`. */
|
|
121
|
+
persistence?: PreviewPersistence;
|
|
122
|
+
/** The widths a shell offers to lay the story panes out at
|
|
123
|
+
* (the configuration module's `previewPaneWidths`). Absent means the preview's own. */
|
|
124
|
+
paneWidths?: PreviewPaneWidth[];
|
|
125
|
+
/** The mode the kit builds its Svelte target in (`svelte.mode`), which a
|
|
126
|
+
* story's Svelte source follows. Absent means `legacy`. */
|
|
127
|
+
svelteMode?: 'legacy' | 'runes';
|
|
128
|
+
/** The entry the host opens on when its address names none
|
|
129
|
+
* (`preview.landing`). Absent means the first listed story. */
|
|
130
|
+
landing?: PreviewLandingConfiguration;
|
|
131
|
+
/** How React spells the HTML attributes it renames (`tabindex` as
|
|
132
|
+
* `tabIndex`), by their HTML names, which a story's React source spells
|
|
133
|
+
* a component's attributes with. */
|
|
134
|
+
reactAttributeNames?: Record<string, string>;
|
|
135
|
+
}
|
|
136
|
+
export declare function buildManifest(models: ResolvedStory[], sources: ManifestSource[], colorTokens?: (string | null | undefined)[], kitName?: string, labels?: PreviewLabels, kitVersion?: string, persistence?: PreviewPersistence, targets?: PreviewTarget[], imports?: Record<string, ManifestImport>, codeBlock?: {
|
|
137
|
+
framework: ViewFramework;
|
|
138
|
+
}, paneWidths?: PreviewPaneWidth[], svelteMode?: 'legacy' | 'runes', reactAttributeNames?: Readonly<Record<string, string>>, landing?: PreviewLandingConfiguration): Manifest;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { JsonValue, SlotFill, StoryAround, Target } from '../lib/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A two-way prop the story gives, which the printed source binds to state of
|
|
4
|
+
* its own so the component's changes come back: React holds it in `useState`
|
|
5
|
+
* and passes the setter as `changeProp`, Vue binds it with `v-model` (bare
|
|
6
|
+
* with `vueModel`) or `v-model:<prop>`, and Svelte with `bind:<prop>`.
|
|
7
|
+
*/
|
|
8
|
+
export interface SourceBinding {
|
|
9
|
+
/** The two-way prop. */
|
|
10
|
+
prop: string;
|
|
11
|
+
/** The event prop called with each new value. Without one, React prints
|
|
12
|
+
* the prop's value alone, as it has no way to hear a change. */
|
|
13
|
+
changeProp?: string;
|
|
14
|
+
/** The prop the component's own value starts from when the two-way prop
|
|
15
|
+
* is not given, which the source leaves out while it gives the prop. */
|
|
16
|
+
defaultProp?: string;
|
|
17
|
+
/** Whether a Vue consumer binds the prop with a bare `v-model`. */
|
|
18
|
+
vueModel?: boolean;
|
|
19
|
+
/** The prop's type as the component declares it, which types the state
|
|
20
|
+
* where the value alone would read narrower. */
|
|
21
|
+
declaredType?: string;
|
|
22
|
+
/** Whether the component takes type parameters, so its prop's type is
|
|
23
|
+
* the consumer's to infer rather than to name. */
|
|
24
|
+
generic?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** A story resolved for printing: its root component, props and slot content. */
|
|
27
|
+
export interface SourceStory {
|
|
28
|
+
/** The root component's local name (its export name). */
|
|
29
|
+
component: string;
|
|
30
|
+
/** The props to print, already merged and filtered. */
|
|
31
|
+
props: Record<string, JsonValue>;
|
|
32
|
+
/** Default-slot content. */
|
|
33
|
+
children?: SlotFill;
|
|
34
|
+
/** Named-slot content, keyed by slot name. */
|
|
35
|
+
named: Record<string, SlotFill>;
|
|
36
|
+
/** The content beside the component, printed as its siblings: React holds
|
|
37
|
+
* them in a fragment, Vue's template and Svelte's markup list them. */
|
|
38
|
+
around?: StoryAround;
|
|
39
|
+
/** Import lines' modules per local component name, and the names the
|
|
40
|
+
* component declares that React would otherwise respell
|
|
41
|
+
* (`declaredAttributes`: `class`, `style`, an attribute React renames),
|
|
42
|
+
* which React takes as they are. */
|
|
43
|
+
imports: Map<string, {
|
|
44
|
+
module: string;
|
|
45
|
+
exported: string;
|
|
46
|
+
declaredAttributes?: string[];
|
|
47
|
+
}>;
|
|
48
|
+
/** The root component's two-way props, those given in `props` bound to
|
|
49
|
+
* state of the source's own. */
|
|
50
|
+
bindings?: SourceBinding[];
|
|
51
|
+
/** The mode the kit builds its Svelte target in, which the state a bound
|
|
52
|
+
* prop is held in follows: `$state` in runes mode, a plain `let` in
|
|
53
|
+
* legacy mode (the default). */
|
|
54
|
+
svelteMode?: 'legacy' | 'runes';
|
|
55
|
+
/** How React spells the HTML attributes it renames (`tabindex` as
|
|
56
|
+
* `tabIndex`), by their HTML names. A story spells a component's
|
|
57
|
+
* attributes as HTML does; React's source takes `class` as `className`,
|
|
58
|
+
* a `style` string as a style object and these by their React names,
|
|
59
|
+
* unless the component declares a prop by that name. Without it, only
|
|
60
|
+
* `class` and `style` are respelled. */
|
|
61
|
+
reactAttributeNames?: Readonly<Record<string, string>>;
|
|
62
|
+
/** The type names the kit's package entries export, each with the module
|
|
63
|
+
* it is imported from for this target: a bound prop's state is typed by
|
|
64
|
+
* its declared type where it names these and the language's own types
|
|
65
|
+
* alone, importing them. */
|
|
66
|
+
exportedTypes?: ReadonlyMap<string, string>;
|
|
67
|
+
}
|
|
68
|
+
/** The story as a React component module, the attributes it gives a
|
|
69
|
+
* component spelled as React takes them (see `reactAttributeNames`). */
|
|
70
|
+
export declare function reactSource(given: SourceStory): string;
|
|
71
|
+
/** The story as a Vue single-file component. */
|
|
72
|
+
export declare function vueSource(given: SourceStory): string;
|
|
73
|
+
/** The story as a Svelte component. */
|
|
74
|
+
export declare function svelteSource(given: SourceStory): string;
|
|
75
|
+
/**
|
|
76
|
+
* A story's props in the order the component declares them, so the source
|
|
77
|
+
* prints them alike however they were gathered (the template's defaults, the
|
|
78
|
+
* story file's, a scenario's); a prop the component does not declare follows,
|
|
79
|
+
* in the order given.
|
|
80
|
+
*
|
|
81
|
+
* @param props - The props to print.
|
|
82
|
+
* @param declared - The component's prop names, in declaration order.
|
|
83
|
+
* @returns The same props, reordered.
|
|
84
|
+
*/
|
|
85
|
+
export declare function inDeclarationOrder(props: Record<string, JsonValue>, declared: readonly string[]): Record<string, JsonValue>;
|
|
86
|
+
/** The printer per target. */
|
|
87
|
+
export declare const SOURCE_PRINTERS: Record<Target, (story: SourceStory) => string>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A React body as one JSX expression: JSX content that is not one already in
|
|
3
|
+
* a fragment, anything else as given.
|
|
4
|
+
*
|
|
5
|
+
* Content opening with a tag goes in a fragment when it has two or more root
|
|
6
|
+
* nodes. Content opening with anything an expression cannot open with - a
|
|
7
|
+
* `{name}` placeholder, punctuation - is text, and goes in one too. Content
|
|
8
|
+
* opening as an expression can (a word, a number, a bracket, a quote) is an
|
|
9
|
+
* expression (`row.name`, `open && <Badge />`) unless it reads as text: two
|
|
10
|
+
* words side by side (`4 messages`), or a word followed by a placeholder or a
|
|
11
|
+
* tag (`hello {name}`, `remove <Button />`). A body the scanner cannot read
|
|
12
|
+
* through is left as given.
|
|
13
|
+
*
|
|
14
|
+
* @param body - The React body, as the fill gives it.
|
|
15
|
+
* @returns The body, in `<>...</>` when it is not one JSX expression.
|
|
16
|
+
* @example
|
|
17
|
+
* singleJsxRoot('<Button label="keep" /><Button label="empty" />');
|
|
18
|
+
* // '<><Button label="keep" /><Button label="empty" /></>'
|
|
19
|
+
* singleJsxRoot('{name}');
|
|
20
|
+
* // '<>{name}</>'
|
|
21
|
+
*/
|
|
22
|
+
export declare function singleJsxRoot(body: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The token a source's `moduleBase` names its target with. */
|
|
2
|
+
export declare const TARGET_TOKEN = "{target}";
|
|
3
|
+
/**
|
|
4
|
+
* The module a source's components are imported from for one target: the
|
|
5
|
+
* source's `moduleBase` with `{target}` replaced by the target, or, when it
|
|
6
|
+
* has no `{target}`, the target as a subpath of it.
|
|
7
|
+
*
|
|
8
|
+
* @param moduleBase - The source's `moduleBase`.
|
|
9
|
+
* @param target - The target, such as `'react'`.
|
|
10
|
+
* @returns The module specifier.
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* moduleOfSource('my-ui-kit', 'react'); // 'my-ui-kit/react'
|
|
14
|
+
* moduleOfSource('@acme/{target}', 'react'); // '@acme/react'
|
|
15
|
+
* moduleOfSource('acme-{target}', 'vue'); // 'acme-vue'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function moduleOfSource(moduleBase: string, target: string): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare function sanitize(value: string): string;
|
|
2
|
+
/** The id of the preview's own Empty scenario, which renders a component
|
|
3
|
+
* with its slots empty: no scenario of a story's takes it. */
|
|
4
|
+
export declare const EMPTY_SCENARIO_ID = "empty";
|
|
5
|
+
/**
|
|
6
|
+
* The id a pane mounts the story of one scenario by, when the scenario has
|
|
7
|
+
* slot content of its own: the component's id and the scenario's, with two
|
|
8
|
+
* hyphens between, which no component id holds.
|
|
9
|
+
*
|
|
10
|
+
* @param componentId - The component's story id.
|
|
11
|
+
* @param scenarioId - The scenario's id.
|
|
12
|
+
* @returns The scenario story's id.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* scenarioStoryId('components-notice', 'warning'); // 'components-notice--warning'
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function scenarioStoryId(componentId: string, scenarioId: string): string;
|
|
19
|
+
export declare function storyId(title: string, exportName: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* The name a kit's build gives a template without a component node, from its
|
|
22
|
+
* file: the stem's alphanumeric runs in PascalCase, `_` before a leading
|
|
23
|
+
* digit, `Component` when nothing is left (`theme-toggle.ts` → `ThemeToggle`,
|
|
24
|
+
* `2up.grid.ts` → `_2upGrid`). A copy of `componentNameFromFilePath` in
|
|
25
|
+
* scaffold-ui-kit's `template-sources.ts`, the source of truth, which this
|
|
26
|
+
* package cannot import; the two must agree, since the name namespaces the
|
|
27
|
+
* `data-jte-node` markers the kit's stylesheet selects.
|
|
28
|
+
*/
|
|
29
|
+
export declare function componentNameFromFile(file: string): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { SlotFill } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* A plain-CSS `style` string's declarations, split at each `;` outside a
|
|
4
|
+
* quoted string and outside parentheses, so a `url("data:...;base64,...")`
|
|
5
|
+
* stays whole.
|
|
6
|
+
*
|
|
7
|
+
* @param css - The declarations as a `style` attribute holds them.
|
|
8
|
+
* @returns Each declaration's text, as written.
|
|
9
|
+
*/
|
|
10
|
+
export declare function styleDeclarations(css: string): string[];
|
|
11
|
+
/**
|
|
12
|
+
* A plain-CSS `style` string as the properties of a React style object:
|
|
13
|
+
* each property camel-cased (a vendor prefix capitalized, `-ms-` as `ms`), a
|
|
14
|
+
* custom property (`--gap`) kept as written. A `;` inside a quoted string or
|
|
15
|
+
* parentheses stays in its value. A React style object has no
|
|
16
|
+
* `!important`, so a value marked with it is kept without the mark: the
|
|
17
|
+
* browser would drop the whole declaration otherwise.
|
|
18
|
+
*
|
|
19
|
+
* @param css - The declarations, `;`-separated.
|
|
20
|
+
* @returns The style object's properties, in their order.
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* styleProperties('padding-inline: 1ch; --gap: 2px'); // { paddingInline: '1ch', '--gap': '2px' }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function styleProperties(css: string): Record<string, string>;
|
|
27
|
+
/**
|
|
28
|
+
* A component's props as React takes them: `class` as `className`, a
|
|
29
|
+
* `style` string as a style object, and each attribute React renames by its
|
|
30
|
+
* React name, unless the component declares a prop by that exact name, which
|
|
31
|
+
* it takes as it is. Any other prop passes unchanged. A story that gives both
|
|
32
|
+
* `class` and `className` gets the two joined, in their order.
|
|
33
|
+
*
|
|
34
|
+
* @param props - The props, as the story gives them.
|
|
35
|
+
* @param declares - Whether the component declares a prop of a name.
|
|
36
|
+
* @param attributeNames - The React name of each attribute React renames,
|
|
37
|
+
* by its HTML name.
|
|
38
|
+
* @returns The props, spelled as React takes them, in their order.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* reactProps({ class: 'w-48', tabindex: 0 }, () => false, { tabindex: 'tabIndex' });
|
|
42
|
+
* // { className: 'w-48', tabIndex: 0 }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function reactProps<Value>(props: Record<string, Value>, declares: (name: string) => boolean, attributeNames: Readonly<Record<string, string>>): Record<string, Value | Record<string, string> | string>;
|
|
46
|
+
/**
|
|
47
|
+
* A slot fill as React takes it: each component's props in it spelled by
|
|
48
|
+
* {@link reactProps}, and each attribute of an html element React renames by
|
|
49
|
+
* its React name (`for` as `htmlFor`). An html element's `class` and `style`
|
|
50
|
+
* stay as written, which the React emitters spell themselves, and opaque
|
|
51
|
+
* bodies stay as they are.
|
|
52
|
+
*
|
|
53
|
+
* @param fill - The fill.
|
|
54
|
+
* @param declares - Whether a component declares a prop of a name.
|
|
55
|
+
* @param attributeNames - The React name of each attribute React renames.
|
|
56
|
+
* @returns The fill, every component's attributes spelled as React takes them.
|
|
57
|
+
*/
|
|
58
|
+
export declare function reactFill<Fill extends SlotFill | undefined>(fill: Fill, declares: (component: string, name: string) => boolean, attributeNames: Readonly<Record<string, string>>): Fill;
|
|
59
|
+
/**
|
|
60
|
+
* The names a component declares that {@link reactProps} would otherwise
|
|
61
|
+
* respell: `class`, `style` and the attributes React renames. A component
|
|
62
|
+
* keeps these as they are in React.
|
|
63
|
+
*
|
|
64
|
+
* @param declared - The component's declared prop names.
|
|
65
|
+
* @param attributeNames - The React name of each attribute React renames.
|
|
66
|
+
* @returns Those of `declared` React would otherwise respell.
|
|
67
|
+
*/
|
|
68
|
+
export declare function declaredAttributes(declared: Iterable<string>, attributeNames: Readonly<Record<string, string>>): string[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ResolvedStory, Scenario, SlotPlan } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The slot plan one scenario of a story shows: the scenario's own fills over
|
|
4
|
+
* the story's, slot by slot. A scenario with no slots of its own shows the
|
|
5
|
+
* story's plan.
|
|
6
|
+
*
|
|
7
|
+
* @param story - The story's plan, if it has one.
|
|
8
|
+
* @param scenario - The scenario's own plan, if it has one.
|
|
9
|
+
* @returns The plan the scenario shows, or `undefined` when neither has one.
|
|
10
|
+
*/
|
|
11
|
+
export declare function scenarioSlotPlan(story: SlotPlan | undefined, scenario: SlotPlan | undefined): SlotPlan | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* A resolved story as one of its scenarios shows it: with the scenario's
|
|
14
|
+
* slot plan over the story's. A scenario with no slots of its own, or no
|
|
15
|
+
* scenario, shows the story as it is.
|
|
16
|
+
*
|
|
17
|
+
* @param model - The component's resolved story.
|
|
18
|
+
* @param scenario - The scenario, when one is meant.
|
|
19
|
+
* @returns The story to print or render for that scenario.
|
|
20
|
+
*/
|
|
21
|
+
export declare function storyOnScenario(model: ResolvedStory, scenario: Scenario | undefined): ResolvedStory;
|
|
22
|
+
/**
|
|
23
|
+
* The stories of a component's scenarios that have slot content of their
|
|
24
|
+
* own: one per such scenario, the component's story with the scenario's
|
|
25
|
+
* plan, under the id the panes mount it by. The panes render a story's slot
|
|
26
|
+
* content as it was generated, so a scenario that changes it is a story
|
|
27
|
+
* beside the component's.
|
|
28
|
+
*
|
|
29
|
+
* @param model - The component's resolved story.
|
|
30
|
+
* @returns The scenario stories, in the scenarios' order; none for a
|
|
31
|
+
* component whose scenarios set props alone.
|
|
32
|
+
*/
|
|
33
|
+
export declare function scenarioStories(model: ResolvedStory): ResolvedStory[];
|
|
34
|
+
/**
|
|
35
|
+
* The id a pane mounts a resolved story by: a scenario story's own, or the
|
|
36
|
+
* one derived from the title.
|
|
37
|
+
*
|
|
38
|
+
* @param model - The resolved story.
|
|
39
|
+
* @returns Its id in every target's registry.
|
|
40
|
+
*/
|
|
41
|
+
export declare function storyRegistryId(model: ResolvedStory): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PartFill, SlotFill } from './types.js';
|
|
2
|
+
/** Adds every component name a fill tree references to `into`: each `element`'s
|
|
3
|
+
* component, and the declared `imports` of an opaque `raw` or `scoped` body
|
|
4
|
+
* or a part's, unless `parts` is false. */
|
|
5
|
+
export declare function collectSlotComponents(fill: SlotFill | undefined, into: Set<string>, parts?: boolean): void;
|
|
6
|
+
/**
|
|
7
|
+
* The parts a story's slot content calls, by name, in the order first called.
|
|
8
|
+
* A part is called in the content's tree; a call inside a body is the body's
|
|
9
|
+
* own markup and declares nothing.
|
|
10
|
+
*
|
|
11
|
+
* @param fills - The story's slot fills: its default slot and named slots.
|
|
12
|
+
* @returns Each part's call, carrying its declaration.
|
|
13
|
+
* @throws When two calls of one name declare different parts.
|
|
14
|
+
*/
|
|
15
|
+
export declare function collectParts(fills: Iterable<SlotFill | undefined>): Map<string, PartFill>;
|