@storybook/vue3 7.0.0-alpha.5 → 7.0.0-alpha.50

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 (67) hide show
  1. package/dist/chunk-YPCW34O2.mjs +4 -0
  2. package/dist/config.d.ts +21 -0
  3. package/dist/config.js +4 -0
  4. package/dist/config.mjs +1 -0
  5. package/dist/index.d.ts +59 -0
  6. package/dist/index.js +4 -0
  7. package/dist/index.mjs +1 -0
  8. package/dist/render-52740da1.d.ts +14 -0
  9. package/jest.config.js +11 -0
  10. package/package.json +49 -15
  11. package/preview.js +1 -1
  12. package/template/cli/Button.stories.js +64 -0
  13. package/template/cli/Button.vue +52 -0
  14. package/template/cli/Header.stories.js +41 -0
  15. package/template/cli/Header.vue +41 -0
  16. package/template/cli/Page.stories.js +36 -0
  17. package/template/cli/Page.vue +88 -0
  18. package/template/components/Button.vue +52 -0
  19. package/template/components/Form.vue +44 -0
  20. package/template/components/Html.vue +20 -0
  21. package/template/components/Pre.vue +34 -0
  22. package/template/components/button.css +30 -0
  23. package/template/components/index.js +9 -0
  24. package/template/stories/GlobalUsage.stories.js +29 -0
  25. package/template/stories/GlobalUsage.vue +3 -0
  26. package/template/stories/OverrideArgs.stories.js +43 -0
  27. package/template/stories/OverrideArgs.vue +40 -0
  28. package/template/stories/decorators.stories.js +66 -0
  29. package/template/stories/preview.js +13 -0
  30. package/template/stories/vue3-mdx.stories.mdx +46 -0
  31. package/LICENSE +0 -21
  32. package/dist/cjs/config.js +0 -36
  33. package/dist/cjs/docs/config.js +0 -21
  34. package/dist/cjs/docs/extractArgTypes.js +0 -53
  35. package/dist/cjs/index.js +0 -91
  36. package/dist/cjs/preview/config.js +0 -33
  37. package/dist/cjs/preview/decorateStory.js +0 -66
  38. package/dist/cjs/preview/globals.js +0 -11
  39. package/dist/cjs/preview/index.js +0 -67
  40. package/dist/cjs/preview/render.js +0 -84
  41. package/dist/cjs/preview/types-6-0.js +0 -5
  42. package/dist/cjs/preview/types-7-0.js +0 -5
  43. package/dist/cjs/preview/types.js +0 -5
  44. package/dist/esm/config.js +0 -6
  45. package/dist/esm/docs/config.js +0 -10
  46. package/dist/esm/docs/extractArgTypes.js +0 -42
  47. package/dist/esm/index.js +0 -4
  48. package/dist/esm/preview/config.js +0 -5
  49. package/dist/esm/preview/decorateStory.js +0 -58
  50. package/dist/esm/preview/globals.js +0 -6
  51. package/dist/esm/preview/index.js +0 -37
  52. package/dist/esm/preview/render.js +0 -66
  53. package/dist/esm/preview/types-6-0.js +0 -1
  54. package/dist/esm/preview/types-7-0.js +0 -1
  55. package/dist/esm/preview/types.js +0 -1
  56. package/dist/types/config.d.ts +0 -10
  57. package/dist/types/docs/config.d.ts +0 -9
  58. package/dist/types/docs/extractArgTypes.d.ts +0 -2
  59. package/dist/types/index.d.ts +0 -2
  60. package/dist/types/preview/config.d.ts +0 -5
  61. package/dist/types/preview/decorateStory.d.ts +0 -3
  62. package/dist/types/preview/globals.d.ts +0 -1
  63. package/dist/types/preview/index.d.ts +0 -30
  64. package/dist/types/preview/render.d.ts +0 -6
  65. package/dist/types/preview/types-6-0.d.ts +0 -35
  66. package/dist/types/preview/types-7-0.d.ts +0 -9
  67. package/dist/types/preview/types.d.ts +0 -15
