@fab1o978/react-ui 0.2.3 → 0.2.5
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 +52 -65
- package/dist/components/ColorWheel/index.cjs.map +1 -1
- package/dist/components/ColorWheel/index.css +0 -2
- package/dist/components/ColorWheel/index.css.map +1 -1
- package/dist/components/ColorWheel/index.js +52 -65
- package/dist/components/ColorWheel/index.js.map +1 -1
- package/dist/index.cjs +52 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +52 -65
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -270,11 +270,6 @@ var ARC_A1 = 150;
|
|
|
270
270
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
271
271
|
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
272
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
|
-
}
|
|
278
273
|
var MODES_HSV = ["h", "s", "v"];
|
|
279
274
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
280
275
|
function ringGradient(mode, hsv) {
|
|
@@ -321,14 +316,6 @@ function ColorWheel({
|
|
|
321
316
|
const [editValue, setEditValue] = react.useState("");
|
|
322
317
|
const [eyedropperSupported, setEyedropperSupported] = react.useState(false);
|
|
323
318
|
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
|
-
}, []);
|
|
332
319
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
333
320
|
const lastEmitted = react.useRef(value);
|
|
334
321
|
react.useEffect(() => {
|
|
@@ -379,8 +366,15 @@ function ColorWheel({
|
|
|
379
366
|
const arcHandleR = ARC_HANDLE_R_FRAC * 380;
|
|
380
367
|
const arcHandleDx = arcHandleR * Math.sin(arcAngleFromTop);
|
|
381
368
|
const arcHandleDy = -arcHandleR * Math.cos(arcAngleFromTop);
|
|
369
|
+
function nextHueHsv(h) {
|
|
370
|
+
return {
|
|
371
|
+
h,
|
|
372
|
+
s: hsv.s === 0 ? 50 : hsv.s,
|
|
373
|
+
v: hsv.v === 0 ? 50 : hsv.v
|
|
374
|
+
};
|
|
375
|
+
}
|
|
382
376
|
function applyRingAngle(angle) {
|
|
383
|
-
if (mode === "h") commit(
|
|
377
|
+
if (mode === "h") commit(nextHueHsv(angle), alpha);
|
|
384
378
|
else if (mode === "s") commit({ ...hsv, s: angle / 360 * 100 }, alpha);
|
|
385
379
|
else if (mode === "a") commit(hsv, angle / 360);
|
|
386
380
|
else commit({ ...hsv, v: angle / 360 * 100 }, alpha);
|
|
@@ -431,7 +425,7 @@ function ColorWheel({
|
|
|
431
425
|
if (dist < rect.width * RING_INNER_FRAC || dist > rect.width * RING_OUTER_FRAC) return;
|
|
432
426
|
e.preventDefault();
|
|
433
427
|
const dir = e.deltaY > 0 ? -1 : 1;
|
|
434
|
-
if (mode === "h") commit(
|
|
428
|
+
if (mode === "h") commit(nextHueHsv((hsv.h + dir * 4 + 360) % 360), alpha);
|
|
435
429
|
else if (mode === "s") commit({ ...hsv, s: clamp(hsv.s + dir * 3, 0, 100) }, alpha);
|
|
436
430
|
else if (mode === "a") commit(hsv, clamp(round2(alpha + dir * 0.03), 0, 1));
|
|
437
431
|
else commit({ ...hsv, v: clamp(hsv.v + dir * 3, 0, 100) }, alpha);
|
|
@@ -546,56 +540,49 @@ function ColorWheel({
|
|
|
546
540
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
547
541
|
},
|
|
548
542
|
children: [
|
|
549
|
-
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
"
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
]
|
|
593
|
-
},
|
|
594
|
-
hex
|
|
595
|
-
)
|
|
596
|
-
))
|
|
597
|
-
}
|
|
598
|
-
),
|
|
543
|
+
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsxRuntime.jsx("div", { className: [ColorWheel_module_default.recents, favorites.length === 0 ? ColorWheel_module_default.recentsEmpty : ""].join(" "), children: favorites.map((hex, i) => (
|
|
544
|
+
// keyed by hex alone (not index) so an add/remove -- which
|
|
545
|
+
// shifts every other item's index -- doesn't remount and replay
|
|
546
|
+
// the entrance animation on chips that were already there; only
|
|
547
|
+
// a genuinely new hex mounts fresh and animates in
|
|
548
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
549
|
+
"div",
|
|
550
|
+
{
|
|
551
|
+
className: [ColorWheel_module_default.chipWrap, removingHexes.has(hex) ? ColorWheel_module_default.chipWrapRemoving : ""].join(" "),
|
|
552
|
+
style: { animationDelay: removingHexes.has(hex) ? void 0 : `${i * 0.05}s` },
|
|
553
|
+
onAnimationEnd: (e) => {
|
|
554
|
+
if (e.target === e.currentTarget && e.animationName.includes("chipOut")) handleChipRemoveEnd(hex);
|
|
555
|
+
},
|
|
556
|
+
children: [
|
|
557
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
558
|
+
"button",
|
|
559
|
+
{
|
|
560
|
+
type: "button",
|
|
561
|
+
className: ColorWheel_module_default.chip,
|
|
562
|
+
style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
|
|
563
|
+
title: hex,
|
|
564
|
+
"aria-label": `Apply color ${hex}`,
|
|
565
|
+
onClick: () => applyFavorite(hex)
|
|
566
|
+
}
|
|
567
|
+
),
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
569
|
+
"button",
|
|
570
|
+
{
|
|
571
|
+
type: "button",
|
|
572
|
+
className: ColorWheel_module_default.chipRemove,
|
|
573
|
+
"aria-label": `Remove ${hex} from favorites`,
|
|
574
|
+
onClick: (e) => {
|
|
575
|
+
e.stopPropagation();
|
|
576
|
+
removeFavorite(hex);
|
|
577
|
+
},
|
|
578
|
+
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" }) })
|
|
579
|
+
}
|
|
580
|
+
)
|
|
581
|
+
]
|
|
582
|
+
},
|
|
583
|
+
hex
|
|
584
|
+
)
|
|
585
|
+
)) }),
|
|
599
586
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
600
587
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
601
588
|
"div",
|