@aurelia/storybook 2.0.0 → 2.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.
Files changed (56) hide show
  1. package/CONTINUITY.md +22 -0
  2. package/README.md +210 -156
  3. package/apps/hello-world/.storybook/main.ts +0 -1
  4. package/apps/hello-world/package-lock.json +4485 -2626
  5. package/apps/hello-world/package.json +6 -16
  6. package/apps/hello-world/src/components/feedback-form.html +111 -0
  7. package/apps/hello-world/src/components/feedback-form.ts +45 -0
  8. package/apps/hello-world/src/components/notification-center.html +119 -0
  9. package/apps/hello-world/src/components/notification-center.ts +27 -0
  10. package/apps/hello-world/src/components/stat-card.html +107 -0
  11. package/apps/hello-world/src/components/stat-card.ts +33 -0
  12. package/apps/hello-world/src/components/weather-widget.html +89 -0
  13. package/apps/hello-world/src/components/weather-widget.ts +30 -0
  14. package/apps/hello-world/src/hello-world.html +44 -2
  15. package/apps/hello-world/src/services/weather-service.ts +15 -0
  16. package/apps/hello-world/src/stories/feedback-form.stories.ts +52 -0
  17. package/apps/hello-world/src/stories/hello-world.stories.ts +4 -5
  18. package/apps/hello-world/src/stories/notification-center.stories.ts +81 -0
  19. package/apps/hello-world/src/stories/stat-card.stories.ts +65 -0
  20. package/apps/hello-world/src/stories/weather-widget.stories.ts +57 -0
  21. package/apps/hello-world/tsconfig.json +4 -3
  22. package/apps/hello-world/vite.config.ts +0 -2
  23. package/apps/hello-world-webpack/.storybook/main.ts +0 -1
  24. package/apps/hello-world-webpack/package-lock.json +3646 -836
  25. package/apps/hello-world-webpack/package.json +2 -5
  26. package/apps/hello-world-webpack/src/components/feedback-form.html +111 -0
  27. package/apps/hello-world-webpack/src/components/feedback-form.ts +45 -0
  28. package/apps/hello-world-webpack/src/components/notification-center.html +119 -0
  29. package/apps/hello-world-webpack/src/components/notification-center.ts +27 -0
  30. package/apps/hello-world-webpack/src/components/stat-card.html +107 -0
  31. package/apps/hello-world-webpack/src/components/stat-card.ts +33 -0
  32. package/apps/hello-world-webpack/src/components/weather-widget.html +89 -0
  33. package/apps/hello-world-webpack/src/components/weather-widget.ts +30 -0
  34. package/apps/hello-world-webpack/src/hello-world.html +44 -2
  35. package/apps/hello-world-webpack/src/services/weather-service.ts +15 -0
  36. package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +52 -0
  37. package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +5 -6
  38. package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +81 -0
  39. package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +65 -0
  40. package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +57 -0
  41. package/apps/hello-world-webpack/tsconfig.json +1 -1
  42. package/package.json +5 -5
  43. package/apps/hello-world/.yarnrc.yml +0 -2
  44. package/apps/hello-world-webpack/.yarnrc.yml +0 -2
  45. package/dist/index.mjs +0 -132
  46. package/dist/index.mjs.map +0 -1
  47. package/dist/preset.mjs +0 -60
  48. package/dist/preset.mjs.map +0 -1
  49. package/dist/preview/render.mjs +0 -114
  50. package/dist/preview/render.mjs.map +0 -1
  51. package/dist/preview/types.mjs +0 -2
  52. package/dist/preview/types.mjs.map +0 -1
  53. package/dist/preview.mjs +0 -114
  54. package/dist/preview.mjs.map +0 -1
  55. package/dist/webpack.mjs +0 -21
  56. package/dist/webpack.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"render.mjs","sources":["../../src/preview/render.ts"],"sourcesContent":["import { STORY_CHANGED } from 'storybook/internal/core-events';\nimport type { RenderContext, ArgsStoryFn } from 'storybook/internal/types';\nimport type { AureliaRenderer } from './types';\nimport Aurelia, { Constructable, CustomElement } from 'aurelia';\n\ninterface AureliaStoryResult {\n template: string;\n components?: unknown[];\n Component?: unknown;\n container?: any;\n items?: unknown[];\n innerHtml?: string;\n props?: Record<string, any>;\n}\n\n// Track Aurelia apps for cleanup\nconst appMap = new Map<HTMLElement, any>();\n\nasync function teardown(element: HTMLElement) {\n if (appMap.has(element)) {\n const app = appMap.get(element);\n if (app) {\n await app.stop();\n appMap.delete(element);\n }\n }\n}\n\nexport const render: ArgsStoryFn<AureliaRenderer> = (args, context) => {\n const { id, component: Component } = context;\n \n if (!Component) {\n throw new Error(\n `Unable to render story ${id} as the component annotation is missing from the default export`\n );\n }\n return { Component, props: args, template: '' };\n};\n\nexport async function renderToCanvas(\n {\n storyFn,\n title,\n name,\n showMain,\n showError,\n storyContext,\n forceRemount,\n }: RenderContext<AureliaRenderer>,\n canvasElement: HTMLElement,\n bootstrapAppFn?: typeof createAureliaApp\n) {\n // Store reference to the original storybook root element\n const rootElement = canvasElement;\n\n // Ensure we have (or create) a single container inside the root where the Aurelia app actually renders\n let hostElement: HTMLElement;\n if (rootElement.id === 'storybook-root') {\n hostElement = rootElement.querySelector('.aurelia-story-container') as HTMLElement;\n if (!hostElement) {\n hostElement = document.createElement('div');\n hostElement.className = 'aurelia-story-container';\n hostElement.style.height = '100%';\n rootElement.appendChild(hostElement);\n }\n } else {\n hostElement = rootElement;\n }\n\n // All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe\n const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;\n const { parameters, component, args } = storyContext;\n \n let app = appMap.get(rootElement);\n const story = storyFn() as AureliaStoryResult;\n \n // Temporary debug logging\n console.log(`[DEBUG] Story: ${name}, forceRemount: ${forceRemount}, hasExistingApp: ${!!app}, canvasId: ${canvasElement.className}`);\n\n if (!story) {\n showError({\n title: `Expecting an Aurelia component from the story: \"${name}\" of \"${title}\".`,\n description: `\n Did you forget to return the Aurelia component from the story?\n Use \"() => ({ template: '<custom-component></custom-component>' })\" when defining the story.\n `,\n });\n return () => {};\n }\n\n showMain();\n\n if (!app || forceRemount) {\n if (forceRemount && app) {\n await teardown(rootElement);\n app = undefined;\n }\n // Clear container before mounting new app\n hostElement.innerHTML = '';\n\n const mergedProps = { ...parameters?.args, ...args, ...story.props };\n\n const aureliaApp = appBootstrapFn(\n story,\n mergedProps,\n hostElement,\n component as Constructable\n );\n await aureliaApp.start();\n appMap.set(rootElement, aureliaApp);\n app = aureliaApp;\n } else {\n // update existing app props\n const mergedProps = { ...parameters?.args, ...args, ...story.props };\n if (app?.root?.controller?.viewModel) {\n Object.assign(app.root.controller.viewModel, mergedProps);\n }\n }\n\n // Return cleanup fn\n return async () => {\n await teardown(rootElement);\n };\n}\n\nexport function createAureliaApp(\n story: AureliaStoryResult,\n args: Record<string, any>,\n domElement: HTMLElement,\n component?: Constructable\n) {\n const aurelia = new Aurelia(story.container);\n\n if (story.items?.length) {\n aurelia.register(...story.items);\n }\n\n if (story.components?.length) {\n aurelia.register(...story.components);\n }\n\n let { template } = story;\n\n if (component) {\n template = template ?? createComponentTemplate(component, story.innerHtml);\n aurelia.register(component);\n }\n\n const App = CustomElement.define(\n {\n name: 'sb-app',\n template,\n containerless: true,\n },\n class {}\n );\n\n const app = Object.assign(new App(), args);\n\n return aurelia.app({\n host: domElement,\n component: app,\n });\n}\n\nexport function createComponentTemplate(\n component: Constructable,\n innerHtml?: string\n): string {\n const def = CustomElement.getDefinition(component);\n\n return `<${def.name} ${Object.values(def.bindables)\n .map((bindable) => `${bindable.attribute}.bind=\"${bindable.name}\"`)\n .join(' ')}>${innerHtml ?? ''}</${def.name}>`;\n}"],"names":[],"mappings":";;AAeA;AACA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB;AAE1C,eAAe,QAAQ,CAAC,OAAoB,EAAA;AAC1C,IAAA,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE;QACvB,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;QAC/B,IAAI,GAAG,EAAE;AACP,YAAA,MAAM,GAAG,CAAC,IAAI,EAAE;AAChB,YAAA,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;;;AAG5B;MAEa,MAAM,GAAiC,CAAC,IAAI,EAAE,OAAO,KAAI;IACpE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAA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AC,GAAG,CAAC,CAAA,CAAA,EAAI,SAAS,IAAI,EAAE,CAAA,EAAA,EAAK,GAAG,CAAC,IAAI,CAAA,CAAA,CAAG;AACjD;;;;"}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=types.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/dist/preview.mjs DELETED
