@storybook/components 6.5.0-beta.8 → 6.5.0

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.
Files changed (25) hide show
  1. package/dist/cjs/{Color-ab37fa61.js → Color-90d9da2c.js} +2 -2
  2. package/dist/cjs/{OverlayScrollbars-6e69c99f.js → OverlayScrollbars-82979310.js} +2 -2
  3. package/dist/cjs/{WithTooltip-460d00ad.js → WithTooltip-60d59c62.js} +2 -2
  4. package/dist/cjs/{formatter-9109d2ae.js → formatter-adb74648.js} +1 -1
  5. package/dist/cjs/{index-cd84b86a.js → index-97a2a5a9.js} +23 -110
  6. package/dist/cjs/index.js +2 -2
  7. package/dist/cjs/syntaxhighlighter-bc65a250.js +211 -0
  8. package/dist/esm/{Color-a159ae15.js → Color-01c31ae2.js} +2 -2
  9. package/dist/esm/{OverlayScrollbars-a2bd4cea.js → OverlayScrollbars-9b821cbe.js} +2 -2
  10. package/dist/esm/{WithTooltip-b75eefc8.js → WithTooltip-2fc4c925.js} +2 -2
  11. package/dist/esm/{formatter-4df2e127.js → formatter-9bb0ae57.js} +1 -1
  12. package/dist/esm/{index-2a91f2bc.js → index-3ae04fda.js} +24 -111
  13. package/dist/esm/index.js +2 -2
  14. package/dist/esm/syntaxhighlighter-b09267a2.js +229 -0
  15. package/dist/modern/{Color-8e98d21f.js → Color-adcd690c.js} +2 -2
  16. package/dist/modern/{OverlayScrollbars-a4969259.js → OverlayScrollbars-2dbee1e7.js} +2 -2
  17. package/dist/modern/{WithTooltip-069246bb.js → WithTooltip-e676f2b3.js} +2 -2
  18. package/dist/modern/{formatter-0e68a4fc.js → formatter-409edac5.js} +1 -1
  19. package/dist/modern/{index-0619466c.js → index-377367fa.js} +24 -111
  20. package/dist/modern/index.js +2 -2
  21. package/dist/modern/syntaxhighlighter-a425409f.js +157 -0
  22. package/package.json +8 -8
  23. package/dist/cjs/syntaxhighlighter-b73c8adf.js +0 -10216
  24. package/dist/esm/syntaxhighlighter-af6b50e9.js +0 -10291
  25. package/dist/modern/syntaxhighlighter-fd785d56.js +0 -10198
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'react';
2
- export { E as A, A as ActionBar, ao as AddonPanel, aF as ArgsTable, aD as ArgsTableError, a3 as Badge, am as Bar, G as Blockquote, aV as BooleanControl, aa as Button, H as Code, aU as ColorControl, aQ as ColorItem, aR as ColorPalette, K as DL, a_ as DateControl, au as Description, J as Div, ax as DocsContent, az as DocsPageWrapper, ay as DocsWrapper, a5 as DocumentWrapper, b6 as FilesControl, an as FlexBar, F as Form, L as H1, M as H2, N as H3, O as H4, P as H5, Q as H6, R as HR, aO as IFrame, ai as IconButton, aT as IconGallery, aS as IconItem, I as Icons, U as Img, V as LI, a4 as Link, as as Loader, aH as NoControlsWarning, b1 as NumberControl, X as OL, b3 as ObjectControl, b2 as OptionsControl, Y as P, a8 as Placeholder, Z as Pre, aA as Preview, aB as PreviewSkeleton, b4 as RangeControl, S as ScrollArea, ak as Separator, aJ as Source, aI as SourceError, a7 as Spaced, $ as Span, aM as Story, aL as StoryError, aN as StorySkeleton, ar as StorybookIcon, aq as StorybookLogo, aK as StyledSyntaxHighlighter, aw as Subtitle, ap as Symbols, a6 as SyntaxHighlighter, a1 as TT, ag as TabBar, aj as TabButton, ah as TabWrapper, aG as TabbedArgsTable, a0 as Table, aC as TableWrapper, ae as Tabs, af as TabsState, b5 as TextControl, av as Title, ad as TooltipLinkList, ac as TooltipMessage, T as TooltipNote, aP as Typeset, a2 as UL, W as WithTooltip, ab as WithTooltipPure, a9 as Zoom, aE as argsTableLoadingData, C as components, b0 as format, aY as formatDate, aZ as formatTime, at as getStoryHref, al as interleaveSeparators, b7 as nameSpaceClassNames, a$ as parse, aW as parseDate, aX as parseTime, D as resetComponents } from './index-2a91f2bc.js';
2
+ export { E as A, A as ActionBar, ao as AddonPanel, aF as ArgsTable, aD as ArgsTableError, a3 as Badge, am as Bar, G as Blockquote, aV as BooleanControl, aa as Button, H as Code, aU as ColorControl, aQ as ColorItem, aR as ColorPalette, K as DL, a_ as DateControl, au as Description, J as Div, ax as DocsContent, az as DocsPageWrapper, ay as DocsWrapper, a5 as DocumentWrapper, b6 as FilesControl, an as FlexBar, F as Form, L as H1, M as H2, N as H3, O as H4, P as H5, Q as H6, R as HR, aO as IFrame, ai as IconButton, aT as IconGallery, aS as IconItem, I as Icons, U as Img, V as LI, a4 as Link, as as Loader, aH as NoControlsWarning, b1 as NumberControl, X as OL, b3 as ObjectControl, b2 as OptionsControl, Y as P, a8 as Placeholder, Z as Pre, aA as Preview, aB as PreviewSkeleton, b4 as RangeControl, S as ScrollArea, ak as Separator, aJ as Source, aI as SourceError, a7 as Spaced, $ as Span, aM as Story, aL as StoryError, aN as StorySkeleton, ar as StorybookIcon, aq as StorybookLogo, aK as StyledSyntaxHighlighter, aw as Subtitle, ap as Symbols, a6 as SyntaxHighlighter, a1 as TT, ag as TabBar, aj as TabButton, ah as TabWrapper, aG as TabbedArgsTable, a0 as Table, aC as TableWrapper, ae as Tabs, af as TabsState, b5 as TextControl, av as Title, ad as TooltipLinkList, ac as TooltipMessage, T as TooltipNote, aP as Typeset, a2 as UL, W as WithTooltip, ab as WithTooltipPure, a9 as Zoom, aE as argsTableLoadingData, C as components, b0 as format, aY as formatDate, aZ as formatTime, at as getStoryHref, al as interleaveSeparators, b7 as nameSpaceClassNames, a$ as parse, aW as parseDate, aX as parseTime, D as resetComponents } from './index-3ae04fda.js';
3
3
  import '@storybook/theming';
