@storybook/react 6.4.0-beta.23 → 6.4.0-beta.24

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 (100) hide show
  1. package/package.json +8 -8
  2. package/types-7-0.d.ts +1 -0
  3. package/dist/cjs/client/index.js +0 -87
  4. package/dist/cjs/client/preview/config.js +0 -25
  5. package/dist/cjs/client/preview/globals.js +0 -11
  6. package/dist/cjs/client/preview/index.js +0 -52
  7. package/dist/cjs/client/preview/render.js +0 -213
  8. package/dist/cjs/client/preview/types-6-0.js +0 -1
  9. package/dist/cjs/client/preview/types-6-3.js +0 -22
  10. package/dist/cjs/client/preview/types-7-0.js +0 -1
  11. package/dist/cjs/client/preview/types.js +0 -1
  12. package/dist/cjs/demo/Button.js +0 -37
  13. package/dist/cjs/demo/Welcome.js +0 -122
  14. package/dist/cjs/server/build.js +0 -9
  15. package/dist/cjs/server/cra-config.js +0 -69
  16. package/dist/cjs/server/framework-preset-cra.js +0 -35
  17. package/dist/cjs/server/framework-preset-react-docgen.js +0 -58
  18. package/dist/cjs/server/framework-preset-react.js +0 -98
  19. package/dist/cjs/server/index.js +0 -9
  20. package/dist/cjs/server/options.js +0 -17
  21. package/dist/cjs/server/preset.js +0 -16
  22. package/dist/cjs/typings.d.js +0 -1
  23. package/dist/esm/client/index.js +0 -6
  24. package/dist/esm/client/preview/config.js +0 -4
  25. package/dist/esm/client/preview/globals.js +0 -6
  26. package/dist/esm/client/preview/index.js +0 -29
  27. package/dist/esm/client/preview/render.js +0 -177
  28. package/dist/esm/client/preview/types-6-0.js +0 -0
  29. package/dist/esm/client/preview/types-6-3.js +0 -8
  30. package/dist/esm/client/preview/types-7-0.js +0 -0
  31. package/dist/esm/client/preview/types.js +0 -0
  32. package/dist/esm/demo/Button.js +0 -26
  33. package/dist/esm/demo/Welcome.js +0 -111
  34. package/dist/esm/server/build.js +0 -3
  35. package/dist/esm/server/cra-config.js +0 -49
  36. package/dist/esm/server/framework-preset-cra.js +0 -25
  37. package/dist/esm/server/framework-preset-react-docgen.js +0 -45
  38. package/dist/esm/server/framework-preset-react.js +0 -78
  39. package/dist/esm/server/index.js +0 -3
  40. package/dist/esm/server/options.js +0 -8
  41. package/dist/esm/server/preset.js +0 -5
  42. package/dist/esm/typings.d.js +0 -0
  43. package/dist/modern/client/index.js +0 -6
  44. package/dist/modern/client/preview/config.js +0 -4
  45. package/dist/modern/client/preview/globals.js +0 -8
  46. package/dist/modern/client/preview/index.js +0 -21
  47. package/dist/modern/client/preview/render.js +0 -94
  48. package/dist/modern/client/preview/types-6-0.js +0 -0
  49. package/dist/modern/client/preview/types-6-3.js +0 -8
  50. package/dist/modern/client/preview/types-7-0.js +0 -0
  51. package/dist/modern/client/preview/types.js +0 -0
  52. package/dist/modern/demo/Button.js +0 -25
  53. package/dist/modern/demo/Welcome.js +0 -104
  54. package/dist/modern/server/build.js +0 -3
  55. package/dist/modern/server/cra-config.js +0 -49
  56. package/dist/modern/server/framework-preset-cra.js +0 -25
  57. package/dist/modern/server/framework-preset-react-docgen.js +0 -45
  58. package/dist/modern/server/framework-preset-react.js +0 -78
  59. package/dist/modern/server/index.js +0 -3
  60. package/dist/modern/server/options.js +0 -8
  61. package/dist/modern/server/preset.js +0 -5
  62. package/dist/modern/typings.d.js +0 -0
  63. package/dist/ts3.4/client/index.d.ts +0 -3
  64. package/dist/ts3.4/client/preview/config.d.ts +0 -4
  65. package/dist/ts3.4/client/preview/globals.d.ts +0 -1
  66. package/dist/ts3.4/client/preview/index.d.ts +0 -25
  67. package/dist/ts3.4/client/preview/render.d.ts +0 -5
  68. package/dist/ts3.4/client/preview/types-6-0.d.ts +0 -35
  69. package/dist/ts3.4/client/preview/types-6-3.d.ts +0 -40
  70. package/dist/ts3.4/client/preview/types-7-0.d.ts +0 -21
  71. package/dist/ts3.4/client/preview/types.d.ts +0 -16
  72. package/dist/ts3.4/demo/Button.d.ts +0 -4
  73. package/dist/ts3.4/demo/Welcome.d.ts +0 -6
  74. package/dist/ts3.4/server/build.d.ts +0 -1
  75. package/dist/ts3.4/server/cra-config.d.ts +0 -4
  76. package/dist/ts3.4/server/framework-preset-cra.d.ts +0 -3
  77. package/dist/ts3.4/server/framework-preset-react-docgen.d.ts +0 -5
  78. package/dist/ts3.4/server/framework-preset-react.d.ts +0 -51
  79. package/dist/ts3.4/server/index.d.ts +0 -1
  80. package/dist/ts3.4/server/options.d.ts +0 -3
  81. package/dist/ts3.4/server/preset.d.ts +0 -3
  82. package/dist/ts3.9/client/index.d.ts +0 -3
  83. package/dist/ts3.9/client/preview/config.d.ts +0 -4
  84. package/dist/ts3.9/client/preview/globals.d.ts +0 -1
  85. package/dist/ts3.9/client/preview/index.d.ts +0 -25
  86. package/dist/ts3.9/client/preview/render.d.ts +0 -5
  87. package/dist/ts3.9/client/preview/types-6-0.d.ts +0 -35
  88. package/dist/ts3.9/client/preview/types-6-3.d.ts +0 -40
  89. package/dist/ts3.9/client/preview/types-7-0.d.ts +0 -21
  90. package/dist/ts3.9/client/preview/types.d.ts +0 -16
  91. package/dist/ts3.9/demo/Button.d.ts +0 -4
  92. package/dist/ts3.9/demo/Welcome.d.ts +0 -6
  93. package/dist/ts3.9/server/build.d.ts +0 -1
  94. package/dist/ts3.9/server/cra-config.d.ts +0 -4
  95. package/dist/ts3.9/server/framework-preset-cra.d.ts +0 -3
  96. package/dist/ts3.9/server/framework-preset-react-docgen.d.ts +0 -5
  97. package/dist/ts3.9/server/framework-preset-react.d.ts +0 -51
  98. package/dist/ts3.9/server/index.d.ts +0 -1
  99. package/dist/ts3.9/server/options.d.ts +0 -3
  100. package/dist/ts3.9/server/preset.d.ts +0 -3
