1 | import "core-js/modules/es.array.index-of.js";
|
2 | import "core-js/modules/es.object.keys.js";
|
3 |
|
4 | 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); }
|
5 |
|
6 | 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; }
|
7 |
|
8 | 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; }
|
9 |
|
10 | import React from 'react';
|
11 | import { styled, ThemeProvider, convert, themes } from '@storybook/theming';
|
12 | import { EmptyBlock } from './EmptyBlock';
|
13 | import { SyntaxHighlighter } from '../syntaxhighlighter/lazy-syntaxhighlighter';
|
14 | var StyledSyntaxHighlighter = styled(SyntaxHighlighter)(function (_ref) {
|
15 | var theme = _ref.theme;
|
16 | return {
|
17 |
|
18 | fontSize: "".concat(theme.typography.size.s2 - 1, "px"),
|
19 | lineHeight: '19px',
|
20 | margin: '25px 0 40px',
|
21 | borderRadius: theme.appBorderRadius,
|
22 | boxShadow: theme.base === 'light' ? 'rgba(0, 0, 0, 0.10) 0 1px 3px 0' : 'rgba(0, 0, 0, 0.20) 0 2px 5px 0',
|
23 | 'pre.prismjs': {
|
24 | padding: 20,
|
25 | background: 'inherit'
|
26 | }
|
27 | };
|
28 | });
|
29 | export var SourceError;
|
30 |
|
31 | (function (SourceError) {
|
32 | SourceError["NO_STORY"] = "There\u2019s no story here.";
|
33 | SourceError["SOURCE_UNAVAILABLE"] = "Oh no! The source is not available.";
|
34 | })(SourceError || (SourceError = {}));
|
35 |
|
36 |
|
37 |
|
38 |
|
39 | var Source = function Source(props) {
|
40 | var _ref2 = props,
|
41 | error = _ref2.error;
|
42 |
|
43 | if (error) {
|
44 | return React.createElement(EmptyBlock, null, error);
|
45 | }
|
46 |
|
47 | var _ref3 = props,
|
48 | language = _ref3.language,
|
49 | code = _ref3.code,
|
50 | dark = _ref3.dark,
|
51 | format = _ref3.format,
|
52 | rest = _objectWithoutProperties(_ref3, ["language", "code", "dark", "format"]);
|
53 |
|
54 | var syntaxHighlighter = React.createElement(StyledSyntaxHighlighter, _extends({
|
55 | bordered: true,
|
56 | copyable: true,
|
57 | format: format,
|
58 | language: language,
|
59 | className: "docblock-source"
|
60 | }, rest), code);
|
61 |
|
62 | if (typeof dark === 'undefined') {
|
63 | return syntaxHighlighter;
|
64 | }
|
65 |
|
66 | var overrideTheme = dark ? themes.dark : themes.light;
|
67 | return React.createElement(ThemeProvider, {
|
68 | theme: convert(overrideTheme)
|
69 | }, syntaxHighlighter);
|
70 | };
|
71 |
|
72 | Source.displayName = "Source";
|
73 | Source.defaultProps = {
|
74 | format: false
|
75 | };
|
76 | export { Source }; |
\ | No newline at end of file |