forgebook 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 +21 -0
- package/README.md +136 -2
- package/dist/bin/forgebook/catalogueVite.d.ts +16 -0
- package/dist/bin/forgebook/catalogueVite.d.ts.map +1 -0
- package/dist/bin/forgebook/catalogueVite.js +15 -0
- package/dist/bin/forgebook/catalogueVite.js.map +1 -0
- package/dist/bin/forgebook/forgebook.d.mts +3 -0
- package/dist/bin/forgebook/forgebook.d.mts.map +1 -0
- package/dist/bin/forgebook/forgebook.mjs +93 -0
- package/dist/bin/forgebook/forgebook.mjs.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts +90 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.js +1 -0
- package/dist/bin/forgebook-docs/catalogueDocs.types.js.map +1 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts +9 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.js +132 -0
- package/dist/bin/forgebook-docs/catalogueMarkdown.js.map +1 -0
- package/dist/bin/forgebook-docs/collectDocs.d.ts +17 -0
- package/dist/bin/forgebook-docs/collectDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/collectDocs.js +115 -0
- package/dist/bin/forgebook-docs/collectDocs.js.map +1 -0
- package/dist/bin/forgebook-docs/forgebook-docs.d.mts +3 -0
- package/dist/bin/forgebook-docs/forgebook-docs.d.mts.map +1 -0
- package/dist/bin/forgebook-docs/forgebook-docs.mjs +115 -0
- package/dist/bin/forgebook-docs/forgebook-docs.mjs.map +1 -0
- package/dist/bin/forgebook-docs/moduleDocs.d.ts +9 -0
- package/dist/bin/forgebook-docs/moduleDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/moduleDocs.js +62 -0
- package/dist/bin/forgebook-docs/moduleDocs.js.map +1 -0
- package/dist/bin/forgebook-docs/sassDocs.d.ts +20 -0
- package/dist/bin/forgebook-docs/sassDocs.d.ts.map +1 -0
- package/dist/bin/forgebook-docs/sassDocs.js +77 -0
- package/dist/bin/forgebook-docs/sassDocs.js.map +1 -0
- package/dist/bin/forgebook-texts/forgebook-texts.d.mts +3 -0
- package/dist/bin/forgebook-texts/forgebook-texts.d.mts.map +1 -0
- package/dist/bin/forgebook-texts/forgebook-texts.mjs +94 -0
- package/dist/bin/forgebook-texts/forgebook-texts.mjs.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.d.ts +26 -0
- package/dist/bin/forgebook-texts/storyTextsReport.d.ts.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.js +35 -0
- package/dist/bin/forgebook-texts/storyTextsReport.js.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts +25 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.d.ts.map +1 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.js +7 -0
- package/dist/bin/forgebook-texts/storyTextsReport.types.js.map +1 -0
- package/dist/src/a11y.d.ts +28 -0
- package/dist/src/a11y.d.ts.map +1 -0
- package/dist/src/a11y.js +29 -0
- package/dist/src/a11y.js.map +1 -0
- package/dist/src/argTypes.d.ts +114 -0
- package/dist/src/argTypes.d.ts.map +1 -0
- package/dist/src/argTypes.js +254 -0
- package/dist/src/argTypes.js.map +1 -0
- package/dist/src/backdrops.d.ts +88 -0
- package/dist/src/backdrops.d.ts.map +1 -0
- package/dist/src/backdrops.js +202 -0
- package/dist/src/backdrops.js.map +1 -0
- package/dist/src/catalogue.d.ts +120 -0
- package/dist/src/catalogue.d.ts.map +1 -0
- package/dist/src/catalogue.js +80 -0
- package/dist/src/catalogue.js.map +1 -0
- package/dist/src/componentDocs.d.ts +98 -0
- package/dist/src/componentDocs.d.ts.map +1 -0
- package/dist/src/componentDocs.js +47 -0
- package/dist/src/componentDocs.js.map +1 -0
- package/dist/src/frame/checkStory.d.ts +20 -0
- package/dist/src/frame/checkStory.d.ts.map +1 -0
- package/dist/src/frame/checkStory.js +31 -0
- package/dist/src/frame/checkStory.js.map +1 -0
- package/dist/src/frame/frame.css +51 -0
- package/dist/src/frame/frameClock.d.ts +53 -0
- package/dist/src/frame/frameClock.d.ts.map +1 -0
- package/dist/src/frame/frameClock.js +80 -0
- package/dist/src/frame/frameClock.js.map +1 -0
- package/dist/src/frame/frameStatus.d.ts +8 -0
- package/dist/src/frame/frameStatus.d.ts.map +1 -0
- package/dist/src/frame/frameStatus.js +8 -0
- package/dist/src/frame/frameStatus.js.map +1 -0
- package/dist/src/frame/frameView.d.ts +33 -0
- package/dist/src/frame/frameView.d.ts.map +1 -0
- package/dist/src/frame/frameView.js +134 -0
- package/dist/src/frame/frameView.js.map +1 -0
- package/dist/src/frame/matrixLayout.d.ts +36 -0
- package/dist/src/frame/matrixLayout.d.ts.map +1 -0
- package/dist/src/frame/matrixLayout.js +87 -0
- package/dist/src/frame/matrixLayout.js.map +1 -0
- package/dist/src/frame/measureTools.d.ts +24 -0
- package/dist/src/frame/measureTools.d.ts.map +1 -0
- package/dist/src/frame/measureTools.js +141 -0
- package/dist/src/frame/measureTools.js.map +1 -0
- package/dist/src/frame/mountFrame.d.ts +47 -0
- package/dist/src/frame/mountFrame.d.ts.map +1 -0
- package/dist/src/frame/mountFrame.js +229 -0
- package/dist/src/frame/mountFrame.js.map +1 -0
- package/dist/src/frame/playStory.d.ts +40 -0
- package/dist/src/frame/playStory.d.ts.map +1 -0
- package/dist/src/frame/playStory.js +55 -0
- package/dist/src/frame/playStory.js.map +1 -0
- package/dist/src/frame/renderer.d.ts +85 -0
- package/dist/src/frame/renderer.d.ts.map +1 -0
- package/dist/src/frame/renderer.js +18 -0
- package/dist/src/frame/renderer.js.map +1 -0
- package/dist/src/frame/settle.d.ts +24 -0
- package/dist/src/frame/settle.d.ts.map +1 -0
- package/dist/src/frame/settle.js +25 -0
- package/dist/src/frame/settle.js.map +1 -0
- package/dist/src/frame/staleModule.d.ts +40 -0
- package/dist/src/frame/staleModule.d.ts.map +1 -0
- package/dist/src/frame/staleModule.js +74 -0
- package/dist/src/frame/staleModule.js.map +1 -0
- package/dist/src/frame/storyCanvas.d.ts +21 -0
- package/dist/src/frame/storyCanvas.d.ts.map +1 -0
- package/dist/src/frame/storyCanvas.js +30 -0
- package/dist/src/frame/storyCanvas.js.map +1 -0
- package/dist/src/frame/storyHooks.d.ts +31 -0
- package/dist/src/frame/storyHooks.d.ts.map +1 -0
- package/dist/src/frame/storyHooks.js +59 -0
- package/dist/src/frame/storyHooks.js.map +1 -0
- package/dist/src/frame/storyModule.d.ts +104 -0
- package/dist/src/frame/storyModule.d.ts.map +1 -0
- package/dist/src/frame/storyModule.js +205 -0
- package/dist/src/frame/storyModule.js.map +1 -0
- package/dist/src/frame/storyRun.d.ts +96 -0
- package/dist/src/frame/storyRun.d.ts.map +1 -0
- package/dist/src/frame/storyRun.js +318 -0
- package/dist/src/frame/storyRun.js.map +1 -0
- package/dist/src/languages.d.ts +15 -0
- package/dist/src/languages.d.ts.map +1 -0
- package/dist/src/languages.js +8 -0
- package/dist/src/languages.js.map +1 -0
- package/dist/src/matrix.d.ts +56 -0
- package/dist/src/matrix.d.ts.map +1 -0
- package/dist/src/matrix.js +61 -0
- package/dist/src/matrix.js.map +1 -0
- package/dist/src/messages.d.ts +203 -0
- package/dist/src/messages.d.ts.map +1 -0
- package/dist/src/messages.js +193 -0
- package/dist/src/messages.js.map +1 -0
- package/dist/src/namedValues.d.ts +38 -0
- package/dist/src/namedValues.d.ts.map +1 -0
- package/dist/src/namedValues.js +48 -0
- package/dist/src/namedValues.js.map +1 -0
- package/dist/src/pageConfig.d.ts +23 -0
- package/dist/src/pageConfig.d.ts.map +1 -0
- package/dist/src/pageConfig.js +1 -0
- package/dist/src/pageConfig.js.map +1 -0
- package/dist/src/playTrace.d.ts +41 -0
- package/dist/src/playTrace.d.ts.map +1 -0
- package/dist/src/playTrace.js +35 -0
- package/dist/src/playTrace.js.map +1 -0
- package/dist/src/shell/A11yTab.d.ts +44 -0
- package/dist/src/shell/A11yTab.d.ts.map +1 -0
- package/dist/src/shell/A11yTab.js +30 -0
- package/dist/src/shell/A11yTab.js.map +1 -0
- package/dist/src/shell/ApiReference.d.ts +18 -0
- package/dist/src/shell/ApiReference.d.ts.map +1 -0
- package/dist/src/shell/ApiReference.js +41 -0
- package/dist/src/shell/ApiReference.js.map +1 -0
- package/dist/src/shell/ClockControls.d.ts +43 -0
- package/dist/src/shell/ClockControls.d.ts.map +1 -0
- package/dist/src/shell/ClockControls.js +53 -0
- package/dist/src/shell/ClockControls.js.map +1 -0
- package/dist/src/shell/Code.d.ts +16 -0
- package/dist/src/shell/Code.d.ts.map +1 -0
- package/dist/src/shell/Code.js +9 -0
- package/dist/src/shell/Code.js.map +1 -0
- package/dist/src/shell/CodeTab.d.ts +17 -0
- package/dist/src/shell/CodeTab.d.ts.map +1 -0
- package/dist/src/shell/CodeTab.js +17 -0
- package/dist/src/shell/CodeTab.js.map +1 -0
- package/dist/src/shell/CodeText.d.ts +16 -0
- package/dist/src/shell/CodeText.d.ts.map +1 -0
- package/dist/src/shell/CodeText.js +10 -0
- package/dist/src/shell/CodeText.js.map +1 -0
- package/dist/src/shell/ComponentPage.d.ts +38 -0
- package/dist/src/shell/ComponentPage.d.ts.map +1 -0
- package/dist/src/shell/ComponentPage.js +146 -0
- package/dist/src/shell/ComponentPage.js.map +1 -0
- package/dist/src/shell/Dock.d.ts +42 -0
- package/dist/src/shell/Dock.d.ts.map +1 -0
- package/dist/src/shell/Dock.js +90 -0
- package/dist/src/shell/Dock.js.map +1 -0
- package/dist/src/shell/EventsTab.d.ts +25 -0
- package/dist/src/shell/EventsTab.d.ts.map +1 -0
- package/dist/src/shell/EventsTab.js +26 -0
- package/dist/src/shell/EventsTab.js.map +1 -0
- package/dist/src/shell/FrameView.d.ts +49 -0
- package/dist/src/shell/FrameView.d.ts.map +1 -0
- package/dist/src/shell/FrameView.js +29 -0
- package/dist/src/shell/FrameView.js.map +1 -0
- package/dist/src/shell/HomePage.d.ts +39 -0
- package/dist/src/shell/HomePage.d.ts.map +1 -0
- package/dist/src/shell/HomePage.js +85 -0
- package/dist/src/shell/HomePage.js.map +1 -0
- package/dist/src/shell/InteractionsTab.d.ts +28 -0
- package/dist/src/shell/InteractionsTab.d.ts.map +1 -0
- package/dist/src/shell/InteractionsTab.js +17 -0
- package/dist/src/shell/InteractionsTab.js.map +1 -0
- package/dist/src/shell/MatrixPicker.d.ts +24 -0
- package/dist/src/shell/MatrixPicker.d.ts.map +1 -0
- package/dist/src/shell/MatrixPicker.js +29 -0
- package/dist/src/shell/MatrixPicker.js.map +1 -0
- package/dist/src/shell/PackageHtml.d.ts +17 -0
- package/dist/src/shell/PackageHtml.d.ts.map +1 -0
- package/dist/src/shell/PackageHtml.js +13 -0
- package/dist/src/shell/PackageHtml.js.map +1 -0
- package/dist/src/shell/PartsTab.d.ts +23 -0
- package/dist/src/shell/PartsTab.d.ts.map +1 -0
- package/dist/src/shell/PartsTab.js +23 -0
- package/dist/src/shell/PartsTab.js.map +1 -0
- package/dist/src/shell/PropFields.d.ts +31 -0
- package/dist/src/shell/PropFields.d.ts.map +1 -0
- package/dist/src/shell/PropFields.js +81 -0
- package/dist/src/shell/PropFields.js.map +1 -0
- package/dist/src/shell/PropsTab.d.ts +45 -0
- package/dist/src/shell/PropsTab.d.ts.map +1 -0
- package/dist/src/shell/PropsTab.js +81 -0
- package/dist/src/shell/PropsTab.js.map +1 -0
- package/dist/src/shell/SchemeSwitches.d.ts +24 -0
- package/dist/src/shell/SchemeSwitches.d.ts.map +1 -0
- package/dist/src/shell/SchemeSwitches.js +36 -0
- package/dist/src/shell/SchemeSwitches.js.map +1 -0
- package/dist/src/shell/Segmented.d.ts +41 -0
- package/dist/src/shell/Segmented.d.ts.map +1 -0
- package/dist/src/shell/Segmented.js +19 -0
- package/dist/src/shell/Segmented.js.map +1 -0
- package/dist/src/shell/Shell.d.ts +49 -0
- package/dist/src/shell/Shell.d.ts.map +1 -0
- package/dist/src/shell/Shell.js +279 -0
- package/dist/src/shell/Shell.js.map +1 -0
- package/dist/src/shell/Sidebar.d.ts +52 -0
- package/dist/src/shell/Sidebar.d.ts.map +1 -0
- package/dist/src/shell/Sidebar.js +132 -0
- package/dist/src/shell/Sidebar.js.map +1 -0
- package/dist/src/shell/SidebarHandle.d.ts +29 -0
- package/dist/src/shell/SidebarHandle.d.ts.map +1 -0
- package/dist/src/shell/SidebarHandle.js +46 -0
- package/dist/src/shell/SidebarHandle.js.map +1 -0
- package/dist/src/shell/Stage.d.ts +68 -0
- package/dist/src/shell/Stage.d.ts.map +1 -0
- package/dist/src/shell/Stage.js +218 -0
- package/dist/src/shell/Stage.js.map +1 -0
- package/dist/src/shell/StageTools.d.ts +27 -0
- package/dist/src/shell/StageTools.d.ts.map +1 -0
- package/dist/src/shell/StageTools.js +34 -0
- package/dist/src/shell/StageTools.js.map +1 -0
- package/dist/src/shell/StageViewport.d.ts +47 -0
- package/dist/src/shell/StageViewport.d.ts.map +1 -0
- package/dist/src/shell/StageViewport.js +174 -0
- package/dist/src/shell/StageViewport.js.map +1 -0
- package/dist/src/shell/StoryCodeBlock.d.ts +35 -0
- package/dist/src/shell/StoryCodeBlock.d.ts.map +1 -0
- package/dist/src/shell/StoryCodeBlock.js +27 -0
- package/dist/src/shell/StoryCodeBlock.js.map +1 -0
- package/dist/src/shell/StoryPicker.d.ts +26 -0
- package/dist/src/shell/StoryPicker.d.ts.map +1 -0
- package/dist/src/shell/StoryPicker.js +32 -0
- package/dist/src/shell/StoryPicker.js.map +1 -0
- package/dist/src/shell/Toolbar.d.ts +40 -0
- package/dist/src/shell/Toolbar.d.ts.map +1 -0
- package/dist/src/shell/Toolbar.js +125 -0
- package/dist/src/shell/Toolbar.js.map +1 -0
- package/dist/src/shell/WidthField.d.ts +24 -0
- package/dist/src/shell/WidthField.d.ts.map +1 -0
- package/dist/src/shell/WidthField.js +40 -0
- package/dist/src/shell/WidthField.js.map +1 -0
- package/dist/src/shell/catalogueContext.d.ts +6 -0
- package/dist/src/shell/catalogueContext.d.ts.map +1 -0
- package/dist/src/shell/catalogueContext.js +14 -0
- package/dist/src/shell/catalogueContext.js.map +1 -0
- package/dist/src/shell/codeTokens.d.ts +23 -0
- package/dist/src/shell/codeTokens.d.ts.map +1 -0
- package/dist/src/shell/codeTokens.js +48 -0
- package/dist/src/shell/codeTokens.js.map +1 -0
- package/dist/src/shell/codeWriter.d.ts +6 -0
- package/dist/src/shell/codeWriter.d.ts.map +1 -0
- package/dist/src/shell/codeWriter.js +14 -0
- package/dist/src/shell/codeWriter.js.map +1 -0
- package/dist/src/shell/compareVariants.d.ts +35 -0
- package/dist/src/shell/compareVariants.d.ts.map +1 -0
- package/dist/src/shell/compareVariants.js +68 -0
- package/dist/src/shell/compareVariants.js.map +1 -0
- package/dist/src/shell/dockTabs.d.ts +63 -0
- package/dist/src/shell/dockTabs.d.ts.map +1 -0
- package/dist/src/shell/dockTabs.js +140 -0
- package/dist/src/shell/dockTabs.js.map +1 -0
- package/dist/src/shell/icons.d.ts +47 -0
- package/dist/src/shell/icons.d.ts.map +1 -0
- package/dist/src/shell/icons.js +36 -0
- package/dist/src/shell/icons.js.map +1 -0
- package/dist/src/shell/keyboard.d.ts +35 -0
- package/dist/src/shell/keyboard.d.ts.map +1 -0
- package/dist/src/shell/keyboard.js +51 -0
- package/dist/src/shell/keyboard.js.map +1 -0
- package/dist/src/shell/mountShell.d.ts +22 -0
- package/dist/src/shell/mountShell.d.ts.map +1 -0
- package/dist/src/shell/mountShell.js +39 -0
- package/dist/src/shell/mountShell.js.map +1 -0
- package/dist/src/shell/shell.css +1831 -0
- package/dist/src/shell/strings.d.ts +184 -0
- package/dist/src/shell/strings.d.ts.map +1 -0
- package/dist/src/shell/strings.js +188 -0
- package/dist/src/shell/strings.js.map +1 -0
- package/dist/src/shell/switchView.d.ts +23 -0
- package/dist/src/shell/switchView.d.ts.map +1 -0
- package/dist/src/shell/switchView.js +19 -0
- package/dist/src/shell/switchView.js.map +1 -0
- package/dist/src/shell/treeSearch.d.ts +35 -0
- package/dist/src/shell/treeSearch.d.ts.map +1 -0
- package/dist/src/shell/treeSearch.js +60 -0
- package/dist/src/shell/treeSearch.js.map +1 -0
- package/dist/src/shell/useComponentDocs.d.ts +16 -0
- package/dist/src/shell/useComponentDocs.d.ts.map +1 -0
- package/dist/src/shell/useComponentDocs.js +25 -0
- package/dist/src/shell/useComponentDocs.js.map +1 -0
- package/dist/src/shell/useCopy.d.ts +10 -0
- package/dist/src/shell/useCopy.d.ts.map +1 -0
- package/dist/src/shell/useCopy.js +23 -0
- package/dist/src/shell/useCopy.js.map +1 -0
- package/dist/src/shell/useFrameMessages.d.ts +54 -0
- package/dist/src/shell/useFrameMessages.d.ts.map +1 -0
- package/dist/src/shell/useFrameMessages.js +90 -0
- package/dist/src/shell/useFrameMessages.js.map +1 -0
- package/dist/src/shell/useFrameQueue.d.ts +29 -0
- package/dist/src/shell/useFrameQueue.d.ts.map +1 -0
- package/dist/src/shell/useFrameQueue.js +72 -0
- package/dist/src/shell/useFrameQueue.js.map +1 -0
- package/dist/src/shell/useLiveView.d.ts +29 -0
- package/dist/src/shell/useLiveView.d.ts.map +1 -0
- package/dist/src/shell/useLiveView.js +51 -0
- package/dist/src/shell/useLiveView.js.map +1 -0
- package/dist/src/shell/useLoaded.d.ts +20 -0
- package/dist/src/shell/useLoaded.d.ts.map +1 -0
- package/dist/src/shell/useLoaded.js +40 -0
- package/dist/src/shell/useLoaded.js.map +1 -0
- package/dist/src/shell/usePageDoc.d.ts +20 -0
- package/dist/src/shell/usePageDoc.d.ts.map +1 -0
- package/dist/src/shell/usePageDoc.js +21 -0
- package/dist/src/shell/usePageDoc.js.map +1 -0
- package/dist/src/shell/usePopover.d.ts +23 -0
- package/dist/src/shell/usePopover.d.ts.map +1 -0
- package/dist/src/shell/usePopover.js +39 -0
- package/dist/src/shell/usePopover.js.map +1 -0
- package/dist/src/shell/useRecentPages.d.ts +21 -0
- package/dist/src/shell/useRecentPages.d.ts.map +1 -0
- package/dist/src/shell/useRecentPages.js +62 -0
- package/dist/src/shell/useRecentPages.js.map +1 -0
- package/dist/src/shell/useScrollMemory.d.ts +40 -0
- package/dist/src/shell/useScrollMemory.d.ts.map +1 -0
- package/dist/src/shell/useScrollMemory.js +69 -0
- package/dist/src/shell/useScrollMemory.js.map +1 -0
- package/dist/src/shell/useSidebarLayout.d.ts +14 -0
- package/dist/src/shell/useSidebarLayout.d.ts.map +1 -0
- package/dist/src/shell/useSidebarLayout.js +19 -0
- package/dist/src/shell/useSidebarLayout.js.map +1 -0
- package/dist/src/shell/useStored.d.ts +11 -0
- package/dist/src/shell/useStored.d.ts.map +1 -0
- package/dist/src/shell/useStored.js +68 -0
- package/dist/src/shell/useStored.js.map +1 -0
- package/dist/src/shell/useStoryCode.d.ts +14 -0
- package/dist/src/shell/useStoryCode.d.ts.map +1 -0
- package/dist/src/shell/useStoryCode.js +29 -0
- package/dist/src/shell/useStoryCode.js.map +1 -0
- package/dist/src/shell/useStoryHeights.d.ts +9 -0
- package/dist/src/shell/useStoryHeights.d.ts.map +1 -0
- package/dist/src/shell/useStoryHeights.js +31 -0
- package/dist/src/shell/useStoryHeights.js.map +1 -0
- package/dist/src/shell/useStoryIdsElement.d.ts +7 -0
- package/dist/src/shell/useStoryIdsElement.d.ts.map +1 -0
- package/dist/src/shell/useStoryIdsElement.js +29 -0
- package/dist/src/shell/useStoryIdsElement.js.map +1 -0
- package/dist/src/shell/useStoryKeys.d.ts +11 -0
- package/dist/src/shell/useStoryKeys.d.ts.map +1 -0
- package/dist/src/shell/useStoryKeys.js +40 -0
- package/dist/src/shell/useStoryKeys.js.map +1 -0
- package/dist/src/shell/useSystemDark.d.ts +3 -0
- package/dist/src/shell/useSystemDark.d.ts.map +1 -0
- package/dist/src/shell/useSystemDark.js +19 -0
- package/dist/src/shell/useSystemDark.js.map +1 -0
- package/dist/src/sourceFiles.d.ts +18 -0
- package/dist/src/sourceFiles.d.ts.map +1 -0
- package/dist/src/sourceFiles.js +22 -0
- package/dist/src/sourceFiles.js.map +1 -0
- package/dist/src/storyBackground.d.ts +21 -0
- package/dist/src/storyBackground.d.ts.map +1 -0
- package/dist/src/storyBackground.js +27 -0
- package/dist/src/storyBackground.js.map +1 -0
- package/dist/src/storyClock.d.ts +62 -0
- package/dist/src/storyClock.d.ts.map +1 -0
- package/dist/src/storyClock.js +51 -0
- package/dist/src/storyClock.js.map +1 -0
- package/dist/src/storyGlobals.d.ts +60 -0
- package/dist/src/storyGlobals.d.ts.map +1 -0
- package/dist/src/storyGlobals.js +117 -0
- package/dist/src/storyGlobals.js.map +1 -0
- package/dist/src/storyHeights.d.ts +37 -0
- package/dist/src/storyHeights.d.ts.map +1 -0
- package/dist/src/storyHeights.js +53 -0
- package/dist/src/storyHeights.js.map +1 -0
- package/dist/src/storyIdsElement.d.ts +9 -0
- package/dist/src/storyIdsElement.d.ts.map +1 -0
- package/dist/src/storyIdsElement.js +9 -0
- package/dist/src/storyIdsElement.js.map +1 -0
- package/dist/src/storyTexts.d.ts +43 -0
- package/dist/src/storyTexts.d.ts.map +1 -0
- package/dist/src/storyTexts.js +71 -0
- package/dist/src/storyTexts.js.map +1 -0
- package/dist/src/storyTree.d.ts +215 -0
- package/dist/src/storyTree.d.ts.map +1 -0
- package/dist/src/storyTree.js +308 -0
- package/dist/src/storyTree.js.map +1 -0
- package/dist/src/switches.d.ts +156 -0
- package/dist/src/switches.d.ts.map +1 -0
- package/dist/src/switches.js +193 -0
- package/dist/src/switches.js.map +1 -0
- package/dist/src/viewState.d.ts +194 -0
- package/dist/src/viewState.d.ts.map +1 -0
- package/dist/src/viewState.js +303 -0
- package/dist/src/viewState.js.map +1 -0
- package/dist/src/vite/adapter.d.ts +70 -0
- package/dist/src/vite/adapter.d.ts.map +1 -0
- package/dist/src/vite/adapter.js +22 -0
- package/dist/src/vite/adapter.js.map +1 -0
- package/dist/src/vite/autoTitle.d.ts +28 -0
- package/dist/src/vite/autoTitle.d.ts.map +1 -0
- package/dist/src/vite/autoTitle.js +44 -0
- package/dist/src/vite/autoTitle.js.map +1 -0
- package/dist/src/vite/componentPage.d.ts +34 -0
- package/dist/src/vite/componentPage.d.ts.map +1 -0
- package/dist/src/vite/componentPage.js +94 -0
- package/dist/src/vite/componentPage.js.map +1 -0
- package/dist/src/vite/config.d.ts +72 -0
- package/dist/src/vite/config.d.ts.map +1 -0
- package/dist/src/vite/config.js +25 -0
- package/dist/src/vite/config.js.map +1 -0
- package/dist/src/vite/configFile.d.ts +76 -0
- package/dist/src/vite/configFile.d.ts.map +1 -0
- package/dist/src/vite/configFile.js +190 -0
- package/dist/src/vite/configFile.js.map +1 -0
- package/dist/src/vite/docsExtractor.d.ts +46 -0
- package/dist/src/vite/docsExtractor.d.ts.map +1 -0
- package/dist/src/vite/docsExtractor.js +88 -0
- package/dist/src/vite/docsExtractor.js.map +1 -0
- package/dist/src/vite/docsProgram.d.ts +42 -0
- package/dist/src/vite/docsProgram.d.ts.map +1 -0
- package/dist/src/vite/docsProgram.js +144 -0
- package/dist/src/vite/docsProgram.js.map +1 -0
- package/dist/src/vite/docsWorker.d.ts +2 -0
- package/dist/src/vite/docsWorker.d.ts.map +1 -0
- package/dist/src/vite/docsWorker.js +68 -0
- package/dist/src/vite/docsWorker.js.map +1 -0
- package/dist/src/vite/forcedStates.d.ts +27 -0
- package/dist/src/vite/forcedStates.d.ts.map +1 -0
- package/dist/src/vite/forcedStates.js +60 -0
- package/dist/src/vite/forcedStates.js.map +1 -0
- package/dist/src/vite/forgebookPlugin.d.ts +28 -0
- package/dist/src/vite/forgebookPlugin.d.ts.map +1 -0
- package/dist/src/vite/forgebookPlugin.js +375 -0
- package/dist/src/vite/forgebookPlugin.js.map +1 -0
- package/dist/src/vite/highlightCode.d.ts +16 -0
- package/dist/src/vite/highlightCode.d.ts.map +1 -0
- package/dist/src/vite/highlightCode.js +82 -0
- package/dist/src/vite/highlightCode.js.map +1 -0
- package/dist/src/vite/indexStoryFile.d.ts +35 -0
- package/dist/src/vite/indexStoryFile.d.ts.map +1 -0
- package/dist/src/vite/indexStoryFile.js +458 -0
- package/dist/src/vite/indexStoryFile.js.map +1 -0
- package/dist/src/vite/pages.d.ts +49 -0
- package/dist/src/vite/pages.d.ts.map +1 -0
- package/dist/src/vite/pages.js +171 -0
- package/dist/src/vite/pages.js.map +1 -0
- package/dist/src/vite/prebundled.d.ts +30 -0
- package/dist/src/vite/prebundled.d.ts.map +1 -0
- package/dist/src/vite/prebundled.js +81 -0
- package/dist/src/vite/prebundled.js.map +1 -0
- package/dist/src/vite/storyCode.d.ts +28 -0
- package/dist/src/vite/storyCode.d.ts.map +1 -0
- package/dist/src/vite/storyCode.js +80 -0
- package/dist/src/vite/storyCode.js.map +1 -0
- package/dist/src/vite/storyFilesModule.d.ts +17 -0
- package/dist/src/vite/storyFilesModule.d.ts.map +1 -0
- package/dist/src/vite/storyFilesModule.js +64 -0
- package/dist/src/vite/storyFilesModule.js.map +1 -0
- package/dist/src/vite/storyMeta.d.ts +34 -0
- package/dist/src/vite/storyMeta.d.ts.map +1 -0
- package/dist/src/vite/storyMeta.js +74 -0
- package/dist/src/vite/storyMeta.js.map +1 -0
- package/dist/src/vite/typeScriptPieces.d.ts +23 -0
- package/dist/src/vite/typeScriptPieces.d.ts.map +1 -0
- package/dist/src/vite/typeScriptPieces.js +236 -0
- package/dist/src/vite/typeScriptPieces.js.map +1 -0
- package/package.json +202 -3
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The switches of the toolbar and the View menu, as a catalogue declares them: what each offers, where it applies,
|
|
3
|
+
* and the two roles the catalogue itself reads (the colour scheme and the contrast).
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Forgebook knows no library's switches: a catalogue (or, from phase 4, a library's preset) declares them, as
|
|
7
|
+
* Storybook's `globalTypes`. A switch applies either on the frame's root, live (an attribute, a class, the
|
|
8
|
+
* `color-scheme`, a custom property), or by code: the story reads it as `context.globals`. Its value lives in the
|
|
9
|
+
* address (`?<id>=<value>`, only when it is not the default). The theme and the contrast are switches like the others,
|
|
10
|
+
* ready-made here; a catalogue that declares none gets them. The language a catalogue offers is a switch the frame
|
|
11
|
+
* applies by code (`languageSwitch`). Pure.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** One value a switch offers. */
|
|
16
|
+
export type SwitchValue = {
|
|
17
|
+
/** The value, as the address and the root's attribute write it (`dark`). */
|
|
18
|
+
readonly value: string;
|
|
19
|
+
/** Its name in the toolbar or the View menu (`Dark`). */
|
|
20
|
+
readonly label: string;
|
|
21
|
+
/** Whether the value is the library's own: the switch then writes nothing on the root (`theme=system`). */
|
|
22
|
+
readonly isUnset?: boolean;
|
|
23
|
+
/** For a `colorScheme` switch: the scheme the value draws in; `system` follows the system. */
|
|
24
|
+
readonly scheme?: "light" | "dark" | "system";
|
|
25
|
+
/** For a `contrast` switch: whether the value is the higher contrast. */
|
|
26
|
+
readonly isMore?: boolean;
|
|
27
|
+
};
|
|
28
|
+
/** Where a switch applies. */
|
|
29
|
+
export type SwitchApply =
|
|
30
|
+
/** An attribute on the frame's root (`data-theme`). */
|
|
31
|
+
{
|
|
32
|
+
readonly kind: "attribute";
|
|
33
|
+
readonly name: string;
|
|
34
|
+
}
|
|
35
|
+
/** A class on the frame's root, the value after a prefix (`theme-dark`). */
|
|
36
|
+
| {
|
|
37
|
+
readonly kind: "class";
|
|
38
|
+
readonly prefix: string;
|
|
39
|
+
}
|
|
40
|
+
/** The root's `color-scheme`. */
|
|
41
|
+
| {
|
|
42
|
+
readonly kind: "colorScheme";
|
|
43
|
+
}
|
|
44
|
+
/** A custom property on the root (`--density`). */
|
|
45
|
+
| {
|
|
46
|
+
readonly kind: "cssVariable";
|
|
47
|
+
readonly name: string;
|
|
48
|
+
}
|
|
49
|
+
/** Nothing on the root: the story reads the value as `context.globals[id]` (a provider, a prop). */
|
|
50
|
+
| {
|
|
51
|
+
readonly kind: "code";
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* What the catalogue itself reads of a switch: the colour scheme (the loading boxes' and backgrounds' colours, the
|
|
55
|
+
* tests' themes), the contrast (the source's more-contrast colours, the tests' variants), the language (the stories'
|
|
56
|
+
* texts and the language's provider).
|
|
57
|
+
*/
|
|
58
|
+
export type SwitchRole = "colorScheme" | "contrast" | "language";
|
|
59
|
+
/** A switch of the toolbar or the View menu. */
|
|
60
|
+
export type ViewSwitch = {
|
|
61
|
+
/** A stable id, the address's parameter (`theme`). */
|
|
62
|
+
readonly id: string;
|
|
63
|
+
/** Its name in the toolbar or the View menu (`Theme`). */
|
|
64
|
+
readonly label: string;
|
|
65
|
+
/** Its values, in their order. */
|
|
66
|
+
readonly values: readonly SwitchValue[];
|
|
67
|
+
/** The value when the address names none. */
|
|
68
|
+
readonly default: string;
|
|
69
|
+
/** Where it applies. */
|
|
70
|
+
readonly apply: SwitchApply;
|
|
71
|
+
/** What the catalogue reads of it; none for a switch only the library reads. */
|
|
72
|
+
readonly role?: SwitchRole;
|
|
73
|
+
/** How the View menu offers it: a row of segments (by default, up to six values) or a list. */
|
|
74
|
+
readonly control?: "segments" | "list";
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Why a list of switches cannot be used, or none: ids unique and not the address's own, a default among the values,
|
|
78
|
+
* at most one switch per role.
|
|
79
|
+
*
|
|
80
|
+
* @param switches - the declared switches.
|
|
81
|
+
*/
|
|
82
|
+
export declare const switchesProblem: (switches: readonly ViewSwitch[]) => string | undefined;
|
|
83
|
+
/** The theme: light, dark, or the system's (no attribute), on `data-theme`. */
|
|
84
|
+
export declare const themeSwitch: () => ViewSwitch;
|
|
85
|
+
/** The contrast: standard or more, on `data-contrast`. */
|
|
86
|
+
export declare const contrastSwitch: () => ViewSwitch;
|
|
87
|
+
/** The switches of a catalogue that declares none: the theme and the contrast. */
|
|
88
|
+
export declare const DEFAULT_SWITCHES: readonly ViewSwitch[];
|
|
89
|
+
/** The language switch's id, the address's `lang` parameter. */
|
|
90
|
+
export declare const LANGUAGE_SWITCH_ID = "lang";
|
|
91
|
+
/**
|
|
92
|
+
* The language switch for the languages a story can be drawn in: the stories' own text, then each language. Applied
|
|
93
|
+
* by code: the frame hands the story the language's texts and provider.
|
|
94
|
+
*
|
|
95
|
+
* @param languages - the languages, by id and name.
|
|
96
|
+
*/
|
|
97
|
+
export declare const languageSwitch: (languages: readonly {
|
|
98
|
+
readonly id: string;
|
|
99
|
+
readonly label: string;
|
|
100
|
+
}[]) => ViewSwitch;
|
|
101
|
+
/**
|
|
102
|
+
* The switch with a role, among a catalogue's.
|
|
103
|
+
*
|
|
104
|
+
* @param switches - the switches.
|
|
105
|
+
* @param role - the role.
|
|
106
|
+
*/
|
|
107
|
+
export declare const switchWithRole: (switches: readonly ViewSwitch[], role: SwitchRole) => ViewSwitch | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* A switch's value as declared, for a value an address or a message gives.
|
|
110
|
+
*
|
|
111
|
+
* @param each - the switch.
|
|
112
|
+
* @param value - the value given; none for the default.
|
|
113
|
+
*/
|
|
114
|
+
export declare const switchValueOf: (each: ViewSwitch, value: string | undefined) => SwitchValue | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* How the View menu offers a switch: as it declares, or segments up to six values and a list past them.
|
|
117
|
+
*
|
|
118
|
+
* @param each - the switch.
|
|
119
|
+
*/
|
|
120
|
+
export declare const switchControl: (each: ViewSwitch) => "segments" | "list";
|
|
121
|
+
/**
|
|
122
|
+
* A catalogue's switches: the ones it declares (the theme and the contrast when it declares none), then, when it or a
|
|
123
|
+
* source offers languages, the language switch over all of them.
|
|
124
|
+
*
|
|
125
|
+
* @param declared - the switches the catalogue declares; none for the default ones.
|
|
126
|
+
* @param languages - every language the catalogue and its sources offer, by id and name; the first of an id wins.
|
|
127
|
+
* @throws when the switches cannot be used (`switchesProblem`): a catalogue's configuration error, shown at once.
|
|
128
|
+
*/
|
|
129
|
+
export declare const catalogueSwitches: (declared: readonly ViewSwitch[] | undefined, languages: readonly {
|
|
130
|
+
readonly id: string;
|
|
131
|
+
readonly label: string;
|
|
132
|
+
}[]) => readonly ViewSwitch[];
|
|
133
|
+
/** What a switch made from a `globalType` may take besides it: where it applies, what the catalogue reads of it. */
|
|
134
|
+
export type GlobalTypeSwitchOverride = Partial<Pick<ViewSwitch, "label" | "apply" | "role" | "control">>;
|
|
135
|
+
/** How `switchesFromGlobalTypes` reads Storybook's preview. */
|
|
136
|
+
export type GlobalTypesOptions = {
|
|
137
|
+
/** The preview's `initialGlobals`: each switch's default, over the `globalType`'s `defaultValue`. */
|
|
138
|
+
readonly initialGlobals?: Readonly<Record<string, unknown>>;
|
|
139
|
+
/**
|
|
140
|
+
* What each switch takes besides its `globalType`, by id: by default a switch applies by code (the story's
|
|
141
|
+
* decorators read `context.globals`, as Storybook's do) and the catalogue reads nothing of it.
|
|
142
|
+
*/
|
|
143
|
+
readonly overrides?: Readonly<Record<string, GlobalTypeSwitchOverride>>;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* The catalogue's switches from Storybook's `globalTypes` (a toolbar of a preview's own globals): one switch per
|
|
147
|
+
* `globalType` with toolbar items, applied by code, so the decorators that read `context.globals` work as in
|
|
148
|
+
* Storybook. Its label is the toolbar's title (or the `globalType`'s `name`, or its id); its default the preview's
|
|
149
|
+
* `initialGlobals`, or its `defaultValue`, or its first value. The globals of Storybook's addons and the address's
|
|
150
|
+
* own names are left out.
|
|
151
|
+
*
|
|
152
|
+
* @param globalTypes - the preview's `globalTypes`, as plain data (the configuration reads it on Node).
|
|
153
|
+
* @param options - the preview's `initialGlobals`, and what a switch takes besides its `globalType`.
|
|
154
|
+
*/
|
|
155
|
+
export declare const switchesFromGlobalTypes: (globalTypes: Readonly<Record<string, unknown>>, options?: GlobalTypesOptions) => ViewSwitch[];
|
|
156
|
+
//# sourceMappingUR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AU,KAAG,UAAU,GAAG,MACG,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,SAAS,UAAU,EAAE,GAAG,SAAS,EAC3C,WAAW,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,KACpE,SAAS,UAAU,EAWrB,CAAC;AAEF,oHAAoH;AACpH,MAAM,MAAM,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAEzG,+DAA+D;AAC/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,qGAAqG;IACrG,QAAQ,CAAC,cAAc,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5D;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC,CAAC;CACzE,CAAC;AAuBF;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,GAClC,aAAa,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC9C,UAAS,kBAAuB,KAC/B,UAAU,EAmBT,CAAC"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The switches of the toolbar and the View menu, as a catalogue declares them: what each offers, where it applies,
|
|
3
|
+
* and the two roles the catalogue itself reads (the colour scheme and the contrast).
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Forgebook knows no library's switches: a catalogue (or, from phase 4, a library's preset) declares them, as
|
|
7
|
+
* Storybook's `globalTypes`. A switch applies either on the frame's root, live (an attribute, a class, the
|
|
8
|
+
* `color-scheme`, a custom property), or by code: the story reads it as `context.globals`. Its value lives in the
|
|
9
|
+
* address (`?<id>=<value>`, only when it is not the default). The theme and the contrast are switches like the others,
|
|
10
|
+
* ready-made here; a catalogue that declares none gets them. The language a catalogue offers is a switch the frame
|
|
11
|
+
* applies by code (`languageSwitch`). Pure.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** The address's own parameters: a switch may not take their names. */
|
|
16
|
+
const RESERVED_IDS = [
|
|
17
|
+
"story",
|
|
18
|
+
"component",
|
|
19
|
+
"backdrop",
|
|
20
|
+
"sheets",
|
|
21
|
+
"text",
|
|
22
|
+
"compare",
|
|
23
|
+
"width",
|
|
24
|
+
"height",
|
|
25
|
+
"panel",
|
|
26
|
+
"tab",
|
|
27
|
+
"zoom",
|
|
28
|
+
"tools",
|
|
29
|
+
"args",
|
|
30
|
+
"matrix",
|
|
31
|
+
"clock"
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Why a list of switches cannot be used, or none: ids unique and not the address's own, a default among the values,
|
|
35
|
+
* at most one switch per role.
|
|
36
|
+
*
|
|
37
|
+
* @param switches - the declared switches.
|
|
38
|
+
*/
|
|
39
|
+
export const switchesProblem = (switches) => {
|
|
40
|
+
const ids = new Set();
|
|
41
|
+
const roles = new Set();
|
|
42
|
+
for (const each of switches) {
|
|
43
|
+
if (ids.has(each.id))
|
|
44
|
+
return `Two switches are named "${each.id}"`;
|
|
45
|
+
if (RESERVED_IDS.includes(each.id))
|
|
46
|
+
return `"${each.id}" is a parameter of the address, not a switch's name`;
|
|
47
|
+
if (!each.values.some((value) => value.value === each.default))
|
|
48
|
+
return `The switch "${each.id}" has no value "${each.default}", its default`;
|
|
49
|
+
if (each.role !== undefined) {
|
|
50
|
+
if (roles.has(each.role))
|
|
51
|
+
return `Two switches have the role "${each.role}"`;
|
|
52
|
+
roles.add(each.role);
|
|
53
|
+
}
|
|
54
|
+
ids.add(each.id);
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
};
|
|
58
|
+
/** The theme: light, dark, or the system's (no attribute), on `data-theme`. */
|
|
59
|
+
export const themeSwitch = () => ({
|
|
60
|
+
id: "theme",
|
|
61
|
+
label: "Theme",
|
|
62
|
+
role: "colorScheme",
|
|
63
|
+
apply: { kind: "attribute", name: "data-theme" },
|
|
64
|
+
default: "light",
|
|
65
|
+
values: [
|
|
66
|
+
{ value: "light", label: "Light", scheme: "light" },
|
|
67
|
+
{ value: "dark", label: "Dark", scheme: "dark" },
|
|
68
|
+
{ value: "system", label: "System", scheme: "system", isUnset: true }
|
|
69
|
+
]
|
|
70
|
+
});
|
|
71
|
+
/** The contrast: standard or more, on `data-contrast`. */
|
|
72
|
+
export const contrastSwitch = () => ({
|
|
73
|
+
id: "contrast",
|
|
74
|
+
label: "More contrast",
|
|
75
|
+
role: "contrast",
|
|
76
|
+
apply: { kind: "attribute", name: "data-contrast" },
|
|
77
|
+
default: "standard",
|
|
78
|
+
values: [
|
|
79
|
+
{ value: "standard", label: "Standard", isMore: false },
|
|
80
|
+
{ value: "more", label: "More contrast", isMore: true }
|
|
81
|
+
]
|
|
82
|
+
});
|
|
83
|
+
/** The switches of a catalogue that declares none: the theme and the contrast. */
|
|
84
|
+
export const DEFAULT_SWITCHES = [themeSwitch(), contrastSwitch()];
|
|
85
|
+
/** The language switch's id, the address's `lang` parameter. */
|
|
86
|
+
export const LANGUAGE_SWITCH_ID = "lang";
|
|
87
|
+
/**
|
|
88
|
+
* The language switch for the languages a story can be drawn in: the stories' own text, then each language. Applied
|
|
89
|
+
* by code: the frame hands the story the language's texts and provider.
|
|
90
|
+
*
|
|
91
|
+
* @param languages - the languages, by id and name.
|
|
92
|
+
*/
|
|
93
|
+
export const languageSwitch = (languages) => ({
|
|
94
|
+
id: LANGUAGE_SWITCH_ID,
|
|
95
|
+
label: "Language",
|
|
96
|
+
role: "language",
|
|
97
|
+
apply: { kind: "code" },
|
|
98
|
+
control: "list",
|
|
99
|
+
default: "",
|
|
100
|
+
values: [
|
|
101
|
+
{ value: "", label: "Stories' own", isUnset: true },
|
|
102
|
+
...languages.map((language) => ({ value: language.id, label: language.label }))
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* The switch with a role, among a catalogue's.
|
|
107
|
+
*
|
|
108
|
+
* @param switches - the switches.
|
|
109
|
+
* @param role - the role.
|
|
110
|
+
*/
|
|
111
|
+
export const switchWithRole = (switches, role) => switches.find((each) => each.role === role);
|
|
112
|
+
/**
|
|
113
|
+
* A switch's value as declared, for a value an address or a message gives.
|
|
114
|
+
*
|
|
115
|
+
* @param each - the switch.
|
|
116
|
+
* @param value - the value given; none for the default.
|
|
117
|
+
*/
|
|
118
|
+
export const switchValueOf = (each, value) => each.values.find((candidate) => candidate.value === (value ?? each.default));
|
|
119
|
+
/**
|
|
120
|
+
* How the View menu offers a switch: as it declares, or segments up to six values and a list past them.
|
|
121
|
+
*
|
|
122
|
+
* @param each - the switch.
|
|
123
|
+
*/
|
|
124
|
+
export const switchControl = (each) => each.control ?? (each.values.length <= 6 ? "segments" : "list");
|
|
125
|
+
/**
|
|
126
|
+
* A catalogue's switches: the ones it declares (the theme and the contrast when it declares none), then, when it or a
|
|
127
|
+
* source offers languages, the language switch over all of them.
|
|
128
|
+
*
|
|
129
|
+
* @param declared - the switches the catalogue declares; none for the default ones.
|
|
130
|
+
* @param languages - every language the catalogue and its sources offer, by id and name; the first of an id wins.
|
|
131
|
+
* @throws when the switches cannot be used (`switchesProblem`): a catalogue's configuration error, shown at once.
|
|
132
|
+
*/
|
|
133
|
+
export const catalogueSwitches = (declared, languages) => {
|
|
134
|
+
const unique = languages.filter((language, index) => languages.findIndex((other) => other.id === language.id) === index);
|
|
135
|
+
const switches = [
|
|
136
|
+
...(declared ?? DEFAULT_SWITCHES),
|
|
137
|
+
...(unique.length > 0 ? [languageSwitch(unique)] : [])
|
|
138
|
+
];
|
|
139
|
+
const problem = switchesProblem(switches);
|
|
140
|
+
if (problem !== undefined)
|
|
141
|
+
throw new Error(`Forgebook's switches: ${problem}`);
|
|
142
|
+
return switches;
|
|
143
|
+
};
|
|
144
|
+
/** The globals of Storybook's own addons: the catalogue has its own background, width and measuring tools. */
|
|
145
|
+
const ADDON_GLOBALS = ["backgrounds", "viewport", "measureEnabled", "outline", "grid"];
|
|
146
|
+
/** Whether a value is a plain object. */
|
|
147
|
+
const isRecordValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
148
|
+
/**
|
|
149
|
+
* The values of a `globalType`'s toolbar: each item a text, or `{ value, title }`; an item without a text value (a
|
|
150
|
+
* reset) is left out.
|
|
151
|
+
*
|
|
152
|
+
* @param items - the toolbar's `items`.
|
|
153
|
+
*/
|
|
154
|
+
const globalTypeValues = (items) => (Array.isArray(items) ? items : []).flatMap((item) => {
|
|
155
|
+
if (typeof item === "string")
|
|
156
|
+
return [{ value: item, label: item }];
|
|
157
|
+
if (!isRecordValue(item) || typeof item["value"] !== "string")
|
|
158
|
+
return [];
|
|
159
|
+
const title = item["title"];
|
|
160
|
+
return [{ value: item["value"], label: typeof title === "string" ? title : item["value"] }];
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* The catalogue's switches from Storybook's `globalTypes` (a toolbar of a preview's own globals): one switch per
|
|
164
|
+
* `globalType` with toolbar items, applied by code, so the decorators that read `context.globals` work as in
|
|
165
|
+
* Storybook. Its label is the toolbar's title (or the `globalType`'s `name`, or its id); its default the preview's
|
|
166
|
+
* `initialGlobals`, or its `defaultValue`, or its first value. The globals of Storybook's addons and the address's
|
|
167
|
+
* own names are left out.
|
|
168
|
+
*
|
|
169
|
+
* @param globalTypes - the preview's `globalTypes`, as plain data (the configuration reads it on Node).
|
|
170
|
+
* @param options - the preview's `initialGlobals`, and what a switch takes besides its `globalType`.
|
|
171
|
+
*/
|
|
172
|
+
export const switchesFromGlobalTypes = (globalTypes, options = {}) => Object.entries(globalTypes).flatMap(([id, globalType]) => {
|
|
173
|
+
if (!isRecordValue(globalType) || ADDON_GLOBALS.includes(id) || RESERVED_IDS.includes(id))
|
|
174
|
+
return [];
|
|
175
|
+
const toolbar = isRecordValue(globalType["toolbar"]) ? globalType["toolbar"] : {};
|
|
176
|
+
const values = globalTypeValues(toolbar["items"]);
|
|
177
|
+
const [first] = values;
|
|
178
|
+
if (first === undefined)
|
|
179
|
+
return [];
|
|
180
|
+
const initial = options.initialGlobals?.[id] ?? globalType["defaultValue"];
|
|
181
|
+
const title = toolbar["title"] ?? globalType["name"];
|
|
182
|
+
return [
|
|
183
|
+
{
|
|
184
|
+
id,
|
|
185
|
+
label: typeof title === "string" ? title : id,
|
|
186
|
+
values,
|
|
187
|
+
default: values.some((value) => value.value === initial) ? String(initial) : first.value,
|
|
188
|
+
apply: { kind: "code" },
|
|
189
|
+
...options.overrides?.[id]
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
});
|
|
193
|
+
//# sourceMappingURL=switches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switches.js","sourceRoot":"","sources":["../../src/switches.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsDH,uEAAuE;AACvE,MAAM,YAAY,GAAG;IACnB,OAAO;IACP,WAAW;IACX,UAAU;IACV,QAAQ;IACR,MAAM;IACN,SAAS;IACT,OAAO;IACP,QAAQ;IACR,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,QAAQ;IACR,OAAO;CACR,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,QAA+B,EAAsB,EAAE;IACrF,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,MAAM,KAAK,GAAG,IAAI,GAAG,EAAc,CAAC;IACpC,KAAK,MAAM,IAAI,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAAE,OAAO,2BAA2B,IAAI,CAAC,EAAE,GAAG,CAAC;QACnE,I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
+
/**
|
|
2
|
+
* The toolbar's switches as a value, read from and written to the URL, so a view is shared with a link and the
|
|
3
|
+
* frames and the tests open the same address.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Only values that differ from the defaults are written; an unknown or invalid value reads as the default. The view
|
|
7
|
+
* holds a value for each switch the catalogue declares (`switches.ts`: the theme, the contrast, the language, the
|
|
8
|
+
* library's own), which the frame applies on its root or hands the story; and Forgebook's own settings: the style
|
|
9
|
+
* sheets, the root font size and the backdrop Forgebook draws behind the story. The stage's width, height, zoom and tools and the panel (open, its tab) are the shell's alone: a frame's address leaves them
|
|
10
|
+
* out. Pure.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import type { CatalogueSettings, PanelTabId } from "./catalogue.ts";
|
|
15
|
+
import { type ViewSwitch } from "./switches.ts";
|
|
16
|
+
/**
|
|
17
|
+
* What Forgebook draws behind the story, in place of its page's colour (D-644): `plain`, the page's colour itself,
|
|
18
|
+
* or the id of one of the catalogue's backdrops (`backdrops.ts`). Forgebook draws them itself, never the library it
|
|
19
|
+
* shows (D-67).
|
|
20
|
+
*/
|
|
21
|
+
export type BackdropChoice = string;
|
|
22
|
+
/** The page's own colour: no backdrop drawn. */
|
|
23
|
+
export declare const PLAIN_BACKDROP = "plain";
|
|
24
|
+
/** Which style sheets the frame loads besides the required ones. */
|
|
25
|
+
export type SheetsChoice = "full" | "structure" | "restyled";
|
|
26
|
+
/** The root font size, in percent of the browser's (one of the catalogue's text sizes): lengths in rem follow it. */
|
|
27
|
+
export type TextScale = number;
|
|
28
|
+
/**
|
|
29
|
+
* What the compare view sets side by side: the values of one switch, or of two (the theme at both contrasts), or
|
|
30
|
+
* Forgebook's text sizes or style sheets; none shows the story once. Each is a switch's id, `text` or `sheets`.
|
|
31
|
+
*/
|
|
32
|
+
export type CompareAxes = readonly string[];
|
|
33
|
+
/** Forgebook's own settings the compare view can set side by side. */
|
|
34
|
+
export declare const OWN_COMPARE_AXES: readonly ["text", "sheets"];
|
|
35
|
+
/** A tool drawn over the story: every element's outline, an 8 px grid, the box of the element under the pointer. */
|
|
36
|
+
export type MeasureTool = "outline" | "grid" | "measure";
|
|
37
|
+
/** The story's zoom on the stage, in percent: it scales the drawing, never the layout. */
|
|
38
|
+
export type Zoom = number;
|
|
39
|
+
/** A tab of the panel under a story. */
|
|
40
|
+
export type PanelTab = PanelTabId;
|
|
41
|
+
/** The story's width on the stage: the stage's whole width, or a width in CSS px (a preset, or dragged). */
|
|
42
|
+
export type StageWidth = "fill" | number;
|
|
43
|
+
/**
|
|
44
|
+
* The story's height on the stage: its own (`auto`: the story's content, at least the height it declares) or a
|
|
45
|
+
* height in CSS px dragged with the handle at its foot (note 142).
|
|
46
|
+
*/
|
|
47
|
+
export type StageHeight = "auto" | number;
|
|
48
|
+
/** Every switch of the toolbar. */
|
|
49
|
+
export type ViewState = {
|
|
50
|
+
/** Each declared switch's value, by the switch's id; a switch the address leaves out has its default. */
|
|
51
|
+
readonly switches: Readonly<Record<string, string>>;
|
|
52
|
+
/** What is drawn behind the story. */
|
|
53
|
+
readonly backdrop: BackdropChoice;
|
|
54
|
+
/** The style sheets. */
|
|
55
|
+
readonly sheets: SheetsChoice;
|
|
56
|
+
/** The text size. */
|
|
57
|
+
readonly text: TextScale;
|
|
58
|
+
/** What the stage compares side by side: nothing (empty), or the story across one or two switches' values. */
|
|
59
|
+
readonly compare: CompareAxes;
|
|
60
|
+
/** The story's width on the stage. */
|
|
61
|
+
readonly width: StageWidth;
|
|
62
|
+
/** The story's height on the stage. */
|
|
63
|
+
readonly height: StageHeight;
|
|
64
|
+
/** Whether the panel is shown under the story. */
|
|
65
|
+
readonly isPanelOpen: boolean;
|
|
66
|
+
/** The panel's tab; a tab the story has nothing for shows the first one it has. */
|
|
67
|
+
readonly panelTab: PanelTab;
|
|
68
|
+
/** The story's zoom. */
|
|
69
|
+
readonly zoom: Zoom;
|
|
70
|
+
/** The tools drawn over the story, in `MEASURE_TOOLS`' order. */
|
|
71
|
+
readonly tools: readonly MeasureTool[];
|
|
72
|
+
};
|
|
73
|
+
/** The part of the view a frame applies on its root without loading again, so the story keeps its state. */
|
|
74
|
+
export type LiveView = Pick<ViewState, "switches" | "backdrop" | "text">;
|
|
75
|
+
/** The view without any change. */
|
|
76
|
+
export declare const DEFAULT_VIEW: ViewState;
|
|
77
|
+
/** Every style sheet setting, in the menu's order. */
|
|
78
|
+
export declare const SHEETS_CHOICES: readonly SheetsChoice[];
|
|
79
|
+
/**
|
|
80
|
+
* Whether the stage compares the story across a switch's values.
|
|
81
|
+
*
|
|
82
|
+
* @param view - the view.
|
|
83
|
+
*/
|
|
84
|
+
export declare const isComparing: (view: ViewState) => boolean;
|
|
85
|
+
/** Every tool, in the bar's order. */
|
|
86
|
+
export declare const MEASURE_TOOLS: readonly MeasureTool[];
|
|
87
|
+
/** What the view reads of a catalogue: its switches and the lists its values are checked against. */
|
|
88
|
+
export type ViewCatalogue = Pick<CatalogueSettings, "switches" | "widthRange" | "zooms" | "textSizes" | "backdrops" | "tabs">;
|
|
89
|
+
/**
|
|
90
|
+
* A width kept in a catalogue's range, in whole pixels.
|
|
91
|
+
*
|
|
92
|
+
* @param width - a width in CSS px.
|
|
93
|
+
* @param range - the narrowest and widest a story may be set.
|
|
94
|
+
*/
|
|
95
|
+
export declare const clampedWidth: (width: number, range: ViewCatalogue["widthRange"]) => number;
|
|
96
|
+
/** The lowest and highest story a height in the address or a drag may set, in CSS px. */
|
|
97
|
+
export declare const STAGE_HEIGHT_RANGE: {
|
|
98
|
+
readonly min: 48;
|
|
99
|
+
readonly max: 4000;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* A height kept in the range, in whole pixels.
|
|
103
|
+
*
|
|
104
|
+
* @param height - a height in CSS px.
|
|
105
|
+
*/
|
|
106
|
+
export declare const clampedHeight: (height: number) => number;
|
|
107
|
+
/**
|
|
108
|
+
* The view a URL's query describes.
|
|
109
|
+
*
|
|
110
|
+
* @param search - the query (`?theme=dark&motion=reduced`), with or without `?`.
|
|
111
|
+
* @param catalogue - the catalogue's switches and lists.
|
|
112
|
+
*/
|
|
113
|
+
export declare const parseView: (search: string, catalogue: ViewCatalogue) => ViewState;
|
|
114
|
+
/**
|
|
115
|
+
* The view without any change, for a catalogue.
|
|
116
|
+
*
|
|
117
|
+
* @param catalogue - the catalogue's switches and lists.
|
|
118
|
+
*/
|
|
119
|
+
export declare const defaultView: (catalogue: ViewCatalogue) => ViewState;
|
|
120
|
+
/**
|
|
121
|
+
* The query parameters of a view: only what differs from the defaults.
|
|
122
|
+
*
|
|
123
|
+
* @param view - the view.
|
|
124
|
+
* @param switches - the catalogue's switches.
|
|
125
|
+
* @returns the parameters, in a stable order.
|
|
126
|
+
*/
|
|
127
|
+
export declare const viewParams: (view: ViewState, switches: readonly ViewSwitch[]) => URLSearchParams;
|
|
128
|
+
/**
|
|
129
|
+
* Whether one of the View menu's settings is changed (a switch the toolbar does not show itself, the background,
|
|
130
|
+
* the style sheets, the text size): the menu button then shows a dot, so a view is never left changed by mistake.
|
|
131
|
+
*
|
|
132
|
+
* @param view - the view.
|
|
133
|
+
* @param switches - the catalogue's switches.
|
|
134
|
+
*/
|
|
135
|
+
export declare const hasViewChanges: (view: ViewState, switches: readonly ViewSwitch[]) => boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Whether a switch sits in the View menu: every one but the colour scheme and the contrast, which the toolbar shows.
|
|
138
|
+
*
|
|
139
|
+
* @param each - the switch.
|
|
140
|
+
*/
|
|
141
|
+
export declare const isMenuSwitch: (each: ViewSwitch) => boolean;
|
|
142
|
+
/**
|
|
143
|
+
* The address of a story's frame.
|
|
144
|
+
*
|
|
145
|
+
* @param frameUrl - the frame page (`frame.html`).
|
|
146
|
+
* @param id - the story's id.
|
|
147
|
+
* @param view - the view; what only the shell reads (compare, the stage's width, the panel) is left out.
|
|
148
|
+
* @param switches - the catalogue's switches.
|
|
149
|
+
*/
|
|
150
|
+
export declare const frameAddress: (frameUrl: string, id: string, view: ViewState, switches: readonly ViewSwitch[]) => string;
|
|
151
|
+
/**
|
|
152
|
+
* The part of a view a frame applies live.
|
|
153
|
+
*
|
|
154
|
+
* @param view - the view.
|
|
155
|
+
*/
|
|
156
|
+
export declare const liveView: (view: ViewState) => LiveView;
|
|
157
|
+
/**
|
|
158
|
+
* The scheme a view draws in: its colour scheme switch's, light when the catalogue has none.
|
|
159
|
+
*
|
|
160
|
+
* @param view - the view's switches.
|
|
161
|
+
* @param switches - the catalogue's switches.
|
|
162
|
+
*/
|
|
163
|
+
export declare const schemeOf: (view: Pick<ViewState, "switches">, switches: readonly ViewSwitch[]) => "light" | "dark" | "system";
|
|
164
|
+
/**
|
|
165
|
+
* Whether a view draws in the higher contrast: its contrast switch's value says so; never without one.
|
|
166
|
+
*
|
|
167
|
+
* @param view - the view's switches.
|
|
168
|
+
* @param switches - the catalogue's switches.
|
|
169
|
+
*/
|
|
170
|
+
export declare const isMoreContrastOf: (view: Pick<ViewState, "switches">, switches: readonly ViewSwitch[]) => boolean;
|
|
171
|
+
/**
|
|
172
|
+
* The language a view shows: the language switch's value, empty for the stories' own text.
|
|
173
|
+
*
|
|
174
|
+
* @param view - the view's switches.
|
|
175
|
+
* @param switches - the catalogue's switches.
|
|
176
|
+
*/
|
|
177
|
+
export declare const languageOf: (view: Pick<ViewState, "switches">, switches: readonly ViewSwitch[]) => string;
|
|
178
|
+
/**
|
|
179
|
+
* The values of the switches applied by code, by id: what the story reads as `context.globals`.
|
|
180
|
+
*
|
|
181
|
+
* @param view - the view's switches.
|
|
182
|
+
* @param switches - the catalogue's switches.
|
|
183
|
+
*/
|
|
184
|
+
export declare const codeGlobalsOf: (view: Pick<ViewState, "switches">, switches: readonly ViewSwitch[]) => Readonly<Record<string, string>>;
|
|
185
|
+
/**
|
|
186
|
+
* The address of a story's frame from a catalogue's address query, for a tool that does not know the catalogue's
|
|
187
|
+
* switches (`forgebook-shot`): every parameter but the shell's own is kept as written.
|
|
188
|
+
*
|
|
189
|
+
* @param frameUrl - the frame page (`frame.html`).
|
|
190
|
+
* @param id - the story's id.
|
|
191
|
+
* @param search - the catalogue's query (`theme=dark&lang=it`), with or without `?`.
|
|
192
|
+
*/
|
|
193
|
+
export declare const frameAddressOf: (frameUrl: string, id: string, search: string) => string;
|
|
194
|
+
//# sourceMappingURL=viewState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewState.d.ts","sourceRoot":"","sources":["../../src/viewState.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAiC,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAE/E;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC,gDAAgD;AAChD,eAAO,MAAM,cAAc,UAAU,CAAC;AAEtC,oEAAoE;AACpE,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;AAE7D,qHAAqH;AACrH,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,MAAM,EAAE,CAAC;AAE5C,sEAAsE;AACtE,eAAO,MAAM,gBAAgB,6BAA8B,CAAC;AAE5D,oHAAoH;AACpH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAAC;AAEzD,0FAA0F;AAC1F,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,wCAAwC;AACxC,MAAM,MAAM,QAAQ,GAAG,UAAU,CAAC;AAElC,4GAA4G;AAC5G,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1C,mCAAmC;AACnC,MAAM,MAAM,SAAS,G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