4
4
  import '@storybook/csf';
5
- import 'util';
5
+ import 'qs';
6
6
  import '@storybook/client-logger';
@@ -0,0 +1,229 @@
1
+ import "regenerator-runtime/runtime.js";
2
+
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+
5
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
6
+
7
+ 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."); }
8
+
9
+ 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); }
10
+
11
+ 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; }
12
+
13
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_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; }
14
+
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+
17
+ import "core-js/modules/es.object.to-string.js";
18
+ import "core-js/modules/es.object.entries.js";
19
+ import "core-js/modules/es.object.assign.js";
20
+ import "core-js/modules/es.string.trim.js";
21
+ import "core-js/modules/es.regexp.to-string.js";
22
+ import "core-js/modules/es.symbol.js";
23
+ import "core-js/modules/es.symbol.description.js";
24
+ import "core-js/modules/es.symbol.iterator.js";
25
+ import "core-js/modules/es.array.iterator.js";
26
+ import "core-js/modules/es.string.iterator.js";
27
+ import "core-js/modules/web.dom-collections.iterator.js";
28
+ import "core-js/modules/es.array.slice.js";
29
+ import "core-js/modules/es.function.name.js";
30
+ import "core-js/modules/es.array.from.js";
31
+ import "core-js/modules/es.regexp.exec.js";
32
+ import { m as memoizerific, _ as __awaiter, S as ScrollArea, a as __rest, A as ActionBar, w as window_1 } from './index-3ae04fda.js';
33
+ import React__default, { useState, useCallback } from 'react';
34
+ import { logger } from '@storybook/client-logger';
35
+ import { styled } from '@storybook/theming';
36
+ import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx';
37
+ import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash';
38
+ import css from 'react-syntax-highlighter/dist/esm/languages/prism/css';
39
+ import jsExtras from 'react-syntax-highlighter/dist/esm/languages/prism/js-extras';
40
+ import json from 'react-syntax-highlighter/dist/esm/languages/prism/json';
41
+ import graphql from 'react-syntax-highlighter/dist/esm/languages/prism/graphql';
42
+ import html from 'react-syntax-highlighter/dist/esm/languages/prism/markup';
43
+ import md from 'react-syntax-highlighter/dist/esm/languages/prism/markdown';
44
+ import yml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml';
45
+ import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx';
46
+ import typescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript';
47
+ import ReactSyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-light';
48
+ import '@storybook/csf';
49
+ import 'qs';
50
+ var navigator = window_1.navigator,
51
+ document = window_1.document,
52
+ globalWindow = window_1.window;
53
+ ReactSyntaxHighlighter.registerLanguage('jsextra', jsExtras);
54
+ ReactSyntaxHighlighter.registerLanguage('jsx', jsx);
55
+ ReactSyntaxHighlighter.registerLanguage('json', json);
56
+ ReactSyntaxHighlighter.registerLanguage('yml', yml);
57
+ ReactSyntaxHighlighter.registerLanguage('md', md);
58
+ ReactSyntaxHighlighter.registerLanguage('bash', bash);
59
+ ReactSyntaxHighlighter.registerLanguage('css', css);
60
+ ReactSyntaxHighlighter.registerLanguage('html', html);
61
+ ReactSyntaxHighlighter.registerLanguage('tsx', tsx);
62
+ ReactSyntaxHighlighter.registerLanguage('typescript', typescript);
63
+ ReactSyntaxHighlighter.registerLanguage('graphql', graphql);
64
+ var themedSyntax = memoizerific(2)(function (theme) {
65
+ return Object.entries(theme.code || {}).reduce(function (acc, _ref) {
66
+ var _ref2 = _slicedToArray(_ref, 2),
67
+ key = _ref2[0],
68
+ val = _ref2[1];
69
+
70
+ return Object.assign(Object.assign({}, acc), _defineProperty({}, "* .".concat(key), val));
71
+ }, {});
72
+ });
73
+ var copyToClipboard = createCopyToClipboardFunction();
74
+
75
+ function createCopyToClipboardFunction() {
76
+ var _this = this;
77
+
78
+ if (navigator === null || navigator === void 0 ? void 0 : navigator.clipboard) {
79
+ return function (text) {
80
+ return navigator.clipboard.writeText(text);
81
+ };
82
+ }
83
+
84
+ return function (text) {
85
+ return __awaiter(_this, void 0, void 0, /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
86
+ var tmp, focus;
87
+ return regeneratorRuntime.wrap(function _callee$(_context) {
88
+ while (1) {
89
+ switch (_context.prev = _context.next) {
90
+ case 0:
91
+ tmp = document.createElement('TEXTAREA');
92
+ focus = document.activeElement;
93
+ tmp.value = text;
94
+ document.body.appendChild(tmp);
95
+ tmp.select();
96
+ document.execCommand('copy');
97
+ document.body.removeChild(tmp);
98
+ focus.focus();
99
+
100
+ case 8:
101
+ case "end":
102
+ return _context.stop();
103
+ }
104
+ }
105
+ }, _callee);
106
+ }));
107
+ };
108
+ }
109
+
110
+ var Wrapper = styled.div(function (_ref3) {
111
+ var theme = _ref3.theme;
112
+ return {
113
+ position: 'relative',
114
+ overflow: 'hidden',
115
+ color: theme.color.defaultText
116
+ };
117
+ }, function (_ref4) {
118
+ var theme = _ref4.theme,
119
+ bordered = _ref4.bordered;
120
+ return bordered ? {
121
+ border: "1px solid ".concat(theme.appBorderColor),
122
+ borderRadius: theme.borderRadius,
123
+ background: theme.background.content
124
+ } : {};
125
+ });
126
+ var Scroller = styled(function (_ref5) {
127
+ var children = _ref5.children,
128
+ className = _ref5.className;
129
+ return React__default.createElement(ScrollArea, {
130
+ horizontal: true,
131
+ vertical: true,
132
+ className: className
133
+ }, children);
134
+ })({
135
+ position: 'relative'
136
+ }, function (_ref6) {
137
+ var theme = _ref6.theme;
138
+ return themedSyntax(theme);
139
+ });
140
+ var Pre = styled.pre(function (_ref7) {
141
+ var theme = _ref7.theme,
142
+ padded = _ref7.padded;
143
+ return {
144
+ display: 'flex',
145
+ justifyContent: 'flex-start',
146
+ margin: 0,
147
+ padding: padded ? theme.layoutMargin : 0
148
+ };
149
+ });
150
+ /*
151
+ We can't use `code` since PrismJS races for it.
152
+ See https://github.com/storybookjs/storybook/issues/18090
153
+ */
154
+
155
+ var Code = styled.div(function (_ref8) {
156
+ var theme = _ref8.theme;
157
+ return {
158
+ flex: 1,
159
+ paddingLeft: 2,
160
+ paddingRight: theme.layoutMargin,
161
+ opacity: 1
162
+ };
163
+ }); // copied from @types/react-syntax-highlighter/index.d.ts
164
+
165
+ var SyntaxHighlighter = function SyntaxHighlighter(_a) {
166
+ var children = _a.children,
167
+ _a$language = _a.language,
168
+ language = _a$language === void 0 ? 'jsx' : _a$language,
169
+ _a$copyable = _a.copyable,
170
+ copyable = _a$copyable === void 0 ? false : _a$copyable,
171
+ _a$bordered = _a.bordered,
172
+ bordered = _a$bordered === void 0 ? false : _a$bordered,
173
+ _a$padded = _a.padded,
174
+ padded = _a$padded === void 0 ? false : _a$padded,
175
+ _a$format = _a.format,
176
+ format = _a$format === void 0 ? true : _a$format,
177
+ _a$formatter = _a.formatter,
178
+ formatter = _a$formatter === void 0 ? null : _a$formatter,
179
+ _a$className = _a.className,
180
+ className = _a$className === void 0 ? null : _a$className,
181
+ _a$showLineNumbers = _a.showLineNumbers,
182
+ showLineNumbers = _a$showLineNumbers === void 0 ? false : _a$showLineNumbers,
183
+ rest = __rest(_a, ["children", "language", "copyable", "bordered", "padded", "format", "formatter", "className", "showLineNumbers"]);
184
+
185
+ if (typeof children !== 'string' || !children.trim()) {
186
+ return null;
187
+ }
188
+
189
+ var highlightableCode = formatter ? formatter(format, children) : children.trim();
190
+
191
+ var _useState = useState(false),
192
+ _useState2 = _slicedToArray(_useState, 2),
193
+ copied = _useState2[0],
194
+ setCopied = _useState2[1];
195
+
196
+ var onClick = useCallback(function (e) {
197
+ e.preventDefault();
198
+ var selectedText = globalWindow.getSelection().toString();
199
+ var textToCopy = e.type !== 'click' && selectedText ? selectedText : highlightableCode;
200
+ copyToClipboard(textToCopy).then(function () {
201
+ setCopied(true);
202
+ globalWindow.setTimeout(function () {
203
+ return setCopied(false);
204
+ }, 1500);
205
+ }).catch(logger.error);
206
+ }, []);
207
+ return React__default.createElement(Wrapper, {
208
+ bordered: bordered,
209
+ padded: padded,
210
+ className: className,
211
+ onCopyCapture: onClick
212
+ }, React__default.createElement(Scroller, null, React__default.createElement(ReactSyntaxHighlighter, Object.assign({
213
+ padded: padded || bordered,
214
+ language: language,
215
+ showLineNumbers: showLineNumbers,
216
+ showInlineLineNumbers: showLineNumbers,
217
+ useInlineStyles: false,
218
+ PreTag: Pre,
219
+ CodeTag: Code,
220
+ lineNumberContainerStyle: {}
221
+ }, rest), highlightableCode)), copyable ? React__default.createElement(ActionBar, {
222
+ actionItems: [{
223
+ title: copied ? 'Copied' : 'Copy',
224
+ onClick: onClick
225
+ }]
226
+ }) : null);
227
+ };
228
+
229
+ export { SyntaxHighlighter, createCopyToClipboardFunction, SyntaxHighlighter as default };
@@ -1,8 +1,8 @@
1
- import { x as _root, y as isObject_1, z as isSymbol_1, W as WithTooltip, T as TooltipNote, F as Form, I as Icons, B as getControlId, d as __rest } from './index-0619466c.js';
1
+ import { x as _root, y as isObject_1, z as isSymbol_1, W as WithTooltip, T as TooltipNote, F as Form, I as Icons, B as getControlId, a as __rest } from './index-377367fa.js';
2
2
  import React__default, { useRef, useMemo, useEffect, useState, useCallback, useLayoutEffect } from 'react';
