@storybook/components 6.5.0-alpha.12 → 6.5.0-alpha.16

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.
@@ -41,6 +41,8 @@ var _ZoomContext = require("./ZoomContext");
41
41
 
42
42
  var _ = require("..");
43
43
 
44
+ var _getStoryHref = require("../utils/getStoryHref");
45
+
44
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
45
47
 
46
48
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
@@ -94,7 +96,9 @@ var IFrameStory = function IFrameStory(_ref2) {
94
96
  key: "iframe",
95
97
  id: "iframe--".concat(id),
96
98
  title: title,
97
- src: "".concat(BASE_URL, "?id=").concat(id, "&viewMode=story"),
99
+ src: (0, _getStoryHref.getStoryHref)(BASE_URL, id, {
100
+ viewMode: 'story'
101
+ }),
98
102
  allowFullScreen: true,
99
103
  scale: scale,
100
104
  style: {
@@ -2,8 +2,6 @@
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
4
 
5
- require("core-js/modules/es.object.keys.js");
6
-
7
5
  require("core-js/modules/es.symbol.js");
8
6
 
9
7
  require("core-js/modules/es.weak-map.js");
@@ -27,10 +25,10 @@ Object.defineProperty(exports, "__esModule", {
27
25
  });
28
26
  exports.Toolbar = void 0;
29
27
 
30
- require("core-js/modules/es.array.concat.js");
31
-
32
28
  require("core-js/modules/es.array.map.js");
33
29
 
30
+ require("core-js/modules/es.object.keys.js");
31
+
34
32
  var _react = _interopRequireWildcard(require("react"));
35
33
 
36
34
  var _theming = require("@storybook/theming");
@@ -41,6 +39,8 @@ var _icon = require("../icon/icon");
41
39
 
42
40
  var _button = require("../bar/button");
43
41
 
42
+ var _getStoryHref = require("../utils/getStoryHref");
43
+
44
44
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
45
45
 
46
46
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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; }
@@ -87,7 +87,7 @@ var Eject = function Eject(_ref2) {
87
87
  storyId = _ref2.storyId;
88
88
  return /*#__PURE__*/_react.default.createElement(_button.IconButton, {
89
89
  key: "opener",
90
- href: "".concat(baseUrl, "?id=").concat(storyId),
90
+ href: (0, _getStoryHref.getStoryHref)(baseUrl, storyId),
91
91
  target: "_blank",
92
92
  title: "Open canvas in new tab"
93
93
  }, /*#__PURE__*/_react.default.createElement(_icon.Icons, {
package/dist/cjs/index.js CHANGED
@@ -37,7 +37,8 @@ var _exportNames = {
37
37
  Symbols: true,
38
38
  StorybookLogo: true,
39
39
  StorybookIcon: true,
40
- Loader: true
40
+ Loader: true,
41
+ getStoryHref: true
41
42
  };
42
43
  Object.defineProperty(exports, "components", {
43
44
  enumerable: true,
@@ -237,6 +238,12 @@ Object.defineProperty(exports, "Loader", {
237
238
  return _Loader.Loader;
238
239
  }
239
240
  });
241
+ Object.defineProperty(exports, "getStoryHref", {
242
+ enumerable: true,
243
+ get: function get() {
244
+ return _getStoryHref.getStoryHref;
245
+ }
246
+ });
240
247
  exports.resetComponents = void 0;
241
248
 
242
249
  require("core-js/modules/web.dom-collections.for-each.js");
@@ -337,6 +344,8 @@ Object.keys(_controls).forEach(function (key) {
337
344
 
338
345
  var _Loader = require("./Loader/Loader");
339
346
 
347
+ var _getStoryHref = require("./utils/getStoryHref");
348
+
340
349
  // Typography
341
350
  // UI
342
351
  // Forms
@@ -344,6 +353,7 @@ var _Loader = require("./Loader/Loader");
344
353
  // Toolbar and subcomponents
345
354
  // Doc blocks
346
355
  // Loader
356
+ // Utils
347
357
  var resetComponents = {};
348
358
  exports.resetComponents = resetComponents;
349
359
  Object.keys(_DocumentFormatting.components).forEach(function (key) {
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.symbol.js");
4
+
5
+ require("core-js/modules/es.symbol.description.js");
6
+
7
+ require("core-js/modules/es.object.to-string.js");
8
+
9
+ require("core-js/modules/es.symbol.iterator.js");
10
+
11
+ require("core-js/modules/es.string.iterator.js");
12
+
13
+ require("core-js/modules/es.array.iterator.js");
14
+
15
+ require("core-js/modules/web.dom-collections.iterator.js");
16
+
17
+ require("core-js/modules/es.array.slice.js");
18
+
19
+ require("core-js/modules/es.function.name.js");
20
+
21
+ require("core-js/modules/es.array.from.js");
22
+
23
+ Object.defineProperty(exports, "__esModule", {
24
+ value: true
25
+ });
26
+ exports.getStoryHref = void 0;
27
+
28
+ require("core-js/modules/es.string.split.js");
29
+
30
+ require("core-js/modules/es.regexp.exec.js");
31
+
32
+ require("core-js/modules/es.object.assign.js");
33
+
34
+ require("core-js/modules/es.array.concat.js");
35
+
36
+ var _qs = _interopRequireDefault(require("qs"));
37
+
38
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
+
40
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
41
+
42
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+
44
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
45
+
46
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
47
+
48
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
49
+
50
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
51
+
52
+ var getStoryHref = function getStoryHref(baseUrl, storyId) {
53
+ var additionalParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
54
+
55
+ var _baseUrl$split = baseUrl.split('?'),
56
+ _baseUrl$split2 = _slicedToArray(_baseUrl$split, 2),
57
+ url = _baseUrl$split2[0],
58
+ paramsStr = _baseUrl$split2[1];
59
+
60
+ var params = paramsStr ? Object.assign({}, _qs.default.parse(paramsStr), additionalParams, {
61
+ id: storyId
62
+ }) : Object.assign({}, additionalParams, {
63
+ id: storyId
64
+ });
65
+ return "".concat(url).concat(_qs.default.stringify(params, {
66
+ addQueryPrefix: true,
67
+ encode: false
68
+ }));
69
+ };
70
+
71
+ exports.getStoryHref = getStoryHref;
@@ -11,6 +11,7 @@ import { IFrame } from './IFrame';
11
11
  import { EmptyBlock } from './EmptyBlock';
12
12
  import { ZoomContext } from './ZoomContext';
13
13
  import { Loader } from '..';
14
+ import { getStoryHref } from '../utils/getStoryHref';
14
15
  var PREVIEW_URL = global.PREVIEW_URL;
15
16
  var BASE_URL = PREVIEW_URL || 'iframe.html';
16
17
  export var StoryError;
@@ -52,7 +53,9 @@ var IFrameStory = function IFrameStory(_ref2) {
52
53
  key: "iframe",
53
54
  id: "iframe--".concat(id),
54
55
  title: title,
55
- src: "".concat(BASE_URL, "?id=").concat(id, "&viewMode=story"),
56
+ src: getStoryHref(BASE_URL, id, {
57
+ viewMode: 'story'
58
+ }),
56
59
  allowFullScreen: true,
57
60
  scale: scale,
58
61
  style: {
@@ -1,16 +1,17 @@
1
+ import "core-js/modules/es.array.map.js";
2
+ import "core-js/modules/es.object.keys.js";
3
+ import "core-js/modules/es.symbol.js";
4
+
1
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; }
2
6
 
3
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; }
4
8
 
5
- import "core-js/modules/es.array.concat.js";
6
- import "core-js/modules/es.array.map.js";
7
- import "core-js/modules/es.object.keys.js";
8
- import "core-js/modules/es.symbol.js";
9
9
  import React, { Fragment } from 'react';
10
10
  import { styled } from '@storybook/theming';
11
11
  import { FlexBar } from '../bar/bar';
12
12
  import { Icons } from '../icon/icon';
13
13
  import { IconButton, IconButtonSkeleton } from '../bar/button';
14
+ import { getStoryHref } from '../utils/getStoryHref';
14
15
 
15
16
  var Zoom = function Zoom(_ref) {
16
17
  var zoom = _ref.zoom,
@@ -50,7 +51,7 @@ var Eject = function Eject(_ref2) {
50
51
  storyId = _ref2.storyId;
51
52
  return /*#__PURE__*/React.createElement(IconButton, {
52
53
  key: "opener",
53
- href: "".concat(baseUrl, "?id=").concat(storyId),
54
+ href: getStoryHref(baseUrl, storyId),
54
55
  target: "_blank",
55
56
  title: "Open canvas in new tab"
56
57
  }, /*#__PURE__*/React.createElement(Icons, {
package/dist/esm/index.js CHANGED
@@ -36,7 +36,9 @@ export { StorybookIcon } from './brand/StorybookIcon'; // Doc blocks
36
36
  export * from './blocks';
37
37
  export * from './controls'; // Loader
38
38
 
39
- export { Loader } from './Loader/Loader';
39
+ export { Loader } from './Loader/Loader'; // Utils
40
+
41
+ export { getStoryHref } from './utils/getStoryHref';
40
42
  export * from './typography/DocumentFormatting';
41
43
  export { rawComponents as components };
42
44
  var resetComponents = {};
@@ -0,0 +1,46 @@
1
+ import "core-js/modules/es.string.split.js";
2
+ import "core-js/modules/es.regexp.exec.js";
3
+ import "core-js/modules/es.object.assign.js";
4
+ import "core-js/modules/es.array.concat.js";
5
+ import "core-js/modules/es.symbol.js";
6
+ import "core-js/modules/es.symbol.description.js";
7
+ import "core-js/modules/es.object.to-string.js";
8
+ import "core-js/modules/es.symbol.iterator.js";
9
+ import "core-js/modules/es.string.iterator.js";
10
+ import "core-js/modules/es.array.iterator.js";
11
+ import "core-js/modules/web.dom-collections.iterator.js";
12
+ import "core-js/modules/es.array.slice.js";
13
+ import "core-js/modules/es.function.name.js";
14
+ import "core-js/modules/es.array.from.js";
15
+
16
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
+
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
+
24
+ function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
25
+
26
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
+
28
+ import qs from 'qs';
29
+ export var getStoryHref = function getStoryHref(baseUrl, storyId) {
30
+ var additionalParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
31
+
32
+ var _baseUrl$split = baseUrl.split('?'),
33
+ _baseUrl$split2 = _slicedToArray(_baseUrl$split, 2),
34
+ url = _baseUrl$split2[0],
35
+ paramsStr = _baseUrl$split2[1];
36
+
37
+ var params = paramsStr ? Object.assign({}, qs.parse(paramsStr), additionalParams, {
38
+ id: storyId
39
+ }) : Object.assign({}, additionalParams, {
40
+ id: storyId
41
+ });
42
+ return "".concat(url).concat(qs.stringify(params, {
43
+ addQueryPrefix: true,
44
+ encode: false
45
+ }));
46
+ };
@@ -6,6 +6,7 @@ import { IFrame } from './IFrame';
6
6
  import { EmptyBlock } from './EmptyBlock';
7
7
  import { ZoomContext } from './ZoomContext';
8
8
  import { Loader } from '..';
9
+ import { getStoryHref } from '../utils/getStoryHref';
9
10
  const {
10
11
  PREVIEW_URL
11
12
  } = global;
@@ -46,7 +47,9 @@ const IFrameStory = ({
46
47
  key: "iframe",
47
48
  id: `iframe--${id}`,
48
49
  title: title,
49
- src: `${BASE_URL}?id=${id}&viewMode=story`,
50
+ src: getStoryHref(BASE_URL, id, {
51
+ viewMode: 'story'
52
+ }),
50
53
  allowFullScreen: true,
51
54
  scale: scale,
52
55
  style: {
@@ -5,6 +5,7 @@ import { styled } from '@storybook/theming';
5
5
  import { FlexBar } from '../bar/bar';
6
6
  import { Icons } from '../icon/icon';
7
7
  import { IconButton, IconButtonSkeleton } from '../bar/button';
8
+ import { getStoryHref } from '../utils/getStoryHref';
8
9
 
9
10
  const Zoom = ({
10
11
  zoom,
@@ -43,7 +44,7 @@ const Eject = ({
43
44
  storyId
44
45
  }) => /*#__PURE__*/React.createElement(IconButton, {
45
46
  key: "opener",
46
- href: `${baseUrl}?id=${storyId}`,
47
+ href: getStoryHref(baseUrl, storyId),
47
48
  target: "_blank",
48
49
  title: "Open canvas in new tab"
49
50
  }, /*#__PURE__*/React.createElement(Icons, {
@@ -33,7 +33,9 @@ export { StorybookIcon } from './brand/StorybookIcon'; // Doc blocks
33
33
  export * from './blocks';
34
34
  export * from './controls'; // Loader
35
35
 
36
- export { Loader } from './Loader/Loader';
36
+ export { Loader } from './Loader/Loader'; // Utils
37
+
38
+ export { getStoryHref } from './utils/getStoryHref';
37
39
  export * from './typography/DocumentFormatting';
38
40
  export { rawComponents as components };
39
41
  const resetComponents = {};
@@ -0,0 +1,13 @@
1
+ import qs from 'qs';
2
+ export const getStoryHref = (baseUrl, storyId, additionalParams = {}) => {
3
+ const [url, paramsStr] = baseUrl.split('?');
4
+ const params = paramsStr ? Object.assign({}, qs.parse(paramsStr), additionalParams, {
5
+ id: storyId
6
+ }) : Object.assign({}, additionalParams, {
7
+ id: storyId
8
+ });
9
+ return `${url}${qs.stringify(params, {
10
+ addQueryPrefix: true,
11
+ encode: false
12
+ })}`;
13
+ };
@@ -28,6 +28,7 @@ export { StorybookIcon } from './brand/StorybookIcon';
28
28
  export * from './blocks';
29
29
  export * from './controls';
30
30
  export { Loader } from './Loader/Loader';
31
+ export { getStoryHref } from './utils/getStoryHref';
31
32
  export * from './typography/DocumentFormatting';
32
33
  export { rawComponents as components };
33
34
  declare const resetComponents: Record<string, ElementType>;
@@ -0,0 +1 @@
1
+ export declare const getStoryHref: (baseUrl: string, storyId: string, additionalParams?: Record<string, string>) => string;
@@ -28,6 +28,7 @@ export { StorybookIcon } from './brand/StorybookIcon';
28
28
  export * from './blocks';
29
29
  export * from './controls';
30
30
  export { Loader } from './Loader/Loader';
31
+ export { getStoryHref } from './utils/getStoryHref';
31
32
  export * from './typography/DocumentFormatting';
32
33
  export { rawComponents as components };
33
34
  declare const resetComponents: Record<string, ElementType>;
@@ -0,0 +1 @@
1
+ export declare const getStoryHref: (baseUrl: string, storyId: string, additionalParams?: Record<string, string>) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/components",
3
- "version": "6.5.0-alpha.12",
3
+ "version": "6.5.0-alpha.16",
4
4
  "description": "Core Storybook Components",
5
5
  "keywords": [
6
6
  "storybook"
@@ -41,9 +41,9 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@popperjs/core": "^2.6.0",
44
- "@storybook/client-logger": "6.5.0-alpha.12",
44
+ "@storybook/client-logger": "6.5.0-alpha.16",
45
45
  "@storybook/csf": "0.0.2--canary.87bc651.0",
46
- "@storybook/theming": "6.5.0-alpha.12",
46
+ "@storybook/theming": "6.5.0-alpha.16",
47
47
  "@types/color-convert": "^2.0.0",
48
48
  "@types/overlayscrollbars": "^1.12.0",
49
49
  "@types/react-syntax-highlighter": "11.0.5",
@@ -57,6 +57,7 @@
57
57
  "overlayscrollbars": "^1.13.1",
58
58
  "polished": "^4.0.5",
59
59
  "prop-types": "^15.7.2",
60
+ "qs": "^6.10.0",
60
61
  "react-colorful": "^5.1.2",
61
62
  "react-popper-tooltip": "^3.1.1",
62
63
  "react-syntax-highlighter": "^15.4.5",
@@ -76,6 +77,6 @@
76
77
  "publishConfig": {
77
78
  "access": "public"
78
79
  },
79
- "gitHead": "e1f8050f2461859cd560fc166f2dfe9d5c478a55",
80
+ "gitHead": "6d5a6d7bc603eff573a7b3ed3ce226c7d057ae72",
80
81
  "sbmodern": "dist/modern/index.js"
81
82
  }