@fab1o978/react-ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +73 -0
  2. package/dist/components/Badge/index.cjs +47 -0
  3. package/dist/components/Badge/index.cjs.map +1 -0
  4. package/dist/components/Badge/index.css +112 -0
  5. package/dist/components/Badge/index.css.map +1 -0
  6. package/dist/components/Badge/index.d.cts +14 -0
  7. package/dist/components/Badge/index.d.ts +14 -0
  8. package/dist/components/Badge/index.js +45 -0
  9. package/dist/components/Badge/index.js.map +1 -0
  10. package/dist/components/Button/index.cjs +64 -0
  11. package/dist/components/Button/index.cjs.map +1 -0
  12. package/dist/components/Button/index.css +159 -0
  13. package/dist/components/Button/index.css.map +1 -0
  14. package/dist/components/Button/index.d.cts +13 -0
  15. package/dist/components/Button/index.d.ts +13 -0
  16. package/dist/components/Button/index.js +58 -0
  17. package/dist/components/Button/index.js.map +1 -0
  18. package/dist/components/ColorPicker/index.cjs +523 -0
  19. package/dist/components/ColorPicker/index.cjs.map +1 -0
  20. package/dist/components/ColorPicker/index.css +308 -0
  21. package/dist/components/ColorPicker/index.css.map +1 -0
  22. package/dist/components/ColorPicker/index.d.cts +35 -0
  23. package/dist/components/ColorPicker/index.d.ts +35 -0
  24. package/dist/components/ColorPicker/index.js +521 -0
  25. package/dist/components/ColorPicker/index.js.map +1 -0
  26. package/dist/components/Input/index.cjs +86 -0
  27. package/dist/components/Input/index.cjs.map +1 -0
  28. package/dist/components/Input/index.css +170 -0
  29. package/dist/components/Input/index.css.map +1 -0
  30. package/dist/components/Input/index.d.cts +15 -0
  31. package/dist/components/Input/index.d.ts +15 -0
  32. package/dist/components/Input/index.js +80 -0
  33. package/dist/components/Input/index.js.map +1 -0
  34. package/dist/components/RainCanvas/index.cjs +227 -0
  35. package/dist/components/RainCanvas/index.cjs.map +1 -0
  36. package/dist/components/RainCanvas/index.css +32 -0
  37. package/dist/components/RainCanvas/index.css.map +1 -0
  38. package/dist/components/RainCanvas/index.d.cts +12 -0
  39. package/dist/components/RainCanvas/index.d.ts +12 -0
  40. package/dist/components/RainCanvas/index.js +225 -0
  41. package/dist/components/RainCanvas/index.js.map +1 -0
  42. package/dist/components/Timeline/index.cjs +169 -0
  43. package/dist/components/Timeline/index.cjs.map +1 -0
  44. package/dist/components/Timeline/index.css +247 -0
  45. package/dist/components/Timeline/index.css.map +1 -0
  46. package/dist/components/Timeline/index.d.cts +22 -0
  47. package/dist/components/Timeline/index.d.ts +22 -0
  48. package/dist/components/Timeline/index.js +167 -0
  49. package/dist/components/Timeline/index.js.map +1 -0
  50. package/dist/index.cjs +993 -0
  51. package/dist/index.cjs.map +1 -0
  52. package/dist/index.css +1019 -0
  53. package/dist/index.css.map +1 -0
  54. package/dist/index.d.cts +7 -0
  55. package/dist/index.d.ts +7 -0
  56. package/dist/index.js +982 -0
  57. package/dist/index.js.map +1 -0
  58. package/package.json +69 -0
