@aurelia/storybook 2.1.0 → 2.3.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 (116) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +195 -12
  3. package/dist/index.d.ts +25 -0
  4. package/dist/index.js +101 -27
  5. package/dist/index.js.map +1 -1
  6. package/dist/preset.d.ts +21 -0
  7. package/dist/preset.js +74 -20
  8. package/dist/preset.js.map +1 -1
  9. package/dist/preview/helpers.d.ts +2 -0
  10. package/dist/preview/helpers.js +6 -0
  11. package/dist/preview/helpers.js.map +1 -0
  12. package/dist/preview/render.d.ts +7 -0
  13. package/dist/preview/render.js +99 -28
  14. package/dist/preview/render.js.map +1 -1
  15. package/dist/preview/storybook-types-runtime.d.ts +1 -0
  16. package/dist/preview/storybook-types-runtime.js +5 -0
  17. package/dist/preview/storybook-types-runtime.js.map +1 -0
  18. package/dist/preview/storybook-types.d.ts +27 -0
  19. package/dist/preview/types-runtime.d.ts +1 -0
  20. package/dist/preview/types-runtime.js +5 -0
  21. package/dist/preview/types-runtime.js.map +1 -0
  22. package/dist/preview/types.d.ts +44 -0
  23. package/dist/preview.d.ts +3 -0
  24. package/dist/preview.js +104 -29
  25. package/dist/preview.js.map +1 -1
  26. package/dist/webpack.d.ts +10 -0
  27. package/dist/webpack.js +19 -1
  28. package/dist/webpack.js.map +1 -1
  29. package/package.json +75 -15
  30. package/preset.js +2 -1
  31. package/CONTINUITY.md +0 -22
  32. package/__tests__/preset.test.ts +0 -49
  33. package/__tests__/preview.test.ts +0 -139
  34. package/__tests__/render.test.ts +0 -187
  35. package/__tests__/webpack.test.ts +0 -21
  36. package/apps/hello-world/.storybook/main.ts +0 -49
  37. package/apps/hello-world/.storybook/preview.ts +0 -1
  38. package/apps/hello-world/.stylelintrc.json +0 -5
  39. package/apps/hello-world/README.md +0 -28
  40. package/apps/hello-world/eslint.config.mjs +0 -25
  41. package/apps/hello-world/favicon.ico +0 -0
  42. package/apps/hello-world/index.html +0 -17
  43. package/apps/hello-world/package-lock.json +0 -9307
  44. package/apps/hello-world/package.json +0 -55
  45. package/apps/hello-world/src/components/feedback-form.html +0 -111
  46. package/apps/hello-world/src/components/feedback-form.ts +0 -45
  47. package/apps/hello-world/src/components/notification-center.html +0 -119
  48. package/apps/hello-world/src/components/notification-center.ts +0 -27
  49. package/apps/hello-world/src/components/stat-card.html +0 -107
  50. package/apps/hello-world/src/components/stat-card.ts +0 -33
  51. package/apps/hello-world/src/components/weather-widget.html +0 -89
  52. package/apps/hello-world/src/components/weather-widget.ts +0 -30
  53. package/apps/hello-world/src/hello-world.html +0 -48
  54. package/apps/hello-world/src/hello-world.ts +0 -17
  55. package/apps/hello-world/src/main.ts +0 -6
  56. package/apps/hello-world/src/my-app.html +0 -1
  57. package/apps/hello-world/src/my-app.ts +0 -3
  58. package/apps/hello-world/src/resource.d.ts +0 -15
  59. package/apps/hello-world/src/services/weather-service.ts +0 -15
  60. package/apps/hello-world/src/stories/feedback-form.stories.ts +0 -52
  61. package/apps/hello-world/src/stories/hello-world.stories.ts +0 -53
  62. package/apps/hello-world/src/stories/notification-center.stories.ts +0 -81
  63. package/apps/hello-world/src/stories/stat-card.stories.ts +0 -65
  64. package/apps/hello-world/src/stories/weather-widget.stories.ts +0 -57
  65. package/apps/hello-world/test/my-app.spec.ts +0 -15
  66. package/apps/hello-world/test/setup.ts +0 -29
  67. package/apps/hello-world/tsconfig.json +0 -19
  68. package/apps/hello-world/tsconfig.vitest.json +0 -11
  69. package/apps/hello-world/vite.config.ts +0 -17
  70. package/apps/hello-world/vitest.config.ts +0 -15
  71. package/apps/hello-world-webpack/.env.development +0 -0
  72. package/apps/hello-world-webpack/.storybook/main.ts +0 -14
  73. package/apps/hello-world-webpack/.storybook/preview.ts +0 -3
  74. package/apps/hello-world-webpack/.stylelintrc.json +0 -5
  75. package/apps/hello-world-webpack/README.md +0 -29
  76. package/apps/hello-world-webpack/eslint.config.mjs +0 -25
  77. package/apps/hello-world-webpack/favicon.ico +0 -0
  78. package/apps/hello-world-webpack/index.html +0 -15
  79. package/apps/hello-world-webpack/package-lock.json +0 -9853
  80. package/apps/hello-world-webpack/package.json +0 -51
  81. package/apps/hello-world-webpack/src/components/feedback-form.html +0 -111
  82. package/apps/hello-world-webpack/src/components/feedback-form.ts +0 -45
  83. package/apps/hello-world-webpack/src/components/notification-center.html +0 -119
  84. package/apps/hello-world-webpack/src/components/notification-center.ts +0 -27
  85. package/apps/hello-world-webpack/src/components/stat-card.html +0 -107
  86. package/apps/hello-world-webpack/src/components/stat-card.ts +0 -33
  87. package/apps/hello-world-webpack/src/components/weather-widget.html +0 -89
  88. package/apps/hello-world-webpack/src/components/weather-widget.ts +0 -30
  89. package/apps/hello-world-webpack/src/hello-world.html +0 -48
  90. package/apps/hello-world-webpack/src/hello-world.ts +0 -17
  91. package/apps/hello-world-webpack/src/main.ts +0 -6
  92. package/apps/hello-world-webpack/src/my-app.css +0 -3
  93. package/apps/hello-world-webpack/src/my-app.html +0 -1
  94. package/apps/hello-world-webpack/src/my-app.stories.ts +0 -15
  95. package/apps/hello-world-webpack/src/my-app.ts +0 -3
  96. package/apps/hello-world-webpack/src/resource.d.ts +0 -13
  97. package/apps/hello-world-webpack/src/services/weather-service.ts +0 -15
  98. package/apps/hello-world-webpack/src/stories/feedback-form.stories.ts +0 -52
  99. package/apps/hello-world-webpack/src/stories/hello-world.stories.ts +0 -53
  100. package/apps/hello-world-webpack/src/stories/notification-center.stories.ts +0 -81
  101. package/apps/hello-world-webpack/src/stories/stat-card.stories.ts +0 -65
  102. package/apps/hello-world-webpack/src/stories/weather-widget.stories.ts +0 -57
  103. package/apps/hello-world-webpack/tsconfig.json +0 -18
  104. package/apps/hello-world-webpack/webpack.config.js +0 -111
  105. package/dist/preview/types.js +0 -2
  106. package/dist/preview/types.js.map +0 -1
  107. package/jest.config.js +0 -9
  108. package/rollup.config.mjs +0 -50
  109. package/src/index.ts +0 -32
  110. package/src/preset.ts +0 -49
  111. package/src/preview/render.ts +0 -175
  112. package/src/preview/types.ts +0 -7
  113. package/src/preview.ts +0 -1
  114. package/src/webpack.ts +0 -21
  115. package/tsconfig.build.json +0 -5
  116. package/tsconfig.json +0 -15