@@ -0,0 +1,44 @@
1
+ <template>
2
+ <form id="interaction-test-form" @submit.prevent="onSubmit">
3
+ <label>
4
+ Enter Value
5
+ <input type="text" data-testid="value" :value="value" required @click="setValue" />
6
+ </label>
7
+ <button type="submit">Submit</button>
8
+ <p v-if="complete">Completed!!</p>
9
+ </form>
10
+ </template>
11
+
12
+ <script>
13
+ export default {
14
+ name: 'my-form',
15
+
16
+ props: {
17
+ onSuccess: {
18
+ type: Function,
19
+ },
20
+ },
21
+
22
+ data() {
23
+ return {
24
+ value: '',
25
+ complete: false,
26
+ };
27
+ },
28
+
29
+ methods: {
30
+ setValue(event) {
31
+ this.value = event.target.value;
32
+ },
33
+ onSubmit() {
34
+ this.onSuccess(this.value);
35
+ setTimeout(() => {
36
+ this.complete = true;
37
+ }, 500);
38
+ setTimeout(() => {
39
+ this.complete = false;
40
+ }, 1500);
41
+ },
42
+ },
43
+ };
44
+ </script>
@@ -0,0 +1,20 @@
1
+ <template>
2
+ <div v-html="content"></div>
3
+ </template>
4
+
5
+ <script>
6
+
7
+ export default {
8
+ name: 'my-html',
9
+
10
+ props: {
11
+ content: {
12
+ type: String,
13
+ required: true,
14
+ },
15
+ },
16
+
17
+
18
+ setup() { },
19
+ };
20
+ </script>
@@ -0,0 +1,34 @@
1
+ <template>
2
+ <pre data-testid="pre" :style="style">{{ finalText }}</pre>
3
+ </template>
4
+
5
+ <script>
6
+ import { reactive, computed } from 'vue';
7
+
8
+ export default {
9
+ name: 'my-pre',
10
+
11
+ props: {
12
+ // deepscan-disable-next-line
13
+ style: {
14
+ type: Object,
15
+ },
16
+ object: {
17
+ type: Object,
18
+ },
19
+ text: {
20
+ type: String,
21
+ default: '',
22
+ },
23
+ },
24
+
25
+ setup(props, { emit }) {
26
+ props = reactive(props);
27
+ return {
28
+ finalText: computed(() =>
29
+ props.object ? JSON.stringify(props.object, null, 2) : props.text
30
+ ),
31
+ };
32
+ },
33
+ };
34
+ </script>
@@ -0,0 +1,30 @@
1
+ .storybook-button {
2
+ font-family: 'Nunito Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
3
+ font-weight: 700;
4
+ border: 0;
5
+ border-radius: 3em;
6
+ cursor: pointer;
7
+ display: inline-block;
8
+ line-height: 1;
9
+ }
10
+ .storybook-button--primary {
11
+ color: white;
12
+ background-color: #1ea7fd;
13
+ }
14
+ .storybook-button--secondary {
15
+ color: #333;
16
+ background-color: transparent;
17
+ box-shadow: rgba(0, 0, 0, 0.15) 0px 0px 0px 1px inset;
18
+ }
19
+ .storybook-button--small {
20
+ font-size: 12px;
21
+ padding: 10px 16px;
22
+ }
23
+ .storybook-button--medium {
24
+ font-size: 14px;
25
+ padding: 11px 20px;
26
+ }
27
+ .storybook-button--large {
28
+ font-size: 16px;
29
+ padding: 12px 24px;
30
+ }
@@ -0,0 +1,9 @@
1
+ import globalThis from 'global';
2
+
3
+ import Button from './Button.vue';
4
+ import Pre from './Pre.vue';
5
+ import Form from './Form.vue';
6
+ import Html from './Html.vue';
7
+
8
+ globalThis.Components = { Button, Pre, Form, Html };
9
+ globalThis.storybookRenderer = 'vue3';
@@ -0,0 +1,29 @@
1
+ import GlobalUsage from './GlobalUsage.vue';
2
+
3
+ export default {
4
+ component: GlobalUsage,
5
+ argTypes: {},
6
+ render: (args) => ({
7
+ // Components used in your story `template` are defined in the `components` object
8
+ components: { GlobalUsage },
9
+ // The story's `args` need to be mapped into the template through the `setup()` method
10
+ setup() {
11
+ return { args };
12
+ },
13
+ // And then the `args` are bound to your component with `v-bind="args"`
14
+ template: '<global-usage v-bind="args" />',
15
+ }),
16
+ };
17
+
18
+ export const Primary = {
19
+ args: {
20
+ primary: true,
21
+ label: 'Globally Defined',
22
+ },
23
+ };
24
+
25
+ export const Secondary = {
26
+ args: {
27
+ label: 'Globally Defined',
28
+ },
29
+ };
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <global-button v-bind="$props" />
3
+ </template>
@@ -0,0 +1,43 @@
1
+ import OverrideArgs from './OverrideArgs.vue';
2
+
3
+ // Emulate something that isn't serializable
4
+ const icons = {
5
+ Primary: {
6
+ template: '<span>Primary Icon</span>',
7
+ },
8
+ Secondary: {
9
+ template: '<span>Secondary Icon</span>',
10
+ },
11
+ };
12
+
13
+ export default {
14
+ component: OverrideArgs,
15
+ argTypes: {
16
+ // To show that other props are passed through
17
+ backgroundColor: { control: 'color' },
18
+ icon: {
19
+ control: {
20
+ type: 'select',
21
+ options: Object.keys(icons),
22
+ },
23
+ defaultValue: 'Primary',
24
+ },
25
+ },
26
+ render: (args) => {
27
+ // Individual properties can be overridden by spreading the args
28
+ // and the replacing the key-values that need to be updated
29
+ args = { ...args, icon: icons[args.icon] }; // eslint-disable-line no-param-reassign
30
+ return {
31
+ // Components used in your story `template` are defined in the `components` object
32
+ components: { OverrideArgs },
33
+ // Updated `args` need to be mapped into the template through the `setup()` method
34
+ setup() {
35
+ return { args };
36
+ },
37
+ // And then the `args` are bound to your component with `v-bind="args"`
38
+ template: '<override-args v-bind="args" />',
39
+ };
40
+ },
41
+ };
42
+
43
+ export const TestOne = {};
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <button type="button" :class="classes" :style="style">
3
+ <!-- You can use <component /> with `:is` when passing a component as a prop -->
4
+ <component :is="icon" />
5
+ </button>
6
+ </template>
7
+
8
+ <script lang="typescript">
9
+ import { h, computed, reactive } from 'vue';
10
+
11
+ export default {
12
+ name: 'override-args',
13
+
14
+ props: {
15
+ icon: {
16
+ type: Object,
17
+ required: true,
18
+ },
19
+
20
+ backgroundColor: {
21
+ type: String
22
+ },
23
+ },
24
+
25
+ // @ts-expect-error (Converted from ts-ignore)
26
+ setup(props, { emit }) {
27
+ const classes = {
28
+ 'storybook-button': true,
29
+ 'storybook-button--primary': true,
30
+ 'storybook-button--large': true,
31
+ };
32
+ const style = computed(() => ({
33
+ backgroundColor: props.backgroundColor,
34
+ }));
35
+
36
+ // Notice that `icon` prop component is still passed through even though it isn't mapped
37
+ return { classes, style, }
38
+ },
39
+ };
40
+ </script>
@@ -0,0 +1,66 @@
1
+ import globalThis from 'global';
2
+ import { h } from 'vue';
3
+
4
+ const { Button, Pre } = globalThis.Components;
5
+
6
+ export default {
7
+ component: Button,
8
+ };
9
+
10
+ export const ComponentTemplate = {
11
+ args: { label: 'With component' },
12
+ decorators: [
13
+ () => ({
14
+ components: {
15
+ Pre,
16
+ },
17
+ template: `
18
+ <Pre text="decorator" />
19
+ <story/>
20
+ `,
21
+ }),
22
+ ],
23
+ };
24
+
25
+ export const SimpleTemplate = {
26
+ args: { label: 'With border' },
27
+ decorators: [
28
+ () => ({
29
+ template: `
30
+ <div style="border: 5px solid red;">
31
+ <story/>
32
+ </div>
33
+ `,
34
+ }),
35
+ ],
36
+ };
37
+
38
+ export const VueWrapper = {
39
+ args: { label: 'With Vue wrapper' },
40
+ decorators: [
41
+ (storyFn) => {
42
+ // Call the `storyFn` to receive a component that Vue can render
43
+ const story = storyFn();
44
+ // Vue 3 "Functional" component as decorator
45
+ return () => {
46
+ return h('div', { style: 'border: 2px solid blue' }, h(story));
47
+ };
48
+ },
49
+ ],
50
+ };
51
+
52
+ export const DynamicWrapper = {
53
+ args: { label: 'With dynamic wrapper', primary: true },
54
+ argTypes: {
55
+ // Number type is detected, but we still want to constrain the range from 1-6
56
+ level: { control: { type: 'range', min: 1, max: 6 } },
57
+ },
58
+ decorators: [
59
+ (storyFn, { args }) => ({
60
+ template: `<div :style="{ borderWidth: level, borderColor: 'red', borderStyle: 'solid' }"><story /></div>`,
61
+ data() {
62
+ return { level: `${args.level}px` };
63
+ },
64
+ }),
65
+ ],
66
+ };
@@ -0,0 +1,13 @@
1
+ import globalThis from 'global';
2
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
+ import { setup } from '@storybook/vue3';
4
+
5
+ // TODO: I'd like to be able to export rather than imperatively calling an imported function
6
+ // export const setup = (app) => {
7
+ // app.component('GlobalButton', Button);
8
+ // };
9
+
10
+ setup((app) => {
11
+ // This adds a component that can be used globally in stories
12
+ app.component('GlobalButton', globalThis.Components.Button);
13
+ });
@@ -0,0 +1,46 @@
1
+ import globalThis from 'global';
2
+ import { Meta, Story, Canvas } from '@storybook/addon-docs';
3
+
4
+ <Meta title="stories/renderers/vue3/vue3-mdx" />
5
+
6
+ # Vue3-specific MDX Stories
7
+
8
+ export const Button = globalThis.Components.Button;
9
+
10
+ export const Template = (args, { argTypes }) => ({
11
+ components: { MyButton: Button },
12
+ template: '<my-button v-bind="args" />',
13
+ setup() {
14
+ return { args };
15
+ },
16
+ });
17
+
18
+ ## Primary
19
+
20
+ <Canvas>
21
+ <Story name="Primary">
22
+ {{
23
+ components: { MyButton: Button },
24
+ template: '<my-button :primary="true" label="Primary button" />',
25
+ }}
26
+ </Story>
27
+ </Canvas>
28
+
29
+ ## Secondary
30
+
31
+ <Canvas>
32
+ <Story name="Secondary">
33
+ {{
34
+ components: { MyButton: Button },
35
+ template: '<my-button :primary="false" label="Secondary button" />',
36
+ }}
37
+ </Story>
38
+ </Canvas>
39
+
40
+ ## From template
41
+
42
+ <Canvas>
43
+ <Story name="From Template" args={{ label: 'From template' }}>
44
+ {Template.bind({})}
45
+ </Story>
46
+ </Canvas>
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2017 Kadira Inc. <hello@kadira.io>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,36 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- parameters: true,
8
- argTypesEnhancers: true
9
- };
10
- Object.defineProperty(exports, "argTypesEnhancers", {
11
- enumerable: true,
12
- get: function () {
13
- return _config.argTypesEnhancers;
14
- }
15
- });
16
- exports.parameters = void 0;
17
-
18
- var _config = require("./docs/config");
19
-
20
- var _config2 = require("./preview/config");
21
-
22
- Object.keys(_config2).forEach(function (key) {
23
- if (key === "default" || key === "__esModule") return;
24
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
25
- if (key in exports && exports[key] === _config2[key]) return;
26
- Object.defineProperty(exports, key, {
27
- enumerable: true,
28
- get: function () {
29
- return _config2[key];
30
- }
31
- });
32
- });
33
- const parameters = Object.assign({
34
- framework: 'vue3'
35
- }, _config.parameters);
36
- exports.parameters = parameters;
@@ -1,21 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.parameters = exports.argTypesEnhancers = void 0;
7
-
8
- var _docsTools = require("@storybook/docs-tools");
9
-
10
- var _extractArgTypes = require("./extractArgTypes");
11
-
12
- const parameters = {
13
- docs: {
14
- inlineStories: true,
15
- extractArgTypes: _extractArgTypes.extractArgTypes,
16
- extractComponentDescription: _docsTools.extractComponentDescription
17
- }
18
- };
19
- exports.parameters = parameters;
20
- const argTypesEnhancers = [_docsTools.enhanceArgTypes];
21
- exports.argTypesEnhancers = argTypesEnhancers;
@@ -1,53 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.extractArgTypes = void 0;
7
-
8
- var _docsTools = require("@storybook/docs-tools");
9
-
10
- const SECTIONS = ['props', 'events', 'slots'];
11
-
12
- const extractArgTypes = component => {
13
- if (!(0, _docsTools.hasDocgen)(component)) {
14
- return null;
15
- }
16
-
17
- const results = {};
18
- SECTIONS.forEach(section => {
19
- const props = (0, _docsTools.extractComponentProps)(component, section);
20
- props.forEach(({
21
- propDef,
22
- docgenInfo,
23
- jsDocTags
24
- }) => {
25
- const {
26
- name,
27
- type,
28
- description,
29
- defaultValue: defaultSummary,
30
- required
31
- } = propDef;
32
- const sbType = section === 'props' ? (0, _docsTools.convert)(docgenInfo) : {
33
- name: 'void'
34
- };
35
- results[name] = {
36
- name,
37
- description,
38
- type: Object.assign({
39
- required
40
- }, sbType),
41
- table: {
42
- type,
43
- jsDocTags,
44
- defaultValue: defaultSummary,
45
- category: section
46
- }
47
- };
48
- });
49
- });
50
- return results;
51
- };
52
-
53
- exports.extractArgTypes = extractArgTypes;
package/dist/cjs/index.js DELETED
@@ -1,91 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- storiesOf: true,
8
- setAddon: true,
9
- addDecorator: true,
10
- addParameters: true,
11
- configure: true,
12
- getStorybook: true,
13
- forceReRender: true,
14
- raw: true,
15
- setup: true
16
- };
17
- Object.defineProperty(exports, "addDecorator", {
18
- enumerable: true,
19
- get: function () {
20
- return _preview.addDecorator;
21
- }
22
- });
23
- Object.defineProperty(exports, "addParameters", {
24
- enumerable: true,
25
- get: function () {
26
- return _preview.addParameters;
27
- }
28
- });
29
- Object.defineProperty(exports, "configure", {
30
- enumerable: true,
31
- get: function () {
32
- return _preview.configure;
33
- }
34
- });
35
- Object.defineProperty(exports, "forceReRender", {
36
- enumerable: true,
37
- get: function () {
38
- return _preview.forceReRender;
39
- }
40
- });
41
- Object.defineProperty(exports, "getStorybook", {
42
- enumerable: true,
43
- get: function () {
44
- return _preview.getStorybook;
45
- }
46
- });
47
- Object.defineProperty(exports, "raw", {
48
- enumerable: true,
49
- get: function () {
50
- return _preview.raw;
51
- }
52
- });
53
- Object.defineProperty(exports, "setAddon", {
54
- enumerable: true,
55
- get: function () {
56
- return _preview.setAddon;
57
- }
58
- });
59
- Object.defineProperty(exports, "setup", {
60
- enumerable: true,
61
- get: function () {
62
- return _preview.setup;
63
- }
64
- });
65
- Object.defineProperty(exports, "storiesOf", {
66
- enumerable: true,
67
- get: function () {
68
- return _preview.storiesOf;
69
- }
70
- });
71
-
72
- var _preview = require("./preview");
73
-
74
- var _types = require("./preview/types-6-0");
75
-
76
- Object.keys(_types).forEach(function (key) {
77
- if (key === "default" || key === "__esModule") return;
78
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
79
- if (key in exports && exports[key] === _types[key]) return;
80
- Object.defineProperty(exports, key, {
81
- enumerable: true,
82
- get: function () {
83
- return _types[key];
84
- }
85
- });
86
- });
87
-
88
- var _module, _module$hot;
89
-
90
- // optimization: stop HMR propagation in webpack
91
- (_module = module) === null || _module === void 0 ? void 0 : (_module$hot = _module.hot) === null || _module$hot === void 0 ? void 0 : _module$hot.decline();
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "applyDecorators", {
7
- enumerable: true,
8
- get: function () {
9
- return _decorateStory.decorateStory;
10
- }
11
- });
12
- exports.parameters = void 0;
13
- Object.defineProperty(exports, "render", {
14
- enumerable: true,
15
- get: function () {
16
- return _render.render;
17
- }
18
- });
19
- Object.defineProperty(exports, "renderToDOM", {
20
- enumerable: true,
21
- get: function () {
22
- return _render.renderToDOM;
23
- }
24
- });
25
-
26
- var _render = require("./render");
27
-
28
- var _decorateStory = require("./decorateStory");
29
-
30
- const parameters = {
31
- framework: 'vue3'
32
- };
33
- exports.parameters = parameters;