@storybook/addon-docs 10.1.0-alpha.10 → 10.1.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/Color-S5NAVK5F.js +1096 -0
- package/dist/_browser-chunks/{DocsRenderer-HT7GNKAR.js → DocsRenderer-GHJI37HO.js} +2 -2
- package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
- package/dist/_browser-chunks/chunk-CYSK6WYR.js +7 -0
- package/dist/_browser-chunks/chunk-DDRHE7EB.js +949 -0
- package/dist/_browser-chunks/{chunk-74ZUTOZN.js → chunk-OATZR77O.js} +9 -22
- package/dist/_browser-chunks/chunk-UUESKCKV.js +31 -0
- package/dist/_node-chunks/{chunk-AAP3IT42.js → chunk-C335KFTP.js} +13 -19
- package/dist/_node-chunks/chunk-KYCOJTNB.js +168 -0
- package/dist/_node-chunks/chunk-O7PYD3IJ.js +22630 -0
- package/dist/_node-chunks/chunk-W3QUNYQ5.js +196 -0
- package/dist/_node-chunks/mdx-plugin-DEILFM7O.js +1032 -0
- package/dist/_node-chunks/rehype-external-links-5BFMYXOM.js +121 -0
- package/dist/_node-chunks/{rehype-slug-NPV5OLTF.js → rehype-slug-WW2KPWVT.js} +24 -58
- package/dist/angular/index.js +3 -5
- package/dist/blocks.d.ts +4 -2
- package/dist/blocks.js +1833 -3846
- package/dist/ember/index.js +3 -5
- package/dist/index.js +4 -6
- package/dist/manager.js +11 -22
- package/dist/mdx-loader.js +13 -19
- package/dist/preset.js +155 -454
- package/dist/preview.js +2 -2
- package/package.json +6 -6
- package/dist/_browser-chunks/Color-553OW3OY.js +0 -1694
- package/dist/_browser-chunks/chunk-DMNQCVA2.js +0 -12
- package/dist/_browser-chunks/chunk-UZFOWTVP.js +0 -974
- package/dist/_browser-chunks/chunk-YDZYZRYC.js +0 -39
- package/dist/_node-chunks/chunk-BHIBLL2L.js +0 -36332
- package/dist/_node-chunks/chunk-RAVRMRBT.js +0 -248
- package/dist/_node-chunks/chunk-TSMODHW2.js +0 -231
- package/dist/_node-chunks/mdx-plugin-OGZHIA54.js +0 -1654
- package/dist/_node-chunks/rehype-external-links-32F3YIMH.js +0 -168
|
@@ -1,1694 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getControlId
|
|
3
|
-
} from "./chunk-DMNQCVA2.js";
|
|
4
|
-
import {
|
|
5
|
-
__commonJS,
|
|
6
|
-
__name,
|
|
7
|
-
__toESM
|
|
8
|
-
} from "./chunk-MM7DTO55.js";
|
|
9
|
-
|
|
10
|
-
// ../../node_modules/color-name/index.js
|
|
11
|
-
var require_color_name = __commonJS({
|
|
12
|
-
"../../node_modules/color-name/index.js"(exports, module) {
|
|
13
|
-
"use strict";
|
|
14
|
-
module.exports = {
|
|
15
|
-
"aliceblue": [240, 248, 255],
|
|
16
|
-
"antiquewhite": [250, 235, 215],
|
|
17
|
-
"aqua": [0, 255, 255],
|
|
18
|
-
"aquamarine": [127, 255, 212],
|
|
19
|
-
"azure": [240, 255, 255],
|
|
20
|
-
"beige": [245, 245, 220],
|
|
21
|
-
"bisque": [255, 228, 196],
|
|
22
|
-
"black": [0, 0, 0],
|
|
23
|
-
"blanchedalmond": [255, 235, 205],
|
|
24
|
-
"blue": [0, 0, 255],
|
|
25
|
-
"blueviolet": [138, 43, 226],
|
|
26
|
-
"brown": [165, 42, 42],
|
|
27
|
-
"burlywood": [222, 184, 135],
|
|
28
|
-
"cadetblue": [95, 158, 160],
|
|
29
|
-
"chartreuse": [127, 255, 0],
|
|
30
|
-
"chocolate": [210, 105, 30],
|
|
31
|
-
"coral": [255, 127, 80],
|
|
32
|
-
"cornflowerblue": [100, 149, 237],
|
|
33
|
-
"cornsilk": [255, 248, 220],
|
|
34
|
-
"crimson": [220, 20, 60],
|
|
35
|
-
"cyan": [0, 255, 255],
|
|
36
|
-
"darkblue": [0, 0, 139],
|
|
37
|
-
"darkcyan": [0, 139, 139],
|
|
38
|
-
"darkgoldenrod": [184, 134, 11],
|
|
39
|
-
"darkgray": [169, 169, 169],
|
|
40
|
-
"darkgreen": [0, 100, 0],
|
|
41
|
-
"darkgrey": [169, 169, 169],
|
|
42
|
-
"darkkhaki": [189, 183, 107],
|
|
43
|
-
"darkmagenta": [139, 0, 139],
|
|
44
|
-
"darkolivegreen": [85, 107, 47],
|
|
45
|
-
"darkorange": [255, 140, 0],
|
|
46
|
-
"darkorchid": [153, 50, 204],
|
|
47
|
-
"darkred": [139, 0, 0],
|
|
48
|
-
"darksalmon": [233, 150, 122],
|
|
49
|
-
"darkseagreen": [143, 188, 143],
|
|
50
|
-
"darkslateblue": [72, 61, 139],
|
|
51
|
-
"darkslategray": [47, 79, 79],
|
|
52
|
-
"darkslategrey": [47, 79, 79],
|
|
53
|
-
"darkturquoise": [0, 206, 209],
|
|
54
|
-
"darkviolet": [148, 0, 211],
|
|
55
|
-
"deeppink": [255, 20, 147],
|
|
56
|
-
"deepskyblue": [0, 191, 255],
|
|
57
|
-
"dimgray": [105, 105, 105],
|
|
58
|
-
"dimgrey": [105, 105, 105],
|
|
59
|
-
"dodgerblue": [30, 144, 255],
|
|
60
|
-
"firebrick": [178, 34, 34],
|
|
61
|
-
"floralwhite": [255, 250, 240],
|
|
62
|
-
"forestgreen": [34, 139, 34],
|
|
63
|
-
"fuchsia": [255, 0, 255],
|
|
64
|
-
"gainsboro": [220, 220, 220],
|
|
65
|
-
"ghostwhite": [248, 248, 255],
|
|
66
|
-
"gold": [255, 215, 0],
|
|
67
|
-
"goldenrod": [218, 165, 32],
|
|
68
|
-
"gray": [128, 128, 128],
|
|
69
|
-
"green": [0, 128, 0],
|
|
70
|
-
"greenyellow": [173, 255, 47],
|
|
71
|
-
"grey": [128, 128, 128],
|
|
72
|
-
"honeydew": [240, 255, 240],
|
|
73
|
-
"hotpink": [255, 105, 180],
|
|
74
|
-
"indianred": [205, 92, 92],
|
|
75
|
-
"indigo": [75, 0, 130],
|
|
76
|
-
"ivory": [255, 255, 240],
|
|
77
|
-
"khaki": [240, 230, 140],
|
|
78
|
-
"lavender": [230, 230, 250],
|
|
79
|
-
"lavenderblush": [255, 240, 245],
|
|
80
|
-
"lawngreen": [124, 252, 0],
|
|
81
|
-
"lemonchiffon": [255, 250, 205],
|
|
82
|
-
"lightblue": [173, 216, 230],
|
|
83
|
-
"lightcoral": [240, 128, 128],
|
|
84
|
-
"lightcyan": [224, 255, 255],
|
|
85
|
-
"lightgoldenrodyellow": [250, 250, 210],
|
|
86
|
-
"lightgray": [211, 211, 211],
|
|
87
|
-
"lightgreen": [144, 238, 144],
|
|
88
|
-
"lightgrey": [211, 211, 211],
|
|
89
|
-
"lightpink": [255, 182, 193],
|
|
90
|
-
"lightsalmon": [255, 160, 122],
|
|
91
|
-
"lightseagreen": [32, 178, 170],
|
|
92
|
-
"lightskyblue": [135, 206, 250],
|
|
93
|
-
"lightslategray": [119, 136, 153],
|
|
94
|
-
"lightslategrey": [119, 136, 153],
|
|
95
|
-
"lightsteelblue": [176, 196, 222],
|
|
96
|
-
"lightyellow": [255, 255, 224],
|
|
97
|
-
"lime": [0, 255, 0],
|
|
98
|
-
"limegreen": [50, 205, 50],
|
|
99
|
-
"linen": [250, 240, 230],
|
|
100
|
-
"magenta": [255, 0, 255],
|
|
101
|
-
"maroon": [128, 0, 0],
|
|
102
|
-
"mediumaquamarine": [102, 205, 170],
|
|
103
|
-
"mediumblue": [0, 0, 205],
|
|
104
|
-
"mediumorchid": [186, 85, 211],
|
|
105
|
-
"mediumpurple": [147, 112, 219],
|
|
106
|
-
"mediumseagreen": [60, 179, 113],
|
|
107
|
-
"mediumslateblue": [123, 104, 238],
|
|
108
|
-
"mediumspringgreen": [0, 250, 154],
|
|
109
|
-
"mediumturquoise": [72, 209, 204],
|
|
110
|
-
"mediumvioletred": [199, 21, 133],
|
|
111
|
-
"midnightblue": [25, 25, 112],
|
|
112
|
-
"mintcream": [245, 255, 250],
|
|
113
|
-
"mistyrose": [255, 228, 225],
|
|
114
|
-
"moccasin": [255, 228, 181],
|
|
115
|
-
"navajowhite": [255, 222, 173],
|
|
116
|
-
"navy": [0, 0, 128],
|
|
117
|
-
"oldlace": [253, 245, 230],
|
|
118
|
-
"olive": [128, 128, 0],
|
|
119
|
-
"olivedrab": [107, 142, 35],
|
|
120
|
-
"orange": [255, 165, 0],
|
|
121
|
-
"orangered": [255, 69, 0],
|
|
122
|
-
"orchid": [218, 112, 214],
|
|
123
|
-
"palegoldenrod": [238, 232, 170],
|
|
124
|
-
"palegreen": [152, 251, 152],
|
|
125
|
-
"paleturquoise": [175, 238, 238],
|
|
126
|
-
"palevioletred": [219, 112, 147],
|
|
127
|
-
"papayawhip": [255, 239, 213],
|
|
128
|
-
"peachpuff": [255, 218, 185],
|
|
129
|
-
"peru": [205, 133, 63],
|
|
130
|
-
"pink": [255, 192, 203],
|
|
131
|
-
"plum": [221, 160, 221],
|
|
132
|
-
"powderblue": [176, 224, 230],
|
|
133
|
-
"purple": [128, 0, 128],
|
|
134
|
-
"rebeccapurple": [102, 51, 153],
|
|
135
|
-
"red": [255, 0, 0],
|
|
136
|
-
"rosybrown": [188, 143, 143],
|
|
137
|
-
"royalblue": [65, 105, 225],
|
|
138
|
-
"saddlebrown": [139, 69, 19],
|
|
139
|
-
"salmon": [250, 128, 114],
|
|
140
|
-
"sandybrown": [244, 164, 96],
|
|
141
|
-
"seagreen": [46, 139, 87],
|
|
142
|
-
"seashell": [255, 245, 238],
|
|
143
|
-
"sienna": [160, 82, 45],
|
|
144
|
-
"silver": [192, 192, 192],
|
|
145
|
-
"skyblue": [135, 206, 235],
|
|
146
|
-
"slateblue": [106, 90, 205],
|
|
147
|
-
"slategray": [112, 128, 144],
|
|
148
|
-
"slategrey": [112, 128, 144],
|
|
149
|
-
"snow": [255, 250, 250],
|
|
150
|
-
"springgreen": [0, 255, 127],
|
|
151
|
-
"steelblue": [70, 130, 180],
|
|
152
|
-
"tan": [210, 180, 140],
|
|
153
|
-
"teal": [0, 128, 128],
|
|
154
|
-
"thistle": [216, 191, 216],
|
|
155
|
-
"tomato": [255, 99, 71],
|
|
156
|
-
"turquoise": [64, 224, 208],
|
|
157
|
-
"violet": [238, 130, 238],
|
|
158
|
-
"wheat": [245, 222, 179],
|
|
159
|
-
"white": [255, 255, 255],
|
|
160
|
-
"whitesmoke": [245, 245, 245],
|
|
161
|
-
"yellow": [255, 255, 0],
|
|
162
|
-
"yellowgreen": [154, 205, 50]
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
// ../../node_modules/color-convert/conversions.js
|
|
168
|
-
var require_conversions = __commonJS({
|
|
169
|
-
"../../node_modules/color-convert/conversions.js"(exports, module) {
|
|
170
|
-
var cssKeywords = require_color_name();
|
|
171
|
-
var reverseKeywords = {};
|
|
172
|
-
for (const key of Object.keys(cssKeywords)) {
|
|
173
|
-
reverseKeywords[cssKeywords[key]] = key;
|
|
174
|
-
}
|
|
175
|
-
var convert2 = {
|
|
176
|
-
rgb: { channels: 3, labels: "rgb" },
|
|
177
|
-
hsl: { channels: 3, labels: "hsl" },
|
|
178
|
-
hsv: { channels: 3, labels: "hsv" },
|
|
179
|
-
hwb: { channels: 3, labels: "hwb" },
|
|
180
|
-
cmyk: { channels: 4, labels: "cmyk" },
|
|
181
|
-
xyz: { channels: 3, labels: "xyz" },
|
|
182
|
-
lab: { channels: 3, labels: "lab" },
|
|
183
|
-
lch: { channels: 3, labels: "lch" },
|
|
184
|
-
hex: { channels: 1, labels: ["hex"] },
|
|
185
|
-
keyword: { channels: 1, labels: ["keyword"] },
|
|
186
|
-
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
187
|
-
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
188
|
-
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
189
|
-
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
190
|
-
gray: { channels: 1, labels: ["gray"] }
|
|
191
|
-
};
|
|
192
|
-
module.exports = convert2;
|
|
193
|
-
for (const model of Object.keys(convert2)) {
|
|
194
|
-
if (!("channels" in convert2[model])) {
|
|
195
|
-
throw new Error("missing channels property: " + model);
|
|
196
|
-
}
|
|
197
|
-
if (!("labels" in convert2[model])) {
|
|
198
|
-
throw new Error("missing channel labels property: " + model);
|
|
199
|
-
}
|
|
200
|
-
if (convert2[model].labels.length !== convert2[model].channels) {
|
|
201
|
-
throw new Error("channel and label counts mismatch: " + model);
|
|
202
|
-
}
|
|
203
|
-
const { channels, labels } = convert2[model];
|
|
204
|
-
delete convert2[model].channels;
|
|
205
|
-
delete convert2[model].labels;
|
|
206
|
-
Object.defineProperty(convert2[model], "channels", { value: channels });
|
|
207
|
-
Object.defineProperty(convert2[model], "labels", { value: labels });
|
|
208
|
-
}
|
|
209
|
-
convert2.rgb.hsl = function(rgb) {
|
|
210
|
-
const r2 = rgb[0] / 255;
|
|
211
|
-
const g2 = rgb[1] / 255;
|
|
212
|
-
const b2 = rgb[2] / 255;
|
|
213
|
-
const min = Math.min(r2, g2, b2);
|
|
214
|
-
const max = Math.max(r2, g2, b2);
|
|
215
|
-
const delta = max - min;
|
|
216
|
-
let h2;
|
|
217
|
-
let s2;
|
|
218
|
-
if (max === min) {
|
|
219
|
-
h2 = 0;
|
|
220
|
-
} else if (r2 === max) {
|
|
221
|
-
h2 = (g2 - b2) / delta;
|
|
222
|
-
} else if (g2 === max) {
|
|
223
|
-
h2 = 2 + (b2 - r2) / delta;
|
|
224
|
-
} else if (b2 === max) {
|
|
225
|
-
h2 = 4 + (r2 - g2) / delta;
|
|
226
|
-
}
|
|
227
|
-
h2 = Math.min(h2 * 60, 360);
|
|
228
|
-
if (h2 < 0) {
|
|
229
|
-
h2 += 360;
|
|
230
|
-
}
|
|
231
|
-
const l2 = (min + max) / 2;
|
|
232
|
-
if (max === min) {
|
|
233
|
-
s2 = 0;
|
|
234
|
-
} else if (l2 <= 0.5) {
|
|
235
|
-
s2 = delta / (max + min);
|
|
236
|
-
} else {
|
|
237
|
-
s2 = delta / (2 - max - min);
|
|
238
|
-
}
|
|
239
|
-
return [h2, s2 * 100, l2 * 100];
|
|
240
|
-
};
|
|
241
|
-
convert2.rgb.hsv = function(rgb) {
|
|
242
|
-
let rdif;
|
|
243
|
-
let gdif;
|
|
244
|
-
let bdif;
|
|
245
|
-
let h2;
|
|
246
|
-
let s2;
|
|
247
|
-
const r2 = rgb[0] / 255;
|
|
248
|
-
const g2 = rgb[1] / 255;
|
|
249
|
-
const b2 = rgb[2] / 255;
|
|
250
|
-
const v2 = Math.max(r2, g2, b2);
|
|
251
|
-
const diff = v2 - Math.min(r2, g2, b2);
|
|
252
|
-
const diffc = /* @__PURE__ */ __name(function(c2) {
|
|
253
|
-
return (v2 - c2) / 6 / diff + 1 / 2;
|
|
254
|
-
}, "diffc");
|
|
255
|
-
if (diff === 0) {
|
|
256
|
-
h2 = 0;
|
|
257
|
-
s2 = 0;
|
|
258
|
-
} else {
|
|
259
|
-
s2 = diff / v2;
|
|
260
|
-
rdif = diffc(r2);
|
|
261
|
-
gdif = diffc(g2);
|
|
262
|
-
bdif = diffc(b2);
|
|
263
|
-
if (r2 === v2) {
|
|
264
|
-
h2 = bdif - gdif;
|
|
265
|
-
} else if (g2 === v2) {
|
|
266
|
-
h2 = 1 / 3 + rdif - bdif;
|
|
267
|
-
} else if (b2 === v2) {
|
|
268
|
-
h2 = 2 / 3 + gdif - rdif;
|
|
269
|
-
}
|
|
270
|
-
if (h2 < 0) {
|
|
271
|
-
h2 += 1;
|
|
272
|
-
} else if (h2 > 1) {
|
|
273
|
-
h2 -= 1;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return [
|
|
277
|
-
h2 * 360,
|
|
278
|
-
s2 * 100,
|
|
279
|
-
v2 * 100
|
|
280
|
-
];
|
|
281
|
-
};
|
|
282
|
-
convert2.rgb.hwb = function(rgb) {
|
|
283
|
-
const r2 = rgb[0];
|
|
284
|
-
const g2 = rgb[1];
|
|
285
|
-
let b2 = rgb[2];
|
|
286
|
-
const h2 = convert2.rgb.hsl(rgb)[0];
|
|
287
|
-
const w2 = 1 / 255 * Math.min(r2, Math.min(g2, b2));
|
|
288
|
-
b2 = 1 - 1 / 255 * Math.max(r2, Math.max(g2, b2));
|
|
289
|
-
return [h2, w2 * 100, b2 * 100];
|
|
290
|
-
};
|
|
291
|
-
convert2.rgb.cmyk = function(rgb) {
|
|
292
|
-
const r2 = rgb[0] / 255;
|
|
293
|
-
const g2 = rgb[1] / 255;
|
|
294
|
-
const b2 = rgb[2] / 255;
|
|
295
|
-
const k2 = Math.min(1 - r2, 1 - g2, 1 - b2);
|
|
296
|
-
const c2 = (1 - r2 - k2) / (1 - k2) || 0;
|
|
297
|
-
const m2 = (1 - g2 - k2) / (1 - k2) || 0;
|
|
298
|
-
const y2 = (1 - b2 - k2) / (1 - k2) || 0;
|
|
299
|
-
return [c2 * 100, m2 * 100, y2 * 100, k2 * 100];
|
|
300
|
-
};
|
|
301
|
-
function comparativeDistance(x2, y2) {
|
|
302
|
-
return (x2[0] - y2[0]) ** 2 + (x2[1] - y2[1]) ** 2 + (x2[2] - y2[2]) ** 2;
|
|
303
|
-
}
|
|
304
|
-
__name(comparativeDistance, "comparativeDistance");
|
|
305
|
-
convert2.rgb.keyword = function(rgb) {
|
|
306
|
-
const reversed = reverseKeywords[rgb];
|
|
307
|
-
if (reversed) {
|
|
308
|
-
return reversed;
|
|
309
|
-
}
|
|
310
|
-
let currentClosestDistance = Infinity;
|
|
311
|
-
let currentClosestKeyword;
|
|
312
|
-
for (const keyword of Object.keys(cssKeywords)) {
|
|
313
|
-
const value = cssKeywords[keyword];
|
|
314
|
-
const distance = comparativeDistance(rgb, value);
|
|
315
|
-
if (distance < currentClosestDistance) {
|
|
316
|
-
currentClosestDistance = distance;
|
|
317
|
-
currentClosestKeyword = keyword;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return currentClosestKeyword;
|
|
321
|
-
};
|
|
322
|
-
convert2.keyword.rgb = function(keyword) {
|
|
323
|
-
return cssKeywords[keyword];
|
|
324
|
-
};
|
|
325
|
-
convert2.rgb.xyz = function(rgb) {
|
|
326
|
-
let r2 = rgb[0] / 255;
|
|
327
|
-
let g2 = rgb[1] / 255;
|
|
328
|
-
let b2 = rgb[2] / 255;
|
|
329
|
-
r2 = r2 > 0.04045 ? ((r2 + 0.055) / 1.055) ** 2.4 : r2 / 12.92;
|
|
330
|
-
g2 = g2 > 0.04045 ? ((g2 + 0.055) / 1.055) ** 2.4 : g2 / 12.92;
|
|
331
|
-
b2 = b2 > 0.04045 ? ((b2 + 0.055) / 1.055) ** 2.4 : b2 / 12.92;
|
|
332
|
-
const x2 = r2 * 0.4124 + g2 * 0.3576 + b2 * 0.1805;
|
|
333
|
-
const y2 = r2 * 0.2126 + g2 * 0.7152 + b2 * 0.0722;
|
|
334
|
-
const z2 = r2 * 0.0193 + g2 * 0.1192 + b2 * 0.9505;
|
|
335
|
-
return [x2 * 100, y2 * 100, z2 * 100];
|
|
336
|
-
};
|
|
337
|
-
convert2.rgb.lab = function(rgb) {
|
|
338
|
-
const xyz = convert2.rgb.xyz(rgb);
|
|
339
|
-
let x2 = xyz[0];
|
|
340
|
-
let y2 = xyz[1];
|
|
341
|
-
let z2 = xyz[2];
|
|
342
|
-
x2 /= 95.047;
|
|
343
|
-
y2 /= 100;
|
|
344
|
-
z2 /= 108.883;
|
|
345
|
-
x2 = x2 > 8856e-6 ? x2 ** (1 / 3) : 7.787 * x2 + 16 / 116;
|
|
346
|
-
y2 = y2 > 8856e-6 ? y2 ** (1 / 3) : 7.787 * y2 + 16 / 116;
|
|
347
|
-
z2 = z2 > 8856e-6 ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
|
|
348
|
-
const l2 = 116 * y2 - 16;
|
|
349
|
-
const a2 = 500 * (x2 - y2);
|
|
350
|
-
const b2 = 200 * (y2 - z2);
|
|
351
|
-
return [l2, a2, b2];
|
|
352
|
-
};
|
|
353
|
-
convert2.hsl.rgb = function(hsl) {
|
|
354
|
-
const h2 = hsl[0] / 360;
|
|
355
|
-
const s2 = hsl[1] / 100;
|
|
356
|
-
const l2 = hsl[2] / 100;
|
|
357
|
-
let t2;
|
|
358
|
-
let t3;
|
|
359
|
-
let val;
|
|
360
|
-
if (s2 === 0) {
|
|
361
|
-
val = l2 * 255;
|
|
362
|
-
return [val, val, val];
|
|
363
|
-
}
|
|
364
|
-
if (l2 < 0.5) {
|
|
365
|
-
t2 = l2 * (1 + s2);
|
|
366
|
-
} else {
|
|
367
|
-
t2 = l2 + s2 - l2 * s2;
|
|
368
|
-
}
|
|
369
|
-
const t1 = 2 * l2 - t2;
|
|
370
|
-
const rgb = [0, 0, 0];
|
|
371
|
-
for (let i2 = 0; i2 < 3; i2++) {
|
|
372
|
-
t3 = h2 + 1 / 3 * -(i2 - 1);
|
|
373
|
-
if (t3 < 0) {
|
|
374
|
-
t3++;
|
|
375
|
-
}
|
|
376
|
-
if (t3 > 1) {
|
|
377
|
-
t3--;
|
|
378
|
-
}
|
|
379
|
-
if (6 * t3 < 1) {
|
|
380
|
-
val = t1 + (t2 - t1) * 6 * t3;
|
|
381
|
-
} else if (2 * t3 < 1) {
|
|
382
|
-
val = t2;
|
|
383
|
-
} else if (3 * t3 < 2) {
|
|
384
|
-
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
|
|
385
|
-
} else {
|
|
386
|
-
val = t1;
|
|
387
|
-
}
|
|
388
|
-
rgb[i2] = val * 255;
|
|
389
|
-
}
|
|
390
|
-
return rgb;
|
|
391
|
-
};
|
|
392
|
-
convert2.hsl.hsv = function(hsl) {
|
|
393
|
-
const h2 = hsl[0];
|
|
394
|
-
let s2 = hsl[1] / 100;
|
|
395
|
-
let l2 = hsl[2] / 100;
|
|
396
|
-
let smin = s2;
|
|
397
|
-
const lmin = Math.max(l2, 0.01);
|
|
398
|
-
l2 *= 2;
|
|
399
|
-
s2 *= l2 <= 1 ? l2 : 2 - l2;
|
|
400
|
-
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
401
|
-
const v2 = (l2 + s2) / 2;
|
|
402
|
-
const sv = l2 === 0 ? 2 * smin / (lmin + smin) : 2 * s2 / (l2 + s2);
|
|
403
|
-
return [h2, sv * 100, v2 * 100];
|
|
404
|
-
};
|
|
405
|
-
convert2.hsv.rgb = function(hsv) {
|
|
406
|
-
const h2 = hsv[0] / 60;
|
|
407
|
-
const s2 = hsv[1] / 100;
|
|
408
|
-
let v2 = hsv[2] / 100;
|
|
409
|
-
const hi = Math.floor(h2) % 6;
|
|
410
|
-
const f2 = h2 - Math.floor(h2);
|
|
411
|
-
const p2 = 255 * v2 * (1 - s2);
|
|
412
|
-
const q2 = 255 * v2 * (1 - s2 * f2);
|
|
413
|
-
const t2 = 255 * v2 * (1 - s2 * (1 - f2));
|
|
414
|
-
v2 *= 255;
|
|
415
|
-
switch (hi) {
|
|
416
|
-
case 0:
|
|
417
|
-
return [v2, t2, p2];
|
|
418
|
-
case 1:
|
|
419
|
-
return [q2, v2, p2];
|
|
420
|
-
case 2:
|
|
421
|
-
return [p2, v2, t2];
|
|
422
|
-
case 3:
|
|
423
|
-
return [p2, q2, v2];
|
|
424
|
-
case 4:
|
|
425
|
-
return [t2, p2, v2];
|
|
426
|
-
case 5:
|
|
427
|
-
return [v2, p2, q2];
|
|
428
|
-
}
|
|
429
|
-
};
|
|
430
|
-
convert2.hsv.hsl = function(hsv) {
|
|
431
|
-
const h2 = hsv[0];
|
|
432
|
-
const s2 = hsv[1] / 100;
|
|
433
|
-
const v2 = hsv[2] / 100;
|
|
434
|
-
const vmin = Math.max(v2, 0.01);
|
|
435
|
-
let sl;
|
|
436
|
-
let l2;
|
|
437
|
-
l2 = (2 - s2) * v2;
|
|
438
|
-
const lmin = (2 - s2) * vmin;
|
|
439
|
-
sl = s2 * vmin;
|
|
440
|
-
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
441
|
-
sl = sl || 0;
|
|
442
|
-
l2 /= 2;
|
|
443
|
-
return [h2, sl * 100, l2 * 100];
|
|
444
|
-
};
|
|
445
|
-
convert2.hwb.rgb = function(hwb) {
|
|
446
|
-
const h2 = hwb[0] / 360;
|
|
447
|
-
let wh = hwb[1] / 100;
|
|
448
|
-
let bl = hwb[2] / 100;
|
|
449
|
-
const ratio = wh + bl;
|
|
450
|
-
let f2;
|
|
451
|
-
if (ratio > 1) {
|
|
452
|
-
wh /= ratio;
|
|
453
|
-
bl /= ratio;
|
|
454
|
-
}
|
|
455
|
-
const i2 = Math.floor(6 * h2);
|
|
456
|
-
const v2 = 1 - bl;
|
|
457
|
-
f2 = 6 * h2 - i2;
|
|
458
|
-
if ((i2 & 1) !== 0) {
|
|
459
|
-
f2 = 1 - f2;
|
|
460
|
-
}
|
|
461
|
-
const n2 = wh + f2 * (v2 - wh);
|
|
462
|
-
let r2;
|
|
463
|
-
let g2;
|
|
464
|
-
let b2;
|
|
465
|
-
switch (i2) {
|
|
466
|
-
default:
|
|
467
|
-
case 6:
|
|
468
|
-
case 0:
|
|
469
|
-
r2 = v2;
|
|
470
|
-
g2 = n2;
|
|
471
|
-
b2 = wh;
|
|
472
|
-
break;
|
|
473
|
-
case 1:
|
|
474
|
-
r2 = n2;
|
|
475
|
-
g2 = v2;
|
|
476
|
-
b2 = wh;
|
|
477
|
-
break;
|
|
478
|
-
case 2:
|
|
479
|
-
r2 = wh;
|
|
480
|
-
g2 = v2;
|
|
481
|
-
b2 = n2;
|
|
482
|
-
break;
|
|
483
|
-
case 3:
|
|
484
|
-
r2 = wh;
|
|
485
|
-
g2 = n2;
|
|
486
|
-
b2 = v2;
|
|
487
|
-
break;
|
|
488
|
-
case 4:
|
|
489
|
-
r2 = n2;
|
|
490
|
-
g2 = wh;
|
|
491
|
-
b2 = v2;
|
|
492
|
-
break;
|
|
493
|
-
case 5:
|
|
494
|
-
r2 = v2;
|
|
495
|
-
g2 = wh;
|
|
496
|
-
b2 = n2;
|
|
497
|
-
break;
|
|
498
|
-
}
|
|
499
|
-
return [r2 * 255, g2 * 255, b2 * 255];
|
|
500
|
-
};
|
|
501
|
-
convert2.cmyk.rgb = function(cmyk) {
|
|
502
|
-
const c2 = cmyk[0] / 100;
|
|
503
|
-
const m2 = cmyk[1] / 100;
|
|
504
|
-
const y2 = cmyk[2] / 100;
|
|
505
|
-
const k2 = cmyk[3] / 100;
|
|
506
|
-
const r2 = 1 - Math.min(1, c2 * (1 - k2) + k2);
|
|
507
|
-
const g2 = 1 - Math.min(1, m2 * (1 - k2) + k2);
|
|
508
|
-
const b2 = 1 - Math.min(1, y2 * (1 - k2) + k2);
|
|
509
|
-
return [r2 * 255, g2 * 255, b2 * 255];
|
|
510
|
-
};
|
|
511
|
-
convert2.xyz.rgb = function(xyz) {
|
|
512
|
-
const x2 = xyz[0] / 100;
|
|
513
|
-
const y2 = xyz[1] / 100;
|
|
514
|
-
const z2 = xyz[2] / 100;
|
|
515
|
-
let r2;
|
|
516
|
-
let g2;
|
|
517
|
-
let b2;
|
|
518
|
-
r2 = x2 * 3.2406 + y2 * -1.5372 + z2 * -0.4986;
|
|
519
|
-
g2 = x2 * -0.9689 + y2 * 1.8758 + z2 * 0.0415;
|
|
520
|
-
b2 = x2 * 0.0557 + y2 * -0.204 + z2 * 1.057;
|
|
521
|
-
r2 = r2 > 31308e-7 ? 1.055 * r2 ** (1 / 2.4) - 0.055 : r2 * 12.92;
|
|
522
|
-
g2 = g2 > 31308e-7 ? 1.055 * g2 ** (1 / 2.4) - 0.055 : g2 * 12.92;
|
|
523
|
-
b2 = b2 > 31308e-7 ? 1.055 * b2 ** (1 / 2.4) - 0.055 : b2 * 12.92;
|
|
524
|
-
r2 = Math.min(Math.max(0, r2), 1);
|
|
525
|
-
g2 = Math.min(Math.max(0, g2), 1);
|
|
526
|
-
b2 = Math.min(Math.max(0, b2), 1);
|
|
527
|
-
return [r2 * 255, g2 * 255, b2 * 255];
|
|
528
|
-
};
|
|
529
|
-
convert2.xyz.lab = function(xyz) {
|
|
530
|
-
let x2 = xyz[0];
|
|
531
|
-
let y2 = xyz[1];
|
|
532
|
-
let z2 = xyz[2];
|
|
533
|
-
x2 /= 95.047;
|
|
534
|
-
y2 /= 100;
|
|
535
|
-
z2 /= 108.883;
|
|
536
|
-
x2 = x2 > 8856e-6 ? x2 ** (1 / 3) : 7.787 * x2 + 16 / 116;
|
|
537
|
-
y2 = y2 > 8856e-6 ? y2 ** (1 / 3) : 7.787 * y2 + 16 / 116;
|
|
538
|
-
z2 = z2 > 8856e-6 ? z2 ** (1 / 3) : 7.787 * z2 + 16 / 116;
|
|
539
|
-
const l2 = 116 * y2 - 16;
|
|
540
|
-
const a2 = 500 * (x2 - y2);
|
|
541
|
-
const b2 = 200 * (y2 - z2);
|
|
542
|
-
return [l2, a2, b2];
|
|
543
|
-
};
|
|
544
|
-
convert2.lab.xyz = function(lab) {
|
|
545
|
-
const l2 = lab[0];
|
|
546
|
-
const a2 = lab[1];
|
|
547
|
-
const b2 = lab[2];
|
|
548
|
-
let x2;
|
|
549
|
-
let y2;
|
|
550
|
-
let z2;
|
|
551
|
-
y2 = (l2 + 16) / 116;
|
|
552
|
-
x2 = a2 / 500 + y2;
|
|
553
|
-
z2 = y2 - b2 / 200;
|
|
554
|
-
const y22 = y2 ** 3;
|
|
555
|
-
const x22 = x2 ** 3;
|
|
556
|
-
const z22 = z2 ** 3;
|
|
557
|
-
y2 = y22 > 8856e-6 ? y22 : (y2 - 16 / 116) / 7.787;
|
|
558
|
-
x2 = x22 > 8856e-6 ? x22 : (x2 - 16 / 116) / 7.787;
|
|
559
|
-
z2 = z22 > 8856e-6 ? z22 : (z2 - 16 / 116) / 7.787;
|
|
560
|
-
x2 *= 95.047;
|
|
561
|
-
y2 *= 100;
|
|
562
|
-
z2 *= 108.883;
|
|
563
|
-
return [x2, y2, z2];
|
|
564
|
-
};
|
|
565
|
-
convert2.lab.lch = function(lab) {
|
|
566
|
-
const l2 = lab[0];
|
|
567
|
-
const a2 = lab[1];
|
|
568
|
-
const b2 = lab[2];
|
|
569
|
-
let h2;
|
|
570
|
-
const hr = Math.atan2(b2, a2);
|
|
571
|
-
h2 = hr * 360 / 2 / Math.PI;
|
|
572
|
-
if (h2 < 0) {
|
|
573
|
-
h2 += 360;
|
|
574
|
-
}
|
|
575
|
-
const c2 = Math.sqrt(a2 * a2 + b2 * b2);
|
|
576
|
-
return [l2, c2, h2];
|
|
577
|
-
};
|
|
578
|
-
convert2.lch.lab = function(lch) {
|
|
579
|
-
const l2 = lch[0];
|
|
580
|
-
const c2 = lch[1];
|
|
581
|
-
const h2 = lch[2];
|
|
582
|
-
const hr = h2 / 360 * 2 * Math.PI;
|
|
583
|
-
const a2 = c2 * Math.cos(hr);
|
|
584
|
-
const b2 = c2 * Math.sin(hr);
|
|
585
|
-
return [l2, a2, b2];
|
|
586
|
-
};
|
|
587
|
-
convert2.rgb.ansi16 = function(args, saturation = null) {
|
|
588
|
-
const [r2, g2, b2] = args;
|
|
589
|
-
let value = saturation === null ? convert2.rgb.hsv(args)[2] : saturation;
|
|
590
|
-
value = Math.round(value / 50);
|
|
591
|
-
if (value === 0) {
|
|
592
|
-
return 30;
|
|
593
|
-
}
|
|
594
|
-
let ansi = 30 + (Math.round(b2 / 255) << 2 | Math.round(g2 / 255) << 1 | Math.round(r2 / 255));
|
|
595
|
-
if (value === 2) {
|
|
596
|
-
ansi += 60;
|
|
597
|
-
}
|
|
598
|
-
return ansi;
|
|
599
|
-
};
|
|
600
|
-
convert2.hsv.ansi16 = function(args) {
|
|
601
|
-
return convert2.rgb.ansi16(convert2.hsv.rgb(args), args[2]);
|
|
602
|
-
};
|
|
603
|
-
convert2.rgb.ansi256 = function(args) {
|
|
604
|
-
const r2 = args[0];
|
|
605
|
-
const g2 = args[1];
|
|
606
|
-
const b2 = args[2];
|
|
607
|
-
if (r2 === g2 && g2 === b2) {
|
|
608
|
-
if (r2 < 8) {
|
|
609
|
-
return 16;
|
|
610
|
-
}
|
|
611
|
-
if (r2 > 248) {
|
|
612
|
-
return 231;
|
|
613
|
-
}
|
|
614
|
-
return Math.round((r2 - 8) / 247 * 24) + 232;
|
|
615
|
-
}
|
|
616
|
-
const ansi = 16 + 36 * Math.round(r2 / 255 * 5) + 6 * Math.round(g2 / 255 * 5) + Math.round(b2 / 255 * 5);
|
|
617
|
-
return ansi;
|
|
618
|
-
};
|
|
619
|
-
convert2.ansi16.rgb = function(args) {
|
|
620
|
-
let color = args % 10;
|
|
621
|
-
if (color === 0 || color === 7) {
|
|
622
|
-
if (args > 50) {
|
|
623
|
-
color += 3.5;
|
|
624
|
-
}
|
|
625
|
-
color = color / 10.5 * 255;
|
|
626
|
-
return [color, color, color];
|
|
627
|
-
}
|
|
628
|
-
const mult = (~~(args > 50) + 1) * 0.5;
|
|
629
|
-
const r2 = (color & 1) * mult * 255;
|
|
630
|
-
const g2 = (color >> 1 & 1) * mult * 255;
|
|
631
|
-
const b2 = (color >> 2 & 1) * mult * 255;
|
|
632
|
-
return [r2, g2, b2];
|
|
633
|
-
};
|
|
634
|
-
convert2.ansi256.rgb = function(args) {
|
|
635
|
-
if (args >= 232) {
|
|
636
|
-
const c2 = (args - 232) * 10 + 8;
|
|
637
|
-
return [c2, c2, c2];
|
|
638
|
-
}
|
|
639
|
-
args -= 16;
|
|
640
|
-
let rem;
|
|
641
|
-
const r2 = Math.floor(args / 36) / 5 * 255;
|
|
642
|
-
const g2 = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
643
|
-
const b2 = rem % 6 / 5 * 255;
|
|
644
|
-
return [r2, g2, b2];
|
|
645
|
-
};
|
|
646
|
-
convert2.rgb.hex = function(args) {
|
|
647
|
-
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
648
|
-
const string = integer.toString(16).toUpperCase();
|
|
649
|
-
return "000000".substring(string.length) + string;
|
|
650
|
-
};
|
|
651
|
-
convert2.hex.rgb = function(args) {
|
|
652
|
-
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
653
|
-
if (!match) {
|
|
654
|
-
return [0, 0, 0];
|
|
655
|
-
}
|
|
656
|
-
let colorString = match[0];
|
|
657
|
-
if (match[0].length === 3) {
|
|
658
|
-
colorString = colorString.split("").map((char) => {
|
|
659
|
-
return char + char;
|
|
660
|
-
}).join("");
|
|
661
|
-
}
|
|
662
|
-
const integer = parseInt(colorString, 16);
|
|
663
|
-
const r2 = integer >> 16 & 255;
|
|
664
|
-
const g2 = integer >> 8 & 255;
|
|
665
|
-
const b2 = integer & 255;
|
|
666
|
-
return [r2, g2, b2];
|
|
667
|
-
};
|
|
668
|
-
convert2.rgb.hcg = function(rgb) {
|
|
669
|
-
const r2 = rgb[0] / 255;
|
|
670
|
-
const g2 = rgb[1] / 255;
|
|
671
|
-
const b2 = rgb[2] / 255;
|
|
672
|
-
const max = Math.max(Math.max(r2, g2), b2);
|
|
673
|
-
const min = Math.min(Math.min(r2, g2), b2);
|
|
674
|
-
const chroma = max - min;
|
|
675
|
-
let grayscale;
|
|
676
|
-
let hue;
|
|
677
|
-
if (chroma < 1) {
|
|
678
|
-
grayscale = min / (1 - chroma);
|
|
679
|
-
} else {
|
|
680
|
-
grayscale = 0;
|
|
681
|
-
}
|
|
682
|
-
if (chroma <= 0) {
|
|
683
|
-
hue = 0;
|
|
684
|
-
} else if (max === r2) {
|
|
685
|
-
hue = (g2 - b2) / chroma % 6;
|
|
686
|
-
} else if (max === g2) {
|
|
687
|
-
hue = 2 + (b2 - r2) / chroma;
|
|
688
|
-
} else {
|
|
689
|
-
hue = 4 + (r2 - g2) / chroma;
|
|
690
|
-
}
|
|
691
|
-
hue /= 6;
|
|
692
|
-
hue %= 1;
|
|
693
|
-
return [hue * 360, chroma * 100, grayscale * 100];
|
|
694
|
-
};
|
|
695
|
-
convert2.hsl.hcg = function(hsl) {
|
|
696
|
-
const s2 = hsl[1] / 100;
|
|
697
|
-
const l2 = hsl[2] / 100;
|
|
698
|
-
const c2 = l2 < 0.5 ? 2 * s2 * l2 : 2 * s2 * (1 - l2);
|
|
699
|
-
let f2 = 0;
|
|
700
|
-
if (c2 < 1) {
|
|
701
|
-
f2 = (l2 - 0.5 * c2) / (1 - c2);
|
|
702
|
-
}
|
|
703
|
-
return [hsl[0], c2 * 100, f2 * 100];
|
|
704
|
-
};
|
|
705
|
-
convert2.hsv.hcg = function(hsv) {
|
|
706
|
-
const s2 = hsv[1] / 100;
|
|
707
|
-
const v2 = hsv[2] / 100;
|
|
708
|
-
const c2 = s2 * v2;
|
|
709
|
-
let f2 = 0;
|
|
710
|
-
if (c2 < 1) {
|
|
711
|
-
f2 = (v2 - c2) / (1 - c2);
|
|
712
|
-
}
|
|
713
|
-
return [hsv[0], c2 * 100, f2 * 100];
|
|
714
|
-
};
|
|
715
|
-
convert2.hcg.rgb = function(hcg) {
|
|
716
|
-
const h2 = hcg[0] / 360;
|
|
717
|
-
const c2 = hcg[1] / 100;
|
|
718
|
-
const g2 = hcg[2] / 100;
|
|
719
|
-
if (c2 === 0) {
|
|
720
|
-
return [g2 * 255, g2 * 255, g2 * 255];
|
|
721
|
-
}
|
|
722
|
-
const pure = [0, 0, 0];
|
|
723
|
-
const hi = h2 % 1 * 6;
|
|
724
|
-
const v2 = hi % 1;
|
|
725
|
-
const w2 = 1 - v2;
|
|
726
|
-
let mg = 0;
|
|
727
|
-
switch (Math.floor(hi)) {
|
|
728
|
-
case 0:
|
|
729
|
-
pure[0] = 1;
|
|
730
|
-
pure[1] = v2;
|
|
731
|
-
pure[2] = 0;
|
|
732
|
-
break;
|
|
733
|
-
case 1:
|
|
734
|
-
pure[0] = w2;
|
|
735
|
-
pure[1] = 1;
|
|
736
|
-
pure[2] = 0;
|
|
737
|
-
break;
|
|
738
|
-
case 2:
|
|
739
|
-
pure[0] = 0;
|
|
740
|
-
pure[1] = 1;
|
|
741
|
-
pure[2] = v2;
|
|
742
|
-
break;
|
|
743
|
-
case 3:
|
|
744
|
-
pure[0] = 0;
|
|
745
|
-
pure[1] = w2;
|
|
746
|
-
pure[2] = 1;
|
|
747
|
-
break;
|
|
748
|
-
case 4:
|
|
749
|
-
pure[0] = v2;
|
|
750
|
-
pure[1] = 0;
|
|
751
|
-
pure[2] = 1;
|
|
752
|
-
break;
|
|
753
|
-
default:
|
|
754
|
-
pure[0] = 1;
|
|
755
|
-
pure[1] = 0;
|
|
756
|
-
pure[2] = w2;
|
|
757
|
-
}
|
|
758
|
-
mg = (1 - c2) * g2;
|
|
759
|
-
return [
|
|
760
|
-
(c2 * pure[0] + mg) * 255,
|
|
761
|
-
(c2 * pure[1] + mg) * 255,
|
|
762
|
-
(c2 * pure[2] + mg) * 255
|
|
763
|
-
];
|
|
764
|
-
};
|
|
765
|
-
convert2.hcg.hsv = function(hcg) {
|
|
766
|
-
const c2 = hcg[1] / 100;
|
|
767
|
-
const g2 = hcg[2] / 100;
|
|
768
|
-
const v2 = c2 + g2 * (1 - c2);
|
|
769
|
-
let f2 = 0;
|
|
770
|
-
if (v2 > 0) {
|
|
771
|
-
f2 = c2 / v2;
|
|
772
|
-
}
|
|
773
|
-
return [hcg[0], f2 * 100, v2 * 100];
|
|
774
|
-
};
|
|
775
|
-
convert2.hcg.hsl = function(hcg) {
|
|
776
|
-
const c2 = hcg[1] / 100;
|
|
777
|
-
const g2 = hcg[2] / 100;
|
|
778
|
-
const l2 = g2 * (1 - c2) + 0.5 * c2;
|
|
779
|
-
let s2 = 0;
|
|
780
|
-
if (l2 > 0 && l2 < 0.5) {
|
|
781
|
-
s2 = c2 / (2 * l2);
|
|
782
|
-
} else if (l2 >= 0.5 && l2 < 1) {
|
|
783
|
-
s2 = c2 / (2 * (1 - l2));
|
|
784
|
-
}
|
|
785
|
-
return [hcg[0], s2 * 100, l2 * 100];
|
|
786
|
-
};
|
|
787
|
-
convert2.hcg.hwb = function(hcg) {
|
|
788
|
-
const c2 = hcg[1] / 100;
|
|
789
|
-
const g2 = hcg[2] / 100;
|
|
790
|
-
const v2 = c2 + g2 * (1 - c2);
|
|
791
|
-
return [hcg[0], (v2 - c2) * 100, (1 - v2) * 100];
|
|
792
|
-
};
|
|
793
|
-
convert2.hwb.hcg = function(hwb) {
|
|
794
|
-
const w2 = hwb[1] / 100;
|
|
795
|
-
const b2 = hwb[2] / 100;
|
|
796
|
-
const v2 = 1 - b2;
|
|
797
|
-
const c2 = v2 - w2;
|
|
798
|
-
let g2 = 0;
|
|
799
|
-
if (c2 < 1) {
|
|
800
|
-
g2 = (v2 - c2) / (1 - c2);
|
|
801
|
-
}
|
|
802
|
-
return [hwb[0], c2 * 100, g2 * 100];
|
|
803
|
-
};
|
|
804
|
-
convert2.apple.rgb = function(apple) {
|
|
805
|
-
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
806
|
-
};
|
|
807
|
-
convert2.rgb.apple = function(rgb) {
|
|
808
|
-
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
809
|
-
};
|
|
810
|
-
convert2.gray.rgb = function(args) {
|
|
811
|
-
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
812
|
-
};
|
|
813
|
-
convert2.gray.hsl = function(args) {
|
|
814
|
-
return [0, 0, args[0]];
|
|
815
|
-
};
|
|
816
|
-
convert2.gray.hsv = convert2.gray.hsl;
|
|
817
|
-
convert2.gray.hwb = function(gray) {
|
|
818
|
-
return [0, 100, gray[0]];
|
|
819
|
-
};
|
|
820
|
-
convert2.gray.cmyk = function(gray) {
|
|
821
|
-
return [0, 0, 0, gray[0]];
|
|
822
|
-
};
|
|
823
|
-
convert2.gray.lab = function(gray) {
|
|
824
|
-
return [gray[0], 0, 0];
|
|
825
|
-
};
|
|
826
|
-
convert2.gray.hex = function(gray) {
|
|
827
|
-
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
828
|
-
const integer = (val << 16) + (val << 8) + val;
|
|
829
|
-
const string = integer.toString(16).toUpperCase();
|
|
830
|
-
return "000000".substring(string.length) + string;
|
|
831
|
-
};
|
|
832
|
-
convert2.rgb.gray = function(rgb) {
|
|
833
|
-
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
834
|
-
return [val / 255 * 100];
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
|
|
839
|
-
// ../../node_modules/color-convert/route.js
|
|
840
|
-
var require_route = __commonJS({
|
|
841
|
-
"../../node_modules/color-convert/route.js"(exports, module) {
|
|
842
|
-
var conversions = require_conversions();
|
|
843
|
-
function buildGraph() {
|
|
844
|
-
const graph = {};
|
|
845
|
-
const models = Object.keys(conversions);
|
|
846
|
-
for (let len = models.length, i2 = 0; i2 < len; i2++) {
|
|
847
|
-
graph[models[i2]] = {
|
|
848
|
-
// http://jsperf.com/1-vs-infinity
|
|
849
|
-
// micro-opt, but this is simple.
|
|
850
|
-
distance: -1,
|
|
851
|
-
parent: null
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
return graph;
|
|
855
|
-
}
|
|
856
|
-
__name(buildGraph, "buildGraph");
|
|
857
|
-
function deriveBFS(fromModel) {
|
|
858
|
-
const graph = buildGraph();
|
|
859
|
-
const queue = [fromModel];
|
|
860
|
-
graph[fromModel].distance = 0;
|
|
861
|
-
while (queue.length) {
|
|
862
|
-
const current = queue.pop();
|
|
863
|
-
const adjacents = Object.keys(conversions[current]);
|
|
864
|
-
for (let len = adjacents.length, i2 = 0; i2 < len; i2++) {
|
|
865
|
-
const adjacent = adjacents[i2];
|
|
866
|
-
const node = graph[adjacent];
|
|
867
|
-
if (node.distance === -1) {
|
|
868
|
-
node.distance = graph[current].distance + 1;
|
|
869
|
-
node.parent = current;
|
|
870
|
-
queue.unshift(adjacent);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
return graph;
|
|
875
|
-
}
|
|
876
|
-
__name(deriveBFS, "deriveBFS");
|
|
877
|
-
function link(from, to) {
|
|
878
|
-
return function(args) {
|
|
879
|
-
return to(from(args));
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
__name(link, "link");
|
|
883
|
-
function wrapConversion(toModel, graph) {
|
|
884
|
-
const path = [graph[toModel].parent, toModel];
|
|
885
|
-
let fn = conversions[graph[toModel].parent][toModel];
|
|
886
|
-
let cur = graph[toModel].parent;
|
|
887
|
-
while (graph[cur].parent) {
|
|
888
|
-
path.unshift(graph[cur].parent);
|
|
889
|
-
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
890
|
-
cur = graph[cur].parent;
|
|
891
|
-
}
|
|
892
|
-
fn.conversion = path;
|
|
893
|
-
return fn;
|
|
894
|
-
}
|
|
895
|
-
__name(wrapConversion, "wrapConversion");
|
|
896
|
-
module.exports = function(fromModel) {
|
|
897
|
-
const graph = deriveBFS(fromModel);
|
|
898
|
-
const conversion = {};
|
|
899
|
-
const models = Object.keys(graph);
|
|
900
|
-
for (let len = models.length, i2 = 0; i2 < len; i2++) {
|
|
901
|
-
const toModel = models[i2];
|
|
902
|
-
const node = graph[toModel];
|
|
903
|
-
if (node.parent === null) {
|
|
904
|
-
continue;
|
|
905
|
-
}
|
|
906
|
-
conversion[toModel] = wrapConversion(toModel, graph);
|
|
907
|
-
}
|
|
908
|
-
return conversion;
|
|
909
|
-
};
|
|
910
|
-
}
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// ../../node_modules/color-convert/index.js
|
|
914
|
-
var require_color_convert = __commonJS({
|
|
915
|
-
"../../node_modules/color-convert/index.js"(exports, module) {
|
|
916
|
-
var conversions = require_conversions();
|
|
917
|
-
var route = require_route();
|
|
918
|
-
var convert2 = {};
|
|
919
|
-
var models = Object.keys(conversions);
|
|
920
|
-
function wrapRaw(fn) {
|
|
921
|
-
const wrappedFn = /* @__PURE__ */ __name(function(...args) {
|
|
922
|
-
const arg0 = args[0];
|
|
923
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
924
|
-
return arg0;
|
|
925
|
-
}
|
|
926
|
-
if (arg0.length > 1) {
|
|
927
|
-
args = arg0;
|
|
928
|
-
}
|
|
929
|
-
return fn(args);
|
|
930
|
-
}, "wrappedFn");
|
|
931
|
-
if ("conversion" in fn) {
|
|
932
|
-
wrappedFn.conversion = fn.conversion;
|
|
933
|
-
}
|
|
934
|
-
return wrappedFn;
|
|
935
|
-
}
|
|
936
|
-
__name(wrapRaw, "wrapRaw");
|
|
937
|
-
function wrapRounded(fn) {
|
|
938
|
-
const wrappedFn = /* @__PURE__ */ __name(function(...args) {
|
|
939
|
-
const arg0 = args[0];
|
|
940
|
-
if (arg0 === void 0 || arg0 === null) {
|
|
941
|
-
return arg0;
|
|
942
|
-
}
|
|
943
|
-
if (arg0.length > 1) {
|
|
944
|
-
args = arg0;
|
|
945
|
-
}
|
|
946
|
-
const result = fn(args);
|
|
947
|
-
if (typeof result === "object") {
|
|
948
|
-
for (let len = result.length, i2 = 0; i2 < len; i2++) {
|
|
949
|
-
result[i2] = Math.round(result[i2]);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return result;
|
|
953
|
-
}, "wrappedFn");
|
|
954
|
-
if ("conversion" in fn) {
|
|
955
|
-
wrappedFn.conversion = fn.conversion;
|
|
956
|
-
}
|
|
957
|
-
return wrappedFn;
|
|
958
|
-
}
|
|
959
|
-
__name(wrapRounded, "wrapRounded");
|
|
960
|
-
models.forEach((fromModel) => {
|
|
961
|
-
convert2[fromModel] = {};
|
|
962
|
-
Object.defineProperty(convert2[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
963
|
-
Object.defineProperty(convert2[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
964
|
-
const routes = route(fromModel);
|
|
965
|
-
const routeModels = Object.keys(routes);
|
|
966
|
-
routeModels.forEach((toModel) => {
|
|
967
|
-
const fn = routes[toModel];
|
|
968
|
-
convert2[fromModel][toModel] = wrapRounded(fn);
|
|
969
|
-
convert2[fromModel][toModel].raw = wrapRaw(fn);
|
|
970
|
-
});
|
|
971
|
-
});
|
|
972
|
-
module.exports = convert2;
|
|
973
|
-
}
|
|
974
|
-
});
|
|
975
|
-
|
|
976
|
-
// src/blocks/controls/Color.tsx
|
|
977
|
-
var import_color_convert = __toESM(require_color_convert(), 1);
|
|
978
|
-
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
979
|
-
import { Button, Form, PopoverProvider } from "storybook/internal/components";
|
|
980
|
-
import { MarkupIcon } from "@storybook/icons";
|
|
981
|
-
|
|
982
|
-
// ../../node_modules/es-toolkit/dist/function/debounce.mjs
|
|
983
|
-
function debounce(func, debounceMs, { signal, edges } = {}) {
|
|
984
|
-
let pendingThis = void 0;
|
|
985
|
-
let pendingArgs = null;
|
|
986
|
-
const leading = edges != null && edges.includes("leading");
|
|
987
|
-
const trailing = edges == null || edges.includes("trailing");
|
|
988
|
-
const invoke = /* @__PURE__ */ __name(() => {
|
|
989
|
-
if (pendingArgs !== null) {
|
|
990
|
-
func.apply(pendingThis, pendingArgs);
|
|
991
|
-
pendingThis = void 0;
|
|
992
|
-
pendingArgs = null;
|
|
993
|
-
}
|
|
994
|
-
}, "invoke");
|
|
995
|
-
const onTimerEnd = /* @__PURE__ */ __name(() => {
|
|
996
|
-
if (trailing) {
|
|
997
|
-
invoke();
|
|
998
|
-
}
|
|
999
|
-
cancel();
|
|
1000
|
-
}, "onTimerEnd");
|
|
1001
|
-
let timeoutId = null;
|
|
1002
|
-
const schedule = /* @__PURE__ */ __name(() => {
|
|
1003
|
-
if (timeoutId != null) {
|
|
1004
|
-
clearTimeout(timeoutId);
|
|
1005
|
-
}
|
|
1006
|
-
timeoutId = setTimeout(() => {
|
|
1007
|
-
timeoutId = null;
|
|
1008
|
-
onTimerEnd();
|
|
1009
|
-
}, debounceMs);
|
|
1010
|
-
}, "schedule");
|
|
1011
|
-
const cancelTimer = /* @__PURE__ */ __name(() => {
|
|
1012
|
-
if (timeoutId !== null) {
|
|
1013
|
-
clearTimeout(timeoutId);
|
|
1014
|
-
timeoutId = null;
|
|
1015
|
-
}
|
|
1016
|
-
}, "cancelTimer");
|
|
1017
|
-
const cancel = /* @__PURE__ */ __name(() => {
|
|
1018
|
-
cancelTimer();
|
|
1019
|
-
pendingThis = void 0;
|
|
1020
|
-
pendingArgs = null;
|
|
1021
|
-
}, "cancel");
|
|
1022
|
-
const flush = /* @__PURE__ */ __name(() => {
|
|
1023
|
-
invoke();
|
|
1024
|
-
}, "flush");
|
|
1025
|
-
const debounced = /* @__PURE__ */ __name(function(...args) {
|
|
1026
|
-
if (signal?.aborted) {
|
|
1027
|
-
return;
|
|
1028
|
-
}
|
|
1029
|
-
pendingThis = this;
|
|
1030
|
-
pendingArgs = args;
|
|
1031
|
-
const isFirstCall = timeoutId == null;
|
|
1032
|
-
schedule();
|
|
1033
|
-
if (leading && isFirstCall) {
|
|
1034
|
-
invoke();
|
|
1035
|
-
}
|
|
1036
|
-
}, "debounced");
|
|
1037
|
-
debounced.schedule = schedule;
|
|
1038
|
-
debounced.cancel = cancel;
|
|
1039
|
-
debounced.flush = flush;
|
|
1040
|
-
signal?.addEventListener("abort", cancel, { once: true });
|
|
1041
|
-
return debounced;
|
|
1042
|
-
}
|
|
1043
|
-
__name(debounce, "debounce");
|
|
1044
|
-
|
|
1045
|
-
// ../../node_modules/es-toolkit/dist/function/partial.mjs
|
|
1046
|
-
function partial(func, ...partialArgs) {
|
|
1047
|
-
return partialImpl(func, placeholderSymbol, ...partialArgs);
|
|
1048
|
-
}
|
|
1049
|
-
__name(partial, "partial");
|
|
1050
|
-
function partialImpl(func, placeholder, ...partialArgs) {
|
|
1051
|
-
const partialed = /* @__PURE__ */ __name(function(...providedArgs) {
|
|
1052
|
-
let providedArgsIndex = 0;
|
|
1053
|
-
const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg);
|
|
1054
|
-
const remainingArgs = providedArgs.slice(providedArgsIndex);
|
|
1055
|
-
return func.apply(this, substitutedArgs.concat(remainingArgs));
|
|
1056
|
-
}, "partialed");
|
|
1057
|
-
if (func.prototype) {
|
|
1058
|
-
partialed.prototype = Object.create(func.prototype);
|
|
1059
|
-
}
|
|
1060
|
-
return partialed;
|
|
1061
|
-
}
|
|
1062
|
-
__name(partialImpl, "partialImpl");
|
|
1063
|
-
var placeholderSymbol = Symbol("partial.placeholder");
|
|
1064
|
-
partial.placeholder = placeholderSymbol;
|
|
1065
|
-
|
|
1066
|
-
// ../../node_modules/es-toolkit/dist/function/partialRight.mjs
|
|
1067
|
-
function partialRight(func, ...partialArgs) {
|
|
1068
|
-
return partialRightImpl(func, placeholderSymbol2, ...partialArgs);
|
|
1069
|
-
}
|
|
1070
|
-
__name(partialRight, "partialRight");
|
|
1071
|
-
function partialRightImpl(func, placeholder, ...partialArgs) {
|
|
1072
|
-
const partialedRight = /* @__PURE__ */ __name(function(...providedArgs) {
|
|
1073
|
-
const placeholderLength = partialArgs.filter((arg) => arg === placeholder).length;
|
|
1074
|
-
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
1075
|
-
const remainingArgs = providedArgs.slice(0, rangeLength);
|
|
1076
|
-
let providedArgsIndex = rangeLength;
|
|
1077
|
-
const substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg);
|
|
1078
|
-
return func.apply(this, remainingArgs.concat(substitutedArgs));
|
|
1079
|
-
}, "partialedRight");
|
|
1080
|
-
if (func.prototype) {
|
|
1081
|
-
partialedRight.prototype = Object.create(func.prototype);
|
|
1082
|
-
}
|
|
1083
|
-
return partialedRight;
|
|
1084
|
-
}
|
|
1085
|
-
__name(partialRightImpl, "partialRightImpl");
|
|
1086
|
-
var placeholderSymbol2 = Symbol("partialRight.placeholder");
|
|
1087
|
-
partialRight.placeholder = placeholderSymbol2;
|
|
1088
|
-
|
|
1089
|
-
// ../../node_modules/es-toolkit/dist/function/retry.mjs
|
|
1090
|
-
var DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
|
|
1091
|
-
|
|
1092
|
-
// ../../node_modules/react-colorful/dist/index.mjs
|
|
1093
|
-
import e, { useRef as r, useMemo as t, useEffect as n, useState as o, useCallback as a, useLayoutEffect as l } from "react";
|
|
1094
|
-
function u() {
|
|
1095
|
-
return (u = Object.assign || function(e2) {
|
|
1096
|
-
for (var r2 = 1; r2 < arguments.length; r2++) {
|
|
1097
|
-
var t2 = arguments[r2];
|
|
1098
|
-
for (var n2 in t2) Object.prototype.hasOwnProperty.call(t2, n2) && (e2[n2] = t2[n2]);
|
|
1099
|
-
}
|
|
1100
|
-
return e2;
|
|
1101
|
-
}).apply(this, arguments);
|
|
1102
|
-
}
|
|
1103
|
-
__name(u, "u");
|
|
1104
|
-
function c(e2, r2) {
|
|
1105
|
-
if (null == e2) return {};
|
|
1106
|
-
var t2, n2, o2 = {}, a2 = Object.keys(e2);
|
|
1107
|
-
for (n2 = 0; n2 < a2.length; n2++) r2.indexOf(t2 = a2[n2]) >= 0 || (o2[t2] = e2[t2]);
|
|
1108
|
-
return o2;
|
|
1109
|
-
}
|
|
1110
|
-
__name(c, "c");
|
|
1111
|
-
function i(e2) {
|
|
1112
|
-
var t2 = r(e2), n2 = r(function(e3) {
|
|
1113
|
-
t2.current && t2.current(e3);
|
|
1114
|
-
});
|
|
1115
|
-
return t2.current = e2, n2.current;
|
|
1116
|
-
}
|
|
1117
|
-
__name(i, "i");
|
|
1118
|
-
var s = /* @__PURE__ */ __name(function(e2, r2, t2) {
|
|
1119
|
-
return void 0 === r2 && (r2 = 0), void 0 === t2 && (t2 = 1), e2 > t2 ? t2 : e2 < r2 ? r2 : e2;
|
|
1120
|
-
}, "s");
|
|
1121
|
-
var f = /* @__PURE__ */ __name(function(e2) {
|
|
1122
|
-
return "touches" in e2;
|
|
1123
|
-
}, "f");
|
|
1124
|
-
var v = /* @__PURE__ */ __name(function(e2) {
|
|
1125
|
-
return e2 && e2.ownerDocument.defaultView || self;
|
|
1126
|
-
}, "v");
|
|
1127
|
-
var d = /* @__PURE__ */ __name(function(e2, r2, t2) {
|
|
1128
|
-
var n2 = e2.getBoundingClientRect(), o2 = f(r2) ? function(e3, r3) {
|
|
1129
|
-
for (var t3 = 0; t3 < e3.length; t3++) if (e3[t3].identifier === r3) return e3[t3];
|
|
1130
|
-
return e3[0];
|
|
1131
|
-
}(r2.touches, t2) : r2;
|
|
1132
|
-
return { left: s((o2.pageX - (n2.left + v(e2).pageXOffset)) / n2.width), top: s((o2.pageY - (n2.top + v(e2).pageYOffset)) / n2.height) };
|
|
1133
|
-
}, "d");
|
|
1134
|
-
var h = /* @__PURE__ */ __name(function(e2) {
|
|
1135
|
-
!f(e2) && e2.preventDefault();
|
|
1136
|
-
}, "h");
|
|
1137
|
-
var m = e.memo(function(o2) {
|
|
1138
|
-
var a2 = o2.onMove, l2 = o2.onKey, s2 = c(o2, ["onMove", "onKey"]), m2 = r(null), g2 = i(a2), p2 = i(l2), b2 = r(null), _2 = r(false), x2 = t(function() {
|
|
1139
|
-
var e2 = /* @__PURE__ */ __name(function(e3) {
|
|
1140
|
-
h(e3), (f(e3) ? e3.touches.length > 0 : e3.buttons > 0) && m2.current ? g2(d(m2.current, e3, b2.current)) : t2(false);
|
|
1141
|
-
}, "e"), r2 = /* @__PURE__ */ __name(function() {
|
|
1142
|
-
return t2(false);
|
|
1143
|
-
}, "r");
|
|
1144
|
-
function t2(t3) {
|
|
1145
|
-
var n2 = _2.current, o3 = v(m2.current), a3 = t3 ? o3.addEventListener : o3.removeEventListener;
|
|
1146
|
-
a3(n2 ? "touchmove" : "mousemove", e2), a3(n2 ? "touchend" : "mouseup", r2);
|
|
1147
|
-
}
|
|
1148
|
-
__name(t2, "t");
|
|
1149
|
-
return [function(e3) {
|
|
1150
|
-
var r3 = e3.nativeEvent, n2 = m2.current;
|
|
1151
|
-
if (n2 && (h(r3), !function(e4, r4) {
|
|
1152
|
-
return r4 && !f(e4);
|
|
1153
|
-
}(r3, _2.current) && n2)) {
|
|
1154
|
-
if (f(r3)) {
|
|
1155
|
-
_2.current = true;
|
|
1156
|
-
var o3 = r3.changedTouches || [];
|
|
1157
|
-
o3.length && (b2.current = o3[0].identifier);
|
|
1158
|
-
}
|
|
1159
|
-
n2.focus(), g2(d(n2, r3, b2.current)), t2(true);
|
|
1160
|
-
}
|
|
1161
|
-
}, function(e3) {
|
|
1162
|
-
var r3 = e3.which || e3.keyCode;
|
|
1163
|
-
r3 < 37 || r3 > 40 || (e3.preventDefault(), p2({ left: 39 === r3 ? 0.05 : 37 === r3 ? -0.05 : 0, top: 40 === r3 ? 0.05 : 38 === r3 ? -0.05 : 0 }));
|
|
1164
|
-
}, t2];
|
|
1165
|
-
}, [p2, g2]), C2 = x2[0], E2 = x2[1], H2 = x2[2];
|
|
1166
|
-
return n(function() {
|
|
1167
|
-
return H2;
|
|
1168
|
-
}, [H2]), e.createElement("div", u({}, s2, { onTouchStart: C2, onMouseDown: C2, className: "react-colorful__interactive", ref: m2, onKeyDown: E2, tabIndex: 0, role: "slider" }));
|
|
1169
|
-
});
|
|
1170
|
-
var g = /* @__PURE__ */ __name(function(e2) {
|
|
1171
|
-
return e2.filter(Boolean).join(" ");
|
|
1172
|
-
}, "g");
|
|
1173
|
-
var p = /* @__PURE__ */ __name(function(r2) {
|
|
1174
|
-
var t2 = r2.color, n2 = r2.left, o2 = r2.top, a2 = void 0 === o2 ? 0.5 : o2, l2 = g(["react-colorful__pointer", r2.className]);
|
|
1175
|
-
return e.createElement("div", { className: l2, style: { top: 100 * a2 + "%", left: 100 * n2 + "%" } }, e.createElement("div", { className: "react-colorful__pointer-fill", style: { backgroundColor: t2 } }));
|
|
1176
|
-
}, "p");
|
|
1177
|
-
var b = /* @__PURE__ */ __name(function(e2, r2, t2) {
|
|
1178
|
-
return void 0 === r2 && (r2 = 0), void 0 === t2 && (t2 = Math.pow(10, r2)), Math.round(t2 * e2) / t2;
|
|
1179
|
-
}, "b");
|
|
1180
|
-
var _ = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
|
|
1181
|
-
var x = /* @__PURE__ */ __name(function(e2) {
|
|
1182
|
-
return L(C(e2));
|
|
1183
|
-
}, "x");
|
|
1184
|
-
var C = /* @__PURE__ */ __name(function(e2) {
|
|
1185
|
-
return "#" === e2[0] && (e2 = e2.substring(1)), e2.length < 6 ? { r: parseInt(e2[0] + e2[0], 16), g: parseInt(e2[1] + e2[1], 16), b: parseInt(e2[2] + e2[2], 16), a: 4 === e2.length ? b(parseInt(e2[3] + e2[3], 16) / 255, 2) : 1 } : { r: parseInt(e2.substring(0, 2), 16), g: parseInt(e2.substring(2, 4), 16), b: parseInt(e2.substring(4, 6), 16), a: 8 === e2.length ? b(parseInt(e2.substring(6, 8), 16) / 255, 2) : 1 };
|
|
1186
|
-
}, "C");
|
|
1187
|
-
var E = /* @__PURE__ */ __name(function(e2, r2) {
|
|
1188
|
-
return void 0 === r2 && (r2 = "deg"), Number(e2) * (_[r2] || 1);
|
|
1189
|
-
}, "E");
|
|
1190
|
-
var H = /* @__PURE__ */ __name(function(e2) {
|
|
1191
|
-
var r2 = /hsla?\(?\s*(-?\d*\.?\d+)(deg|rad|grad|turn)?[,\s]+(-?\d*\.?\d+)%?[,\s]+(-?\d*\.?\d+)%?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e2);
|
|
1192
|
-
return r2 ? N({ h: E(r2[1], r2[2]), s: Number(r2[3]), l: Number(r2[4]), a: void 0 === r2[5] ? 1 : Number(r2[5]) / (r2[6] ? 100 : 1) }) : { h: 0, s: 0, v: 0, a: 1 };
|
|
1193
|
-
}, "H");
|
|
1194
|
-
var N = /* @__PURE__ */ __name(function(e2) {
|
|
1195
|
-
var r2 = e2.s, t2 = e2.l;
|
|
1196
|
-
return { h: e2.h, s: (r2 *= (t2 < 50 ? t2 : 100 - t2) / 100) > 0 ? 2 * r2 / (t2 + r2) * 100 : 0, v: t2 + r2, a: e2.a };
|
|
1197
|
-
}, "N");
|
|
1198
|
-
var w = /* @__PURE__ */ __name(function(e2) {
|
|
1199
|
-
return K(I(e2));
|
|
1200
|
-
}, "w");
|
|
1201
|
-
var y = /* @__PURE__ */ __name(function(e2) {
|
|
1202
|
-
var r2 = e2.s, t2 = e2.v, n2 = e2.a, o2 = (200 - r2) * t2 / 100;
|
|
1203
|
-
return { h: b(e2.h), s: b(o2 > 0 && o2 < 200 ? r2 * t2 / 100 / (o2 <= 100 ? o2 : 200 - o2) * 100 : 0), l: b(o2 / 2), a: b(n2, 2) };
|
|
1204
|
-
}, "y");
|
|
1205
|
-
var q = /* @__PURE__ */ __name(function(e2) {
|
|
1206
|
-
var r2 = y(e2);
|
|
1207
|
-
return "hsl(" + r2.h + ", " + r2.s + "%, " + r2.l + "%)";
|
|
1208
|
-
}, "q");
|
|
1209
|
-
var k = /* @__PURE__ */ __name(function(e2) {
|
|
1210
|
-
var r2 = y(e2);
|
|
1211
|
-
return "hsla(" + r2.h + ", " + r2.s + "%, " + r2.l + "%, " + r2.a + ")";
|
|
1212
|
-
}, "k");
|
|
1213
|
-
var I = /* @__PURE__ */ __name(function(e2) {
|
|
1214
|
-
var r2 = e2.h, t2 = e2.s, n2 = e2.v, o2 = e2.a;
|
|
1215
|
-
r2 = r2 / 360 * 6, t2 /= 100, n2 /= 100;
|
|
1216
|
-
var a2 = Math.floor(r2), l2 = n2 * (1 - t2), u2 = n2 * (1 - (r2 - a2) * t2), c2 = n2 * (1 - (1 - r2 + a2) * t2), i2 = a2 % 6;
|
|
1217
|
-
return { r: b(255 * [n2, u2, l2, l2, c2, n2][i2]), g: b(255 * [c2, n2, n2, u2, l2, l2][i2]), b: b(255 * [l2, l2, c2, n2, n2, u2][i2]), a: b(o2, 2) };
|
|
1218
|
-
}, "I");
|
|
1219
|
-
var z = /* @__PURE__ */ __name(function(e2) {
|
|
1220
|
-
var r2 = /rgba?\(?\s*(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?[,\s]+(-?\d*\.?\d+)(%)?,?\s*[/\s]*(-?\d*\.?\d+)?(%)?\s*\)?/i.exec(e2);
|
|
1221
|
-
return r2 ? L({ r: Number(r2[1]) / (r2[2] ? 100 / 255 : 1), g: Number(r2[3]) / (r2[4] ? 100 / 255 : 1), b: Number(r2[5]) / (r2[6] ? 100 / 255 : 1), a: void 0 === r2[7] ? 1 : Number(r2[7]) / (r2[8] ? 100 : 1) }) : { h: 0, s: 0, v: 0, a: 1 };
|
|
1222
|
-
}, "z");
|
|
1223
|
-
var D = /* @__PURE__ */ __name(function(e2) {
|
|
1224
|
-
var r2 = e2.toString(16);
|
|
1225
|
-
return r2.length < 2 ? "0" + r2 : r2;
|
|
1226
|
-
}, "D");
|
|
1227
|
-
var K = /* @__PURE__ */ __name(function(e2) {
|
|
1228
|
-
var r2 = e2.r, t2 = e2.g, n2 = e2.b, o2 = e2.a, a2 = o2 < 1 ? D(b(255 * o2)) : "";
|
|
1229
|
-
return "#" + D(r2) + D(t2) + D(n2) + a2;
|
|
1230
|
-
}, "K");
|
|
1231
|
-
var L = /* @__PURE__ */ __name(function(e2) {
|
|
1232
|
-
var r2 = e2.r, t2 = e2.g, n2 = e2.b, o2 = e2.a, a2 = Math.max(r2, t2, n2), l2 = a2 - Math.min(r2, t2, n2), u2 = l2 ? a2 === r2 ? (t2 - n2) / l2 : a2 === t2 ? 2 + (n2 - r2) / l2 : 4 + (r2 - t2) / l2 : 0;
|
|
1233
|
-
return { h: b(60 * (u2 < 0 ? u2 + 6 : u2)), s: b(a2 ? l2 / a2 * 100 : 0), v: b(a2 / 255 * 100), a: o2 };
|
|
1234
|
-
}, "L");
|
|
1235
|
-
var S = e.memo(function(r2) {
|
|
1236
|
-
var t2 = r2.hue, n2 = r2.onChange, o2 = g(["react-colorful__hue", r2.className]);
|
|
1237
|
-
return e.createElement("div", { className: o2 }, e.createElement(m, { onMove: /* @__PURE__ */ __name(function(e2) {
|
|
1238
|
-
n2({ h: 360 * e2.left });
|
|
1239
|
-
}, "onMove"), onKey: /* @__PURE__ */ __name(function(e2) {
|
|
1240
|
-
n2({ h: s(t2 + 360 * e2.left, 0, 360) });
|
|
1241
|
-
}, "onKey"), "aria-label": "Hue", "aria-valuenow": b(t2), "aria-valuemax": "360", "aria-valuemin": "0" }, e.createElement(p, { className: "react-colorful__hue-pointer", left: t2 / 360, color: q({ h: t2, s: 100, v: 100, a: 1 }) })));
|
|
1242
|
-
});
|
|
1243
|
-
var T = e.memo(function(r2) {
|
|
1244
|
-
var t2 = r2.hsva, n2 = r2.onChange, o2 = { backgroundColor: q({ h: t2.h, s: 100, v: 100, a: 1 }) };
|
|
1245
|
-
return e.createElement("div", { className: "react-colorful__saturation", style: o2 }, e.createElement(m, { onMove: /* @__PURE__ */ __name(function(e2) {
|
|
1246
|
-
n2({ s: 100 * e2.left, v: 100 - 100 * e2.top });
|
|
1247
|
-
}, "onMove"), onKey: /* @__PURE__ */ __name(function(e2) {
|
|
1248
|
-
n2({ s: s(t2.s + 100 * e2.left, 0, 100), v: s(t2.v - 100 * e2.top, 0, 100) });
|
|
1249
|
-
}, "onKey"), "aria-label": "Color", "aria-valuetext": "Saturation " + b(t2.s) + "%, Brightness " + b(t2.v) + "%" }, e.createElement(p, { className: "react-colorful__saturation-pointer", top: 1 - t2.v / 100, left: t2.s / 100, color: q(t2) })));
|
|
1250
|
-
});
|
|
1251
|
-
var F = /* @__PURE__ */ __name(function(e2, r2) {
|
|
1252
|
-
if (e2 === r2) return true;
|
|
1253
|
-
for (var t2 in e2) if (e2[t2] !== r2[t2]) return false;
|
|
1254
|
-
return true;
|
|
1255
|
-
}, "F");
|
|
1256
|
-
var P = /* @__PURE__ */ __name(function(e2, r2) {
|
|
1257
|
-
return e2.replace(/\s/g, "") === r2.replace(/\s/g, "");
|
|
1258
|
-
}, "P");
|
|
1259
|
-
var X = /* @__PURE__ */ __name(function(e2, r2) {
|
|
1260
|
-
return e2.toLowerCase() === r2.toLowerCase() || F(C(e2), C(r2));
|
|
1261
|
-
}, "X");
|
|
1262
|
-
function Y(e2, t2, l2) {
|
|
1263
|
-
var u2 = i(l2), c2 = o(function() {
|
|
1264
|
-
return e2.toHsva(t2);
|
|
1265
|
-
}), s2 = c2[0], f2 = c2[1], v2 = r({ color: t2, hsva: s2 });
|
|
1266
|
-
n(function() {
|
|
1267
|
-
if (!e2.equal(t2, v2.current.color)) {
|
|
1268
|
-
var r2 = e2.toHsva(t2);
|
|
1269
|
-
v2.current = { hsva: r2, color: t2 }, f2(r2);
|
|
1270
|
-
}
|
|
1271
|
-
}, [t2, e2]), n(function() {
|
|
1272
|
-
var r2;
|
|
1273
|
-
F(s2, v2.current.hsva) || e2.equal(r2 = e2.fromHsva(s2), v2.current.color) || (v2.current = { hsva: s2, color: r2 }, u2(r2));
|
|
1274
|
-
}, [s2, e2, u2]);
|
|
1275
|
-
var d2 = a(function(e3) {
|
|
1276
|
-
f2(function(r2) {
|
|
1277
|
-
return Object.assign({}, r2, e3);
|
|
1278
|
-
});
|
|
1279
|
-
}, []);
|
|
1280
|
-
return [s2, d2];
|
|
1281
|
-
}
|
|
1282
|
-
__name(Y, "Y");
|
|
1283
|
-
var R;
|
|
1284
|
-
var V = "undefined" != typeof window ? l : n;
|
|
1285
|
-
var $ = /* @__PURE__ */ __name(function() {
|
|
1286
|
-
return R || ("undefined" != typeof __webpack_nonce__ ? __webpack_nonce__ : void 0);
|
|
1287
|
-
}, "$");
|
|
1288
|
-
var J = /* @__PURE__ */ new Map();
|
|
1289
|
-
var Q = /* @__PURE__ */ __name(function(e2) {
|
|
1290
|
-
V(function() {
|
|
1291
|
-
var r2 = e2.current ? e2.current.ownerDocument : document;
|
|
1292
|
-
if (void 0 !== r2 && !J.has(r2)) {
|
|
1293
|
-
var t2 = r2.createElement("style");
|
|
1294
|
-
t2.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}`, J.set(r2, t2);
|
|
1295
|
-
var n2 = $();
|
|
1296
|
-
n2 && t2.setAttribute("nonce", n2), r2.head.appendChild(t2);
|
|
1297
|
-
}
|
|
1298
|
-
}, []);
|
|
1299
|
-
}, "Q");
|
|
1300
|
-
var U = /* @__PURE__ */ __name(function(t2) {
|
|
1301
|
-
var n2 = t2.className, o2 = t2.colorModel, a2 = t2.color, l2 = void 0 === a2 ? o2.defaultColor : a2, i2 = t2.onChange, s2 = c(t2, ["className", "colorModel", "color", "onChange"]), f2 = r(null);
|
|
1302
|
-
Q(f2);
|
|
1303
|
-
var v2 = Y(o2, l2, i2), d2 = v2[0], h2 = v2[1], m2 = g(["react-colorful", n2]);
|
|
1304
|
-
return e.createElement("div", u({}, s2, { ref: f2, className: m2 }), e.createElement(T, { hsva: d2, onChange: h2 }), e.createElement(S, { hue: d2.h, onChange: h2, className: "react-colorful__last-control" }));
|
|
1305
|
-
}, "U");
|
|
1306
|
-
var W = { defaultColor: "000", toHsva: x, fromHsva: /* @__PURE__ */ __name(function(e2) {
|
|
1307
|
-
return w({ h: e2.h, s: e2.s, v: e2.v, a: 1 });
|
|
1308
|
-
}, "fromHsva"), equal: X };
|
|
1309
|
-
var Z = /* @__PURE__ */ __name(function(r2) {
|
|
1310
|
-
return e.createElement(U, u({}, r2, { colorModel: W }));
|
|
1311
|
-
}, "Z");
|
|
1312
|
-
var ee = /* @__PURE__ */ __name(function(r2) {
|
|
1313
|
-
var t2 = r2.className, n2 = r2.hsva, o2 = r2.onChange, a2 = { backgroundImage: "linear-gradient(90deg, " + k(Object.assign({}, n2, { a: 0 })) + ", " + k(Object.assign({}, n2, { a: 1 })) + ")" }, l2 = g(["react-colorful__alpha", t2]), u2 = b(100 * n2.a);
|
|
1314
|
-
return e.createElement("div", { className: l2 }, e.createElement("div", { className: "react-colorful__alpha-gradient", style: a2 }), e.createElement(m, { onMove: /* @__PURE__ */ __name(function(e2) {
|
|
1315
|
-
o2({ a: e2.left });
|
|
1316
|
-
}, "onMove"), onKey: /* @__PURE__ */ __name(function(e2) {
|
|
1317
|
-
o2({ a: s(n2.a + e2.left) });
|
|
1318
|
-
}, "onKey"), "aria-label": "Alpha", "aria-valuetext": u2 + "%", "aria-valuenow": u2, "aria-valuemin": "0", "aria-valuemax": "100" }, e.createElement(p, { className: "react-colorful__alpha-pointer", left: n2.a, color: k(n2) })));
|
|
1319
|
-
}, "ee");
|
|
1320
|
-
var re = /* @__PURE__ */ __name(function(t2) {
|
|
1321
|
-
var n2 = t2.className, o2 = t2.colorModel, a2 = t2.color, l2 = void 0 === a2 ? o2.defaultColor : a2, i2 = t2.onChange, s2 = c(t2, ["className", "colorModel", "color", "onChange"]), f2 = r(null);
|
|
1322
|
-
Q(f2);
|
|
1323
|
-
var v2 = Y(o2, l2, i2), d2 = v2[0], h2 = v2[1], m2 = g(["react-colorful", n2]);
|
|
1324
|
-
return e.createElement("div", u({}, s2, { ref: f2, className: m2 }), e.createElement(T, { hsva: d2, onChange: h2 }), e.createElement(S, { hue: d2.h, onChange: h2 }), e.createElement(ee, { hsva: d2, onChange: h2, className: "react-colorful__last-control" }));
|
|
1325
|
-
}, "re");
|
|
1326
|
-
var le = { defaultColor: "hsla(0, 0%, 0%, 1)", toHsva: H, fromHsva: k, equal: P };
|
|
1327
|
-
var ue = /* @__PURE__ */ __name(function(r2) {
|
|
1328
|
-
return e.createElement(re, u({}, r2, { colorModel: le }));
|
|
1329
|
-
}, "ue");
|
|
1330
|
-
var Ee = { defaultColor: "rgba(0, 0, 0, 1)", toHsva: z, fromHsva: /* @__PURE__ */ __name(function(e2) {
|
|
1331
|
-
var r2 = I(e2);
|
|
1332
|
-
return "rgba(" + r2.r + ", " + r2.g + ", " + r2.b + ", " + r2.a + ")";
|
|
1333
|
-
}, "fromHsva"), equal: P };
|
|
1334
|
-
var He = /* @__PURE__ */ __name(function(r2) {
|
|
1335
|
-
return e.createElement(re, u({}, r2, { colorModel: Ee }));
|
|
1336
|
-
}, "He");
|
|
1337
|
-
|
|
1338
|
-
// src/blocks/controls/Color.tsx
|
|
1339
|
-
import { styled } from "storybook/theming";
|
|
1340
|
-
var Wrapper = styled.div({
|
|
1341
|
-
position: "relative",
|
|
1342
|
-
maxWidth: 250
|
|
1343
|
-
});
|
|
1344
|
-
var TooltipContent = styled.div({
|
|
1345
|
-
width: 200,
|
|
1346
|
-
margin: 5,
|
|
1347
|
-
".react-colorful__saturation": {
|
|
1348
|
-
borderRadius: "4px 4px 0 0"
|
|
1349
|
-
},
|
|
1350
|
-
".react-colorful__hue": {
|
|
1351
|
-
boxShadow: "inset 0 0 0 1px rgb(0 0 0 / 5%)"
|
|
1352
|
-
},
|
|
1353
|
-
".react-colorful__last-control": {
|
|
1354
|
-
borderRadius: "0 0 4px 4px"
|
|
1355
|
-
}
|
|
1356
|
-
});
|
|
1357
|
-
var Swatches = styled.div({
|
|
1358
|
-
display: "grid",
|
|
1359
|
-
gridTemplateColumns: "repeat(9, 16px)",
|
|
1360
|
-
gap: 6,
|
|
1361
|
-
padding: 3,
|
|
1362
|
-
marginTop: 5,
|
|
1363
|
-
width: 200
|
|
1364
|
-
});
|
|
1365
|
-
var swatchBackground = `url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')`;
|
|
1366
|
-
var SwatchColor = styled(Button)(
|
|
1367
|
-
({ value, selected, theme }) => ({
|
|
1368
|
-
width: 16,
|
|
1369
|
-
height: 16,
|
|
1370
|
-
boxShadow: selected ? `${theme.appBorderColor} 0 0 0 1px inset, ${theme.textMutedColor}50 0 0 0 4px` : `${theme.appBorderColor} 0 0 0 1px inset`,
|
|
1371
|
-
border: "none",
|
|
1372
|
-
borderRadius: theme.appBorderRadius,
|
|
1373
|
-
"&, &:hover": {
|
|
1374
|
-
background: "unset",
|
|
1375
|
-
backgroundColor: "unset",
|
|
1376
|
-
backgroundImage: `linear-gradient(${value}, ${value}), ${swatchBackground}, linear-gradient(hsl(0 0 100 / .4), hsl(0 0 100 / .4))`
|
|
1377
|
-
}
|
|
1378
|
-
})
|
|
1379
|
-
);
|
|
1380
|
-
var Input = styled(Form.Input)(({ theme }) => ({
|
|
1381
|
-
width: "100%",
|
|
1382
|
-
paddingLeft: 30,
|
|
1383
|
-
paddingRight: 30,
|
|
1384
|
-
boxSizing: "border-box",
|
|
1385
|
-
fontFamily: theme.typography.fonts.base,
|
|
1386
|
-
'[aria-readonly="true"] > &': {
|
|
1387
|
-
background: theme.base === "light" ? theme.color.lighter : "transparent"
|
|
1388
|
-
}
|
|
1389
|
-
}));
|
|
1390
|
-
var PopoverTrigger = styled(SwatchColor)(({ disabled }) => ({
|
|
1391
|
-
position: "absolute",
|
|
1392
|
-
top: 4,
|
|
1393
|
-
left: 4,
|
|
1394
|
-
zIndex: 1,
|
|
1395
|
-
cursor: disabled ? "not-allowed" : "pointer"
|
|
1396
|
-
}));
|
|
1397
|
-
var CycleColorSpaceButton = styled(Button)(({ theme }) => ({
|
|
1398
|
-
position: "absolute",
|
|
1399
|
-
zIndex: 1,
|
|
1400
|
-
top: 6,
|
|
1401
|
-
right: 7,
|
|
1402
|
-
width: 20,
|
|
1403
|
-
height: 20,
|
|
1404
|
-
padding: 4,
|
|
1405
|
-
boxSizing: "border-box",
|
|
1406
|
-
cursor: "pointer",
|
|
1407
|
-
color: theme.input.color
|
|
1408
|
-
}));
|
|
1409
|
-
var ColorSpace = /* @__PURE__ */ ((ColorSpace2) => {
|
|
1410
|
-
ColorSpace2["RGB"] = "rgb";
|
|
1411
|
-
ColorSpace2["HSL"] = "hsl";
|
|
1412
|
-
ColorSpace2["HEX"] = "hex";
|
|
1413
|
-
return ColorSpace2;
|
|
1414
|
-
})(ColorSpace || {});
|
|
1415
|
-
var COLOR_SPACES = Object.values(ColorSpace);
|
|
1416
|
-
var COLOR_REGEXP = /\(([0-9]+),\s*([0-9]+)%?,\s*([0-9]+)%?,?\s*([0-9.]+)?\)/;
|
|
1417
|
-
var RGB_REGEXP = /^\s*rgba?\(([0-9]+),\s*([0-9]+),\s*([0-9]+),?\s*([0-9.]+)?\)\s*$/i;
|
|
1418
|
-
var HSL_REGEXP = /^\s*hsla?\(([0-9]+),\s*([0-9]+)%,\s*([0-9]+)%,?\s*([0-9.]+)?\)\s*$/i;
|
|
1419
|
-
var HEX_REGEXP = /^\s*#?([0-9a-f]{3}|[0-9a-f]{6})\s*$/i;
|
|
1420
|
-
var SHORTHEX_REGEXP = /^\s*#?([0-9a-f]{3})\s*$/i;
|
|
1421
|
-
var ColorPicker = {
|
|
1422
|
-
["hex" /* HEX */]: Z,
|
|
1423
|
-
["rgb" /* RGB */]: He,
|
|
1424
|
-
["hsl" /* HSL */]: ue
|
|
1425
|
-
};
|
|
1426
|
-
var fallbackColor = {
|
|
1427
|
-
["hex" /* HEX */]: "transparent",
|
|
1428
|
-
["rgb" /* RGB */]: "rgba(0, 0, 0, 0)",
|
|
1429
|
-
["hsl" /* HSL */]: "hsla(0, 0%, 0%, 0)"
|
|
1430
|
-
};
|
|
1431
|
-
var stringToArgs = /* @__PURE__ */ __name((value) => {
|
|
1432
|
-
const match = value?.match(COLOR_REGEXP);
|
|
1433
|
-
if (!match) {
|
|
1434
|
-
return [0, 0, 0, 1];
|
|
1435
|
-
}
|
|
1436
|
-
const [, x2, y2, z2, a2 = 1] = match;
|
|
1437
|
-
return [x2, y2, z2, a2].map(Number);
|
|
1438
|
-
}, "stringToArgs");
|
|
1439
|
-
var parseRgb = /* @__PURE__ */ __name((value) => {
|
|
1440
|
-
const [r2, g2, b2, a2] = stringToArgs(value);
|
|
1441
|
-
const [h2, s2, l2] = import_color_convert.default.rgb.hsl([r2, g2, b2]) || [0, 0, 0];
|
|
1442
|
-
return {
|
|
1443
|
-
valid: true,
|
|
1444
|
-
value,
|
|
1445
|
-
keyword: import_color_convert.default.rgb.keyword([r2, g2, b2]),
|
|
1446
|
-
colorSpace: "rgb" /* RGB */,
|
|
1447
|
-
["rgb" /* RGB */]: value,
|
|
1448
|
-
["hsl" /* HSL */]: `hsla(${h2}, ${s2}%, ${l2}%, ${a2})`,
|
|
1449
|
-
["hex" /* HEX */]: `#${import_color_convert.default.rgb.hex([r2, g2, b2]).toLowerCase()}`
|
|
1450
|
-
};
|
|
1451
|
-
}, "parseRgb");
|
|
1452
|
-
var parseHsl = /* @__PURE__ */ __name((value) => {
|
|
1453
|
-
const [h2, s2, l2, a2] = stringToArgs(value);
|
|
1454
|
-
const [r2, g2, b2] = import_color_convert.default.hsl.rgb([h2, s2, l2]) || [0, 0, 0];
|
|
1455
|
-
return {
|
|
1456
|
-
valid: true,
|
|
1457
|
-
value,
|
|
1458
|
-
keyword: import_color_convert.default.hsl.keyword([h2, s2, l2]),
|
|
1459
|
-
colorSpace: "hsl" /* HSL */,
|
|
1460
|
-
["rgb" /* RGB */]: `rgba(${r2}, ${g2}, ${b2}, ${a2})`,
|
|
1461
|
-
["hsl" /* HSL */]: value,
|
|
1462
|
-
["hex" /* HEX */]: `#${import_color_convert.default.hsl.hex([h2, s2, l2]).toLowerCase()}`
|
|
1463
|
-
};
|
|
1464
|
-
}, "parseHsl");
|
|
1465
|
-
var parseHexOrKeyword = /* @__PURE__ */ __name((value) => {
|
|
1466
|
-
const plain = value.replace("#", "");
|
|
1467
|
-
const rgb = import_color_convert.default.keyword.rgb(plain) || import_color_convert.default.hex.rgb(plain);
|
|
1468
|
-
const hsl = import_color_convert.default.rgb.hsl(rgb);
|
|
1469
|
-
let mapped = value;
|
|
1470
|
-
if (/[^#a-f0-9]/i.test(value)) {
|
|
1471
|
-
mapped = plain;
|
|
1472
|
-
} else if (HEX_REGEXP.test(value)) {
|
|
1473
|
-
mapped = `#${plain}`;
|
|
1474
|
-
}
|
|
1475
|
-
let valid = true;
|
|
1476
|
-
if (mapped.startsWith("#")) {
|
|
1477
|
-
valid = HEX_REGEXP.test(mapped);
|
|
1478
|
-
} else {
|
|
1479
|
-
try {
|
|
1480
|
-
import_color_convert.default.keyword.hex(mapped);
|
|
1481
|
-
} catch (e2) {
|
|
1482
|
-
valid = false;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
return {
|
|
1486
|
-
valid,
|
|
1487
|
-
value: mapped,
|
|
1488
|
-
keyword: import_color_convert.default.rgb.keyword(rgb),
|
|
1489
|
-
colorSpace: "hex" /* HEX */,
|
|
1490
|
-
["rgb" /* RGB */]: `rgba(${rgb[0]}, ${rgb[1]}, ${rgb[2]}, 1)`,
|
|
1491
|
-
["hsl" /* HSL */]: `hsla(${hsl[0]}, ${hsl[1]}%, ${hsl[2]}%, 1)`,
|
|
1492
|
-
["hex" /* HEX */]: mapped
|
|
1493
|
-
};
|
|
1494
|
-
}, "parseHexOrKeyword");
|
|
1495
|
-
var parseValue = /* @__PURE__ */ __name((value) => {
|
|
1496
|
-
if (!value) {
|
|
1497
|
-
return void 0;
|
|
1498
|
-
}
|
|
1499
|
-
if (RGB_REGEXP.test(value)) {
|
|
1500
|
-
return parseRgb(value);
|
|
1501
|
-
}
|
|
1502
|
-
if (HSL_REGEXP.test(value)) {
|
|
1503
|
-
return parseHsl(value);
|
|
1504
|
-
}
|
|
1505
|
-
return parseHexOrKeyword(value);
|
|
1506
|
-
}, "parseValue");
|
|
1507
|
-
var getRealValue = /* @__PURE__ */ __name((value, color, colorSpace) => {
|
|
1508
|
-
if (!value || !color?.valid) {
|
|
1509
|
-
return fallbackColor[colorSpace];
|
|
1510
|
-
}
|
|
1511
|
-
if (colorSpace !== "hex" /* HEX */) {
|
|
1512
|
-
return color?.[colorSpace] || fallbackColor[colorSpace];
|
|
1513
|
-
}
|
|
1514
|
-
if (!color.hex.startsWith("#")) {
|
|
1515
|
-
try {
|
|
1516
|
-
return `#${import_color_convert.default.keyword.hex(color.hex)}`;
|
|
1517
|
-
} catch (e2) {
|
|
1518
|
-
return fallbackColor.hex;
|
|
1519
|
-
}
|
|
1520
|
-
}
|
|
1521
|
-
const short = color.hex.match(SHORTHEX_REGEXP);
|
|
1522
|
-
if (!short) {
|
|
1523
|
-
return HEX_REGEXP.test(color.hex) ? color.hex : fallbackColor.hex;
|
|
1524
|
-
}
|
|
1525
|
-
const [r2, g2, b2] = short[1].split("");
|
|
1526
|
-
return `#${r2}${r2}${g2}${g2}${b2}${b2}`;
|
|
1527
|
-
}, "getRealValue");
|
|
1528
|
-
var useColorInput = /* @__PURE__ */ __name((initialValue, onChange) => {
|
|
1529
|
-
const [value, setValue] = useState(initialValue || "");
|
|
1530
|
-
const [color, setColor] = useState(() => parseValue(value));
|
|
1531
|
-
const [colorSpace, setColorSpace] = useState(color?.colorSpace || "hex" /* HEX */);
|
|
1532
|
-
useEffect(() => {
|
|
1533
|
-
const nextValue = initialValue || "";
|
|
1534
|
-
const nextColor = parseValue(nextValue);
|
|
1535
|
-
setValue(nextValue);
|
|
1536
|
-
setColor(nextColor);
|
|
1537
|
-
setColorSpace(nextColor?.colorSpace || "hex" /* HEX */);
|
|
1538
|
-
}, [initialValue]);
|
|
1539
|
-
const realValue = useMemo(
|
|
1540
|
-
() => getRealValue(value, color, colorSpace).toLowerCase(),
|
|
1541
|
-
[value, color, colorSpace]
|
|
1542
|
-
);
|
|
1543
|
-
const updateValue = useCallback(
|
|
1544
|
-
(update) => {
|
|
1545
|
-
const parsed = parseValue(update);
|
|
1546
|
-
const v2 = parsed?.value || update || "";
|
|
1547
|
-
setValue(v2);
|
|
1548
|
-
if (v2 === "") {
|
|
1549
|
-
setColor(void 0);
|
|
1550
|
-
onChange(void 0);
|
|
1551
|
-
}
|
|
1552
|
-
if (!parsed) {
|
|
1553
|
-
return;
|
|
1554
|
-
}
|
|
1555
|
-
setColor(parsed);
|
|
1556
|
-
setColorSpace(parsed.colorSpace);
|
|
1557
|
-
onChange(parsed.value);
|
|
1558
|
-
},
|
|
1559
|
-
[onChange]
|
|
1560
|
-
);
|
|
1561
|
-
const cycleColorSpace = useCallback(() => {
|
|
1562
|
-
const currentIndex = COLOR_SPACES.indexOf(colorSpace);
|
|
1563
|
-
const nextIndex = (currentIndex + 1) % COLOR_SPACES.length;
|
|
1564
|
-
const nextSpace = COLOR_SPACES[nextIndex];
|
|
1565
|
-
setColorSpace(nextSpace);
|
|
1566
|
-
const updatedValue = color?.[nextSpace] || "";
|
|
1567
|
-
setValue(updatedValue);
|
|
1568
|
-
onChange(updatedValue);
|
|
1569
|
-
}, [color, colorSpace, onChange]);
|
|
1570
|
-
return { value, realValue, updateValue, color, colorSpace, cycleColorSpace };
|
|
1571
|
-
}, "useColorInput");
|
|
1572
|
-
var id = /* @__PURE__ */ __name((value) => value.replace(/\s*/, "").toLowerCase(), "id");
|
|
1573
|
-
var usePresets = /* @__PURE__ */ __name((presetColors, currentColor, colorSpace) => {
|
|
1574
|
-
const [selectedColors, setSelectedColors] = useState(currentColor?.valid ? [currentColor] : []);
|
|
1575
|
-
useEffect(() => {
|
|
1576
|
-
if (currentColor !== void 0) {
|
|
1577
|
-
return;
|
|
1578
|
-
}
|
|
1579
|
-
setSelectedColors([]);
|
|
1580
|
-
}, [currentColor]);
|
|
1581
|
-
const presets = useMemo(() => {
|
|
1582
|
-
const initialPresets = (presetColors || []).map((preset) => {
|
|
1583
|
-
if (typeof preset === "string") {
|
|
1584
|
-
return parseValue(preset);
|
|
1585
|
-
}
|
|
1586
|
-
if (preset.title) {
|
|
1587
|
-
return { ...parseValue(preset.color), keyword: preset.title };
|
|
1588
|
-
}
|
|
1589
|
-
return parseValue(preset.color);
|
|
1590
|
-
});
|
|
1591
|
-
return initialPresets.concat(selectedColors).filter(Boolean).slice(-27);
|
|
1592
|
-
}, [presetColors, selectedColors]);
|
|
1593
|
-
const addPreset = useCallback(
|
|
1594
|
-
(color) => {
|
|
1595
|
-
if (!color?.valid) {
|
|
1596
|
-
return;
|
|
1597
|
-
}
|
|
1598
|
-
if (presets.some(
|
|
1599
|
-
(preset) => preset && preset[colorSpace] && id(preset[colorSpace] || "") === id(color[colorSpace] || "")
|
|
1600
|
-
)) {
|
|
1601
|
-
return;
|
|
1602
|
-
}
|
|
1603
|
-
setSelectedColors((arr) => arr.concat(color));
|
|
1604
|
-
},
|
|
1605
|
-
[colorSpace, presets]
|
|
1606
|
-
);
|
|
1607
|
-
return { presets, addPreset };
|
|
1608
|
-
}, "usePresets");
|
|
1609
|
-
var ColorControl = /* @__PURE__ */ __name(({
|
|
1610
|
-
name,
|
|
1611
|
-
value: initialValue,
|
|
1612
|
-
onChange,
|
|
1613
|
-
onFocus,
|
|
1614
|
-
onBlur,
|
|
1615
|
-
presetColors,
|
|
1616
|
-
startOpen = false,
|
|
1617
|
-
argType
|
|
1618
|
-
}) => {
|
|
1619
|
-
const debouncedOnChange = useCallback(debounce(onChange, 200), [onChange]);
|
|
1620
|
-
const { value, realValue, updateValue, color, colorSpace, cycleColorSpace } = useColorInput(
|
|
1621
|
-
initialValue,
|
|
1622
|
-
debouncedOnChange
|
|
1623
|
-
);
|
|
1624
|
-
const { presets, addPreset } = usePresets(presetColors ?? [], color, colorSpace);
|
|
1625
|
-
const Picker = ColorPicker[colorSpace];
|
|
1626
|
-
const readOnly = !!argType?.table?.readonly;
|
|
1627
|
-
const controlId = getControlId(name);
|
|
1628
|
-
return React.createElement(Wrapper, null, React.createElement("label", { htmlFor: controlId, className: "sb-sr-only" }, name), React.createElement(
|
|
1629
|
-
Input,
|
|
1630
|
-
{
|
|
1631
|
-
id: controlId,
|
|
1632
|
-
value,
|
|
1633
|
-
onChange: (e2) => updateValue(e2.target.value),
|
|
1634
|
-
onFocus: (e2) => e2.target.select(),
|
|
1635
|
-
readOnly,
|
|
1636
|
-
placeholder: "Choose color..."
|
|
1637
|
-
}
|
|
1638
|
-
), React.createElement(
|
|
1639
|
-
PopoverProvider,
|
|
1640
|
-
{
|
|
1641
|
-
defaultVisible: startOpen,
|
|
1642
|
-
visible: readOnly ? false : void 0,
|
|
1643
|
-
onVisibleChange: () => color && addPreset(color),
|
|
1644
|
-
popover: React.createElement(TooltipContent, null, React.createElement(
|
|
1645
|
-
Picker,
|
|
1646
|
-
{
|
|
1647
|
-
color: realValue === "transparent" ? "#000000" : realValue,
|
|
1648
|
-
...{ onChange: updateValue, onFocus, onBlur }
|
|
1649
|
-
}
|
|
1650
|
-
), presets.length > 0 && React.createElement(Swatches, null, presets.map((preset, index) => React.createElement(
|
|
1651
|
-
SwatchColor,
|
|
1652
|
-
{
|
|
1653
|
-
key: `${preset?.value || index}-${index}`,
|
|
1654
|
-
variant: "ghost",
|
|
1655
|
-
padding: "small",
|
|
1656
|
-
size: "small",
|
|
1657
|
-
ariaLabel: "Pick this color",
|
|
1658
|
-
tooltip: preset?.keyword || preset?.value || "",
|
|
1659
|
-
value: preset?.value || "",
|
|
1660
|
-
selected: !!(color && preset && preset[colorSpace] && id(preset[colorSpace] || "") === id(color[colorSpace])),
|
|
1661
|
-
onClick: () => preset && updateValue(preset.value || "")
|
|
1662
|
-
}
|
|
1663
|
-
))))
|
|
1664
|
-
},
|
|
1665
|
-
React.createElement(
|
|
1666
|
-
PopoverTrigger,
|
|
1667
|
-
{
|
|
1668
|
-
variant: "ghost",
|
|
1669
|
-
padding: "small",
|
|
1670
|
-
size: "small",
|
|
1671
|
-
ariaLabel: "Open color picker",
|
|
1672
|
-
value: realValue,
|
|
1673
|
-
style: { margin: 4 },
|
|
1674
|
-
disabled: readOnly
|
|
1675
|
-
}
|
|
1676
|
-
)
|
|
1677
|
-
), value ? React.createElement(
|
|
1678
|
-
CycleColorSpaceButton,
|
|
1679
|
-
{
|
|
1680
|
-
variant: "ghost",
|
|
1681
|
-
padding: "small",
|
|
1682
|
-
size: "small",
|
|
1683
|
-
ariaLabel: "Cycle through color spaces",
|
|
1684
|
-
disabled: readOnly,
|
|
1685
|
-
onClick: readOnly ? void 0 : cycleColorSpace
|
|
1686
|
-
},
|
|
1687
|
-
React.createElement(MarkupIcon, null)
|
|
1688
|
-
) : null);
|
|
1689
|
-
}, "ColorControl");
|
|
1690
|
-
var Color_default = ColorControl;
|
|
1691
|
-
export {
|
|
1692
|
-
ColorControl,
|
|
1693
|
-
Color_default as default
|
|
1694
|
-
};
|