@@ -1,3 +0,0 @@
1
- export class MyApp {
2
- // Your app logic
3
- }
@@ -1,15 +0,0 @@
1
- declare module '*.html' {
2
- import { IContainer, PartialBindableDefinition } from 'aurelia';
3
- export const name: string;
4
- export const template: string;
5
- export default template;
6
- export const dependencies: string[];
7
- export const containerless: boolean | undefined;
8
- export const bindables: Record<string, PartialBindableDefinition>;
9
- export const shadowOptions: { mode: 'open' | 'closed' } | undefined;
10
- export function register(container: IContainer): void;
11
- }
12
-
13
- declare module '*.css';
14
-
15
- declare module '*.au';
@@ -1,15 +0,0 @@
1
- import { DI } from 'aurelia';
2
-
3
- export interface WeatherSummary {
4
- location: string;
5
- condition: string;
6
- temperature: number;
7
- high: number;
8
- low: number;
9
- }
10
-
11
- export interface WeatherService {
12
- getWeather(location: string): Promise<WeatherSummary>;
13
- }
14
-
15
- export const IWeatherService = DI.createInterface<WeatherService>('IWeatherService');
@@ -1,52 +0,0 @@
1
- import { fn, userEvent, within } from 'storybook/test';
2
- import { FeedbackForm } from '../components/feedback-form';
3
-
4
- const meta = {
5
- title: 'Dashboard/FeedbackForm',
6
- component: FeedbackForm,
7
- parameters: {
8
- layout: 'centered',
9
- },
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
- };
18
-
19
- export default meta;
20
-
21
- type Story = typeof meta;
22
-
23
- export const DefaultForm = {
24
- args: {
25
- topics: ['Bug report', 'Feature request', 'General question'],
26
- onSubmit: fn(),
27
- submitting: false,
28
- },
29
- };
30
-
31
- export const SubmittingState = {
32
- args: {
33
- topics: ['Design review', 'Accessibility', 'Performance'],
34
- submitting: true,
35
- onSubmit: fn(),
36
- },
37
- };
38
-
39
- export const FillAndSubmit = {
40
- args: {
41
- topics: ['Beta feedback', 'Success story'],
42
- onSubmit: fn(),
43
- },
44
- play: async ({ canvasElement }) => {
45
- const canvas = within(canvasElement);
46
- await userEvent.type(canvas.getByLabelText('Name'), 'Jordan');
47
- await userEvent.type(canvas.getByLabelText('Email'), 'jordan@example.com');
48
- await userEvent.selectOptions(canvas.getByLabelText('Topic'), 'Success story');
49
- await userEvent.type(canvas.getByLabelText('Message'), 'The new timeline view is great');
50
- await userEvent.click(canvas.getByRole('button', { name: /send feedback/i }));
51
- },
52
- };
@@ -1,53 +0,0 @@
1
- import { HelloWorld } from '../hello-world';
2
- import { fn, userEvent, within } from 'storybook/test';
3
-
4
- const meta = {
5
- title: 'Example/HelloWorld',
6
- component: HelloWorld,
7
- render: () => ({
8
- template: `<hello-world message.bind="message" on-increment.bind="onIncrement"></hello-world>`,
9
- }),
10
- argTypes: {
11
- message: { control: 'text' },
12
- onIncrement: { action: 'increment' }
13
- }
14
- };
15
-
16
- export default meta;
17
-
18
- export const DefaultHelloWorld = {
19
- args: {
20
- message: 'Hello from Aurelia Storybook',
21
- onIncrement: fn()
22
- }
23
- };
24
-
25
- export const InteractiveHelloWorld = {
26
- args: {
27
- message: 'Try clicking the button!',
28
- onIncrement: fn()
29
- },
30
- play: async ({ canvasElement }: { canvasElement: HTMLElement }) => {
31
- const canvas = within(canvasElement);
32
- const button = canvas.getByRole('button');
33
- // Simulate three button clicks
34
- await userEvent.click(button);
35
- await userEvent.click(button);
36
- await userEvent.click(button);
37
- }
38
- };
39
-
40
- export const NoArgs = {
41
- render: () => ({
42
- template: `<hello-world></hello-world>`
43
- })
44
- };
45
-
46
- export const WithCustomTemplate = {
47
- render: () => ({
48
- template: `<hello-world message.bind="message">Click me!</hello-world>`
49
- }),
50
- args: {
51
- message: 'This is a custom message'
52
- }
53
- };
@@ -1,81 +0,0 @@
1
- import { fn, userEvent, within } from 'storybook/test';
2
- import { NotificationCenter, NotificationItem } from '../components/notification-center';
3
-
4
- const baseNotifications: NotificationItem[] = [
5
- {
6
- id: 1,
7
- title: 'Build succeeded',
8
- message: 'Main pipeline finished in 4m 12s.',
9
- level: 'success',
10
- timestamp: 'Today - 09:24',
11
- },
12
- {
13
- id: 2,
14
- title: 'New comment',
15
- message: 'Samira replied to your review on PR #512.',
16
- level: 'info',
17
- timestamp: 'Today - 08:51',
18
- },
19
- {
20
- id: 3,
21
- title: 'Usage warning',
22
- message: 'API quota is at 85% of the monthly allocation.',
23
- level: 'warning',
24
- timestamp: 'Yesterday - 17:05',
25
- },
26
- {
27
- id: 4,
28
- title: 'Error spike',
29
- message: 'Synthetic tests detected an uptick in 500s.',
30
- level: 'error',
31
- timestamp: 'Yesterday - 15:33',
32
- },
33
- ];
34
-
35
- const meta = {
36
- title: 'Dashboard/NotificationCenter',
37
- 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
- };
47
-
48
- export default meta;
49
-
50
- type Story = typeof meta;
51
-
52
- export const DefaultNotifications = {
53
- args: {
54
- notifications: baseNotifications,
55
- maxVisible: 3,
56
- showTimestamp: true,
57
- onDismiss: fn(),
58
- },
59
- };
60
-
61
- export const CompactList = {
62
- args: {
63
- notifications: baseNotifications.slice(0, 2),
64
- maxVisible: 2,
65
- onDismiss: fn(),
66
- showTimestamp: false,
67
- },
68
- };
69
-
70
- export const Interactions = {
71
- args: {
72
- notifications: baseNotifications,
73
- maxVisible: 4,
74
- onDismiss: fn(),
75
- },
76
- play: async ({ canvasElement }) => {
77
- const canvas = within(canvasElement);
78
- const dismissButtons = await canvas.findAllByRole('button', { name: /dismiss/i });
79
- await userEvent.click(dismissButtons[0]);
80
- },
81
- };
@@ -1,65 +0,0 @@
1
- import { fn, userEvent, within } from 'storybook/test';
2
- import { StatCard } from '../components/stat-card';
3
-
4
- const meta = {
5
- title: 'Dashboard/StatCard',
6
- component: StatCard,
7
- parameters: {
8
- layout: 'centered',
9
- },
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
- };
22
-
23
- export default meta;
24
-
25
- type Story = typeof meta;
26
-
27
- export const DefaultCard = {
28
- args: {
29
- title: 'Active users',
30
- value: 1284,
31
- unit: '',
32
- change: 12.5,
33
- changeCopy: 'vs last week',
34
- description: 'Rolling 7-day average of unique user sessions.',
35
- onRefresh: fn(),
36
- },
37
- };
38
-
39
- export const NegativeTrend = {
40
- args: {
41
- title: 'NPS score',
42
- value: 42,
43
- change: -6.3,
44
- changeCopy: 'vs previous survey',
45
- description: 'Direct feedback collected from in-app survey responses.',
46
- onRefresh: fn(),
47
- },
48
- };
49
-
50
- export const ManualRefreshDemo = {
51
- args: {
52
- title: 'Deploy success rate',
53
- value: '99.2',
54
- unit: '%',
55
- change: 1.1,
56
- changeCopy: 'vs last 24h',
57
- description: 'Completed deploys without rollbacks.',
58
- onRefresh: fn(),
59
- },
60
- play: async ({ canvasElement }) => {
61
- const canvas = within(canvasElement);
62
- const refreshButton = await canvas.findByRole('button', { name: /refresh metric/i });
63
- await userEvent.click(refreshButton);
64
- },
65
- };
@@ -1,57 +0,0 @@
1
- import { Registration } from 'aurelia';
2
- import { fn, userEvent, within } from 'storybook/test';
3
- import { WeatherWidget } from '../components/weather-widget';
4
- import { IWeatherService, WeatherService, WeatherSummary } from '../services/weather-service';
5
-
6
- const mockService: WeatherService = {
7
- async getWeather(location: string): Promise<WeatherSummary> {
8
- 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,
14
- };
15
- },
16
- };
17
-
18
- const meta = {
19
- title: 'Dashboard/WeatherWidget',
20
- component: WeatherWidget,
21
- parameters: {
22
- layout: 'centered',
23
- },
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
- };
31
-
32
- export default meta;
33
-
34
- type Story = typeof meta;
35
-
36
- export const DefaultWeather = {
37
- args: {
38
- location: 'Seattle, WA',
39
- },
40
- };
41
-
42
- export const EuropeanCity = {
43
- args: {
44
- location: 'Berlin, Germany',
45
- },
46
- };
47
-
48
- export const RefreshInteraction = {
49
- args: {
50
- location: 'Lisbon, Portugal',
51
- },
52
- play: async ({ canvasElement }) => {
53
- const canvas = within(canvasElement);
54
- const refreshButton = await canvas.findByRole('button', { name: /refresh/i });
55
- await userEvent.click(refreshButton);
56
- },
57
- };
@@ -1,15 +0,0 @@
1
- import { describe, it } from 'vitest';
2
- import { MyApp } from '../src/my-app';
3
- import { createFixture } from '@aurelia/testing';
4
-
5
- describe('my-app', () => {
6
- it('should render message', async () => {
7
- const { assertText } = await createFixture(
8
- '<my-app></my-app>',
9
- {},
10
- [MyApp],
11
- ).started;
12
-
13
- assertText('Hello World!', { compact: true });
14
- });
15
- });
@@ -1,29 +0,0 @@
1
- import { BrowserPlatform } from '@aurelia/platform-browser';
2
- import { setPlatform, onFixtureCreated, type IFixture } from '@aurelia/testing';
3
- import { beforeAll, afterEach } from 'vitest';
4
-
5
- // Sets up the Aurelia environment for testing
6
- function bootstrapTextEnv() {
7
- const platform = new BrowserPlatform(window);
8
- setPlatform(platform);
9
- BrowserPlatform.set(globalThis, platform);
10
- }
11
-
12
- const fixtures: IFixture<object>[] = [];
13
- beforeAll(() => {
14
- bootstrapTextEnv();
15
- onFixtureCreated(fixture => {
16
- fixtures.push(fixture);
17
- });
18
- });
19
-
20
- afterEach(() => {
21
- fixtures.forEach(async f => {
22
- try {
23
- await f.stop(true);
24
- } catch {
25
- // ignore
26
- }
27
- });
28
- fixtures.length = 0;
29
- });
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "esnext",
4
- "moduleResolution": "bundler",
5
- "skipLibCheck": true,
6
- "target": "ES2017",
7
- "esModuleInterop": true,
8
- "resolveJsonModule": true,
9
- "importHelpers": true,
10
- "sourceMap": true
11
- },
12
- "include": [
13
- "src",
14
- "aurelia-sfc-plugin.js"
15
- ],
16
- "files": [
17
- "src/resource.d.ts"
18
- ]
19
- }
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "composite": true,
5
- "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
6
- "types": [
7
- "node",
8
- "jsdom"
9
- ]
10
- }
11
- }
@@ -1,17 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import aurelia from '@aurelia/vite-plugin';
3
-
4
- export default defineConfig({
5
- server: {
6
- open: !process.env.CI,
7
- port: 9000,
8
- },
9
- esbuild: {
10
- target: 'es2022'
11
- },
12
- plugins: [
13
- aurelia({
14
- useDev: true,
15
- }),
16
- ],
17
- });
@@ -1,15 +0,0 @@
1
- import { fileURLToPath } from "node:url";
2
- import { mergeConfig, defineConfig } from "vitest/config";
3
- import viteConfig from "./vite.config";
4
-
5
- export default mergeConfig(
6
- viteConfig,
7
- defineConfig({
8
- test: {
9
- environment: "jsdom",
10
- watch: false,
11
- root: fileURLToPath(new URL("./", import.meta.url)),
12
- setupFiles: ["./test/setup.ts"]
13
- },
14
- }),
15
- );
File without changes
@@ -1,14 +0,0 @@
1
- const config = {
2
- stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
3
- addons: [
4
- ],
5
- framework: {
6
- name: '@aurelia/storybook',
7
- options: {},
8
- },
9
- core: {
10
- builder: '@storybook/builder-webpack5',
11
- },
12
- docs: {},
13
- };
14
- export default config;
@@ -1,3 +0,0 @@
1
- // .storybook/preview.ts
2
- // Import the render function from the plugin package.
3
- export { render, renderToCanvas } from '@aurelia/storybook';
@@ -1,5 +0,0 @@
1
- {
2
- "extends": [
3
- "stylelint-config-standard"
4
- ]
5
- }
@@ -1,29 +0,0 @@
1
- # examples
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
- ## Build the app in production mode
10
-
11
- npm run build
12
-
13
- It builds all files to dist folder. To deploy to production server, copy all the `dist/*` files to production root folder.
14
-
15
- For example
16
- ```
17
- dist/index.html
18
- dist/foo.12345.js
19
- ```
20
- Copy to production root folder
21
- ```
22
- root_folder/index.html
23
- root_folder/foo.12345.js
24
- ```
25
-
26
-
27
- ## Analyze webpack bundle
28
-
29
- npm run analyze
@@ -1,25 +0,0 @@
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
- ];
@@ -1,15 +0,0 @@
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
- <base href="/">
9
- </head>
10
-
11
- <body>
12
- <my-app></my-app>
13
- </body>
14
-
15
- </html>