@storybook/addon-docs 6.5.7 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blocks.d.ts +1 -1
- package/dist/cjs/blocks/ArgsTable.js +1 -1
- package/dist/cjs/blocks/Primary.js +1 -1
- package/dist/cjs/blocks/Stories.js +1 -1
- package/dist/cjs/blocks/mdx.js +1 -1
- package/dist/cjs/blocks/useStory.js +18 -4
- package/dist/cjs/preset.js +137 -33
- package/dist/cjs/preview.js +22 -6
- package/dist/esm/blocks/Anchor.js +7 -10
- package/dist/esm/blocks/ArgsTable.js +133 -182
- package/dist/esm/blocks/Canvas.js +34 -46
- package/dist/esm/blocks/Description.js +39 -45
- package/dist/esm/blocks/DocsContainer.js +36 -44
- package/dist/esm/blocks/DocsContext.js +1 -1
- package/dist/esm/blocks/DocsPage.js +3 -5
- package/dist/esm/blocks/DocsStory.js +18 -27
- package/dist/esm/blocks/Heading.js +5 -7
- package/dist/esm/blocks/Meta.js +9 -13
- package/dist/esm/blocks/Preview.js +5 -10
- package/dist/esm/blocks/Primary.js +10 -16
- package/dist/esm/blocks/Props.js +5 -10
- package/dist/esm/blocks/Source.js +64 -70
- package/dist/esm/blocks/SourceContainer.js +17 -50
- package/dist/esm/blocks/Stories.js +15 -27
- package/dist/esm/blocks/Story.js +58 -99
- package/dist/esm/blocks/Subheading.js +5 -7
- package/dist/esm/blocks/Subtitle.js +12 -12
- package/dist/esm/blocks/Title.js +10 -11
- package/dist/esm/blocks/Wrapper.js +7 -8
- package/dist/esm/blocks/enhanceSource.js +32 -56
- package/dist/esm/blocks/mdx.js +85 -89
- package/dist/esm/blocks/types.js +2 -2
- package/dist/esm/blocks/useStory.js +16 -73
- package/dist/esm/blocks/utils.js +4 -18
- package/dist/esm/manager.js +9 -14
- package/dist/esm/preset.js +114 -179
- package/dist/esm/preview.js +3 -61
- package/dist/esm/shared.js +5 -5
- package/dist/{ts3.9 → types}/blocks/Anchor.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/ArgsTable.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Canvas.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Description.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsContainer.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsContext.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsPage.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/DocsStory.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Heading.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Meta.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Preview.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Primary.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Props.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Source.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/SourceContainer.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Stories.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Story.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Subheading.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Subtitle.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Title.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/Wrapper.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/enhanceSource.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/index.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/mdx.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/types.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/useStory.d.ts +0 -0
- package/dist/{ts3.9 → types}/blocks/utils.d.ts +0 -0
- package/dist/{ts3.9 → types}/index.d.ts +0 -0
- package/dist/{ts3.9 → types}/manager.d.ts +0 -0
- package/dist/{ts3.9 → types}/preset.d.ts +2 -1
- package/dist/{ts3.9 → types}/preview.d.ts +0 -0
- package/dist/{ts3.9 → types}/shared.d.ts +0 -0
- package/package.json +16 -24
- package/dist/modern/blocks/Anchor.js +0 -8
- package/dist/modern/blocks/ArgsTable.js +0 -292
- package/dist/modern/blocks/Canvas.js +0 -83
- package/dist/modern/blocks/Description.js +0 -107
- package/dist/modern/blocks/DocsContainer.js +0 -98
- package/dist/modern/blocks/DocsContext.js +0 -16
- package/dist/modern/blocks/DocsPage.js +0 -11
- package/dist/modern/blocks/DocsStory.js +0 -48
- package/dist/modern/blocks/Heading.js +0 -17
- package/dist/modern/blocks/Meta.js +0 -31
- package/dist/modern/blocks/Preview.js +0 -9
- package/dist/modern/blocks/Primary.js +0 -23
- package/dist/modern/blocks/Props.js +0 -14
- package/dist/modern/blocks/Source.js +0 -154
- package/dist/modern/blocks/SourceContainer.js +0 -44
- package/dist/modern/blocks/Stories.js +0 -34
- package/dist/modern/blocks/Story.js +0 -168
- package/dist/modern/blocks/Subheading.js +0 -17
- package/dist/modern/blocks/Subtitle.js +0 -23
- package/dist/modern/blocks/Title.js +0 -24
- package/dist/modern/blocks/Wrapper.js +0 -8
- package/dist/modern/blocks/enhanceSource.js +0 -89
- package/dist/modern/blocks/index.js +0 -24
- package/dist/modern/blocks/mdx.js +0 -204
- package/dist/modern/blocks/types.js +0 -2
- package/dist/modern/blocks/useStory.js +0 -28
- package/dist/modern/blocks/utils.js +0 -29
- package/dist/modern/index.js +0 -1
- package/dist/modern/manager.js +0 -16
- package/dist/modern/preset.js +0 -130
- package/dist/modern/preview.js +0 -6
- package/dist/modern/shared.js +0 -11
- package/dist/ts3.4/blocks/Anchor.d.ts +0 -6
- package/dist/ts3.4/blocks/ArgsTable.d.ts +0 -33
- package/dist/ts3.4/blocks/Canvas.d.ts +0 -9
- package/dist/ts3.4/blocks/Description.d.ts +0 -20
- package/dist/ts3.4/blocks/DocsContainer.d.ts +0 -7
- package/dist/ts3.4/blocks/DocsContext.d.ts +0 -5
- package/dist/ts3.4/blocks/DocsPage.d.ts +0 -2
- package/dist/ts3.4/blocks/DocsStory.d.ts +0 -3
- package/dist/ts3.4/blocks/Heading.d.ts +0 -6
- package/dist/ts3.4/blocks/Meta.d.ts +0 -9
- package/dist/ts3.4/blocks/Preview.d.ts +0 -3
- package/dist/ts3.4/blocks/Primary.d.ts +0 -6
- package/dist/ts3.4/blocks/Props.d.ts +0 -3
- package/dist/ts3.4/blocks/Source.d.ts +0 -38
- package/dist/ts3.4/blocks/SourceContainer.d.ts +0 -14
- package/dist/ts3.4/blocks/Stories.d.ts +0 -7
- package/dist/ts3.4/blocks/Story.d.ts +0 -28
- package/dist/ts3.4/blocks/Subheading.d.ts +0 -3
- package/dist/ts3.4/blocks/Subtitle.d.ts +0 -6
- package/dist/ts3.4/blocks/Title.d.ts +0 -8
- package/dist/ts3.4/blocks/Wrapper.d.ts +0 -2
- package/dist/ts3.4/blocks/enhanceSource.d.ts +0 -3
- package/dist/ts3.4/blocks/index.d.ts +0 -24
- package/dist/ts3.4/blocks/mdx.d.ts +0 -20
- package/dist/ts3.4/blocks/types.d.ts +0 -13
- package/dist/ts3.4/blocks/useStory.d.ts +0 -5
- package/dist/ts3.4/blocks/utils.d.ts +0 -3
- package/dist/ts3.4/index.d.ts +0 -1
- package/dist/ts3.4/manager.d.ts +0 -1
- package/dist/ts3.4/preset.d.ts +0 -11
- package/dist/ts3.4/preview.d.ts +0 -6
- package/dist/ts3.4/shared.d.ts +0 -24
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import "core-js/modules/es.symbol.js";
|
|
2
|
-
import "core-js/modules/es.symbol.description.js";
|
|
3
|
-
import "core-js/modules/es.string.trim.js";
|
|
4
|
-
import "core-js/modules/es.array.concat.js";
|
|
5
|
-
import "core-js/modules/es.object.assign.js";
|
|
6
1
|
import React, { useContext } from 'react';
|
|
7
2
|
import { Description } from '@storybook/components';
|
|
8
3
|
import { str } from '@storybook/docs-tools';
|
|
9
4
|
import { DocsContext } from './DocsContext';
|
|
10
5
|
import { CURRENT_SELECTION } from './types';
|
|
11
|
-
export
|
|
6
|
+
export let DescriptionType;
|
|
12
7
|
|
|
13
8
|
(function (DescriptionType) {
|
|
14
9
|
DescriptionType["INFO"] = "info";
|
|
@@ -18,29 +13,25 @@ export var DescriptionType;
|
|
|
18
13
|
DescriptionType["AUTO"] = "auto";
|
|
19
14
|
})(DescriptionType || (DescriptionType = {}));
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
return notes && (typeof notes === 'string' ? notes : str(notes.markdown) || str(notes.text));
|
|
23
|
-
};
|
|
16
|
+
const getNotes = notes => notes && (typeof notes === 'string' ? notes : str(notes.markdown) || str(notes.text));
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
return info && (typeof info === 'string' ? info : str(info.text));
|
|
27
|
-
};
|
|
18
|
+
const getInfo = info => info && (typeof info === 'string' ? info : str(info.text));
|
|
28
19
|
|
|
29
|
-
|
|
30
|
-
return null;
|
|
31
|
-
};
|
|
20
|
+
const noDescription = component => null;
|
|
32
21
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
22
|
+
export const getDescriptionProps = ({
|
|
23
|
+
of,
|
|
24
|
+
type,
|
|
25
|
+
markdown,
|
|
26
|
+
children
|
|
27
|
+
}, {
|
|
28
|
+
id,
|
|
29
|
+
storyById
|
|
30
|
+
}) => {
|
|
31
|
+
const {
|
|
32
|
+
component,
|
|
33
|
+
parameters
|
|
34
|
+
} = storyById(id);
|
|
44
35
|
|
|
45
36
|
if (children || markdown) {
|
|
46
37
|
return {
|
|
@@ -48,18 +39,18 @@ export var getDescriptionProps = function getDescriptionProps(_ref, _ref2) {
|
|
|
48
39
|
};
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
42
|
+
const {
|
|
43
|
+
notes,
|
|
44
|
+
info,
|
|
45
|
+
docs
|
|
46
|
+
} = parameters;
|
|
47
|
+
const {
|
|
48
|
+
extractComponentDescription = noDescription,
|
|
49
|
+
description
|
|
50
|
+
} = docs || {};
|
|
51
|
+
const target = of === CURRENT_SELECTION ? component : of; // override component description
|
|
59
52
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var componentDescriptionParameter = description === null || description === void 0 ? void 0 : description.component;
|
|
53
|
+
const componentDescriptionParameter = description?.component;
|
|
63
54
|
|
|
64
55
|
if (componentDescriptionParameter) {
|
|
65
56
|
return {
|
|
@@ -81,7 +72,11 @@ export var getDescriptionProps = function getDescriptionProps(_ref, _ref2) {
|
|
|
81
72
|
|
|
82
73
|
case DescriptionType.LEGACY_5_2:
|
|
83
74
|
return {
|
|
84
|
-
markdown:
|
|
75
|
+
markdown: `
|
|
76
|
+
${getNotes(notes) || getInfo(info) || ''}
|
|
77
|
+
|
|
78
|
+
${extractComponentDescription(target) || ''}
|
|
79
|
+
`.trim()
|
|
85
80
|
};
|
|
86
81
|
|
|
87
82
|
case DescriptionType.DOCGEN:
|
|
@@ -89,18 +84,17 @@ export var getDescriptionProps = function getDescriptionProps(_ref, _ref2) {
|
|
|
89
84
|
default:
|
|
90
85
|
return {
|
|
91
86
|
markdown: extractComponentDescription(target, Object.assign({
|
|
92
|
-
component
|
|
87
|
+
component
|
|
93
88
|
}, parameters))
|
|
94
89
|
};
|
|
95
90
|
}
|
|
96
91
|
};
|
|
97
92
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
const DescriptionContainer = props => {
|
|
94
|
+
const context = useContext(DocsContext);
|
|
95
|
+
const {
|
|
96
|
+
markdown
|
|
97
|
+
} = getDescriptionProps(props, context);
|
|
104
98
|
return markdown ? /*#__PURE__*/React.createElement(Description, {
|
|
105
99
|
markdown: markdown
|
|
106
100
|
}) : null;
|
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.array.slice.js";
|
|
2
|
-
import "core-js/modules/es.object.freeze.js";
|
|
3
|
-
|
|
4
|
-
var _templateObject;
|
|
5
|
-
|
|
6
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
7
|
-
|
|
8
|
-
import "core-js/modules/es.object.assign.js";
|
|
9
|
-
import "core-js/modules/es.array.iterator.js";
|
|
10
|
-
import "core-js/modules/es.object.to-string.js";
|
|
11
|
-
import "core-js/modules/es.string.iterator.js";
|
|
12
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
|
13
|
-
import "core-js/modules/web.url.js";
|
|
14
|
-
import "core-js/modules/web.url-search-params.js";
|
|
15
1
|
import React, { useEffect } from 'react';
|
|
16
2
|
import global from 'global';
|
|
17
3
|
import deprecate from 'util-deprecate';
|
|
@@ -25,37 +11,44 @@ import { storyBlockIdFromId } from './Story';
|
|
|
25
11
|
import { SourceContainer } from './SourceContainer';
|
|
26
12
|
import { CodeOrSourceMdx, AnchorMdx, HeadersMdx } from './mdx';
|
|
27
13
|
import { scrollToElement } from './utils';
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
const {
|
|
15
|
+
document,
|
|
16
|
+
window: globalWindow
|
|
17
|
+
} = global;
|
|
18
|
+
const defaultComponents = Object.assign({}, htmlComponents, {
|
|
31
19
|
code: CodeOrSourceMdx,
|
|
32
20
|
a: AnchorMdx
|
|
33
21
|
}, HeadersMdx);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var context = _ref.context,
|
|
37
|
-
children = _ref.children;
|
|
38
|
-
var storyId = context.id,
|
|
39
|
-
storyById = context.storyById;
|
|
40
|
-
|
|
41
|
-
var _storyById = storyById(storyId),
|
|
42
|
-
_storyById$parameters = _storyById.parameters,
|
|
43
|
-
_storyById$parameters2 = _storyById$parameters.options,
|
|
44
|
-
options = _storyById$parameters2 === void 0 ? {} : _storyById$parameters2,
|
|
45
|
-
_storyById$parameters3 = _storyById$parameters.docs,
|
|
46
|
-
docs = _storyById$parameters3 === void 0 ? {} : _storyById$parameters3;
|
|
22
|
+
const warnOptionsTheme = deprecate(() => {}, dedent`
|
|
23
|
+
Deprecated parameter: options.theme => docs.theme
|
|
47
24
|
|
|
48
|
-
|
|
25
|
+
https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/theming.md#storybook-theming
|
|
26
|
+
`);
|
|
27
|
+
export const DocsContainer = ({
|
|
28
|
+
context,
|
|
29
|
+
children
|
|
30
|
+
}) => {
|
|
31
|
+
const {
|
|
32
|
+
id: storyId,
|
|
33
|
+
storyById
|
|
34
|
+
} = context;
|
|
35
|
+
const {
|
|
36
|
+
parameters: {
|
|
37
|
+
options = {},
|
|
38
|
+
docs = {}
|
|
39
|
+
}
|
|
40
|
+
} = storyById(storyId);
|
|
41
|
+
let themeVars = docs.theme;
|
|
49
42
|
|
|
50
43
|
if (!themeVars && options.theme) {
|
|
51
44
|
warnOptionsTheme();
|
|
52
45
|
themeVars = options.theme;
|
|
53
46
|
}
|
|
54
47
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
useEffect(
|
|
58
|
-
|
|
48
|
+
const theme = ensureTheme(themeVars);
|
|
49
|
+
const allComponents = Object.assign({}, defaultComponents, docs.components);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
let url;
|
|
59
52
|
|
|
60
53
|
try {
|
|
61
54
|
url = new URL(globalWindow.parent.location);
|
|
@@ -64,29 +57,28 @@ export var DocsContainer = function DocsContainer(_ref) {
|
|
|
64
57
|
}
|
|
65
58
|
|
|
66
59
|
if (url.hash) {
|
|
67
|
-
|
|
60
|
+
const element = document.getElementById(url.hash.substring(1));
|
|
68
61
|
|
|
69
62
|
if (element) {
|
|
70
63
|
// Introducing a delay to ensure scrolling works when it's a full refresh.
|
|
71
|
-
setTimeout(
|
|
64
|
+
setTimeout(() => {
|
|
72
65
|
scrollToElement(element);
|
|
73
66
|
}, 200);
|
|
74
67
|
}
|
|
75
68
|
} else {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (_element) {
|
|
79
|
-
var allStories = _element.parentElement.querySelectorAll('[id|="anchor-"]');
|
|
69
|
+
const element = document.getElementById(anchorBlockIdFromId(storyId)) || document.getElementById(storyBlockIdFromId(storyId));
|
|
80
70
|
|
|
81
|
-
|
|
71
|
+
if (element) {
|
|
72
|
+
const allStories = element.parentElement.querySelectorAll('[id|="anchor-"]');
|
|
73
|
+
let scrollTarget = element;
|
|
82
74
|
|
|
83
|
-
if (allStories && allStories[0] ===
|
|
75
|
+
if (allStories && allStories[0] === element) {
|
|
84
76
|
// Include content above first story
|
|
85
77
|
scrollTarget = document.getElementById('docs-root');
|
|
86
78
|
} // Introducing a delay to ensure scrolling works when it's a full refresh.
|
|
87
79
|
|
|
88
80
|
|
|
89
|
-
setTimeout(
|
|
81
|
+
setTimeout(() => {
|
|
90
82
|
scrollToElement(scrollTarget, 'start');
|
|
91
83
|
}, 200);
|
|
92
84
|
}
|
|
@@ -13,4 +13,4 @@ if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) {
|
|
|
13
13
|
globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext';
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export const DocsContext = globalWindow ? globalWindow.__DOCS_CONTEXT__ : /*#__PURE__*/createContext({});
|
|
@@ -6,8 +6,6 @@ import { Primary } from './Primary';
|
|
|
6
6
|
import { PRIMARY_STORY } from './types';
|
|
7
7
|
import { ArgsTable } from './ArgsTable';
|
|
8
8
|
import { Stories } from './Stories';
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}), /*#__PURE__*/React.createElement(Stories, null));
|
|
13
|
-
};
|
|
9
|
+
export const DocsPage = () => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Title, null), /*#__PURE__*/React.createElement(Subtitle, null), /*#__PURE__*/React.createElement(Description, null), /*#__PURE__*/React.createElement(Primary, null), /*#__PURE__*/React.createElement(ArgsTable, {
|
|
10
|
+
story: PRIMARY_STORY
|
|
11
|
+
}), /*#__PURE__*/React.createElement(Stories, null));
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import "core-js/modules/es.array.slice.js";
|
|
2
|
-
import "core-js/modules/es.object.freeze.js";
|
|
3
|
-
|
|
4
|
-
var _templateObject;
|
|
5
|
-
|
|
6
|
-
import "core-js/modules/es.function.name.js";
|
|
7
|
-
import "core-js/modules/es.symbol.js";
|
|
8
|
-
import "core-js/modules/es.symbol.description.js";
|
|
9
|
-
|
|
10
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
11
|
-
|
|
12
1
|
import React from 'react';
|
|
13
2
|
import deprecate from 'util-deprecate';
|
|
14
3
|
import dedent from 'ts-dedent';
|
|
@@ -17,23 +6,25 @@ import { Anchor } from './Anchor';
|
|
|
17
6
|
import { Description } from './Description';
|
|
18
7
|
import { Story } from './Story';
|
|
19
8
|
import { Canvas } from './Canvas';
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
const warnStoryDescription = deprecate(() => {}, dedent`
|
|
10
|
+
Deprecated parameter: docs.storyDescription => docs.description.story
|
|
11
|
+
|
|
12
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#docs-description-parameter
|
|
13
|
+
`);
|
|
14
|
+
export const DocsStory = ({
|
|
15
|
+
id,
|
|
16
|
+
name,
|
|
17
|
+
expanded = true,
|
|
18
|
+
withToolbar = false,
|
|
19
|
+
parameters = {}
|
|
20
|
+
}) => {
|
|
21
|
+
let description;
|
|
22
|
+
const {
|
|
23
|
+
docs
|
|
24
|
+
} = parameters;
|
|
32
25
|
|
|
33
26
|
if (expanded && docs) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
description = (_docs$description = docs.description) === null || _docs$description === void 0 ? void 0 : _docs$description.story;
|
|
27
|
+
description = docs.description?.story;
|
|
37
28
|
|
|
38
29
|
if (!description) {
|
|
39
30
|
description = docs.storyDescription;
|
|
@@ -41,7 +32,7 @@ export var DocsStory = function DocsStory(_ref) {
|
|
|
41
32
|
}
|
|
42
33
|
}
|
|
43
34
|
|
|
44
|
-
|
|
35
|
+
const subheading = expanded && name;
|
|
45
36
|
return /*#__PURE__*/React.createElement(Anchor, {
|
|
46
37
|
storyId: id
|
|
47
38
|
}, subheading && /*#__PURE__*/React.createElement(Subheading, null, subheading), description && /*#__PURE__*/React.createElement(Description, {
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import "core-js/modules/es.regexp.exec.js";
|
|
2
|
-
import "core-js/modules/es.string.replace.js";
|
|
3
1
|
import React from 'react';
|
|
4
2
|
import { H2 } from '@storybook/components';
|
|
5
3
|
import { HeaderMdx } from './mdx';
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export const Heading = ({
|
|
5
|
+
children,
|
|
6
|
+
disableAnchor
|
|
7
|
+
}) => {
|
|
10
8
|
if (disableAnchor || typeof children !== 'string') {
|
|
11
9
|
return /*#__PURE__*/React.createElement(H2, null, children);
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
const tagID = children.toLowerCase().replace(/[^a-z0-9]/gi, '-');
|
|
15
13
|
return /*#__PURE__*/React.createElement(HeaderMdx, {
|
|
16
14
|
as: "h2",
|
|
17
15
|
id: tagID
|
package/dist/esm/blocks/Meta.js
CHANGED
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import "core-js/modules/es.array.iterator.js";
|
|
2
|
-
import "core-js/modules/es.object.to-string.js";
|
|
3
|
-
import "core-js/modules/es.string.iterator.js";
|
|
4
|
-
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
|
-
import "core-js/modules/web.url.js";
|
|
6
|
-
import "core-js/modules/web.url-search-params.js";
|
|
7
1
|
import React, { useContext } from 'react';
|
|
8
2
|
import global from 'global';
|
|
9
3
|
import { Anchor } from './Anchor';
|
|
10
4
|
import { DocsContext } from './DocsContext';
|
|
11
|
-
|
|
5
|
+
const {
|
|
6
|
+
document
|
|
7
|
+
} = global;
|
|
12
8
|
|
|
13
9
|
function getFirstStoryId(docsContext) {
|
|
14
|
-
|
|
10
|
+
const stories = docsContext.componentStories();
|
|
15
11
|
return stories.length > 0 ? stories[0].id : null;
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
function renderAnchor() {
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
const context = useContext(DocsContext);
|
|
16
|
+
const anchorId = getFirstStoryId(context) || context.id;
|
|
21
17
|
return /*#__PURE__*/React.createElement(Anchor, {
|
|
22
18
|
storyId: anchorId
|
|
23
19
|
});
|
|
@@ -28,8 +24,8 @@ function renderAnchor() {
|
|
|
28
24
|
*/
|
|
29
25
|
|
|
30
26
|
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
export const Meta = () => {
|
|
28
|
+
const params = new URL(document.location).searchParams;
|
|
29
|
+
const isDocs = params.get('viewMode') === 'docs';
|
|
34
30
|
return isDocs ? renderAnchor() : null;
|
|
35
31
|
};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
import "core-js/modules/es.array.slice.js";
|
|
2
|
-
import "core-js/modules/es.object.freeze.js";
|
|
3
|
-
|
|
4
|
-
var _templateObject;
|
|
5
|
-
|
|
6
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
7
|
-
|
|
8
1
|
import React from 'react';
|
|
9
2
|
import deprecate from 'util-deprecate';
|
|
10
3
|
import dedent from 'ts-dedent';
|
|
11
4
|
import { Canvas } from './Canvas';
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
export const Preview = deprecate(props => /*#__PURE__*/React.createElement(Canvas, props), dedent`
|
|
6
|
+
Preview doc block has been renamed to Canvas.
|
|
7
|
+
|
|
8
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#previewprops-renamed
|
|
9
|
+
`);
|
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
1
|
+
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); }
|
|
2
2
|
|
|
3
|
-
import "core-js/modules/es.function.name.js";
|
|
4
|
-
import "core-js/modules/es.array.find.js";
|
|
5
|
-
import "core-js/modules/es.object.to-string.js";
|
|
6
|
-
import "core-js/modules/es.object.assign.js";
|
|
7
3
|
import React, { useContext } from 'react';
|
|
8
4
|
import { DocsContext } from './DocsContext';
|
|
9
5
|
import { DocsStory } from './DocsStory';
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
export const Primary = ({
|
|
7
|
+
name
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
componentStories: getComponentStories
|
|
11
|
+
} = useContext(DocsContext);
|
|
12
|
+
const componentStories = getComponentStories();
|
|
13
|
+
let story;
|
|
18
14
|
|
|
19
15
|
if (componentStories) {
|
|
20
|
-
story = name ? componentStories.find(
|
|
21
|
-
return s.name === name;
|
|
22
|
-
}) : componentStories[0];
|
|
16
|
+
story = name ? componentStories.find(s => s.name === name) : componentStories[0];
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
return story ? /*#__PURE__*/React.createElement(DocsStory, _extends({}, story, {
|
package/dist/esm/blocks/Props.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import "core-js/modules/es.array.slice.js";
|
|
2
|
-
import "core-js/modules/es.object.freeze.js";
|
|
3
|
-
|
|
4
|
-
var _templateObject;
|
|
5
|
-
|
|
6
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
7
|
-
|
|
8
1
|
import React from 'react';
|
|
9
2
|
import deprecate from 'util-deprecate';
|
|
10
3
|
import dedent from 'ts-dedent';
|
|
11
4
|
import { ArgsTable } from './ArgsTable';
|
|
12
5
|
import { CURRENT_SELECTION } from './types';
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
export const Props = deprecate(props => /*#__PURE__*/React.createElement(ArgsTable, props), dedent`
|
|
7
|
+
Props doc block has been renamed to ArgsTable.
|
|
8
|
+
|
|
9
|
+
https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#previewprops-renamed
|
|
10
|
+
`); // @ts-ignore
|
|
16
11
|
|
|
17
12
|
Props.defaultProps = {
|
|
18
13
|
of: CURRENT_SELECTION
|