@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 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 { action } from '@storybook/addon-actions';
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: (args) => ({
145
- template: <hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>,
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: action('increment')
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: action('increment')
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: <hello-world></hello-world>
178
+ template: `<hello-world></hello-world>`
180
179
  })
181
180
  };
182
181
 
183
182
  export const WithCustomTemplate = {
184
- render: (args) => ({
185
- template: <hello-world message.bind="message">Click me!</hello-world>
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
- viteConfig.optimizeDeps = viteConfig.optimizeDeps || {};
18
- viteConfig.optimizeDeps.exclude = viteConfig.optimizeDeps.exclude || [];
19
- if (!viteConfig.optimizeDeps.exclude.includes('@aurelia/runtime-html')) {
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
- // ...any additional Vite configuration
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
  };