3
3
  import { styled } from '@storybook/theming';
4
4
  import '@storybook/csf';
5
- import 'util';
5
+ import 'qs';
6
6
  import '@storybook/client-logger';
7
7
 
8
8
  function u() {
@@ -1,8 +1,8 @@
1
- import { c as commonjsGlobal, d as __rest } from './index-0619466c.js';
1
+ import { c as commonjsGlobal, a as __rest } from './index-377367fa.js';
2
2
  import React__default, { useRef, useEffect } from 'react';
3
3
  import '@storybook/theming';
4
4
  import '@storybook/csf';
5
- import 'util';
5
+ import 'qs';
6
6
  import '@storybook/client-logger';
7
7
  var OverlayScrollbars$1 = {
8
8
  exports: {}
@@ -1,10 +1,10 @@
1
- import { f as basePlacements, t as top, l as left, h as bottom, r as right, i as end, v as viewport, s as start, p as popper, j as clippingParents, k as reference, n as variationPlacements, o as placements, q as auto, u as modifierPhases, a as _extends, _ as _objectWithoutPropertiesLoose, m as memoizerific, d as __rest, w as window_1 } from './index-0619466c.js';
1
+ import { b as basePlacements, t as top, l as left, e as bottom, r as right, f as end, v as viewport, s as start, p as popper, h as clippingParents, i as reference, j as variationPlacements, k as placements, n as auto, o as modifierPhases, q as _extends, u as _objectWithoutPropertiesLoose, m as memoizerific, a as __rest, w as window_1 } from './index-377367fa.js';
2
2
  import * as React from 'react';
3
3
  import React__default, { Component, useState, useCallback, useEffect } from 'react';
4
4
  import { styled, lighten, darken } from '@storybook/theming';
5
5
  import { createPortal } from 'react-dom';
6
6
  import '@storybook/csf';
7
- import 'util';
7
+ import 'qs';
8
8
  import '@storybook/client-logger';
9
9
 
10
10
  function getNodeName(element) {
@@ -1,4 +1,4 @@
1
- import"core-js/modules/es.typed-array.set.js";import{c as commonjsGlobal,g as getDefaultExportFromCjs,m as memoizerific,e as dedent}from'./index-0619466c.js';import'react';import'@storybook/theming';import'@storybook/csf';import'util';import'@storybook/client-logger';var parserHtml={exports:{}};(function(module,exports){!function(e,t){module.exports=t();}(commonjsGlobal,function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports;}var r=t(function(e,t){function r(e){return t.$0<=e&&e<=t.$9;}/**
1
+ import"core-js/modules/es.typed-array.set.js";import{c as commonjsGlobal,g as getDefaultExportFromCjs,m as memoizerific,d as dedent}from'./index-377367fa.js';import'react';import'@storybook/theming';import'@storybook/csf';import'qs';import'@storybook/client-logger';var parserHtml={exports:{}};(function(module,exports){!function(e,t){module.exports=t();}(commonjsGlobal,function(){var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof commonjsGlobal?commonjsGlobal:"undefined"!=typeof self?self:{};function t(e){var t={exports:{}};return e(t,t.exports),t.exports;}var r=t(function(e,t){function r(e){return t.$0<=e&&e<=t.$9;}/**
2
2
  * @license
3
3
  * Copyright Google Inc. All Rights Reserved.
4
4
  *