@@ -1,114 +0,0 @@
1
- import Aurelia, { CustomElement } from 'aurelia';
2
-
3
- // Track Aurelia apps for cleanup
4
- const appMap = new Map();
5
- async function teardown(element) {
6
- if (appMap.has(element)) {
7
- const app = appMap.get(element);
8
- if (app) {
9
- await app.stop();
10
- appMap.delete(element);
11
- }
12
- }
13
- }
14
- const render = (args, context) => {
15
- const { id, component: Component } = context;
16
- if (!Component) {
17
- throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
18
- }
19
- return { Component, props: args, template: '' };
20
- };
21
- async function renderToCanvas({ storyFn, title, name, showMain, showError, storyContext, forceRemount, }, canvasElement, bootstrapAppFn) {
22
- // Store reference to the original storybook root element
23
- const rootElement = canvasElement;
24
- // Ensure we have (or create) a single container inside the root where the Aurelia app actually renders
25
- let hostElement;
26
- if (rootElement.id === 'storybook-root') {
27
- hostElement = rootElement.querySelector('.aurelia-story-container');
28
- if (!hostElement) {
29
- hostElement = document.createElement('div');
30
- hostElement.className = 'aurelia-story-container';
31
- hostElement.style.height = '100%';
32
- rootElement.appendChild(hostElement);
33
- }
34
- }
35
- else {
36
- hostElement = rootElement;
37
- }
38
- // All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe
39
- const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;
40
- const { parameters, component, args } = storyContext;
41
- let app = appMap.get(rootElement);
42
- const story = storyFn();
43
- // Temporary debug logging
44
- console.log(`[DEBUG] Story: ${name}, forceRemount: ${forceRemount}, hasExistingApp: ${!!app}, canvasId: ${canvasElement.className}`);
45
- if (!story) {
46
- showError({
47
- title: `Expecting an Aurelia component from the story: "${name}" of "${title}".`,
48
- description: `
49
- Did you forget to return the Aurelia component from the story?
50
- Use "() => ({ template: '<custom-component></custom-component>' })" when defining the story.
51
- `,
52
- });
53
- return () => { };
54
- }
55
- showMain();
56
- if (!app || forceRemount) {
57
- if (forceRemount && app) {
58
- await teardown(rootElement);
59
- app = undefined;
60
- }
61
- // Clear container before mounting new app
62
- hostElement.innerHTML = '';
63
- const mergedProps = { ...parameters?.args, ...args, ...story.props };
64
- const aureliaApp = appBootstrapFn(story, mergedProps, hostElement, component);
65
- await aureliaApp.start();
66
- appMap.set(rootElement, aureliaApp);
67
- app = aureliaApp;
68
- }
69
- else {
70
- // update existing app props
71
- const mergedProps = { ...parameters?.args, ...args, ...story.props };
72
- if (app?.root?.controller?.viewModel) {
73
- Object.assign(app.root.controller.viewModel, mergedProps);
74
- }
75
- }
76
- // Return cleanup fn
77
- return async () => {
78
- await teardown(rootElement);
79
- };
80
- }
81
- function createAureliaApp(story, args, domElement, component) {
82
- const aurelia = new Aurelia(story.container);
83
- if (story.items?.length) {
84
- aurelia.register(...story.items);
85
- }
86
- if (story.components?.length) {
87
- aurelia.register(...story.components);
88
- }
89
- let { template } = story;
90
- if (component) {
91
- template = template ?? createComponentTemplate(component, story.innerHtml);
92
- aurelia.register(component);
93
- }
94
- const App = CustomElement.define({
95
- name: 'sb-app',
96
- template,
97
- containerless: true,
98
- }, class {
99
- });
100
- const app = Object.assign(new App(), args);
101
- return aurelia.app({
102
- host: domElement,
103
- component: app,
104
- });
105
- }
106
- function createComponentTemplate(component, innerHtml) {
107
- const def = CustomElement.getDefinition(component);
108
- return `<${def.name} ${Object.values(def.bindables)
109
- .map((bindable) => `${bindable.attribute}.bind="${bindable.name}"`)
110
- .join(' ')}>${innerHtml ?? ''}</${def.name}>`;
111
- }
112
-
113
- export { render, renderToCanvas };
114
- //# sourceMappingURL=preview.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"preview.mjs","sources":["../src/preview/render.ts"],"sourcesContent":["import { STORY_CHANGED } from 'storybook/internal/core-events';\nimport type { RenderContext, ArgsStoryFn } from 'storybook/internal/types';\nimport type { AureliaRenderer } from './types';\nimport Aurelia, { Constructable, CustomElement } from 'aurelia';\n\ninterface AureliaStoryResult {\n template: string;\n components?: unknown[];\n Component?: unknown;\n container?: any;\n items?: unknown[];\n innerHtml?: string;\n props?: Record<string, any>;\n}\n\n// Track Aurelia apps for cleanup\nconst appMap = new Map<HTMLElement, any>();\n\nasync function teardown(element: HTMLElement) {\n if (appMap.has(element)) {\n const app = appMap.get(element);\n if (app) {\n await app.stop();\n appMap.delete(element);\n }\n }\n}\n\nexport const render: ArgsStoryFn<AureliaRenderer> = (args, context) => {\n const { id, component: Component } = context;\n \n if (!Component) {\n throw new Error(\n `Unable to render story ${id} as the component annotation is missing from the default export`\n );\n }\n return { Component, props: args, template: '' };\n};\n\nexport async function renderToCanvas(\n {\n storyFn,\n title,\n name,\n showMain,\n showError,\n storyContext,\n forceRemount,\n }: RenderContext<AureliaRenderer>,\n canvasElement: HTMLElement,\n bootstrapAppFn?: typeof createAureliaApp\n) {\n // Store reference to the original storybook root element\n const rootElement = canvasElement;\n\n // Ensure we have (or create) a single container inside the root where the Aurelia app actually renders\n let hostElement: HTMLElement;\n if (rootElement.id === 'storybook-root') {\n hostElement = rootElement.querySelector('.aurelia-story-container') as HTMLElement;\n if (!hostElement) {\n hostElement = document.createElement('div');\n hostElement.className = 'aurelia-story-container';\n hostElement.style.height = '100%';\n rootElement.appendChild(hostElement);\n }\n } else {\n hostElement = rootElement;\n }\n\n // All app instances are now tracked by the *root* element, ensuring we only ever have one per story iframe\n const appBootstrapFn = bootstrapAppFn ?? createAureliaApp;\n const { parameters, component, args } = storyContext;\n \n let app = appMap.get(rootElement);\n const story = storyFn() as AureliaStoryResult;\n \n // Temporary debug logging\n console.log(`[DEBUG] Story: ${name}, forceRemount: ${forceRemount}, hasExistingApp: ${!!app}, canvasId: ${canvasElement.className}`);\n\n if (!story) {\n showError({\n title: `Expecting an Aurelia component from the story: \"${name}\" of \"${title}\".`,\n description: `\n Did you forget to return the Aurelia component from the story?\n Use \"() => ({ template: '<custom-component></custom-component>' })\" when defining the story.\n `,\n });\n return () => {};\n }\n\n showMain();\n\n if (!app || forceRemount) {\n if (forceRemount && app) {\n await teardown(rootElement);\n app = undefined;\n }\n // Clear container before mounting new app\n hostElement.innerHTML = '';\n\n const mergedProps = { ...parameters?.args, ...args, ...story.props };\n\n const aureliaApp = appBootstrapFn(\n story,\n mergedProps,\n hostElement,\n component as Constructable\n );\n await aureliaApp.start();\n appMap.set(rootElement, aureliaApp);\n app = aureliaApp;\n } else {\n // update existing app props\n const mergedProps = { ...parameters?.args, ...args, ...story.props };\n if (app?.root?.controller?.viewModel) {\n Object.assign(app.root.controller.viewModel, mergedProps);\n }\n }\n\n // Return cleanup fn\n return async () => {\n await teardown(rootElement);\n };\n}\n\nexport function createAureliaApp(\n story: AureliaStoryResult,\n args: Record<string, any>,\n domElement: HTMLElement,\n component?: Constructable\n) {\n const aurelia = new Aurelia(story.container);\n\n if (story.items?.length) {\n aurelia.register(...story.items);\n }\n\n if (story.components?.length) {\n aurelia.register(...story.components);\n }\n\n let { template } = story;\n\n if (component) {\n template = template ?? createComponentTemplate(component, story.innerHtml);\n aurelia.register(component);\n }\n\n const App = CustomElement.define(\n {\n name: 'sb-app',\n template,\n containerless: true,\n },\n class {}\n );\n\n const app = Object.assign(new App(), args);\n\n return aurelia.app({\n host: domElement,\n component: app,\n });\n}\n\nexport function createComponentTemplate(\n component: Constructable,\n innerHtml?: string\n): string {\n const def = CustomElement.getDefinition(component);\n\n return `<${def.name} ${Object.values(def.bindables)\n .map((bindable) => `${bindable.attribute}.bind=\"${bindable.name}\"`)\n .join(' ')}>${innerHtml ?? ''}</${def.name}>`;\n}"],"names":[],"mappings":";;AAeA;AACA,MAAM,MAAM,GAAG,IAAI,GAAG,EAAoB;AAE1C,eAAe,QAAQ,CAAC,OAAoB,EAA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B,CACrC,SAAwB,EACxB,SAAkB,EAAA;IAElB,MAAM,GAAG,GAAG,aAAa,CAAC,aAAa,CAAC,SAAS,CAAC;AAElD,IAAA,OAAO,CAAA,CAAA,EAAI,GAAG,CAAC,IAAI,CAAA,CAAA,EAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS;AAC/C,SAAA,GAAG,CAAC,CAAC,QAAQ,KAAK,CAAA,EAAG,QAAQ,CAAC,SAAS,CAAA,OAAA,EAAU,QAAQ,CAAC,IAAI,GAAG;AACjE,SAAA,IAAI,CAAC,GAAG,CAAC,CAAA,CAAA,EAAI,SAAS,IAAI,EAAE,CAAA,EAAA,EAAK,GAAG,CAAC,IAAI,CAAA,CAAA,CAAG;AACjD;;;;"}
package/dist/webpack.mjs DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * A set of rules to be added to the webpack configuration.
3
- * @returns
4
- */
5
- function getRules() {
6
- return [
7
- {
8
- test: /\.ts$/i,
9
- use: ['ts-loader', '@aurelia/webpack-loader'],
10
- exclude: /node_modules/,
11
- },
12
- {
13
- test: /\.html$/i,
14
- use: '@aurelia/webpack-loader',
15
- exclude: /node_modules/,
16
- },
17
- ];
18
- }
19
-
20
- export { getRules };
21
- //# sourceMappingURL=webpack.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack.mjs","sources":["../src/webpack.ts"],"sourcesContent":["// src/webpack.ts\nimport type { RuleSetRule } from 'webpack';\n\n/**\n * A set of rules to be added to the webpack configuration.\n * @returns\n */\nexport function getRules(): RuleSetRule[] {\n return [\n {\n test: /\\.ts$/i,\n use: ['ts-loader', '@aurelia/webpack-loader'],\n exclude: /node_modules/,\n },\n {\n test: /\\.html$/i,\n use: '@aurelia/webpack-loader',\n exclude: /node_modules/,\n },\n ];\n}\n"],"names":[],"mappings":"AAGA;;;AAGG;SACa,QAAQ,GAAA;IACtB,OAAO;AACL,QAAA;AACE,YAAA,IAAI,EAAE,QAAQ;AACd,YAAA,GAAG,EAAE,CAAC,WAAW,EAAE,yBAAyB,CAAC;AAC7C,YAAA,OAAO,EAAE,cAAc;AACxB,SAAA;AACD,QAAA;AACE,YAAA,IAAI,EAAE,UAAU;AAChB,YAAA,GAAG,EAAE,yBAAyB;AAC9B,YAAA,OAAO,EAAE,cAAc;AACxB,SAAA;KACF;AACH;;;;"}