@storybook/components 6.4.0-alpha.8 → 6.4.0-beta.10
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.
- package/dist/cjs/ActionBar/ActionBar.js +1 -0
- package/dist/cjs/Button/Button.stories.js +8 -1
- package/dist/cjs/bar/separator.js +0 -2
- package/dist/cjs/blocks/ArgsTable/ArgControl.js +24 -41
- package/dist/cjs/blocks/ArgsTable/ArgRow.js +9 -1
- package/dist/cjs/blocks/ArgsTable/ArgsTable.js +1 -3
- package/dist/cjs/blocks/ColorPalette.js +33 -19
- package/dist/cjs/blocks/Preview.js +81 -8
- package/dist/cjs/controls/Boolean.js +2 -1
- package/dist/cjs/controls/Color.js +2 -2
- package/dist/cjs/controls/Number.js +1 -0
- package/dist/cjs/controls/Object.js +1 -0
- package/dist/cjs/controls/Text.js +1 -0
- package/dist/cjs/controls/helpers.js +15 -2
- package/dist/cjs/controls/index.js +0 -14
- package/dist/cjs/controls/options/Options.js +22 -26
- package/dist/cjs/icon/icons.js +3 -0
- package/dist/cjs/index.js +7 -3
- package/dist/cjs/syntaxhighlighter/syntaxhighlighter.js +20 -14
- package/dist/cjs/typography/DocumentFormatting.js +15 -4
- package/dist/esm/ActionBar/ActionBar.js +1 -0
- package/dist/esm/Button/Button.stories.js +8 -1
- package/dist/esm/bar/separator.js +0 -1
- package/dist/esm/blocks/ArgsTable/ArgControl.js +23 -41
- package/dist/esm/blocks/ArgsTable/ArgRow.js +8 -1
- package/dist/esm/blocks/ArgsTable/ArgsTable.js +1 -2
- package/dist/esm/blocks/ColorPalette.js +33 -19
- package/dist/esm/blocks/Preview.js +74 -7
- package/dist/esm/controls/Boolean.js +3 -2
- package/dist/esm/controls/Color.js +2 -2
- package/dist/esm/controls/Number.js +2 -1
- package/dist/esm/controls/Object.js +2 -1
- package/dist/esm/controls/Text.js +2 -1
- package/dist/esm/controls/helpers.js +10 -0
- package/dist/esm/controls/index.js +0 -1
- package/dist/esm/controls/options/Options.js +18 -24
- package/dist/esm/icon/icons.js +3 -0
- package/dist/esm/index.js +7 -4
- package/dist/esm/syntaxhighlighter/syntaxhighlighter.js +16 -13
- package/dist/esm/typography/DocumentFormatting.js +12 -3
- package/dist/modern/ActionBar/ActionBar.js +1 -0
- package/dist/modern/Button/Button.stories.js +8 -1
- package/dist/modern/blocks/ArgsTable/ArgControl.js +23 -41
- package/dist/modern/blocks/ArgsTable/ArgRow.js +7 -1
- package/dist/modern/blocks/ArgsTable/ArgsTable.js +1 -1
- package/dist/modern/blocks/ColorPalette.js +20 -7
- package/dist/modern/blocks/Preview.js +34 -5
- package/dist/modern/controls/Boolean.js +3 -2
- package/dist/modern/controls/Color.js +2 -2
- package/dist/modern/controls/Number.js +2 -1
- package/dist/modern/controls/Object.js +2 -1
- package/dist/modern/controls/Text.js +2 -1
- package/dist/modern/controls/helpers.js +9 -1
- package/dist/modern/controls/index.js +0 -1
- package/dist/modern/controls/options/Options.js +16 -23
- package/dist/modern/icon/icons.js +3 -0
- package/dist/modern/index.js +4 -2
- package/dist/modern/syntaxhighlighter/syntaxhighlighter.js +11 -8
- package/dist/modern/typography/DocumentFormatting.js +7 -2
- package/dist/ts3.4/Button/Button.d.ts +1 -0
- package/dist/ts3.4/controls/helpers.d.ts +7 -0
- package/dist/ts3.4/controls/index.d.ts +0 -1
- package/dist/ts3.4/controls/types.d.ts +1 -5
- package/dist/ts3.4/icon/icons.d.ts +3 -0
- package/dist/ts3.4/syntaxhighlighter/syntaxhighlighter.d.ts +1 -0
- package/dist/ts3.9/Button/Button.d.ts +1 -0
- package/dist/ts3.9/controls/helpers.d.ts +7 -0
- package/dist/ts3.9/controls/index.d.ts +0 -1
- package/dist/ts3.9/controls/types.d.ts +1 -5
- package/dist/ts3.9/icon/icons.d.ts +3 -0
- package/dist/ts3.9/syntaxhighlighter/syntaxhighlighter.d.ts +1 -0
- package/package.json +7 -7
- package/dist/cjs/controls/Array.js +0 -123
- package/dist/cjs/controls/Array.stories.js +0 -92
- package/dist/esm/controls/Array.js +0 -86
- package/dist/esm/controls/Array.stories.js +0 -55
- package/dist/modern/controls/Array.js +0 -55
- package/dist/modern/controls/Array.stories.js +0 -20
- package/dist/ts3.4/controls/Array.d.ts +0 -4
- package/dist/ts3.9/controls/Array.d.ts +0 -4
|
@@ -6,8 +6,6 @@ require("core-js/modules/es.symbol.js");
|
|
|
6
6
|
|
|
7
7
|
require("core-js/modules/es.symbol.description.js");
|
|
8
8
|
|
|
9
|
-
require("core-js/modules/es.object.to-string.js");
|
|
10
|
-
|
|
11
9
|
require("core-js/modules/es.symbol.iterator.js");
|
|
12
10
|
|
|
13
11
|
require("core-js/modules/es.string.iterator.js");
|
|
@@ -33,18 +31,21 @@ require("core-js/modules/es.object.get-own-property-descriptor.js");
|
|
|
33
31
|
Object.defineProperty(exports, "__esModule", {
|
|
34
32
|
value: true
|
|
35
33
|
});
|
|
34
|
+
exports.createCopyToClipboardFunction = createCopyToClipboardFunction;
|
|
36
35
|
exports.default = exports.SyntaxHighlighter = void 0;
|
|
37
36
|
|
|
38
37
|
require("regenerator-runtime/runtime.js");
|
|
39
38
|
|
|
40
|
-
require("core-js/modules/es.array.reduce.js");
|
|
41
|
-
|
|
42
39
|
require("core-js/modules/es.object.entries.js");
|
|
43
40
|
|
|
44
41
|
require("core-js/modules/es.object.assign.js");
|
|
45
42
|
|
|
46
43
|
require("core-js/modules/es.string.trim.js");
|
|
47
44
|
|
|
45
|
+
require("core-js/modules/es.object.to-string.js");
|
|
46
|
+
|
|
47
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
48
|
+
|
|
48
49
|
var _react = _interopRequireWildcard(require("react"));
|
|
49
50
|
|
|
50
51
|
var _clientLogger = require("@storybook/client-logger");
|
|
@@ -150,14 +151,16 @@ var themedSyntax = (0, _memoizerific.default)(2)(function (theme) {
|
|
|
150
151
|
return Object.assign({}, acc, _defineProperty({}, "* .".concat(key), val));
|
|
151
152
|
}, {});
|
|
152
153
|
});
|
|
153
|
-
var copyToClipboard;
|
|
154
|
+
var copyToClipboard = createCopyToClipboardFunction();
|
|
154
155
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
156
|
+
function createCopyToClipboardFunction() {
|
|
157
|
+
if (navigator !== null && navigator !== void 0 && navigator.clipboard) {
|
|
158
|
+
return function (text) {
|
|
159
|
+
return navigator.clipboard.writeText(text);
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return /*#__PURE__*/function () {
|
|
161
164
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(text) {
|
|
162
165
|
var tmp, focus;
|
|
163
166
|
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
@@ -181,7 +184,7 @@ if (navigator !== null && navigator !== void 0 && navigator.clipboard) {
|
|
|
181
184
|
}, _callee);
|
|
182
185
|
}));
|
|
183
186
|
|
|
184
|
-
return function
|
|
187
|
+
return function (_x) {
|
|
185
188
|
return _ref3.apply(this, arguments);
|
|
186
189
|
};
|
|
187
190
|
}();
|
|
@@ -274,7 +277,9 @@ var SyntaxHighlighter = function SyntaxHighlighter(_ref10) {
|
|
|
274
277
|
|
|
275
278
|
var onClick = function onClick(e) {
|
|
276
279
|
e.preventDefault();
|
|
277
|
-
|
|
280
|
+
var selectedText = globalWindow.getSelection().toString();
|
|
281
|
+
var textToCopy = e.type !== 'click' && selectedText ? selectedText : highlightableCode;
|
|
282
|
+
copyToClipboard(textToCopy).then(function () {
|
|
278
283
|
setCopied(true);
|
|
279
284
|
globalWindow.setTimeout(function () {
|
|
280
285
|
return setCopied(false);
|
|
@@ -285,7 +290,8 @@ var SyntaxHighlighter = function SyntaxHighlighter(_ref10) {
|
|
|
285
290
|
return /*#__PURE__*/_react.default.createElement(Wrapper, {
|
|
286
291
|
bordered: bordered,
|
|
287
292
|
padded: padded,
|
|
288
|
-
className: className
|
|
293
|
+
className: className,
|
|
294
|
+
onCopyCapture: onClick
|
|
289
295
|
}, /*#__PURE__*/_react.default.createElement(Scroller, null, /*#__PURE__*/_react.default.createElement(_prismLight.default, _extends({
|
|
290
296
|
padded: padded || bordered,
|
|
291
297
|
language: language,
|
|
@@ -13,10 +13,10 @@ require("core-js/modules/es.string.match.js");
|
|
|
13
13
|
|
|
14
14
|
require("core-js/modules/es.regexp.exec.js");
|
|
15
15
|
|
|
16
|
-
require("core-js/modules/es.array.join.js");
|
|
17
|
-
|
|
18
16
|
require("core-js/modules/es.array.filter.js");
|
|
19
17
|
|
|
18
|
+
require("core-js/modules/es.array.join.js");
|
|
19
|
+
|
|
20
20
|
require("core-js/modules/es.array.concat.js");
|
|
21
21
|
|
|
22
22
|
require("core-js/modules/es.object.keys.js");
|
|
@@ -442,6 +442,12 @@ var DefaultCodeBlock = _theming.styled.code(function (_ref16) {
|
|
|
442
442
|
};
|
|
443
443
|
}, _shared.codeCommon);
|
|
444
444
|
|
|
445
|
+
var isInlineCodeRegex = /[\n\r]/g;
|
|
446
|
+
|
|
447
|
+
var isReactChildString = function isReactChildString(child) {
|
|
448
|
+
return typeof child === 'string';
|
|
449
|
+
};
|
|
450
|
+
|
|
445
451
|
var Code = function Code(_ref17) {
|
|
446
452
|
var _language$;
|
|
447
453
|
|
|
@@ -450,12 +456,17 @@ var Code = function Code(_ref17) {
|
|
|
450
456
|
props = _objectWithoutProperties(_ref17, ["className", "children"]);
|
|
451
457
|
|
|
452
458
|
var language = (className || '').match(/lang-(\S+)/);
|
|
453
|
-
|
|
459
|
+
|
|
460
|
+
var childrenArray = _react.default.Children.toArray(children);
|
|
461
|
+
|
|
462
|
+
var isInlineCode = !childrenArray.filter(isReactChildString).some(function (child) {
|
|
463
|
+
return child.match(isInlineCodeRegex);
|
|
464
|
+
});
|
|
454
465
|
|
|
455
466
|
if (isInlineCode) {
|
|
456
467
|
return /*#__PURE__*/_react.default.createElement(DefaultCodeBlock, _extends({}, props, {
|
|
457
468
|
className: className
|
|
458
|
-
}),
|
|
469
|
+
}), childrenArray);
|
|
459
470
|
}
|
|
460
471
|
|
|
461
472
|
return /*#__PURE__*/_react.default.createElement(_Source.StyledSyntaxHighlighter, _extends({
|
|
@@ -54,5 +54,12 @@ storiesOf('Basics/Button', module).add('all buttons', function () {
|
|
|
54
54
|
small: true
|
|
55
55
|
}, /*#__PURE__*/React.createElement(Icons, {
|
|
56
56
|
icon: "link"
|
|
57
|
-
}), "Link")
|
|
57
|
+
}), "Link"), /*#__PURE__*/React.createElement(Button, {
|
|
58
|
+
primary: true,
|
|
59
|
+
small: true,
|
|
60
|
+
isLink: true,
|
|
61
|
+
href: "#"
|
|
62
|
+
}, /*#__PURE__*/React.createElement(Icons, {
|
|
63
|
+
icon: "link"
|
|
64
|
+
}), " Link"));
|
|
58
65
|
});
|
|
@@ -28,6 +28,23 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
28
28
|
|
|
29
29
|
import React, { useCallback, useState, useEffect } from 'react';
|
|
30
30
|
import { BooleanControl, ColorControl, DateControl, FilesControl, NumberControl, ObjectControl, OptionsControl, RangeControl, TextControl } from '../../controls';
|
|
31
|
+
var Controls = {
|
|
32
|
+
array: ObjectControl,
|
|
33
|
+
object: ObjectControl,
|
|
34
|
+
boolean: BooleanControl,
|
|
35
|
+
color: ColorControl,
|
|
36
|
+
date: DateControl,
|
|
37
|
+
number: NumberControl,
|
|
38
|
+
check: OptionsControl,
|
|
39
|
+
'inline-check': OptionsControl,
|
|
40
|
+
radio: OptionsControl,
|
|
41
|
+
'inline-radio': OptionsControl,
|
|
42
|
+
select: OptionsControl,
|
|
43
|
+
'multi-select': OptionsControl,
|
|
44
|
+
range: RangeControl,
|
|
45
|
+
text: TextControl,
|
|
46
|
+
file: FilesControl
|
|
47
|
+
};
|
|
31
48
|
|
|
32
49
|
var NoControl = function NoControl() {
|
|
33
50
|
return /*#__PURE__*/React.createElement(React.Fragment, null, "-");
|
|
@@ -82,44 +99,9 @@ export var ArgControl = function ArgControl(_ref) {
|
|
|
82
99
|
onBlur: onBlur,
|
|
83
100
|
onFocus: onFocus
|
|
84
101
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
case 'boolean':
|
|
92
|
-
return /*#__PURE__*/React.createElement(BooleanControl, _extends({}, props, control));
|
|
93
|
-
|
|
94
|
-
case 'color':
|
|
95
|
-
return /*#__PURE__*/React.createElement(ColorControl, _extends({}, props, control));
|
|
96
|
-
|
|
97
|
-
case 'date':
|
|
98
|
-
return /*#__PURE__*/React.createElement(DateControl, _extends({}, props, control));
|
|
99
|
-
|
|
100
|
-
case 'number':
|
|
101
|
-
return /*#__PURE__*/React.createElement(NumberControl, _extends({}, props, control));
|
|
102
|
-
|
|
103
|
-
case 'check':
|
|
104
|
-
case 'inline-check':
|
|
105
|
-
case 'radio':
|
|
106
|
-
case 'inline-radio':
|
|
107
|
-
case 'select':
|
|
108
|
-
case 'multi-select':
|
|
109
|
-
return /*#__PURE__*/React.createElement(OptionsControl, _extends({}, props, control, {
|
|
110
|
-
controlType: control.type
|
|
111
|
-
}));
|
|
112
|
-
|
|
113
|
-
case 'range':
|
|
114
|
-
return /*#__PURE__*/React.createElement(RangeControl, _extends({}, props, control));
|
|
115
|
-
|
|
116
|
-
case 'text':
|
|
117
|
-
return /*#__PURE__*/React.createElement(TextControl, _extends({}, props, control));
|
|
118
|
-
|
|
119
|
-
case 'file':
|
|
120
|
-
return /*#__PURE__*/React.createElement(FilesControl, _extends({}, props, control));
|
|
121
|
-
|
|
122
|
-
default:
|
|
123
|
-
return /*#__PURE__*/React.createElement(NoControl, null);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
102
|
+
var Control = Controls[control.type] || NoControl;
|
|
103
|
+
return /*#__PURE__*/React.createElement(Control, _extends({}, props, control, {
|
|
104
|
+
controlType: control.type
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
ArgControl.displayName = "ArgControl";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "core-js/modules/es.object.assign.js";
|
|
1
2
|
import "core-js/modules/es.function.name.js";
|
|
2
3
|
import "core-js/modules/es.symbol.js";
|
|
3
4
|
import "core-js/modules/es.symbol.description.js";
|
|
@@ -31,12 +32,18 @@ var Description = styled.div(function (_ref2) {
|
|
|
31
32
|
color: theme.color.secondary
|
|
32
33
|
}
|
|
33
34
|
},
|
|
34
|
-
code: codeCommon({
|
|
35
|
+
code: Object.assign({}, codeCommon({
|
|
35
36
|
theme: theme
|
|
37
|
+
}), {
|
|
38
|
+
fontSize: 12,
|
|
39
|
+
fontFamily: theme.typography.fonts.mono
|
|
36
40
|
}),
|
|
37
41
|
'& code': {
|
|
38
42
|
margin: 0,
|
|
39
43
|
display: 'inline-block'
|
|
44
|
+
},
|
|
45
|
+
'& pre > code': {
|
|
46
|
+
whiteSpace: 'pre-wrap'
|
|
40
47
|
}
|
|
41
48
|
};
|
|
42
49
|
});
|
|
@@ -20,7 +20,6 @@ import "core-js/modules/es.function.name.js";
|
|
|
20
20
|
import "core-js/modules/es.number.constructor.js";
|
|
21
21
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
22
22
|
import "core-js/modules/es.object.entries.js";
|
|
23
|
-
import "core-js/modules/es.array.reduce.js";
|
|
24
23
|
import "core-js/modules/es.object.keys.js";
|
|
25
24
|
import "core-js/modules/es.array.map.js";
|
|
26
25
|
import "core-js/modules/es.symbol.js";
|
|
@@ -343,7 +342,7 @@ export var ArgsTable = function ArgsTable(props) {
|
|
|
343
342
|
},
|
|
344
343
|
title: "Reset controls"
|
|
345
344
|
}, /*#__PURE__*/React.createElement(Icons, {
|
|
346
|
-
icon: "
|
|
345
|
+
icon: "undo",
|
|
347
346
|
"aria-hidden": true
|
|
348
347
|
})))) : null)), /*#__PURE__*/React.createElement("tbody", {
|
|
349
348
|
className: "docblock-argstable-body"
|
|
@@ -60,17 +60,33 @@ var SwatchLabels = styled.div({
|
|
|
60
60
|
display: 'flex',
|
|
61
61
|
flexDirection: 'row'
|
|
62
62
|
});
|
|
63
|
-
var Swatch = styled.div({
|
|
64
|
-
|
|
63
|
+
var Swatch = styled.div(function (_ref4) {
|
|
64
|
+
var background = _ref4.background;
|
|
65
|
+
return {
|
|
66
|
+
position: 'relative',
|
|
67
|
+
flex: 1,
|
|
68
|
+
'&::before': {
|
|
69
|
+
position: 'absolute',
|
|
70
|
+
top: 0,
|
|
71
|
+
left: 0,
|
|
72
|
+
width: '100%',
|
|
73
|
+
height: '100%',
|
|
74
|
+
background: background,
|
|
75
|
+
content: '""'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
65
78
|
});
|
|
66
|
-
var SwatchColors = styled.div(function (
|
|
67
|
-
var theme =
|
|
79
|
+
var SwatchColors = styled.div(function (_ref5) {
|
|
80
|
+
var theme = _ref5.theme;
|
|
68
81
|
return Object.assign({}, getBlockBackgroundStyle(theme), {
|
|
69
82
|
display: 'flex',
|
|
70
83
|
flexDirection: 'row',
|
|
71
84
|
height: 50,
|
|
72
85
|
marginBottom: 5,
|
|
73
|
-
overflow: 'hidden'
|
|
86
|
+
overflow: 'hidden',
|
|
87
|
+
backgroundColor: 'white',
|
|
88
|
+
backgroundImage: "repeating-linear-gradient(-45deg, #ccc, #ccc 1px, #fff 1px, #fff 16px)",
|
|
89
|
+
backgroundClip: 'padding-box'
|
|
74
90
|
});
|
|
75
91
|
});
|
|
76
92
|
var SwatchSpecimen = styled.div({
|
|
@@ -95,8 +111,8 @@ var ListName = styled.div({
|
|
|
95
111
|
var ListSwatches = styled.div({
|
|
96
112
|
flex: 1
|
|
97
113
|
});
|
|
98
|
-
var ListHeading = styled.div(function (
|
|
99
|
-
var theme =
|
|
114
|
+
var ListHeading = styled.div(function (_ref6) {
|
|
115
|
+
var theme = _ref6.theme;
|
|
100
116
|
return {
|
|
101
117
|
display: 'flex',
|
|
102
118
|
flexDirection: 'row',
|
|
@@ -106,8 +122,8 @@ var ListHeading = styled.div(function (_ref5) {
|
|
|
106
122
|
color: theme.base === 'light' ? transparentize(0.4, theme.color.defaultText) : transparentize(0.6, theme.color.defaultText)
|
|
107
123
|
};
|
|
108
124
|
});
|
|
109
|
-
var List = styled.div(function (
|
|
110
|
-
var theme =
|
|
125
|
+
var List = styled.div(function (_ref7) {
|
|
126
|
+
var theme = _ref7.theme;
|
|
111
127
|
return {
|
|
112
128
|
fontSize: theme.typography.size.s2,
|
|
113
129
|
lineHeight: "20px",
|
|
@@ -120,9 +136,7 @@ function renderSwatch(color, index) {
|
|
|
120
136
|
return /*#__PURE__*/React.createElement(Swatch, {
|
|
121
137
|
key: "".concat(color, "-").concat(index),
|
|
122
138
|
title: color,
|
|
123
|
-
|
|
124
|
-
background: color
|
|
125
|
-
}
|
|
139
|
+
background: color
|
|
126
140
|
});
|
|
127
141
|
}
|
|
128
142
|
|
|
@@ -159,10 +173,10 @@ renderSwatchSpecimen.displayName = "renderSwatchSpecimen";
|
|
|
159
173
|
* A single color row your styleguide showing title, subtitle and one or more colors, used
|
|
160
174
|
* as a child of `ColorPalette`.
|
|
161
175
|
*/
|
|
162
|
-
export var ColorItem = function ColorItem(
|
|
163
|
-
var title =
|
|
164
|
-
subtitle =
|
|
165
|
-
colors =
|
|
176
|
+
export var ColorItem = function ColorItem(_ref8) {
|
|
177
|
+
var title = _ref8.title,
|
|
178
|
+
subtitle = _ref8.subtitle,
|
|
179
|
+
colors = _ref8.colors;
|
|
166
180
|
return /*#__PURE__*/React.createElement(Item, null, /*#__PURE__*/React.createElement(ItemDescription, null, /*#__PURE__*/React.createElement(ItemTitle, null, title), /*#__PURE__*/React.createElement(ItemSubtitle, null, subtitle)), /*#__PURE__*/React.createElement(Swatches, null, renderSwatchSpecimen(colors)));
|
|
167
181
|
};
|
|
168
182
|
ColorItem.displayName = "ColorItem";
|
|
@@ -171,9 +185,9 @@ ColorItem.displayName = "ColorItem";
|
|
|
171
185
|
* Styleguide documentation for colors, including names, captions, and color swatches,
|
|
172
186
|
* all specified as `ColorItem` children of this wrapper component.
|
|
173
187
|
*/
|
|
174
|
-
export var ColorPalette = function ColorPalette(
|
|
175
|
-
var children =
|
|
176
|
-
props = _objectWithoutProperties(
|
|
188
|
+
export var ColorPalette = function ColorPalette(_ref9) {
|
|
189
|
+
var children = _ref9.children,
|
|
190
|
+
props = _objectWithoutProperties(_ref9, ["children"]);
|
|
177
191
|
|
|
178
192
|
return /*#__PURE__*/React.createElement(ResetWrapper, null, /*#__PURE__*/React.createElement(List, _extends({}, props, {
|
|
179
193
|
className: "docblock-colorpalette"
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import "regenerator-runtime/runtime.js";
|
|
2
|
+
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
|
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
6
|
+
|
|
1
7
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
8
|
|
|
3
9
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -25,14 +31,15 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
25
31
|
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); }
|
|
26
32
|
|
|
27
33
|
import "core-js/modules/es.object.assign.js";
|
|
28
|
-
import "core-js/modules/es.array.reduce.js";
|
|
29
34
|
import "core-js/modules/es.array.concat.js";
|
|
35
|
+
import "core-js/modules/es.promise.js";
|
|
36
|
+
import "core-js/modules/es.object.to-string.js";
|
|
37
|
+
import "core-js/modules/es.array.filter.js";
|
|
30
38
|
import "core-js/modules/es.array.join.js";
|
|
31
39
|
import "core-js/modules/es.array.map.js";
|
|
32
40
|
import "core-js/modules/es.object.keys.js";
|
|
33
41
|
import "core-js/modules/es.symbol.js";
|
|
34
42
|
import "core-js/modules/es.symbol.description.js";
|
|
35
|
-
import "core-js/modules/es.object.to-string.js";
|
|
36
43
|
import "core-js/modules/es.symbol.iterator.js";
|
|
37
44
|
import "core-js/modules/es.string.iterator.js";
|
|
38
45
|
import "core-js/modules/es.array.iterator.js";
|
|
@@ -40,9 +47,10 @@ import "core-js/modules/web.dom-collections.iterator.js";
|
|
|
40
47
|
import "core-js/modules/es.array.slice.js";
|
|
41
48
|
import "core-js/modules/es.function.name.js";
|
|
42
49
|
import "core-js/modules/es.array.from.js";
|
|
43
|
-
import React, { Children, useState } from 'react';
|
|
50
|
+
import React, { Children, useCallback, useState } from 'react';
|
|
44
51
|
import { darken } from 'polished';
|
|
45
52
|
import { styled } from '@storybook/theming';
|
|
53
|
+
import global from 'global';
|
|
46
54
|
import { getBlockBackgroundStyle } from './BlockBackgroundStyles';
|
|
47
55
|
import { Source } from './Source';
|
|
48
56
|
import { ActionBar } from '../ActionBar/ActionBar';
|
|
@@ -168,7 +176,9 @@ var getSource = function getSource(withSource, expanded, setExpanded) {
|
|
|
168
176
|
default:
|
|
169
177
|
{
|
|
170
178
|
return {
|
|
171
|
-
source:
|
|
179
|
+
source: /*#__PURE__*/React.createElement(StyledSource, _extends({}, withSource, {
|
|
180
|
+
dark: true
|
|
181
|
+
})),
|
|
172
182
|
actionItem: {
|
|
173
183
|
title: 'Show code',
|
|
174
184
|
className: 'docblock-code-toggle',
|
|
@@ -254,9 +264,65 @@ var Preview = function Preview(_ref8) {
|
|
|
254
264
|
|
|
255
265
|
var previewClasses = [className].concat(['sbdocs', 'sbdocs-preview']);
|
|
256
266
|
var defaultActionItems = withSource ? [actionItem] : [];
|
|
257
|
-
|
|
267
|
+
|
|
268
|
+
var _useState5 = useState(additionalActions ? _toConsumableArray(additionalActions) : []),
|
|
269
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
270
|
+
additionalActionItems = _useState6[0],
|
|
271
|
+
setAdditionalActionItems = _useState6[1];
|
|
272
|
+
|
|
273
|
+
var actionItems = [].concat(defaultActionItems, _toConsumableArray(additionalActionItems)); // @ts-ignore
|
|
258
274
|
|
|
259
275
|
var layout = getLayout(Children.count(children) === 1 ? [children] : children);
|
|
276
|
+
var globalWindow = global.window;
|
|
277
|
+
var copyToClipboard = useCallback( /*#__PURE__*/function () {
|
|
278
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(text) {
|
|
279
|
+
var _yield$import, createCopyToClipboardFunction;
|
|
280
|
+
|
|
281
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
282
|
+
while (1) {
|
|
283
|
+
switch (_context.prev = _context.next) {
|
|
284
|
+
case 0:
|
|
285
|
+
_context.next = 2;
|
|
286
|
+
return import('../syntaxhighlighter/syntaxhighlighter');
|
|
287
|
+
|
|
288
|
+
case 2:
|
|
289
|
+
_yield$import = _context.sent;
|
|
290
|
+
createCopyToClipboardFunction = _yield$import.createCopyToClipboardFunction;
|
|
291
|
+
createCopyToClipboardFunction();
|
|
292
|
+
|
|
293
|
+
case 5:
|
|
294
|
+
case "end":
|
|
295
|
+
return _context.stop();
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}, _callee);
|
|
299
|
+
}));
|
|
300
|
+
|
|
301
|
+
return function (_x) {
|
|
302
|
+
return _ref9.apply(this, arguments);
|
|
303
|
+
};
|
|
304
|
+
}(), []);
|
|
305
|
+
|
|
306
|
+
var onCopyCapture = function onCopyCapture(e) {
|
|
307
|
+
e.preventDefault();
|
|
308
|
+
|
|
309
|
+
if (additionalActionItems.filter(function (item) {
|
|
310
|
+
return item.title === 'Copied';
|
|
311
|
+
}).length === 0) {
|
|
312
|
+
copyToClipboard(source.props.code).then(function () {
|
|
313
|
+
setAdditionalActionItems([].concat(_toConsumableArray(additionalActionItems), [{
|
|
314
|
+
title: 'Copied',
|
|
315
|
+
onClick: function onClick() {}
|
|
316
|
+
}]));
|
|
317
|
+
globalWindow.setTimeout(function () {
|
|
318
|
+
return setAdditionalActionItems(additionalActionItems.filter(function (item) {
|
|
319
|
+
return item.title !== 'Copied';
|
|
320
|
+
}));
|
|
321
|
+
}, 1500);
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
|
|
260
326
|
return /*#__PURE__*/React.createElement(PreviewContainer, _extends({
|
|
261
327
|
withSource: withSource,
|
|
262
328
|
withToolbar: withToolbar
|
|
@@ -277,7 +343,8 @@ var Preview = function Preview(_ref8) {
|
|
|
277
343
|
scale: scale
|
|
278
344
|
}
|
|
279
345
|
}, /*#__PURE__*/React.createElement(Relative, {
|
|
280
|
-
className: "docs-story"
|
|
346
|
+
className: "docs-story",
|
|
347
|
+
onCopyCapture: withSource && onCopyCapture
|
|
281
348
|
}, /*#__PURE__*/React.createElement(ChildrenContainer, {
|
|
282
349
|
isColumn: isColumn || !Array.isArray(children),
|
|
283
350
|
columns: columns,
|
|
@@ -291,7 +358,7 @@ var Preview = function Preview(_ref8) {
|
|
|
291
358
|
}, child);
|
|
292
359
|
}) : /*#__PURE__*/React.createElement("div", null, children))), /*#__PURE__*/React.createElement(ActionBar, {
|
|
293
360
|
actionItems: actionItems
|
|
294
|
-
}))), withSource && source);
|
|
361
|
+
}))), withSource && expanded && source);
|
|
295
362
|
};
|
|
296
363
|
|
|
297
364
|
Preview.displayName = "Preview";
|
|
@@ -3,7 +3,7 @@ import "core-js/modules/es.function.name.js";
|
|
|
3
3
|
import React, { useCallback } from 'react';
|
|
4
4
|
import { opacify, transparentize } from 'polished';
|
|
5
5
|
import { styled } from '@storybook/theming';
|
|
6
|
-
import { getControlId } from './helpers';
|
|
6
|
+
import { getControlId, getControlSetterButtonId } from './helpers';
|
|
7
7
|
import { Form } from '../form';
|
|
8
8
|
var Label = styled.label(function (_ref) {
|
|
9
9
|
var theme = _ref.theme;
|
|
@@ -63,7 +63,7 @@ var Label = styled.label(function (_ref) {
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
'input:checked ~ span:last-of-type, input:not(:checked) ~ span:first-of-type': {
|
|
66
|
-
background: theme.background.
|
|
66
|
+
background: theme.background.app,
|
|
67
67
|
boxShadow: "".concat(opacify(0.1, theme.appBorderColor), " 0 0 2px"),
|
|
68
68
|
color: theme.color.defaultText,
|
|
69
69
|
padding: '7px 15px'
|
|
@@ -91,6 +91,7 @@ export var BooleanControl = function BooleanControl(_ref2) {
|
|
|
91
91
|
|
|
92
92
|
if (value === undefined) {
|
|
93
93
|
return /*#__PURE__*/React.createElement(Form.Button, {
|
|
94
|
+
id: getControlSetterButtonId(name),
|
|
94
95
|
onClick: onSetFalse
|
|
95
96
|
}, "Set boolean");
|
|
96
97
|
}
|
|
@@ -437,10 +437,10 @@ export var ColorControl = function ColorControl(_ref13) {
|
|
|
437
437
|
return e.target.select();
|
|
438
438
|
},
|
|
439
439
|
placeholder: "Choose color..."
|
|
440
|
-
}), /*#__PURE__*/React.createElement(ToggleIcon, {
|
|
440
|
+
}), value ? /*#__PURE__*/React.createElement(ToggleIcon, {
|
|
441
441
|
icon: "markup",
|
|
442
442
|
onClick: cycleColorSpace
|
|
443
|
-
}));
|
|
443
|
+
}) : null);
|
|
444
444
|
};
|
|
445
445
|
ColorControl.displayName = "ColorControl";
|
|
446
446
|
export default ColorControl;
|
|
@@ -25,7 +25,7 @@ import "core-js/modules/es.array.from.js";
|
|
|
25
25
|
import React, { useState, useCallback, useEffect, useRef } from 'react';
|
|
26
26
|
import { styled } from '@storybook/theming';
|
|
27
27
|
import { Form } from '../form';
|
|
28
|
-
import { getControlId } from './helpers';
|
|
28
|
+
import { getControlId, getControlSetterButtonId } from './helpers';
|
|
29
29
|
var Wrapper = styled.label({
|
|
30
30
|
display: 'flex'
|
|
31
31
|
});
|
|
@@ -84,6 +84,7 @@ export var NumberControl = function NumberControl(_ref) {
|
|
|
84
84
|
|
|
85
85
|
if (!forceVisible && value === undefined) {
|
|
86
86
|
return /*#__PURE__*/React.createElement(Form.Button, {
|
|
87
|
+
id: getControlSetterButtonId(name),
|
|
87
88
|
onClick: onForceVisible
|
|
88
89
|
}, "Set number");
|
|
89
90
|
}
|
|
@@ -27,7 +27,7 @@ import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react'
|
|
|
27
27
|
import { styled, useTheme } from '@storybook/theming'; // @ts-ignore
|
|
28
28
|
|
|
29
29
|
import { JsonTree, getObjectType } from './react-editable-json-tree';
|
|
30
|
-
import { getControlId } from './helpers';
|
|
30
|
+
import { getControlId, getControlSetterButtonId } from './helpers';
|
|
31
31
|
import { Form } from '../form';
|
|
32
32
|
import { Icons } from '../icon/icon';
|
|
33
33
|
import { IconButton } from '../bar/button';
|
|
@@ -312,6 +312,7 @@ export var ObjectControl = function ObjectControl(_ref7) {
|
|
|
312
312
|
|
|
313
313
|
if (!hasData) {
|
|
314
314
|
return /*#__PURE__*/React.createElement(Form.Button, {
|
|
315
|
+
id: getControlSetterButtonId(name),
|
|
315
316
|
onClick: onForceVisible
|
|
316
317
|
}, "Set object");
|
|
317
318
|
}
|
|
@@ -23,7 +23,7 @@ import "core-js/modules/es.array.from.js";
|
|
|
23
23
|
import React, { useCallback, useState } from 'react';
|
|
24
24
|
import { styled } from '@storybook/theming';
|
|
25
25
|
import { Form } from '../form';
|
|
26
|
-
import { getControlId } from './helpers';
|
|
26
|
+
import { getControlId, getControlSetterButtonId } from './helpers';
|
|
27
27
|
var Wrapper = styled.label({
|
|
28
28
|
display: 'flex'
|
|
29
29
|
});
|
|
@@ -50,6 +50,7 @@ export var TextControl = function TextControl(_ref) {
|
|
|
50
50
|
|
|
51
51
|
if (value === undefined) {
|
|
52
52
|
return /*#__PURE__*/React.createElement(Form.Button, {
|
|
53
|
+
id: getControlSetterButtonId(name),
|
|
53
54
|
onClick: onForceVisible
|
|
54
55
|
}, "Set string");
|
|
55
56
|
}
|
|
@@ -9,4 +9,14 @@ import "core-js/modules/es.regexp.exec.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export var getControlId = function getControlId(value) {
|
|
11
11
|
return "control-".concat(value.replace(/\s+/g, '-'));
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Adds `set` prefix to make ID attribute more specific.
|
|
15
|
+
* Removes spaces because spaces are not allowed in ID attributes
|
|
16
|
+
* @link http://xahlee.info/js/html_allowed_chars_in_attribute.html
|
|
17
|
+
* @example getControlSetterButtonId('my prop name') -> 'set-my-prop-name'
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export var getControlSetterButtonId = function getControlSetterButtonId(value) {
|
|
21
|
+
return "set-".concat(value.replace(/\s+/g, '-'));
|
|
12
22
|
};
|
|
@@ -2,7 +2,6 @@ import "core-js/modules/es.promise.js";
|
|
|
2
2
|
import "core-js/modules/es.object.to-string.js";
|
|
3
3
|
import React, { Suspense } from 'react';
|
|
4
4
|
export * from './types';
|
|
5
|
-
export * from './Array';
|
|
6
5
|
export * from './Boolean';
|
|
7
6
|
var LazyColorControl = /*#__PURE__*/React.lazy(function () {
|
|
8
7
|
return import('./Color');
|