@storybook/ember 8.0.0-alpha.2 → 8.0.0-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/client/preview/config.d.ts +1 -0
- package/dist/client/preview/config.js +1 -0
- package/dist/client/preview/docs/config.d.ts +3 -0
- package/dist/client/preview/docs/config.js +13 -0
- package/dist/client/preview/docs/jsondoc.d.ts +3 -0
- package/dist/client/preview/docs/jsondoc.js +49 -0
- package/dist/client/preview/render.js +10 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -1
- package/dist/index.mjs +1 -1
- package/dist/server/framework-preset-babel-ember.js +2 -2
- package/dist/server/framework-preset-ember-docs.js +2 -2
- package/dist/types.d.ts +3 -0
- package/dist/util.d.ts +1 -0
- package/dist/util.js +17 -0
- package/dist/util.mjs +10 -0
- package/package.json +13 -11
- package/template/cli/Button.stories.js +6 -5
- package/template/components/index.js +0 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.parameters = exports.renderToCanvas = void 0;
|
4
|
+
require("./globals");
|
4
5
|
var render_1 = require("./render");
|
5
6
|
Object.defineProperty(exports, "renderToCanvas", { enumerable: true, get: function () { return render_1.renderToCanvas; } });
|
6
7
|
exports.parameters = { renderer: 'ember' };
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.argTypesEnhancers = exports.parameters = void 0;
|
4
|
+
const docs_tools_1 = require("@storybook/docs-tools");
|
5
|
+
const jsondoc_1 = require("./jsondoc");
|
6
|
+
exports.parameters = {
|
7
|
+
docs: {
|
8
|
+
story: { iframeHeight: '80px' },
|
9
|
+
extractArgTypes: jsondoc_1.extractArgTypes,
|
10
|
+
extractComponentDescription: jsondoc_1.extractComponentDescription,
|
11
|
+
},
|
12
|
+
};
|
13
|
+
exports.argTypesEnhancers = [docs_tools_1.enhanceArgTypes];
|
@@ -0,0 +1,49 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.extractComponentDescription = exports.extractArgTypes = exports.getJSONDoc = void 0;
|
4
|
+
/* eslint-disable no-underscore-dangle */
|
5
|
+
const global_1 = require("@storybook/global");
|
6
|
+
const getJSONDoc = () => {
|
7
|
+
return global_1.global.__EMBER_GENERATED_DOC_JSON__;
|
8
|
+
};
|
9
|
+
exports.getJSONDoc = getJSONDoc;
|
10
|
+
const extractArgTypes = (componentName) => {
|
11
|
+
const json = (0, exports.getJSONDoc)();
|
12
|
+
if (!(json && json.included)) {
|
13
|
+
return null;
|
14
|
+
}
|
15
|
+
const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
|
16
|
+
if (!componentDoc) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
return componentDoc.attributes.arguments.reduce((acc, prop) => {
|
20
|
+
acc[prop.name] = {
|
21
|
+
name: prop.name,
|
22
|
+
defaultValue: prop.defaultValue,
|
23
|
+
description: prop.description,
|
24
|
+
table: {
|
25
|
+
defaultValue: { summary: prop.defaultValue },
|
26
|
+
type: {
|
27
|
+
summary: prop.type,
|
28
|
+
required: prop.tags.length
|
29
|
+
? prop.tags.some((tag) => tag.name === 'required')
|
30
|
+
: false,
|
31
|
+
},
|
32
|
+
},
|
33
|
+
};
|
34
|
+
return acc;
|
35
|
+
}, {});
|
36
|
+
};
|
37
|
+
exports.extractArgTypes = extractArgTypes;
|
38
|
+
const extractComponentDescription = (componentName) => {
|
39
|
+
const json = (0, exports.getJSONDoc)();
|
40
|
+
if (!(json && json.included)) {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
|
44
|
+
if (!componentDoc) {
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
return componentDoc.attributes.description;
|
48
|
+
};
|
49
|
+
exports.extractComponentDescription = extractComponentDescription;
|
@@ -1,21 +1,19 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
3
|
exports.renderToCanvas = void 0;
|
7
4
|
const global_1 = require("@storybook/global");
|
8
5
|
const ts_dedent_1 = require("ts-dedent");
|
9
|
-
// @ts-expect-error (Converted from ts-ignore)
|
10
|
-
const component_1 = __importDefault(require("@ember/component")); // eslint-disable-line import/no-unresolved
|
11
6
|
const { document } = global_1.global;
|
12
7
|
const rootEl = document.getElementById('storybook-root');
|
13
|
-
|
14
|
-
const
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
function loadEmberApp() {
|
9
|
+
const config = global_1.global.require(`${global_1.global.STORYBOOK_NAME}/config/environment`);
|
10
|
+
return global_1.global.require(`${global_1.global.STORYBOOK_NAME}/app`).default.create({
|
11
|
+
autoboot: false,
|
12
|
+
rootElement: rootEl,
|
13
|
+
...config.APP,
|
14
|
+
});
|
15
|
+
}
|
16
|
+
const app = loadEmberApp();
|
19
17
|
let lastPromise = app.boot();
|
20
18
|
let hasRendered = false;
|
21
19
|
let isRendering = false;
|
@@ -33,7 +31,7 @@ function render(options, el) {
|
|
33
31
|
return appInstancePrivate.boot().then(() => appInstancePrivate);
|
34
32
|
})
|
35
33
|
.then((instance) => {
|
36
|
-
instance.register('component:story-mode',
|
34
|
+
instance.register('component:story-mode', Ember.Component.extend({
|
37
35
|
layout: template || options,
|
38
36
|
...context,
|
39
37
|
}));
|
package/dist/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
export * from './types';
|
package/dist/index.js
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
"use strict";
|
2
2
|
/// <reference types="webpack-env" />
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
4
|
+
if (k2 === undefined) k2 = k;
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
8
|
+
}
|
9
|
+
Object.defineProperty(o, k2, desc);
|
10
|
+
}) : (function(o, m, k, k2) {
|
11
|
+
if (k2 === undefined) k2 = k;
|
12
|
+
o[k2] = m[k];
|
13
|
+
}));
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
16
|
+
};
|
3
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4
|
-
require("./
|
18
|
+
__exportStar(require("./types"), exports);
|
5
19
|
// optimization: stop HMR propagation in webpack
|
6
20
|
if (typeof module !== 'undefined')
|
7
21
|
module?.hot?.decline();
|
package/dist/index.mjs
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.previewAnnotations = exports.babel = void 0;
|
4
4
|
const ember_template_compiler_1 = require("ember-source/dist/ember-template-compiler");
|
5
|
-
const
|
5
|
+
const util_1 = require("../util");
|
6
6
|
let emberOptions;
|
7
7
|
function precompileWithPlugins(string, options) {
|
8
8
|
const precompileOptions = options;
|
@@ -45,6 +45,6 @@ const babel = (config, options) => {
|
|
45
45
|
};
|
46
46
|
exports.babel = babel;
|
47
47
|
const previewAnnotations = (entry = []) => {
|
48
|
-
return [...entry, (0,
|
48
|
+
return [...entry, (0, util_1.findDistFile)(__dirname, 'client/preview/config')];
|
49
49
|
};
|
50
50
|
exports.previewAnnotations = previewAnnotations;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.previewAnnotations = void 0;
|
4
|
-
const core_common_1 = require("@storybook/core-common");
|
5
4
|
const docs_tools_1 = require("@storybook/docs-tools");
|
5
|
+
const util_1 = require("../util");
|
6
6
|
const previewAnnotations = (entry = [], options) => {
|
7
7
|
if (!(0, docs_tools_1.hasDocsOrControls)(options))
|
8
8
|
return entry;
|
9
|
-
return [...entry, (0,
|
9
|
+
return [...entry, (0, util_1.findDistFile)(__dirname, 'client/preview/docs/config')];
|
10
10
|
};
|
11
11
|
exports.previewAnnotations = previewAnnotations;
|
package/dist/types.d.ts
CHANGED
@@ -22,4 +22,7 @@ type StorybookConfigFramework = {
|
|
22
22
|
* The interface for Storybook configuration in `main.ts` files.
|
23
23
|
*/
|
24
24
|
export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
|
25
|
+
declare global {
|
26
|
+
var __EMBER_GENERATED_DOC_JSON__: any;
|
27
|
+
}
|
25
28
|
export {};
|
package/dist/util.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare const findDistFile: (cwd: string, relativePath: string) => string;
|
package/dist/util.js
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.findDistFile = void 0;
|
7
|
+
const path_1 = __importDefault(require("path"));
|
8
|
+
const find_up_1 = require("find-up");
|
9
|
+
const findDistFile = (cwd, relativePath) => {
|
10
|
+
const nearestPackageJson = (0, find_up_1.sync)('package.json', { cwd });
|
11
|
+
if (!nearestPackageJson) {
|
12
|
+
throw new Error(`Could not find package.json in: ${cwd}`);
|
13
|
+
}
|
14
|
+
const packageDir = path_1.default.dirname(nearestPackageJson);
|
15
|
+
return path_1.default.join(packageDir, 'dist', relativePath);
|
16
|
+
};
|
17
|
+
exports.findDistFile = findDistFile;
|
package/dist/util.mjs
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
import path from 'path';
|
2
|
+
import { sync as findUpSync } from 'find-up';
|
3
|
+
export const findDistFile = (cwd, relativePath) => {
|
4
|
+
const nearestPackageJson = findUpSync('package.json', { cwd });
|
5
|
+
if (!nearestPackageJson) {
|
6
|
+
throw new Error(`Could not find package.json in: ${cwd}`);
|
7
|
+
}
|
8
|
+
const packageDir = path.dirname(nearestPackageJson);
|
9
|
+
return path.join(packageDir, 'dist', relativePath);
|
10
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/ember",
|
3
|
-
"version": "8.0.0-alpha.
|
3
|
+
"version": "8.0.0-alpha.3",
|
4
4
|
"description": "Storybook for Ember: Develop Ember Component in isolation with Hot Reloading.",
|
5
5
|
"homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/ember",
|
6
6
|
"bugs": {
|
@@ -32,12 +32,13 @@
|
|
32
32
|
"prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/tsc.ts"
|
33
33
|
},
|
34
34
|
"dependencies": {
|
35
|
-
"@storybook/builder-webpack5": "8.0.0-alpha.
|
36
|
-
"@storybook/core-common": "8.0.0-alpha.
|
37
|
-
"@storybook/docs-tools": "8.0.0-alpha.
|
35
|
+
"@storybook/builder-webpack5": "8.0.0-alpha.3",
|
36
|
+
"@storybook/core-common": "8.0.0-alpha.3",
|
37
|
+
"@storybook/docs-tools": "8.0.0-alpha.3",
|
38
38
|
"@storybook/global": "^5.0.0",
|
39
|
-
"@storybook/preview-api": "8.0.0-alpha.
|
40
|
-
"@storybook/types": "8.0.0-alpha.
|
39
|
+
"@storybook/preview-api": "8.0.0-alpha.3",
|
40
|
+
"@storybook/types": "8.0.0-alpha.3",
|
41
|
+
"find-up": "^5.0.0",
|
41
42
|
"ts-dedent": "^2.0.0"
|
42
43
|
},
|
43
44
|
"devDependencies": {
|
@@ -46,13 +47,14 @@
|
|
46
47
|
},
|
47
48
|
"peerDependencies": {
|
48
49
|
"@babel/core": "*",
|
49
|
-
"
|
50
|
-
"babel-plugin-
|
51
|
-
"
|
52
|
-
"
|
50
|
+
"babel-plugin-ember-modules-api-polyfill": "^3.5.0",
|
51
|
+
"babel-plugin-htmlbars-inline-precompile": "^5.3.1",
|
52
|
+
"ember-source": "~3.28.1 || ^4.0.0",
|
53
|
+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
54
|
+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
53
55
|
},
|
54
56
|
"engines": {
|
55
|
-
"node": ">=
|
57
|
+
"node": ">=18.0.0"
|
56
58
|
},
|
57
59
|
"publishConfig": {
|
58
60
|
"access": "public"
|
@@ -6,13 +6,13 @@ import { linkTo } from '@storybook/addon-links';
|
|
6
6
|
export default {
|
7
7
|
title: 'Example/Button',
|
8
8
|
render: (args) => ({
|
9
|
-
template: hbs`<button {{
|
9
|
+
template: hbs`<button {{on "click" this.onClick}}>{{this.label}}</button>`,
|
10
10
|
context: args,
|
11
11
|
}),
|
12
12
|
argTypes: {
|
13
13
|
label: { control: 'text' },
|
14
14
|
},
|
15
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
15
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/ember/writing-docs/autodocs
|
16
16
|
tags: ['autodocs'],
|
17
17
|
};
|
18
18
|
|
@@ -27,13 +27,14 @@ export const Text = {
|
|
27
27
|
export const Emoji = {
|
28
28
|
args: {
|
29
29
|
label: '😀 😎 👍 💯',
|
30
|
+
onClick: action('onClick'),
|
30
31
|
},
|
31
32
|
};
|
32
33
|
|
33
34
|
export const TextWithAction = {
|
34
35
|
render: () => ({
|
35
36
|
template: hbs`
|
36
|
-
<button {{
|
37
|
+
<button {{on "click" this.onClick}}>
|
37
38
|
Trigger Action
|
38
39
|
</button>
|
39
40
|
`,
|
@@ -50,12 +51,12 @@ export const TextWithAction = {
|
|
50
51
|
export const ButtonWithLinkToAnotherStory = {
|
51
52
|
render: () => ({
|
52
53
|
template: hbs`
|
53
|
-
<button {{
|
54
|
+
<button {{on "click" this.onClick}}>
|
54
55
|
Go to Welcome Story
|
55
56
|
</button>
|
56
57
|
`,
|
57
58
|
context: {
|
58
|
-
onClick: linkTo('example-
|
59
|
+
onClick: linkTo('example-button--docs'),
|
59
60
|
},
|
60
61
|
}),
|
61
62
|
name: 'button with link to another story',
|
File without changes
|