@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.cjs
CHANGED
|
@@ -4886,11 +4886,6 @@ var ARC_A1 = 150;
|
|
|
4886
4886
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
4887
4887
|
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
4888
4888
|
var PICKER_HEIGHT_NO_ARC = 224;
|
|
4889
|
-
var CHIP_SIZE = 26;
|
|
4890
|
-
var CHIP_GAP = 7;
|
|
4891
|
-
function recentsContentWidth(chipCount) {
|
|
4892
|
-
return chipCount > 0 ? chipCount * CHIP_SIZE + (chipCount - 1) * CHIP_GAP : 0;
|
|
4893
|
-
}
|
|
4894
4889
|
var MODES_HSV = ["h", "s", "v"];
|
|
4895
4890
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
4896
4891
|
function ringGradient(mode, hsv) {
|
|
@@ -4937,14 +4932,6 @@ function ColorWheel({
|
|
|
4937
4932
|
const [editValue, setEditValue] = React.useState("");
|
|
4938
4933
|
const [eyedropperSupported, setEyedropperSupported] = React.useState(false);
|
|
4939
4934
|
const [removingHexes, setRemovingHexes] = React.useState(/* @__PURE__ */ new Set());
|
|
4940
|
-
const [recentsGrown, setRecentsGrown] = React.useState(false);
|
|
4941
|
-
const recentsGrowRaf = React.useRef(0);
|
|
4942
|
-
React.useEffect(() => {
|
|
4943
|
-
recentsGrowRaf.current = requestAnimationFrame(() => {
|
|
4944
|
-
recentsGrowRaf.current = requestAnimationFrame(() => setRecentsGrown(true));
|
|
4945
|
-
});
|
|
4946
|
-
return () => cancelAnimationFrame(recentsGrowRaf.current);
|
|
4947
|
-
}, []);
|
|
4948
4935
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
4949
4936
|
const lastEmitted = React.useRef(value);
|
|
4950
4937
|
React.useEffect(() => {
|
|
@@ -4995,8 +4982,15 @@ function ColorWheel({
|
|
|
4995
4982
|
const arcHandleR = ARC_HANDLE_R_FRAC * 380;
|
|
4996
4983
|
const arcHandleDx = arcHandleR * Math.sin(arcAngleFromTop);
|
|
4997
4984
|
const arcHandleDy = -arcHandleR * Math.cos(arcAngleFromTop);
|
|
4985
|
+
function nextHueHsv(h) {
|
|
4986
|
+
return {
|
|
4987
|
+
h,
|
|
4988
|
+
s: hsv.s === 0 ? 50 : hsv.s,
|
|
4989
|
+
v: hsv.v === 0 ? 50 : hsv.v
|
|
4990
|
+
};
|
|
4991
|
+
}
|
|
4998
4992
|
function applyRingAngle(angle) {
|
|
4999
|
-
if (mode === "h") commit(
|
|
4993
|
+
if (mode === "h") commit(nextHueHsv(angle), alpha);
|
|
5000
4994
|
else if (mode === "s") commit({ ...hsv, s: angle / 360 * 100 }, alpha);
|
|
5001
4995
|
else if (mode === "a") commit(hsv, angle / 360);
|
|
5002
4996
|
else commit({ ...hsv, v: angle / 360 * 100 }, alpha);
|
|
@@ -5047,7 +5041,7 @@ function ColorWheel({
|
|
|
5047
5041
|
if (dist < rect.width * RING_INNER_FRAC || dist > rect.width * RING_OUTER_FRAC) return;
|
|
5048
5042
|
e.preventDefault();
|
|
5049
5043
|
const dir = e.deltaY > 0 ? -1 : 1;
|
|
5050
|
-
if (mode === "h") commit(
|
|
5044
|
+
if (mode === "h") commit(nextHueHsv((hsv.h + dir * 4 + 360) % 360), alpha);
|
|
5051
5045
|
else if (mode === "s") commit({ ...hsv, s: clamp2(hsv.s + dir * 3, 0, 100) }, alpha);
|
|
5052
5046
|
else if (mode === "a") commit(hsv, clamp2(round2(alpha + dir * 0.03), 0, 1));
|
|
5053
5047
|
else commit({ ...hsv, v: clamp2(hsv.v + dir * 3, 0, 100) }, alpha);
|
|
@@ -5162,56 +5156,49 @@ function ColorWheel({
|
|
|
5162
5156
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
5163
5157
|
},
|
|
5164
5158
|
children: [
|
|
5165
|
-
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
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
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
]
|
|
5209
|
-
},
|
|
5210
|
-
hex
|
|
5211
|
-
)
|
|
5212
|
-
))
|
|
5213
|
-
}
|
|
5214
|
-
),
|
|
5159
|
+
(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) => (
|
|
5160
|
+
// keyed by hex alone (not index) so an add/remove -- which
|
|
5161
|
+
// shifts every other item's index -- doesn't remount and replay
|
|
5162
|
+
// the entrance animation on chips that were already there; only
|
|
5163
|
+
// a genuinely new hex mounts fresh and animates in
|
|
5164
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5165
|
+
"div",
|
|
5166
|
+
{
|
|
5167
|
+
className: [ColorWheel_module_default.chipWrap, removingHexes.has(hex) ? ColorWheel_module_default.chipWrapRemoving : ""].join(" "),
|
|
5168
|
+
style: { animationDelay: removingHexes.has(hex) ? void 0 : `${i * 0.05}s` },
|
|
5169
|
+
onAnimationEnd: (e) => {
|
|
5170
|
+
if (e.target === e.currentTarget && e.animationName.includes("chipOut")) handleChipRemoveEnd(hex);
|
|
5171
|
+
},
|
|
5172
|
+
children: [
|
|
5173
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5174
|
+
"button",
|
|
5175
|
+
{
|
|
5176
|
+
type: "button",
|
|
5177
|
+
className: ColorWheel_module_default.chip,
|
|
5178
|
+
style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
|
|
5179
|
+
title: hex,
|
|
5180
|
+
"aria-label": `Apply color ${hex}`,
|
|
5181
|
+
onClick: () => applyFavorite(hex)
|
|
5182
|
+
}
|
|
5183
|
+
),
|
|
5184
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5185
|
+
"button",
|
|
5186
|
+
{
|
|
5187
|
+
type: "button",
|
|
5188
|
+
className: ColorWheel_module_default.chipRemove,
|
|
5189
|
+
"aria-label": `Remove ${hex} from favorites`,
|
|
5190
|
+
onClick: (e) => {
|
|
5191
|
+
e.stopPropagation();
|
|
5192
|
+
removeFavorite(hex);
|
|
5193
|
+
},
|
|
5194
|
+
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" }) })
|
|
5195
|
+
}
|
|
5196
|
+
)
|
|
5197
|
+
]
|
|
5198
|
+
},
|
|
5199
|
+
hex
|
|
5200
|
+
)
|
|
5201
|
+
)) }),
|
|
5215
5202
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
5216
5203
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5217
5204
|
"div",
|