@storybook/react 7.0.0-alpha.4 → 7.0.0-alpha.40
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/chunk-WO7CMEGS.mjs +1 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.js +3 -0
- package/dist/config.mjs +3 -0
- package/dist/index.d.ts +185 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/types-7e2d88a6.d.ts +10 -0
- package/package.json +47 -19
- package/preview.js +1 -1
- package/LICENSE +0 -21
- package/dist/cjs/config.js +0 -43
- package/dist/cjs/docs/config.js +0 -25
- package/dist/cjs/docs/extractArgTypes.js +0 -47
- package/dist/cjs/docs/extractProps.js +0 -57
- package/dist/cjs/docs/jsxDecorator.js +0 -210
- package/dist/cjs/docs/lib/captions.js +0 -18
- package/dist/cjs/docs/lib/componentTypes.js +0 -14
- package/dist/cjs/docs/lib/defaultValues/createDefaultValue.js +0 -86
- package/dist/cjs/docs/lib/defaultValues/createFromRawDefaultProp.js +0 -206
- package/dist/cjs/docs/lib/defaultValues/generateArray.js +0 -31
- package/dist/cjs/docs/lib/defaultValues/generateObject.js +0 -31
- package/dist/cjs/docs/lib/defaultValues/index.js +0 -31
- package/dist/cjs/docs/lib/defaultValues/prettyIdentifier.js +0 -38
- package/dist/cjs/docs/lib/generateCode.js +0 -74
- package/dist/cjs/docs/lib/index.js +0 -57
- package/dist/cjs/docs/lib/inspection/acornParser.js +0 -230
- package/dist/cjs/docs/lib/inspection/index.js +0 -31
- package/dist/cjs/docs/lib/inspection/inspectValue.js +0 -24
- package/dist/cjs/docs/lib/inspection/types.js +0 -19
- package/dist/cjs/docs/lib/isHtmlTag.js +0 -14
- package/dist/cjs/docs/propTypes/createType.js +0 -458
- package/dist/cjs/docs/propTypes/generateFuncSignature.js +0 -68
- package/dist/cjs/docs/propTypes/handleProp.js +0 -52
- package/dist/cjs/docs/propTypes/rawDefaultPropResolvers.js +0 -43
- package/dist/cjs/docs/propTypes/sortProps.js +0 -21
- package/dist/cjs/docs/react-argtypes.stories.js +0 -67
- package/dist/cjs/docs/typeScript/handleProp.js +0 -38
- package/dist/cjs/index.js +0 -98
- package/dist/cjs/preview/config.js +0 -19
- package/dist/cjs/preview/globals.js +0 -13
- package/dist/cjs/preview/index.js +0 -44
- package/dist/cjs/preview/render.js +0 -165
- package/dist/cjs/preview/types-6-0.js +0 -5
- package/dist/cjs/preview/types-6-3.js +0 -18
- package/dist/cjs/preview/types-7-0.js +0 -5
- package/dist/cjs/preview/types.js +0 -5
- package/dist/cjs/testing/index.js +0 -113
- package/dist/esm/config.js +0 -6
- package/dist/esm/docs/config.js +0 -12
- package/dist/esm/docs/extractArgTypes.js +0 -37
- package/dist/esm/docs/extractProps.js +0 -42
- package/dist/esm/docs/jsxDecorator.js +0 -170
- package/dist/esm/docs/lib/captions.js +0 -6
- package/dist/esm/docs/lib/componentTypes.js +0 -2
- package/dist/esm/docs/lib/defaultValues/createDefaultValue.js +0 -72
- package/dist/esm/docs/lib/defaultValues/createFromRawDefaultProp.js +0 -183
- package/dist/esm/docs/lib/defaultValues/generateArray.js +0 -21
- package/dist/esm/docs/lib/defaultValues/generateObject.js +0 -21
- package/dist/esm/docs/lib/defaultValues/index.js +0 -2
- package/dist/esm/docs/lib/defaultValues/prettyIdentifier.js +0 -26
- package/dist/esm/docs/lib/generateCode.js +0 -59
- package/dist/esm/docs/lib/index.js +0 -4
- package/dist/esm/docs/lib/inspection/acornParser.js +0 -211
- package/dist/esm/docs/lib/inspection/index.js +0 -2
- package/dist/esm/docs/lib/inspection/inspectValue.js +0 -15
- package/dist/esm/docs/lib/inspection/types.js +0 -12
- package/dist/esm/docs/lib/isHtmlTag.js +0 -4
- package/dist/esm/docs/propTypes/createType.js +0 -447
- package/dist/esm/docs/propTypes/generateFuncSignature.js +0 -57
- package/dist/esm/docs/propTypes/handleProp.js +0 -39
- package/dist/esm/docs/propTypes/rawDefaultPropResolvers.js +0 -31
- package/dist/esm/docs/propTypes/sortProps.js +0 -14
- package/dist/esm/docs/react-argtypes.stories.js +0 -54
- package/dist/esm/docs/typeScript/handleProp.js +0 -28
- package/dist/esm/index.js +0 -5
- package/dist/esm/preview/config.js +0 -1
- package/dist/esm/preview/globals.js +0 -8
- package/dist/esm/preview/index.js +0 -21
- package/dist/esm/preview/render.js +0 -141
- package/dist/esm/preview/types-6-0.js +0 -1
- package/dist/esm/preview/types-6-3.js +0 -10
- package/dist/esm/preview/types-7-0.js +0 -1
- package/dist/esm/preview/types.js +0 -1
- package/dist/esm/testing/index.js +0 -97
- package/dist/types/config.d.ts +0 -10
- package/dist/types/docs/config.d.ts +0 -10
- package/dist/types/docs/extractArgTypes.d.ts +0 -2
- package/dist/types/docs/extractProps.d.ts +0 -9
- package/dist/types/docs/jsxDecorator.d.ts +0 -23
- package/dist/types/docs/lib/captions.d.ts +0 -6
- package/dist/types/docs/lib/componentTypes.d.ts +0 -2
- package/dist/types/docs/lib/defaultValues/createDefaultValue.d.ts +0 -2
- package/dist/types/docs/lib/defaultValues/createFromRawDefaultProp.d.ts +0 -11
- package/dist/types/docs/lib/defaultValues/generateArray.d.ts +0 -3
- package/dist/types/docs/lib/defaultValues/generateObject.d.ts +0 -3
- package/dist/types/docs/lib/defaultValues/index.d.ts +0 -2
- package/dist/types/docs/lib/defaultValues/prettyIdentifier.d.ts +0 -4
- package/dist/types/docs/lib/generateCode.d.ts +0 -3
- package/dist/types/docs/lib/index.d.ts +0 -4
- package/dist/types/docs/lib/inspection/acornParser.d.ts +0 -7
- package/dist/types/docs/lib/inspection/index.d.ts +0 -2
- package/dist/types/docs/lib/inspection/inspectValue.d.ts +0 -2
- package/dist/types/docs/lib/inspection/types.d.ts +0 -50
- package/dist/types/docs/lib/isHtmlTag.d.ts +0 -1
- package/dist/types/docs/propTypes/createType.d.ts +0 -2
- package/dist/types/docs/propTypes/generateFuncSignature.d.ts +0 -4
- package/dist/types/docs/propTypes/handleProp.d.ts +0 -5
- package/dist/types/docs/propTypes/rawDefaultPropResolvers.d.ts +0 -1
- package/dist/types/docs/propTypes/sortProps.d.ts +0 -4
- package/dist/types/docs/react-argtypes.stories.d.ts +0 -1
- package/dist/types/docs/typeScript/handleProp.d.ts +0 -3
- package/dist/types/index.d.ts +0 -4
- package/dist/types/preview/config.d.ts +0 -1
- package/dist/types/preview/globals.d.ts +0 -1
- package/dist/types/preview/index.d.ts +0 -25
- package/dist/types/preview/render.d.ts +0 -5
- package/dist/types/preview/types-6-0.d.ts +0 -35
- package/dist/types/preview/types-6-3.d.ts +0 -40
- package/dist/types/preview/types-7-0.d.ts +0 -21
- package/dist/types/preview/types.d.ts +0 -16
- package/dist/types/testing/index.d.ts +0 -84
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.enhanceTypeScriptProp = enhanceTypeScriptProp;
|
|
7
|
-
exports.enhanceTypeScriptProps = enhanceTypeScriptProps;
|
|
8
|
-
|
|
9
|
-
var _defaultValues = require("../lib/defaultValues");
|
|
10
|
-
|
|
11
|
-
function enhanceTypeScriptProp(extractedProp, rawDefaultProp) {
|
|
12
|
-
const {
|
|
13
|
-
propDef
|
|
14
|
-
} = extractedProp;
|
|
15
|
-
const {
|
|
16
|
-
defaultValue
|
|
17
|
-
} = extractedProp.docgenInfo;
|
|
18
|
-
|
|
19
|
-
if (defaultValue != null && defaultValue.value != null) {
|
|
20
|
-
const newDefaultValue = (0, _defaultValues.createDefaultValue)(defaultValue.value);
|
|
21
|
-
|
|
22
|
-
if (newDefaultValue != null) {
|
|
23
|
-
propDef.defaultValue = newDefaultValue;
|
|
24
|
-
}
|
|
25
|
-
} else if (rawDefaultProp != null) {
|
|
26
|
-
const newDefaultValue = (0, _defaultValues.createDefaultValueFromRawDefaultProp)(rawDefaultProp, propDef);
|
|
27
|
-
|
|
28
|
-
if (newDefaultValue != null) {
|
|
29
|
-
propDef.defaultValue = newDefaultValue;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return propDef;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function enhanceTypeScriptProps(extractedProps) {
|
|
37
|
-
return extractedProps.map(prop => enhanceTypeScriptProp(prop));
|
|
38
|
-
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,98 +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
|
-
raw: true,
|
|
14
|
-
forceReRender: true
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "addDecorator", {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return _preview.addDecorator;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(exports, "addParameters", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () {
|
|
25
|
-
return _preview.addParameters;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports, "configure", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return _preview.configure;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, "forceReRender", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function () {
|
|
37
|
-
return _preview.forceReRender;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
Object.defineProperty(exports, "getStorybook", {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function () {
|
|
43
|
-
return _preview.getStorybook;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
Object.defineProperty(exports, "raw", {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function () {
|
|
49
|
-
return _preview.raw;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
Object.defineProperty(exports, "setAddon", {
|
|
53
|
-
enumerable: true,
|
|
54
|
-
get: function () {
|
|
55
|
-
return _preview.setAddon;
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
Object.defineProperty(exports, "storiesOf", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
get: function () {
|
|
61
|
-
return _preview.storiesOf;
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
var _preview = require("./preview");
|
|
66
|
-
|
|
67
|
-
var _testing = require("./testing");
|
|
68
|
-
|
|
69
|
-
Object.keys(_testing).forEach(function (key) {
|
|
70
|
-
if (key === "default" || key === "__esModule") return;
|
|
71
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
72
|
-
if (key in exports && exports[key] === _testing[key]) return;
|
|
73
|
-
Object.defineProperty(exports, key, {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
get: function () {
|
|
76
|
-
return _testing[key];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
var _types = require("./preview/types-6-3");
|
|
82
|
-
|
|
83
|
-
Object.keys(_types).forEach(function (key) {
|
|
84
|
-
if (key === "default" || key === "__esModule") return;
|
|
85
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _types[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
var _module, _module$hot;
|
|
96
|
-
|
|
97
|
-
// optimization: stop HMR propagation in webpack
|
|
98
|
-
(_module = module) === null || _module === void 0 ? void 0 : (_module$hot = _module.hot) === null || _module$hot === void 0 ? void 0 : _module$hot.decline();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "render", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _render.render;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "renderToDOM", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _render.renderToDOM;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
var _render = require("./render");
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _global = _interopRequireDefault(require("global"));
|
|
4
|
-
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
window: globalWindow
|
|
9
|
-
} = _global.default;
|
|
10
|
-
|
|
11
|
-
if (globalWindow) {
|
|
12
|
-
globalWindow.STORYBOOK_ENV = 'react';
|
|
13
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.storiesOf = exports.setAddon = exports.raw = exports.getStorybook = exports.forceReRender = exports.configure = exports.clearDecorators = exports.addParameters = exports.addDecorator = void 0;
|
|
7
|
-
|
|
8
|
-
var _coreClient = require("@storybook/core-client");
|
|
9
|
-
|
|
10
|
-
require("./globals");
|
|
11
|
-
|
|
12
|
-
var _render = require("./render");
|
|
13
|
-
|
|
14
|
-
/* eslint-disable prefer-destructuring */
|
|
15
|
-
const framework = 'react';
|
|
16
|
-
const api = (0, _coreClient.start)(_render.renderToDOM, {
|
|
17
|
-
render: _render.render
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const storiesOf = (kind, m) => {
|
|
21
|
-
return api.clientApi.storiesOf(kind, m).addParameters({
|
|
22
|
-
framework
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.storiesOf = storiesOf;
|
|
27
|
-
|
|
28
|
-
const configure = (...args) => api.configure(framework, ...args);
|
|
29
|
-
|
|
30
|
-
exports.configure = configure;
|
|
31
|
-
const addDecorator = api.clientApi.addDecorator;
|
|
32
|
-
exports.addDecorator = addDecorator;
|
|
33
|
-
const addParameters = api.clientApi.addParameters;
|
|
34
|
-
exports.addParameters = addParameters;
|
|
35
|
-
const clearDecorators = api.clientApi.clearDecorators;
|
|
36
|
-
exports.clearDecorators = clearDecorators;
|
|
37
|
-
const setAddon = api.clientApi.setAddon;
|
|
38
|
-
exports.setAddon = setAddon;
|
|
39
|
-
const forceReRender = api.forceReRender;
|
|
40
|
-
exports.forceReRender = forceReRender;
|
|
41
|
-
const getStorybook = api.clientApi.getStorybook;
|
|
42
|
-
exports.getStorybook = getStorybook;
|
|
43
|
-
const raw = api.clientApi.raw;
|
|
44
|
-
exports.raw = raw;
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.render = void 0;
|
|
7
|
-
exports.renderToDOM = renderToDOM;
|
|
8
|
-
|
|
9
|
-
var _global = _interopRequireDefault(require("global"));
|
|
10
|
-
|
|
11
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
-
|
|
13
|
-
var _reactDom = _interopRequireWildcard(require("react-dom"));
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
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); }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
const {
|
|
22
|
-
FRAMEWORK_OPTIONS
|
|
23
|
-
} = _global.default; // A map of all rendered React 18 nodes
|
|
24
|
-
|
|
25
|
-
const nodes = new Map();
|
|
26
|
-
|
|
27
|
-
const render = (args, context) => {
|
|
28
|
-
const {
|
|
29
|
-
id,
|
|
30
|
-
component: Component
|
|
31
|
-
} = context;
|
|
32
|
-
|
|
33
|
-
if (!Component) {
|
|
34
|
-
throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return /*#__PURE__*/_react.default.createElement(Component, args);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
exports.render = render;
|
|
41
|
-
|
|
42
|
-
const renderElement = async (node, el) => {
|
|
43
|
-
// Create Root Element conditionally for new React 18 Root Api
|
|
44
|
-
const root = await getReactRoot(el);
|
|
45
|
-
return new Promise(resolve => {
|
|
46
|
-
if (root) {
|
|
47
|
-
root.render(node);
|
|
48
|
-
setTimeout(() => {
|
|
49
|
-
resolve(null);
|
|
50
|
-
}, 0);
|
|
51
|
-
} else {
|
|
52
|
-
_reactDom.default.render(node, el, () => resolve(null));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const canUseNewReactRootApi = _reactDom.version && (_reactDom.version.startsWith('18') || _reactDom.version.startsWith('0.0.0'));
|
|
58
|
-
|
|
59
|
-
const shouldUseNewRootApi = (FRAMEWORK_OPTIONS === null || FRAMEWORK_OPTIONS === void 0 ? void 0 : FRAMEWORK_OPTIONS.legacyRootApi) !== true;
|
|
60
|
-
const isUsingNewReactRootApi = shouldUseNewRootApi && canUseNewReactRootApi;
|
|
61
|
-
|
|
62
|
-
const unmountElement = el => {
|
|
63
|
-
const root = nodes.get(el);
|
|
64
|
-
|
|
65
|
-
if (root && isUsingNewReactRootApi) {
|
|
66
|
-
root.unmount();
|
|
67
|
-
nodes.delete(el);
|
|
68
|
-
} else {
|
|
69
|
-
_reactDom.default.unmountComponentAtNode(el);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const getReactRoot = async el => {
|
|
74
|
-
if (!isUsingNewReactRootApi) {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let root = nodes.get(el);
|
|
79
|
-
|
|
80
|
-
if (!root) {
|
|
81
|
-
// eslint-disable-next-line import/no-unresolved
|
|
82
|
-
const reactDomClient = (await Promise.resolve().then(() => _interopRequireWildcard(require('react-dom/client')))).default;
|
|
83
|
-
root = reactDomClient.createRoot(el);
|
|
84
|
-
nodes.set(el, root);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return root;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
class ErrorBoundary extends _react.Component {
|
|
91
|
-
constructor(...args) {
|
|
92
|
-
super(...args);
|
|
93
|
-
this.state = {
|
|
94
|
-
hasError: false
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
static getDerivedStateFromError() {
|
|
99
|
-
return {
|
|
100
|
-
hasError: true
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
componentDidMount() {
|
|
105
|
-
const {
|
|
106
|
-
hasError
|
|
107
|
-
} = this.state;
|
|
108
|
-
const {
|
|
109
|
-
showMain
|
|
110
|
-
} = this.props;
|
|
111
|
-
|
|
112
|
-
if (!hasError) {
|
|
113
|
-
showMain();
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
componentDidCatch(err) {
|
|
118
|
-
const {
|
|
119
|
-
showException
|
|
120
|
-
} = this.props; // message partially duplicates stack, strip it
|
|
121
|
-
|
|
122
|
-
showException(err);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
render() {
|
|
126
|
-
const {
|
|
127
|
-
hasError
|
|
128
|
-
} = this.state;
|
|
129
|
-
const {
|
|
130
|
-
children
|
|
131
|
-
} = this.props;
|
|
132
|
-
return hasError ? null : children;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const Wrapper = FRAMEWORK_OPTIONS !== null && FRAMEWORK_OPTIONS !== void 0 && FRAMEWORK_OPTIONS.strictMode ? _react.StrictMode : _react.Fragment;
|
|
138
|
-
|
|
139
|
-
async function renderToDOM({
|
|
140
|
-
storyContext,
|
|
141
|
-
unboundStoryFn,
|
|
142
|
-
showMain,
|
|
143
|
-
showException,
|
|
144
|
-
forceRemount
|
|
145
|
-
}, domElement) {
|
|
146
|
-
const Story = unboundStoryFn;
|
|
147
|
-
|
|
148
|
-
const content = /*#__PURE__*/_react.default.createElement(ErrorBoundary, {
|
|
149
|
-
showMain: showMain,
|
|
150
|
-
showException: showException
|
|
151
|
-
}, /*#__PURE__*/_react.default.createElement(Story, storyContext)); // For React 15, StrictMode & Fragment doesn't exists.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
const element = Wrapper ? /*#__PURE__*/_react.default.createElement(Wrapper, null, content) : content; // In most cases, we need to unmount the existing set of components in the DOM node.
|
|
155
|
-
// Otherwise, React may not recreate instances for every story run.
|
|
156
|
-
// This could leads to issues like below:
|
|
157
|
-
// https://github.com/storybookjs/react-storybook/issues/81
|
|
158
|
-
// (This is not the case when we change args or globals to the story however)
|
|
159
|
-
|
|
160
|
-
if (forceRemount) {
|
|
161
|
-
unmountElement(domElement);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
await renderElement(element, domElement);
|
|
165
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _types = require("./types-6-0");
|
|
8
|
-
|
|
9
|
-
Object.keys(_types).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _types[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.composeStories = composeStories;
|
|
7
|
-
exports.composeStory = composeStory;
|
|
8
|
-
exports.setGlobalConfig = setGlobalConfig;
|
|
9
|
-
exports.setProjectAnnotations = setProjectAnnotations;
|
|
10
|
-
|
|
11
|
-
var _store = require("@storybook/store");
|
|
12
|
-
|
|
13
|
-
var _clientLogger = require("@storybook/client-logger");
|
|
14
|
-
|
|
15
|
-
var _render = require("../preview/render");
|
|
16
|
-
|
|
17
|
-
/** Function that sets the globalConfig of your storybook. The global config is the preview module of your .storybook folder.
|
|
18
|
-
*
|
|
19
|
-
* It should be run a single time, so that your global config (e.g. decorators) is applied to your stories when using `composeStories` or `composeStory`.
|
|
20
|
-
*
|
|
21
|
-
* Example:
|
|
22
|
-
*```jsx
|
|
23
|
-
* // setup.js (for jest)
|
|
24
|
-
* import { setProjectAnnotations } from '@storybook/react';
|
|
25
|
-
* import * as projectAnnotations from './.storybook/preview';
|
|
26
|
-
*
|
|
27
|
-
* setProjectAnnotations(projectAnnotations);
|
|
28
|
-
*```
|
|
29
|
-
*
|
|
30
|
-
* @param projectAnnotations - e.g. (import * as projectAnnotations from '../.storybook/preview')
|
|
31
|
-
*/
|
|
32
|
-
function setProjectAnnotations(projectAnnotations) {
|
|
33
|
-
(0, _store.setProjectAnnotations)(projectAnnotations);
|
|
34
|
-
}
|
|
35
|
-
/** Preserved for users migrating from `@storybook/testing-react`.
|
|
36
|
-
*
|
|
37
|
-
* @deprecated Use setProjectAnnotations instead
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function setGlobalConfig(projectAnnotations) {
|
|
42
|
-
_clientLogger.once.warn(`setGlobalConfig is deprecated. Use setProjectAnnotations instead.`);
|
|
43
|
-
|
|
44
|
-
setProjectAnnotations(projectAnnotations);
|
|
45
|
-
} // This will not be necessary once we have auto preset loading
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const defaultProjectAnnotations = {
|
|
49
|
-
render: _render.render
|
|
50
|
-
};
|
|
51
|
-
/**
|
|
52
|
-
* Function that will receive a story along with meta (e.g. a default export from a .stories file)
|
|
53
|
-
* and optionally projectAnnotations e.g. (import * from '../.storybook/preview)
|
|
54
|
-
* and will return a composed component that has all args/parameters/decorators/etc combined and applied to it.
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* It's very useful for reusing a story in scenarios outside of Storybook like unit testing.
|
|
58
|
-
*
|
|
59
|
-
* Example:
|
|
60
|
-
*```jsx
|
|
61
|
-
* import { render } from '@testing-library/react';
|
|
62
|
-
* import { composeStory } from '@storybook/react';
|
|
63
|
-
* import Meta, { Primary as PrimaryStory } from './Button.stories';
|
|
64
|
-
*
|
|
65
|
-
* const Primary = composeStory(PrimaryStory, Meta);
|
|
66
|
-
*
|
|
67
|
-
* test('renders primary button with Hello World', () => {
|
|
68
|
-
* const { getByText } = render(<Primary>Hello world</Primary>);
|
|
69
|
-
* expect(getByText(/Hello world/i)).not.toBeNull();
|
|
70
|
-
* });
|
|
71
|
-
*```
|
|
72
|
-
*
|
|
73
|
-
* @param story
|
|
74
|
-
* @param componentAnnotations - e.g. (import Meta from './Button.stories')
|
|
75
|
-
* @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
|
76
|
-
* @param [exportsName] - in case your story does not contain a name and you want it to have a name.
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
function composeStory(story, componentAnnotations, projectAnnotations, exportsName) {
|
|
80
|
-
return (0, _store.composeStory)(story, componentAnnotations, projectAnnotations, defaultProjectAnnotations, exportsName);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Function that will receive a stories import (e.g. `import * as stories from './Button.stories'`)
|
|
84
|
-
* and optionally projectAnnotations (e.g. `import * from '../.storybook/preview`)
|
|
85
|
-
* and will return an object containing all the stories passed, but now as a composed component that has all args/parameters/decorators/etc combined and applied to it.
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
* It's very useful for reusing stories in scenarios outside of Storybook like unit testing.
|
|
89
|
-
*
|
|
90
|
-
* Example:
|
|
91
|
-
*```jsx
|
|
92
|
-
* import { render } from '@testing-library/react';
|
|
93
|
-
* import { composeStories } from '@storybook/react';
|
|
94
|
-
* import * as stories from './Button.stories';
|
|
95
|
-
*
|
|
96
|
-
* const { Primary, Secondary } = composeStories(stories);
|
|
97
|
-
*
|
|
98
|
-
* test('renders primary button with Hello World', () => {
|
|
99
|
-
* const { getByText } = render(<Primary>Hello world</Primary>);
|
|
100
|
-
* expect(getByText(/Hello world/i)).not.toBeNull();
|
|
101
|
-
* });
|
|
102
|
-
*```
|
|
103
|
-
*
|
|
104
|
-
* @param csfExports - e.g. (import * as stories from './Button.stories')
|
|
105
|
-
* @param [projectAnnotations] - e.g. (import * as projectAnnotations from '../.storybook/preview') this can be applied automatically if you use `setProjectAnnotations` in your setup files.
|
|
106
|
-
*/
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
function composeStories(csfExports, projectAnnotations) {
|
|
110
|
-
// @ts-ignore
|
|
111
|
-
const composedStories = (0, _store.composeStories)(csfExports, projectAnnotations, composeStory);
|
|
112
|
-
return composedStories;
|
|
113
|
-
}
|
package/dist/esm/config.js
DELETED
package/dist/esm/docs/config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { extractComponentDescription, enhanceArgTypes } from '@storybook/docs-tools';
|
|
2
|
-
import { extractArgTypes } from './extractArgTypes';
|
|
3
|
-
import { jsxDecorator } from './jsxDecorator';
|
|
4
|
-
export const parameters = {
|
|
5
|
-
docs: {
|
|
6
|
-
inlineStories: true,
|
|
7
|
-
extractArgTypes,
|
|
8
|
-
extractComponentDescription
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export const decorators = [jsxDecorator];
|
|
12
|
-
export const argTypesEnhancers = [enhanceArgTypes];
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { extractProps } from './extractProps';
|
|
2
|
-
export const extractArgTypes = component => {
|
|
3
|
-
if (component) {
|
|
4
|
-
const {
|
|
5
|
-
rows
|
|
6
|
-
} = extractProps(component);
|
|
7
|
-
|
|
8
|
-
if (rows) {
|
|
9
|
-
return rows.reduce((acc, row) => {
|
|
10
|
-
const {
|
|
11
|
-
name,
|
|
12
|
-
description,
|
|
13
|
-
type,
|
|
14
|
-
sbType,
|
|
15
|
-
defaultValue: defaultSummary,
|
|
16
|
-
jsDocTags,
|
|
17
|
-
required
|
|
18
|
-
} = row;
|
|
19
|
-
acc[name] = {
|
|
20
|
-
name,
|
|
21
|
-
description,
|
|
22
|
-
type: Object.assign({
|
|
23
|
-
required
|
|
24
|
-
}, sbType),
|
|
25
|
-
table: {
|
|
26
|
-
type,
|
|
27
|
-
jsDocTags,
|
|
28
|
-
defaultValue: defaultSummary
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return acc;
|
|
32
|
-
}, {});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { hasDocgen, extractComponentProps, TypeSystem } from '@storybook/docs-tools';
|
|
3
|
-
import { enhancePropTypesProps } from './propTypes/handleProp';
|
|
4
|
-
import { enhanceTypeScriptProps } from './typeScript/handleProp';
|
|
5
|
-
import { isMemo } from './lib'; // FIXME
|
|
6
|
-
|
|
7
|
-
const propTypesMap = new Map();
|
|
8
|
-
Object.keys(PropTypes).forEach(typeName => {
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
const type = PropTypes[typeName];
|
|
11
|
-
propTypesMap.set(type, typeName);
|
|
12
|
-
propTypesMap.set(type.isRequired, typeName);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
function getPropDefs(component, section) {
|
|
16
|
-
let processedComponent = component; // eslint-disable-next-line react/forbid-foreign-prop-types
|
|
17
|
-
|
|
18
|
-
if (!hasDocgen(component) && !component.propTypes && isMemo(component)) {
|
|
19
|
-
processedComponent = component.type;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const extractedProps = extractComponentProps(processedComponent, section);
|
|
23
|
-
|
|
24
|
-
if (extractedProps.length === 0) {
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
switch (extractedProps[0].typeSystem) {
|
|
29
|
-
case TypeSystem.JAVASCRIPT:
|
|
30
|
-
return enhancePropTypesProps(extractedProps, component);
|
|
31
|
-
|
|
32
|
-
case TypeSystem.TYPESCRIPT:
|
|
33
|
-
return enhanceTypeScriptProps(extractedProps);
|
|
34
|
-
|
|
35
|
-
default:
|
|
36
|
-
return extractedProps.map(x => x.propDef);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const extractProps = component => ({
|
|
41
|
-
rows: getPropDefs(component, 'props')
|
|
42
|
-
});
|