@hilum/ui 3.8.4 → 3.8.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/index.js +21 -13
- package/dist/index.js.map +1 -1
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/src/components/color-picker.tsx +32 -12
package/dist/index.js
CHANGED
|
@@ -6651,6 +6651,13 @@ function parseColor(input) {
|
|
|
6651
6651
|
}
|
|
6652
6652
|
return null;
|
|
6653
6653
|
}
|
|
6654
|
+
function colorsRepresentSameValue(left, right) {
|
|
6655
|
+
if (left.trim().toLowerCase() === right.trim().toLowerCase()) return true;
|
|
6656
|
+
const leftColor = parseColor(left);
|
|
6657
|
+
const rightColor = parseColor(right);
|
|
6658
|
+
if (!leftColor || !rightColor) return false;
|
|
6659
|
+
return Math.abs(leftColor.r - rightColor.r) < 0.5 && Math.abs(leftColor.g - rightColor.g) < 0.5 && Math.abs(leftColor.b - rightColor.b) < 0.5 && Math.abs(leftColor.a - rightColor.a) < 0.5 / 255;
|
|
6660
|
+
}
|
|
6654
6661
|
function buildParsed(h, s, v, a) {
|
|
6655
6662
|
const { r, g, b } = hsvToRgb(h, s, v);
|
|
6656
6663
|
const hsl = rgbToHsl(r, g, b);
|
|
@@ -6694,7 +6701,7 @@ var CHECKER_BG = {
|
|
|
6694
6701
|
function SaturationSquare({ h, s, v, onChange }) {
|
|
6695
6702
|
const ref = useRef(null);
|
|
6696
6703
|
const dragging = useRef(false);
|
|
6697
|
-
const
|
|
6704
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
6698
6705
|
const [focused, setFocused] = useState(false);
|
|
6699
6706
|
const [hovered, setHovered] = useState(false);
|
|
6700
6707
|
const [cursorPos, setCursorPos] = useState(null);
|
|
@@ -6722,7 +6729,7 @@ function SaturationSquare({ h, s, v, onChange }) {
|
|
|
6722
6729
|
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
6723
6730
|
e.preventDefault();
|
|
6724
6731
|
dragging.current = true;
|
|
6725
|
-
|
|
6732
|
+
setIsDragging(true);
|
|
6726
6733
|
e.currentTarget.setPointerCapture(e.pointerId);
|
|
6727
6734
|
updateFromPointer(e.clientX, e.clientY);
|
|
6728
6735
|
},
|
|
@@ -6732,14 +6739,13 @@ function SaturationSquare({ h, s, v, onChange }) {
|
|
|
6732
6739
|
(e) => {
|
|
6733
6740
|
updateCursorPos(e.clientX, e.clientY);
|
|
6734
6741
|
if (!dragging.current) return;
|
|
6735
|
-
hasMoved.current = true;
|
|
6736
6742
|
updateFromPointer(e.clientX, e.clientY);
|
|
6737
6743
|
},
|
|
6738
6744
|
[updateFromPointer, updateCursorPos]
|
|
6739
6745
|
);
|
|
6740
6746
|
const onPointerUp = useCallback(() => {
|
|
6741
6747
|
dragging.current = false;
|
|
6742
|
-
|
|
6748
|
+
setIsDragging(false);
|
|
6743
6749
|
}, []);
|
|
6744
6750
|
const onKeyDown = useCallback(
|
|
6745
6751
|
(e) => {
|
|
@@ -6778,6 +6784,8 @@ function SaturationSquare({ h, s, v, onChange }) {
|
|
|
6778
6784
|
onPointerDown,
|
|
6779
6785
|
onPointerMove,
|
|
6780
6786
|
onPointerUp,
|
|
6787
|
+
onPointerCancel: onPointerUp,
|
|
6788
|
+
onLostPointerCapture: onPointerUp,
|
|
6781
6789
|
onKeyDown,
|
|
6782
6790
|
className: cn("relative w-full select-none touch-none cursor-none outline-none", shape3.bg),
|
|
6783
6791
|
style: {
|
|
@@ -6798,18 +6806,16 @@ function SaturationSquare({ h, s, v, onChange }) {
|
|
|
6798
6806
|
}
|
|
6799
6807
|
),
|
|
6800
6808
|
/* @__PURE__ */ jsx(
|
|
6801
|
-
|
|
6809
|
+
"div",
|
|
6802
6810
|
{
|
|
6811
|
+
"data-slot": "color-picker-thumb",
|
|
6812
|
+
"aria-hidden": "true",
|
|
6803
6813
|
className: "absolute pointer-events-none rounded-full",
|
|
6804
|
-
|
|
6805
|
-
animate: {
|
|
6814
|
+
style: {
|
|
6806
6815
|
left: `${s * 100}%`,
|
|
6807
6816
|
top: `${(1 - v) * 100}%`,
|
|
6808
6817
|
width: 18,
|
|
6809
|
-
height: 18
|
|
6810
|
-
},
|
|
6811
|
-
transition: { duration: 0 },
|
|
6812
|
-
style: {
|
|
6818
|
+
height: 18,
|
|
6813
6819
|
transform: "translate(-50%, -50%)",
|
|
6814
6820
|
border: "1px solid white",
|
|
6815
6821
|
boxShadow: "0 0 0 1px rgba(0,0,0,1)",
|
|
@@ -6817,9 +6823,11 @@ function SaturationSquare({ h, s, v, onChange }) {
|
|
|
6817
6823
|
}
|
|
6818
6824
|
}
|
|
6819
6825
|
),
|
|
6820
|
-
hovered && !
|
|
6826
|
+
hovered && !isDragging && cursorPos && /* @__PURE__ */ jsx(
|
|
6821
6827
|
"div",
|
|
6822
6828
|
{
|
|
6829
|
+
"data-slot": "color-picker-hover",
|
|
6830
|
+
"aria-hidden": "true",
|
|
6823
6831
|
className: "absolute pointer-events-none rounded-full",
|
|
6824
6832
|
style: {
|
|
6825
6833
|
left: `${cursorPos.x}%`,
|
|
@@ -7409,7 +7417,7 @@ var ColorPicker = forwardRef(
|
|
|
7409
7417
|
if (!isControlled) return;
|
|
7410
7418
|
const emitted = lastEmittedRef.current;
|
|
7411
7419
|
const cur = value;
|
|
7412
|
-
if (cur === emitted) return;
|
|
7420
|
+
if (cur === emitted || colorsRepresentSameValue(cur, emitted)) return;
|
|
7413
7421
|
const p = parseColor(cur);
|
|
7414
7422
|
if (!p) return;
|
|
7415
7423
|
oklchHueRef.current = null;
|