@aurelia/storybook 1.0.1 → 1.0.2
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 +9 -10
- package/apps/hello-world/.storybook/main.ts +27 -5
- package/apps/hello-world/package-lock.json +684 -3377
- package/apps/hello-world/package.json +6 -2
- 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 +165 -1978
- 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 -114
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -115
- package/dist/index.mjs.map +1 -1
- package/dist/preset.js +15 -1
- 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 +41 -116
- 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.js +81 -38
- package/dist/preview.js.map +1 -1
- package/dist/preview.mjs +81 -39
- package/dist/preview.mjs.map +1 -1
- package/package.json +1 -1
- package/rollup.config.mjs +6 -1
- package/src/index.ts +28 -0
- package/src/preset.ts +19 -1
- package/src/preview/render.ts +49 -47
- package/src/preview.ts +1 -50
package/README.md
CHANGED
|
@@ -101,7 +101,6 @@ To integrate Aurelia 2 with your Storybook instance, follow these steps:
|
|
|
101
101
|
const config: StorybookConfig = {
|
|
102
102
|
stories: ['../src/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
|
|
103
103
|
addons: [
|
|
104
|
-
'@storybook/addon-webpack5-compiler-swc',
|
|
105
104
|
'@storybook/addon-links'
|
|
106
105
|
],
|
|
107
106
|
framework: {
|
|
@@ -135,14 +134,14 @@ Aurelia 2 stories are written similarly to standard Storybook stories, with a fe
|
|
|
135
134
|
|
|
136
135
|
```typescript
|
|
137
136
|
import { HelloWorld } from '../hello-world';
|
|
138
|
-
import {
|
|
137
|
+
import { fn } from '@storybook/test';
|
|
139
138
|
import { userEvent, within } from '@storybook/test';
|
|
140
139
|
|
|
141
140
|
const meta = {
|
|
142
141
|
title: 'Example/HelloWorld',
|
|
143
142
|
component: HelloWorld,
|
|
144
|
-
render: (
|
|
145
|
-
template:
|
|
143
|
+
render: () => ({
|
|
144
|
+
template: `<hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>`,
|
|
146
145
|
}),
|
|
147
146
|
argTypes: {
|
|
148
147
|
message: { control: 'text' },
|
|
@@ -155,16 +154,16 @@ export default meta;
|
|
|
155
154
|
export const DefaultHelloWorld = {
|
|
156
155
|
args: {
|
|
157
156
|
message: "Hello from Storybook!",
|
|
158
|
-
onIncrement:
|
|
157
|
+
onIncrement: fn()
|
|
159
158
|
}
|
|
160
159
|
};
|
|
161
160
|
|
|
162
161
|
export const InteractiveHelloWorld = {
|
|
163
162
|
args: {
|
|
164
163
|
message: "Try clicking the button!",
|
|
165
|
-
onIncrement:
|
|
164
|
+
onIncrement: fn()
|
|
166
165
|
},
|
|
167
|
-
play: async ({ canvasElement }) => {
|
|
166
|
+
play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
|
|
168
167
|
const canvas = within(canvasElement);
|
|
169
168
|
const button = canvas.getByRole('button');
|
|
170
169
|
// Simulate three button clicks
|
|
@@ -176,13 +175,13 @@ export const InteractiveHelloWorld = {
|
|
|
176
175
|
|
|
177
176
|
export const NoArgs = {
|
|
178
177
|
render: () => ({
|
|
179
|
-
template:
|
|
178
|
+
template: `<hello-world></hello-world>`
|
|
180
179
|
})
|
|
181
180
|
};
|
|
182
181
|
|
|
183
182
|
export const WithCustomTemplate = {
|
|
184
|
-
render: (
|
|
185
|
-
template:
|
|
183
|
+
render: () => ({
|
|
184
|
+
template: `<hello-world message.bind="message">Click me!</hello-world>`
|
|
186
185
|
}),
|
|
187
186
|
args: {
|
|
188
187
|
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
|
};
|