@storybook/components 6.5.7 → 7.0.0-alpha.0

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