@fab1o978/react-ui 0.2.1 → 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 +75 -26
- package/dist/components/ColorWheel/index.cjs.map +1 -1
- package/dist/components/ColorWheel/index.css +19 -0
- package/dist/components/ColorWheel/index.css.map +1 -1
- package/dist/components/ColorWheel/index.js +75 -26
- package/dist/components/ColorWheel/index.js.map +1 -1
- package/dist/index.cjs +75 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +19 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +75 -26
- 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",
|
|
@@ -4876,6 +4878,11 @@ var ARC_A1 = 150;
|
|
|
4876
4878
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
4877
4879
|
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
4878
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
|
+
}
|
|
4879
4886
|
var MODES_HSV = ["h", "s", "v"];
|
|
4880
4887
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
4881
4888
|
function ringGradient(mode, hsv) {
|
|
@@ -4921,6 +4928,15 @@ function ColorWheel({
|
|
|
4921
4928
|
const [editing, setEditing] = useState(false);
|
|
4922
4929
|
const [editValue, setEditValue] = useState("");
|
|
4923
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
|
+
}, []);
|
|
4924
4940
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
4925
4941
|
const lastEmitted = useRef(value);
|
|
4926
4942
|
useEffect(() => {
|
|
@@ -5116,6 +5132,15 @@ function ColorWheel({
|
|
|
5116
5132
|
if (next) commit(next.hsv, next.a);
|
|
5117
5133
|
}
|
|
5118
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
|
+
});
|
|
5119
5144
|
onFavoritesChange?.(favorites.filter((h) => h !== hex));
|
|
5120
5145
|
}
|
|
5121
5146
|
return /* @__PURE__ */ jsxs(
|
|
@@ -5129,32 +5154,56 @@ function ColorWheel({
|
|
|
5129
5154
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
5130
5155
|
},
|
|
5131
5156
|
children: [
|
|
5132
|
-
favorites.length > 0
|
|
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
|
-
|
|
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
|
+
),
|
|
5158
5207
|
/* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
5159
5208
|
/* @__PURE__ */ jsx(
|
|
5160
5209
|
"div",
|