@aurelia/storybook 1.0.1 → 2.0.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 +12 -20
- package/apps/hello-world/.storybook/main.ts +27 -5
- package/apps/hello-world/package-lock.json +781 -3474
- package/apps/hello-world/package.json +12 -8
- package/apps/hello-world/src/stories/hello-world.stories.ts +6 -6
- package/apps/hello-world-webpack/.storybook/main.ts +0 -1
- package/apps/hello-world-webpack/package-lock.json +229 -2042
- package/apps/hello-world-webpack/package.json +8 -7
- package/apps/hello-world-webpack/src/hello-world.html +6 -0
- package/apps/hello-world-webpack/src/hello-world.ts +17 -0
- package/apps/hello-world-webpack/src/my-app.stories.ts +10 -7
- package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +54 -0
- package/dist/index.js +65 -121
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -115
- package/dist/index.mjs.map +1 -1
- package/dist/preset.js +17 -10
- package/dist/preset.js.map +1 -1
- package/dist/preset.mjs +15 -1
- package/dist/preset.mjs.map +1 -1
- package/dist/preview/render.js +44 -124
- package/dist/preview/render.js.map +1 -1
- package/dist/preview/render.mjs +41 -116
- package/dist/preview/render.mjs.map +1 -1
- package/dist/preview/types.js +0 -1
- package/dist/preview/types.js.map +1 -1
- package/dist/preview.js +84 -44
- package/dist/preview.js.map +1 -1
- package/dist/preview.mjs +81 -39
- package/dist/preview.mjs.map +1 -1
- package/dist/webpack.js +1 -3
- package/dist/webpack.js.map +1 -1
- package/package.json +16 -19
- package/rollup.config.mjs +10 -8
- package/src/index.ts +28 -0
- package/src/preset.ts +20 -2
- package/src/preview/render.ts +49 -47
- package/src/preview.ts +1 -50
- package/tsconfig.json +1 -1
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> **Note:** Storybook support is currently in an early stage, and there may be bugs, issues, or unsupported features in this plugin. The intention is to make this plugin more production-ready when Aurelia 2 reaches stable release.
|
|
4
4
|
|
|
5
|
-
This package provides an integration between Aurelia 2 and Storybook
|
|
5
|
+
This package provides an integration between Aurelia 2 and Storybook 10 using Vite or Webpack. It lets you write and render Aurelia 2 components as Storybook stories with full support for Storybook controls, actions, and interactive testing.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- **Vite & Webpack Support**: Works with both Vite (via `@storybook/builder-vite`) and Webpack 5 (via `@storybook/builder-webpack5`).
|
|
10
10
|
- **Aurelia Enhancement**: Renders Aurelia 2 components using Aurelia's `enhance()` API.
|
|
11
|
-
- **Storybook
|
|
11
|
+
- **Storybook 10 Compatibility**: Fully compatible with Storybook 10's rendering API and ESM-only architecture.
|
|
12
12
|
- **Arg & Action Support**: Use story args and actions as you would with any Storybook story.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
@@ -25,12 +25,6 @@ Also, make sure to have the required dependencies installed in your project:
|
|
|
25
25
|
npm install --save-dev storybook @storybook/builder-vite
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
For testing functionality, you may also want to install:
|
|
29
|
-
|
|
30
|
-
```bash
|
|
31
|
-
npm install --save-dev @storybook/test @storybook/addon-actions
|
|
32
|
-
```
|
|
33
|
-
|
|
34
28
|
> **Tip:** Check your existing Aurelia 2 app for already installed versions. The peer dependencies are expected to be compatible with Aurelia 2 beta releases (see `package.json` for version details).
|
|
35
29
|
|
|
36
30
|
## Getting Started
|
|
@@ -89,7 +83,7 @@ To integrate Aurelia 2 with your Storybook instance, follow these steps:
|
|
|
89
83
|
export { render, renderToCanvas } from '@aurelia/storybook';
|
|
90
84
|
```
|
|
91
85
|
|
|
92
|
-
> **Note:** Essential features like actions, controls, backgrounds, and viewport are now built into Storybook
|
|
86
|
+
> **Note:** Essential features like actions, controls, backgrounds, and viewport are now built into Storybook 10 core and don't need to be installed separately. However, if you need to use the `action()` function in your stories (for programmatic actions), you may still need to install `@storybook/addon-actions`. Additional addons like `@storybook/addon-links` can be installed and added to the `addons` array in your configuration.
|
|
93
87
|
|
|
94
88
|
### Using with Webpack
|
|
95
89
|
|
|
@@ -101,7 +95,6 @@ To integrate Aurelia 2 with your Storybook instance, follow these steps:
|
|
|
101
95
|
const config: StorybookConfig = {
|
|
102
96
|
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
103
97
|
addons: [
|
|
104
|
-
'@storybook/addon-webpack5-compiler-swc',
|
|
105
98
|
'@storybook/addon-links'
|
|
106
99
|
],
|
|
107
100
|
framework: {
|
|
@@ -135,14 +128,13 @@ Aurelia 2 stories are written similarly to standard Storybook stories, with a fe
|
|
|
135
128
|
|
|
136
129
|
```typescript
|
|
137
130
|
import { HelloWorld } from '../hello-world';
|
|
138
|
-
import {
|
|
139
|
-
import { userEvent, within } from '@storybook/test';
|
|
131
|
+
import { fn, userEvent, within } from 'storybook/test';
|
|
140
132
|
|
|
141
133
|
const meta = {
|
|
142
134
|
title: 'Example/HelloWorld',
|
|
143
135
|
component: HelloWorld,
|
|
144
|
-
render: (
|
|
145
|
-
template:
|
|
136
|
+
render: () => ({
|
|
137
|
+
template: `<hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>`,
|
|
146
138
|
}),
|
|
147
139
|
argTypes: {
|
|
148
140
|
message: { control: 'text' },
|
|
@@ -155,16 +147,16 @@ export default meta;
|
|
|
155
147
|
export const DefaultHelloWorld = {
|
|
156
148
|
args: {
|
|
157
149
|
message: "Hello from Storybook!",
|
|
158
|
-
onIncrement:
|
|
150
|
+
onIncrement: fn()
|
|
159
151
|
}
|
|
160
152
|
};
|
|
161
153
|
|
|
162
154
|
export const InteractiveHelloWorld = {
|
|
163
155
|
args: {
|
|
164
156
|
message: "Try clicking the button!",
|
|
165
|
-
onIncrement:
|
|
157
|
+
onIncrement: fn()
|
|
166
158
|
},
|
|
167
|
-
play: async ({ canvasElement }) => {
|
|
159
|
+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
168
160
|
const canvas = within(canvasElement);
|
|
169
161
|
const button = canvas.getByRole('button');
|
|
170
162
|
// Simulate three button clicks
|
|
@@ -176,13 +168,13 @@ export const InteractiveHelloWorld = {
|
|
|
176
168
|
|
|
177
169
|
export const NoArgs = {
|
|
178
170
|
render: () => ({
|
|
179
|
-
template:
|
|
171
|
+
template: `<hello-world></hello-world>`
|
|
180
172
|
})
|
|
181
173
|
};
|
|
182
174
|
|
|
183
175
|
export const WithCustomTemplate = {
|
|
184
|
-
render: (
|
|
185
|
-
template:
|
|
176
|
+
render: () => ({
|
|
177
|
+
template: `<hello-world message.bind="message">Click me!</hello-world>`
|
|
186
178
|
}),
|
|
187
179
|
args: {
|
|
188
180
|
message: "This is a custom message"
|
|
@@ -14,13 +14,35 @@ const config: StorybookConfig & { viteFinal?: (config: InlineConfig, options: {
|
|
|
14
14
|
builder: '@storybook/builder-vite',
|
|
15
15
|
},
|
|
16
16
|
viteFinal: async (viteConfig) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
viteConfig.optimizeDeps.exclude.push('@aurelia/runtime-html');
|
|
17
|
+
// Initialize optimizeDeps and exclude array
|
|
18
|
+
if (!viteConfig.optimizeDeps) {
|
|
19
|
+
viteConfig.optimizeDeps = {};
|
|
21
20
|
}
|
|
21
|
+
if (!viteConfig.optimizeDeps.exclude) {
|
|
22
|
+
viteConfig.optimizeDeps.exclude = [];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Exclude Aurelia dependencies from pre-bundling, but allow React for Storybook
|
|
26
|
+
const excludeList = [
|
|
27
|
+
'@aurelia/runtime-html'
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
excludeList.forEach(dep => {
|
|
31
|
+
if (viteConfig.optimizeDeps?.exclude && !viteConfig.optimizeDeps.exclude.includes(dep)) {
|
|
32
|
+
viteConfig.optimizeDeps.exclude.push(dep);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
22
36
|
return mergeConfig(viteConfig, {
|
|
23
|
-
|
|
37
|
+
define: {
|
|
38
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
|
|
39
|
+
},
|
|
40
|
+
// Allow React to be bundled for Storybook's theming system
|
|
41
|
+
resolve: {
|
|
42
|
+
alias: {
|
|
43
|
+
// Ensure React is properly resolved
|
|
44
|
+
}
|
|
45
|
+
}
|
|
24
46
|
});
|
|
25
47
|
},
|
|
26
48
|
};
|