@@ -1,111 +0,0 @@
1
- import "core-js/modules/es.object.assign.js";
2
- import "core-js/modules/es.object.keys.js";
3
- import "core-js/modules/es.symbol.js";
4
-
5
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
-
7
- 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; }
8
-
9
- function _extends() { _extends = Object.assign || 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); }
10
-
11
- import React from 'react';
12
-
13
- var Main = function Main(props) {
14
- return /*#__PURE__*/React.createElement("article", _extends({}, props, {
15
- style: {
16
- padding: 15,
17
- lineHeight: 1.4,
18
- fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
19
- backgroundColor: '#fff',
20
- color: '#000'
21
- }
22
- }));
23
- };
24
-
25
- var Title = function Title(_ref) {
26
- var children = _ref.children,
27
- props = _objectWithoutProperties(_ref, ["children"]);
28
-
29
- return /*#__PURE__*/React.createElement("h1", props, children);
30
- };
31
-
32
- var Note = function Note(props) {
33
- return /*#__PURE__*/React.createElement("p", _extends({}, props, {
34
- style: {
35
- opacity: 0.5
36
- }
37
- }));
38
- };
39
-
40
- var InlineCode = function InlineCode(props) {
41
- return /*#__PURE__*/React.createElement("code", _extends({}, props, {
42
- style: {
43
- fontSize: 15,
44
- fontWeight: 600,
45
- padding: '2px 5px',
46
- border: '1px solid #eae9e9',
47
- borderRadius: 4,
48
- backgroundColor: '#f3f2f2',
49
- color: '#3a3a3a'
50
- }
51
- }));
52
- };
53
-
54
- var Link = function Link(_ref2) {
55
- var children = _ref2.children,
56
- href = _ref2.href,
57
- target = _ref2.target,
58
- rel = _ref2.rel,
59
- props = _objectWithoutProperties(_ref2, ["children", "href", "target", "rel"]);
60
-
61
- return /*#__PURE__*/React.createElement("a", _extends({
62
- href: href
63
- }, props, {
64
- target: target,
65
- rel: rel,
66
- style: {
67
- color: '#1474f3',
68
- textDecoration: 'none',
69
- borderBottom: '1px solid #1474f3',
70
- paddingBottom: 2
71
- }
72
- }), children);
73
- };
74
-
75
- var NavButton = function NavButton(_ref3) {
76
- var children = _ref3.children,
77
- onClick = _ref3.onClick,
78
- props = _objectWithoutProperties(_ref3, ["children", "onClick"]);
79
-
80
- return /*#__PURE__*/React.createElement("button", _extends({}, props, {
81
- type: "button",
82
- onClick: onClick,
83
- style: {
84
- color: '#1474f3',
85
- textDecoration: 'none',
86
- borderBottom: '1px solid #1474f3',
87
- paddingBottom: 2,
88
- borderTop: 'none',
89
- borderRight: 'none',
90
- borderLeft: 'none',
91
- backgroundColor: 'transparent',
92
- padding: 0,
93
- cursor: 'pointer',
94
- font: 'inherit'
95
- }
96
- }), children);
97
- };
98
-
99
- var Welcome = function Welcome(_ref4) {
100
- var showApp = _ref4.showApp;
101
- return /*#__PURE__*/React.createElement(Main, null, /*#__PURE__*/React.createElement(Title, null, "Welcome to storybook"), /*#__PURE__*/React.createElement("p", null, "This is a UI component dev environment for your app."), /*#__PURE__*/React.createElement("p", null, "We've added some basic stories inside the ", /*#__PURE__*/React.createElement(InlineCode, null, "src/stories"), " directory.", /*#__PURE__*/React.createElement("br", null), "A story is a single state of one or more UI components. You can have as many stories as you want.", /*#__PURE__*/React.createElement("br", null), "(Basically a story is like a visual test case.)"), /*#__PURE__*/React.createElement("p", null, "See these sample ", /*#__PURE__*/React.createElement(NavButton, {
102
- onClick: showApp
103
- }, "stories"), " for a component called\xA0", /*#__PURE__*/React.createElement(InlineCode, null, "Button"), "."), /*#__PURE__*/React.createElement("p", null, "Just like that, you can add your own components as stories.", /*#__PURE__*/React.createElement("br", null), "You can also edit those components and see changes right away.", /*#__PURE__*/React.createElement("br", null), "(Try editing the ", /*#__PURE__*/React.createElement(InlineCode, null, "Button"), " stories located at\xA0", /*#__PURE__*/React.createElement(InlineCode, null, "src/stories/1-Button.stories.js"), ".)"), /*#__PURE__*/React.createElement("p", null, "Usually we create stories with smaller UI components in the app.", /*#__PURE__*/React.createElement("br", null), "Have a look at the\xA0", /*#__PURE__*/React.createElement(Link, {
104
- href: "https://storybook.js.org/basics/writing-stories",
105
- target: "_blank",
106
- rel: "noopener noreferrer"
107
- }, "Writing Stories"), "\xA0section in our documentation."), /*#__PURE__*/React.createElement(Note, null, /*#__PURE__*/React.createElement("b", null, "NOTE:"), /*#__PURE__*/React.createElement("br", null), "Have a look at the ", /*#__PURE__*/React.createElement(InlineCode, null, ".storybook/webpack.config.js"), " to add webpack loaders and plugins you are using in this project."));
108
- };
109
-
110
- Welcome.displayName = 'Welcome';
111
- export { Welcome as default };
@@ -1,3 +0,0 @@
1
- import { buildStatic } from '@storybook/core/server';
2
- import options from './options';
3
- buildStatic(options);
@@ -1,49 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- import semver from '@storybook/semver';
4
- import { logger } from '@storybook/node-logger';
5
- var appDirectory = fs.realpathSync(process.cwd());
6
- var reactScriptsPath;
7
- export function getReactScriptsPath({
8
- noCache: noCache
9
- } = {}) {
10
- if (reactScriptsPath && !noCache) return reactScriptsPath;
11
- var reactScriptsScriptPath = fs.realpathSync(path.join(appDirectory, '/node_modules/.bin/react-scripts'));
12
-
13
- try {
14
- // Note: Since there is no symlink for .bin/react-scripts on Windows
15
- // we'll parse react-scripts file to find actual package path.
16
- // This is important if you use fork of CRA.
17
- var pathIsNotResolved = /node_modules[\\/]\.bin[\\/]react-scripts/i.test(reactScriptsScriptPath);
18
-
19
- if (pathIsNotResolved) {
20
- var content = fs.readFileSync(reactScriptsScriptPath, 'utf8');
21
- var packagePathMatch = content.match(/"\$basedir[\\/]([^\s]+?[\\/]bin[\\/]react-scripts\.js")/i);
22
-
23
- if (packagePathMatch && packagePathMatch.length > 1) {
24
- reactScriptsScriptPath = path.join(appDirectory, '/node_modules/.bin/', packagePathMatch[1]);
25
- }
26
- }
27
- } catch (e) {
28
- logger.warn(`Error occurred during react-scripts package path resolving: ${e}`);
29
- }
30
-
31
- reactScriptsPath = path.join(reactScriptsScriptPath, '../..');
32
- var scriptsPkgJson = path.join(reactScriptsPath, 'package.json');
33
-
34
- if (!fs.existsSync(scriptsPkgJson)) {
35
- reactScriptsPath = 'react-scripts';
36
- }
37
-
38
- return reactScriptsPath;
39
- }
40
- export function isReactScriptsInstalled(requiredVersion = '2.0.0') {
41
- try {
42
- // eslint-disable-next-line import/no-dynamic-require,global-require
43
- var reactScriptsJson = require(path.join(getReactScriptsPath(), 'package.json'));
44
-
45
- return !semver.gtr(requiredVersion, reactScriptsJson.version);
46
- } catch (e) {
47
- return false;
48
- }
49
- }
@@ -1,25 +0,0 @@
1
- import { logger } from '@storybook/node-logger';
2
- import { isReactScriptsInstalled } from './cra-config';
3
-
4
- var checkForNewPreset = function (presetsList) {
5
- var hasNewPreset = presetsList.some(function (preset) {
6
- var presetName = typeof preset === 'string' ? preset : preset.name;
7
- return /@storybook(\/|\\)preset-create-react-app/.test(presetName);
8
- });
9
-
10
- if (!hasNewPreset) {
11
- logger.warn('Storybook support for Create React App is now a separate preset.');
12
- logger.warn('To use the new preset, install `@storybook/preset-create-react-app` and add it to the list of `addons` in your `.storybook/main.js` config file.');
13
- logger.warn('The built-in preset has been disabled in Storybook 6.0.');
14
- }
15
- };
16
-
17
- export function webpackFinal(config, {
18
- presetsList: presetsList
19
- }) {
20
- if (isReactScriptsInstalled()) {
21
- checkForNewPreset(presetsList);
22
- }
23
-
24
- return config;
25
- }
@@ -1,45 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- import "core-js/modules/es.promise.js";
8
- import ReactDocgenTypescriptPlugin from '@storybook/react-docgen-typescript-plugin';
9
- export async function babel(config, {
10
- presets: presets
11
- }) {
12
- var typescriptOptions = await presets.apply('typescript', {});
13
- var reactDocgen = typescriptOptions.reactDocgen;
14
-
15
- if (typeof reactDocgen !== 'string') {
16
- return config;
17
- }
18
-
19
- return _objectSpread(_objectSpread({}, config), {}, {
20
- overrides: [{
21
- test: reactDocgen === 'react-docgen' ? /\.(mjs|tsx?|jsx?)$/ : /\.(mjs|jsx?)$/,
22
- plugins: [[require.resolve('babel-plugin-react-docgen'), {
23
- DOC_GEN_COLLECTION_NAME: 'STORYBOOK_REACT_CLASSES'
24
- }]]
25
- }]
26
- });
27
- }
28
- export async function webpackFinal(config, {
29
- presets: presets
30
- }) {
31
- var typescriptOptions = await presets.apply('typescript', {});
32
- var reactDocgen = typescriptOptions.reactDocgen,
33
- reactDocgenTypescriptOptions = typescriptOptions.reactDocgenTypescriptOptions;
34
-
35
- if (reactDocgen !== 'react-docgen-typescript') {
36
- return config;
37
- }
38
-
39
- return _objectSpread(_objectSpread({}, config), {}, {
40
- plugins: [...config.plugins, new ReactDocgenTypescriptPlugin(_objectSpread(_objectSpread({}, reactDocgenTypescriptOptions), {}, {
41
- // We *need* this set so that RDT returns default values in the same format as react-docgen
42
- savePropValueAsString: true
43
- }))]
44
- });
45
- }
@@ -1,78 +0,0 @@
1
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
2
-
3
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4
-
5
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
-
7
- import "core-js/modules/es.promise.js";
8
- import path from 'path';
9
- import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
10
- import { logger } from '@storybook/node-logger';
11
- export async function babel(config, options) {
12
- var isDevelopment = options.configType === 'DEVELOPMENT';
13
- var reactOptions = await options.presets.apply('reactOptions', {}, options);
14
- var fastRefreshEnabled = isDevelopment && (reactOptions.fastRefresh || process.env.FAST_REFRESH === 'true');
15
-
16
- if (!fastRefreshEnabled) {
17
- return config;
18
- }
19
-
20
- return _objectSpread(_objectSpread({}, config), {}, {
21
- plugins: [[require.resolve('react-refresh/babel'), {}, 'storybook-react-refresh'], ...(config.plugins || [])]
22
- });
23
- }
24
- var storybookReactDirName = path.dirname(require.resolve('@storybook/react/package.json')); // TODO: improve node_modules detection
25
-
26
- var context = storybookReactDirName.includes('node_modules') ? path.join(storybookReactDirName, '../../') // Real life case, already in node_modules
27
- : path.join(storybookReactDirName, '../../node_modules'); // SB Monorepo
28
-
29
- var hasJsxRuntime = function () {
30
- try {
31
- require.resolve('react/jsx-runtime', {
32
- paths: [context]
33
- });
34
-
35
- return true;
36
- } catch (e) {
37
- return false;
38
- }
39
- };
40
-
41
- export async function babelDefault(config) {
42
- var presetReactOptions = hasJsxRuntime() ? {
43
- runtime: 'automatic'
44
- } : {};
45
- return _objectSpread(_objectSpread({}, config), {}, {
46
- presets: [...((config === null || config === void 0 ? void 0 : config.presets) || []), [require.resolve('@babel/preset-react'), presetReactOptions], require.resolve('@babel/preset-flow')],
47
- plugins: [...((config === null || config === void 0 ? void 0 : config.plugins) || []), require.resolve('babel-plugin-add-react-displayname')]
48
- });
49
- }
50
- export async function webpackFinal(config, options) {
51
- var isDevelopment = options.configType === 'DEVELOPMENT';
52
- var reactOptions = await options.presets.apply('reactOptions', {}, options);
53
- var fastRefreshEnabled = isDevelopment && (reactOptions.fastRefresh || process.env.FAST_REFRESH === 'true');
54
-
55
- if (!fastRefreshEnabled) {
56
- return config;
57
- } // matches the name of the plugin in CRA.
58
-
59
-
60
- var hasReactRefresh = config.plugins.find(function (p) {
61
- return p.constructor.name === 'ReactRefreshPlugin';
62
- });
63
-
64
- if (hasReactRefresh) {
65
- logger.warn("=> React refresh is already set. You don't need to set the option");
66
- return config;
67
- }
68
-
69
- logger.info('=> Using React fast refresh');
70
- return _objectSpread(_objectSpread({}, config), {}, {
71
- plugins: [...config.plugins, // Storybook uses webpack-hot-middleware https://github.com/storybookjs/storybook/issues/14114
72
- new ReactRefreshWebpackPlugin({
73
- overlay: {
74
- sockIntegration: 'whm'
75
- }
76
- })]
77
- });
78
- }
@@ -1,3 +0,0 @@
1
- import { buildDev } from '@storybook/core/server';
2
- import options from './options';
3
- buildDev(options);
@@ -1,8 +0,0 @@
1
- import { sync } from 'read-pkg-up';
2
- export default {
3
- packageJson: sync({
4
- cwd: __dirname
5
- }).packageJson,
6
- framework: 'react',
7
- frameworkPresets: [require.resolve('./preset')]
8
- };
@@ -1,5 +0,0 @@
1
- import { findDistEsm } from '@storybook/core-common';
2
- export var config = function (entries = []) {
3
- return [...entries, findDistEsm(__dirname, 'client/preview/config')];
4
- };
5
- export var addons = [require.resolve('./framework-preset-react'), require.resolve('./framework-preset-cra'), require.resolve('./framework-preset-react-docgen')];
File without changes
@@ -1,6 +0,0 @@
1
- export { storiesOf, setAddon, addDecorator, addParameters, configure, getStorybook, raw, forceReRender } from './preview';
2
- export * from './preview/types-6-3';
3
-
4
- if (module && module.hot && module.hot.decline) {
5
- module.hot.decline();
6
- }
@@ -1,4 +0,0 @@
1
- export { render, renderToDOM } from './render';
2
- export const parameters = {
3
- framework: 'react'
4
- };
@@ -1,8 +0,0 @@
1
- import global from 'global';
2
- const {
3
- window: globalWindow
4
- } = global;
5
-
6
- if (globalWindow) {
7
- globalWindow.STORYBOOK_ENV = 'react';
8
- }
@@ -1,21 +0,0 @@
1
- /* eslint-disable prefer-destructuring */
2
- import { start } from '@storybook/core/client';
3
- import './globals';
4
- import { renderToDOM, render } from './render';
5
- const framework = 'react';
6
- const api = start(renderToDOM, {
7
- render
8
- });
9
- export const storiesOf = (kind, m) => {
10
- return api.clientApi.storiesOf(kind, m).addParameters({
11
- framework
12
- });
13
- };
14
- export const configure = (...args) => api.configure(framework, ...args);
15
- export const addDecorator = api.clientApi.addDecorator;
16
- export const addParameters = api.clientApi.addParameters;
17
- export const clearDecorators = api.clientApi.clearDecorators;
18
- export const setAddon = api.clientApi.setAddon;
19
- export const forceReRender = api.forceReRender;
20
- export const getStorybook = api.clientApi.getStorybook;
21
- export const raw = api.clientApi.raw;
@@ -1,94 +0,0 @@
1
- import global from 'global';
2
- import React, { Component as ReactComponent, StrictMode, Fragment } from 'react';
3
- import ReactDOM from 'react-dom';
4
- const {
5
- FRAMEWORK_OPTIONS
6
- } = global;
7
- export const render = (args, {
8
- id,
9
- component: Component
10
- }) => {
11
- if (!Component) {
12
- throw new Error(`Unable to render story ${id} as the component annotation is missing from the default export`);
13
- }
14
-
15
- return /*#__PURE__*/React.createElement(Component, args);
16
- };
17
-
18
- const renderElement = async (node, el) => new Promise(resolve => {
19
- ReactDOM.render(node, el, () => resolve(null));
20
- });
21
-
22
- class ErrorBoundary extends ReactComponent {
23
- constructor(...args) {
24
- super(...args);
25
- this.state = {
26
- hasError: false
27
- };
28
- }
29
-
30
- static getDerivedStateFromError() {
31
- return {
32
- hasError: true
33
- };
34
- }
35
-
36
- componentDidMount() {
37
- const {
38
- hasError
39
- } = this.state;
40
- const {
41
- showMain
42
- } = this.props;
43
-
44
- if (!hasError) {
45
- showMain();
46
- }
47
- }
48
-
49
- componentDidCatch(err) {
50
- const {
51
- showException
52
- } = this.props; // message partially duplicates stack, strip it
53
-
54
- showException(err);
55
- }
56
-
57
- render() {
58
- const {
59
- hasError
60
- } = this.state;
61
- const {
62
- children
63
- } = this.props;
64
- return hasError ? null : children;
65
- }
66
-
67
- }
68
-
69
- const Wrapper = FRAMEWORK_OPTIONS !== null && FRAMEWORK_OPTIONS !== void 0 && FRAMEWORK_OPTIONS.strictMode ? StrictMode : Fragment;
70
- export async function renderToDOM({
71
- storyContext,
72
- unboundStoryFn,
73
- showMain,
74
- showException,
75
- forceRemount
76
- }, domElement) {
77
- const Story = unboundStoryFn;
78
- const content = /*#__PURE__*/React.createElement(ErrorBoundary, {
79
- showMain: showMain,
80
- showException: showException
81
- }, /*#__PURE__*/React.createElement(Story, storyContext)); // For React 15, StrictMode & Fragment doesn't exists.
82
-
83
- const element = Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, content) : content; // In most cases, we need to unmount the existing set of components in the DOM node.
84
- // Otherwise, React may not recreate instances for every story run.
85
- // This could leads to issues like below:
86
- // https://github.com/storybookjs/react-storybook/issues/81
87
- // (This is not the case when we change args or globals to the story however)
88
-
89
- if (forceRemount) {
90
- ReactDOM.unmountComponentAtNode(domElement);
91
- }
92
-
93
- await renderElement(element, domElement);
94
- }
File without changes
@@ -1,8 +0,0 @@
1
- export * from './types-6-0';
2
- /**
3
- * For the common case where a component's stories are simple components that receives args as props:
4
- *
5
- * ```tsx
6
- * export default { ... } as ComponentMeta<typeof Button>;
7
- * ```
8
- */
File without changes
File without changes
@@ -1,25 +0,0 @@
1
- import React from 'react';
2
- const styles = {
3
- border: '1px solid #eee',
4
- borderRadius: 3,
5
- backgroundColor: '#FFFFFF',
6
- cursor: 'pointer',
7
- fontSize: 15,
8
- padding: '3px 10px',
9
- margin: 10
10
- };
11
-
12
- const Button = ({
13
- children,
14
- onClick
15
- }) => /*#__PURE__*/React.createElement("button", {
16
- onClick: onClick,
17
- style: styles,
18
- type: "button"
19
- }, children);
20
-
21
- Button.displayName = 'Button';
22
- Button.defaultProps = {
23
- onClick: () => {}
24
- };
25
- export default Button;
@@ -1,104 +0,0 @@
1
- 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; }
2
-
3
- function _extends() { _extends = Object.assign || 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); }
4
-
5
- import React from 'react';
6
-
7
- const Main = props => /*#__PURE__*/React.createElement("article", _extends({}, props, {
8
- style: {
9
- padding: 15,
10
- lineHeight: 1.4,
11
- fontFamily: '"Helvetica Neue", Helvetica, "Segoe UI", Arial, freesans, sans-serif',
12
- backgroundColor: '#fff',
13
- color: '#000'
14
- }
15
- }));
16
-
17
- const Title = (_ref) => {
18
- let {
19
- children
20
- } = _ref,
21
- props = _objectWithoutPropertiesLoose(_ref, ["children"]);
22
-
23
- return /*#__PURE__*/React.createElement("h1", props, children);
24
- };
25
-
26
- const Note = props => /*#__PURE__*/React.createElement("p", _extends({}, props, {
27
- style: {
28
- opacity: 0.5
29
- }
30
- }));
31
-
32
- const InlineCode = props => /*#__PURE__*/React.createElement("code", _extends({}, props, {
33
- style: {
34
- fontSize: 15,
35
- fontWeight: 600,
36
- padding: '2px 5px',
37
- border: '1px solid #eae9e9',
38
- borderRadius: 4,
39
- backgroundColor: '#f3f2f2',
40
- color: '#3a3a3a'
41
- }
42
- }));
43
-
44
- const Link = (_ref2) => {
45
- let {
46
- children,
47
- href,
48
- target,
49
- rel
50
- } = _ref2,
51
- props = _objectWithoutPropertiesLoose(_ref2, ["children", "href", "target", "rel"]);
52
-
53
- return /*#__PURE__*/React.createElement("a", _extends({
54
- href: href
55
- }, props, {
56
- target: target,
57
- rel: rel,
58
- style: {
59
- color: '#1474f3',
60
- textDecoration: 'none',
61
- borderBottom: '1px solid #1474f3',
62
- paddingBottom: 2
63
- }
64
- }), children);
65
- };
66
-
67
- const NavButton = (_ref3) => {
68
- let {
69
- children,
70
- onClick
71
- } = _ref3,
72
- props = _objectWithoutPropertiesLoose(_ref3, ["children", "onClick"]);
73
-
74
- return /*#__PURE__*/React.createElement("button", _extends({}, props, {
75
- type: "button",
76
- onClick: onClick,
77
- style: {
78
- color: '#1474f3',
79
- textDecoration: 'none',
80
- borderBottom: '1px solid #1474f3',
81
- paddingBottom: 2,
82
- borderTop: 'none',
83
- borderRight: 'none',
84
- borderLeft: 'none',
85
- backgroundColor: 'transparent',
86
- padding: 0,
87
- cursor: 'pointer',
88
- font: 'inherit'
89
- }
90
- }), children);
91
- };
92
-
93
- const Welcome = ({
94
- showApp
95
- }) => /*#__PURE__*/React.createElement(Main, null, /*#__PURE__*/React.createElement(Title, null, "Welcome to storybook"), /*#__PURE__*/React.createElement("p", null, "This is a UI component dev environment for your app."), /*#__PURE__*/React.createElement("p", null, "We've added some basic stories inside the ", /*#__PURE__*/React.createElement(InlineCode, null, "src/stories"), " directory.", /*#__PURE__*/React.createElement("br", null), "A story is a single state of one or more UI components. You can have as many stories as you want.", /*#__PURE__*/React.createElement("br", null), "(Basically a story is like a visual test case.)"), /*#__PURE__*/React.createElement("p", null, "See these sample ", /*#__PURE__*/React.createElement(NavButton, {
96
- onClick: showApp
97
- }, "stories"), " for a component called\xA0", /*#__PURE__*/React.createElement(InlineCode, null, "Button"), "."), /*#__PURE__*/React.createElement("p", null, "Just like that, you can add your own components as stories.", /*#__PURE__*/React.createElement("br", null), "You can also edit those components and see changes right away.", /*#__PURE__*/React.createElement("br", null), "(Try editing the ", /*#__PURE__*/React.createElement(InlineCode, null, "Button"), " stories located at\xA0", /*#__PURE__*/React.createElement(InlineCode, null, "src/stories/1-Button.stories.js"), ".)"), /*#__PURE__*/React.createElement("p", null, "Usually we create stories with smaller UI components in the app.", /*#__PURE__*/React.createElement("br", null), "Have a look at the\xA0", /*#__PURE__*/React.createElement(Link, {
98
- href: "https://storybook.js.org/basics/writing-stories",
99
- target: "_blank",
100
- rel: "noopener noreferrer"
101
- }, "Writing Stories"), "\xA0section in our documentation."), /*#__PURE__*/React.createElement(Note, null, /*#__PURE__*/React.createElement("b", null, "NOTE:"), /*#__PURE__*/React.createElement("br", null), "Have a look at the ", /*#__PURE__*/React.createElement(InlineCode, null, ".storybook/webpack.config.js"), " to add webpack loaders and plugins you are using in this project."));
102
-
103
- Welcome.displayName = 'Welcome';
104
- export { Welcome as default };
@@ -1,3 +0,0 @@
1
- import { buildStatic } from '@storybook/core/server';
2
- import options from './options';
3
- buildStatic(options);