@storybook/components 6.5.0-alpha.2 → 6.5.0-alpha.20

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.
@@ -29,6 +29,8 @@ exports.StorySkeleton = exports.Story = exports.StoryError = void 0;
29
29
 
30
30
  require("core-js/modules/es.array.concat.js");
31
31
 
32
+ var _global = _interopRequireDefault(require("global"));
33
+
32
34
  var _react = _interopRequireWildcard(require("react"));
33
35
 
34
36
  var _IFrame = require("./IFrame");
@@ -39,15 +41,20 @@ var _ZoomContext = require("./ZoomContext");
39
41
 
40
42
  var _ = require("..");
41
43
 
44
+ var _getStoryHref = require("../utils/getStoryHref");
45
+
42
46
  function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
43
47
 
44
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; }
45
49
 
50
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
+
46
52
  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; }
47
53
 
48
54
  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; }
49
55
 
50
- var BASE_URL = 'iframe.html';
56
+ var PREVIEW_URL = _global.default.PREVIEW_URL;
57
+ var BASE_URL = PREVIEW_URL || 'iframe.html';
51
58
  var StoryError;
52
59
  /** error message for Story with null storyFn
53
60
  * if the story id exists, it must be pointing to a non-existing story
@@ -89,7 +96,9 @@ var IFrameStory = function IFrameStory(_ref2) {
89
96
  key: "iframe",
90
97
  id: "iframe--".concat(id),
91
98
  title: title,
92
- src: "".concat(BASE_URL, "?id=").concat(id, "&viewMode=story"),
99
+ src: (0, _getStoryHref.getStoryHref)(BASE_URL, id, {
100
+ viewMode: 'story'
101
+ }),
93
102
  allowFullScreen: true,
94
103
  scale: scale,
95
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, {
@@ -121,6 +121,13 @@ var NumberControl = function NumberControl(_ref) {
121
121
  (0, _react.useEffect)(function () {
122
122
  if (forceVisible && htmlElRef.current) htmlElRef.current.select();
123
123
  }, [forceVisible]);
124
+ (0, _react.useEffect)(function () {
125
+ var newInputValue = typeof value === 'number' ? value : '';
126
+
127
+ if (inputValue !== newInputValue) {
128
+ setInputValue(value);
129
+ }
130
+ }, [value]);
124
131
 
125
132
  if (!forceVisible && value === undefined) {
126
133
  return /*#__PURE__*/_react.default.createElement(_form.Form.Button, {
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;
@@ -5,12 +5,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
5
5
  import "core-js/modules/es.array.concat.js";
6
6
  import "core-js/modules/es.object.keys.js";
7
7
  import "core-js/modules/es.symbol.js";
8
+ import global from 'global';
8
9
  import React, { createElement, Fragment } from 'react';
9
10
  import { IFrame } from './IFrame';
10
11
  import { EmptyBlock } from './EmptyBlock';
11
12
  import { ZoomContext } from './ZoomContext';
12
13
  import { Loader } from '..';
13
- var BASE_URL = 'iframe.html';
14
+ import { getStoryHref } from '../utils/getStoryHref';
15
+ var PREVIEW_URL = global.PREVIEW_URL;
16
+ var BASE_URL = PREVIEW_URL || 'iframe.html';
14
17
  export var StoryError;
15
18
  /** error message for Story with null storyFn
16
19
  * if the story id exists, it must be pointing to a non-existing story
@@ -50,7 +53,9 @@ var IFrameStory = function IFrameStory(_ref2) {
50
53
  key: "iframe",
51
54
  id: "iframe--".concat(id),
52
55
  title: title,
53
- src: "".concat(BASE_URL, "?id=").concat(id, "&viewMode=story"),
56
+ src: getStoryHref(BASE_URL, id, {
57
+ viewMode: 'story'
58
+ }),
54
59
  allowFullScreen: true,
55
60
  scale: scale,
56
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, {
@@ -81,6 +81,13 @@ export var NumberControl = function NumberControl(_ref) {
81
81
  useEffect(function () {
82
82
  if (forceVisible && htmlElRef.current) htmlElRef.current.select();
83
83
  }, [forceVisible]);
84
+ useEffect(function () {
85
+ var newInputValue = typeof value === 'number' ? value : '';
86
+
87
+ if (inputValue !== newInputValue) {
88
+ setInputValue(value);
89
+ }
90
+ }, [value]);
84
91
 
85
92
  if (!forceVisible && value === undefined) {
86
93
  return /*#__PURE__*/React.createElement(Form.Button, {
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
+ };
@@ -1,11 +1,16 @@
1
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
2
 
3
+ import global from 'global';
3
4
  import React, { createElement, Fragment } from 'react';
4
5
  import { IFrame } from './IFrame';
5
6
  import { EmptyBlock } from './EmptyBlock';
6
7
  import { ZoomContext } from './ZoomContext';
7
8
  import { Loader } from '..';
8
- const BASE_URL = 'iframe.html';
9
+ import { getStoryHref } from '../utils/getStoryHref';
10
+ const {
11
+ PREVIEW_URL
12
+ } = global;
13
+ const BASE_URL = PREVIEW_URL || 'iframe.html';
9
14
  export let StoryError;
10
15
  /** error message for Story with null storyFn
11
16
  * if the story id exists, it must be pointing to a non-existing story
@@ -42,7 +47,9 @@ const IFrameStory = ({
42
47
  key: "iframe",
43
48
  id: `iframe--${id}`,
44
49
  title: title,
45
- src: `${BASE_URL}?id=${id}&viewMode=story`,
50
+ src: getStoryHref(BASE_URL, id, {
51
+ viewMode: 'story'
52
+ }),
46
53
  allowFullScreen: true,
47
54
  scale: scale,
48
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, {
@@ -43,6 +43,13 @@ export const NumberControl = ({
43
43
  useEffect(() => {
44
44
  if (forceVisible && htmlElRef.current) htmlElRef.current.select();
45
45
  }, [forceVisible]);
46
+ useEffect(() => {
47
+ const newInputValue = typeof value === 'number' ? value : '';
48
+
49
+ if (inputValue !== newInputValue) {
50
+ setInputValue(value);
51
+ }
52
+ }, [value]);
46
53
 
47
54
  if (!forceVisible && value === undefined) {
48
55
  return /*#__PURE__*/React.createElement(Form.Button, {
@@ -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.2",
3
+ "version": "6.5.0-alpha.20",
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.2",
44
+ "@storybook/client-logger": "6.5.0-alpha.20",
45
45
  "@storybook/csf": "0.0.2--canary.87bc651.0",
46
- "@storybook/theming": "6.5.0-alpha.2",
46
+ "@storybook/theming": "6.5.0-alpha.20",
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,9 +57,10 @@
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
- "react-syntax-highlighter": "^13.5.3",
63
+ "react-syntax-highlighter": "^15.4.5",
63
64
  "react-textarea-autosize": "^8.3.0",
64
65
  "regenerator-runtime": "^0.13.7",
65
66
  "ts-dedent": "^2.0.0",
@@ -76,6 +77,6 @@
76
77
  "publishConfig": {
77
78
  "access": "public"
78
79
  },
79
- "gitHead": "ca9d89393f36d156e34819fe120eb7e6819245f4",
80
+ "gitHead": "8b9f966f4378d540c767bdbeb1840f910ebc3375",
80
81
  "sbmodern": "dist/modern/index.js"
81
82
  }