1 | import "core-js/modules/es.array.concat.js";
|
2 | import "core-js/modules/es.array.index-of.js";
|
3 | import "core-js/modules/es.object.keys.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 | import React, { createElement, Fragment } from 'react';
|
10 | import { IFrame } from './IFrame';
|
11 | import { EmptyBlock } from './EmptyBlock';
|
12 | import { ZoomContext } from './ZoomContext';
|
13 | var BASE_URL = 'iframe.html';
|
14 | export var StoryError;
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | (function (StoryError) {
|
21 | StoryError["NO_STORY"] = "No component or story to display";
|
22 | })(StoryError || (StoryError = {}));
|
23 |
|
24 | var MISSING_STORY = function MISSING_STORY(id) {
|
25 | return id ? "Story \"".concat(id, "\" doesn't exist.") : StoryError.NO_STORY;
|
26 | };
|
27 |
|
28 | var InlineStory = function InlineStory(_ref) {
|
29 | var storyFn = _ref.storyFn,
|
30 | height = _ref.height,
|
31 | id = _ref.id;
|
32 | return React.createElement(Fragment, null, height ? React.createElement("style", null, "#story--".concat(id, " { min-height: ").concat(height, "; transform: translateZ(0); overflow: auto }")) : null, React.createElement(Fragment, null, storyFn ? createElement(storyFn) : React.createElement(EmptyBlock, null, MISSING_STORY(id))));
|
33 | };
|
34 |
|
35 | InlineStory.displayName = "InlineStory";
|
36 |
|
37 | var IFrameStory = function IFrameStory(_ref2) {
|
38 | var id = _ref2.id,
|
39 | title = _ref2.title,
|
40 | _ref2$height = _ref2.height,
|
41 | height = _ref2$height === void 0 ? '500px' : _ref2$height;
|
42 | return React.createElement("div", {
|
43 | style: {
|
44 | width: '100%',
|
45 | height: height
|
46 | }
|
47 | }, React.createElement(ZoomContext.Consumer, null, function (_ref3) {
|
48 | var scale = _ref3.scale;
|
49 | return React.createElement(IFrame, {
|
50 | key: "iframe",
|
51 | id: "iframe--".concat(id),
|
52 | title: title,
|
53 | src: "".concat(BASE_URL, "?id=").concat(id, "&viewMode=story"),
|
54 | allowFullScreen: true,
|
55 | scale: scale,
|
56 | style: {
|
57 | width: '100%',
|
58 | height: '100%',
|
59 | border: '0 none'
|
60 | }
|
61 | });
|
62 | }));
|
63 | };
|
64 |
|
65 | IFrameStory.displayName = "IFrameStory";
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 | var Story = function Story(_ref4) {
|
72 | var children = _ref4.children,
|
73 | error = _ref4.error,
|
74 | inline = _ref4.inline,
|
75 | props = _objectWithoutProperties(_ref4, ["children", "error", "inline"]);
|
76 |
|
77 | var id = props.id,
|
78 | title = props.title,
|
79 | height = props.height;
|
80 |
|
81 | if (error) {
|
82 | return React.createElement(EmptyBlock, null, error);
|
83 | }
|
84 |
|
85 | return inline ? React.createElement(InlineStory, props) : React.createElement(IFrameStory, {
|
86 | id: id,
|
87 | title: title,
|
88 | height: height
|
89 | });
|
90 | };
|
91 |
|
92 | export { Story }; |
\ | No newline at end of file |