@storybook/components 6.5.9 → 7.0.0-alpha.2

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