@storybook/addon-docs 7.0.0-alpha.4 → 7.0.0-alpha.41
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/README.md +12 -75
- package/angular/index.js +1 -1
- package/dist/cjs/DocsRenderer.js +54 -0
- package/dist/cjs/blocks.js +18 -0
- package/dist/cjs/index.js +13 -1
- package/dist/cjs/preset.js +35 -18
- package/dist/cjs/preview.js +6 -2
- package/dist/esm/DocsRenderer.js +35 -0
- package/dist/esm/blocks.js +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/preset.js +31 -11
- package/dist/esm/preview.js +6 -2
- package/dist/types/DocsRenderer.d.ts +8 -0
- package/dist/types/blocks.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/preset.d.ts +8 -2
- package/dist/types/preview.d.ts +1 -6
- package/jest-transform-mdx.js +4 -3
- package/package.json +25 -32
- package/web-components/README.md +1 -0
- package/LICENSE +0 -21
- package/blocks.d.ts +0 -2
- package/blocks.js +0 -14
- package/dist/cjs/blocks/Anchor.js +0 -23
- package/dist/cjs/blocks/ArgsTable.js +0 -329
- package/dist/cjs/blocks/Canvas.js +0 -109
- package/dist/cjs/blocks/Description.js +0 -126
- package/dist/cjs/blocks/DocsContainer.js +0 -127
- package/dist/cjs/blocks/DocsContext.js +0 -25
- package/dist/cjs/blocks/DocsPage.js +0 -30
- package/dist/cjs/blocks/DocsStory.js +0 -68
- package/dist/cjs/blocks/Heading.js +0 -31
- package/dist/cjs/blocks/Meta.js +0 -50
- package/dist/cjs/blocks/Preview.js +0 -23
- package/dist/cjs/blocks/Primary.js +0 -39
- package/dist/cjs/blocks/Props.js +0 -29
- package/dist/cjs/blocks/Source.js +0 -179
- package/dist/cjs/blocks/SourceContainer.js +0 -67
- package/dist/cjs/blocks/Stories.js +0 -51
- package/dist/cjs/blocks/Story.js +0 -143
- package/dist/cjs/blocks/Subheading.js +0 -31
- package/dist/cjs/blocks/Subtitle.js +0 -39
- package/dist/cjs/blocks/Title.js +0 -44
- package/dist/cjs/blocks/Wrapper.js +0 -20
- package/dist/cjs/blocks/enhanceSource.js +0 -92
- package/dist/cjs/blocks/index.js +0 -366
- package/dist/cjs/blocks/mdx.js +0 -234
- package/dist/cjs/blocks/types.js +0 -10
- package/dist/cjs/blocks/useStory.js +0 -37
- package/dist/cjs/blocks/utils.js +0 -40
- package/dist/cjs/manager.js +0 -20
- package/dist/esm/blocks/Anchor.js +0 -8
- package/dist/esm/blocks/ArgsTable.js +0 -292
- package/dist/esm/blocks/Canvas.js +0 -83
- package/dist/esm/blocks/Description.js +0 -107
- package/dist/esm/blocks/DocsContainer.js +0 -98
- package/dist/esm/blocks/DocsContext.js +0 -16
- package/dist/esm/blocks/DocsPage.js +0 -11
- package/dist/esm/blocks/DocsStory.js +0 -46
- package/dist/esm/blocks/Heading.js +0 -17
- package/dist/esm/blocks/Meta.js +0 -31
- package/dist/esm/blocks/Preview.js +0 -9
- package/dist/esm/blocks/Primary.js +0 -23
- package/dist/esm/blocks/Props.js +0 -14
- package/dist/esm/blocks/Source.js +0 -144
- package/dist/esm/blocks/SourceContainer.js +0 -44
- package/dist/esm/blocks/Stories.js +0 -30
- package/dist/esm/blocks/Story.js +0 -114
- package/dist/esm/blocks/Subheading.js +0 -17
- package/dist/esm/blocks/Subtitle.js +0 -23
- package/dist/esm/blocks/Title.js +0 -24
- package/dist/esm/blocks/Wrapper.js +0 -8
- package/dist/esm/blocks/enhanceSource.js +0 -87
- package/dist/esm/blocks/index.js +0 -24
- package/dist/esm/blocks/mdx.js +0 -203
- package/dist/esm/blocks/types.js +0 -2
- package/dist/esm/blocks/useStory.js +0 -27
- package/dist/esm/blocks/utils.js +0 -29
- package/dist/esm/manager.js +0 -16
- package/dist/types/blocks/Anchor.d.ts +0 -6
- package/dist/types/blocks/ArgsTable.d.ts +0 -33
- package/dist/types/blocks/Canvas.d.ts +0 -9
- package/dist/types/blocks/Description.d.ts +0 -20
- package/dist/types/blocks/DocsContainer.d.ts +0 -7
- package/dist/types/blocks/DocsContext.d.ts +0 -5
- package/dist/types/blocks/DocsPage.d.ts +0 -2
- package/dist/types/blocks/DocsStory.d.ts +0 -3
- package/dist/types/blocks/Heading.d.ts +0 -6
- package/dist/types/blocks/Meta.d.ts +0 -9
- package/dist/types/blocks/Preview.d.ts +0 -3
- package/dist/types/blocks/Primary.d.ts +0 -6
- package/dist/types/blocks/Props.d.ts +0 -3
- package/dist/types/blocks/Source.d.ts +0 -38
- package/dist/types/blocks/SourceContainer.d.ts +0 -14
- package/dist/types/blocks/Stories.d.ts +0 -7
- package/dist/types/blocks/Story.d.ts +0 -28
- package/dist/types/blocks/Subheading.d.ts +0 -3
- package/dist/types/blocks/Subtitle.d.ts +0 -6
- package/dist/types/blocks/Title.d.ts +0 -8
- package/dist/types/blocks/Wrapper.d.ts +0 -2
- package/dist/types/blocks/enhanceSource.d.ts +0 -3
- package/dist/types/blocks/index.d.ts +0 -24
- package/dist/types/blocks/mdx.d.ts +0 -20
- package/dist/types/blocks/types.d.ts +0 -13
- package/dist/types/blocks/useStory.d.ts +0 -5
- package/dist/types/blocks/utils.d.ts +0 -3
- package/dist/types/manager.d.ts +0 -1
- package/manager.js +0 -1
- package/register.js +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-docs",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.41",
|
|
4
4
|
"description": "Document component usage and properties in Markdown",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"addon",
|
|
@@ -45,52 +45,45 @@
|
|
|
45
45
|
"!__testfixtures__"
|
|
46
46
|
],
|
|
47
47
|
"scripts": {
|
|
48
|
-
"
|
|
48
|
+
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
|
49
|
+
"prep": "node ../../../scripts/prepare.js"
|
|
49
50
|
},
|
|
50
51
|
"dependencies": {
|
|
51
52
|
"@babel/plugin-transform-react-jsx": "^7.12.12",
|
|
52
|
-
"@babel/preset-env": "^7.12.11",
|
|
53
53
|
"@jest/transform": "^26.6.2",
|
|
54
|
-
"@mdx-js/react": "^1.
|
|
55
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
56
|
-
"@storybook/api": "7.0.0-alpha.
|
|
57
|
-
"@storybook/
|
|
58
|
-
"@storybook/
|
|
59
|
-
"@storybook/core-
|
|
60
|
-
"@storybook/
|
|
61
|
-
"@storybook/csf
|
|
62
|
-
"@storybook/
|
|
63
|
-
"@storybook/
|
|
64
|
-
"@storybook/
|
|
65
|
-
"@storybook/
|
|
66
|
-
"@storybook/
|
|
67
|
-
"@storybook/
|
|
68
|
-
"@storybook/
|
|
69
|
-
"@storybook/
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
54
|
+
"@mdx-js/react": "^2.1.5",
|
|
55
|
+
"@storybook/addons": "7.0.0-alpha.41",
|
|
56
|
+
"@storybook/api": "7.0.0-alpha.41",
|
|
57
|
+
"@storybook/blocks": "7.0.0-alpha.41",
|
|
58
|
+
"@storybook/components": "7.0.0-alpha.41",
|
|
59
|
+
"@storybook/core-common": "7.0.0-alpha.41",
|
|
60
|
+
"@storybook/core-events": "7.0.0-alpha.41",
|
|
61
|
+
"@storybook/csf": "0.0.2--canary.49.258942b.0",
|
|
62
|
+
"@storybook/csf-tools": "7.0.0-alpha.41",
|
|
63
|
+
"@storybook/docs-tools": "7.0.0-alpha.41",
|
|
64
|
+
"@storybook/mdx2-csf": "0.1.0-next.0",
|
|
65
|
+
"@storybook/node-logger": "7.0.0-alpha.41",
|
|
66
|
+
"@storybook/postinstall": "7.0.0-alpha.41",
|
|
67
|
+
"@storybook/preview-web": "7.0.0-alpha.41",
|
|
68
|
+
"@storybook/source-loader": "7.0.0-alpha.41",
|
|
69
|
+
"@storybook/store": "7.0.0-alpha.41",
|
|
70
|
+
"@storybook/theming": "7.0.0-alpha.41",
|
|
71
|
+
"dequal": "^2.0.2",
|
|
72
|
+
"fs-extra": "^9.0.1",
|
|
73
73
|
"global": "^4.4.0",
|
|
74
|
-
"lodash": "^4.17.21",
|
|
75
74
|
"remark-external-links": "^8.0.0",
|
|
76
75
|
"remark-slug": "^6.0.0",
|
|
77
|
-
"ts-dedent": "^2.0.0"
|
|
78
|
-
"util-deprecate": "^1.0.2"
|
|
76
|
+
"ts-dedent": "^2.0.0"
|
|
79
77
|
},
|
|
80
78
|
"devDependencies": {
|
|
81
79
|
"@babel/core": "^7.12.10",
|
|
82
|
-
"
|
|
83
|
-
"@types/util-deprecate": "^1.0.0"
|
|
80
|
+
"typescript": "~4.6.3"
|
|
84
81
|
},
|
|
85
82
|
"peerDependencies": {
|
|
86
|
-
"@storybook/mdx2-csf": "^0.0.3",
|
|
87
83
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
88
84
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
89
85
|
},
|
|
90
86
|
"peerDependenciesMeta": {
|
|
91
|
-
"@storybook/mdx2-csf": {
|
|
92
|
-
"optional": true
|
|
93
|
-
},
|
|
94
87
|
"react": {
|
|
95
88
|
"optional": true
|
|
96
89
|
},
|
|
@@ -101,7 +94,7 @@
|
|
|
101
94
|
"publishConfig": {
|
|
102
95
|
"access": "public"
|
|
103
96
|
},
|
|
104
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "7ec6f916eb875bd2e3cf3aa6b1afcd1fe25d1637",
|
|
105
98
|
"storybook": {
|
|
106
99
|
"displayName": "Docs",
|
|
107
100
|
"icon": "https://user-images.githubusercontent.com/263385/101991672-48355c80-3c7c-11eb-82d9-95fa12438f64.png",
|
package/web-components/README.md
CHANGED
|
@@ -39,6 +39,7 @@ Known analyzers that output `custom-elements.json` v1.0.0:
|
|
|
39
39
|
- Supports Vanilla, LitElement, FASTElement, Stencil, Catalyst, Atomico
|
|
40
40
|
|
|
41
41
|
Known analyzers that output older versions of `custom-elements.json`:
|
|
42
|
+
|
|
42
43
|
- [web-component-analyzer](https://github.com/runem/web-component-analyzer)
|
|
43
44
|
- Supports LitElement, Polymer, Vanilla, (Stencil)
|
|
44
45
|
- [stenciljs](https://stenciljs.com/)
|
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.
|
package/blocks.d.ts
DELETED
package/blocks.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import deprecate from 'util-deprecate';
|
|
2
|
-
import dedent from 'ts-dedent';
|
|
3
|
-
|
|
4
|
-
const warnBlocksImport = deprecate(
|
|
5
|
-
() => {},
|
|
6
|
-
dedent`
|
|
7
|
-
Importing from '@storybook/addon-docs/blocks' is deprecated, import directly from '@storybook/addon-docs' instead:
|
|
8
|
-
|
|
9
|
-
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-scoped-blocks-imports
|
|
10
|
-
`
|
|
11
|
-
);
|
|
12
|
-
warnBlocksImport();
|
|
13
|
-
|
|
14
|
-
export * from './dist/esm/blocks';
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.anchorBlockIdFromId = exports.Anchor = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const anchorBlockIdFromId = storyId => `anchor--${storyId}`;
|
|
13
|
-
|
|
14
|
-
exports.anchorBlockIdFromId = anchorBlockIdFromId;
|
|
15
|
-
|
|
16
|
-
const Anchor = ({
|
|
17
|
-
storyId,
|
|
18
|
-
children
|
|
19
|
-
}) => /*#__PURE__*/_react.default.createElement("div", {
|
|
20
|
-
id: anchorBlockIdFromId(storyId)
|
|
21
|
-
}, children);
|
|
22
|
-
|
|
23
|
-
exports.Anchor = Anchor;
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getComponent = exports.extractComponentArgTypes = exports.StoryTable = exports.ComponentsTable = exports.ArgsTable = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
|
-
var _mapValues = _interopRequireDefault(require("lodash/mapValues"));
|
|
11
|
-
|
|
12
|
-
var _components = require("@storybook/components");
|
|
13
|
-
|
|
14
|
-
var _addons = require("@storybook/addons");
|
|
15
|
-
|
|
16
|
-
var _store = require("@storybook/store");
|
|
17
|
-
|
|
18
|
-
var _coreEvents = _interopRequireDefault(require("@storybook/core-events"));
|
|
19
|
-
|
|
20
|
-
var _DocsContext = require("./DocsContext");
|
|
21
|
-
|
|
22
|
-
var _types = require("./types");
|
|
23
|
-
|
|
24
|
-
var _utils = require("./utils");
|
|
25
|
-
|
|
26
|
-
var _Story = require("./Story");
|
|
27
|
-
|
|
28
|
-
var _useStory = require("./useStory");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
-
|
|
34
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
36
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
37
|
-
|
|
38
|
-
const getContext = (storyId, context) => {
|
|
39
|
-
const story = context.storyById(storyId);
|
|
40
|
-
|
|
41
|
-
if (!story) {
|
|
42
|
-
throw new Error(`Unknown story: ${storyId}`);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return context.getStoryContext(story);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const useArgs = (storyId, context) => {
|
|
49
|
-
const channel = _addons.addons.getChannel();
|
|
50
|
-
|
|
51
|
-
const storyContext = getContext(storyId, context);
|
|
52
|
-
const [args, setArgs] = (0, _react.useState)(storyContext.args);
|
|
53
|
-
(0, _react.useEffect)(() => {
|
|
54
|
-
const cb = changed => {
|
|
55
|
-
if (changed.storyId === storyId) {
|
|
56
|
-
setArgs(changed.args);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
channel.on(_coreEvents.default.STORY_ARGS_UPDATED, cb);
|
|
61
|
-
return () => channel.off(_coreEvents.default.STORY_ARGS_UPDATED, cb);
|
|
62
|
-
}, [storyId]);
|
|
63
|
-
const updateArgs = (0, _react.useCallback)(updatedArgs => channel.emit(_coreEvents.default.UPDATE_STORY_ARGS, {
|
|
64
|
-
storyId,
|
|
65
|
-
updatedArgs
|
|
66
|
-
}), [storyId]);
|
|
67
|
-
const resetArgs = (0, _react.useCallback)(argNames => channel.emit(_coreEvents.default.RESET_STORY_ARGS, {
|
|
68
|
-
storyId,
|
|
69
|
-
argNames
|
|
70
|
-
}), [storyId]);
|
|
71
|
-
return [args, updateArgs, resetArgs];
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const useGlobals = (storyId, context) => {
|
|
75
|
-
const channel = _addons.addons.getChannel();
|
|
76
|
-
|
|
77
|
-
const storyContext = getContext(storyId, context);
|
|
78
|
-
const [globals, setGlobals] = (0, _react.useState)(storyContext.globals);
|
|
79
|
-
(0, _react.useEffect)(() => {
|
|
80
|
-
const cb = changed => {
|
|
81
|
-
setGlobals(changed.globals);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
channel.on(_coreEvents.default.GLOBALS_UPDATED, cb);
|
|
85
|
-
return () => channel.off(_coreEvents.default.GLOBALS_UPDATED, cb);
|
|
86
|
-
}, []);
|
|
87
|
-
return [globals];
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
const extractComponentArgTypes = (component, {
|
|
91
|
-
id,
|
|
92
|
-
storyById
|
|
93
|
-
}, include, exclude) => {
|
|
94
|
-
const {
|
|
95
|
-
parameters
|
|
96
|
-
} = storyById(id);
|
|
97
|
-
const {
|
|
98
|
-
extractArgTypes
|
|
99
|
-
} = parameters.docs || {};
|
|
100
|
-
|
|
101
|
-
if (!extractArgTypes) {
|
|
102
|
-
throw new Error(_components.ArgsTableError.ARGS_UNSUPPORTED);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
let argTypes = extractArgTypes(component);
|
|
106
|
-
argTypes = (0, _store.filterArgTypes)(argTypes, include, exclude);
|
|
107
|
-
return argTypes;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
exports.extractComponentArgTypes = extractComponentArgTypes;
|
|
111
|
-
|
|
112
|
-
const isShortcut = value => {
|
|
113
|
-
return value && [_types.CURRENT_SELECTION, _types.PRIMARY_STORY].includes(value);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const getComponent = (props = {}, {
|
|
117
|
-
id,
|
|
118
|
-
storyById
|
|
119
|
-
}) => {
|
|
120
|
-
const {
|
|
121
|
-
of
|
|
122
|
-
} = props;
|
|
123
|
-
const {
|
|
124
|
-
story
|
|
125
|
-
} = props;
|
|
126
|
-
const {
|
|
127
|
-
component
|
|
128
|
-
} = storyById(id);
|
|
129
|
-
|
|
130
|
-
if (isShortcut(of) || isShortcut(story)) {
|
|
131
|
-
return component || null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!of) {
|
|
135
|
-
throw new Error(_components.ArgsTableError.NO_COMPONENT);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return of;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
exports.getComponent = getComponent;
|
|
142
|
-
|
|
143
|
-
const addComponentTabs = (tabs, components, context, include, exclude, sort) => Object.assign({}, tabs, (0, _mapValues.default)(components, comp => ({
|
|
144
|
-
rows: extractComponentArgTypes(comp, context, include, exclude),
|
|
145
|
-
sort
|
|
146
|
-
})));
|
|
147
|
-
|
|
148
|
-
const StoryTable = props => {
|
|
149
|
-
const context = (0, _react.useContext)(_DocsContext.DocsContext);
|
|
150
|
-
const {
|
|
151
|
-
id: currentId,
|
|
152
|
-
componentStories
|
|
153
|
-
} = context;
|
|
154
|
-
const {
|
|
155
|
-
story: storyName,
|
|
156
|
-
component,
|
|
157
|
-
subcomponents,
|
|
158
|
-
showComponent,
|
|
159
|
-
include,
|
|
160
|
-
exclude,
|
|
161
|
-
sort
|
|
162
|
-
} = props;
|
|
163
|
-
|
|
164
|
-
try {
|
|
165
|
-
let storyId;
|
|
166
|
-
|
|
167
|
-
switch (storyName) {
|
|
168
|
-
case _types.CURRENT_SELECTION:
|
|
169
|
-
{
|
|
170
|
-
storyId = currentId;
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
case _types.PRIMARY_STORY:
|
|
175
|
-
{
|
|
176
|
-
const primaryStory = componentStories()[0];
|
|
177
|
-
storyId = primaryStory.id;
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
default:
|
|
182
|
-
{
|
|
183
|
-
storyId = (0, _Story.lookupStoryId)(storyName, context);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const story = (0, _useStory.useStory)(storyId, context); // eslint-disable-next-line prefer-const
|
|
188
|
-
|
|
189
|
-
let [args, updateArgs, resetArgs] = useArgs(storyId, context);
|
|
190
|
-
const [globals] = useGlobals(storyId, context);
|
|
191
|
-
if (!story) return /*#__PURE__*/_react.default.createElement(_components.ArgsTable, {
|
|
192
|
-
isLoading: true,
|
|
193
|
-
updateArgs: updateArgs,
|
|
194
|
-
resetArgs: resetArgs
|
|
195
|
-
});
|
|
196
|
-
const argTypes = (0, _store.filterArgTypes)(story.argTypes, include, exclude);
|
|
197
|
-
const mainLabel = (0, _utils.getComponentName)(component) || 'Story';
|
|
198
|
-
let tabs = {
|
|
199
|
-
[mainLabel]: {
|
|
200
|
-
rows: argTypes,
|
|
201
|
-
args,
|
|
202
|
-
globals,
|
|
203
|
-
updateArgs,
|
|
204
|
-
resetArgs
|
|
205
|
-
}
|
|
206
|
-
}; // Use the dynamically generated component tabs if there are no controls
|
|
207
|
-
|
|
208
|
-
const storyHasArgsWithControls = argTypes && Object.values(argTypes).find(v => !!(v !== null && v !== void 0 && v.control));
|
|
209
|
-
|
|
210
|
-
if (!storyHasArgsWithControls) {
|
|
211
|
-
updateArgs = null;
|
|
212
|
-
resetArgs = null;
|
|
213
|
-
tabs = {};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (component && (!storyHasArgsWithControls || showComponent)) {
|
|
217
|
-
tabs = addComponentTabs(tabs, {
|
|
218
|
-
[mainLabel]: component
|
|
219
|
-
}, context, include, exclude);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (subcomponents) {
|
|
223
|
-
if (Array.isArray(subcomponents)) {
|
|
224
|
-
throw new Error(`Unexpected subcomponents array. Expected an object whose keys are tab labels and whose values are components.`);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
tabs = addComponentTabs(tabs, subcomponents, context, include, exclude);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return /*#__PURE__*/_react.default.createElement(_components.TabbedArgsTable, {
|
|
231
|
-
tabs: tabs,
|
|
232
|
-
sort: sort
|
|
233
|
-
});
|
|
234
|
-
} catch (err) {
|
|
235
|
-
return /*#__PURE__*/_react.default.createElement(_components.ArgsTable, {
|
|
236
|
-
error: err.message
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
exports.StoryTable = StoryTable;
|
|
242
|
-
|
|
243
|
-
const ComponentsTable = props => {
|
|
244
|
-
const context = (0, _react.useContext)(_DocsContext.DocsContext);
|
|
245
|
-
const {
|
|
246
|
-
components,
|
|
247
|
-
include,
|
|
248
|
-
exclude,
|
|
249
|
-
sort
|
|
250
|
-
} = props;
|
|
251
|
-
const tabs = addComponentTabs({}, components, context, include, exclude);
|
|
252
|
-
return /*#__PURE__*/_react.default.createElement(_components.TabbedArgsTable, {
|
|
253
|
-
tabs: tabs,
|
|
254
|
-
sort: sort
|
|
255
|
-
});
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
exports.ComponentsTable = ComponentsTable;
|
|
259
|
-
|
|
260
|
-
const ArgsTable = props => {
|
|
261
|
-
const context = (0, _react.useContext)(_DocsContext.DocsContext);
|
|
262
|
-
const {
|
|
263
|
-
id,
|
|
264
|
-
storyById
|
|
265
|
-
} = context;
|
|
266
|
-
const {
|
|
267
|
-
parameters: {
|
|
268
|
-
controls
|
|
269
|
-
},
|
|
270
|
-
subcomponents
|
|
271
|
-
} = storyById(id);
|
|
272
|
-
const {
|
|
273
|
-
include,
|
|
274
|
-
exclude,
|
|
275
|
-
components,
|
|
276
|
-
sort: sortProp
|
|
277
|
-
} = props;
|
|
278
|
-
const {
|
|
279
|
-
story: storyName
|
|
280
|
-
} = props;
|
|
281
|
-
const sort = sortProp || (controls === null || controls === void 0 ? void 0 : controls.sort);
|
|
282
|
-
const main = getComponent(props, context);
|
|
283
|
-
|
|
284
|
-
if (storyName) {
|
|
285
|
-
return /*#__PURE__*/_react.default.createElement(StoryTable, _extends({}, props, {
|
|
286
|
-
component: main,
|
|
287
|
-
subcomponents,
|
|
288
|
-
sort
|
|
289
|
-
}));
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
if (!components && !subcomponents) {
|
|
293
|
-
let mainProps;
|
|
294
|
-
|
|
295
|
-
try {
|
|
296
|
-
mainProps = {
|
|
297
|
-
rows: extractComponentArgTypes(main, context, include, exclude)
|
|
298
|
-
};
|
|
299
|
-
} catch (err) {
|
|
300
|
-
mainProps = {
|
|
301
|
-
error: err.message
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return /*#__PURE__*/_react.default.createElement(_components.ArgsTable, _extends({}, mainProps, {
|
|
306
|
-
sort: sort
|
|
307
|
-
}));
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (components) {
|
|
311
|
-
return /*#__PURE__*/_react.default.createElement(ComponentsTable, _extends({}, props, {
|
|
312
|
-
components,
|
|
313
|
-
sort
|
|
314
|
-
}));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const mainLabel = (0, _utils.getComponentName)(main);
|
|
318
|
-
return /*#__PURE__*/_react.default.createElement(ComponentsTable, _extends({}, props, {
|
|
319
|
-
components: Object.assign({
|
|
320
|
-
[mainLabel]: main
|
|
321
|
-
}, subcomponents),
|
|
322
|
-
sort: sort
|
|
323
|
-
}));
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
exports.ArgsTable = ArgsTable;
|
|
327
|
-
ArgsTable.defaultProps = {
|
|
328
|
-
of: _types.CURRENT_SELECTION
|
|
329
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.Canvas = void 0;
|
|
7
|
-
Object.defineProperty(exports, "SourceState", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _Source.SourceState;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
|
-
var _react2 = require("@mdx-js/react");
|
|
17
|
-
|
|
18
|
-
var _csf = require("@storybook/csf");
|
|
19
|
-
|
|
20
|
-
var _components = require("@storybook/components");
|
|
21
|
-
|
|
22
|
-
var _DocsContext = require("./DocsContext");
|
|
23
|
-
|
|
24
|
-
var _SourceContainer = require("./SourceContainer");
|
|
25
|
-
|
|
26
|
-
var _Source = require("./Source");
|
|
27
|
-
|
|
28
|
-
var _useStory = require("./useStory");
|
|
29
|
-
|
|
30
|
-
var _types = require("./types");
|
|
31
|
-
|
|
32
|
-
const _excluded = ["withSource", "mdxSource", "children"];
|
|
33
|
-
|
|
34
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
-
|
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
|
|
38
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
39
|
-
|
|
40
|
-
const getPreviewProps = (_ref, docsContext, sourceContext) => {
|
|
41
|
-
let {
|
|
42
|
-
withSource,
|
|
43
|
-
mdxSource,
|
|
44
|
-
children
|
|
45
|
-
} = _ref,
|
|
46
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
47
|
-
|
|
48
|
-
const {
|
|
49
|
-
mdxComponentAnnotations,
|
|
50
|
-
mdxStoryNameToKey
|
|
51
|
-
} = docsContext;
|
|
52
|
-
let sourceState = withSource;
|
|
53
|
-
let isLoading = false;
|
|
54
|
-
|
|
55
|
-
if (sourceState === _Source.SourceState.NONE) {
|
|
56
|
-
return {
|
|
57
|
-
isLoading,
|
|
58
|
-
previewProps: props
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (mdxSource) {
|
|
63
|
-
return {
|
|
64
|
-
isLoading,
|
|
65
|
-
previewProps: Object.assign({}, props, {
|
|
66
|
-
withSource: (0, _Source.getSourceProps)({
|
|
67
|
-
code: decodeURI(mdxSource)
|
|
68
|
-
}, docsContext, sourceContext)
|
|
69
|
-
})
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const childArray = Array.isArray(children) ? children : [children];
|
|
74
|
-
const storyChildren = childArray.filter(c => c.props && (c.props.id || c.props.name));
|
|
75
|
-
const targetIds = storyChildren.map(s => s.props.id || (0, _csf.toId)(mdxComponentAnnotations.id || mdxComponentAnnotations.title, (0, _csf.storyNameFromExport)(mdxStoryNameToKey[s.props.name])));
|
|
76
|
-
const sourceProps = (0, _Source.getSourceProps)({
|
|
77
|
-
ids: targetIds
|
|
78
|
-
}, docsContext, sourceContext);
|
|
79
|
-
if (!sourceState) sourceState = sourceProps.state;
|
|
80
|
-
const storyIds = targetIds.map(targetId => targetId === _types.CURRENT_SELECTION ? docsContext.id : targetId);
|
|
81
|
-
const stories = (0, _useStory.useStories)(storyIds, docsContext);
|
|
82
|
-
isLoading = stories.some(s => !s);
|
|
83
|
-
return {
|
|
84
|
-
isLoading,
|
|
85
|
-
previewProps: Object.assign({}, props, {
|
|
86
|
-
// pass through columns etc.
|
|
87
|
-
withSource: sourceProps,
|
|
88
|
-
isExpanded: sourceState === _Source.SourceState.OPEN
|
|
89
|
-
})
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const Canvas = props => {
|
|
94
|
-
const docsContext = (0, _react.useContext)(_DocsContext.DocsContext);
|
|
95
|
-
const sourceContext = (0, _react.useContext)(_SourceContainer.SourceContext);
|
|
96
|
-
const {
|
|
97
|
-
isLoading,
|
|
98
|
-
previewProps
|
|
99
|
-
} = getPreviewProps(props, docsContext, sourceContext);
|
|
100
|
-
const {
|
|
101
|
-
children
|
|
102
|
-
} = props;
|
|
103
|
-
if (isLoading) return /*#__PURE__*/_react.default.createElement(_components.PreviewSkeleton, null);
|
|
104
|
-
return /*#__PURE__*/_react.default.createElement(_react2.MDXProvider, {
|
|
105
|
-
components: _components.resetComponents
|
|
106
|
-
}, /*#__PURE__*/_react.default.createElement(_components.Preview, previewProps, children));
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
exports.Canvas = Canvas;
|