@storybook/components 6.2.0-rc.9 → 6.2.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.
@@ -96,6 +96,7 @@ var PickerTooltip = (0, _theming.styled)(_lazyWithTooltip.WithTooltip)({
96
96
  });
97
97
 
98
98
  var TooltipContent = _theming.styled.div({
99
+ width: 200,
99
100
  margin: 5,
100
101
  '.react-colorful__saturation': {
101
102
  borderRadius: '4px 4px 0 0'
@@ -108,6 +109,13 @@ var TooltipContent = _theming.styled.div({
108
109
  }
109
110
  });
110
111
 
112
+ var Note = (0, _theming.styled)(_TooltipNote.TooltipNote)(function (_ref) {
113
+ var theme = _ref.theme;
114
+ return {
115
+ fontFamily: theme.typography.fonts.base
116
+ };
117
+ });
118
+
111
119
  var Swatches = _theming.styled.div({
112
120
  display: 'grid',
113
121
  gridTemplateColumns: 'repeat(9, 16px)',
@@ -117,9 +125,9 @@ var Swatches = _theming.styled.div({
117
125
  width: 200
118
126
  });
119
127
 
120
- var SwatchColor = _theming.styled.div(function (_ref) {
121
- var theme = _ref.theme,
122
- active = _ref.active;
128
+ var SwatchColor = _theming.styled.div(function (_ref2) {
129
+ var theme = _ref2.theme,
130
+ active = _ref2.active;
123
131
  return {
124
132
  width: 16,
125
133
  height: 16,
@@ -130,12 +138,12 @@ var SwatchColor = _theming.styled.div(function (_ref) {
130
138
 
131
139
  var swatchBackground = "url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill-opacity=\".05\"><path d=\"M8 0h8v8H8zM0 8h8v8H0z\"/></svg>')";
132
140
 
133
- var Swatch = function Swatch(_ref2) {
134
- var value = _ref2.value,
135
- active = _ref2.active,
136
- onClick = _ref2.onClick,
137
- style = _ref2.style,
138
- props = _objectWithoutProperties(_ref2, ["value", "active", "onClick", "style"]);
141
+ var Swatch = function Swatch(_ref3) {
142
+ var value = _ref3.value,
143
+ active = _ref3.active,
144
+ onClick = _ref3.onClick,
145
+ style = _ref3.style,
146
+ props = _objectWithoutProperties(_ref3, ["value", "active", "onClick", "style"]);
139
147
 
140
148
  var backgroundImage = "linear-gradient(".concat(value, ", ").concat(value, "), ").concat(swatchBackground, ", linear-gradient(#fff, #fff)");
141
149
  return /*#__PURE__*/_react.default.createElement(SwatchColor, _extends({}, props, {
@@ -148,13 +156,18 @@ var Swatch = function Swatch(_ref2) {
148
156
  };
149
157
 
150
158
  Swatch.displayName = "Swatch";
151
- var Input = (0, _theming.styled)(_form.Form.Input)({
152
- width: '100%',
153
- paddingLeft: 30,
154
- paddingRight: 30
159
+ var Input = (0, _theming.styled)(_form.Form.Input)(function (_ref4) {
160
+ var theme = _ref4.theme;
161
+ return {
162
+ width: '100%',
163
+ paddingLeft: 30,
164
+ paddingRight: 30,
165
+ boxSizing: 'border-box',
166
+ fontFamily: theme.typography.fonts.base
167
+ };
155
168
  });
156
- var ToggleIcon = (0, _theming.styled)(_icon.Icons)(function (_ref3) {
157
- var theme = _ref3.theme;
169
+ var ToggleIcon = (0, _theming.styled)(_icon.Icons)(function (_ref5) {
170
+ var theme = _ref5.theme;
158
171
  return {
159
172
  position: 'absolute',
160
173
  zIndex: 1,
@@ -163,6 +176,7 @@ var ToggleIcon = (0, _theming.styled)(_icon.Icons)(function (_ref3) {
163
176
  width: 20,
164
177
  height: 20,
165
178
  padding: 4,
179
+ boxSizing: 'border-box',
166
180
  cursor: 'pointer',
167
181
  color: theme.input.color
168
182
  };
@@ -199,12 +213,13 @@ var stringToArgs = function stringToArgs(value) {
199
213
  };
200
214
 
201
215
  var parseValue = function parseValue(value) {
202
- var _ref10;
216
+ var _ref12;
203
217
 
204
218
  if (!value) return undefined;
219
+ var valid = true;
205
220
 
206
221
  if (RGB_REGEXP.test(value)) {
207
- var _ref6;
222
+ var _ref8;
208
223
 
209
224
  var _stringToArgs = stringToArgs(value),
210
225
  _stringToArgs2 = _slicedToArray(_stringToArgs, 4),
@@ -213,21 +228,22 @@ var parseValue = function parseValue(value) {
213
228
  b = _stringToArgs2[2],
214
229
  a = _stringToArgs2[3];
215
230
 
216
- var _ref4 = _colorConvert.default.rgb.hsl([r, g, b]) || [0, 0, 0],
217
- _ref5 = _slicedToArray(_ref4, 3),
218
- h = _ref5[0],
219
- s = _ref5[1],
220
- l = _ref5[2];
231
+ var _ref6 = _colorConvert.default.rgb.hsl([r, g, b]) || [0, 0, 0],
232
+ _ref7 = _slicedToArray(_ref6, 3),
233
+ h = _ref7[0],
234
+ s = _ref7[1],
235
+ l = _ref7[2];
221
236
 
222
- return _ref6 = {
237
+ return _ref8 = {
238
+ valid: valid,
223
239
  value: value,
224
240
  keyword: _colorConvert.default.rgb.keyword([r, g, b]),
225
241
  colorSpace: ColorSpace.RGB
226
- }, _defineProperty(_ref6, ColorSpace.RGB, value), _defineProperty(_ref6, ColorSpace.HSL, "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(a, ")")), _defineProperty(_ref6, ColorSpace.HEX, "#".concat(_colorConvert.default.rgb.hex([r, g, b]).toLowerCase())), _ref6;
242
+ }, _defineProperty(_ref8, ColorSpace.RGB, value), _defineProperty(_ref8, ColorSpace.HSL, "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(a, ")")), _defineProperty(_ref8, ColorSpace.HEX, "#".concat(_colorConvert.default.rgb.hex([r, g, b]).toLowerCase())), _ref8;
227
243
  }
228
244
 
229
245
  if (HSL_REGEXP.test(value)) {
230
- var _ref9;
246
+ var _ref11;
231
247
 
232
248
  var _stringToArgs3 = stringToArgs(value),
233
249
  _stringToArgs4 = _slicedToArray(_stringToArgs3, 4),
@@ -236,17 +252,18 @@ var parseValue = function parseValue(value) {
236
252
  _l = _stringToArgs4[2],
237
253
  _a = _stringToArgs4[3];
238
254
 
239
- var _ref7 = _colorConvert.default.hsl.rgb([_h, _s2, _l]) || [0, 0, 0],
240
- _ref8 = _slicedToArray(_ref7, 3),
241
- _r = _ref8[0],
242
- _g = _ref8[1],
243
- _b = _ref8[2];
255
+ var _ref9 = _colorConvert.default.hsl.rgb([_h, _s2, _l]) || [0, 0, 0],
256
+ _ref10 = _slicedToArray(_ref9, 3),
257
+ _r = _ref10[0],
258
+ _g = _ref10[1],
259
+ _b = _ref10[2];
244
260
 
245
- return _ref9 = {
261
+ return _ref11 = {
262
+ valid: valid,
246
263
  value: value,
247
264
  keyword: _colorConvert.default.hsl.keyword([_h, _s2, _l]),
248
265
  colorSpace: ColorSpace.HSL
249
- }, _defineProperty(_ref9, ColorSpace.RGB, "rgba(".concat(_r, ", ").concat(_g, ", ").concat(_b, ", ").concat(_a, ")")), _defineProperty(_ref9, ColorSpace.HSL, value), _defineProperty(_ref9, ColorSpace.HEX, "#".concat(_colorConvert.default.hsl.hex([_h, _s2, _l]).toLowerCase())), _ref9;
266
+ }, _defineProperty(_ref11, ColorSpace.RGB, "rgba(".concat(_r, ", ").concat(_g, ", ").concat(_b, ", ").concat(_a, ")")), _defineProperty(_ref11, ColorSpace.HSL, value), _defineProperty(_ref11, ColorSpace.HEX, "#".concat(_colorConvert.default.hsl.hex([_h, _s2, _l]).toLowerCase())), _ref11;
250
267
  }
251
268
 
252
269
  var plain = value.replace('#', '');
@@ -257,15 +274,27 @@ var parseValue = function parseValue(value) {
257
274
 
258
275
  var mapped = value;
259
276
  if (/[^#a-f0-9]/i.test(value)) mapped = plain;else if (HEX_REGEXP.test(value)) mapped = "#".concat(plain);
260
- return _ref10 = {
277
+
278
+ if (mapped.startsWith('#')) {
279
+ valid = HEX_REGEXP.test(mapped);
280
+ } else {
281
+ try {
282
+ _colorConvert.default.keyword.hex(mapped);
283
+ } catch (e) {
284
+ valid = false;
285
+ }
286
+ }
287
+
288
+ return _ref12 = {
289
+ valid: valid,
261
290
  value: mapped,
262
291
  keyword: _colorConvert.default.rgb.keyword(rgb),
263
292
  colorSpace: ColorSpace.HEX
264
- }, _defineProperty(_ref10, ColorSpace.RGB, "rgba(".concat(rgb[0], ", ").concat(rgb[1], ", ").concat(rgb[2], ", 1)")), _defineProperty(_ref10, ColorSpace.HSL, "hsla(".concat(hsl[0], ", ").concat(hsl[1], "%, ").concat(hsl[2], "%, 1)")), _defineProperty(_ref10, ColorSpace.HEX, mapped), _ref10;
293
+ }, _defineProperty(_ref12, ColorSpace.RGB, "rgba(".concat(rgb[0], ", ").concat(rgb[1], ", ").concat(rgb[2], ", 1)")), _defineProperty(_ref12, ColorSpace.HSL, "hsla(".concat(hsl[0], ", ").concat(hsl[1], "%, ").concat(hsl[2], "%, 1)")), _defineProperty(_ref12, ColorSpace.HEX, mapped), _ref12;
265
294
  };
266
295
 
267
296
  var getRealValue = function getRealValue(value, color, colorSpace) {
268
- if (!value) return fallbackColor[colorSpace];
297
+ if (!value || !(color !== null && color !== void 0 && color.valid)) return fallbackColor[colorSpace];
269
298
  if (colorSpace !== ColorSpace.HEX) return (color === null || color === void 0 ? void 0 : color[colorSpace]) || fallbackColor[colorSpace];
270
299
 
271
300
  if (!color.hex.startsWith('#')) {
@@ -340,7 +369,7 @@ var id = function id(value) {
340
369
  };
341
370
 
342
371
  var usePresets = function usePresets(presetColors, currentColor, colorSpace) {
343
- var _useState7 = (0, _react.useState)(currentColor ? [currentColor] : []),
372
+ var _useState7 = (0, _react.useState)(currentColor !== null && currentColor !== void 0 && currentColor.valid ? [currentColor] : []),
344
373
  _useState8 = _slicedToArray(_useState7, 2),
345
374
  selectedColors = _useState8[0],
346
375
  setSelectedColors = _useState8[1];
@@ -356,7 +385,7 @@ var usePresets = function usePresets(presetColors, currentColor, colorSpace) {
356
385
  return initialPresets.concat(selectedColors).filter(Boolean).slice(-27);
357
386
  }, [presetColors, selectedColors]);
358
387
  var addPreset = (0, _react.useCallback)(function (color) {
359
- if (!(color !== null && color !== void 0 && color[colorSpace])) return;
388
+ if (!(color !== null && color !== void 0 && color.valid)) return;
360
389
  if (presets.some(function (preset) {
361
390
  return id(preset[colorSpace]) === id(color[colorSpace]);
362
391
  })) return;
@@ -370,13 +399,13 @@ var usePresets = function usePresets(presetColors, currentColor, colorSpace) {
370
399
  };
371
400
  };
372
401
 
373
- var ColorControl = function ColorControl(_ref11) {
374
- var initialValue = _ref11.value,
375
- onChange = _ref11.onChange,
376
- onFocus = _ref11.onFocus,
377
- onBlur = _ref11.onBlur,
378
- presetColors = _ref11.presetColors,
379
- startOpen = _ref11.startOpen;
402
+ var ColorControl = function ColorControl(_ref13) {
403
+ var initialValue = _ref13.value,
404
+ onChange = _ref13.onChange,
405
+ onFocus = _ref13.onFocus,
406
+ onBlur = _ref13.onBlur,
407
+ presetColors = _ref13.presetColors,
408
+ startOpen = _ref13.startOpen;
380
409
 
381
410
  var _useColorInput = useColorInput(initialValue, (0, _throttle.default)(onChange, 200)),
382
411
  value = _useColorInput.value,
@@ -399,7 +428,7 @@ var ColorControl = function ColorControl(_ref11) {
399
428
  return addPreset(color);
400
429
  },
401
430
  tooltip: /*#__PURE__*/_react.default.createElement(TooltipContent, null, /*#__PURE__*/_react.default.createElement(Picker, {
402
- color: realValue,
431
+ color: realValue === 'transparent' ? '#000000' : realValue,
403
432
  onChange: updateValue,
404
433
  onFocus: onFocus,
405
434
  onBlur: onBlur
@@ -407,7 +436,7 @@ var ColorControl = function ColorControl(_ref11) {
407
436
  return /*#__PURE__*/_react.default.createElement(_lazyWithTooltip.WithTooltip, {
408
437
  key: preset.value,
409
438
  hasChrome: false,
410
- tooltip: /*#__PURE__*/_react.default.createElement(_TooltipNote.TooltipNote, {
439
+ tooltip: /*#__PURE__*/_react.default.createElement(Note, {
411
440
  note: preset.keyword || preset.value
412
441
  })
413
442
  }, /*#__PURE__*/_react.default.createElement(Swatch, {
@@ -47,9 +47,7 @@ var parseDate = function parseDate(value) {
47
47
  day = _value$split2[2];
48
48
 
49
49
  var result = new Date();
50
- result.setFullYear(parseInt(year, 10));
51
- result.setMonth(parseInt(month, 10) - 1);
52
- result.setDate(parseInt(day, 10));
50
+ result.setFullYear(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10));
53
51
  return result;
54
52
  };
55
53
 
@@ -131,9 +129,7 @@ var DateControl = function DateControl(_ref2) {
131
129
  var onDateChange = function onDateChange(e) {
132
130
  var parsed = parseDate(e.target.value);
133
131
  var result = new Date(value);
134
- result.setFullYear(parsed.getFullYear());
135
- result.setMonth(parsed.getMonth());
136
- result.setDate(parsed.getDate());
132
+ result.setFullYear(parsed.getFullYear(), parsed.getMonth(), parsed.getDate());
137
133
  var time = result.getTime();
138
134
  if (time) onChange(time);
139
135
  setValid(!!time);
@@ -2,6 +2,8 @@
2
2
 
3
3
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
4
 
5
+ require("core-js/modules/es.array.includes.js");
6
+
5
7
  require("core-js/modules/es.function.name.js");
6
8
 
7
9
  Object.defineProperty(exports, "__esModule", {
@@ -322,7 +324,7 @@ var ObjectControl = function ObjectControl(_ref7) {
322
324
  valid: parseError ? 'error' : null
323
325
  });
324
326
 
325
- return /*#__PURE__*/_react.default.createElement(Wrapper, null, hasData && /*#__PURE__*/_react.default.createElement(RawButton, {
327
+ return /*#__PURE__*/_react.default.createElement(Wrapper, null, hasData && ['Object', 'Array'].includes((0, _reactEditableJsonTree.getObjectType)(data)) && /*#__PURE__*/_react.default.createElement(RawButton, {
326
328
  onClick: function onClick() {
327
329
  return setShowRaw(function (v) {
328
330
  return !v;
@@ -29,6 +29,12 @@ Object.defineProperty(exports, "UPDATE_DELTA_TYPE", {
29
29
  return _deltaTypes.UPDATE_DELTA_TYPE;
30
30
  }
31
31
  });
32
+ Object.defineProperty(exports, "getObjectType", {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _objectTypes.getObjectType;
36
+ }
37
+ });
32
38
  Object.defineProperty(exports, "DATA_TYPES", {
33
39
  enumerable: true,
34
40
  get: function get() {
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ components: true,
8
+ resetComponents: true
9
+ };
10
+ Object.defineProperty(exports, "components", {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _index.components;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "resetComponents", {
17
+ enumerable: true,
18
+ get: function get() {
19
+ return _index.resetComponents;
20
+ }
21
+ });
22
+
23
+ var _tsDedent = _interopRequireDefault(require("ts-dedent"));
24
+
25
+ var _utilDeprecate = _interopRequireDefault(require("util-deprecate"));
26
+
27
+ var _DocumentFormatting = require("./typography/DocumentFormatting");
28
+
29
+ Object.keys(_DocumentFormatting).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
+ if (key in exports && exports[key] === _DocumentFormatting[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function get() {
36
+ return _DocumentFormatting[key];
37
+ }
38
+ });
39
+ });
40
+
41
+ var _index = require("./index");
42
+
43
+ var _templateObject;
44
+
45
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
+
47
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
48
+
49
+ var deprecatedHtmlEndpoint = (0, _utilDeprecate.default)(function () {}, (0, _tsDedent.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n The entry point '@storybook/components/html' is deprecated. Please use '@storybook/components' directly instead.\n\n See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-storybook-components-html-entry-point\n "]))));
50
+ deprecatedHtmlEndpoint();
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
2
 
3
+ require("core-js/modules/es.array.index-of.js");
4
+
5
+ require("core-js/modules/es.object.keys.js");
6
+
3
7
  require("core-js/modules/es.string.bold.js");
4
8
 
5
9
  Object.defineProperty(exports, "__esModule", {
@@ -13,6 +17,10 @@ var _theming = require("@storybook/theming");
13
17
 
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
20
+ 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; }
21
+
22
+ 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; }
23
+
16
24
  var Note = _theming.styled.div(function (_ref) {
17
25
  var theme = _ref.theme;
18
26
  return {
@@ -32,8 +40,10 @@ var Note = _theming.styled.div(function (_ref) {
32
40
  });
33
41
 
34
42
  var TooltipNote = function TooltipNote(_ref2) {
35
- var note = _ref2.note;
36
- return /*#__PURE__*/_react.default.createElement(Note, null, note);
43
+ var note = _ref2.note,
44
+ props = _objectWithoutProperties(_ref2, ["note"]);
45
+
46
+ return /*#__PURE__*/_react.default.createElement(Note, props, note);
37
47
  };
38
48
 
39
49
  exports.TooltipNote = TooltipNote;
@@ -56,6 +56,7 @@ var PickerTooltip = styled(WithTooltip)({
56
56
  left: 4
57
57
  });
58
58
  var TooltipContent = styled.div({
59
+ width: 200,
59
60
  margin: 5,
60
61
  '.react-colorful__saturation': {
61
62
  borderRadius: '4px 4px 0 0'
@@ -67,6 +68,12 @@ var TooltipContent = styled.div({
67
68
  borderRadius: '0 0 4px 4px'
68
69
  }
69
70
  });
71
+ var Note = styled(TooltipNote)(function (_ref) {
72
+ var theme = _ref.theme;
73
+ return {
74
+ fontFamily: theme.typography.fonts.base
75
+ };
76
+ });
70
77
  var Swatches = styled.div({
71
78
  display: 'grid',
72
79
  gridTemplateColumns: 'repeat(9, 16px)',
@@ -75,9 +82,9 @@ var Swatches = styled.div({
75
82
  marginTop: 5,
76
83
  width: 200
77
84
  });
78
- var SwatchColor = styled.div(function (_ref) {
79
- var theme = _ref.theme,
80
- active = _ref.active;
85
+ var SwatchColor = styled.div(function (_ref2) {
86
+ var theme = _ref2.theme,
87
+ active = _ref2.active;
81
88
  return {
82
89
  width: 16,
83
90
  height: 16,
@@ -87,12 +94,12 @@ var SwatchColor = styled.div(function (_ref) {
87
94
  });
88
95
  var swatchBackground = "url('data:image/svg+xml;charset=utf-8,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" fill-opacity=\".05\"><path d=\"M8 0h8v8H8zM0 8h8v8H0z\"/></svg>')";
89
96
 
90
- var Swatch = function Swatch(_ref2) {
91
- var value = _ref2.value,
92
- active = _ref2.active,
93
- onClick = _ref2.onClick,
94
- style = _ref2.style,
95
- props = _objectWithoutProperties(_ref2, ["value", "active", "onClick", "style"]);
97
+ var Swatch = function Swatch(_ref3) {
98
+ var value = _ref3.value,
99
+ active = _ref3.active,
100
+ onClick = _ref3.onClick,
101
+ style = _ref3.style,
102
+ props = _objectWithoutProperties(_ref3, ["value", "active", "onClick", "style"]);
96
103
 
97
104
  var backgroundImage = "linear-gradient(".concat(value, ", ").concat(value, "), ").concat(swatchBackground, ", linear-gradient(#fff, #fff)");
98
105
  return /*#__PURE__*/React.createElement(SwatchColor, _extends({}, props, {
@@ -105,13 +112,18 @@ var Swatch = function Swatch(_ref2) {
105
112
  };
106
113
 
107
114
  Swatch.displayName = "Swatch";
108
- var Input = styled(Form.Input)({
109
- width: '100%',
110
- paddingLeft: 30,
111
- paddingRight: 30
115
+ var Input = styled(Form.Input)(function (_ref4) {
116
+ var theme = _ref4.theme;
117
+ return {
118
+ width: '100%',
119
+ paddingLeft: 30,
120
+ paddingRight: 30,
121
+ boxSizing: 'border-box',
122
+ fontFamily: theme.typography.fonts.base
123
+ };
112
124
  });
113
- var ToggleIcon = styled(Icons)(function (_ref3) {
114
- var theme = _ref3.theme;
125
+ var ToggleIcon = styled(Icons)(function (_ref5) {
126
+ var theme = _ref5.theme;
115
127
  return {
116
128
  position: 'absolute',
117
129
  zIndex: 1,
@@ -120,6 +132,7 @@ var ToggleIcon = styled(Icons)(function (_ref3) {
120
132
  width: 20,
121
133
  height: 20,
122
134
  padding: 4,
135
+ boxSizing: 'border-box',
123
136
  cursor: 'pointer',
124
137
  color: theme.input.color
125
138
  };
@@ -156,12 +169,13 @@ var stringToArgs = function stringToArgs(value) {
156
169
  };
157
170
 
158
171
  var parseValue = function parseValue(value) {
159
- var _ref10;
172
+ var _ref12;
160
173
 
161
174
  if (!value) return undefined;
175
+ var valid = true;
162
176
 
163
177
  if (RGB_REGEXP.test(value)) {
164
- var _ref6;
178
+ var _ref8;
165
179
 
166
180
  var _stringToArgs = stringToArgs(value),
167
181
  _stringToArgs2 = _slicedToArray(_stringToArgs, 4),
@@ -170,21 +184,22 @@ var parseValue = function parseValue(value) {
170
184
  b = _stringToArgs2[2],
171
185
  a = _stringToArgs2[3];
172
186
 
173
- var _ref4 = convert.rgb.hsl([r, g, b]) || [0, 0, 0],
174
- _ref5 = _slicedToArray(_ref4, 3),
175
- h = _ref5[0],
176
- s = _ref5[1],
177
- l = _ref5[2];
187
+ var _ref6 = convert.rgb.hsl([r, g, b]) || [0, 0, 0],
188
+ _ref7 = _slicedToArray(_ref6, 3),
189
+ h = _ref7[0],
190
+ s = _ref7[1],
191
+ l = _ref7[2];
178
192
 
179
- return _ref6 = {
193
+ return _ref8 = {
194
+ valid: valid,
180
195
  value: value,
181
196
  keyword: convert.rgb.keyword([r, g, b]),
182
197
  colorSpace: ColorSpace.RGB
183
- }, _defineProperty(_ref6, ColorSpace.RGB, value), _defineProperty(_ref6, ColorSpace.HSL, "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(a, ")")), _defineProperty(_ref6, ColorSpace.HEX, "#".concat(convert.rgb.hex([r, g, b]).toLowerCase())), _ref6;
198
+ }, _defineProperty(_ref8, ColorSpace.RGB, value), _defineProperty(_ref8, ColorSpace.HSL, "hsla(".concat(h, ", ").concat(s, "%, ").concat(l, "%, ").concat(a, ")")), _defineProperty(_ref8, ColorSpace.HEX, "#".concat(convert.rgb.hex([r, g, b]).toLowerCase())), _ref8;
184
199
  }
185
200
 
186
201
  if (HSL_REGEXP.test(value)) {
187
- var _ref9;
202
+ var _ref11;
188
203
 
189
204
  var _stringToArgs3 = stringToArgs(value),
190
205
  _stringToArgs4 = _slicedToArray(_stringToArgs3, 4),
@@ -193,17 +208,18 @@ var parseValue = function parseValue(value) {
193
208
  _l = _stringToArgs4[2],
194
209
  _a = _stringToArgs4[3];
195
210
 
196
- var _ref7 = convert.hsl.rgb([_h, _s2, _l]) || [0, 0, 0],
197
- _ref8 = _slicedToArray(_ref7, 3),
198
- _r = _ref8[0],
199
- _g = _ref8[1],
200
- _b = _ref8[2];
211
+ var _ref9 = convert.hsl.rgb([_h, _s2, _l]) || [0, 0, 0],
212
+ _ref10 = _slicedToArray(_ref9, 3),
213
+ _r = _ref10[0],
214
+ _g = _ref10[1],
215
+ _b = _ref10[2];
201
216
 
202
- return _ref9 = {
217
+ return _ref11 = {
218
+ valid: valid,
203
219
  value: value,
204
220
  keyword: convert.hsl.keyword([_h, _s2, _l]),
205
221
  colorSpace: ColorSpace.HSL
206
- }, _defineProperty(_ref9, ColorSpace.RGB, "rgba(".concat(_r, ", ").concat(_g, ", ").concat(_b, ", ").concat(_a, ")")), _defineProperty(_ref9, ColorSpace.HSL, value), _defineProperty(_ref9, ColorSpace.HEX, "#".concat(convert.hsl.hex([_h, _s2, _l]).toLowerCase())), _ref9;
222
+ }, _defineProperty(_ref11, ColorSpace.RGB, "rgba(".concat(_r, ", ").concat(_g, ", ").concat(_b, ", ").concat(_a, ")")), _defineProperty(_ref11, ColorSpace.HSL, value), _defineProperty(_ref11, ColorSpace.HEX, "#".concat(convert.hsl.hex([_h, _s2, _l]).toLowerCase())), _ref11;
207
223
  }
208
224
 
209
225
  var plain = value.replace('#', '');
@@ -211,15 +227,27 @@ var parseValue = function parseValue(value) {
211
227
  var hsl = convert.rgb.hsl(rgb);
212
228
  var mapped = value;
213
229
  if (/[^#a-f0-9]/i.test(value)) mapped = plain;else if (HEX_REGEXP.test(value)) mapped = "#".concat(plain);
214
- return _ref10 = {
230
+
231
+ if (mapped.startsWith('#')) {
232
+ valid = HEX_REGEXP.test(mapped);
233
+ } else {
234
+ try {
235
+ convert.keyword.hex(mapped);
236
+ } catch (e) {
237
+ valid = false;
238
+ }
239
+ }
240
+
241
+ return _ref12 = {
242
+ valid: valid,
215
243
  value: mapped,
216
244
  keyword: convert.rgb.keyword(rgb),
217
245
  colorSpace: ColorSpace.HEX
218
- }, _defineProperty(_ref10, ColorSpace.RGB, "rgba(".concat(rgb[0], ", ").concat(rgb[1], ", ").concat(rgb[2], ", 1)")), _defineProperty(_ref10, ColorSpace.HSL, "hsla(".concat(hsl[0], ", ").concat(hsl[1], "%, ").concat(hsl[2], "%, 1)")), _defineProperty(_ref10, ColorSpace.HEX, mapped), _ref10;
246
+ }, _defineProperty(_ref12, ColorSpace.RGB, "rgba(".concat(rgb[0], ", ").concat(rgb[1], ", ").concat(rgb[2], ", 1)")), _defineProperty(_ref12, ColorSpace.HSL, "hsla(".concat(hsl[0], ", ").concat(hsl[1], "%, ").concat(hsl[2], "%, 1)")), _defineProperty(_ref12, ColorSpace.HEX, mapped), _ref12;
219
247
  };
220
248
 
221
249
  var getRealValue = function getRealValue(value, color, colorSpace) {
222
- if (!value) return fallbackColor[colorSpace];
250
+ if (!value || !(color !== null && color !== void 0 && color.valid)) return fallbackColor[colorSpace];
223
251
  if (colorSpace !== ColorSpace.HEX) return (color === null || color === void 0 ? void 0 : color[colorSpace]) || fallbackColor[colorSpace];
224
252
 
225
253
  if (!color.hex.startsWith('#')) {
@@ -294,7 +322,7 @@ var id = function id(value) {
294
322
  };
295
323
 
296
324
  var usePresets = function usePresets(presetColors, currentColor, colorSpace) {
297
- var _useState7 = useState(currentColor ? [currentColor] : []),
325
+ var _useState7 = useState(currentColor !== null && currentColor !== void 0 && currentColor.valid ? [currentColor] : []),
298
326
  _useState8 = _slicedToArray(_useState7, 2),
299
327
  selectedColors = _useState8[0],
300
328
  setSelectedColors = _useState8[1];
@@ -310,7 +338,7 @@ var usePresets = function usePresets(presetColors, currentColor, colorSpace) {
310
338
  return initialPresets.concat(selectedColors).filter(Boolean).slice(-27);
311
339
  }, [presetColors, selectedColors]);
312
340
  var addPreset = useCallback(function (color) {
313
- if (!(color !== null && color !== void 0 && color[colorSpace])) return;
341
+ if (!(color !== null && color !== void 0 && color.valid)) return;
314
342
  if (presets.some(function (preset) {
315
343
  return id(preset[colorSpace]) === id(color[colorSpace]);
316
344
  })) return;
@@ -324,13 +352,13 @@ var usePresets = function usePresets(presetColors, currentColor, colorSpace) {
324
352
  };
325
353
  };
326
354
 
327
- export var ColorControl = function ColorControl(_ref11) {
328
- var initialValue = _ref11.value,
329
- onChange = _ref11.onChange,
330
- onFocus = _ref11.onFocus,
331
- onBlur = _ref11.onBlur,
332
- presetColors = _ref11.presetColors,
333
- startOpen = _ref11.startOpen;
355
+ export var ColorControl = function ColorControl(_ref13) {
356
+ var initialValue = _ref13.value,
357
+ onChange = _ref13.onChange,
358
+ onFocus = _ref13.onFocus,
359
+ onBlur = _ref13.onBlur,
360
+ presetColors = _ref13.presetColors,
361
+ startOpen = _ref13.startOpen;
334
362
 
335
363
  var _useColorInput = useColorInput(initialValue, throttle(onChange, 200)),
336
364
  value = _useColorInput.value,
@@ -353,7 +381,7 @@ export var ColorControl = function ColorControl(_ref11) {
353
381
  return addPreset(color);
354
382
  },
355
383
  tooltip: /*#__PURE__*/React.createElement(TooltipContent, null, /*#__PURE__*/React.createElement(Picker, {
356
- color: realValue,
384
+ color: realValue === 'transparent' ? '#000000' : realValue,
357
385
  onChange: updateValue,
358
386
  onFocus: onFocus,
359
387
  onBlur: onBlur
@@ -361,7 +389,7 @@ export var ColorControl = function ColorControl(_ref11) {
361
389
  return /*#__PURE__*/React.createElement(WithTooltip, {
362
390
  key: preset.value,
363
391
  hasChrome: false,
364
- tooltip: /*#__PURE__*/React.createElement(TooltipNote, {
392
+ tooltip: /*#__PURE__*/React.createElement(Note, {
365
393
  note: preset.keyword || preset.value
366
394
  })
367
395
  }, /*#__PURE__*/React.createElement(Swatch, {
@@ -28,9 +28,7 @@ var parseDate = function parseDate(value) {
28
28
  day = _value$split2[2];
29
29
 
30
30
  var result = new Date();
31
- result.setFullYear(parseInt(year, 10));
32
- result.setMonth(parseInt(month, 10) - 1);
33
- result.setDate(parseInt(day, 10));
31
+ result.setFullYear(parseInt(year, 10), parseInt(month, 10) - 1, parseInt(day, 10));
34
32
  return result;
35
33
  };
36
34
 
@@ -111,9 +109,7 @@ export var DateControl = function DateControl(_ref2) {
111
109
  var onDateChange = function onDateChange(e) {
112
110
  var parsed = parseDate(e.target.value);
113
111
  var result = new Date(value);
114
- result.setFullYear(parsed.getFullYear());
115
- result.setMonth(parsed.getMonth());
116
- result.setDate(parsed.getDate());
112
+ result.setFullYear(parsed.getFullYear(), parsed.getMonth(), parsed.getDate());
117
113
  var time = result.getTime();
118
114
  if (time) onChange(time);
119
115
  setValid(!!time);
@@ -1,3 +1,4 @@
1
+ import "core-js/modules/es.array.includes.js";
1
2
  import "core-js/modules/es.function.name.js";
2
3
 
3
4
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -17,7 +18,7 @@ import cloneDeep from 'lodash/cloneDeep';
17
18
  import React, { useCallback, useMemo, useState } from 'react';
18
19
  import { styled, useTheme } from '@storybook/theming'; // @ts-ignore
19
20
 
20
- import { JsonTree } from './react-editable-json-tree';
21
+ import { JsonTree, getObjectType } from './react-editable-json-tree';
21
22
  import { Form } from '../form';
22
23
  import { Icons } from '../icon/icon';
23
24
  import { IconButton } from '../bar/button';
@@ -294,7 +295,7 @@ export var ObjectControl = function ObjectControl(_ref7) {
294
295
  placeholder: "Enter JSON string",
295
296
  valid: parseError ? 'error' : null
296
297
  });
297
- return /*#__PURE__*/React.createElement(Wrapper, null, hasData && /*#__PURE__*/React.createElement(RawButton, {
298
+ return /*#__PURE__*/React.createElement(Wrapper, null, hasData && ['Object', 'Array'].includes(getObjectType(data)) && /*#__PURE__*/React.createElement(RawButton, {
298
299
  onClick: function onClick() {
299
300
  return setShowRaw(function (v) {
300
301
  return !v;
@@ -252,6 +252,7 @@ JsonTree.defaultProps = {
252
252
  fallback: null
253
253
  };
254
254
  export { JsonTree };
255
+ export { getObjectType };
255
256
  export { ADD_DELTA_TYPE };
256
257
  export { REMOVE_DELTA_TYPE };
257
258
  export { UPDATE_DELTA_TYPE };
@@ -0,0 +1,10 @@
1
+ var _templateObject;
2
+
3
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
4
+
5
+ import dedent from 'ts-dedent';
6
+ import deprecate from 'util-deprecate';
7
+ var deprecatedHtmlEndpoint = deprecate(function () {}, dedent(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n The entry point '@storybook/components/html' is deprecated. Please use '@storybook/components' directly instead.\n\n See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#deprecated-storybook-components-html-entry-point\n "]))));
8
+ deprecatedHtmlEndpoint();
9
+ export * from './typography/DocumentFormatting';
10
+ export { components, resetComponents } from './index';
@@ -1,4 +1,11 @@
1
+ import "core-js/modules/es.array.index-of.js";
2
+ import "core-js/modules/es.object.keys.js";
1
3
  import "core-js/modules/es.string.bold.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
+
2
9
  import React from 'react';
3
10
  import { styled } from '@storybook/theming';
4
11
  var Note = styled.div(function (_ref) {
@@ -19,7 +26,9 @@ var Note = styled.div(function (_ref) {
19
26
  };
20
27
  });
21
28
  export var TooltipNote = function TooltipNote(_ref2) {
22
- var note = _ref2.note;
23
- return /*#__PURE__*/React.createElement(Note, null, note);
29
+ var note = _ref2.note,
30
+ props = _objectWithoutProperties(_ref2, ["note"]);
31
+
32
+ return /*#__PURE__*/React.createElement(Note, props, note);
24
33
  };
25
34
  TooltipNote.displayName = "TooltipNote";
@@ -0,0 +1,2 @@
1
+ export * from './typography/DocumentFormatting';
2
+ export { components, resetComponents } from './index';
@@ -0,0 +1,2 @@
1
+ export * from './typography/DocumentFormatting';
2
+ export { components, resetComponents } from './index';
package/html.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/ts3.9/html.d';
package/html.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./dist/cjs/html');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/components",
3
- "version": "6.2.0-rc.9",
3
+ "version": "6.2.0",
4
4
  "description": "Core Storybook Components",
5
5
  "keywords": [
6
6
  "storybook"
@@ -37,9 +37,9 @@
37
37
  },
38
38
  "dependencies": {
39
39
  "@popperjs/core": "^2.6.0",
40
- "@storybook/client-logger": "6.2.0-rc.9",
40
+ "@storybook/client-logger": "6.2.0",
41
41
  "@storybook/csf": "0.0.1",
42
- "@storybook/theming": "6.2.0-rc.9",
42
+ "@storybook/theming": "6.2.0",
43
43
  "@types/color-convert": "^2.0.0",
44
44
  "@types/overlayscrollbars": "^1.12.0",
45
45
  "@types/react-syntax-highlighter": "11.0.5",
@@ -58,7 +58,8 @@
58
58
  "react-syntax-highlighter": "^13.5.3",
59
59
  "react-textarea-autosize": "^8.3.0",
60
60
  "regenerator-runtime": "^0.13.7",
61
- "ts-dedent": "^2.0.0"
61
+ "ts-dedent": "^2.0.0",
62
+ "util-deprecate": "^1.0.2"
62
63
  },
63
64
  "devDependencies": {
64
65
  "css": "^3.0.0",
@@ -71,5 +72,5 @@
71
72
  "publishConfig": {
72
73
  "access": "public"
73
74
  },
74
- "gitHead": "b100a45b69db3c2b9c4cd06e68d9035a769f592d"
75
+ "gitHead": "829c72e4374888ca74ed4e68e0c1de940ac18163"
75
76
  }