@fab1o978/react-ui 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ColorWheel/index.cjs +78 -27
- package/dist/components/ColorWheel/index.cjs.map +1 -1
- package/dist/components/ColorWheel/index.css +21 -3
- package/dist/components/ColorWheel/index.css.map +1 -1
- package/dist/components/ColorWheel/index.js +78 -27
- package/dist/components/ColorWheel/index.js.map +1 -1
- package/dist/index.cjs +78 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +21 -3
- package/dist/index.css.map +1 -1
- package/dist/index.js +78 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,9 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
9
9
|
var ColorWheel_module_default = {
|
|
10
10
|
root: "ColorWheel_module_root2",
|
|
11
11
|
recents: "ColorWheel_module_recents2",
|
|
12
|
+
recentsEmpty: "ColorWheel_module_recentsEmpty2",
|
|
12
13
|
chipWrap: "ColorWheel_module_chipWrap2",
|
|
14
|
+
chipWrapRemoving: "ColorWheel_module_chipWrapRemoving2",
|
|
13
15
|
chip: "ColorWheel_module_chip2",
|
|
14
16
|
chipRemove: "ColorWheel_module_chipRemove2",
|
|
15
17
|
picker: "ColorWheel_module_picker2",
|
|
@@ -266,6 +268,13 @@ var RING_OUTER_FRAC = 0.5;
|
|
|
266
268
|
var ARC_A0 = 30;
|
|
267
269
|
var ARC_A1 = 150;
|
|
268
270
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
271
|
+
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
272
|
+
var PICKER_HEIGHT_NO_ARC = 224;
|
|
273
|
+
var CHIP_SIZE = 26;
|
|
274
|
+
var CHIP_GAP = 7;
|
|
275
|
+
function recentsContentWidth(chipCount) {
|
|
276
|
+
return chipCount > 0 ? chipCount * CHIP_SIZE + (chipCount - 1) * CHIP_GAP : 0;
|
|
277
|
+
}
|
|
269
278
|
var MODES_HSV = ["h", "s", "v"];
|
|
270
279
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
271
280
|
function ringGradient(mode, hsv) {
|
|
@@ -311,6 +320,15 @@ function ColorWheel({
|
|
|
311
320
|
const [editing, setEditing] = react.useState(false);
|
|
312
321
|
const [editValue, setEditValue] = react.useState("");
|
|
313
322
|
const [eyedropperSupported, setEyedropperSupported] = react.useState(false);
|
|
323
|
+
const [removingHexes, setRemovingHexes] = react.useState(/* @__PURE__ */ new Set());
|
|
324
|
+
const [recentsGrown, setRecentsGrown] = react.useState(false);
|
|
325
|
+
const recentsGrowRaf = react.useRef(0);
|
|
326
|
+
react.useEffect(() => {
|
|
327
|
+
recentsGrowRaf.current = requestAnimationFrame(() => {
|
|
328
|
+
recentsGrowRaf.current = requestAnimationFrame(() => setRecentsGrown(true));
|
|
329
|
+
});
|
|
330
|
+
return () => cancelAnimationFrame(recentsGrowRaf.current);
|
|
331
|
+
}, []);
|
|
314
332
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
315
333
|
const lastEmitted = react.useRef(value);
|
|
316
334
|
react.useEffect(() => {
|
|
@@ -506,6 +524,15 @@ function ColorWheel({
|
|
|
506
524
|
if (next) commit(next.hsv, next.a);
|
|
507
525
|
}
|
|
508
526
|
function removeFavorite(hex) {
|
|
527
|
+
setRemovingHexes((prev) => new Set(prev).add(hex));
|
|
528
|
+
}
|
|
529
|
+
function handleChipRemoveEnd(hex) {
|
|
530
|
+
setRemovingHexes((prev) => {
|
|
531
|
+
if (!prev.has(hex)) return prev;
|
|
532
|
+
const next = new Set(prev);
|
|
533
|
+
next.delete(hex);
|
|
534
|
+
return next;
|
|
535
|
+
});
|
|
509
536
|
onFavoritesChange?.(favorites.filter((h) => h !== hex));
|
|
510
537
|
}
|
|
511
538
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -519,33 +546,57 @@ function ColorWheel({
|
|
|
519
546
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
520
547
|
},
|
|
521
548
|
children: [
|
|
522
|
-
favorites.length > 0
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
+
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
550
|
+
"div",
|
|
551
|
+
{
|
|
552
|
+
className: [ColorWheel_module_default.recents, favorites.length === 0 ? ColorWheel_module_default.recentsEmpty : ""].join(" "),
|
|
553
|
+
style: { width: recentsGrown ? recentsContentWidth(favorites.length) : 0 },
|
|
554
|
+
children: favorites.map((hex, i) => (
|
|
555
|
+
// keyed by hex alone (not index) so an add/remove -- which
|
|
556
|
+
// shifts every other item's index -- doesn't remount and replay
|
|
557
|
+
// the entrance animation on chips that were already there; only
|
|
558
|
+
// a genuinely new hex mounts fresh and animates in
|
|
559
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
560
|
+
"div",
|
|
561
|
+
{
|
|
562
|
+
className: [ColorWheel_module_default.chipWrap, removingHexes.has(hex) ? ColorWheel_module_default.chipWrapRemoving : ""].join(" "),
|
|
563
|
+
style: { animationDelay: removingHexes.has(hex) ? void 0 : `${i * 0.05}s` },
|
|
564
|
+
onAnimationEnd: (e) => {
|
|
565
|
+
if (e.target === e.currentTarget && e.animationName.includes("chipOut")) handleChipRemoveEnd(hex);
|
|
566
|
+
},
|
|
567
|
+
children: [
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
569
|
+
"button",
|
|
570
|
+
{
|
|
571
|
+
type: "button",
|
|
572
|
+
className: ColorWheel_module_default.chip,
|
|
573
|
+
style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
|
|
574
|
+
title: hex,
|
|
575
|
+
"aria-label": `Apply color ${hex}`,
|
|
576
|
+
onClick: () => applyFavorite(hex)
|
|
577
|
+
}
|
|
578
|
+
),
|
|
579
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
580
|
+
"button",
|
|
581
|
+
{
|
|
582
|
+
type: "button",
|
|
583
|
+
className: ColorWheel_module_default.chipRemove,
|
|
584
|
+
"aria-label": `Remove ${hex} from favorites`,
|
|
585
|
+
onClick: (e) => {
|
|
586
|
+
e.stopPropagation();
|
|
587
|
+
removeFavorite(hex);
|
|
588
|
+
},
|
|
589
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, strokeLinecap: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 6l12 12M18 6L6 18" }) })
|
|
590
|
+
}
|
|
591
|
+
)
|
|
592
|
+
]
|
|
593
|
+
},
|
|
594
|
+
hex
|
|
595
|
+
)
|
|
596
|
+
))
|
|
597
|
+
}
|
|
598
|
+
),
|
|
599
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
549
600
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
550
601
|
"div",
|
|
551
602
|
{
|