@aurelia/storybook 2.1.0 → 2.2.1

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 (108) hide show
  1. package/.github/workflows/ci.yml +61 -0
  2. package/.github/workflows/publish.yml +82 -0
  3. package/.github/workflows/storybook-preview.yml +62 -0
  4. package/CHANGELOG.md +5 -0
  5. package/README.md +180 -1
  6. package/__tests__/create-aurelia-app.test.ts +94 -0
  7. package/__tests__/preset.test.ts +32 -3
  8. package/__tests__/preview.test.ts +9 -131
  9. package/__tests__/render.test.ts +15 -26
  10. package/apps/hello-world/package-lock.json +404 -287
  11. package/apps/hello-world/package.json +10 -10
  12. package/apps/hello-world/src/components/notification-center.ts +2 -2
  13. package/apps/hello-world/src/components/stat-card.ts +12 -4
  14. package/apps/hello-world/src/components/weather-widget.ts +2 -1
  15. package/apps/hello-world/src/stories/feedback-form.stories.ts +15 -9
  16. package/apps/hello-world/src/stories/hello-world.stories.ts +20 -9
  17. package/apps/hello-world/src/stories/notification-center.stories.ts +17 -10
  18. package/apps/hello-world/src/stories/stat-card.stories.ts +23 -13
  19. package/apps/hello-world/src/stories/weather-widget.stories.ts +18 -13
  20. package/apps/hello-world-rsbuild/.storybook/main.ts +16 -0
  21. package/apps/hello-world-rsbuild/.storybook/preview.ts +1 -0
  22. package/apps/hello-world-rsbuild/.stylelintrc.json +5 -0
  23. package/apps/hello-world-rsbuild/README.md +28 -0
  24. package/apps/hello-world-rsbuild/eslint.config.mjs +25 -0
  25. package/apps/hello-world-rsbuild/favicon.ico +0 -0
  26. package/apps/hello-world-rsbuild/index.html +17 -0
  27. package/apps/hello-world-rsbuild/package-lock.json +11131 -0
  28. package/apps/hello-world-rsbuild/package.json +56 -0
  29. package/apps/hello-world-rsbuild/src/components/feedback-form.html +111 -0
  30. package/apps/hello-world-rsbuild/src/components/feedback-form.ts +45 -0
  31. package/apps/hello-world-rsbuild/src/components/notification-center.html +119 -0
  32. package/apps/hello-world-rsbuild/src/components/notification-center.ts +27 -0
  33. package/apps/hello-world-rsbuild/src/components/stat-card.html +107 -0
  34. package/apps/hello-world-rsbuild/src/components/stat-card.ts +41 -0
  35. package/apps/hello-world-rsbuild/src/components/weather-widget.html +89 -0
  36. package/apps/hello-world-rsbuild/src/components/weather-widget.ts +31 -0
  37. package/apps/hello-world-rsbuild/src/hello-world.html +48 -0
  38. package/apps/hello-world-rsbuild/src/hello-world.ts +17 -0
  39. package/apps/hello-world-rsbuild/src/main.ts +6 -0
  40. package/apps/hello-world-rsbuild/src/my-app.html +1 -0
  41. package/apps/hello-world-rsbuild/src/my-app.ts +3 -0
  42. package/apps/hello-world-rsbuild/src/resource.d.ts +15 -0
  43. package/apps/hello-world-rsbuild/src/services/weather-service.ts +15 -0
  44. package/apps/hello-world-rsbuild/src/stories/feedback-form.stories.ts +58 -0
  45. package/apps/hello-world-rsbuild/src/stories/hello-world.stories.ts +64 -0
  46. package/apps/hello-world-rsbuild/src/stories/notification-center.stories.ts +88 -0
  47. package/apps/hello-world-rsbuild/src/stories/stat-card.stories.ts +75 -0
  48. package/apps/hello-world-rsbuild/src/stories/weather-widget.stories.ts +62 -0
  49. package/apps/hello-world-rsbuild/test/my-app.spec.ts +15 -0
  50. package/apps/hello-world-rsbuild/test/setup.ts +29 -0
  51. package/apps/hello-world-rsbuild/tsconfig.json +19 -0
  52. package/apps/hello-world-rsbuild/tsconfig.vitest.json +11 -0
  53. package/apps/hello-world-rsbuild/vite.config.ts +17 -0
  54. package/apps/hello-world-rsbuild/vitest.config.ts +15 -0
  55. package/apps/hello-world-webpack/package-lock.json +239 -264
  56. package/apps/hello-world-webpack/package.json +8 -7
  57. package/apps/hello-world-webpack/src/components/notification-center.ts +2 -2
  58. package/apps/hello-world-webpack/src/components/stat-card.ts +12 -4
  59. package/apps/hello-world-webpack/src/components/weather-widget.ts +2 -1
  60. package/apps/hello-world-webpack/src/my-app.stories.ts +6 -4
  61. package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +15 -9
  62. package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +20 -9
  63. package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +17 -10
  64. package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +23 -13
  65. package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +18 -13
  66. package/dist/index.d.ts +25 -0
  67. package/dist/index.js +68 -14
  68. package/dist/index.js.map +1 -1
  69. package/dist/preset.d.ts +21 -0
  70. package/dist/preset.js +46 -2
  71. package/dist/preset.js.map +1 -1
  72. package/dist/preview/helpers.d.ts +2 -0
  73. package/dist/preview/helpers.js +6 -0
  74. package/dist/preview/helpers.js.map +1 -0
  75. package/dist/preview/render.d.ts +7 -0
  76. package/dist/preview/render.js +66 -15
  77. package/dist/preview/render.js.map +1 -1
  78. package/dist/preview/storybook-types-runtime.d.ts +1 -0
  79. package/dist/preview/storybook-types-runtime.js +5 -0
  80. package/dist/preview/storybook-types-runtime.js.map +1 -0
  81. package/dist/preview/storybook-types.d.ts +27 -0
  82. package/dist/preview/types-runtime.d.ts +1 -0
  83. package/dist/preview/types-runtime.js +5 -0
  84. package/dist/preview/types-runtime.js.map +1 -0
  85. package/dist/preview/types.d.ts +44 -0
  86. package/dist/preview.d.ts +3 -0
  87. package/dist/preview.js +71 -16
  88. package/dist/preview.js.map +1 -1
  89. package/dist/webpack.d.ts +10 -0
  90. package/dist/webpack.js +19 -1
  91. package/dist/webpack.js.map +1 -1
  92. package/package.json +54 -9
  93. package/rollup.config.mjs +5 -3
  94. package/scripts/sync-versions.cjs +55 -0
  95. package/src/index.ts +11 -1
  96. package/src/preset.ts +32 -2
  97. package/src/preview/helpers.ts +7 -0
  98. package/src/preview/render.ts +98 -30
  99. package/src/preview/storybook-types-runtime.ts +2 -0
  100. package/src/preview/storybook-types.ts +34 -0
  101. package/src/preview/types-runtime.ts +2 -0
  102. package/src/preview/types.ts +57 -2
  103. package/src/preview.ts +11 -1
  104. package/src/webpack.ts +19 -0
  105. package/CONTINUITY.md +0 -22
  106. package/dist/preview/types.js +0 -2
  107. package/dist/preview/types.js.map +0 -1
  108. /package/{jest.config.js → jest.config.cjs} +0 -0
