@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
package/dist/index.js
CHANGED
|
@@ -4691,7 +4691,9 @@ var PageBreakButton = () => {
|
|
|
4691
4691
|
var ColorWheel_module_default = {
|
|
4692
4692
|
root: "ColorWheel_module_root",
|
|
4693
4693
|
recents: "ColorWheel_module_recents",
|
|
4694
|
+
recentsEmpty: "ColorWheel_module_recentsEmpty",
|
|
4694
4695
|
chipWrap: "ColorWheel_module_chipWrap",
|
|
4696
|
+
chipWrapRemoving: "ColorWheel_module_chipWrapRemoving",
|
|
4695
4697
|
chip: "ColorWheel_module_chip",
|
|
4696
4698
|
chipRemove: "ColorWheel_module_chipRemove",
|
|
4697
4699
|
picker: "ColorWheel_module_picker",
|
|
@@ -4874,6 +4876,13 @@ var RING_OUTER_FRAC = 0.5;
|
|
|
4874
4876
|
var ARC_A0 = 30;
|
|
4875
4877
|
var ARC_A1 = 150;
|
|
4876
4878
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
4879
|
+
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
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
|
+
}
|
|
4877
4886
|
var MODES_HSV = ["h", "s", "v"];
|
|
4878
4887
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
4879
4888
|
function ringGradient(mode, hsv) {
|
|
@@ -4919,6 +4928,15 @@ function ColorWheel({
|
|
|
4919
4928
|
const [editing, setEditing] = useState(false);
|
|
4920
4929
|
const [editValue, setEditValue] = useState("");
|
|
4921
4930
|
const [eyedropperSupported, setEyedropperSupported] = useState(false);
|
|
4931
|
+
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
|
+
}, []);
|
|
4922
4940
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
4923
4941
|
const lastEmitted = useRef(value);
|
|
4924
4942
|
useEffect(() => {
|
|
@@ -5114,6 +5132,15 @@ function ColorWheel({
|
|
|
5114
5132
|
if (next) commit(next.hsv, next.a);
|
|
5115
5133
|
}
|
|
5116
5134
|
function removeFavorite(hex) {
|
|
5135
|
+
setRemovingHexes((prev) => new Set(prev).add(hex));
|
|
5136
|
+
}
|
|
5137
|
+
function handleChipRemoveEnd(hex) {
|
|
5138
|
+
setRemovingHexes((prev) => {
|
|
5139
|
+
if (!prev.has(hex)) return prev;
|
|
5140
|
+
const next = new Set(prev);
|
|
5141
|
+
next.delete(hex);
|
|
5142
|
+
return next;
|
|
5143
|
+
});
|
|
5117
5144
|
onFavoritesChange?.(favorites.filter((h) => h !== hex));
|
|
5118
5145
|
}
|
|
5119
5146
|
return /* @__PURE__ */ jsxs(
|
|
@@ -5127,33 +5154,57 @@ function ColorWheel({
|
|
|
5127
5154
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
5128
5155
|
},
|
|
5129
5156
|
children: [
|
|
5130
|
-
favorites.length > 0
|
|
5131
|
-
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
+
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsx(
|
|
5158
|
+
"div",
|
|
5159
|
+
{
|
|
5160
|
+
className: [ColorWheel_module_default.recents, favorites.length === 0 ? ColorWheel_module_default.recentsEmpty : ""].join(" "),
|
|
5161
|
+
style: { width: recentsGrown ? recentsContentWidth(favorites.length) : 0 },
|
|
5162
|
+
children: favorites.map((hex, i) => (
|
|
5163
|
+
// keyed by hex alone (not index) so an add/remove -- which
|
|
5164
|
+
// shifts every other item's index -- doesn't remount and replay
|
|
5165
|
+
// the entrance animation on chips that were already there; only
|
|
5166
|
+
// a genuinely new hex mounts fresh and animates in
|
|
5167
|
+
/* @__PURE__ */ jsxs(
|
|
5168
|
+
"div",
|
|
5169
|
+
{
|
|
5170
|
+
className: [ColorWheel_module_default.chipWrap, removingHexes.has(hex) ? ColorWheel_module_default.chipWrapRemoving : ""].join(" "),
|
|
5171
|
+
style: { animationDelay: removingHexes.has(hex) ? void 0 : `${i * 0.05}s` },
|
|
5172
|
+
onAnimationEnd: (e) => {
|
|
5173
|
+
if (e.target === e.currentTarget && e.animationName.includes("chipOut")) handleChipRemoveEnd(hex);
|
|
5174
|
+
},
|
|
5175
|
+
children: [
|
|
5176
|
+
/* @__PURE__ */ jsx(
|
|
5177
|
+
"button",
|
|
5178
|
+
{
|
|
5179
|
+
type: "button",
|
|
5180
|
+
className: ColorWheel_module_default.chip,
|
|
5181
|
+
style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
|
|
5182
|
+
title: hex,
|
|
5183
|
+
"aria-label": `Apply color ${hex}`,
|
|
5184
|
+
onClick: () => applyFavorite(hex)
|
|
5185
|
+
}
|
|
5186
|
+
),
|
|
5187
|
+
/* @__PURE__ */ jsx(
|
|
5188
|
+
"button",
|
|
5189
|
+
{
|
|
5190
|
+
type: "button",
|
|
5191
|
+
className: ColorWheel_module_default.chipRemove,
|
|
5192
|
+
"aria-label": `Remove ${hex} from favorites`,
|
|
5193
|
+
onClick: (e) => {
|
|
5194
|
+
e.stopPropagation();
|
|
5195
|
+
removeFavorite(hex);
|
|
5196
|
+
},
|
|
5197
|
+
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" }) })
|
|
5198
|
+
}
|
|
5199
|
+
)
|
|
5200
|
+
]
|
|
5201
|
+
},
|
|
5202
|
+
hex
|
|
5203
|
+
)
|
|
5204
|
+
))
|
|
5205
|
+
}
|
|
5206
|
+
),
|
|
5207
|
+
/* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
5157
5208
|
/* @__PURE__ */ jsx(
|
|
5158
5209
|
"div",
|
|
5159
5210
|
{
|