@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
package/dist/index.js
CHANGED
|
@@ -4878,11 +4878,6 @@ var ARC_A1 = 150;
|
|
|
4878
4878
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
4879
4879
|
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
4880
4880
|
var PICKER_HEIGHT_NO_ARC = 224;
|
|
4881
|
-
var CHIP_SIZE = 26;
|
|
4882
|
-
var CHIP_GAP = 7;
|
|
4883
|
-
function recentsContentWidth(chipCount) {
|
|
4884
|
-
return chipCount > 0 ? chipCount * CHIP_SIZE + (chipCount - 1) * CHIP_GAP : 0;
|
|
4885
|
-
}
|
|
4886
4881
|
var MODES_HSV = ["h", "s", "v"];
|
|
4887
4882
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
4888
4883
|
function ringGradient(mode, hsv) {
|
|
@@ -4929,14 +4924,6 @@ function ColorWheel({
|
|
|
4929
4924
|
const [editValue, setEditValue] = useState("");
|
|
4930
4925
|
const [eyedropperSupported, setEyedropperSupported] = useState(false);
|
|
4931
4926
|
const [removingHexes, setRemovingHexes] = useState(/* @__PURE__ */ new Set());
|
|
4932
|
-
const [recentsGrown, setRecentsGrown] = useState(false);
|
|
4933
|
-
const recentsGrowRaf = useRef(0);
|
|
4934
|
-
useEffect(() => {
|
|
4935
|
-
recentsGrowRaf.current = requestAnimationFrame(() => {
|
|
4936
|
-
recentsGrowRaf.current = requestAnimationFrame(() => setRecentsGrown(true));
|
|
4937
|
-
});
|
|
4938
|
-
return () => cancelAnimationFrame(recentsGrowRaf.current);
|
|
4939
|
-
}, []);
|
|
4940
4927
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
4941
4928
|
const lastEmitted = useRef(value);
|
|
4942
4929
|
useEffect(() => {
|
|
@@ -4987,8 +4974,15 @@ function ColorWheel({
|
|
|
4987
4974
|
const arcHandleR = ARC_HANDLE_R_FRAC * 380;
|
|
4988
4975
|
const arcHandleDx = arcHandleR * Math.sin(arcAngleFromTop);
|
|
4989
4976
|
const arcHandleDy = -arcHandleR * Math.cos(arcAngleFromTop);
|
|
4977
|
+
function nextHueHsv(h) {
|
|
4978
|
+
return {
|
|
4979
|
+
h,
|
|
4980
|
+
s: hsv.s === 0 ? 50 : hsv.s,
|
|
4981
|
+
v: hsv.v === 0 ? 50 : hsv.v
|
|
4982
|
+
};
|
|
4983
|
+
}
|
|
4990
4984
|
function applyRingAngle(angle) {
|
|
4991
|
-
if (mode === "h") commit(
|
|
4985
|
+
if (mode === "h") commit(nextHueHsv(angle), alpha);
|
|
4992
4986
|
else if (mode === "s") commit({ ...hsv, s: angle / 360 * 100 }, alpha);
|
|
4993
4987
|
else if (mode === "a") commit(hsv, angle / 360);
|
|
4994
4988
|
else commit({ ...hsv, v: angle / 360 * 100 }, alpha);
|
|
@@ -5039,7 +5033,7 @@ function ColorWheel({
|
|
|
5039
5033
|
if (dist < rect.width * RING_INNER_FRAC || dist > rect.width * RING_OUTER_FRAC) return;
|
|
5040
5034
|
e.preventDefault();
|
|
5041
5035
|
const dir = e.deltaY > 0 ? -1 : 1;
|
|
5042
|
-
if (mode === "h") commit(
|
|
5036
|
+
if (mode === "h") commit(nextHueHsv((hsv.h + dir * 4 + 360) % 360), alpha);
|
|
5043
5037
|
else if (mode === "s") commit({ ...hsv, s: clamp2(hsv.s + dir * 3, 0, 100) }, alpha);
|
|
5044
5038
|
else if (mode === "a") commit(hsv, clamp2(round2(alpha + dir * 0.03), 0, 1));
|
|
5045
5039
|
else commit({ ...hsv, v: clamp2(hsv.v + dir * 3, 0, 100) }, alpha);
|
|
@@ -5154,56 +5148,49 @@ function ColorWheel({
|
|
|
5154
5148
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
5155
5149
|
},
|
|
5156
5150
|
children: [
|
|
5157
|
-
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsx(
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5168
|
-
"
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
]
|
|
5201
|
-
},
|
|
5202
|
-
hex
|
|
5203
|
-
)
|
|
5204
|
-
))
|
|
5205
|
-
}
|
|
5206
|
-
),
|
|
5151
|
+
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsx("div", { className: [ColorWheel_module_default.recents, favorites.length === 0 ? ColorWheel_module_default.recentsEmpty : ""].join(" "), children: favorites.map((hex, i) => (
|
|
5152
|
+
// keyed by hex alone (not index) so an add/remove -- which
|
|
5153
|
+
// shifts every other item's index -- doesn't remount and replay
|
|
5154
|
+
// the entrance animation on chips that were already there; only
|
|
5155
|
+
// a genuinely new hex mounts fresh and animates in
|
|
5156
|
+
/* @__PURE__ */ jsxs(
|
|
5157
|
+
"div",
|
|
5158
|
+
{
|
|
5159
|
+
className: [ColorWheel_module_default.chipWrap, removingHexes.has(hex) ? ColorWheel_module_default.chipWrapRemoving : ""].join(" "),
|
|
5160
|
+
style: { animationDelay: removingHexes.has(hex) ? void 0 : `${i * 0.05}s` },
|
|
5161
|
+
onAnimationEnd: (e) => {
|
|
5162
|
+
if (e.target === e.currentTarget && e.animationName.includes("chipOut")) handleChipRemoveEnd(hex);
|
|
5163
|
+
},
|
|
5164
|
+
children: [
|
|
5165
|
+
/* @__PURE__ */ jsx(
|
|
5166
|
+
"button",
|
|
5167
|
+
{
|
|
5168
|
+
type: "button",
|
|
5169
|
+
className: ColorWheel_module_default.chip,
|
|
5170
|
+
style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
|
|
5171
|
+
title: hex,
|
|
5172
|
+
"aria-label": `Apply color ${hex}`,
|
|
5173
|
+
onClick: () => applyFavorite(hex)
|
|
5174
|
+
}
|
|
5175
|
+
),
|
|
5176
|
+
/* @__PURE__ */ jsx(
|
|
5177
|
+
"button",
|
|
5178
|
+
{
|
|
5179
|
+
type: "button",
|
|
5180
|
+
className: ColorWheel_module_default.chipRemove,
|
|
5181
|
+
"aria-label": `Remove ${hex} from favorites`,
|
|
5182
|
+
onClick: (e) => {
|
|
5183
|
+
e.stopPropagation();
|
|
5184
|
+
removeFavorite(hex);
|
|
5185
|
+
},
|
|
5186
|
+
children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, strokeLinecap: "round", children: /* @__PURE__ */ jsx("path", { d: "M6 6l12 12M18 6L6 18" }) })
|
|
5187
|
+
}
|
|
5188
|
+
)
|
|
5189
|
+
]
|
|
5190
|
+
},
|
|
5191
|
+
hex
|
|
5192
|
+
)
|
|
5193
|
+
)) }),
|
|
5207
5194
|
/* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
5208
5195
|
/* @__PURE__ */ jsx(
|
|
5209
5196
|
"div",
|