1 | 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); }
|
2 |
|
3 | import "core-js/modules/es.string.replace.js";
|
4 | import "core-js/modules/es.regexp.exec.js";
|
5 | import "core-js/modules/es.array.join.js";
|
6 | import "core-js/modules/es.string.split.js";
|
7 | import "core-js/modules/es.function.name.js";
|
8 | import "core-js/modules/es.array.concat.js";
|
9 | import "core-js/modules/es.object.assign.js";
|
10 | import global from 'global';
|
11 | import React from 'react';
|
12 | import { Consumer, isRoot, isGroup, isStory } from '@storybook/api';
|
13 | import { Preview } from '../components/preview/preview';
|
14 | var PREVIEW_URL = global.PREVIEW_URL;
|
15 |
|
16 | var splitTitleAddExtraSpace = function splitTitleAddExtraSpace(input) {
|
17 | return input.split('/').join(' / ').replace(/\s\s/, ' ');
|
18 | };
|
19 |
|
20 | var getDescription = function getDescription(item) {
|
21 | if (isRoot(item)) {
|
22 | return item.name ? "".concat(item.name, " \u22C5 Storybook") : 'Storybook';
|
23 | }
|
24 |
|
25 | if (isGroup(item)) {
|
26 | return item.name ? "".concat(item.name, " \u22C5 Storybook") : 'Storybook';
|
27 | }
|
28 |
|
29 | if (isStory(item)) {
|
30 | var kind = item.kind,
|
31 | name = item.name;
|
32 | return kind && name ? splitTitleAddExtraSpace("".concat(kind, " - ").concat(name, " \u22C5 Storybook")) : 'Storybook';
|
33 | }
|
34 |
|
35 | return 'Storybook';
|
36 | };
|
37 |
|
38 | var mapper = function mapper(_ref) {
|
39 | var api = _ref.api,
|
40 | state = _ref.state;
|
41 | var layout = state.layout,
|
42 | location = state.location,
|
43 | customQueryParams = state.customQueryParams,
|
44 | storyId = state.storyId,
|
45 | refs = state.refs,
|
46 | viewMode = state.viewMode,
|
47 | path = state.path,
|
48 | refId = state.refId;
|
49 | var story = api.getData(storyId, refId);
|
50 | var docsOnly = story && story.parameters ? !!story.parameters.docsOnly : false;
|
51 | return {
|
52 | api: api,
|
53 | story: story,
|
54 | options: layout,
|
55 | description: getDescription(story),
|
56 | viewMode: viewMode,
|
57 | path: path,
|
58 | refs: refs,
|
59 | storyId: storyId,
|
60 | baseUrl: PREVIEW_URL || 'iframe.html',
|
61 | queryParams: customQueryParams,
|
62 | docsOnly: docsOnly,
|
63 | location: location
|
64 | };
|
65 | };
|
66 |
|
67 | var PreviewConnected = React.memo(function (props) {
|
68 | return React.createElement(Consumer, {
|
69 | filter: mapper
|
70 | }, function (fromState) {
|
71 | return React.createElement(Preview, _extends({}, props, fromState));
|
72 | });
|
73 | });
|
74 | export default PreviewConnected; |
\ | No newline at end of file |