@storybook/components 6.5.9 → 7.0.0-alpha.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.
Files changed (89) hide show
  1. package/dist/GlobalScrollAreaStyles-5MYDB36S.mjs +1 -0
  2. package/dist/OverlayScrollbars-GXD6IR4B.mjs +6 -0
  3. package/dist/WithTooltip-3ZGNZXVO.mjs +9 -0
  4. package/dist/chunk-37LBAZBN.mjs +161 -0
  5. package/dist/chunk-7IK3EOFL.mjs +1 -0
  6. package/dist/chunk-DF422II4.mjs +6 -0
  7. package/dist/chunk-IONIU25V.mjs +5 -0
  8. package/dist/chunk-NS5PSNOW.mjs +7 -0
  9. package/dist/chunk-PJYBQ6PQ.mjs +1 -0
  10. package/dist/formatter-7QCQCGUB.mjs +184 -0
  11. package/dist/html.d.ts +5 -0
  12. package/dist/html.js +169 -0
  13. package/dist/html.mjs +5 -0
  14. package/dist/index.d.ts +831 -0
  15. package/dist/index.js +372 -0
  16. package/dist/index.mjs +1 -0
  17. package/dist/syntaxhighlighter-4PNAP6ZV.mjs +1 -0
  18. package/html.d.ts +1 -1
  19. package/html.js +1 -2
  20. package/package.json +31 -20
  21. package/dist/cjs/Color-a62ba7e9.js +0 -2461
  22. package/dist/cjs/GlobalScrollAreaStyles-ff4bd929.js +0 -463
  23. package/dist/cjs/OverlayScrollbars-c574dc71.js +0 -6622
  24. package/dist/cjs/WithTooltip-f49e8812.js +0 -3170
  25. package/dist/cjs/formatter-e9350ac6.js +0 -128
  26. package/dist/cjs/index-967d55af.js +0 -2047
  27. package/dist/cjs/index.js +0 -133
  28. package/dist/cjs/syntaxhighlighter-9522fde9.js +0 -215
  29. package/dist/esm/Color-3c22bb81.js +0 -2576
  30. package/dist/esm/GlobalScrollAreaStyles-8793ce4a.js +0 -461
  31. package/dist/esm/OverlayScrollbars-26c4a78d.js +0 -6710
  32. package/dist/esm/WithTooltip-508b8277.js +0 -3195
  33. package/dist/esm/formatter-9dc562d4.js +0 -128
  34. package/dist/esm/index-b45716e8.js +0 -1990
  35. package/dist/esm/index.js +0 -7
  36. package/dist/esm/syntaxhighlighter-82dea71a.js +0 -230
  37. package/dist/modern/Color-f9ce6f57.js +0 -2444
  38. package/dist/modern/GlobalScrollAreaStyles-8793ce4a.js +0 -450
  39. package/dist/modern/OverlayScrollbars-119b80c2.js +0 -6604
  40. package/dist/modern/WithTooltip-040f3a83.js +0 -3126
  41. package/dist/modern/formatter-12a1a8d1.js +0 -128
  42. package/dist/modern/index-9ef3b84b.js +0 -2047
  43. package/dist/modern/index.js +0 -7
  44. package/dist/modern/syntaxhighlighter-5c1fdb3d.js +0 -158
  45. package/dist/ts-tmp/index.d.ts +0 -928
  46. package/dist/ts3.4/_modules/@popperjs-core-index.d.ts +0 -1
  47. package/dist/ts3.4/_modules/@popperjs-core-lib-createPopper.d.ts +0 -9
  48. package/dist/ts3.4/_modules/@popperjs-core-lib-enums.d.ts +0 -34
  49. package/dist/ts3.4/_modules/@popperjs-core-lib-index.d.ts +0 -6
  50. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-applyStyles.d.ts +0 -4
  51. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-arrow.d.ts +0 -13
  52. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-computeStyles.d.ts +0 -38
  53. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-eventListeners.d.ts +0 -8
  54. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-flip.d.ts +0 -16
  55. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-hide.d.ts +0 -4
  56. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-index.d.ts +0 -9
  57. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-offset.d.ts +0 -24
  58. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-popperOffsets.d.ts +0 -4
  59. package/dist/ts3.4/_modules/@popperjs-core-lib-modifiers-preventOverflow.d.ts +0 -30
  60. package/dist/ts3.4/_modules/@popperjs-core-lib-popper-lite.d.ts +0 -5
  61. package/dist/ts3.4/_modules/@popperjs-core-lib-popper.d.ts +0 -7
  62. package/dist/ts3.4/_modules/@popperjs-core-lib-types.d.ts +0 -167
  63. package/dist/ts3.4/_modules/@popperjs-core-lib-utils-detectOverflow.d.ts +0 -11
  64. package/dist/ts3.4/_modules/@types-prettier-index.d.ts +0 -641
  65. package/dist/ts3.4/_modules/react-textarea-autosize-dist-declarations-src-index.d.ts +0 -17
  66. package/dist/ts3.4/_modules/react-textarea-autosize-dist-react-textarea-autosize.cjs.d.ts +0 -2
  67. package/dist/ts3.4/index.d.ts +0 -926
  68. package/dist/ts3.9/_modules/@popperjs-core-index.d.ts +0 -1
  69. package/dist/ts3.9/_modules/@popperjs-core-lib-createPopper.d.ts +0 -9
  70. package/dist/ts3.9/_modules/@popperjs-core-lib-enums.d.ts +0 -34
  71. package/dist/ts3.9/_modules/@popperjs-core-lib-index.d.ts +0 -6
  72. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-applyStyles.d.ts +0 -4
  73. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-arrow.d.ts +0 -13
  74. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-computeStyles.d.ts +0 -38
  75. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-eventListeners.d.ts +0 -8
  76. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-flip.d.ts +0 -16
  77. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-hide.d.ts +0 -4
  78. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-index.d.ts +0 -9
  79. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-offset.d.ts +0 -18
  80. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-popperOffsets.d.ts +0 -4
  81. package/dist/ts3.9/_modules/@popperjs-core-lib-modifiers-preventOverflow.d.ts +0 -30
  82. package/dist/ts3.9/_modules/@popperjs-core-lib-popper-lite.d.ts +0 -5
  83. package/dist/ts3.9/_modules/@popperjs-core-lib-popper.d.ts +0 -7
  84. package/dist/ts3.9/_modules/@popperjs-core-lib-types.d.ts +0 -167
  85. package/dist/ts3.9/_modules/@popperjs-core-lib-utils-detectOverflow.d.ts +0 -11
  86. package/dist/ts3.9/_modules/@types-prettier-index.d.ts +0 -641
  87. package/dist/ts3.9/_modules/react-textarea-autosize-dist-declarations-src-index.d.ts +0 -17
  88. package/dist/ts3.9/_modules/react-textarea-autosize-dist-react-textarea-autosize.cjs.d.ts +0 -2
  89. package/dist/ts3.9/index.d.ts +0 -926