@@ -0,0 +1,521 @@
1
+ import { useState, useRef, useEffect, useCallback } from 'react';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+
4
+ // src/components/ColorPicker/ColorPicker.tsx
5
+
6
+ // src/components/ColorPicker/ColorPicker.module.scss
7
+ var ColorPicker_module_default = {
8
+ colorPicker: "ColorPicker_module_colorPicker2",
9
+ topRow: "ColorPicker_module_topRow2",
10
+ discWrapper: "ColorPicker_module_discWrapper2",
11
+ disc: "ColorPicker_module_disc2",
12
+ dot: "ColorPicker_module_dot2",
13
+ lSlider: "ColorPicker_module_lSlider2",
14
+ lThumb: "ColorPicker_module_lThumb2",
15
+ alphaSlider: "ColorPicker_module_alphaSlider2",
16
+ alphaThumb: "ColorPicker_module_alphaThumb2",
17
+ previewSwatch: "ColorPicker_module_previewSwatch2",
18
+ eyedropperBtn: "ColorPicker_module_eyedropperBtn2",
19
+ inputSection: "ColorPicker_module_inputSection2",
20
+ tabs: "ColorPicker_module_tabs2",
21
+ tab: "ColorPicker_module_tab2",
22
+ tabActive: "ColorPicker_module_tabActive2",
23
+ inputWrapper: "ColorPicker_module_inputWrapper2",
24
+ inputAddon: "ColorPicker_module_inputAddon2",
25
+ input: "ColorPicker_module_input2",
26
+ inputCopyBtn: "ColorPicker_module_inputCopyBtn2",
27
+ recents: "ColorPicker_module_recents2",
28
+ recentsLabel: "ColorPicker_module_recentsLabel2",
29
+ swatches: "ColorPicker_module_swatches2",
30
+ recentSwatch: "ColorPicker_module_recentSwatch2"
31
+ };
32
+
33
+ // src/utils/color.ts
34
+ function hexToHsl(hex) {
35
+ const r = parseInt(hex.slice(1, 3), 16) / 255;
36
+ const g = parseInt(hex.slice(3, 5), 16) / 255;
37
+ const b = parseInt(hex.slice(5, 7), 16) / 255;
38
+ const max = Math.max(r, g, b);
39
+ const min = Math.min(r, g, b);
40
+ const l = (max + min) / 2;
41
+ let h = 0;
42
+ let s = 0;
43
+ if (max !== min) {
44
+ const d = max - min;
45
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
46
+ switch (max) {
47
+ case r:
48
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
49
+ break;
50
+ case g:
51
+ h = ((b - r) / d + 2) / 6;
52
+ break;
53
+ case b:
54
+ h = ((r - g) / d + 4) / 6;
55
+ break;
56
+ }
57
+ }
58
+ return [h * 360, s * 100, l * 100];
59
+ }
60
+ function hslToHex(h, s, l) {
61
+ const sl = s / 100;
62
+ const ll = l / 100;
63
+ const a = sl * Math.min(ll, 1 - ll);
64
+ const f = (n) => {
65
+ const k = (n + h / 30) % 12;
66
+ const color = ll - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
67
+ return Math.round(255 * color).toString(16).padStart(2, "0");
68
+ };
69
+ return `#${f(0)}${f(8)}${f(4)}`;
70
+ }
71
+ function hslToRgb(h, s, l) {
72
+ const sl = s / 100;
73
+ const ll = l / 100;
74
+ const a = sl * Math.min(ll, 1 - ll);
75
+ const f = (n) => {
76
+ const k = (n + h / 30) % 12;
77
+ return Math.round(255 * (ll - a * Math.max(Math.min(k - 3, 9 - k, 1), -1)));
78
+ };
79
+ return { r: f(0), g: f(8), b: f(4) };
80
+ }
81
+ function rgbToHsl(r, g, b) {
82
+ const rr = r / 255, gg = g / 255, bb = b / 255;
83
+ const max = Math.max(rr, gg, bb);
84
+ const min = Math.min(rr, gg, bb);
85
+ const l = (max + min) / 2;
86
+ let h = 0, s = 0;
87
+ if (max !== min) {
88
+ const d = max - min;
89
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
90
+ switch (max) {
91
+ case rr:
92
+ h = ((gg - bb) / d + (gg < bb ? 6 : 0)) / 6;
93
+ break;
94
+ case gg:
95
+ h = ((bb - rr) / d + 2) / 6;
96
+ break;
97
+ case bb:
98
+ h = ((rr - gg) / d + 4) / 6;
99
+ break;
100
+ }
101
+ }
102
+ return [h * 360, s * 100, l * 100];
103
+ }
104
+ function hslToRgba(h, s, l, alpha) {
105
+ const { r, g, b } = hslToRgb(h, s, l);
106
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
107
+ }
108
+ function buildColorValue(h, s, l, a) {
109
+ const { r, g, b } = hslToRgb(h, s, l);
110
+ const hex = hslToHex(h, s, l);
111
+ const alphaHex = Math.round(a * 255).toString(16).padStart(2, "0");
112
+ const hR = Math.round(h), sR = Math.round(s), lR = Math.round(l);
113
+ const aR = Math.round(a * 100) / 100;
114
+ return {
115
+ hex,
116
+ hexa: `${hex}${alphaHex}`,
117
+ hsl: `hsl(${hR}, ${sR}%, ${lR}%)`,
118
+ hsla: `hsla(${hR}, ${sR}%, ${lR}%, ${aR})`,
119
+ rgb: `rgb(${r}, ${g}, ${b})`,
120
+ rgba: `rgba(${r}, ${g}, ${b}, ${aR})`,
121
+ h,
122
+ s,
123
+ l,
124
+ a
125
+ };
126
+ }
127
+ function deriveAccent(hex) {
128
+ const [h, s, l] = hexToHsl(hex);
129
+ return {
130
+ base: hex,
131
+ dot: hslToHex(h, s, Math.min(l + 12, 95)),
132
+ track: hex,
133
+ ring: hex,
134
+ glow: hslToRgba(h, s, l, 0.3),
135
+ light: hslToHex(h, Math.max(s - 20, 0), Math.min(l + 45, 96))
136
+ };
137
+ }
138
+ function accentToCssVars(tokens, prefix) {
139
+ return {
140
+ [`--${prefix}-accent`]: tokens.base,
141
+ [`--${prefix}-accent-dot`]: tokens.dot,
142
+ [`--${prefix}-accent-track`]: tokens.track,
143
+ [`--${prefix}-accent-ring`]: tokens.ring,
144
+ [`--${prefix}-accent-glow`]: tokens.glow,
145
+ [`--${prefix}-accent-light`]: tokens.light
146
+ };
147
+ }
148
+ var DISC = 200;
149
+ var CopyIcon = () => /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: [
150
+ /* @__PURE__ */ jsx("rect", { x: "5", y: "5", width: "7", height: "7", rx: "1.5", stroke: "currentColor", strokeWidth: "1.4" }),
151
+ /* @__PURE__ */ jsx("path", { d: "M2 9V2.5A.5.5 0 0 1 2.5 2H9", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
152
+ ] });
153
+ var CheckIcon = () => /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ jsx("path", { d: "M2.5 7L5.5 10L11.5 4", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) });
154
+ var EyedropperIcon = () => /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: [
155
+ /* @__PURE__ */ jsx("path", { d: "M9.5 2.5L11.5 4.5L6 10L3 11L4 8L9.5 2.5Z", stroke: "currentColor", strokeWidth: "1.4", strokeLinejoin: "round" }),
156
+ /* @__PURE__ */ jsx("path", { d: "M8 4L10 6", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }),
157
+ /* @__PURE__ */ jsx("circle", { cx: "2.5", cy: "11.5", r: "1", fill: "currentColor" })
158
+ ] });
159
+ function formatValue(mode, h, s, l, r, g, b, hex) {
160
+ if (mode === "hex") return hex.replace("#", "");
161
+ if (mode === "hsl") return `${Math.round(h)} ${Math.round(s)} ${Math.round(l)}`;
162
+ return `${r} ${g} ${b}`;
163
+ }
164
+ function parseValue(mode, raw) {
165
+ if (mode === "hex") {
166
+ const clean = raw.replace(/^#/, "");
167
+ if (!/^[0-9a-fA-F]{6}$/.test(clean)) return null;
168
+ const [h, s, l] = hexToHsl(`#${clean}`);
169
+ return [h, s, l];
170
+ }
171
+ const parts = raw.trim().split(/[\s,]+/).map(Number);
172
+ if (parts.length !== 3 || parts.some(isNaN)) return null;
173
+ if (mode === "hsl") {
174
+ const [h, s, l] = parts;
175
+ if (h < 0 || h > 360 || s < 0 || s > 100 || l < 0 || l > 100) return null;
176
+ return [h, s, l];
177
+ }
178
+ const [r, g, b] = parts;
179
+ if ([r, g, b].some((v) => v < 0 || v > 255)) return null;
180
+ return rgbToHsl(r, g, b);
181
+ }
182
+ var ColorInput = ({ mode, h, s, l, r, g, b, hex, onChange, onCopy, copied }) => {
183
+ const [draft, setDraft] = useState(() => formatValue(mode, h, s, l, r, g, b, hex));
184
+ const [focused, setFocused] = useState(false);
185
+ useEffect(() => {
186
+ if (!focused) setDraft(formatValue(mode, h, s, l, r, g, b, hex));
187
+ }, [focused, mode, h, s, l, r, g, b, hex]);
188
+ const placeholder = mode === "hex" ? "3b82f6" : mode === "hsl" ? "217 91 60" : "59 130 246";
189
+ return /* @__PURE__ */ jsxs("div", { className: ColorPicker_module_default.inputWrapper, children: [
190
+ mode === "hex" && /* @__PURE__ */ jsx("span", { className: ColorPicker_module_default.inputAddon, children: "#" }),
191
+ /* @__PURE__ */ jsx(
192
+ "input",
193
+ {
194
+ className: ColorPicker_module_default.input,
195
+ value: draft,
196
+ placeholder,
197
+ spellCheck: false,
198
+ onFocus: () => setFocused(true),
199
+ onBlur: () => setFocused(false),
200
+ onChange: (e) => {
201
+ const raw = e.target.value;
202
+ setDraft(raw);
203
+ const result = parseValue(mode, raw);
204
+ if (result) onChange(...result);
205
+ }
206
+ }
207
+ ),
208
+ /* @__PURE__ */ jsx("button", { className: ColorPicker_module_default.inputCopyBtn, onClick: onCopy, tabIndex: -1, title: "Copia", children: copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}) })
209
+ ] });
210
+ };
211
+ function parseInitial(value) {
212
+ if (value?.startsWith("#")) {
213
+ const [h, s, l] = hexToHsl(value);
214
+ return [h, s, l, 1];
215
+ }
216
+ return [217, 91, 60, 1];
217
+ }
218
+ var ColorPicker = ({
219
+ value,
220
+ onChange,
221
+ showAlpha = true,
222
+ recentColors = [],
223
+ accent,
224
+ className
225
+ }) => {
226
+ const init = parseInitial(value);
227
+ const [h, setH] = useState(init[0]);
228
+ const [s, setS] = useState(init[1]);
229
+ const [l, setL] = useState(init[2]);
230
+ const [a, setA] = useState(init[3]);
231
+ const [mode, setMode] = useState("hex");
232
+ const [copied, setCopied] = useState(false);
233
+ const [hasEyeDropper, setHasEyeDropper] = useState(false);
234
+ const canvasRef = useRef(null);
235
+ useEffect(() => {
236
+ setHasEyeDropper(typeof window !== "undefined" && "EyeDropper" in window);
237
+ }, []);
238
+ useEffect(() => {
239
+ if (value?.startsWith("#")) {
240
+ const [nh, ns, nl] = hexToHsl(value);
241
+ setH(nh);
242
+ setS(ns);
243
+ setL(nl);
244
+ }
245
+ }, [value]);
246
+ useEffect(() => {
247
+ const canvas = canvasRef.current;
248
+ if (!canvas) return;
249
+ const ctx = canvas.getContext("2d");
250
+ if (!ctx) return;
251
+ const img = ctx.createImageData(DISC, DISC);
252
+ const data = img.data;
253
+ const cx = DISC / 2;
254
+ const cy = DISC / 2;
255
+ const radius = DISC / 2;
256
+ for (let py = 0; py < DISC; py++) {
257
+ for (let px = 0; px < DISC; px++) {
258
+ const dx = px - cx;
259
+ const dy = py - cy;
260
+ const r = Math.sqrt(dx * dx + dy * dy);
261
+ const idx = (py * DISC + px) * 4;
262
+ if (r > radius) {
263
+ data[idx + 3] = 0;
264
+ continue;
265
+ }
266
+ const theta = Math.atan2(dy, dx) * 180 / Math.PI;
267
+ const hue = (theta + 360) % 360;
268
+ const sat = r / radius * 100;
269
+ const { r: rr2, g: gg2, b: bb2 } = hslToRgb(hue, sat, l);
270
+ data[idx] = rr2;
271
+ data[idx + 1] = gg2;
272
+ data[idx + 2] = bb2;
273
+ data[idx + 3] = r > radius - 1 ? Math.round(255 * (radius - r)) : 255;
274
+ }
275
+ }
276
+ ctx.putImageData(img, 0, 0);
277
+ }, [l]);
278
+ const notify = useCallback(
279
+ (nh, ns, nl, na) => {
280
+ onChange?.(buildColorValue(nh, ns, nl, na));
281
+ },
282
+ [onChange]
283
+ );
284
+ const updateDisc = useCallback(
285
+ (clientX, clientY, rect) => {
286
+ const cx = rect.left + rect.width / 2;
287
+ const cy = rect.top + rect.height / 2;
288
+ const dx = clientX - cx;
289
+ const dy = clientY - cy;
290
+ const r = Math.sqrt(dx * dx + dy * dy);
291
+ const radius = rect.width / 2;
292
+ const clampedR = Math.min(r, radius);
293
+ const theta = Math.atan2(dy, dx) * 180 / Math.PI;
294
+ const nh = (theta + 360) % 360;
295
+ const ns = clampedR / radius * 100;
296
+ setH(nh);
297
+ setS(ns);
298
+ notify(nh, ns, l, a);
299
+ },
300
+ [l, a, notify]
301
+ );
302
+ const handleDiscPointerDown = useCallback(
303
+ (e) => {
304
+ e.currentTarget.setPointerCapture(e.pointerId);
305
+ updateDisc(e.clientX, e.clientY, e.currentTarget.getBoundingClientRect());
306
+ },
307
+ [updateDisc]
308
+ );
309
+ const handleDiscPointerMove = useCallback(
310
+ (e) => {
311
+ if (e.buttons === 0) return;
312
+ updateDisc(e.clientX, e.clientY, e.currentTarget.getBoundingClientRect());
313
+ },
314
+ [updateDisc]
315
+ );
316
+ const updateL = useCallback(
317
+ (clientX, rect) => {
318
+ const nl = Math.max(0, Math.min(100, (clientX - rect.left) / rect.width * 100));
319
+ setL(nl);
320
+ notify(h, s, nl, a);
321
+ },
322
+ [h, s, a, notify]
323
+ );
324
+ const handleLPointerDown = useCallback(
325
+ (e) => {
326
+ e.currentTarget.setPointerCapture(e.pointerId);
327
+ updateL(e.clientX, e.currentTarget.getBoundingClientRect());
328
+ },
329
+ [updateL]
330
+ );
331
+ const handleLPointerMove = useCallback(
332
+ (e) => {
333
+ if (e.buttons === 0) return;
334
+ updateL(e.clientX, e.currentTarget.getBoundingClientRect());
335
+ },
336
+ [updateL]
337
+ );
338
+ const updateA = useCallback(
339
+ (clientX, rect) => {
340
+ const na = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
341
+ setA(na);
342
+ notify(h, s, l, na);
343
+ },
344
+ [h, s, l, notify]
345
+ );
346
+ const handleAPointerDown = useCallback(
347
+ (e) => {
348
+ e.currentTarget.setPointerCapture(e.pointerId);
349
+ updateA(e.clientX, e.currentTarget.getBoundingClientRect());
350
+ },
351
+ [updateA]
352
+ );
353
+ const handleAPointerMove = useCallback(
354
+ (e) => {
355
+ if (e.buttons === 0) return;
356
+ updateA(e.clientX, e.currentTarget.getBoundingClientRect());
357
+ },
358
+ [updateA]
359
+ );
360
+ const { r: rr, g: gg, b: bb } = hslToRgb(h, s, l);
361
+ const hexStr = hslToHex(h, s, l);
362
+ const rgbStr = `rgb(${rr}, ${gg}, ${bb})`;
363
+ const colorValue = buildColorValue(h, s, l, a);
364
+ const dotX = DISC / 2 + s / 100 * (DISC / 2) * Math.cos(h * Math.PI / 180);
365
+ const dotY = DISC / 2 + s / 100 * (DISC / 2) * Math.sin(h * Math.PI / 180);
366
+ const lGradient = `linear-gradient(to right,
367
+ hsl(${h}, ${s}%, 5%),
368
+ hsl(${h}, ${s}%, 50%),
369
+ hsl(${h}, ${s}%, 95%))`;
370
+ const alphaGradient = `linear-gradient(to right, transparent, ${rgbStr})`;
371
+ const handleEyeDropper = async () => {
372
+ if (!window.EyeDropper) return;
373
+ try {
374
+ const result = await new window.EyeDropper().open();
375
+ const [nh, ns, nl] = hexToHsl(result.sRGBHex);
376
+ setH(nh);
377
+ setS(ns);
378
+ setL(nl);
379
+ notify(nh, ns, nl, a);
380
+ } catch {
381
+ }
382
+ };
383
+ const handleCopy = () => {
384
+ const text = mode === "hex" ? colorValue.hexa : mode === "hsl" ? colorValue.hsla : colorValue.rgba;
385
+ navigator.clipboard.writeText(text).then(() => {
386
+ setCopied(true);
387
+ setTimeout(() => setCopied(false), 1500);
388
+ });
389
+ };
390
+ const handleSwatch = (color) => {
391
+ const [nh, ns, nl] = hexToHsl(color);
392
+ setH(nh);
393
+ setS(ns);
394
+ setL(nl);
395
+ notify(nh, ns, nl, a);
396
+ };
397
+ const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorpicker") : {};
398
+ mode === "hex" ? colorValue.hexa : mode === "hsl" ? colorValue.hsla : colorValue.rgba;
399
+ return /* @__PURE__ */ jsxs(
400
+ "div",
401
+ {
402
+ className: [ColorPicker_module_default.colorPicker, className ?? ""].filter(Boolean).join(" "),
403
+ style: accentVars,
404
+ children: [
405
+ /* @__PURE__ */ jsx("div", { className: ColorPicker_module_default.topRow, children: /* @__PURE__ */ jsxs("div", { className: ColorPicker_module_default.discWrapper, children: [
406
+ /* @__PURE__ */ jsx(
407
+ "canvas",
408
+ {
409
+ ref: canvasRef,
410
+ width: DISC,
411
+ height: DISC,
412
+ className: ColorPicker_module_default.disc,
413
+ onPointerDown: handleDiscPointerDown,
414
+ onPointerMove: handleDiscPointerMove
415
+ }
416
+ ),
417
+ /* @__PURE__ */ jsx(
418
+ "div",
419
+ {
420
+ className: ColorPicker_module_default.dot,
421
+ style: {
422
+ left: dotX,
423
+ top: dotY,
424
+ borderColor: l > 55 ? "rgba(0,0,0,0.5)" : "rgba(255,255,255,0.85)"
425
+ }
426
+ }
427
+ )
428
+ ] }) }),
429
+ /* @__PURE__ */ jsx(
430
+ "div",
431
+ {
432
+ className: ColorPicker_module_default.lSlider,
433
+ style: { backgroundImage: lGradient },
434
+ onPointerDown: handleLPointerDown,
435
+ onPointerMove: handleLPointerMove,
436
+ children: /* @__PURE__ */ jsx(
437
+ "div",
438
+ {
439
+ className: ColorPicker_module_default.lThumb,
440
+ style: { left: `${l}%` }
441
+ }
442
+ )
443
+ }
444
+ ),
445
+ showAlpha && /* @__PURE__ */ jsx(
446
+ "div",
447
+ {
448
+ className: ColorPicker_module_default.alphaSlider,
449
+ style: { backgroundImage: alphaGradient },
450
+ onPointerDown: handleAPointerDown,
451
+ onPointerMove: handleAPointerMove,
452
+ children: /* @__PURE__ */ jsx(
453
+ "div",
454
+ {
455
+ className: ColorPicker_module_default.alphaThumb,
456
+ style: { left: `${a * 100}%` }
457
+ }
458
+ )
459
+ }
460
+ ),
461
+ /* @__PURE__ */ jsx(
462
+ "div",
463
+ {
464
+ className: ColorPicker_module_default.previewSwatch,
465
+ style: { background: showAlpha ? colorValue.rgba : hexStr },
466
+ children: hasEyeDropper && /* @__PURE__ */ jsx("button", { className: ColorPicker_module_default.eyedropperBtn, onClick: handleEyeDropper, title: "Pick color", children: /* @__PURE__ */ jsx(EyedropperIcon, {}) })
467
+ }
468
+ ),
469
+ /* @__PURE__ */ jsxs("div", { className: ColorPicker_module_default.inputSection, children: [
470
+ /* @__PURE__ */ jsx("div", { className: ColorPicker_module_default.tabs, children: ["hex", "hsl", "rgb"].map((m) => /* @__PURE__ */ jsx(
471
+ "button",
472
+ {
473
+ className: [ColorPicker_module_default.tab, mode === m ? ColorPicker_module_default.tabActive : ""].filter(Boolean).join(" "),
474
+ onClick: () => setMode(m),
475
+ children: m.toUpperCase()
476
+ },
477
+ m
478
+ )) }),
479
+ /* @__PURE__ */ jsx(
480
+ ColorInput,
481
+ {
482
+ mode,
483
+ h,
484
+ s,
485
+ l,
486
+ r: rr,
487
+ g: gg,
488
+ b: bb,
489
+ hex: hexStr,
490
+ onChange: (nh, ns, nl) => {
491
+ setH(nh);
492
+ setS(ns);
493
+ setL(nl);
494
+ notify(nh, ns, nl, a);
495
+ },
496
+ onCopy: handleCopy,
497
+ copied
498
+ }
499
+ )
500
+ ] }),
501
+ recentColors.length > 0 && /* @__PURE__ */ jsxs("div", { className: ColorPicker_module_default.recents, children: [
502
+ /* @__PURE__ */ jsx("span", { className: ColorPicker_module_default.recentsLabel, children: "Recent" }),
503
+ /* @__PURE__ */ jsx("div", { className: ColorPicker_module_default.swatches, children: recentColors.slice(0, 8).map((c, i) => /* @__PURE__ */ jsx(
504
+ "button",
505
+ {
506
+ className: ColorPicker_module_default.recentSwatch,
507
+ style: { background: c },
508
+ onClick: () => handleSwatch(c),
509
+ title: c
510
+ },
511
+ i
512
+ )) })
513
+ ] })
514
+ ]
515
+ }
516
+ );
517
+ };
518
+
519
+ export { ColorPicker };
520
+ //# sourceMappingURL=index.js.map
521
+ //# sourceMappingURL=index.js.map