@@ -1,23 +1,23 @@
1
1
  {
2
2
  "name": "apptasks-video",
3
3
  "description": "An Aurelia 2 client application.",
4
- "version": "0.1.0",
4
+ "version": "2.2.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "???"
8
8
  },
9
9
  "license": "UNLICENSED",
10
10
  "dependencies": {
11
- "@aurelia/router": "^2.0.0-beta.25",
12
- "@aurelia/validation": "^2.0.0-beta.25",
13
- "@aurelia/validation-html": "^2.0.0-beta.25",
14
- "aurelia": "^2.0.0-beta.25"
11
+ "@aurelia/router": "^2.0.0-rc.0",
12
+ "@aurelia/validation": "^2.0.0-rc.0",
13
+ "@aurelia/validation-html": "^2.0.0-rc.0",
14
+ "aurelia": "^2.0.0-rc.0"
15
15
  },
16
16
  "devDependencies": {
17
- "@aurelia/storybook": "^2.0.0",
18
- "@aurelia/testing": "^2.0.0-beta.25",
19
- "@aurelia/vite-plugin": "^2.0.0-beta.25",
20
- "@storybook/builder-vite": "^10.0.0",
17
+ "@aurelia/storybook": "^2.2.1",
18
+ "@aurelia/testing": "^2.0.0-rc.0",
19
+ "@aurelia/vite-plugin": "^2.0.0-rc.0",
20
+ "@storybook/builder-vite": "^10.2.0",
21
21
  "@tailwindcss/vite": "^4.0.0",
22
22
  "@types/node": "^22.10.2",
23
23
  "@types/react": "^19.1.8",
@@ -29,7 +29,7 @@
29
29
  "react": "^19.1.0",
30
30
  "react-dom": "^19.1.0",
31
31
  "sass": "^1.83.4",
32
- "storybook": "^10.0.0",
32
+ "storybook": "^10.2.0",
33
33
  "stylelint": "^16.12.0",
34
34
  "stylelint-config-standard": "^36.0.1",
35
35
  "stylus": "^0.64.0",
@@ -17,11 +17,11 @@ export class NotificationCenter {
17
17
  @bindable() onDismiss?: (notification: NotificationItem) => void;
18
18
 
19
19
  get visibleNotifications() {
20
- return this.notifications.slice(0, this.maxVisible);
20
+ return (this.notifications ?? []).slice(0, this.maxVisible);
21
21
  }
22
22
 
23
23
  dismiss(notification: NotificationItem) {
24
- this.notifications = this.notifications.filter((note) => note.id !== notification.id);
24
+ this.notifications = (this.notifications ?? []).filter((note) => note.id !== notification.id);
25
25
  this.onDismiss?.(notification);
26
26
  }
27
27
  }
@@ -16,16 +16,24 @@ export class StatCard {
16
16
  }
17
17
 
18
18
  get changeLabel() {
19
- const rounded = Number(this.change).toFixed(1).replace(/\.0$/, '');
20
- const sign = this.change > 0 ? '+' : '';
19
+ const numeric = typeof this.change === 'number' ? this.change : Number(this.change);
20
+ if (!Number.isFinite(numeric)) {
21
+ return '0%';
22
+ }
23
+ const rounded = numeric.toFixed(1).replace(/\.0$/, '');
24
+ const sign = numeric > 0 ? '+' : '';
21
25
  return `${sign}${rounded}%`;
22
26
  }
23
27
 
24
28
  get changeState(): TrendState {
25
- if (this.change > 0) {
29
+ const numeric = typeof this.change === 'number' ? this.change : Number(this.change);
30
+ if (!Number.isFinite(numeric)) {
31
+ return 'neutral';
32
+ }
33
+ if (numeric > 0) {
26
34
  return 'positive';
27
35
  }
28
- if (this.change < 0) {
36
+ if (numeric < 0) {
29
37
  return 'negative';
30
38
  }
31
39
  return 'neutral';
@@ -20,7 +20,8 @@ export class WeatherWidget {
20
20
  try {
21
21
  this.state = 'loading';
22
22
  this.error = '';
23
- this.report = await this.service.getWeather(this.location);
23
+ const location = this.location ?? 'Seattle, WA';
24
+ this.report = await this.service.getWeather(location);
24
25
  this.state = 'ready';
25
26
  } catch (err) {
26
27
  this.state = 'error';
@@ -1,25 +1,31 @@
1
+ import { defineAureliaStory } from '@aurelia/storybook';
1
2
  import { fn, userEvent, within } from 'storybook/test';
2
3
  import { FeedbackForm } from '../components/feedback-form';
3
4
 
5
+ type FeedbackFormArgs = {
6
+ topics: string[];
7
+ submitting?: boolean;
8
+ onSubmit?: (payload: unknown) => void;
9
+ };
10
+
4
11
  const meta = {
5
12
  title: 'Dashboard/FeedbackForm',
6
13
  component: FeedbackForm,
7
14
  parameters: {
8
15
  layout: 'centered',
9
16
  },
10
- render: (args) => ({
11
- template: `<feedback-form topics.bind="topics"
12
- submitting.bind="submitting"
13
- on-submit.bind="onSubmit"></feedback-form>`,
14
- props: args,
15
- components: [FeedbackForm],
16
- }),
17
+ render: (args: FeedbackFormArgs) =>
18
+ defineAureliaStory({
19
+ template: `<feedback-form topics.bind="topics"
20
+ submitting.bind="submitting"
21
+ on-submit.bind="onSubmit"></feedback-form>`,
22
+ props: args,
23
+ components: [FeedbackForm],
24
+ }),
17
25
  };
18
26
 
19
27
  export default meta;
20
28
 
21
- type Story = typeof meta;
22
-
23
29
  export const DefaultForm = {
24
30
  args: {
25
31
  topics: ['Bug report', 'Feature request', 'General question'],
@@ -1,12 +1,20 @@
1
+ import { defineAureliaStory } from '@aurelia/storybook';
1
2
  import { HelloWorld } from '../hello-world';
2
3
  import { fn, userEvent, within } from 'storybook/test';
3
4
 
5
+ type HelloWorldArgs = {
6
+ message?: string;
7
+ onIncrement?: () => void;
8
+ };
9
+
4
10
  const meta = {
5
11
  title: 'Example/HelloWorld',
6
12
  component: HelloWorld,
7
- render: () => ({
8
- template: `<hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>`,
9
- }),
13
+ render: (args: HelloWorldArgs) =>
14
+ defineAureliaStory({
15
+ template: `<hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>`,
16
+ props: args,
17
+ }),
10
18
  argTypes: {
11
19
  message: { control: 'text' },
12
20
  onIncrement: { action: 'increment' }
@@ -38,15 +46,18 @@ export const InteractiveHelloWorld = {
38
46
  };
39
47
 
40
48
  export const NoArgs = {
41
- render: () => ({
42
- template: `<hello-world></hello-world>`
43
- })
49
+ render: () =>
50
+ defineAureliaStory({
51
+ template: `<hello-world></hello-world>`,
52
+ })
44
53
  };
45
54
 
46
55
  export const WithCustomTemplate = {
47
- render: () => ({
48
- template: `<hello-world message.bind="message">Click me!</hello-world>`
49
- }),
56
+ render: (args: HelloWorldArgs) =>
57
+ defineAureliaStory({
58
+ template: `<hello-world message.bind="message">Click me!</hello-world>`,
59
+ props: args,
60
+ }),
50
61
  args: {
51
62
  message: 'This is a custom message'
52
63
  }
@@ -1,6 +1,14 @@
1
+ import { defineAureliaStory } from '@aurelia/storybook';
1
2
  import { fn, userEvent, within } from 'storybook/test';
2
3
  import { NotificationCenter, NotificationItem } from '../components/notification-center';
3
4
 
5
+ type NotificationCenterArgs = {
6
+ notifications: NotificationItem[];
7
+ maxVisible?: number;
8
+ showTimestamp?: boolean;
9
+ onDismiss?: (item: NotificationItem) => void;
10
+ };
11
+
4
12
  const baseNotifications: NotificationItem[] = [
5
13
  {
6
14
  id: 1,
@@ -35,20 +43,19 @@ const baseNotifications: NotificationItem[] = [
35
43
  const meta = {
36
44
  title: 'Dashboard/NotificationCenter',
37
45
  component: NotificationCenter,
38
- render: (args) => ({
39
- template: `<notification-center notifications.bind="notifications"
40
- max-visible.bind="maxVisible"
41
- on-dismiss.bind="onDismiss"
42
- show-timestamp.bind="showTimestamp"></notification-center>`,
43
- props: args,
44
- components: [NotificationCenter],
45
- }),
46
+ render: (args: NotificationCenterArgs) =>
47
+ defineAureliaStory({
48
+ template: `<notification-center notifications.bind="notifications"
49
+ max-visible.bind="maxVisible"
50
+ on-dismiss.bind="onDismiss"
51
+ show-timestamp.bind="showTimestamp"></notification-center>`,
52
+ props: args,
53
+ components: [NotificationCenter],
54
+ }),
46
55
  };
47
56
 
48
57
  export default meta;
49
58
 
50
- type Story = typeof meta;
51
-
52
59
  export const DefaultNotifications = {
53
60
  args: {
54
61
  notifications: baseNotifications,
@@ -1,29 +1,39 @@
1
+ import { defineAureliaStory } from '@aurelia/storybook';
1
2
  import { fn, userEvent, within } from 'storybook/test';
2
3
  import { StatCard } from '../components/stat-card';
3
4
 
5
+ type StatCardArgs = {
6
+ title: string;
7
+ value: number | string;
8
+ unit?: string;
9
+ change?: number;
10
+ changeCopy?: string;
11
+ description?: string;
12
+ onRefresh?: () => void;
13
+ };
14
+
4
15
  const meta = {
5
16
  title: 'Dashboard/StatCard',
6
17
  component: StatCard,
7
18
  parameters: {
8
19
  layout: 'centered',
9
20
  },
10
- render: (args) => ({
11
- components: [StatCard],
12
- template: `<stat-card title.bind="title"
13
- value.bind="value"
14
- unit.bind="unit"
15
- change.bind="change"
16
- change-copy.bind="changeCopy"
17
- description.bind="description"
18
- on-refresh.bind="onRefresh"></stat-card>`,
19
- props: args,
20
- }),
21
+ render: (args: StatCardArgs) =>
22
+ defineAureliaStory({
23
+ components: [StatCard],
24
+ template: `<stat-card title.bind="title"
25
+ value.bind="value"
26
+ unit.bind="unit"
27
+ change.bind="change"
28
+ change-copy.bind="changeCopy"
29
+ description.bind="description"
30
+ on-refresh.bind="onRefresh"></stat-card>`,
31
+ props: args,
32
+ }),
21
33
  };
22
34
 
23
35
  export default meta;
24
36
 
25
- type Story = typeof meta;
26
-
27
37
  export const DefaultCard = {
28
38
  args: {
29
39
  title: 'Active users',
@@ -1,16 +1,22 @@
1
+ import { defineAureliaStory } from '@aurelia/storybook';
1
2
  import { Registration } from 'aurelia';
2
3
  import { fn, userEvent, within } from 'storybook/test';
3
4
  import { WeatherWidget } from '../components/weather-widget';
4
5
  import { IWeatherService, WeatherService, WeatherSummary } from '../services/weather-service';
5
6
 
7
+ type WeatherWidgetArgs = {
8
+ location: string;
9
+ };
10
+
6
11
  const mockService: WeatherService = {
7
12
  async getWeather(location: string): Promise<WeatherSummary> {
13
+ const safeLocation = location ?? '';
8
14
  return {
9
- location,
10
- condition: location.includes('Berlin') ? 'Cloudy' : 'Sunny',
11
- temperature: location.includes('Berlin') ? 16 : 24,
12
- high: location.includes('Berlin') ? 18 : 27,
13
- low: location.includes('Berlin') ? 11 : 19,
15
+ location: safeLocation,
16
+ condition: safeLocation.includes('Berlin') ? 'Cloudy' : 'Sunny',
17
+ temperature: safeLocation.includes('Berlin') ? 16 : 24,
18
+ high: safeLocation.includes('Berlin') ? 18 : 27,
19
+ low: safeLocation.includes('Berlin') ? 11 : 19,
14
20
  };
15
21
  },
16
22
  };
@@ -21,18 +27,17 @@ const meta = {
21
27
  parameters: {
22
28
  layout: 'centered',
23
29
  },
24
- render: (args) => ({
25
- template: `<weather-widget location.bind="location"></weather-widget>`,
26
- props: args,
27
- components: [WeatherWidget],
28
- items: [Registration.instance(IWeatherService, mockService)],
29
- }),
30
+ render: (args: WeatherWidgetArgs) =>
31
+ defineAureliaStory({
32
+ template: `<weather-widget location.bind="location"></weather-widget>`,
33
+ props: args,
34
+ components: [WeatherWidget],
35
+ items: [Registration.instance(IWeatherService, mockService)],
36
+ }),
30
37
  };
31
38
 
32
39
  export default meta;
33
40
 
34
- type Story = typeof meta;
35
-
36
41
  export const DefaultWeather = {
37
42
  args: {
38
43
  location: 'Seattle, WA',
@@ -0,0 +1,16 @@
1
+ import type { StorybookConfig } from 'storybook/internal/types';
2
+
3
+ const config: StorybookConfig = {
4
+ stories: ['../src/stories/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
5
+ addons: [
6
+ ],
7
+ framework: {
8
+ name: '@aurelia/storybook',
9
+ options: {},
10
+ },
11
+ core: {
12
+ builder: 'storybook-builder-rsbuild',
13
+ },
14
+ };
15
+
16
+ export default config;
@@ -0,0 +1 @@
1
+ export { render, renderToCanvas } from '@aurelia/storybook';
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "stylelint-config-standard"
4
+ ]
5
+ }
@@ -0,0 +1,28 @@
1
+ # Aurelia Storybook Hello World
2
+
3
+ This project is bootstrapped by [aurelia/new](https://github.com/aurelia/new).
4
+
5
+ ## Start dev web server
6
+
7
+ npm start
8
+
9
+ ## Start Storybook
10
+
11
+ npm run storybook
12
+
13
+ ## Build the app in production mode
14
+
15
+ npm run build
16
+
17
+ ## Build Storybook
18
+
19
+ npm run build-storybook
20
+
21
+ ## Unit Tests
22
+
23
+ npm run test
24
+
25
+ Run unit tests in watch mode.
26
+
27
+ npm run test:watch
28
+
@@ -0,0 +1,25 @@
1
+ import eslint from "@eslint/js";
2
+ import tseslint from 'typescript-eslint';
3
+ import tsParser from "@typescript-eslint/parser";
4
+ import globals from "globals";
5
+
6
+ export default [
7
+ eslint.configs.recommended,
8
+ ...tseslint.configs.recommended,
9
+ {
10
+ files: ["**/*.ts"],
11
+
12
+ languageOptions: {
13
+ globals: {
14
+ ...globals.builtin,
15
+ ...globals.nodeBuiltin,
16
+ ...globals.browser,
17
+ ...globals.node,
18
+ },
19
+
20
+ parser: tsParser,
21
+ ecmaVersion: 2019,
22
+ sourceType: "module",
23
+ },
24
+ }
25
+ ];
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>Aurelia</title>
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <script type="module" src="/src/main.ts"></script>
9
+ <base href="/">
10
+ </head>
11
+
12
+ <body>
13
+ <my-app></my-app>
14
+ </body>
15
+
16
+ </html>
17
+