@@ -1,2461 +0,0 @@
1
- 'use strict';
2
-
3
- var index = require('./index-967d55af.js');
4
-
5
- var React = require('react');
6
-
7
- var theming = require('@storybook/theming');
8
-
9
- require('memoizerific');
10
-
11
- require('@storybook/csf');
12
-
13
- require('qs');
14
-
15
- require('@storybook/client-logger');
16
-
17
- function _interopDefaultLegacy(e) {
18
- return e && typeof e === 'object' && 'default' in e ? e : {
19
- 'default': e
20
- };
21
- }
22
-
23
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
24
-
25
- function u() {
26
- return (u = Object.assign || function (e) {
27
- for (var r = 1; r < arguments.length; r++) {
28
- var t = arguments[r];
29
-
30
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
31
- }
32
-
33
- return e;
34
- }).apply(this, arguments);
35
- }
36
-
37
- function c(e, r) {
38
- if (null == e) return {};
39
- var t,
40
- n,
41
- o = {},
42
- a = Object.keys(e);
43
-
44
- for (n = 0; n < a.length; n++) r.indexOf(t = a[n]) >= 0 || (o[t] = e[t]);
45
-
46
- return o;
47
- }
48
-
49
- function i(e) {
50
- var t = React.useRef(e),
51
- n = React.useRef(function (e) {
52
- t.current && t.current(e);
53
- });
54
- return t.current = e, n.current;
55
- }
56
-
57
- var s = function (e, r, t) {
58
- return void 0 === r && (r = 0), void 0 === t && (t = 1), e > t ? t : e < r ? r : e;
59
- },
60
- f = function (e) {
61
- return "touches" in e;
62
- },
63
- v = function (e) {
64
- return e && e.ownerDocument.defaultView || self;
65
- },
66
- d = function (e, r, t) {
67
- var n = e.getBoundingClientRect(),
68
- o = f(r) ? function (e, r) {
69
- for (var t = 0; t < e.length; t++) if (e[t].identifier === r) return e[t];
70
-
71
- return e[0];
72
- }(r.touches, t) : r;
73
- return {
74
- left: s((o.pageX - (n.left + v(e).pageXOffset)) / n.width),
75
- top: s((o.pageY - (n.top + v(e).pageYOffset)) / n.height)
76
- };
77
- },
78
- h = function (e) {
79
- !f(e) && e.preventDefault();
80
- },
81
- m = React__default["default"].memo(function (o) {
82
- var a = o.onMove,
83
- l = o.onKey,
84
- s = c(o, ["onMove", "onKey"]),
85
- m = React.useRef(null),
86
- g = i(a),
87
- p = i(l),
88
- b = React.useRef(null),
89
- _ = React.useRef(!1),
90
- x = React.useMemo(function () {
91
- var e = function (e) {
92
- h(e), (f(e) ? e.touches.length > 0 : e.buttons > 0) && m.current ? g(d(m.current, e, b.current)) : t(!1);
93
- },
94
- r = function () {
95
- return t(!1);
96
- };
97
-
98
- function t(t) {
99
- var n = _.current,
100
- o = v(m.current),
101
- a = t ? o.addEventListener : o.removeEventListener;
102
- a(n ? "touchmove" : "mousemove", e), a(n ? "touchend" : "mouseup", r);
103
- }
104
-
105
- return [function (e) {
106
- var r = e.nativeEvent,
107
- n = m.current;
108
-
109
- if (n && (h(r), !function (e, r) {
110
- return r && !f(e);
111
- }(r, _.current) && n)) {
112
- if (f(r)) {
113
- _.current = !0;
114
- var o = r.changedTouches || [];
115
- o.length && (b.current = o[0].identifier);
116
- }
117
-
118
- n.focus(), g(d(n, r, b.current)), t(!0);
119
- }
120
- }, function (e) {
121
- var r = e.which || e.keyCode;
122
- r < 37 || r > 40 || (e.preventDefault(), p({
123
- left: 39 === r ? .05 : 37 === r ? -.05 : 0,
124
- top: 40 === r ? .05 : 38 === r ? -.05 : 0
125
- }));
126
- }, t];
127
- }, [p, g]),
128
- C = x[0],
129
- E = x[1],
130
- H = x[2];
131
-
132
- return React.useEffect(function () {
133
- return H;
134
- }, [H]), React__default["default"].createElement("div", u({}, s, {
135
- onTouchStart: C,
136
- onMouseDown: C,
137
- className: "react-colorful__interactive",
138
- ref: m,
139
- onKeyDown: E,
140
- tabIndex: 0,
141
- role: "slider"
142
- }));
143
- }),
144
- g = function (e) {
145
- return e.filter(Boolean).join(" ");
146
- },
147
- p = function (r) {
148
- var t = r.color,
149
- n = r.left,
150
- o = r.top,
151
- a = void 0 === o ? .5 : o,
152
- l = g(["react-colorful__pointer", r.className]);
153
- return React__default["default"].createElement("div", {
154
- className: l,
155
- style: {
156
- top: 100 * a + "%",
157
- left: 100 * n + "%"
158
- }
159
- }, React__default["default"].createElement("div", {
160
- className: "react-colorful__pointer-fill",
161
- style: {
162
- backgroundColor: t
163
- }
164
- }));
165
- },
166
- b = function (e, r, t) {
167
- return void 0 === r && (r = 0), void 0 === t && (t = Math.pow(10, r)), Math.round(t * e) / t;
168
- },
169
- _ = {
170
- grad: .9,
171
- turn: 360,
172
- rad: 360 / (2 * Math.PI)
173
- },
174
- x = function (e) {
175
- return "#" === e[0] && (e = e.substr(1)), e.length < 6 ? {
176
- r: parseInt(e[0] + e[0], 16),
177
- g: parseInt(e[1] + e[1], 16),
178
- b: parseInt(e[2] + e[2], 16),
179
- a: 1
180
- } : {
181
- r: parseInt(e.substr(0, 2), 16),
182
- g: parseInt(e.substr(2, 2), 16),
183
- b: parseInt(e.substr(4, 2), 16),
184
- a: 1
185
- };
186
- },
187
- C = function (e, r) {
188
- return void 0 === r && (r = "deg"), Number(e) * (_[r] || 1);
189
- },
190
- E = function (e) {
191
- var r = /hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);
192
- return r ? M({
193
- h: C(r[1], r[2]),
194
- s: Number(r[3]),
195
- l: Number(r[4]),
196
- a: void 0 === r[5] ? 1 : Number(r[5]) / (r[6] ? 100 : 1)
197
- }) : {
198
- h: 0,
199
- s: 0,
200
- v: 0,
201
- a: 1
202
- };
203
- },
204
- M = function (e) {
205
- var r = e.s,
206
- t = e.l;
207
- return {
208
- h: e.h,
209
- s: (r *= (t < 50 ? t : 100 - t) / 100) > 0 ? 2 * r / (t + r) * 100 : 0,
210
- v: t + r,
211
- a: e.a
212
- };
213
- },
214
- N = function (e) {
215
- var r = e.s,
216
- t = e.v,
217
- n = e.a,
218
- o = (200 - r) * t / 100;
219
- return {
220
- h: b(e.h),
221
- s: b(o > 0 && o < 200 ? r * t / 100 / (o <= 100 ? o : 200 - o) * 100 : 0),
222
- l: b(o / 2),
223
- a: b(n, 2)
224
- };
225
- },
226
- w = function (e) {
227
- var r = N(e);
228
- return "hsl(" + r.h + ", " + r.s + "%, " + r.l + "%)";
229
- },
230
- y = function (e) {
231
- var r = N(e);
232
- return "hsla(" + r.h + ", " + r.s + "%, " + r.l + "%, " + r.a + ")";
233
- },
234
- q = function (e) {
235
- var r = e.h,
236
- t = e.s,
237
- n = e.v,
238
- o = e.a;
239
- r = r / 360 * 6, t /= 100, n /= 100;
240
- var a = Math.floor(r),
241
- l = n * (1 - t),
242
- u = n * (1 - (r - a) * t),
243
- c = n * (1 - (1 - r + a) * t),
244
- i = a % 6;
245
- return {
246
- r: b(255 * [n, u, l, l, c, n][i]),
247
- g: b(255 * [c, n, n, u, l, l][i]),
248
- b: b(255 * [l, l, c, n, n, u][i]),
249
- a: b(o, 2)
250
- };
251
- },
252
- I = function (e) {
253
- var r = /rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e);
254
- return r ? B({
255
- r: Number(r[1]) / (r[2] ? 100 / 255 : 1),
256
- g: Number(r[3]) / (r[4] ? 100 / 255 : 1),
257
- b: Number(r[5]) / (r[6] ? 100 / 255 : 1),
258
- a: void 0 === r[7] ? 1 : Number(r[7]) / (r[8] ? 100 : 1)
259
- }) : {
260
- h: 0,
261
- s: 0,
262
- v: 0,
263
- a: 1
264
- };
265
- },
266
- z = function (e) {
267
- var r = e.toString(16);
268
- return r.length < 2 ? "0" + r : r;
269
- },
270
- B = function (e) {
271
- var r = e.r,
272
- t = e.g,
273
- n = e.b,
274
- o = e.a,
275
- a = Math.max(r, t, n),
276
- l = a - Math.min(r, t, n),
277
- u = l ? a === r ? (t - n) / l : a === t ? 2 + (n - r) / l : 4 + (r - t) / l : 0;
278
- return {
279
- h: b(60 * (u < 0 ? u + 6 : u)),
280
- s: b(a ? l / a * 100 : 0),
281
- v: b(a / 255 * 100),
282
- a: o
283
- };
284
- },
285
- K = React__default["default"].memo(function (r) {
286
- var t = r.hue,
287
- n = r.onChange,
288
- o = g(["react-colorful__hue", r.className]);
289
- return React__default["default"].createElement("div", {
290
- className: o
291
- }, React__default["default"].createElement(m, {
292
- onMove: function (e) {
293
- n({
294
- h: 360 * e.left
295
- });
296
- },
297
- onKey: function (e) {
298
- n({
299
- h: s(t + 360 * e.left, 0, 360)
300
- });
301
- },
302
- "aria-label": "Hue",
303
- "aria-valuetext": b(t)
304
- }, React__default["default"].createElement(p, {
305
- className: "react-colorful__hue-pointer",
306
- left: t / 360,
307
- color: w({
308
- h: t,
309
- s: 100,
310
- v: 100,
311
- a: 1
312
- })
313
- })));
314
- }),
315
- L = React__default["default"].memo(function (r) {
316
- var t = r.hsva,
317
- n = r.onChange,
318
- o = {
319
- backgroundColor: w({
320
- h: t.h,
321
- s: 100,
322
- v: 100,
323
- a: 1
324
- })
325
- };
326
- return React__default["default"].createElement("div", {
327
- className: "react-colorful__saturation",
328
- style: o
329
- }, React__default["default"].createElement(m, {
330
- onMove: function (e) {
331
- n({
332
- s: 100 * e.left,
333
- v: 100 - 100 * e.top
334
- });
335
- },
336
- onKey: function (e) {
337
- n({
338
- s: s(t.s + 100 * e.left, 0, 100),
339
- v: s(t.v - 100 * e.top, 0, 100)
340
- });
341
- },
342
- "aria-label": "Color",
343
- "aria-valuetext": "Saturation " + b(t.s) + "%, Brightness " + b(t.v) + "%"
344
- }, React__default["default"].createElement(p, {
345
- className: "react-colorful__saturation-pointer",
346
- top: 1 - t.v / 100,
347
- left: t.s / 100,
348
- color: w(t)
349
- })));
350
- }),
351
- A = function (e, r) {
352
- if (e === r) return !0;
353
-
354
- for (var t in e) if (e[t] !== r[t]) return !1;
355
-
356
- return !0;
357
- },
358
- S = function (e, r) {
359
- return e.replace(/\s/g, "") === r.replace(/\s/g, "");
360
- };
361
-
362
- function T(e, t, l) {
363
- var u = i(l),
364
- c = React.useState(function () {
365
- return e.toHsva(t);
366
- }),
367
- s = c[0],
368
- f = c[1],
369
- v = React.useRef({
370
- color: t,
371
- hsva: s
372
- });
373
- React.useEffect(function () {
374
- if (!e.equal(t, v.current.color)) {
375
- var r = e.toHsva(t);
376
- v.current = {
377
- hsva: r,
378
- color: t
379
- }, f(r);
380
- }
381
- }, [t, e]), React.useEffect(function () {
382
- var r;
383
- A(s, v.current.hsva) || e.equal(r = e.fromHsva(s), v.current.color) || (v.current = {
384
- hsva: s,
385
- color: r
386
- }, u(r));
387
- }, [s, e, u]);
388
- var d = React.useCallback(function (e) {
389
- f(function (r) {
390
- return Object.assign({}, r, e);
391
- });
392
- }, []);
393
- return [s, d];
394
- }
395
-
396
- var P = "undefined" != typeof window ? React.useLayoutEffect : React.useEffect,
397
- X = function () {
398
- return "undefined" != typeof __webpack_nonce__ ? __webpack_nonce__ : void 0;
399
- },
400
- R = new Map(),
401
- V = function (e) {
402
- P(function () {
403
- var r = e.current ? e.current.ownerDocument : document;
404
-
405
- if (void 0 !== r && !R.has(r)) {
406
- var t = r.createElement("style");
407
- t.innerHTML = '.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image: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>\')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}', R.set(r, t);
408
- var n = X();
409
- n && t.setAttribute("nonce", n), r.head.appendChild(t);
410
- }
411
- }, []);
412
- },
413
- $ = function (t) {
414
- var n = t.className,
415
- o = t.colorModel,
416
- a = t.color,
417
- l = void 0 === a ? o.defaultColor : a,
418
- i = t.onChange,
419
- s = c(t, ["className", "colorModel", "color", "onChange"]),
420
- f = React.useRef(null);
421
- V(f);
422
- var v = T(o, l, i),
423
- d = v[0],
424
- h = v[1],
425
- m = g(["react-colorful", n]);
426
- return React__default["default"].createElement("div", u({}, s, {
427
- ref: f,
428
- className: m
429
- }), React__default["default"].createElement(L, {
430
- hsva: d,
431
- onChange: h
432
- }), React__default["default"].createElement(K, {
433
- hue: d.h,
434
- onChange: h,
435
- className: "react-colorful__last-control"
436
- }));
437
- },
438
- G = {
439
- defaultColor: "000",
440
- toHsva: function (e) {
441
- return B(x(e));
442
- },
443
- fromHsva: function (e) {
444
- return t = (r = q(e)).g, n = r.b, "#" + z(r.r) + z(t) + z(n);
445
- var r, t, n;
446
- },
447
- equal: function (e, r) {
448
- return e.toLowerCase() === r.toLowerCase() || A(x(e), x(r));
449
- }
450
- },
451
- J = function (r) {
452
- return React__default["default"].createElement($, u({}, r, {
453
- colorModel: G
454
- }));
455
- },
456
- Q = function (r) {
457
- var t = r.className,
458
- n = r.hsva,
459
- o = r.onChange,
460
- a = {
461
- backgroundImage: "linear-gradient(90deg, " + y(Object.assign({}, n, {
462
- a: 0
463
- })) + ", " + y(Object.assign({}, n, {
464
- a: 1
465
- })) + ")"
466
- },
467
- l = g(["react-colorful__alpha", t]);
468
- return React__default["default"].createElement("div", {
469
- className: l
470
- }, React__default["default"].createElement("div", {
471
- className: "react-colorful__alpha-gradient",
472
- style: a
473
- }), React__default["default"].createElement(m, {
474
- onMove: function (e) {
475
- o({
476
- a: e.left
477
- });
478
- },
479
- onKey: function (e) {
480
- o({
481
- a: s(n.a + e.left)
482
- });
483
- },
484
- "aria-label": "Alpha",
485
- "aria-valuetext": b(100 * n.a) + "%"
486
- }, React__default["default"].createElement(p, {
487
- className: "react-colorful__alpha-pointer",
488
- left: n.a,
489
- color: y(n)
490
- })));
491
- },
492
- U = function (t) {
493
- var n = t.className,
494
- o = t.colorModel,
495
- a = t.color,
496
- l = void 0 === a ? o.defaultColor : a,
497
- i = t.onChange,
498
- s = c(t, ["className", "colorModel", "color", "onChange"]),
499
- f = React.useRef(null);
500
- V(f);
501
- var v = T(o, l, i),
502
- d = v[0],
503
- h = v[1],
504
- m = g(["react-colorful", n]);
505
- return React__default["default"].createElement("div", u({}, s, {
506
- ref: f,
507
- className: m
508
- }), React__default["default"].createElement(L, {
509
- hsva: d,
510
- onChange: h
511
- }), React__default["default"].createElement(K, {
512
- hue: d.h,
513
- onChange: h
514
- }), React__default["default"].createElement(Q, {
515
- hsva: d,
516
- onChange: h,
517
- className: "react-colorful__last-control"
518
- }));
519
- },
520
- ee = {
521
- defaultColor: "hsla(0, 0%, 0%, 1)",
522
- toHsva: E,
523
- fromHsva: y,
524
- equal: S
525
- },
526
- re = function (r) {
527
- return React__default["default"].createElement(U, u({}, r, {
528
- colorModel: ee
529
- }));
530
- },
531
- ge = {
532
- defaultColor: "rgba(0, 0, 0, 1)",
533
- toHsva: I,
534
- fromHsva: function (e) {
535
- var r = q(e);
536
- return "rgba(" + r.r + ", " + r.g + ", " + r.b + ", " + r.a + ")";
537
- },
538
- equal: S
539
- },
540
- pe = function (r) {
541
- return React__default["default"].createElement(U, u({}, r, {
542
- colorModel: ge
543
- }));
544
- };
545
-
546
- var colorName = {
547
- "aliceblue": [240, 248, 255],
548
- "antiquewhite": [250, 235, 215],
549
- "aqua": [0, 255, 255],
550
- "aquamarine": [127, 255, 212],
551
- "azure": [240, 255, 255],
552
- "beige": [245, 245, 220],
553
- "bisque": [255, 228, 196],
554
- "black": [0, 0, 0],
555
- "blanchedalmond": [255, 235, 205],
556
- "blue": [0, 0, 255],
557
- "blueviolet": [138, 43, 226],
558
- "brown": [165, 42, 42],
559
- "burlywood": [222, 184, 135],
560
- "cadetblue": [95, 158, 160],
561
- "chartreuse": [127, 255, 0],
562
- "chocolate": [210, 105, 30],
563
- "coral": [255, 127, 80],
564
- "cornflowerblue": [100, 149, 237],
565
- "cornsilk": [255, 248, 220],
566
- "crimson": [220, 20, 60],
567
- "cyan": [0, 255, 255],
568
- "darkblue": [0, 0, 139],
569
- "darkcyan": [0, 139, 139],
570
- "darkgoldenrod": [184, 134, 11],
571
- "darkgray": [169, 169, 169],
572
- "darkgreen": [0, 100, 0],
573
- "darkgrey": [169, 169, 169],
574
- "darkkhaki": [189, 183, 107],
575
- "darkmagenta": [139, 0, 139],
576
- "darkolivegreen": [85, 107, 47],
577
- "darkorange": [255, 140, 0],
578
- "darkorchid": [153, 50, 204],
579
- "darkred": [139, 0, 0],
580
- "darksalmon": [233, 150, 122],
581
- "darkseagreen": [143, 188, 143],
582
- "darkslateblue": [72, 61, 139],
583
- "darkslategray": [47, 79, 79],
584
- "darkslategrey": [47, 79, 79],
585
- "darkturquoise": [0, 206, 209],
586
- "darkviolet": [148, 0, 211],
587
- "deeppink": [255, 20, 147],
588
- "deepskyblue": [0, 191, 255],
589
- "dimgray": [105, 105, 105],
590
- "dimgrey": [105, 105, 105],
591
- "dodgerblue": [30, 144, 255],
592
- "firebrick": [178, 34, 34],
593
- "floralwhite": [255, 250, 240],
594
- "forestgreen": [34, 139, 34],
595
- "fuchsia": [255, 0, 255],
596
- "gainsboro": [220, 220, 220],
597
- "ghostwhite": [248, 248, 255],
598
- "gold": [255, 215, 0],
599
- "goldenrod": [218, 165, 32],
600
- "gray": [128, 128, 128],
601
- "green": [0, 128, 0],
602
- "greenyellow": [173, 255, 47],
603
- "grey": [128, 128, 128],
604
- "honeydew": [240, 255, 240],
605
- "hotpink": [255, 105, 180],
606
- "indianred": [205, 92, 92],
607
- "indigo": [75, 0, 130],
608
- "ivory": [255, 255, 240],
609
- "khaki": [240, 230, 140],
610
- "lavender": [230, 230, 250],
611
- "lavenderblush": [255, 240, 245],
612
- "lawngreen": [124, 252, 0],
613
- "lemonchiffon": [255, 250, 205],
614
- "lightblue": [173, 216, 230],
615
- "lightcoral": [240, 128, 128],
616
- "lightcyan": [224, 255, 255],
617
- "lightgoldenrodyellow": [250, 250, 210],
618
- "lightgray": [211, 211, 211],
619
- "lightgreen": [144, 238, 144],
620
- "lightgrey": [211, 211, 211],
621
- "lightpink": [255, 182, 193],
622
- "lightsalmon": [255, 160, 122],
623
- "lightseagreen": [32, 178, 170],
624
- "lightskyblue": [135, 206, 250],
625
- "lightslategray": [119, 136, 153],
626
- "lightslategrey": [119, 136, 153],
627
- "lightsteelblue": [176, 196, 222],
628
- "lightyellow": [255, 255, 224],
629
- "lime": [0, 255, 0],
630
- "limegreen": [50, 205, 50],
631
- "linen": [250, 240, 230],
632
- "magenta": [255, 0, 255],
633
- "maroon": [128, 0, 0],
634
- "mediumaquamarine": [102, 205, 170],
635
- "mediumblue": [0, 0, 205],
636
- "mediumorchid": [186, 85, 211],
637
- "mediumpurple": [147, 112, 219],
638
- "mediumseagreen": [60, 179, 113],
639
- "mediumslateblue": [123, 104, 238],
640
- "mediumspringgreen": [0, 250, 154],
641
- "mediumturquoise": [72, 209, 204],
642
- "mediumvioletred": [199, 21, 133],
643
- "midnightblue": [25, 25, 112],
644
- "mintcream": [245, 255, 250],
645
- "mistyrose": [255, 228, 225],
646
- "moccasin": [255, 228, 181],
647
- "navajowhite": [255, 222, 173],
648
- "navy": [0, 0, 128],
649
- "oldlace": [253, 245, 230],
650
- "olive": [128, 128, 0],
651
- "olivedrab": [107, 142, 35],
652
- "orange": [255, 165, 0],
653
- "orangered": [255, 69, 0],
654
- "orchid": [218, 112, 214],
655
- "palegoldenrod": [238, 232, 170],
656
- "palegreen": [152, 251, 152],
657
- "paleturquoise": [175, 238, 238],
658
- "palevioletred": [219, 112, 147],
659
- "papayawhip": [255, 239, 213],
660
- "peachpuff": [255, 218, 185],
661
- "peru": [205, 133, 63],
662
- "pink": [255, 192, 203],
663
- "plum": [221, 160, 221],
664
- "powderblue": [176, 224, 230],
665
- "purple": [128, 0, 128],
666
- "rebeccapurple": [102, 51, 153],
667
- "red": [255, 0, 0],
668
- "rosybrown": [188, 143, 143],
669
- "royalblue": [65, 105, 225],
670
- "saddlebrown": [139, 69, 19],
671
- "salmon": [250, 128, 114],
672
- "sandybrown": [244, 164, 96],
673
- "seagreen": [46, 139, 87],
674
- "seashell": [255, 245, 238],
675
- "sienna": [160, 82, 45],
676
- "silver": [192, 192, 192],
677
- "skyblue": [135, 206, 235],
678
- "slateblue": [106, 90, 205],
679
- "slategray": [112, 128, 144],
680
- "slategrey": [112, 128, 144],
681
- "snow": [255, 250, 250],
682
- "springgreen": [0, 255, 127],
683
- "steelblue": [70, 130, 180],
684
- "tan": [210, 180, 140],
685
- "teal": [0, 128, 128],
686
- "thistle": [216, 191, 216],
687
- "tomato": [255, 99, 71],
688
- "turquoise": [64, 224, 208],
689
- "violet": [238, 130, 238],
690
- "wheat": [245, 222, 179],
691
- "white": [255, 255, 255],
692
- "whitesmoke": [245, 245, 245],
693
- "yellow": [255, 255, 0],
694
- "yellowgreen": [154, 205, 50]
695
- };
696
- /* MIT license */
697
-
698
- /* eslint-disable no-mixed-operators */
699
-
700
- const cssKeywords = colorName; // NOTE: conversions should only return primitive values (i.e. arrays, or
701
- // values that give correct `typeof` results).
702
- // do not use box values types (i.e. Number(), String(), etc.)
703
-
704
- const reverseKeywords = {};
705
-
706
- for (const key of Object.keys(cssKeywords)) {
707
- reverseKeywords[cssKeywords[key]] = key;
708
- }
709
-
710
- const convert$1 = {
711
- rgb: {
712
- channels: 3,
713
- labels: 'rgb'
714
- },
715
- hsl: {
716
- channels: 3,
717
- labels: 'hsl'
718
- },
719
- hsv: {
720
- channels: 3,
721
- labels: 'hsv'
722
- },
723
- hwb: {
724
- channels: 3,
725
- labels: 'hwb'
726
- },
727
- cmyk: {
728
- channels: 4,
729
- labels: 'cmyk'
730
- },
731
- xyz: {
732
- channels: 3,
733
- labels: 'xyz'
734
- },
735
- lab: {
736
- channels: 3,
737
- labels: 'lab'
738
- },
739
- lch: {
740
- channels: 3,
741
- labels: 'lch'
742
- },
743
- hex: {
744
- channels: 1,
745
- labels: ['hex']
746
- },
747
- keyword: {
748
- channels: 1,
749
- labels: ['keyword']
750
- },
751
- ansi16: {
752
- channels: 1,
753
- labels: ['ansi16']
754
- },
755
- ansi256: {
756
- channels: 1,
757
- labels: ['ansi256']
758
- },
759
- hcg: {
760
- channels: 3,
761
- labels: ['h', 'c', 'g']
762
- },
763
- apple: {
764
- channels: 3,
765
- labels: ['r16', 'g16', 'b16']
766
- },
767
- gray: {
768
- channels: 1,
769
- labels: ['gray']
770
- }
771
- };
772
- var conversions$2 = convert$1; // Hide .channels and .labels properties
773
-
774
- for (const model of Object.keys(convert$1)) {
775
- if (!('channels' in convert$1[model])) {
776
- throw new Error('missing channels property: ' + model);
777
- }
778
-
779
- if (!('labels' in convert$1[model])) {
780
- throw new Error('missing channel labels property: ' + model);
781
- }
782
-
783
- if (convert$1[model].labels.length !== convert$1[model].channels) {
784
- throw new Error('channel and label counts mismatch: ' + model);
785
- }
786
-
787
- const {
788
- channels,
789
- labels
790
- } = convert$1[model];
791
- delete convert$1[model].channels;
792
- delete convert$1[model].labels;
793
- Object.defineProperty(convert$1[model], 'channels', {
794
- value: channels
795
- });
796
- Object.defineProperty(convert$1[model], 'labels', {
797
- value: labels
798
- });
799
- }
800
-
801
- convert$1.rgb.hsl = function (rgb) {
802
- const r = rgb[0] / 255;
803
- const g = rgb[1] / 255;
804
- const b = rgb[2] / 255;
805
- const min = Math.min(r, g, b);
806
- const max = Math.max(r, g, b);
807
- const delta = max - min;
808
- let h;
809
- let s;
810
-
811
- if (max === min) {
812
- h = 0;
813
- } else if (r === max) {
814
- h = (g - b) / delta;
815
- } else if (g === max) {
816
- h = 2 + (b - r) / delta;
817
- } else if (b === max) {
818
- h = 4 + (r - g) / delta;
819
- }
820
-
821
- h = Math.min(h * 60, 360);
822
-
823
- if (h < 0) {
824
- h += 360;
825
- }
826
-
827
- const l = (min + max) / 2;
828
-
829
- if (max === min) {
830
- s = 0;
831
- } else if (l <= 0.5) {
832
- s = delta / (max + min);
833
- } else {
834
- s = delta / (2 - max - min);
835
- }
836
-
837
- return [h, s * 100, l * 100];
838
- };
839
-
840
- convert$1.rgb.hsv = function (rgb) {
841
- let rdif;
842
- let gdif;
843
- let bdif;
844
- let h;
845
- let s;
846
- const r = rgb[0] / 255;
847
- const g = rgb[1] / 255;
848
- const b = rgb[2] / 255;
849
- const v = Math.max(r, g, b);
850
- const diff = v - Math.min(r, g, b);
851
-
852
- const diffc = function (c) {
853
- return (v - c) / 6 / diff + 1 / 2;
854
- };
855
-
856
- if (diff === 0) {
857
- h = 0;
858
- s = 0;
859
- } else {
860
- s = diff / v;
861
- rdif = diffc(r);
862
- gdif = diffc(g);
863
- bdif = diffc(b);
864
-
865
- if (r === v) {
866
- h = bdif - gdif;
867
- } else if (g === v) {
868
- h = 1 / 3 + rdif - bdif;
869
- } else if (b === v) {
870
- h = 2 / 3 + gdif - rdif;
871
- }
872
-
873
- if (h < 0) {
874
- h += 1;
875
- } else if (h > 1) {
876
- h -= 1;
877
- }
878
- }
879
-
880
- return [h * 360, s * 100, v * 100];
881
- };
882
-
883
- convert$1.rgb.hwb = function (rgb) {
884
- const r = rgb[0];
885
- const g = rgb[1];
886
- let b = rgb[2];
887
- const h = convert$1.rgb.hsl(rgb)[0];
888
- const w = 1 / 255 * Math.min(r, Math.min(g, b));
889
- b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
890
- return [h, w * 100, b * 100];
891
- };
892
-
893
- convert$1.rgb.cmyk = function (rgb) {
894
- const r = rgb[0] / 255;
895
- const g = rgb[1] / 255;
896
- const b = rgb[2] / 255;
897
- const k = Math.min(1 - r, 1 - g, 1 - b);
898
- const c = (1 - r - k) / (1 - k) || 0;
899
- const m = (1 - g - k) / (1 - k) || 0;
900
- const y = (1 - b - k) / (1 - k) || 0;
901
- return [c * 100, m * 100, y * 100, k * 100];
902
- };
903
-
904
- function comparativeDistance(x, y) {
905
- /*
906
- See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance
907
- */
908
- return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
909
- }
910
-
911
- convert$1.rgb.keyword = function (rgb) {
912
- const reversed = reverseKeywords[rgb];
913
-
914
- if (reversed) {
915
- return reversed;
916
- }
917
-
918
- let currentClosestDistance = Infinity;
919
- let currentClosestKeyword;
920
-
921
- for (const keyword of Object.keys(cssKeywords)) {
922
- const value = cssKeywords[keyword]; // Compute comparative distance
923
-
924
- const distance = comparativeDistance(rgb, value); // Check if its less, if so set as closest
925
-
926
- if (distance < currentClosestDistance) {
927
- currentClosestDistance = distance;
928
- currentClosestKeyword = keyword;
929
- }
930
- }
931
-
932
- return currentClosestKeyword;
933
- };
934
-
935
- convert$1.keyword.rgb = function (keyword) {
936
- return cssKeywords[keyword];
937
- };
938
-
939
- convert$1.rgb.xyz = function (rgb) {
940
- let r = rgb[0] / 255;
941
- let g = rgb[1] / 255;
942
- let b = rgb[2] / 255; // Assume sRGB
943
-
944
- r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
945
- g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
946
- b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
947
- const x = r * 0.4124 + g * 0.3576 + b * 0.1805;
948
- const y = r * 0.2126 + g * 0.7152 + b * 0.0722;
949
- const z = r * 0.0193 + g * 0.1192 + b * 0.9505;
950
- return [x * 100, y * 100, z * 100];
951
- };
952
-
953
- convert$1.rgb.lab = function (rgb) {
954
- const xyz = convert$1.rgb.xyz(rgb);
955
- let x = xyz[0];
956
- let y = xyz[1];
957
- let z = xyz[2];
958
- x /= 95.047;
959
- y /= 100;
960
- z /= 108.883;
961
- x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
962
- y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
963
- z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
964
- const l = 116 * y - 16;
965
- const a = 500 * (x - y);
966
- const b = 200 * (y - z);
967
- return [l, a, b];
968
- };
969
-
970
- convert$1.hsl.rgb = function (hsl) {
971
- const h = hsl[0] / 360;
972
- const s = hsl[1] / 100;
973
- const l = hsl[2] / 100;
974
- let t2;
975
- let t3;
976
- let val;
977
-
978
- if (s === 0) {
979
- val = l * 255;
980
- return [val, val, val];
981
- }
982
-
983
- if (l < 0.5) {
984
- t2 = l * (1 + s);
985
- } else {
986
- t2 = l + s - l * s;
987
- }
988
-
989
- const t1 = 2 * l - t2;
990
- const rgb = [0, 0, 0];
991
-
992
- for (let i = 0; i < 3; i++) {
993
- t3 = h + 1 / 3 * -(i - 1);
994
-
995
- if (t3 < 0) {
996
- t3++;
997
- }
998
-
999
- if (t3 > 1) {
1000
- t3--;
1001
- }
1002
-
1003
- if (6 * t3 < 1) {
1004
- val = t1 + (t2 - t1) * 6 * t3;
1005
- } else if (2 * t3 < 1) {
1006
- val = t2;
1007
- } else if (3 * t3 < 2) {
1008
- val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
1009
- } else {
1010
- val = t1;
1011
- }
1012
-
1013
- rgb[i] = val * 255;
1014
- }
1015
-
1016
- return rgb;
1017
- };
1018
-
1019
- convert$1.hsl.hsv = function (hsl) {
1020
- const h = hsl[0];
1021
- let s = hsl[1] / 100;
1022
- let l = hsl[2] / 100;
1023
- let smin = s;
1024
- const lmin = Math.max(l, 0.01);
1025
- l *= 2;
1026
- s *= l <= 1 ? l : 2 - l;
1027
- smin *= lmin <= 1 ? lmin : 2 - lmin;
1028
- const v = (l + s) / 2;
1029
- const sv = l === 0 ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
1030
- return [h, sv * 100, v * 100];
1031
- };
1032
-
1033
- convert$1.hsv.rgb = function (hsv) {
1034
- const h = hsv[0] / 60;
1035
- const s = hsv[1] / 100;
1036
- let v = hsv[2] / 100;
1037
- const hi = Math.floor(h) % 6;
1038
- const f = h - Math.floor(h);
1039
- const p = 255 * v * (1 - s);
1040
- const q = 255 * v * (1 - s * f);
1041
- const t = 255 * v * (1 - s * (1 - f));
1042
- v *= 255;
1043
-
1044
- switch (hi) {
1045
- case 0:
1046
- return [v, t, p];
1047
-
1048
- case 1:
1049
- return [q, v, p];
1050
-
1051
- case 2:
1052
- return [p, v, t];
1053
-
1054
- case 3:
1055
- return [p, q, v];
1056
-
1057
- case 4:
1058
- return [t, p, v];
1059
-
1060
- case 5:
1061
- return [v, p, q];
1062
- }
1063
- };
1064
-
1065
- convert$1.hsv.hsl = function (hsv) {
1066
- const h = hsv[0];
1067
- const s = hsv[1] / 100;
1068
- const v = hsv[2] / 100;
1069
- const vmin = Math.max(v, 0.01);
1070
- let sl;
1071
- let l;
1072
- l = (2 - s) * v;
1073
- const lmin = (2 - s) * vmin;
1074
- sl = s * vmin;
1075
- sl /= lmin <= 1 ? lmin : 2 - lmin;
1076
- sl = sl || 0;
1077
- l /= 2;
1078
- return [h, sl * 100, l * 100];
1079
- }; // http://dev.w3.org/csswg/css-color/#hwb-to-rgb
1080
-
1081
-
1082
- convert$1.hwb.rgb = function (hwb) {
1083
- const h = hwb[0] / 360;
1084
- let wh = hwb[1] / 100;
1085
- let bl = hwb[2] / 100;
1086
- const ratio = wh + bl;
1087
- let f; // Wh + bl cant be > 1
1088
-
1089
- if (ratio > 1) {
1090
- wh /= ratio;
1091
- bl /= ratio;
1092
- }
1093
-
1094
- const i = Math.floor(6 * h);
1095
- const v = 1 - bl;
1096
- f = 6 * h - i;
1097
-
1098
- if ((i & 0x01) !== 0) {
1099
- f = 1 - f;
1100
- }
1101
-
1102
- const n = wh + f * (v - wh); // Linear interpolation
1103
-
1104
- let r;
1105
- let g;
1106
- let b;
1107
- /* eslint-disable max-statements-per-line,no-multi-spaces */
1108
-
1109
- switch (i) {
1110
- default:
1111
- case 6:
1112
- case 0:
1113
- r = v;
1114
- g = n;
1115
- b = wh;
1116
- break;
1117
-
1118
- case 1:
1119
- r = n;
1120
- g = v;
1121
- b = wh;
1122
- break;
1123
-
1124
- case 2:
1125
- r = wh;
1126
- g = v;
1127
- b = n;
1128
- break;
1129
-
1130
- case 3:
1131
- r = wh;
1132
- g = n;
1133
- b = v;
1134
- break;
1135
-
1136
- case 4:
1137
- r = n;
1138
- g = wh;
1139
- b = v;
1140
- break;
1141
-
1142
- case 5:
1143
- r = v;
1144
- g = wh;
1145
- b = n;
1146
- break;
1147
- }
1148
- /* eslint-enable max-statements-per-line,no-multi-spaces */
1149
-
1150
-
1151
- return [r * 255, g * 255, b * 255];
1152
- };
1153
-
1154
- convert$1.cmyk.rgb = function (cmyk) {
1155
- const c = cmyk[0] / 100;
1156
- const m = cmyk[1] / 100;
1157
- const y = cmyk[2] / 100;
1158
- const k = cmyk[3] / 100;
1159
- const r = 1 - Math.min(1, c * (1 - k) + k);
1160
- const g = 1 - Math.min(1, m * (1 - k) + k);
1161
- const b = 1 - Math.min(1, y * (1 - k) + k);
1162
- return [r * 255, g * 255, b * 255];
1163
- };
1164
-
1165
- convert$1.xyz.rgb = function (xyz) {
1166
- const x = xyz[0] / 100;
1167
- const y = xyz[1] / 100;
1168
- const z = xyz[2] / 100;
1169
- let r;
1170
- let g;
1171
- let b;
1172
- r = x * 3.2406 + y * -1.5372 + z * -0.4986;
1173
- g = x * -0.9689 + y * 1.8758 + z * 0.0415;
1174
- b = x * 0.0557 + y * -0.2040 + z * 1.0570; // Assume sRGB
1175
-
1176
- r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : r * 12.92;
1177
- g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : g * 12.92;
1178
- b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : b * 12.92;
1179
- r = Math.min(Math.max(0, r), 1);
1180
- g = Math.min(Math.max(0, g), 1);
1181
- b = Math.min(Math.max(0, b), 1);
1182
- return [r * 255, g * 255, b * 255];
1183
- };
1184
-
1185
- convert$1.xyz.lab = function (xyz) {
1186
- let x = xyz[0];
1187
- let y = xyz[1];
1188
- let z = xyz[2];
1189
- x /= 95.047;
1190
- y /= 100;
1191
- z /= 108.883;
1192
- x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
1193
- y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
1194
- z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
1195
- const l = 116 * y - 16;
1196
- const a = 500 * (x - y);
1197
- const b = 200 * (y - z);
1198
- return [l, a, b];
1199
- };
1200
-
1201
- convert$1.lab.xyz = function (lab) {
1202
- const l = lab[0];
1203
- const a = lab[1];
1204
- const b = lab[2];
1205
- let x;
1206
- let y;
1207
- let z;
1208
- y = (l + 16) / 116;
1209
- x = a / 500 + y;
1210
- z = y - b / 200;
1211
- const y2 = y ** 3;
1212
- const x2 = x ** 3;
1213
- const z2 = z ** 3;
1214
- y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1215
- x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1216
- z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1217
- x *= 95.047;
1218
- y *= 100;
1219
- z *= 108.883;
1220
- return [x, y, z];
1221
- };
1222
-
1223
- convert$1.lab.lch = function (lab) {
1224
- const l = lab[0];
1225
- const a = lab[1];
1226
- const b = lab[2];
1227
- let h;
1228
- const hr = Math.atan2(b, a);
1229
- h = hr * 360 / 2 / Math.PI;
1230
-
1231
- if (h < 0) {
1232
- h += 360;
1233
- }
1234
-
1235
- const c = Math.sqrt(a * a + b * b);
1236
- return [l, c, h];
1237
- };
1238
-
1239
- convert$1.lch.lab = function (lch) {
1240
- const l = lch[0];
1241
- const c = lch[1];
1242
- const h = lch[2];
1243
- const hr = h / 360 * 2 * Math.PI;
1244
- const a = c * Math.cos(hr);
1245
- const b = c * Math.sin(hr);
1246
- return [l, a, b];
1247
- };
1248
-
1249
- convert$1.rgb.ansi16 = function (args, saturation = null) {
1250
- const [r, g, b] = args;
1251
- let value = saturation === null ? convert$1.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization
1252
-
1253
- value = Math.round(value / 50);
1254
-
1255
- if (value === 0) {
1256
- return 30;
1257
- }
1258
-
1259
- let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
1260
-
1261
- if (value === 2) {
1262
- ansi += 60;
1263
- }
1264
-
1265
- return ansi;
1266
- };
1267
-
1268
- convert$1.hsv.ansi16 = function (args) {
1269
- // Optimization here; we already know the value and don't need to get
1270
- // it converted for us.
1271
- return convert$1.rgb.ansi16(convert$1.hsv.rgb(args), args[2]);
1272
- };
1273
-
1274
- convert$1.rgb.ansi256 = function (args) {
1275
- const r = args[0];
1276
- const g = args[1];
1277
- const b = args[2]; // We use the extended greyscale palette here, with the exception of
1278
- // black and white. normal palette only has 4 greyscale shades.
1279
-
1280
- if (r === g && g === b) {
1281
- if (r < 8) {
1282
- return 16;
1283
- }
1284
-
1285
- if (r > 248) {
1286
- return 231;
1287
- }
1288
-
1289
- return Math.round((r - 8) / 247 * 24) + 232;
1290
- }
1291
-
1292
- const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
1293
- return ansi;
1294
- };
1295
-
1296
- convert$1.ansi16.rgb = function (args) {
1297
- let color = args % 10; // Handle greyscale
1298
-
1299
- if (color === 0 || color === 7) {
1300
- if (args > 50) {
1301
- color += 3.5;
1302
- }
1303
-
1304
- color = color / 10.5 * 255;
1305
- return [color, color, color];
1306
- }
1307
-
1308
- const mult = (~~(args > 50) + 1) * 0.5;
1309
- const r = (color & 1) * mult * 255;
1310
- const g = (color >> 1 & 1) * mult * 255;
1311
- const b = (color >> 2 & 1) * mult * 255;
1312
- return [r, g, b];
1313
- };
1314
-
1315
- convert$1.ansi256.rgb = function (args) {
1316
- // Handle greyscale
1317
- if (args >= 232) {
1318
- const c = (args - 232) * 10 + 8;
1319
- return [c, c, c];
1320
- }
1321
-
1322
- args -= 16;
1323
- let rem;
1324
- const r = Math.floor(args / 36) / 5 * 255;
1325
- const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1326
- const b = rem % 6 / 5 * 255;
1327
- return [r, g, b];
1328
- };
1329
-
1330
- convert$1.rgb.hex = function (args) {
1331
- const integer = ((Math.round(args[0]) & 0xFF) << 16) + ((Math.round(args[1]) & 0xFF) << 8) + (Math.round(args[2]) & 0xFF);
1332
- const string = integer.toString(16).toUpperCase();
1333
- return '000000'.substring(string.length) + string;
1334
- };
1335
-
1336
- convert$1.hex.rgb = function (args) {
1337
- const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1338
-
1339
- if (!match) {
1340
- return [0, 0, 0];
1341
- }
1342
-
1343
- let colorString = match[0];
1344
-
1345
- if (match[0].length === 3) {
1346
- colorString = colorString.split('').map(char => {
1347
- return char + char;
1348
- }).join('');
1349
- }
1350
-
1351
- const integer = parseInt(colorString, 16);
1352
- const r = integer >> 16 & 0xFF;
1353
- const g = integer >> 8 & 0xFF;
1354
- const b = integer & 0xFF;
1355
- return [r, g, b];
1356
- };
1357
-
1358
- convert$1.rgb.hcg = function (rgb) {
1359
- const r = rgb[0] / 255;
1360
- const g = rgb[1] / 255;
1361
- const b = rgb[2] / 255;
1362
- const max = Math.max(Math.max(r, g), b);
1363
- const min = Math.min(Math.min(r, g), b);
1364
- const chroma = max - min;
1365
- let grayscale;
1366
- let hue;
1367
-
1368
- if (chroma < 1) {
1369
- grayscale = min / (1 - chroma);
1370
- } else {
1371
- grayscale = 0;
1372
- }
1373
-
1374
- if (chroma <= 0) {
1375
- hue = 0;
1376
- } else if (max === r) {
1377
- hue = (g - b) / chroma % 6;
1378
- } else if (max === g) {
1379
- hue = 2 + (b - r) / chroma;
1380
- } else {
1381
- hue = 4 + (r - g) / chroma;
1382
- }
1383
-
1384
- hue /= 6;
1385
- hue %= 1;
1386
- return [hue * 360, chroma * 100, grayscale * 100];
1387
- };
1388
-
1389
- convert$1.hsl.hcg = function (hsl) {
1390
- const s = hsl[1] / 100;
1391
- const l = hsl[2] / 100;
1392
- const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
1393
- let f = 0;
1394
-
1395
- if (c < 1.0) {
1396
- f = (l - 0.5 * c) / (1.0 - c);
1397
- }
1398
-
1399
- return [hsl[0], c * 100, f * 100];
1400
- };
1401
-
1402
- convert$1.hsv.hcg = function (hsv) {
1403
- const s = hsv[1] / 100;
1404
- const v = hsv[2] / 100;
1405
- const c = s * v;
1406
- let f = 0;
1407
-
1408
- if (c < 1.0) {
1409
- f = (v - c) / (1 - c);
1410
- }
1411
-
1412
- return [hsv[0], c * 100, f * 100];
1413
- };
1414
-
1415
- convert$1.hcg.rgb = function (hcg) {
1416
- const h = hcg[0] / 360;
1417
- const c = hcg[1] / 100;
1418
- const g = hcg[2] / 100;
1419
-
1420
- if (c === 0.0) {
1421
- return [g * 255, g * 255, g * 255];
1422
- }
1423
-
1424
- const pure = [0, 0, 0];
1425
- const hi = h % 1 * 6;
1426
- const v = hi % 1;
1427
- const w = 1 - v;
1428
- let mg = 0;
1429
- /* eslint-disable max-statements-per-line */
1430
-
1431
- switch (Math.floor(hi)) {
1432
- case 0:
1433
- pure[0] = 1;
1434
- pure[1] = v;
1435
- pure[2] = 0;
1436
- break;
1437
-
1438
- case 1:
1439
- pure[0] = w;
1440
- pure[1] = 1;
1441
- pure[2] = 0;
1442
- break;
1443
-
1444
- case 2:
1445
- pure[0] = 0;
1446
- pure[1] = 1;
1447
- pure[2] = v;
1448
- break;
1449
-
1450
- case 3:
1451
- pure[0] = 0;
1452
- pure[1] = w;
1453
- pure[2] = 1;
1454
- break;
1455
-
1456
- case 4:
1457
- pure[0] = v;
1458
- pure[1] = 0;
1459
- pure[2] = 1;
1460
- break;
1461
-
1462
- default:
1463
- pure[0] = 1;
1464
- pure[1] = 0;
1465
- pure[2] = w;
1466
- }
1467
- /* eslint-enable max-statements-per-line */
1468
-
1469
-
1470
- mg = (1.0 - c) * g;
1471
- return [(c * pure[0] + mg) * 255, (c * pure[1] + mg) * 255, (c * pure[2] + mg) * 255];
1472
- };
1473
-
1474
- convert$1.hcg.hsv = function (hcg) {
1475
- const c = hcg[1] / 100;
1476
- const g = hcg[2] / 100;
1477
- const v = c + g * (1.0 - c);
1478
- let f = 0;
1479
-
1480
- if (v > 0.0) {
1481
- f = c / v;
1482
- }
1483
-
1484
- return [hcg[0], f * 100, v * 100];
1485
- };
1486
-
1487
- convert$1.hcg.hsl = function (hcg) {
1488
- const c = hcg[1] / 100;
1489
- const g = hcg[2] / 100;
1490
- const l = g * (1.0 - c) + 0.5 * c;
1491
- let s = 0;
1492
-
1493
- if (l > 0.0 && l < 0.5) {
1494
- s = c / (2 * l);
1495
- } else if (l >= 0.5 && l < 1.0) {
1496
- s = c / (2 * (1 - l));
1497
- }
1498
-
1499
- return [hcg[0], s * 100, l * 100];
1500
- };
1501
-
1502
- convert$1.hcg.hwb = function (hcg) {
1503
- const c = hcg[1] / 100;
1504
- const g = hcg[2] / 100;
1505
- const v = c + g * (1.0 - c);
1506
- return [hcg[0], (v - c) * 100, (1 - v) * 100];
1507
- };
1508
-
1509
- convert$1.hwb.hcg = function (hwb) {
1510
- const w = hwb[1] / 100;
1511
- const b = hwb[2] / 100;
1512
- const v = 1 - b;
1513
- const c = v - w;
1514
- let g = 0;
1515
-
1516
- if (c < 1) {
1517
- g = (v - c) / (1 - c);
1518
- }
1519
-
1520
- return [hwb[0], c * 100, g * 100];
1521
- };
1522
-
1523
- convert$1.apple.rgb = function (apple) {
1524
- return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
1525
- };
1526
-
1527
- convert$1.rgb.apple = function (rgb) {
1528
- return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
1529
- };
1530
-
1531
- convert$1.gray.rgb = function (args) {
1532
- return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
1533
- };
1534
-
1535
- convert$1.gray.hsl = function (args) {
1536
- return [0, 0, args[0]];
1537
- };
1538
-
1539
- convert$1.gray.hsv = convert$1.gray.hsl;
1540
-
1541
- convert$1.gray.hwb = function (gray) {
1542
- return [0, 100, gray[0]];
1543
- };
1544
-
1545
- convert$1.gray.cmyk = function (gray) {
1546
- return [0, 0, 0, gray[0]];
1547
- };
1548
-
1549
- convert$1.gray.lab = function (gray) {
1550
- return [gray[0], 0, 0];
1551
- };
1552
-
1553
- convert$1.gray.hex = function (gray) {
1554
- const val = Math.round(gray[0] / 100 * 255) & 0xFF;
1555
- const integer = (val << 16) + (val << 8) + val;
1556
- const string = integer.toString(16).toUpperCase();
1557
- return '000000'.substring(string.length) + string;
1558
- };
1559
-
1560
- convert$1.rgb.gray = function (rgb) {
1561
- const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1562
- return [val / 255 * 100];
1563
- };
1564
-
1565
- const conversions$1 = conversions$2;
1566
- /*
1567
- This function routes a model to all other models.
1568
-
1569
- all functions that are routed have a property `.conversion` attached
1570
- to the returned synthetic function. This property is an array
1571
- of strings, each with the steps in between the 'from' and 'to'
1572
- color models (inclusive).
1573
-
1574
- conversions that are not possible simply are not included.
1575
- */
1576
-
1577
- function buildGraph() {
1578
- const graph = {}; // https://jsperf.com/object-keys-vs-for-in-with-closure/3
1579
-
1580
- const models = Object.keys(conversions$1);
1581
-
1582
- for (let len = models.length, i = 0; i < len; i++) {
1583
- graph[models[i]] = {
1584
- // http://jsperf.com/1-vs-infinity
1585
- // micro-opt, but this is simple.
1586
- distance: -1,
1587
- parent: null
1588
- };
1589
- }
1590
-
1591
- return graph;
1592
- } // https://en.wikipedia.org/wiki/Breadth-first_search
1593
-
1594
-
1595
- function deriveBFS(fromModel) {
1596
- const graph = buildGraph();
1597
- const queue = [fromModel]; // Unshift -> queue -> pop
1598
-
1599
- graph[fromModel].distance = 0;
1600
-
1601
- while (queue.length) {
1602
- const current = queue.pop();
1603
- const adjacents = Object.keys(conversions$1[current]);
1604
-
1605
- for (let len = adjacents.length, i = 0; i < len; i++) {
1606
- const adjacent = adjacents[i];
1607
- const node = graph[adjacent];
1608
-
1609
- if (node.distance === -1) {
1610
- node.distance = graph[current].distance + 1;
1611
- node.parent = current;
1612
- queue.unshift(adjacent);
1613
- }
1614
- }
1615
- }
1616
-
1617
- return graph;
1618
- }
1619
-
1620
- function link(from, to) {
1621
- return function (args) {
1622
- return to(from(args));
1623
- };
1624
- }
1625
-
1626
- function wrapConversion(toModel, graph) {
1627
- const path = [graph[toModel].parent, toModel];
1628
- let fn = conversions$1[graph[toModel].parent][toModel];
1629
- let cur = graph[toModel].parent;
1630
-
1631
- while (graph[cur].parent) {
1632
- path.unshift(graph[cur].parent);
1633
- fn = link(conversions$1[graph[cur].parent][cur], fn);
1634
- cur = graph[cur].parent;
1635
- }
1636
-
1637
- fn.conversion = path;
1638
- return fn;
1639
- }
1640
-
1641
- var route$1 = function (fromModel) {
1642
- const graph = deriveBFS(fromModel);
1643
- const conversion = {};
1644
- const models = Object.keys(graph);
1645
-
1646
- for (let len = models.length, i = 0; i < len; i++) {
1647
- const toModel = models[i];
1648
- const node = graph[toModel];
1649
-
1650
- if (node.parent === null) {
1651
- // No possible conversion, or this node is the source model.
1652
- continue;
1653
- }
1654
-
1655
- conversion[toModel] = wrapConversion(toModel, graph);
1656
- }
1657
-
1658
- return conversion;
1659
- };
1660
-
1661
- const conversions = conversions$2;
1662
- const route = route$1;
1663
- const convert = {};
1664
- const models = Object.keys(conversions);
1665
-
1666
- function wrapRaw(fn) {
1667
- const wrappedFn = function (...args) {
1668
- const arg0 = args[0];
1669
-
1670
- if (arg0 === undefined || arg0 === null) {
1671
- return arg0;
1672
- }
1673
-
1674
- if (arg0.length > 1) {
1675
- args = arg0;
1676
- }
1677
-
1678
- return fn(args);
1679
- }; // Preserve .conversion property if there is one
1680
-
1681
-
1682
- if ('conversion' in fn) {
1683
- wrappedFn.conversion = fn.conversion;
1684
- }
1685
-
1686
- return wrappedFn;
1687
- }
1688
-
1689
- function wrapRounded(fn) {
1690
- const wrappedFn = function (...args) {
1691
- const arg0 = args[0];
1692
-
1693
- if (arg0 === undefined || arg0 === null) {
1694
- return arg0;
1695
- }
1696
-
1697
- if (arg0.length > 1) {
1698
- args = arg0;
1699
- }
1700
-
1701
- const result = fn(args); // We're assuming the result is an array here.
1702
- // see notice in conversions.js; don't use box types
1703
- // in conversion functions.
1704
-
1705
- if (typeof result === 'object') {
1706
- for (let len = result.length, i = 0; i < len; i++) {
1707
- result[i] = Math.round(result[i]);
1708
- }
1709
- }
1710
-
1711
- return result;
1712
- }; // Preserve .conversion property if there is one
1713
-
1714
-
1715
- if ('conversion' in fn) {
1716
- wrappedFn.conversion = fn.conversion;
1717
- }
1718
-
1719
- return wrappedFn;
1720
- }
1721
-
1722
- models.forEach(fromModel => {
1723
- convert[fromModel] = {};
1724
- Object.defineProperty(convert[fromModel], 'channels', {
1725
- value: conversions[fromModel].channels
1726
- });
1727
- Object.defineProperty(convert[fromModel], 'labels', {
1728
- value: conversions[fromModel].labels
1729
- });
1730
- const routes = route(fromModel);
1731
- const routeModels = Object.keys(routes);
1732
- routeModels.forEach(toModel => {
1733
- const fn = routes[toModel];
1734
- convert[fromModel][toModel] = wrapRounded(fn);
1735
- convert[fromModel][toModel].raw = wrapRaw(fn);
1736
- });
1737
- });
1738
- var colorConvert = convert;
1739
- var root = index._root;
1740
- /**
1741
- * Gets the timestamp of the number of milliseconds that have elapsed since
1742
- * the Unix epoch (1 January 1970 00:00:00 UTC).
1743
- *
1744
- * @static
1745
- * @memberOf _
1746
- * @since 2.4.0
1747
- * @category Date
1748
- * @returns {number} Returns the timestamp.
1749
- * @example
1750
- *
1751
- * _.defer(function(stamp) {
1752
- * console.log(_.now() - stamp);
1753
- * }, _.now());
1754
- * // => Logs the number of milliseconds it took for the deferred invocation.
1755
- */
1756
-
1757
- var now$1 = function () {
1758
- return root.Date.now();
1759
- };
1760
-
1761
- var now_1 = now$1;
1762
- /** Used to match a single whitespace character. */
1763
-
1764
- var reWhitespace = /\s/;
1765
- /**
1766
- * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
1767
- * character of `string`.
1768
- *
1769
- * @private
1770
- * @param {string} string The string to inspect.
1771
- * @returns {number} Returns the index of the last non-whitespace character.
1772
- */
1773
-
1774
- function trimmedEndIndex$1(string) {
1775
- var index = string.length;
1776
-
1777
- while (index-- && reWhitespace.test(string.charAt(index))) {}
1778
-
1779
- return index;
1780
- }
1781
-
1782
- var _trimmedEndIndex = trimmedEndIndex$1;
1783
- var trimmedEndIndex = _trimmedEndIndex;
1784
- /** Used to match leading whitespace. */
1785
-
1786
- var reTrimStart = /^\s+/;
1787
- /**
1788
- * The base implementation of `_.trim`.
1789
- *
1790
- * @private
1791
- * @param {string} string The string to trim.
1792
- * @returns {string} Returns the trimmed string.
1793
- */
1794
-
1795
- function baseTrim$1(string) {
1796
- return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '') : string;
1797
- }
1798
-
1799
- var _baseTrim = baseTrim$1;
1800
- var baseTrim = _baseTrim,
1801
- isObject$2 = index.isObject_1,
1802
- isSymbol = index.isSymbol_1;
1803
- /** Used as references for various `Number` constants. */
1804
-
1805
- var NAN = 0 / 0;
1806
- /** Used to detect bad signed hexadecimal string values. */
1807
-
1808
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
1809
- /** Used to detect binary string values. */
1810
-
1811
- var reIsBinary = /^0b[01]+$/i;
1812
- /** Used to detect octal string values. */
1813
-
1814
- var reIsOctal = /^0o[0-7]+$/i;
1815
- /** Built-in method references without a dependency on `root`. */
1816
-
1817
- var freeParseInt = parseInt;
1818
- /**
1819
- * Converts `value` to a number.
1820
- *
1821
- * @static
1822
- * @memberOf _
1823
- * @since 4.0.0
1824
- * @category Lang
1825
- * @param {*} value The value to process.
1826
- * @returns {number} Returns the number.
1827
- * @example
1828
- *
1829
- * _.toNumber(3.2);
1830
- * // => 3.2
1831
- *
1832
- * _.toNumber(Number.MIN_VALUE);
1833
- * // => 5e-324
1834
- *
1835
- * _.toNumber(Infinity);
1836
- * // => Infinity
1837
- *
1838
- * _.toNumber('3.2');
1839
- * // => 3.2
1840
- */
1841
-
1842
- function toNumber$1(value) {
1843
- if (typeof value == 'number') {
1844
- return value;
1845
- }
1846
-
1847
- if (isSymbol(value)) {
1848
- return NAN;
1849
- }
1850
-
1851
- if (isObject$2(value)) {
1852
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
1853
- value = isObject$2(other) ? other + '' : other;
1854
- }
1855
-
1856
- if (typeof value != 'string') {
1857
- return value === 0 ? value : +value;
1858
- }
1859
-
1860
- value = baseTrim(value);
1861
- var isBinary = reIsBinary.test(value);
1862
- return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
1863
- }
1864
-
1865
- var toNumber_1 = toNumber$1;
1866
- var isObject$1 = index.isObject_1,
1867
- now = now_1,
1868
- toNumber = toNumber_1;
1869
- /** Error message constants. */
1870
-
1871
- var FUNC_ERROR_TEXT$1 = 'Expected a function';
1872
- /* Built-in method references for those with the same name as other `lodash` methods. */
1873
-
1874
- var nativeMax = Math.max,
1875
- nativeMin = Math.min;
1876
- /**
1877
- * Creates a debounced function that delays invoking `func` until after `wait`
1878
- * milliseconds have elapsed since the last time the debounced function was
1879
- * invoked. The debounced function comes with a `cancel` method to cancel
1880
- * delayed `func` invocations and a `flush` method to immediately invoke them.
1881
- * Provide `options` to indicate whether `func` should be invoked on the
1882
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
1883
- * with the last arguments provided to the debounced function. Subsequent
1884
- * calls to the debounced function return the result of the last `func`
1885
- * invocation.
1886
- *
1887
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
1888
- * invoked on the trailing edge of the timeout only if the debounced function
1889
- * is invoked more than once during the `wait` timeout.
1890
- *
1891
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
1892
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
1893
- *
1894
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
1895
- * for details over the differences between `_.debounce` and `_.throttle`.
1896
- *
1897
- * @static
1898
- * @memberOf _
1899
- * @since 0.1.0
1900
- * @category Function
1901
- * @param {Function} func The function to debounce.
1902
- * @param {number} [wait=0] The number of milliseconds to delay.
1903
- * @param {Object} [options={}] The options object.
1904
- * @param {boolean} [options.leading=false]
1905
- * Specify invoking on the leading edge of the timeout.
1906
- * @param {number} [options.maxWait]
1907
- * The maximum time `func` is allowed to be delayed before it's invoked.
1908
- * @param {boolean} [options.trailing=true]
1909
- * Specify invoking on the trailing edge of the timeout.
1910
- * @returns {Function} Returns the new debounced function.
1911
- * @example
1912
- *
1913
- * // Avoid costly calculations while the window size is in flux.
1914
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
1915
- *
1916
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
1917
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
1918
- * 'leading': true,
1919
- * 'trailing': false
1920
- * }));
1921
- *
1922
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
1923
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
1924
- * var source = new EventSource('/stream');
1925
- * jQuery(source).on('message', debounced);
1926
- *
1927
- * // Cancel the trailing debounced invocation.
1928
- * jQuery(window).on('popstate', debounced.cancel);
1929
- */
1930
-
1931
- function debounce$1(func, wait, options) {
1932
- var lastArgs,
1933
- lastThis,
1934
- maxWait,
1935
- result,
1936
- timerId,
1937
- lastCallTime,
1938
- lastInvokeTime = 0,
1939
- leading = false,
1940
- maxing = false,
1941
- trailing = true;
1942
-
1943
- if (typeof func != 'function') {
1944
- throw new TypeError(FUNC_ERROR_TEXT$1);
1945
- }
1946
-
1947
- wait = toNumber(wait) || 0;
1948
-
1949
- if (isObject$1(options)) {
1950
- leading = !!options.leading;
1951
- maxing = 'maxWait' in options;
1952
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
1953
- trailing = 'trailing' in options ? !!options.trailing : trailing;
1954
- }
1955
-
1956
- function invokeFunc(time) {
1957
- var args = lastArgs,
1958
- thisArg = lastThis;
1959
- lastArgs = lastThis = undefined;
1960
- lastInvokeTime = time;
1961
- result = func.apply(thisArg, args);
1962
- return result;
1963
- }
1964
-
1965
- function leadingEdge(time) {
1966
- // Reset any `maxWait` timer.
1967
- lastInvokeTime = time; // Start the timer for the trailing edge.
1968
-
1969
- timerId = setTimeout(timerExpired, wait); // Invoke the leading edge.
1970
-
1971
- return leading ? invokeFunc(time) : result;
1972
- }
1973
-
1974
- function remainingWait(time) {
1975
- var timeSinceLastCall = time - lastCallTime,
1976
- timeSinceLastInvoke = time - lastInvokeTime,
1977
- timeWaiting = wait - timeSinceLastCall;
1978
- return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
1979
- }
1980
-
1981
- function shouldInvoke(time) {
1982
- var timeSinceLastCall = time - lastCallTime,
1983
- timeSinceLastInvoke = time - lastInvokeTime; // Either this is the first call, activity has stopped and we're at the
1984
- // trailing edge, the system time has gone backwards and we're treating
1985
- // it as the trailing edge, or we've hit the `maxWait` limit.
1986
-
1987
- return lastCallTime === undefined || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
1988
- }
1989
-
1990
- function timerExpired() {
1991
- var time = now();
1992
-
1993
- if (shouldInvoke(time)) {
1994
- return trailingEdge(time);
1995
- } // Restart the timer.
1996
-
1997
-
1998
- timerId = setTimeout(timerExpired, remainingWait(time));
1999
- }
2000
-
2001
- function trailingEdge(time) {
2002
- timerId = undefined; // Only invoke if we have `lastArgs` which means `func` has been
2003
- // debounced at least once.
2004
-
2005
- if (trailing && lastArgs) {
2006
- return invokeFunc(time);
2007
- }
2008
-
2009
- lastArgs = lastThis = undefined;
2010
- return result;
2011
- }
2012
-
2013
- function cancel() {
2014
- if (timerId !== undefined) {
2015
- clearTimeout(timerId);
2016
- }
2017
-
2018
- lastInvokeTime = 0;
2019
- lastArgs = lastCallTime = lastThis = timerId = undefined;
2020
- }
2021
-
2022
- function flush() {
2023
- return timerId === undefined ? result : trailingEdge(now());
2024
- }
2025
-
2026
- function debounced() {
2027
- var time = now(),
2028
- isInvoking = shouldInvoke(time);
2029
- lastArgs = arguments;
2030
- lastThis = this;
2031
- lastCallTime = time;
2032
-
2033
- if (isInvoking) {
2034
- if (timerId === undefined) {
2035
- return leadingEdge(lastCallTime);
2036
- }
2037
-
2038
- if (maxing) {
2039
- // Handle invocations in a tight loop.
2040
- clearTimeout(timerId);
2041
- timerId = setTimeout(timerExpired, wait);
2042
- return invokeFunc(lastCallTime);
2043
- }
2044
- }
2045
-
2046
- if (timerId === undefined) {
2047
- timerId = setTimeout(timerExpired, wait);
2048
- }
2049
-
2050
- return result;
2051
- }
2052
-
2053
- debounced.cancel = cancel;
2054
- debounced.flush = flush;
2055
- return debounced;
2056
- }
2057
-
2058
- var debounce_1 = debounce$1;
2059
- var debounce = debounce_1,
2060
- isObject = index.isObject_1;
2061
- /** Error message constants. */
2062
-
2063
- var FUNC_ERROR_TEXT = 'Expected a function';
2064
- /**
2065
- * Creates a throttled function that only invokes `func` at most once per
2066
- * every `wait` milliseconds. The throttled function comes with a `cancel`
2067
- * method to cancel delayed `func` invocations and a `flush` method to
2068
- * immediately invoke them. Provide `options` to indicate whether `func`
2069
- * should be invoked on the leading and/or trailing edge of the `wait`
2070
- * timeout. The `func` is invoked with the last arguments provided to the
2071
- * throttled function. Subsequent calls to the throttled function return the
2072
- * result of the last `func` invocation.
2073
- *
2074
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
2075
- * invoked on the trailing edge of the timeout only if the throttled function
2076
- * is invoked more than once during the `wait` timeout.
2077
- *
2078
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
2079
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
2080
- *
2081
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
2082
- * for details over the differences between `_.throttle` and `_.debounce`.
2083
- *
2084
- * @static
2085
- * @memberOf _
2086
- * @since 0.1.0
2087
- * @category Function
2088
- * @param {Function} func The function to throttle.
2089
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
2090
- * @param {Object} [options={}] The options object.
2091
- * @param {boolean} [options.leading=true]
2092
- * Specify invoking on the leading edge of the timeout.
2093
- * @param {boolean} [options.trailing=true]
2094
- * Specify invoking on the trailing edge of the timeout.
2095
- * @returns {Function} Returns the new throttled function.
2096
- * @example
2097
- *
2098
- * // Avoid excessively updating the position while scrolling.
2099
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
2100
- *
2101
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
2102
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
2103
- * jQuery(element).on('click', throttled);
2104
- *
2105
- * // Cancel the trailing throttled invocation.
2106
- * jQuery(window).on('popstate', throttled.cancel);
2107
- */
2108
-
2109
- function throttle(func, wait, options) {
2110
- var leading = true,
2111
- trailing = true;
2112
-
2113
- if (typeof func != 'function') {
2114
- throw new TypeError(FUNC_ERROR_TEXT);
2115
- }
2116
-
2117
- if (isObject(options)) {
2118
- leading = 'leading' in options ? !!options.leading : leading;
2119
- trailing = 'trailing' in options ? !!options.trailing : trailing;
2120
- }
2121
-
2122
- return debounce(func, wait, {
2123
- 'leading': leading,
2124
- 'maxWait': wait,
2125
- 'trailing': trailing
2126
- });
2127
- }
2128
-
2129
- var throttle_1 = throttle;
2130
- const Wrapper = theming.styled.div({
2131
- position: 'relative',
2132
- maxWidth: 250
2133
- });
2134
- const PickerTooltip = theming.styled(index.WithTooltip)({
2135
- position: 'absolute',
2136
- zIndex: 1,
2137
- top: 4,
2138
- left: 4
2139
- });
2140
- const TooltipContent = theming.styled.div({
2141
- width: 200,
2142
- margin: 5,
2143
- '.react-colorful__saturation': {
2144
- borderRadius: '4px 4px 0 0'
2145
- },
2146
- '.react-colorful__hue': {
2147
- boxShadow: 'inset 0 0 0 1px rgb(0 0 0 / 5%)'
2148
- },
2149
- '.react-colorful__last-control': {
2150
- borderRadius: '0 0 4px 4px'
2151
- }
2152
- });
2153
- const Note = theming.styled(index.TooltipNote)(({
2154
- theme
2155
- }) => ({
2156
- fontFamily: theme.typography.fonts.base
2157
- }));
2158
- const Swatches = theming.styled.div({
2159
- display: 'grid',
2160
- gridTemplateColumns: 'repeat(9, 16px)',
2161
- gap: 6,
2162
- padding: 3,
2163
- marginTop: 5,
2164
- width: 200
2165
- });
2166
- const SwatchColor = theming.styled.div(({
2167
- theme,
2168
- active
2169
- }) => ({
2170
- width: 16,
2171
- height: 16,
2172
- boxShadow: active ? `${theme.appBorderColor} 0 0 0 1px inset, ${theme.color.mediumdark}50 0 0 0 4px` : `${theme.appBorderColor} 0 0 0 1px inset`,
2173
- borderRadius: theme.appBorderRadius
2174
- }));
2175
- const 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>')`;
2176
-
2177
- const Swatch = _a => {
2178
- var {
2179
- value,
2180
- active,
2181
- onClick,
2182
- style
2183
- } = _a,
2184
- props = index.__rest(_a, ["value", "active", "onClick", "style"]);
2185
-
2186
- const backgroundImage = `linear-gradient(${value}, ${value}), ${swatchBackground}, linear-gradient(#fff, #fff)`;
2187
- return React__default["default"].createElement(SwatchColor, Object.assign({}, props, {
2188
- active,
2189
- onClick
2190
- }, {
2191
- style: Object.assign(Object.assign({}, style), {
2192
- backgroundImage
2193
- })
2194
- }));
2195
- };
2196
-
2197
- const Input = theming.styled(index.Form.Input)(({
2198
- theme
2199
- }) => ({
2200
- width: '100%',
2201
- paddingLeft: 30,
2202
- paddingRight: 30,
2203
- boxSizing: 'border-box',
2204
- fontFamily: theme.typography.fonts.base
2205
- }));
2206
- const ToggleIcon = theming.styled(index.Icons)(({
2207
- theme
2208
- }) => ({
2209
- position: 'absolute',
2210
- zIndex: 1,
2211
- top: 6,
2212
- right: 7,
2213
- width: 20,
2214
- height: 20,
2215
- padding: 4,
2216
- boxSizing: 'border-box',
2217
- cursor: 'pointer',
2218
- color: theme.input.color
2219
- }));
2220
- var ColorSpace;
2221
-
2222
- (function (ColorSpace) {
2223
- ColorSpace["RGB"] = "rgb";
2224
- ColorSpace["HSL"] = "hsl";
2225
- ColorSpace["HEX"] = "hex";
2226
- })(ColorSpace || (ColorSpace = {}));
2227
-
2228
- const COLOR_SPACES = Object.values(ColorSpace);
2229
- const COLOR_REGEXP = /\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/;
2230
- const RGB_REGEXP = /^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i;
2231
- const HSL_REGEXP = /^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i;
2232
- const HEX_REGEXP = /^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i;
2233
- const SHORTHEX_REGEXP = /^\s*#?([0-9a-f]{3})\s*$/i;
2234
- const ColorPicker = {
2235
- [ColorSpace.HEX]: J,
2236
- [ColorSpace.RGB]: pe,
2237
- [ColorSpace.HSL]: re
2238
- };
2239
- const fallbackColor = {
2240
- [ColorSpace.HEX]: 'transparent',
2241
- [ColorSpace.RGB]: 'rgba(0, 0, 0, 0)',
2242
- [ColorSpace.HSL]: 'hsla(0, 0%, 0%, 0)'
2243
- };
2244
-
2245
- const stringToArgs = value => {
2246
- const match = value === null || value === void 0 ? void 0 : value.match(COLOR_REGEXP);
2247
- if (!match) return [0, 0, 0, 1];
2248
- const [, x, y, z, a = 1] = match;
2249
- return [x, y, z, a].map(Number);
2250
- };
2251
-
2252
- const parseValue = value => {
2253
- if (!value) return undefined;
2254
- let valid = true;
2255
-
2256
- if (RGB_REGEXP.test(value)) {
2257
- const [r, g, b, a] = stringToArgs(value);
2258
- const [h, s, l] = colorConvert.rgb.hsl([r, g, b]) || [0, 0, 0];
2259
- return {
2260
- valid,
2261
- value,
2262
- keyword: colorConvert.rgb.keyword([r, g, b]),
2263
- colorSpace: ColorSpace.RGB,
2264
- [ColorSpace.RGB]: value,
2265
- [ColorSpace.HSL]: `hsla(${h}, ${s}%, ${l}%, ${a})`,
2266
- [ColorSpace.HEX]: `#${colorConvert.rgb.hex([r, g, b]).toLowerCase()}`
2267
- };
2268
- }
2269
-
2270
- if (HSL_REGEXP.test(value)) {
2271
- const [h, s, l, a] = stringToArgs(value);
2272
- const [r, g, b] = colorConvert.hsl.rgb([h, s, l]) || [0, 0, 0];
2273
- return {
2274
- valid,
2275
- value,
2276
- keyword: colorConvert.hsl.keyword([h, s, l]),
2277
- colorSpace: ColorSpace.HSL,
2278
- [ColorSpace.RGB]: `rgba(${r}, ${g}, ${b}, ${a})`,
2279
- [ColorSpace.HSL]: value,
2280
- [ColorSpace.HEX]: `#${colorConvert.hsl.hex([h, s, l]).toLowerCase()}`
2281
- };
2282
- }
2283
-
2284
- const plain = value.replace('#', '');
2285
- const rgb = colorConvert.keyword.rgb(plain) || colorConvert.hex.rgb(plain);
2286
- const hsl = colorConvert.rgb.hsl(rgb);
2287
- let mapped = value;
2288
- if (/[^#a-f0-9]/i.test(value)) mapped = plain;else if (HEX_REGEXP.test(value)) mapped = `#${plain}`;
2289
-
2290
- if (mapped.startsWith('#')) {
2291
- valid = HEX_REGEXP.test(mapped);
2292
- } else {
2293
- try {
2294
- colorConvert.keyword.hex(mapped);
2295
- } catch (e) {
2296
- valid = false;
2297
- }
2298
- }
2299
-
2300
- return {
2301
- valid,
2302
- value: mapped,
2303
- keyword: colorConvert.rgb.keyword(rgb),
2304
- colorSpace: ColorSpace.HEX,
2305
- [ColorSpace.RGB]: `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`,
2306
- [ColorSpace.HSL]: `hsla(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%, 1)`,
2307
- [ColorSpace.HEX]: mapped
2308
- };
2309
- };
2310
-
2311
- const getRealValue = (value, color, colorSpace) => {
2312
- if (!value || !(color === null || color === void 0 ? void 0 : color.valid)) return fallbackColor[colorSpace];
2313
- if (colorSpace !== ColorSpace.HEX) return (color === null || color === void 0 ? void 0 : color[colorSpace]) || fallbackColor[colorSpace];
2314
-
2315
- if (!color.hex.startsWith('#')) {
2316
- try {
2317
- return `#${colorConvert.keyword.hex(color.hex)}`;
2318
- } catch (e) {
2319
- return fallbackColor.hex;
2320
- }
2321
- }
2322
-
2323
- const short = color.hex.match(SHORTHEX_REGEXP);
2324
- if (!short) return HEX_REGEXP.test(color.hex) ? color.hex : fallbackColor.hex;
2325
- const [r, g, b] = short[1].split('');
2326
- return `#${r}${r}${g}${g}${b}${b}`;
2327
- };
2328
-
2329
- const useColorInput = (initialValue, onChange) => {
2330
- const [value, setValue] = React.useState(initialValue || '');
2331
- const [color, setColor] = React.useState(() => parseValue(value));
2332
- const [colorSpace, setColorSpace] = React.useState((color === null || color === void 0 ? void 0 : color.colorSpace) || ColorSpace.HEX); // Reset state when initialValue becomes undefined (when resetting controls)
2333
-
2334
- React.useEffect(() => {
2335
- if (initialValue !== undefined) return;
2336
- setValue('');
2337
- setColor(undefined);
2338
- setColorSpace(ColorSpace.HEX);
2339
- }, [initialValue]);
2340
- const realValue = React.useMemo(() => getRealValue(value, color, colorSpace).toLowerCase(), [value, color, colorSpace]);
2341
- const updateValue = React.useCallback(update => {
2342
- const parsed = parseValue(update);
2343
- setValue((parsed === null || parsed === void 0 ? void 0 : parsed.value) || update || '');
2344
- if (!parsed) return;
2345
- setColor(parsed);
2346
- setColorSpace(parsed.colorSpace);
2347
- onChange(parsed.value);
2348
- }, [onChange]);
2349
- const cycleColorSpace = React.useCallback(() => {
2350
- let next = COLOR_SPACES.indexOf(colorSpace) + 1;
2351
- if (next >= COLOR_SPACES.length) next = 0;
2352
- setColorSpace(COLOR_SPACES[next]);
2353
- const update = (color === null || color === void 0 ? void 0 : color[COLOR_SPACES[next]]) || '';
2354
- setValue(update);
2355
- onChange(update);
2356
- }, [color, colorSpace, onChange]);
2357
- return {
2358
- value,
2359
- realValue,
2360
- updateValue,
2361
- color,
2362
- colorSpace,
2363
- cycleColorSpace
2364
- };
2365
- };
2366
-
2367
- const id = value => value.replace(/\s*/, '').toLowerCase();
2368
-
2369
- const usePresets = (presetColors, currentColor, colorSpace) => {
2370
- const [selectedColors, setSelectedColors] = React.useState((currentColor === null || currentColor === void 0 ? void 0 : currentColor.valid) ? [currentColor] : []); // Reset state when currentColor becomes undefined (when resetting controls)
2371
-
2372
- React.useEffect(() => {
2373
- if (currentColor !== undefined) return;
2374
- setSelectedColors([]);
2375
- }, [currentColor]);
2376
- const presets = React.useMemo(() => {
2377
- const initialPresets = (presetColors || []).map(preset => {
2378
- if (typeof preset === 'string') return parseValue(preset);
2379
- if (preset.title) return Object.assign(Object.assign({}, parseValue(preset.color)), {
2380
- keyword: preset.title
2381
- });
2382
- return parseValue(preset.color);
2383
- });
2384
- return initialPresets.concat(selectedColors).filter(Boolean).slice(-27);
2385
- }, [presetColors, selectedColors]);
2386
- const addPreset = React.useCallback(color => {
2387
- if (!(color === null || color === void 0 ? void 0 : color.valid)) return;
2388
- if (presets.some(preset => id(preset[colorSpace]) === id(color[colorSpace]))) return;
2389
- setSelectedColors(arr => arr.concat(color));
2390
- }, [colorSpace, presets]);
2391
- return {
2392
- presets,
2393
- addPreset
2394
- };
2395
- };
2396
-
2397
- const ColorControl = ({
2398
- name,
2399
- value: initialValue,
2400
- onChange,
2401
- onFocus,
2402
- onBlur,
2403
- presetColors,
2404
- startOpen
2405
- }) => {
2406
- const {
2407
- value,
2408
- realValue,
2409
- updateValue,
2410
- color,
2411
- colorSpace,
2412
- cycleColorSpace
2413
- } = useColorInput(initialValue, throttle_1(onChange, 200));
2414
- const {
2415
- presets,
2416
- addPreset
2417
- } = usePresets(presetColors, color, colorSpace);
2418
- const Picker = ColorPicker[colorSpace];
2419
- return React__default["default"].createElement(Wrapper, null, React__default["default"].createElement(PickerTooltip, {
2420
- trigger: "click",
2421
- startOpen: startOpen,
2422
- closeOnClick: true,
2423
- onVisibilityChange: () => addPreset(color),
2424
- tooltip: React__default["default"].createElement(TooltipContent, null, React__default["default"].createElement(Picker, Object.assign({
2425
- color: realValue === 'transparent' ? '#000000' : realValue
2426
- }, {
2427
- onChange: updateValue,
2428
- onFocus,
2429
- onBlur
2430
- })), presets.length > 0 && React__default["default"].createElement(Swatches, null, presets.map((preset, index$1) => React__default["default"].createElement(index.WithTooltip // eslint-disable-next-line react/no-array-index-key
2431
- , {
2432
- // eslint-disable-next-line react/no-array-index-key
2433
- key: `${preset.value}-${index$1}`,
2434
- hasChrome: false,
2435
- tooltip: React__default["default"].createElement(Note, {
2436
- note: preset.keyword || preset.value
2437
- })
2438
- }, React__default["default"].createElement(Swatch, {
2439
- value: preset[colorSpace],
2440
- active: color && id(preset[colorSpace]) === id(color[colorSpace]),
2441
- onClick: () => updateValue(preset.value)
2442
- })))))
2443
- }, React__default["default"].createElement(Swatch, {
2444
- value: realValue,
2445
- style: {
2446
- margin: 4
2447
- }
2448
- })), React__default["default"].createElement(Input, {
2449
- id: index.getControlId(name),
2450
- value: value,
2451
- onChange: e => updateValue(e.target.value),
2452
- onFocus: e => e.target.select(),
2453
- placeholder: "Choose color..."
2454
- }), value ? React__default["default"].createElement(ToggleIcon, {
2455
- icon: "markup",
2456
- onClick: cycleColorSpace
2457
- }) : null);
2458
- };
2459
-
2460
- exports.ColorControl = ColorControl;
2461
- exports["default"] = ColorControl;