@storybook/vue3 6.4.0-beta.9 → 6.4.0-rc.3
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/dist/cjs/client/index.js +8 -1
- package/dist/cjs/client/preview/config.js +8 -0
- package/dist/cjs/client/preview/decorateStory.js +73 -0
- package/dist/cjs/client/preview/index.js +9 -68
- package/dist/cjs/client/preview/render.js +2 -1
- package/dist/cjs/server/framework-preset-vue3.js +10 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/client/preview/config.js +1 -0
- package/dist/esm/client/preview/decorateStory.js +63 -0
- package/dist/esm/client/preview/index.js +3 -65
- package/dist/esm/client/preview/render.js +1 -1
- package/dist/esm/server/framework-preset-vue3.js +5 -1
- package/dist/modern/client/index.js +1 -1
- package/dist/modern/client/preview/config.js +1 -0
- package/dist/modern/client/preview/decorateStory.js +59 -0
- package/dist/modern/client/preview/index.js +3 -61
- package/dist/modern/client/preview/render.js +1 -1
- package/dist/modern/server/framework-preset-vue3.js +5 -1
- package/dist/ts3.4/client/index.d.ts +1 -1
- package/dist/ts3.4/client/preview/config.d.ts +1 -0
- package/dist/ts3.4/client/preview/decorateStory.d.ts +3 -0
- package/dist/ts3.4/client/preview/index.d.ts +9 -10
- package/dist/ts3.4/client/preview/render.d.ts +1 -0
- package/dist/ts3.4/server/framework-preset-vue3.d.ts +2 -0
- package/dist/ts3.9/client/index.d.ts +1 -1
- package/dist/ts3.9/client/preview/config.d.ts +1 -0
- package/dist/ts3.9/client/preview/decorateStory.d.ts +3 -0
- package/dist/ts3.9/client/preview/index.d.ts +9 -10
- package/dist/ts3.9/client/preview/render.d.ts +1 -0
- package/dist/ts3.9/server/framework-preset-vue3.d.ts +2 -0
- package/package.json +7 -7
- package/preset.js +1 -7
- package/types-7-0.d.ts +1 -0
package/dist/cjs/client/index.js
CHANGED
|
@@ -16,7 +16,8 @@ var _exportNames = {
|
|
|
16
16
|
getStorybook: true,
|
|
17
17
|
forceReRender: true,
|
|
18
18
|
raw: true,
|
|
19
|
-
app: true
|
|
19
|
+
app: true,
|
|
20
|
+
activeStoryComponent: true
|
|
20
21
|
};
|
|
21
22
|
Object.defineProperty(exports, "storiesOf", {
|
|
22
23
|
enumerable: true,
|
|
@@ -72,6 +73,12 @@ Object.defineProperty(exports, "app", {
|
|
|
72
73
|
return _preview.app;
|
|
73
74
|
}
|
|
74
75
|
});
|
|
76
|
+
Object.defineProperty(exports, "activeStoryComponent", {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function get() {
|
|
79
|
+
return _preview.activeStoryComponent;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
75
82
|
|
|
76
83
|
var _preview = require("./preview");
|
|
77
84
|
|
|
@@ -9,10 +9,18 @@ Object.defineProperty(exports, "renderToDOM", {
|
|
|
9
9
|
return _render.renderToDOM;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
+
Object.defineProperty(exports, "decorateStory", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _decorateStory.decorateStory;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
exports.parameters = void 0;
|
|
13
19
|
|
|
14
20
|
var _render = require("./render");
|
|
15
21
|
|
|
22
|
+
var _decorateStory = require("./decorateStory");
|
|
23
|
+
|
|
16
24
|
var parameters = {
|
|
17
25
|
framework: 'vue3'
|
|
18
26
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.decorateStory = decorateStory;
|
|
7
|
+
|
|
8
|
+
require("core-js/modules/es.function.name.js");
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.object.assign.js");
|
|
11
|
+
|
|
12
|
+
var _vue = require("vue");
|
|
13
|
+
|
|
14
|
+
var _store = require("@storybook/store");
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
This normalizes a functional component into a render method in ComponentOptions.
|
|
18
|
+
|
|
19
|
+
The concept is taken from Vue 3's `defineComponent` but changed from creating a `setup`
|
|
20
|
+
method on the ComponentOptions so end-users don't need to specify a "thunk" as a decorator.
|
|
21
|
+
*/
|
|
22
|
+
function normalizeFunctionalComponent(options) {
|
|
23
|
+
return typeof options === 'function' ? {
|
|
24
|
+
render: options,
|
|
25
|
+
name: options.name
|
|
26
|
+
} : options;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function prepare(rawStory, innerStory) {
|
|
30
|
+
var story = rawStory;
|
|
31
|
+
|
|
32
|
+
if (story == null) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (innerStory) {
|
|
37
|
+
return Object.assign({}, normalizeFunctionalComponent(story), {
|
|
38
|
+
components: Object.assign({}, story.components || {}, {
|
|
39
|
+
story: innerStory
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
render: function render() {
|
|
46
|
+
return (0, _vue.h)(story);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function decorateStory(storyFn, decorators) {
|
|
52
|
+
return decorators.reduce(function (decorated, decorator) {
|
|
53
|
+
return function (context) {
|
|
54
|
+
var story;
|
|
55
|
+
var decoratedStory = decorator(function (update) {
|
|
56
|
+
story = decorated(Object.assign({}, context, (0, _store.sanitizeStoryContextUpdate)(update)));
|
|
57
|
+
return story;
|
|
58
|
+
}, context);
|
|
59
|
+
|
|
60
|
+
if (!story) {
|
|
61
|
+
story = decorated(context);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (decoratedStory === story) {
|
|
65
|
+
return story;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return prepare(decoratedStory, story);
|
|
69
|
+
};
|
|
70
|
+
}, function (context) {
|
|
71
|
+
return prepare(storyFn(context));
|
|
72
|
+
});
|
|
73
|
+
}
|
|
@@ -3,86 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
Object.defineProperty(exports, "activeStoryComponent", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _render.activeStoryComponent;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
6
12
|
exports.app = exports.raw = exports.getStorybook = exports.forceReRender = exports.setAddon = exports.clearDecorators = exports.addParameters = exports.addDecorator = exports.configure = exports.storiesOf = void 0;
|
|
7
13
|
|
|
8
|
-
require("core-js/modules/es.function.name.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.object.assign.js");
|
|
11
|
-
|
|
12
14
|
require("core-js/modules/es.array.concat.js");
|
|
13
15
|
|
|
14
|
-
var _vue = require("vue");
|
|
15
|
-
|
|
16
16
|
var _client = require("@storybook/core/client");
|
|
17
17
|
|
|
18
|
-
var _store = require("@storybook/store");
|
|
19
|
-
|
|
20
18
|
require("./globals");
|
|
21
19
|
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
/*
|
|
25
|
-
This normalizes a functional component into a render method in ComponentOptions.
|
|
26
|
-
|
|
27
|
-
The concept is taken from Vue 3's `defineComponent` but changed from creating a `setup`
|
|
28
|
-
method on the ComponentOptions so end-users don't need to specify a "thunk" as a decorator.
|
|
29
|
-
*/
|
|
30
|
-
function normalizeFunctionalComponent(options) {
|
|
31
|
-
return typeof options === 'function' ? {
|
|
32
|
-
render: options,
|
|
33
|
-
name: options.name
|
|
34
|
-
} : options;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function prepare(rawStory, innerStory) {
|
|
38
|
-
var story = rawStory;
|
|
20
|
+
var _decorateStory = require("./decorateStory");
|
|
39
21
|
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (innerStory) {
|
|
45
|
-
return Object.assign({}, normalizeFunctionalComponent(story), {
|
|
46
|
-
components: Object.assign({}, story.components || {}, {
|
|
47
|
-
story: innerStory
|
|
48
|
-
})
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
render: function render() {
|
|
54
|
-
return (0, _vue.h)(story);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function decorateStory(storyFn, decorators) {
|
|
60
|
-
return decorators.reduce(function (decorated, decorator) {
|
|
61
|
-
return function (context) {
|
|
62
|
-
var story;
|
|
63
|
-
var decoratedStory = decorator(function (update) {
|
|
64
|
-
story = decorated(Object.assign({}, context, (0, _store.sanitizeStoryContextUpdate)(update)));
|
|
65
|
-
return story;
|
|
66
|
-
}, context);
|
|
67
|
-
|
|
68
|
-
if (!story) {
|
|
69
|
-
story = decorated(context);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (decoratedStory === story) {
|
|
73
|
-
return story;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return prepare(decoratedStory, story);
|
|
77
|
-
};
|
|
78
|
-
}, function (context) {
|
|
79
|
-
return prepare(storyFn(context));
|
|
80
|
-
});
|
|
81
|
-
}
|
|
22
|
+
var _render = require("./render");
|
|
82
23
|
|
|
83
24
|
var framework = 'vue3';
|
|
84
25
|
var api = (0, _client.start)(_render.renderToDOM, {
|
|
85
|
-
decorateStory: decorateStory
|
|
26
|
+
decorateStory: _decorateStory.decorateStory
|
|
86
27
|
});
|
|
87
28
|
|
|
88
29
|
var storiesOf = function storiesOf(kind, m) {
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
10
|
exports.renderToDOM = renderToDOM;
|
|
11
|
-
exports.storybookApp = void 0;
|
|
11
|
+
exports.storybookApp = exports.activeStoryComponent = void 0;
|
|
12
12
|
|
|
13
13
|
require("core-js/modules/es.function.name.js");
|
|
14
14
|
|
|
@@ -25,6 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
26
26
|
|
|
27
27
|
var activeStoryComponent = (0, _vue.shallowRef)(null);
|
|
28
|
+
exports.activeStoryComponent = activeStoryComponent;
|
|
28
29
|
var root = null;
|
|
29
30
|
var storybookApp = (0, _vue.createApp)({
|
|
30
31
|
// If an end-user calls `unmount` on the app, we need to clear our root variable
|
|
@@ -4,11 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.webpack = webpack;
|
|
7
|
+
exports.config = void 0;
|
|
7
8
|
|
|
8
9
|
var _vueLoader = require("vue-loader");
|
|
9
10
|
|
|
10
11
|
var _webpack = require("webpack");
|
|
11
12
|
|
|
13
|
+
var _coreCommon = require("@storybook/core-common");
|
|
14
|
+
|
|
12
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
13
16
|
|
|
14
17
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -44,4 +47,10 @@ function webpack(config) {
|
|
|
44
47
|
})
|
|
45
48
|
})
|
|
46
49
|
});
|
|
47
|
-
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var config = function (entry = []) {
|
|
53
|
+
return [...entry, (0, _coreCommon.findDistEsm)(__dirname, 'client/preview/config')];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
exports.config = config;
|
package/dist/esm/client/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app } from './preview';
|
|
1
|
+
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app, activeStoryComponent } from './preview';
|
|
2
2
|
export * from './preview/types-6-0';
|
|
3
3
|
|
|
4
4
|
if (module && module.hot && module.hot.decline) {
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "core-js/modules/es.function.name.js";
|
|
2
|
+
import "core-js/modules/es.object.assign.js";
|
|
3
|
+
import { h } from 'vue';
|
|
4
|
+
import { sanitizeStoryContextUpdate } from '@storybook/store';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
This normalizes a functional component into a render method in ComponentOptions.
|
|
8
|
+
|
|
9
|
+
The concept is taken from Vue 3's `defineComponent` but changed from creating a `setup`
|
|
10
|
+
method on the ComponentOptions so end-users don't need to specify a "thunk" as a decorator.
|
|
11
|
+
*/
|
|
12
|
+
function normalizeFunctionalComponent(options) {
|
|
13
|
+
return typeof options === 'function' ? {
|
|
14
|
+
render: options,
|
|
15
|
+
name: options.name
|
|
16
|
+
} : options;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function prepare(rawStory, innerStory) {
|
|
20
|
+
var story = rawStory;
|
|
21
|
+
|
|
22
|
+
if (story == null) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (innerStory) {
|
|
27
|
+
return Object.assign({}, normalizeFunctionalComponent(story), {
|
|
28
|
+
components: Object.assign({}, story.components || {}, {
|
|
29
|
+
story: innerStory
|
|
30
|
+
})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
render: function render() {
|
|
36
|
+
return h(story);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function decorateStory(storyFn, decorators) {
|
|
42
|
+
return decorators.reduce(function (decorated, decorator) {
|
|
43
|
+
return function (context) {
|
|
44
|
+
var story;
|
|
45
|
+
var decoratedStory = decorator(function (update) {
|
|
46
|
+
story = decorated(Object.assign({}, context, sanitizeStoryContextUpdate(update)));
|
|
47
|
+
return story;
|
|
48
|
+
}, context);
|
|
49
|
+
|
|
50
|
+
if (!story) {
|
|
51
|
+
story = decorated(context);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (decoratedStory === story) {
|
|
55
|
+
return story;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return prepare(decoratedStory, story);
|
|
59
|
+
};
|
|
60
|
+
}, function (context) {
|
|
61
|
+
return prepare(storyFn(context));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
@@ -1,71 +1,8 @@
|
|
|
1
|
-
import "core-js/modules/es.function.name.js";
|
|
2
|
-
import "core-js/modules/es.object.assign.js";
|
|
3
1
|
import "core-js/modules/es.array.concat.js";
|
|
4
|
-
import { h } from 'vue';
|
|
5
2
|
import { start } from '@storybook/core/client';
|
|
6
|
-
import { sanitizeStoryContextUpdate } from '@storybook/store';
|
|
7
3
|
import './globals';
|
|
4
|
+
import { decorateStory } from './decorateStory';
|
|
8
5
|
import { renderToDOM, storybookApp } from './render';
|
|
9
|
-
/*
|
|
10
|
-
This normalizes a functional component into a render method in ComponentOptions.
|
|
11
|
-
|
|
12
|
-
The concept is taken from Vue 3's `defineComponent` but changed from creating a `setup`
|
|
13
|
-
method on the ComponentOptions so end-users don't need to specify a "thunk" as a decorator.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
function normalizeFunctionalComponent(options) {
|
|
17
|
-
return typeof options === 'function' ? {
|
|
18
|
-
render: options,
|
|
19
|
-
name: options.name
|
|
20
|
-
} : options;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function prepare(rawStory, innerStory) {
|
|
24
|
-
var story = rawStory;
|
|
25
|
-
|
|
26
|
-
if (story == null) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (innerStory) {
|
|
31
|
-
return Object.assign({}, normalizeFunctionalComponent(story), {
|
|
32
|
-
components: Object.assign({}, story.components || {}, {
|
|
33
|
-
story: innerStory
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
render: function render() {
|
|
40
|
-
return h(story);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function decorateStory(storyFn, decorators) {
|
|
46
|
-
return decorators.reduce(function (decorated, decorator) {
|
|
47
|
-
return function (context) {
|
|
48
|
-
var story;
|
|
49
|
-
var decoratedStory = decorator(function (update) {
|
|
50
|
-
story = decorated(Object.assign({}, context, sanitizeStoryContextUpdate(update)));
|
|
51
|
-
return story;
|
|
52
|
-
}, context);
|
|
53
|
-
|
|
54
|
-
if (!story) {
|
|
55
|
-
story = decorated(context);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (decoratedStory === story) {
|
|
59
|
-
return story;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return prepare(decoratedStory, story);
|
|
63
|
-
};
|
|
64
|
-
}, function (context) {
|
|
65
|
-
return prepare(storyFn(context));
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
6
|
var framework = 'vue3';
|
|
70
7
|
var api = start(renderToDOM, {
|
|
71
8
|
decorateStory: decorateStory
|
|
@@ -96,4 +33,5 @@ var getStorybook = api.clientApi.getStorybook;
|
|
|
96
33
|
export { getStorybook };
|
|
97
34
|
var raw = api.clientApi.raw;
|
|
98
35
|
export { raw };
|
|
99
|
-
export var app = storybookApp;
|
|
36
|
+
export var app = storybookApp;
|
|
37
|
+
export { activeStoryComponent } from './render';
|
|
@@ -8,7 +8,7 @@ import "core-js/modules/es.array.slice.js";
|
|
|
8
8
|
import "core-js/modules/es.object.freeze.js";
|
|
9
9
|
import dedent from 'ts-dedent';
|
|
10
10
|
import { createApp, h, shallowRef } from 'vue';
|
|
11
|
-
var activeStoryComponent = shallowRef(null);
|
|
11
|
+
export var activeStoryComponent = shallowRef(null);
|
|
12
12
|
var root = null;
|
|
13
13
|
export var storybookApp = createApp({
|
|
14
14
|
// If an end-user calls `unmount` on the app, we need to clear our root variable
|
|
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import { VueLoaderPlugin } from 'vue-loader';
|
|
8
8
|
import { DefinePlugin } from 'webpack';
|
|
9
|
+
import { findDistEsm } from '@storybook/core-common';
|
|
9
10
|
export function webpack(config) {
|
|
10
11
|
return _objectSpread(_objectSpread({}, config), {}, {
|
|
11
12
|
plugins: [...config.plugins, new VueLoaderPlugin(), new DefinePlugin({
|
|
@@ -35,4 +36,7 @@ export function webpack(config) {
|
|
|
35
36
|
})
|
|
36
37
|
})
|
|
37
38
|
});
|
|
38
|
-
}
|
|
39
|
+
}
|
|
40
|
+
export var config = function (entry = []) {
|
|
41
|
+
return [...entry, findDistEsm(__dirname, 'client/preview/config')];
|
|
42
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app } from './preview';
|
|
1
|
+
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app, activeStoryComponent } from './preview';
|
|
2
2
|
export * from './preview/types-6-0';
|
|
3
3
|
|
|
4
4
|
if (module && module.hot && module.hot.decline) {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import "core-js/modules/es.array.reduce.js";
|
|
2
|
+
import { h } from 'vue';
|
|
3
|
+
import { sanitizeStoryContextUpdate } from '@storybook/store';
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
This normalizes a functional component into a render method in ComponentOptions.
|
|
7
|
+
|
|
8
|
+
The concept is taken from Vue 3's `defineComponent` but changed from creating a `setup`
|
|
9
|
+
method on the ComponentOptions so end-users don't need to specify a "thunk" as a decorator.
|
|
10
|
+
*/
|
|
11
|
+
function normalizeFunctionalComponent(options) {
|
|
12
|
+
return typeof options === 'function' ? {
|
|
13
|
+
render: options,
|
|
14
|
+
name: options.name
|
|
15
|
+
} : options;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function prepare(rawStory, innerStory) {
|
|
19
|
+
const story = rawStory;
|
|
20
|
+
|
|
21
|
+
if (story == null) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (innerStory) {
|
|
26
|
+
return Object.assign({}, normalizeFunctionalComponent(story), {
|
|
27
|
+
components: Object.assign({}, story.components || {}, {
|
|
28
|
+
story: innerStory
|
|
29
|
+
})
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
render() {
|
|
35
|
+
return h(story);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function decorateStory(storyFn, decorators) {
|
|
42
|
+
return decorators.reduce((decorated, decorator) => context => {
|
|
43
|
+
let story;
|
|
44
|
+
const decoratedStory = decorator(update => {
|
|
45
|
+
story = decorated(Object.assign({}, context, sanitizeStoryContextUpdate(update)));
|
|
46
|
+
return story;
|
|
47
|
+
}, context);
|
|
48
|
+
|
|
49
|
+
if (!story) {
|
|
50
|
+
story = decorated(context);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (decoratedStory === story) {
|
|
54
|
+
return story;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return prepare(decoratedStory, story);
|
|
58
|
+
}, context => prepare(storyFn(context)));
|
|
59
|
+
}
|
|
@@ -1,66 +1,7 @@
|
|
|
1
|
-
import "core-js/modules/es.array.reduce.js";
|
|
2
|
-
import { h } from 'vue';
|
|
3
1
|
import { start } from '@storybook/core/client';
|
|
4
|
-
import { sanitizeStoryContextUpdate } from '@storybook/store';
|
|
5
2
|
import './globals';
|
|
3
|
+
import { decorateStory } from './decorateStory';
|
|
6
4
|
import { renderToDOM, storybookApp } from './render';
|
|
7
|
-
/*
|
|
8
|
-
This normalizes a functional component into a render method in ComponentOptions.
|
|
9
|
-
|
|
10
|
-
The concept is taken from Vue 3's `defineComponent` but changed from creating a `setup`
|
|
11
|
-
method on the ComponentOptions so end-users don't need to specify a "thunk" as a decorator.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
function normalizeFunctionalComponent(options) {
|
|
15
|
-
return typeof options === 'function' ? {
|
|
16
|
-
render: options,
|
|
17
|
-
name: options.name
|
|
18
|
-
} : options;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function prepare(rawStory, innerStory) {
|
|
22
|
-
const story = rawStory;
|
|
23
|
-
|
|
24
|
-
if (story == null) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (innerStory) {
|
|
29
|
-
return Object.assign({}, normalizeFunctionalComponent(story), {
|
|
30
|
-
components: Object.assign({}, story.components || {}, {
|
|
31
|
-
story: innerStory
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
render() {
|
|
38
|
-
return h(story);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function decorateStory(storyFn, decorators) {
|
|
45
|
-
return decorators.reduce((decorated, decorator) => context => {
|
|
46
|
-
let story;
|
|
47
|
-
const decoratedStory = decorator(update => {
|
|
48
|
-
story = decorated(Object.assign({}, context, sanitizeStoryContextUpdate(update)));
|
|
49
|
-
return story;
|
|
50
|
-
}, context);
|
|
51
|
-
|
|
52
|
-
if (!story) {
|
|
53
|
-
story = decorated(context);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (decoratedStory === story) {
|
|
57
|
-
return story;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return prepare(decoratedStory, story);
|
|
61
|
-
}, context => prepare(storyFn(context)));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
5
|
const framework = 'vue3';
|
|
65
6
|
const api = start(renderToDOM, {
|
|
66
7
|
decorateStory
|
|
@@ -92,4 +33,5 @@ export const {
|
|
|
92
33
|
export const {
|
|
93
34
|
raw
|
|
94
35
|
} = api.clientApi;
|
|
95
|
-
export const app = storybookApp;
|
|
36
|
+
export const app = storybookApp;
|
|
37
|
+
export { activeStoryComponent } from './render';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import dedent from 'ts-dedent';
|
|
2
2
|
import { createApp, h, shallowRef } from 'vue';
|
|
3
|
-
const activeStoryComponent = shallowRef(null);
|
|
3
|
+
export const activeStoryComponent = shallowRef(null);
|
|
4
4
|
let root = null;
|
|
5
5
|
export const storybookApp = createApp({
|
|
6
6
|
// If an end-user calls `unmount` on the app, we need to clear our root variable
|
|
@@ -6,6 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import { VueLoaderPlugin } from 'vue-loader';
|
|
8
8
|
import { DefinePlugin } from 'webpack';
|
|
9
|
+
import { findDistEsm } from '@storybook/core-common';
|
|
9
10
|
export function webpack(config) {
|
|
10
11
|
return _objectSpread(_objectSpread({}, config), {}, {
|
|
11
12
|
plugins: [...config.plugins, new VueLoaderPlugin(), new DefinePlugin({
|
|
@@ -35,4 +36,7 @@ export function webpack(config) {
|
|
|
35
36
|
})
|
|
36
37
|
})
|
|
37
38
|
});
|
|
38
|
-
}
|
|
39
|
+
}
|
|
40
|
+
export var config = function (entry = []) {
|
|
41
|
+
return [...entry, findDistEsm(__dirname, 'client/preview/config')];
|
|
42
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app, } from './preview';
|
|
1
|
+
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app, activeStoryComponent, } from './preview';
|
|
2
2
|
export * from './preview/types-6-0';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="webpack-env" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import { App } from 'vue';
|
|
4
|
-
import { DecoratorFunction } from '@storybook/csf';
|
|
5
4
|
import { ClientStoryApi, Loadable } from '@storybook/addons';
|
|
6
5
|
import './globals';
|
|
7
6
|
import { IStorybookSection } from './types';
|
|
@@ -18,15 +17,15 @@ interface ClientApi extends ClientStoryApi<VueFramework['storyResult']> {
|
|
|
18
17
|
}
|
|
19
18
|
export declare const storiesOf: ClientApi['storiesOf'];
|
|
20
19
|
export declare const configure: ClientApi['configure'];
|
|
21
|
-
export declare const addDecorator: (decorator: DecoratorFunction<VueFramework, import("@storybook/
|
|
22
|
-
export declare const addParameters: ({ globals, globalTypes, ...parameters }: import("@storybook/csf").Parameters & {
|
|
20
|
+
export declare const addDecorator: (() => never) | ((decorator: import("@storybook/csf").DecoratorFunction<VueFramework, import("@storybook/addons").Args>) => void);
|
|
21
|
+
export declare const addParameters: (() => never) | (({ globals, globalTypes, ...parameters }: import("@storybook/csf/dist/story").Parameters & {
|
|
23
22
|
globals?: import("@storybook/csf").Globals;
|
|
24
23
|
globalTypes?: import("@storybook/csf").GlobalTypes;
|
|
25
|
-
}) => void;
|
|
26
|
-
export declare const clearDecorators: () => void;
|
|
27
|
-
export declare const setAddon: (addon: any) => void;
|
|
28
|
-
export declare const forceReRender: () => void;
|
|
29
|
-
export declare const getStorybook: () => import("@storybook/client-api/dist/ts3.9/ClientApi").GetStorybookKind<VueFramework>[];
|
|
30
|
-
export declare const raw: () => import("@storybook/store").BoundStory<VueFramework>[];
|
|
24
|
+
}) => void);
|
|
25
|
+
export declare const clearDecorators: (() => never) | (() => void);
|
|
26
|
+
export declare const setAddon: (() => never) | ((addon: any) => void);
|
|
27
|
+
export declare const forceReRender: (() => never) | (() => void);
|
|
28
|
+
export declare const getStorybook: (() => never) | (() => import("@storybook/client-api/dist/ts3.9/ClientApi").GetStorybookKind<VueFramework>[]);
|
|
29
|
+
export declare const raw: (() => never) | (() => import("@storybook/store").BoundStory<VueFramework>[]);
|
|
31
30
|
export declare const app: ClientApi['app'];
|
|
32
|
-
export {};
|
|
31
|
+
export { activeStoryComponent } from './render';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RenderContext } from '@storybook/store';
|
|
2
2
|
import { VueFramework } from './types-6-0';
|
|
3
|
+
export declare const activeStoryComponent: import("vue").Ref<import("vue").ComponentOptions<any, any, any, Record<string, import("@vue/reactivity").ComputedGetter<any> | import("vue").WritableComputedOptions<any>>, import("vue").MethodOptions, any, any, any>> | import("vue").Ref<import("vue").FunctionalComponent<any, any>>;
|
|
3
4
|
export declare const storybookApp: import("vue").App<Element>;
|
|
4
5
|
export declare function renderToDOM({ title, name, storyFn, showMain, showError, showException }: RenderContext<VueFramework>, domElement: HTMLElement): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app, } from './preview';
|
|
1
|
+
export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, forceReRender, raw, app, activeStoryComponent, } from './preview';
|
|
2
2
|
export * from './preview/types-6-0';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="webpack-env" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
import type { App } from 'vue';
|
|
4
|
-
import { DecoratorFunction } from '@storybook/csf';
|
|
5
4
|
import { ClientStoryApi, Loadable } from '@storybook/addons';
|
|
6
5
|
import './globals';
|
|
7
6
|
import { IStorybookSection } from './types';
|
|
@@ -18,15 +17,15 @@ interface ClientApi extends ClientStoryApi<VueFramework['storyResult']> {
|
|
|
18
17
|
}
|
|
19
18
|
export declare const storiesOf: ClientApi['storiesOf'];
|
|
20
19
|
export declare const configure: ClientApi['configure'];
|
|
21
|
-
export declare const addDecorator: (decorator: DecoratorFunction<VueFramework, import("@storybook/
|
|
22
|
-
export declare const addParameters: ({ globals, globalTypes, ...parameters }: import("@storybook/csf").Parameters & {
|
|
20
|
+
export declare const addDecorator: (() => never) | ((decorator: import("@storybook/csf").DecoratorFunction<VueFramework, import("@storybook/addons").Args>) => void);
|
|
21
|
+
export declare const addParameters: (() => never) | (({ globals, globalTypes, ...parameters }: import("@storybook/csf/dist/story").Parameters & {
|
|
23
22
|
globals?: import("@storybook/csf").Globals;
|
|
24
23
|
globalTypes?: import("@storybook/csf").GlobalTypes;
|
|
25
|
-
}) => void;
|
|
26
|
-
export declare const clearDecorators: () => void;
|
|
27
|
-
export declare const setAddon: (addon: any) => void;
|
|
28
|
-
export declare const forceReRender: () => void;
|
|
29
|
-
export declare const getStorybook: () => import("@storybook/client-api/dist/ts3.9/ClientApi").GetStorybookKind<VueFramework>[];
|
|
30
|
-
export declare const raw: () => import("@storybook/store").BoundStory<VueFramework>[];
|
|
24
|
+
}) => void);
|
|
25
|
+
export declare const clearDecorators: (() => never) | (() => void);
|
|
26
|
+
export declare const setAddon: (() => never) | ((addon: any) => void);
|
|
27
|
+
export declare const forceReRender: (() => never) | (() => void);
|
|
28
|
+
export declare const getStorybook: (() => never) | (() => import("@storybook/client-api/dist/ts3.9/ClientApi").GetStorybookKind<VueFramework>[]);
|
|
29
|
+
export declare const raw: (() => never) | (() => import("@storybook/store").BoundStory<VueFramework>[]);
|
|
31
30
|
export declare const app: ClientApi['app'];
|
|
32
|
-
export {};
|
|
31
|
+
export { activeStoryComponent } from './render';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RenderContext } from '@storybook/store';
|
|
2
2
|
import { VueFramework } from './types-6-0';
|
|
3
|
+
export declare const activeStoryComponent: import("vue").Ref<import("vue").ComponentOptions<any, any, any, Record<string, import("@vue/reactivity").ComputedGetter<any> | import("vue").WritableComputedOptions<any>>, import("vue").MethodOptions, any, any, any>> | import("vue").Ref<import("vue").FunctionalComponent<any, any>>;
|
|
3
4
|
export declare const storybookApp: import("vue").App<Element>;
|
|
4
5
|
export declare function renderToDOM({ title, name, storyFn, showMain, showError, showException }: RenderContext<VueFramework>, domElement: HTMLElement): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/vue3",
|
|
3
|
-
"version": "6.4.0-
|
|
3
|
+
"version": "6.4.0-rc.3",
|
|
4
4
|
"description": "Storybook for Vue 3: Develop Vue 3 Components in isolation with Hot Reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
"prepare": "node ../../scripts/prepare.js"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@storybook/addons": "6.4.0-
|
|
49
|
-
"@storybook/core": "6.4.0-
|
|
50
|
-
"@storybook/core-common": "6.4.0-
|
|
51
|
-
"@storybook/csf": "0.0.2--canary.
|
|
52
|
-
"@storybook/store": "6.4.0-
|
|
48
|
+
"@storybook/addons": "6.4.0-rc.3",
|
|
49
|
+
"@storybook/core": "6.4.0-rc.3",
|
|
50
|
+
"@storybook/core-common": "6.4.0-rc.3",
|
|
51
|
+
"@storybook/csf": "0.0.2--canary.87bc651.0",
|
|
52
|
+
"@storybook/store": "6.4.0-rc.3",
|
|
53
53
|
"@types/webpack-env": "^1.16.0",
|
|
54
54
|
"core-js": "^3.8.2",
|
|
55
55
|
"global": "^4.4.0",
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f23a6daa88a2f051e2a94d803431ab3b3d11e26b",
|
|
85
85
|
"sbmodern": "dist/modern/client/index.js"
|
|
86
86
|
}
|
package/preset.js
CHANGED
package/types-7-0.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dist/ts3.9/client/preview/types-7-0.d';
|