storybook-addon-dependency-previews 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/README.md +192 -0
- package/dist/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/addon/index.cjs +12 -0
- package/dist/addon/index.cjs.map +1 -0
- package/dist/addon/index.d.cts +5 -0
- package/dist/addon/index.d.mts +5 -0
- package/dist/addon/index.mjs +11 -0
- package/dist/addon/index.mjs.map +1 -0
- package/dist/addon/preset.cjs +8 -0
- package/dist/addon/preset.cjs.map +1 -0
- package/dist/addon/preset.d.cts +5 -0
- package/dist/addon/preset.d.mts +5 -0
- package/dist/addon/preset.mjs +6 -0
- package/dist/addon/preset.mjs.map +1 -0
- package/dist/addon/vitePlugin.cjs +26 -0
- package/dist/addon/vitePlugin.cjs.map +1 -0
- package/dist/addon/vitePlugin.d.cts +9 -0
- package/dist/addon/vitePlugin.d.mts +9 -0
- package/dist/addon/vitePlugin.mjs +24 -0
- package/dist/addon/vitePlugin.mjs.map +1 -0
- package/dist/blocks/DependencyPreviews.cjs +102 -0
- package/dist/blocks/DependencyPreviews.cjs.map +1 -0
- package/dist/blocks/DependencyPreviews.d.cts +7 -0
- package/dist/blocks/DependencyPreviews.d.mts +7 -0
- package/dist/blocks/DependencyPreviews.mjs +100 -0
- package/dist/blocks/DependencyPreviews.mjs.map +1 -0
- package/dist/blocks/DependencyPreviews.module.css +14 -0
- package/dist/blocks/index.cjs +1 -0
- package/dist/blocks/index.d.cts +1 -0
- package/dist/blocks/index.d.mts +1 -0
- package/dist/blocks/index.mjs +1 -0
- package/dist/cli/sb-deps.cjs +321 -0
- package/dist/cli/sb-deps.cjs.map +1 -0
- package/dist/cli/sb-deps.d.cts +1 -0
- package/dist/cli/sb-deps.d.mts +1 -0
- package/dist/cli/sb-deps.mjs +319 -0
- package/dist/cli/sb-deps.mjs.map +1 -0
- package/dist/cli/scripts/depcruise.config.cjs +38 -0
- package/dist/cli/scripts/depcruise.config.cjs.map +1 -0
- package/dist/cli/scripts/depcruise.config.d.cts +6 -0
- package/dist/cli/scripts/depcruise.config.d.mts +7 -0
- package/dist/cli/scripts/depcruise.config.mjs +37 -0
- package/dist/cli/scripts/depcruise.config.mjs.map +1 -0
- package/dist/cli/scripts/postprocess.cjs +106 -0
- package/dist/cli/scripts/postprocess.cjs.map +1 -0
- package/dist/cli/scripts/postprocess.d.cts +1 -0
- package/dist/cli/scripts/postprocess.d.mts +1 -0
- package/dist/cli/scripts/postprocess.mjs +106 -0
- package/dist/cli/scripts/postprocess.mjs.map +1 -0
- package/dist/components/ComponentSourceLink.cjs +42 -0
- package/dist/components/ComponentSourceLink.cjs.map +1 -0
- package/dist/components/ComponentSourceLink.mjs +40 -0
- package/dist/components/ComponentSourceLink.mjs.map +1 -0
- package/dist/components/ComponentSourceLink.module.css +5 -0
- package/dist/components/CopyButton.cjs +112 -0
- package/dist/components/CopyButton.cjs.map +1 -0
- package/dist/components/CopyButton.mjs +110 -0
- package/dist/components/CopyButton.mjs.map +1 -0
- package/dist/components/CopyButton.module.css +76 -0
- package/dist/components/Expandable.cjs +51 -0
- package/dist/components/Expandable.cjs.map +1 -0
- package/dist/components/Expandable.mjs +49 -0
- package/dist/components/Expandable.mjs.map +1 -0
- package/dist/components/Expandable.module.css +110 -0
- package/dist/components/FullParityStory.cjs +47 -0
- package/dist/components/FullParityStory.cjs.map +1 -0
- package/dist/components/FullParityStory.mjs +44 -0
- package/dist/components/FullParityStory.mjs.map +1 -0
- package/dist/components/PathCopyMolecule.cjs +28 -0
- package/dist/components/PathCopyMolecule.cjs.map +1 -0
- package/dist/components/PathCopyMolecule.mjs +26 -0
- package/dist/components/PathCopyMolecule.mjs.map +1 -0
- package/dist/components/PathCopyMolecule.module.css +14 -0
- package/dist/components/PrimaryPreview.cjs +35 -0
- package/dist/components/PrimaryPreview.cjs.map +1 -0
- package/dist/components/PrimaryPreview.mjs +34 -0
- package/dist/components/PrimaryPreview.mjs.map +1 -0
- package/dist/components/SbHeading.cjs +18 -0
- package/dist/components/SbHeading.cjs.map +1 -0
- package/dist/components/SbHeading.mjs +16 -0
- package/dist/components/SbHeading.mjs.map +1 -0
- package/dist/components/SbHeading.module.css +23 -0
- package/dist/components/StoryLink.cjs +45 -0
- package/dist/components/StoryLink.cjs.map +1 -0
- package/dist/components/StoryLink.mjs +43 -0
- package/dist/components/StoryLink.mjs.map +1 -0
- package/dist/components/StoryLink.module.css +13 -0
- package/dist/components/TooltipTrigger.cjs +100 -0
- package/dist/components/TooltipTrigger.cjs.map +1 -0
- package/dist/components/TooltipTrigger.mjs +98 -0
- package/dist/components/TooltipTrigger.mjs.map +1 -0
- package/dist/components/TooltipTrigger.module.css +62 -0
- package/dist/components/icons/ArrowToRectangleIcon.cjs +19 -0
- package/dist/components/icons/ArrowToRectangleIcon.cjs.map +1 -0
- package/dist/components/icons/ArrowToRectangleIcon.mjs +18 -0
- package/dist/components/icons/ArrowToRectangleIcon.mjs.map +1 -0
- package/dist/components/icons/BuildIcon.cjs +19 -0
- package/dist/components/icons/BuildIcon.cjs.map +1 -0
- package/dist/components/icons/BuildIcon.mjs +18 -0
- package/dist/components/icons/BuildIcon.mjs.map +1 -0
- package/dist/components/icons/CopyIcon.cjs +19 -0
- package/dist/components/icons/CopyIcon.cjs.map +1 -0
- package/dist/components/icons/CopyIcon.mjs +18 -0
- package/dist/components/icons/CopyIcon.mjs.map +1 -0
- package/dist/components/icons/CubeIcon.cjs +19 -0
- package/dist/components/icons/CubeIcon.cjs.map +1 -0
- package/dist/components/icons/CubeIcon.mjs +18 -0
- package/dist/components/icons/CubeIcon.mjs.map +1 -0
- package/dist/components/icons/DoubleChevronDown.cjs +19 -0
- package/dist/components/icons/DoubleChevronDown.cjs.map +1 -0
- package/dist/components/icons/DoubleChevronDown.mjs +18 -0
- package/dist/components/icons/DoubleChevronDown.mjs.map +1 -0
- package/dist/components/icons/ExternalLinkIcon.cjs +19 -0
- package/dist/components/icons/ExternalLinkIcon.cjs.map +1 -0
- package/dist/components/icons/ExternalLinkIcon.mjs +18 -0
- package/dist/components/icons/ExternalLinkIcon.mjs.map +1 -0
- package/dist/components/icons/EyeOpen.cjs +23 -0
- package/dist/components/icons/EyeOpen.cjs.map +1 -0
- package/dist/components/icons/EyeOpen.mjs +22 -0
- package/dist/components/icons/EyeOpen.mjs.map +1 -0
- package/dist/components/icons/LoadingRipples.cjs +79 -0
- package/dist/components/icons/LoadingRipples.cjs.map +1 -0
- package/dist/components/icons/LoadingRipples.mjs +78 -0
- package/dist/components/icons/LoadingRipples.mjs.map +1 -0
- package/dist/components/icons/SquaresPlus.cjs +19 -0
- package/dist/components/icons/SquaresPlus.cjs.map +1 -0
- package/dist/components/icons/SquaresPlus.mjs +18 -0
- package/dist/components/icons/SquaresPlus.mjs.map +1 -0
- package/dist/components/icons/Svg.cjs +37 -0
- package/dist/components/icons/Svg.cjs.map +1 -0
- package/dist/components/icons/Svg.mjs +36 -0
- package/dist/components/icons/Svg.mjs.map +1 -0
- package/dist/components/icons/X.cjs +19 -0
- package/dist/components/icons/X.cjs.map +1 -0
- package/dist/components/icons/X.mjs +18 -0
- package/dist/components/icons/X.mjs.map +1 -0
- package/dist/constants.cjs +9 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.mjs +7 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/hooks/useDependencyGraph.cjs +63 -0
- package/dist/hooks/useDependencyGraph.cjs.map +1 -0
- package/dist/hooks/useDependencyGraph.mjs +60 -0
- package/dist/hooks/useDependencyGraph.mjs.map +1 -0
- package/dist/hooks/useDynamicStory.cjs +83 -0
- package/dist/hooks/useDynamicStory.cjs.map +1 -0
- package/dist/hooks/useDynamicStory.mjs +82 -0
- package/dist/hooks/useDynamicStory.mjs.map +1 -0
- package/dist/hooks/useStoryParams.cjs +17 -0
- package/dist/hooks/useStoryParams.cjs.map +1 -0
- package/dist/hooks/useStoryParams.mjs +16 -0
- package/dist/hooks/useStoryParams.mjs.map +1 -0
- package/dist/index.cjs +15 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +9 -0
- package/dist/manager.cjs +22 -0
- package/dist/manager.cjs.map +1 -0
- package/dist/manager.d.cts +1 -0
- package/dist/manager.d.mts +1 -0
- package/dist/manager.mjs +21 -0
- package/dist/manager.mjs.map +1 -0
- package/dist/panels/DefaultAutoDocsLayout.cjs +24 -0
- package/dist/panels/DefaultAutoDocsLayout.cjs.map +1 -0
- package/dist/panels/DefaultAutoDocsLayout.d.cts +10 -0
- package/dist/panels/DefaultAutoDocsLayout.d.mts +10 -0
- package/dist/panels/DefaultAutoDocsLayout.mjs +22 -0
- package/dist/panels/DefaultAutoDocsLayout.mjs.map +1 -0
- package/dist/panels/GraphView.cjs +78 -0
- package/dist/panels/GraphView.cjs.map +1 -0
- package/dist/panels/GraphView.d.cts +7 -0
- package/dist/panels/GraphView.d.mts +7 -0
- package/dist/panels/GraphView.mjs +77 -0
- package/dist/panels/GraphView.mjs.map +1 -0
- package/dist/panels/index.cjs +3 -0
- package/dist/panels/index.d.cts +3 -0
- package/dist/panels/index.d.mts +3 -0
- package/dist/panels/index.mjs +3 -0
- package/dist/preview.cjs +23 -0
- package/dist/preview.cjs.map +1 -0
- package/dist/preview.d.cts +9 -0
- package/dist/preview.d.mts +10 -0
- package/dist/preview.mjs +21 -0
- package/dist/preview.mjs.map +1 -0
- package/dist/types.cjs +0 -0
- package/dist/types.d.cts +104 -0
- package/dist/types.d.mts +104 -0
- package/dist/types.mjs +0 -0
- package/package.json +94 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Storybook Add On - Dependency Previews
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
## What is this?
|
|
6
|
+
|
|
7
|
+
> **This plugin is built for Storybook 10**
|
|
8
|
+
|
|
9
|
+
A plugin for [Storybook](https://storybook.js.org/) that shows the full dependency tree in both directions (built with and used by) the components in your application.
|
|
10
|
+
|
|
11
|
+
This is what you will see in Storybook after Dependency Previews have been installed and configured:
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
The below image demonstrates what you will see when you open up some of the dependency segments:
|
|
16
|
+
|
|
17
|
+

|
|
18
|
+
|
|
19
|
+
See the dependency previews add on in action at the [Storybook addon demo site](https://dependency-previews-storybook.netlify.app/).
|
|
20
|
+
|
|
21
|
+
You can also [visit the example website](https://dependency-previews-demo-site.netlify.app/) that the Storybook demo is built for.
|
|
22
|
+
|
|
23
|
+
<!-- TODO: Provide a video/gif of the addon in action -->
|
|
24
|
+
|
|
25
|
+
## Installation guide
|
|
26
|
+
|
|
27
|
+
### Package download
|
|
28
|
+
|
|
29
|
+
First you will need to install the plugin via npm
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
npm install storybook-addon-dependency-previews
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<details>
|
|
36
|
+
<summary>Other package managers</summary>
|
|
37
|
+
<p><pre><code>pnpm add storybook-addon-dependency-previews</code></pre></p>
|
|
38
|
+
<p><pre><code>yarn add storybook-addon-dependency-previews</code></pre></p>
|
|
39
|
+
<p><pre><code>bun add storybook-addon-dependency-previews</code></pre></p>
|
|
40
|
+
<p><pre><code>deno add npm:storybook-addon-dependency-previews</code></pre></p>
|
|
41
|
+
</details>
|
|
42
|
+
|
|
43
|
+
### Register the add-on
|
|
44
|
+
|
|
45
|
+
From your root folder, open your `.storybook/main.ts` file.
|
|
46
|
+
|
|
47
|
+
Edit the `main.ts` to contain the following values or copy/paste the below to replace the full contents of the main.ts file.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { StorybookConfig } from '@storybook/react-vite'
|
|
51
|
+
|
|
52
|
+
const config: StorybookConfig = {
|
|
53
|
+
// tells storybook what files to look for when it goes searching for story files
|
|
54
|
+
stories: ['../src/**/*.stories.@(ts|tsx|mdx|svelte|vue)'],
|
|
55
|
+
addons: [
|
|
56
|
+
// autodocs is required for this addon to work
|
|
57
|
+
'@storybook/addon-docs',
|
|
58
|
+
// the storybook dependency previews addon registration
|
|
59
|
+
'storybook-addon-dependency-previews/addon',
|
|
60
|
+
],
|
|
61
|
+
framework: {
|
|
62
|
+
// The framework that storybook uses to read story components
|
|
63
|
+
// Use @storybook/*-vite for your framework of choice
|
|
64
|
+
name: '@storybook/react-vite',
|
|
65
|
+
options: {},
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export default config
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Bare minimum storybook story example
|
|
73
|
+
|
|
74
|
+
Get a story ready so you have something to test with.
|
|
75
|
+
|
|
76
|
+
Below is the bare minimum needed to generate a viable story that is compatible with the add-on.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import type { Meta } from '@storybook/react-vite'
|
|
80
|
+
import { ComponentName } from './ComponentName'
|
|
81
|
+
|
|
82
|
+
const meta: Meta<typeof ComponentName> = {
|
|
83
|
+
// You can use spaces here to make the title of the story page more human readable
|
|
84
|
+
title: 'Component Name',
|
|
85
|
+
component: ComponentName,
|
|
86
|
+
// autodocs tag is required
|
|
87
|
+
tags: ['autodocs'],
|
|
88
|
+
// The `__filePath` property must be applied to every story file
|
|
89
|
+
// for the addon to track dependencies effectively
|
|
90
|
+
// `import.meta.url` is a Vite specific value that automatically generates the path for you
|
|
91
|
+
parameters: {
|
|
92
|
+
__filePath: import.meta.url,
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default meta
|
|
97
|
+
|
|
98
|
+
type Story = StoryObj<typeof meta>
|
|
99
|
+
|
|
100
|
+
export const Primary: Story = {
|
|
101
|
+
args: {},
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### package.json scripts
|
|
106
|
+
|
|
107
|
+
You will need the following scripts in your `package.json` file:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
// package.json
|
|
111
|
+
{
|
|
112
|
+
...
|
|
113
|
+
"scripts": {
|
|
114
|
+
...
|
|
115
|
+
"sb": "sb-deps --watch --run-storybook",
|
|
116
|
+
"sb:build": "sb-deps && storybook build",
|
|
117
|
+
"sb:deps": "sb-deps",
|
|
118
|
+
"sb:alt-port": "sb-deps --watch --run-storybook --sb-port 7020"
|
|
119
|
+
}
|
|
120
|
+
...
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Don't run any of these yet, you are not finished with the installation.
|
|
125
|
+
|
|
126
|
+
`npm run sb` will run storybook in watch mode. It will update the dependency-previews.json file whenever a story file changes, is added, or removed. Use this instead of the `storybook` command to take advantage of automatic dependency tracking while you work and auto scaffolding of stories when new story files are created.
|
|
127
|
+
|
|
128
|
+
`npm run sb:build` will do a one off compile of your storybook website
|
|
129
|
+
|
|
130
|
+
`npm run sb:deps` will generate a fresh dependency-previews.json on demand
|
|
131
|
+
|
|
132
|
+
`npm run sb:alt-port` (optional) will run storybook in watch mode and run it using a specific port number.
|
|
133
|
+
|
|
134
|
+
### Create the preview.tsx file
|
|
135
|
+
|
|
136
|
+
First run `npm run sb:deps` to generate a fresh `dependency-previews.json` file in the `.storybook` folder.
|
|
137
|
+
|
|
138
|
+
Make sure that the `"resolveJsonModule"` tsConfig.json setting is set to `true` to import this file.
|
|
139
|
+
|
|
140
|
+
Now create a `preview.tsx` file in the `.storybook` folder with the following content:
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
/// <reference types="vite/client" />
|
|
144
|
+
|
|
145
|
+
import * as React from 'react'
|
|
146
|
+
import {
|
|
147
|
+
defaultPreviewParameters,
|
|
148
|
+
dependencyPreviewDecorators,
|
|
149
|
+
type StorybookPreviewConfig,
|
|
150
|
+
} from 'storybook-addon-dependency-previews'
|
|
151
|
+
|
|
152
|
+
// Import the generated dependency-previews.json file
|
|
153
|
+
import dependenciesJson from './dependency-previews.json'
|
|
154
|
+
|
|
155
|
+
// Global styles are imported here
|
|
156
|
+
import '../src/styles.css'
|
|
157
|
+
|
|
158
|
+
const previewConfig: StorybookPreviewConfig = {
|
|
159
|
+
decorators: [...dependencyPreviewDecorators],
|
|
160
|
+
parameters: {
|
|
161
|
+
...defaultPreviewParameters,
|
|
162
|
+
dependencyPreviews: {
|
|
163
|
+
dependenciesJson,
|
|
164
|
+
storyModules: import.meta.glob(
|
|
165
|
+
'/src/**/*.stories.@(tsx|ts|jsx|js|svelte)',
|
|
166
|
+
{ eager: false },
|
|
167
|
+
),
|
|
168
|
+
// Replace this with the base url of your git repository
|
|
169
|
+
// This enables the addon to link to the source code of the component
|
|
170
|
+
sourceRootUrl:
|
|
171
|
+
'https://github.com/Dan503/storybook-addon-dependency-previews/blob/main/example-site',
|
|
172
|
+
// This allows Source File Path to open the
|
|
173
|
+
// component file directly in VS Code when
|
|
174
|
+
// running in a local host environment.
|
|
175
|
+
// `import.meta.url` is a Vite specific feature
|
|
176
|
+
projectRootPath: new URL('..', import.meta.url).pathname,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export default previewConfig
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Run it!
|
|
185
|
+
|
|
186
|
+
You should be all set now.
|
|
187
|
+
|
|
188
|
+
Try running `npm run sb` to boot up storybook, leave it running as you work.
|
|
189
|
+
|
|
190
|
+
As you create new component files, the component will be auto-scaffolded for you and a matching story file will be created for it automatically. The dependency previews json file will also be auto-updated.
|
|
191
|
+
|
|
192
|
+
This workflow allows you to focus on what matters instead of having to waste time writing lots of boilerplate code every time you want to create a new component.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_addon_vitePlugin = require('./vitePlugin.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/addon/index.ts
|
|
5
|
+
async function viteFinal(config) {
|
|
6
|
+
config.plugins = [...config.plugins ?? [], require_addon_vitePlugin.sbDepsVitePlugin()];
|
|
7
|
+
return config;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.viteFinal = viteFinal;
|
|
12
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["sbDepsVitePlugin"],"sources":["../../src/addon/index.ts"],"sourcesContent":["import { sbDepsVitePlugin } from './vitePlugin'\n\nexport async function viteFinal(config: any) {\n\tconfig.plugins = [...(config.plugins ?? []), sbDepsVitePlugin()]\n\treturn config\n}\n"],"mappings":";;;;AAEA,eAAsB,UAAU,QAAa;AAC5C,QAAO,UAAU,CAAC,GAAI,OAAO,WAAW,EAAE,EAAGA,2CAAkB,CAAC;AAChE,QAAO"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { sbDepsVitePlugin } from "./vitePlugin.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/addon/index.ts
|
|
4
|
+
async function viteFinal(config) {
|
|
5
|
+
config.plugins = [...config.plugins ?? [], sbDepsVitePlugin()];
|
|
6
|
+
return config;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { viteFinal };
|
|
11
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/addon/index.ts"],"sourcesContent":["import { sbDepsVitePlugin } from './vitePlugin'\n\nexport async function viteFinal(config: any) {\n\tconfig.plugins = [...(config.plugins ?? []), sbDepsVitePlugin()]\n\treturn config\n}\n"],"mappings":";;;AAEA,eAAsB,UAAU,QAAa;AAC5C,QAAO,UAAU,CAAC,GAAI,OAAO,WAAW,EAAE,EAAG,kBAAkB,CAAC;AAChE,QAAO"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.cjs","names":[],"sources":["../../src/addon/preset.ts"],"sourcesContent":["export const addons: Array<string> = [\n\t'@storybook/addon-docs',\n\t'@storybook/addon-links',\n]\n"],"mappings":";;;AAAA,MAAa,SAAwB,CACpC,yBACA,yBACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset.mjs","names":[],"sources":["../../src/addon/preset.ts"],"sourcesContent":["export const addons: Array<string> = [\n\t'@storybook/addon-docs',\n\t'@storybook/addon-links',\n]\n"],"mappings":";AAAA,MAAa,SAAwB,CACpC,yBACA,yBACA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
|
|
6
|
+
//#region src/addon/vitePlugin.ts
|
|
7
|
+
function sbDepsVitePlugin() {
|
|
8
|
+
const virtId = "virtual:dependency-previews-json";
|
|
9
|
+
const resolved = "\0" + virtId;
|
|
10
|
+
return {
|
|
11
|
+
name: "sb-deps",
|
|
12
|
+
resolveId(id) {
|
|
13
|
+
return id === virtId ? resolved : null;
|
|
14
|
+
},
|
|
15
|
+
load(id) {
|
|
16
|
+
if (id !== resolved) return null;
|
|
17
|
+
const jsonPath = (0, node_path.resolve)(process.cwd(), ".storybook/dependency-previews.json");
|
|
18
|
+
const json = (0, node_fs.existsSync)(jsonPath) ? (0, node_fs.readFileSync)(jsonPath, "utf8") : "{}";
|
|
19
|
+
return `export default ${json};`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.sbDepsVitePlugin = sbDepsVitePlugin;
|
|
26
|
+
//# sourceMappingURL=vitePlugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitePlugin.cjs","names":[],"sources":["../../src/addon/vitePlugin.ts"],"sourcesContent":["import { readFileSync, existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nexport function sbDepsVitePlugin() {\n\tconst virtId = 'virtual:dependency-previews-json'\n\tconst resolved = '\\0' + virtId\n\treturn {\n\t\tname: 'sb-deps',\n\t\tresolveId(id: string) {\n\t\t\treturn id === virtId ? resolved : null\n\t\t},\n\t\tload(id: string) {\n\t\t\tif (id !== resolved) return null\n\t\t\tconst jsonPath = resolve(\n\t\t\t\tprocess.cwd(),\n\t\t\t\t'.storybook/dependency-previews.json',\n\t\t\t)\n\t\t\tconst json = existsSync(jsonPath)\n\t\t\t\t? readFileSync(jsonPath, 'utf8')\n\t\t\t\t: '{}'\n\t\t\treturn `export default ${json};`\n\t\t},\n\t}\n}\n"],"mappings":";;;;;;AAGA,SAAgB,mBAAmB;CAClC,MAAM,SAAS;CACf,MAAM,WAAW,OAAO;AACxB,QAAO;EACN,MAAM;EACN,UAAU,IAAY;AACrB,UAAO,OAAO,SAAS,WAAW;;EAEnC,KAAK,IAAY;AAChB,OAAI,OAAO,SAAU,QAAO;GAC5B,MAAM,kCACL,QAAQ,KAAK,EACb,sCACA;GACD,MAAM,+BAAkB,SAAS,6BACjB,UAAU,OAAO,GAC9B;AACH,UAAO,kBAAkB,KAAK;;EAE/B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/addon/vitePlugin.ts
|
|
5
|
+
function sbDepsVitePlugin() {
|
|
6
|
+
const virtId = "virtual:dependency-previews-json";
|
|
7
|
+
const resolved = "\0" + virtId;
|
|
8
|
+
return {
|
|
9
|
+
name: "sb-deps",
|
|
10
|
+
resolveId(id) {
|
|
11
|
+
return id === virtId ? resolved : null;
|
|
12
|
+
},
|
|
13
|
+
load(id) {
|
|
14
|
+
if (id !== resolved) return null;
|
|
15
|
+
const jsonPath = resolve(process.cwd(), ".storybook/dependency-previews.json");
|
|
16
|
+
const json = existsSync(jsonPath) ? readFileSync(jsonPath, "utf8") : "{}";
|
|
17
|
+
return `export default ${json};`;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { sbDepsVitePlugin };
|
|
24
|
+
//# sourceMappingURL=vitePlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitePlugin.mjs","names":[],"sources":["../../src/addon/vitePlugin.ts"],"sourcesContent":["import { readFileSync, existsSync } from 'node:fs'\nimport { resolve } from 'node:path'\n\nexport function sbDepsVitePlugin() {\n\tconst virtId = 'virtual:dependency-previews-json'\n\tconst resolved = '\\0' + virtId\n\treturn {\n\t\tname: 'sb-deps',\n\t\tresolveId(id: string) {\n\t\t\treturn id === virtId ? resolved : null\n\t\t},\n\t\tload(id: string) {\n\t\t\tif (id !== resolved) return null\n\t\t\tconst jsonPath = resolve(\n\t\t\t\tprocess.cwd(),\n\t\t\t\t'.storybook/dependency-previews.json',\n\t\t\t)\n\t\t\tconst json = existsSync(jsonPath)\n\t\t\t\t? readFileSync(jsonPath, 'utf8')\n\t\t\t\t: '{}'\n\t\t\treturn `export default ${json};`\n\t\t},\n\t}\n}\n"],"mappings":";;;;AAGA,SAAgB,mBAAmB;CAClC,MAAM,SAAS;CACf,MAAM,WAAW,OAAO;AACxB,QAAO;EACN,MAAM;EACN,UAAU,IAAY;AACrB,UAAO,OAAO,SAAS,WAAW;;EAEnC,KAAK,IAAY;AAChB,OAAI,OAAO,SAAU,QAAO;GAC5B,MAAM,WAAW,QAChB,QAAQ,KAAK,EACb,sCACA;GACD,MAAM,OAAO,WAAW,SAAS,GAC9B,aAAa,UAAU,OAAO,GAC9B;AACH,UAAO,kBAAkB,KAAK;;EAE/B"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_PrimaryPreview = require('../components/PrimaryPreview.cjs');
|
|
3
|
+
const require_StoryLink = require('../components/StoryLink.cjs');
|
|
4
|
+
const require_useDependencyGraph = require('../hooks/useDependencyGraph.cjs');
|
|
5
|
+
const require_ComponentSourceLink = require('../components/ComponentSourceLink.cjs');
|
|
6
|
+
const require_Expandable = require('../components/Expandable.cjs');
|
|
7
|
+
const require_BuildIcon = require('../components/icons/BuildIcon.cjs');
|
|
8
|
+
const require_EyeOpen = require('../components/icons/EyeOpen.cjs');
|
|
9
|
+
const require_SquaresPlus = require('../components/icons/SquaresPlus.cjs');
|
|
10
|
+
const require_ArrowToRectangleIcon = require('../components/icons/ArrowToRectangleIcon.cjs');
|
|
11
|
+
const require_CubeIcon = require('../components/icons/CubeIcon.cjs');
|
|
12
|
+
const require_PathCopyMolecule = require('../components/PathCopyMolecule.cjs');
|
|
13
|
+
const require_SbHeading = require('../components/SbHeading.cjs');
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
let src_blocks_DependencyPreviews_module_css = require("./DependencyPreviews.module.css");
|
|
16
|
+
src_blocks_DependencyPreviews_module_css = require_runtime.__toESM(src_blocks_DependencyPreviews_module_css);
|
|
17
|
+
|
|
18
|
+
//#region src/blocks/DependencyPreviews.tsx
|
|
19
|
+
function DependencyPreviews() {
|
|
20
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_useDependencyGraph.DependencyGraphProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TopLevelDependencyPreviews, {}) });
|
|
21
|
+
}
|
|
22
|
+
function TopLevelDependencyPreviews() {
|
|
23
|
+
const { node } = require_useDependencyGraph.useDependencyGraph();
|
|
24
|
+
if (!node) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: "No dependency previews for this component." });
|
|
25
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
26
|
+
className: src_blocks_DependencyPreviews_module_css.default.topLevelWrapper,
|
|
27
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SbHeading.SbHeading, { children: "Dependency previews" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DepsPreviewContent, {
|
|
28
|
+
storyInfo: node,
|
|
29
|
+
enablePreview: false
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function DepsPreviewContent({ storyInfo, enablePreview = true }) {
|
|
34
|
+
const { graph } = require_useDependencyGraph.useDependencyGraph();
|
|
35
|
+
const { builtWith, usedIn } = graph[storyInfo.componentPath];
|
|
36
|
+
const filteredBuiltWith = require_useDependencyGraph.filterOutStoryAndNonComponentFiles(builtWith);
|
|
37
|
+
const filteredUsedIn = require_useDependencyGraph.filterOutStoryAndNonComponentFiles(usedIn);
|
|
38
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
39
|
+
enablePreview && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Expandable.Expandable, {
|
|
40
|
+
Header: `Preview ${storyInfo.storyTitle} component`,
|
|
41
|
+
Icon: require_EyeOpen.EyeOpen,
|
|
42
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PrimaryPreview.PrimaryPreview, { storyInfo })
|
|
43
|
+
}),
|
|
44
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Expandable.Expandable, {
|
|
45
|
+
Header: `Paths to ${storyInfo.storyTitle} component`,
|
|
46
|
+
Icon: require_ArrowToRectangleIcon.ArrowToRectangle,
|
|
47
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
48
|
+
className: src_blocks_DependencyPreviews_module_css.default.pathData,
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PathCopyMolecule.PathCopyMolecule, {
|
|
51
|
+
label: "Source File Path",
|
|
52
|
+
copyContent: storyInfo.componentPath,
|
|
53
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_ComponentSourceLink.ComponentSourceLink, { storyInfo })
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PathCopyMolecule.PathCopyMolecule, {
|
|
56
|
+
label: "Story Title Path",
|
|
57
|
+
copyContent: storyInfo.storyTitlePath,
|
|
58
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_StoryLink.StoryLink, {
|
|
59
|
+
info: storyInfo,
|
|
60
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { dangerouslySetInnerHTML: { __html: storyInfo.storyTitlePath.replaceAll("/", "/<wbr/>") } })
|
|
61
|
+
})
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_PathCopyMolecule.PathCopyMolecule, {
|
|
64
|
+
label: "Story Page ID",
|
|
65
|
+
copyContent: storyInfo.storyId,
|
|
66
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_StoryLink.StoryLink, {
|
|
67
|
+
info: storyInfo,
|
|
68
|
+
children: storyInfo.storyId
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
})
|
|
73
|
+
}),
|
|
74
|
+
filteredBuiltWith.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Expandable.Expandable, {
|
|
75
|
+
Header: `Built with ${filteredBuiltWith.length} component${plural(filteredBuiltWith)}`,
|
|
76
|
+
Icon: require_BuildIcon.BuildIcon,
|
|
77
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: require_useDependencyGraph.filterOutStoryAndNonComponentFiles(builtWith).map((info) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DepsPreviewItem, { storyInfo: info }, info.componentPath)) })
|
|
78
|
+
}),
|
|
79
|
+
filteredUsedIn.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Expandable.Expandable, {
|
|
80
|
+
Header: `Used in ${filteredUsedIn.length} component${plural(filteredUsedIn)}`,
|
|
81
|
+
Icon: require_SquaresPlus.SquaresPlus,
|
|
82
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", { children: require_useDependencyGraph.filterOutStoryAndNonComponentFiles(usedIn).map((info) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DepsPreviewItem, { storyInfo: info }, info.componentPath)) })
|
|
83
|
+
})
|
|
84
|
+
] });
|
|
85
|
+
}
|
|
86
|
+
function DepsPreviewItem({ storyInfo }) {
|
|
87
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: storyInfo.storyId ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Expandable.Expandable, {
|
|
88
|
+
Icon: require_CubeIcon.CubeIcon,
|
|
89
|
+
Header: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_StoryLink.StoryLink, {
|
|
90
|
+
info: storyInfo,
|
|
91
|
+
tooltipPosition: "right"
|
|
92
|
+
}),
|
|
93
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DepsPreviewContent, { storyInfo })
|
|
94
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_StoryLink.StoryLink, { info: storyInfo }) }, storyInfo.componentPath);
|
|
95
|
+
}
|
|
96
|
+
function plural(arr) {
|
|
97
|
+
return arr.length === 1 ? "" : "s";
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
exports.DependencyPreviews = DependencyPreviews;
|
|
102
|
+
//# sourceMappingURL=DependencyPreviews.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyPreviews.cjs","names":["DependencyGraphProvider","useDependencyGraph","s","SbHeading","filterOutStoryAndNonComponentFiles","Expandable","EyeOpen","PrimaryPreview","ArrowToRectangle","PathCopyMolecule","ComponentSourceLink","StoryLink","BuildIcon","SquaresPlus","CubeIcon"],"sources":["../../src/blocks/DependencyPreviews.tsx"],"sourcesContent":["import { PrimaryPreview } from '../components/PrimaryPreview'\nimport { StoryLink } from '../components/StoryLink'\nimport {\n\tDependencyGraphProvider,\n\tfilterOutStoryAndNonComponentFiles,\n\tuseDependencyGraph,\n} from '../hooks/useDependencyGraph'\nimport type { StoryInfo } from '../types'\n\nimport { ComponentSourceLink } from '../components/ComponentSourceLink'\nimport { Expandable } from '../components/Expandable'\nimport { BuildIcon } from '../components/icons/BuildIcon'\nimport { EyeOpen } from '../components/icons/EyeOpen'\nimport { SquaresPlus } from '../components/icons/SquaresPlus'\n\nimport { ArrowToRectangle } from '../components/icons/ArrowToRectangleIcon'\nimport { CubeIcon } from '../components/icons/CubeIcon'\nimport { PathCopyMolecule } from '../components/PathCopyMolecule'\nimport { SbHeading } from '../components/SbHeading'\nimport s from './DependencyPreviews.module.css'\n\nexport function DependencyPreviews() {\n\treturn (\n\t\t<DependencyGraphProvider>\n\t\t\t<TopLevelDependencyPreviews />\n\t\t</DependencyGraphProvider>\n\t)\n}\n\nfunction TopLevelDependencyPreviews() {\n\tconst { node } = useDependencyGraph()\n\tif (!node) return <div>No dependency previews for this component.</div>\n\n\treturn (\n\t\t<div className={s.topLevelWrapper}>\n\t\t\t<SbHeading>Dependency previews</SbHeading>\n\t\t\t<DepsPreviewContent storyInfo={node} enablePreview={false} />\n\t\t</div>\n\t)\n}\n\ninterface PropsForDepsPreviewContent {\n\tstoryInfo: StoryInfo\n\tenablePreview?: boolean\n}\nfunction DepsPreviewContent({\n\tstoryInfo,\n\tenablePreview = true,\n}: PropsForDepsPreviewContent) {\n\tconst { graph } = useDependencyGraph()\n\tconst { builtWith, usedIn } = graph![storyInfo.componentPath]\n\tconst filteredBuiltWith = filterOutStoryAndNonComponentFiles(builtWith)\n\tconst filteredUsedIn = filterOutStoryAndNonComponentFiles(usedIn)\n\n\treturn (\n\t\t<div>\n\t\t\t{enablePreview && (\n\t\t\t\t<Expandable\n\t\t\t\t\tHeader={`Preview ${storyInfo.storyTitle} component`}\n\t\t\t\t\tIcon={EyeOpen}\n\t\t\t\t>\n\t\t\t\t\t<PrimaryPreview storyInfo={storyInfo} />\n\t\t\t\t</Expandable>\n\t\t\t)}\n\n\t\t\t<Expandable\n\t\t\t\tHeader={`Paths to ${storyInfo.storyTitle} component`}\n\t\t\t\tIcon={ArrowToRectangle}\n\t\t\t>\n\t\t\t\t<div className={s.pathData}>\n\t\t\t\t\t<PathCopyMolecule\n\t\t\t\t\t\tlabel=\"Source File Path\"\n\t\t\t\t\t\tcopyContent={storyInfo.componentPath}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ComponentSourceLink storyInfo={storyInfo} />\n\t\t\t\t\t</PathCopyMolecule>\n\n\t\t\t\t\t<PathCopyMolecule\n\t\t\t\t\t\tlabel=\"Story Title Path\"\n\t\t\t\t\t\tcopyContent={storyInfo.storyTitlePath!}\n\t\t\t\t\t>\n\t\t\t\t\t\t<StoryLink info={storyInfo}>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t\t\t// allow line breaks on slashes\n\t\t\t\t\t\t\t\t\t__html: storyInfo.storyTitlePath!.replaceAll(\n\t\t\t\t\t\t\t\t\t\t'/',\n\t\t\t\t\t\t\t\t\t\t'/<wbr/>',\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</StoryLink>\n\t\t\t\t\t</PathCopyMolecule>\n\n\t\t\t\t\t<PathCopyMolecule\n\t\t\t\t\t\tlabel=\"Story Page ID\"\n\t\t\t\t\t\tcopyContent={storyInfo.storyId!}\n\t\t\t\t\t>\n\t\t\t\t\t\t<StoryLink info={storyInfo}>\n\t\t\t\t\t\t\t{storyInfo.storyId}\n\t\t\t\t\t\t</StoryLink>\n\t\t\t\t\t</PathCopyMolecule>\n\t\t\t\t</div>\n\t\t\t</Expandable>\n\n\t\t\t{filteredBuiltWith.length > 0 && (\n\t\t\t\t<Expandable\n\t\t\t\t\tHeader={`Built with ${\n\t\t\t\t\t\tfilteredBuiltWith.length\n\t\t\t\t\t} component${plural(filteredBuiltWith)}`}\n\t\t\t\t\tIcon={BuildIcon}\n\t\t\t\t>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{filterOutStoryAndNonComponentFiles(builtWith).map(\n\t\t\t\t\t\t\t(info) => (\n\t\t\t\t\t\t\t\t<DepsPreviewItem\n\t\t\t\t\t\t\t\t\tstoryInfo={info}\n\t\t\t\t\t\t\t\t\tkey={info.componentPath}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)}\n\t\t\t\t\t</ul>\n\t\t\t\t</Expandable>\n\t\t\t)}\n\t\t\t{filteredUsedIn.length > 0 && (\n\t\t\t\t<Expandable\n\t\t\t\t\tHeader={`Used in ${filteredUsedIn.length} component${plural(\n\t\t\t\t\t\tfilteredUsedIn,\n\t\t\t\t\t)}`}\n\t\t\t\t\tIcon={SquaresPlus}\n\t\t\t\t>\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t{filterOutStoryAndNonComponentFiles(usedIn).map(\n\t\t\t\t\t\t\t(info) => (\n\t\t\t\t\t\t\t\t<DepsPreviewItem\n\t\t\t\t\t\t\t\t\tstoryInfo={info}\n\t\t\t\t\t\t\t\t\tkey={info.componentPath}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)}\n\t\t\t\t\t</ul>\n\t\t\t\t</Expandable>\n\t\t\t)}\n\t\t</div>\n\t)\n}\n\ninterface PropsForDepsPreviewItem {\n\tstoryInfo: StoryInfo\n}\n\nfunction DepsPreviewItem({ storyInfo }: PropsForDepsPreviewItem) {\n\treturn (\n\t\t<li key={storyInfo.componentPath}>\n\t\t\t{storyInfo.storyId ? (\n\t\t\t\t<Expandable\n\t\t\t\t\tIcon={CubeIcon}\n\t\t\t\t\tHeader={\n\t\t\t\t\t\t<StoryLink info={storyInfo} tooltipPosition=\"right\" />\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<DepsPreviewContent storyInfo={storyInfo} />\n\t\t\t\t</Expandable>\n\t\t\t) : (\n\t\t\t\t<StoryLink info={storyInfo} />\n\t\t\t)}\n\t\t</li>\n\t)\n}\n\nfunction plural(arr: Array<any>) {\n\treturn arr.length === 1 ? '' : 's'\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAqBA,SAAgB,qBAAqB;AACpC,QACC,2CAACA,gEACA,2CAAC,+BAA6B,GACL;;AAI5B,SAAS,6BAA6B;CACrC,MAAM,EAAE,SAASC,+CAAoB;AACrC,KAAI,CAAC,KAAM,QAAO,2CAAC,mBAAI,+CAAgD;AAEvE,QACC,4CAAC;EAAI,WAAWC,iDAAE;aACjB,2CAACC,yCAAU,wBAA+B,EAC1C,2CAAC;GAAmB,WAAW;GAAM,eAAe;IAAS;GACxD;;AAQR,SAAS,mBAAmB,EAC3B,WACA,gBAAgB,QACc;CAC9B,MAAM,EAAE,UAAUF,+CAAoB;CACtC,MAAM,EAAE,WAAW,WAAW,MAAO,UAAU;CAC/C,MAAM,oBAAoBG,8DAAmC,UAAU;CACvE,MAAM,iBAAiBA,8DAAmC,OAAO;AAEjE,QACC,4CAAC;EACC,iBACA,2CAACC;GACA,QAAQ,WAAW,UAAU,WAAW;GACxC,MAAMC;aAEN,2CAACC,yCAA0B,YAAa;IAC5B;EAGd,2CAACF;GACA,QAAQ,YAAY,UAAU,WAAW;GACzC,MAAMG;aAEN,4CAAC;IAAI,WAAWN,iDAAE;;KACjB,2CAACO;MACA,OAAM;MACN,aAAa,UAAU;gBAEvB,2CAACC,mDAA+B,YAAa;OAC3B;KAEnB,2CAACD;MACA,OAAM;MACN,aAAa,UAAU;gBAEvB,2CAACE;OAAU,MAAM;iBAChB,2CAAC,UACA,yBAAyB,EAExB,QAAQ,UAAU,eAAgB,WACjC,KACA,UACA,EACD,GACA;QACS;OACM;KAEnB,2CAACF;MACA,OAAM;MACN,aAAa,UAAU;gBAEvB,2CAACE;OAAU,MAAM;iBACf,UAAU;QACA;OACM;;KACd;IACM;EAEZ,kBAAkB,SAAS,KAC3B,2CAACN;GACA,QAAQ,cACP,kBAAkB,OAClB,YAAY,OAAO,kBAAkB;GACtC,MAAMO;aAEN,2CAAC,kBACCR,8DAAmC,UAAU,CAAC,KAC7C,SACA,2CAAC,mBACA,WAAW,QACN,KAAK,cACT,CAEH,GACG;IACO;EAEb,eAAe,SAAS,KACxB,2CAACC;GACA,QAAQ,WAAW,eAAe,OAAO,YAAY,OACpD,eACA;GACD,MAAMQ;aAEN,2CAAC,kBACCT,8DAAmC,OAAO,CAAC,KAC1C,SACA,2CAAC,mBACA,WAAW,QACN,KAAK,cACT,CAEH,GACG;IACO;KAET;;AAQR,SAAS,gBAAgB,EAAE,aAAsC;AAChE,QACC,2CAAC,kBACC,UAAU,UACV,2CAACC;EACA,MAAMS;EACN,QACC,2CAACH;GAAU,MAAM;GAAW,iBAAgB;IAAU;YAGvD,2CAAC,sBAA8B,YAAa;GAChC,GAEb,2CAACA,+BAAU,MAAM,YAAa,IAXvB,UAAU,cAad;;AAIP,SAAS,OAAO,KAAiB;AAChC,QAAO,IAAI,WAAW,IAAI,KAAK"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime2 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/blocks/DependencyPreviews.d.ts
|
|
4
|
+
declare function DependencyPreviews(): react_jsx_runtime2.JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { DependencyPreviews };
|
|
7
|
+
//# sourceMappingURL=DependencyPreviews.d.cts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as react_jsx_runtime3 from "react/jsx-runtime";
|
|
2
|
+
|
|
3
|
+
//#region src/blocks/DependencyPreviews.d.ts
|
|
4
|
+
declare function DependencyPreviews(): react_jsx_runtime3.JSX.Element;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { DependencyPreviews };
|
|
7
|
+
//# sourceMappingURL=DependencyPreviews.d.mts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { PrimaryPreview } from "../components/PrimaryPreview.mjs";
|
|
2
|
+
import { StoryLink } from "../components/StoryLink.mjs";
|
|
3
|
+
import { DependencyGraphProvider, filterOutStoryAndNonComponentFiles, useDependencyGraph } from "../hooks/useDependencyGraph.mjs";
|
|
4
|
+
import { ComponentSourceLink } from "../components/ComponentSourceLink.mjs";
|
|
5
|
+
import { Expandable } from "../components/Expandable.mjs";
|
|
6
|
+
import { BuildIcon } from "../components/icons/BuildIcon.mjs";
|
|
7
|
+
import { EyeOpen } from "../components/icons/EyeOpen.mjs";
|
|
8
|
+
import { SquaresPlus } from "../components/icons/SquaresPlus.mjs";
|
|
9
|
+
import { ArrowToRectangle } from "../components/icons/ArrowToRectangleIcon.mjs";
|
|
10
|
+
import { CubeIcon } from "../components/icons/CubeIcon.mjs";
|
|
11
|
+
import { PathCopyMolecule } from "../components/PathCopyMolecule.mjs";
|
|
12
|
+
import { SbHeading } from "../components/SbHeading.mjs";
|
|
13
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import s from "./DependencyPreviews.module.css";
|
|
15
|
+
|
|
16
|
+
//#region src/blocks/DependencyPreviews.tsx
|
|
17
|
+
function DependencyPreviews() {
|
|
18
|
+
return /* @__PURE__ */ jsx(DependencyGraphProvider, { children: /* @__PURE__ */ jsx(TopLevelDependencyPreviews, {}) });
|
|
19
|
+
}
|
|
20
|
+
function TopLevelDependencyPreviews() {
|
|
21
|
+
const { node } = useDependencyGraph();
|
|
22
|
+
if (!node) return /* @__PURE__ */ jsx("div", { children: "No dependency previews for this component." });
|
|
23
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
className: s.topLevelWrapper,
|
|
25
|
+
children: [/* @__PURE__ */ jsx(SbHeading, { children: "Dependency previews" }), /* @__PURE__ */ jsx(DepsPreviewContent, {
|
|
26
|
+
storyInfo: node,
|
|
27
|
+
enablePreview: false
|
|
28
|
+
})]
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function DepsPreviewContent({ storyInfo, enablePreview = true }) {
|
|
32
|
+
const { graph } = useDependencyGraph();
|
|
33
|
+
const { builtWith, usedIn } = graph[storyInfo.componentPath];
|
|
34
|
+
const filteredBuiltWith = filterOutStoryAndNonComponentFiles(builtWith);
|
|
35
|
+
const filteredUsedIn = filterOutStoryAndNonComponentFiles(usedIn);
|
|
36
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
37
|
+
enablePreview && /* @__PURE__ */ jsx(Expandable, {
|
|
38
|
+
Header: `Preview ${storyInfo.storyTitle} component`,
|
|
39
|
+
Icon: EyeOpen,
|
|
40
|
+
children: /* @__PURE__ */ jsx(PrimaryPreview, { storyInfo })
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ jsx(Expandable, {
|
|
43
|
+
Header: `Paths to ${storyInfo.storyTitle} component`,
|
|
44
|
+
Icon: ArrowToRectangle,
|
|
45
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
46
|
+
className: s.pathData,
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx(PathCopyMolecule, {
|
|
49
|
+
label: "Source File Path",
|
|
50
|
+
copyContent: storyInfo.componentPath,
|
|
51
|
+
children: /* @__PURE__ */ jsx(ComponentSourceLink, { storyInfo })
|
|
52
|
+
}),
|
|
53
|
+
/* @__PURE__ */ jsx(PathCopyMolecule, {
|
|
54
|
+
label: "Story Title Path",
|
|
55
|
+
copyContent: storyInfo.storyTitlePath,
|
|
56
|
+
children: /* @__PURE__ */ jsx(StoryLink, {
|
|
57
|
+
info: storyInfo,
|
|
58
|
+
children: /* @__PURE__ */ jsx("span", { dangerouslySetInnerHTML: { __html: storyInfo.storyTitlePath.replaceAll("/", "/<wbr/>") } })
|
|
59
|
+
})
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ jsx(PathCopyMolecule, {
|
|
62
|
+
label: "Story Page ID",
|
|
63
|
+
copyContent: storyInfo.storyId,
|
|
64
|
+
children: /* @__PURE__ */ jsx(StoryLink, {
|
|
65
|
+
info: storyInfo,
|
|
66
|
+
children: storyInfo.storyId
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
}),
|
|
72
|
+
filteredBuiltWith.length > 0 && /* @__PURE__ */ jsx(Expandable, {
|
|
73
|
+
Header: `Built with ${filteredBuiltWith.length} component${plural(filteredBuiltWith)}`,
|
|
74
|
+
Icon: BuildIcon,
|
|
75
|
+
children: /* @__PURE__ */ jsx("ul", { children: filterOutStoryAndNonComponentFiles(builtWith).map((info) => /* @__PURE__ */ jsx(DepsPreviewItem, { storyInfo: info }, info.componentPath)) })
|
|
76
|
+
}),
|
|
77
|
+
filteredUsedIn.length > 0 && /* @__PURE__ */ jsx(Expandable, {
|
|
78
|
+
Header: `Used in ${filteredUsedIn.length} component${plural(filteredUsedIn)}`,
|
|
79
|
+
Icon: SquaresPlus,
|
|
80
|
+
children: /* @__PURE__ */ jsx("ul", { children: filterOutStoryAndNonComponentFiles(usedIn).map((info) => /* @__PURE__ */ jsx(DepsPreviewItem, { storyInfo: info }, info.componentPath)) })
|
|
81
|
+
})
|
|
82
|
+
] });
|
|
83
|
+
}
|
|
84
|
+
function DepsPreviewItem({ storyInfo }) {
|
|
85
|
+
return /* @__PURE__ */ jsx("li", { children: storyInfo.storyId ? /* @__PURE__ */ jsx(Expandable, {
|
|
86
|
+
Icon: CubeIcon,
|
|
87
|
+
Header: /* @__PURE__ */ jsx(StoryLink, {
|
|
88
|
+
info: storyInfo,
|
|
89
|
+
tooltipPosition: "right"
|
|
90
|
+
}),
|
|
91
|
+
children: /* @__PURE__ */ jsx(DepsPreviewContent, { storyInfo })
|
|
92
|
+
}) : /* @__PURE__ */ jsx(StoryLink, { info: storyInfo }) }, storyInfo.componentPath);
|
|
93
|
+
}
|
|
94
|
+
function plural(arr) {
|
|
95
|
+
return arr.length === 1 ? "" : "s";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
export { DependencyPreviews };
|
|
100
|
+
//# sourceMappingURL=DependencyPreviews.mjs.map
|