@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.cjs
CHANGED
|
@@ -4699,7 +4699,9 @@ var PageBreakButton = () => {
|
|
|
4699
4699
|
var ColorWheel_module_default = {
|
|
4700
4700
|
root: "ColorWheel_module_root",
|
|
4701
4701
|
recents: "ColorWheel_module_recents",
|
|
4702
|
+
recentsEmpty: "ColorWheel_module_recentsEmpty",
|
|
4702
4703
|
chipWrap: "ColorWheel_module_chipWrap",
|
|
4704
|
+
chipWrapRemoving: "ColorWheel_module_chipWrapRemoving",
|
|
4703
4705
|
chip: "ColorWheel_module_chip",
|
|
4704
4706
|
chipRemove: "ColorWheel_module_chipRemove",
|
|
4705
4707
|
picker: "ColorWheel_module_picker",
|
|
@@ -4882,6 +4884,13 @@ var RING_OUTER_FRAC = 0.5;
|
|
|
4882
4884
|
var ARC_A0 = 30;
|
|
4883
4885
|
var ARC_A1 = 150;
|
|
4884
4886
|
var ARC_HANDLE_R_FRAC = 152 / 380;
|
|
4887
|
+
var PICKER_HEIGHT_WITH_ARC = 265;
|
|
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
|
+
}
|
|
4885
4894
|
var MODES_HSV = ["h", "s", "v"];
|
|
4886
4895
|
var MODES_HSVA = ["h", "s", "v", "a"];
|
|
4887
4896
|
function ringGradient(mode, hsv) {
|
|
@@ -4927,6 +4936,15 @@ function ColorWheel({
|
|
|
4927
4936
|
const [editing, setEditing] = React.useState(false);
|
|
4928
4937
|
const [editValue, setEditValue] = React.useState("");
|
|
4929
4938
|
const [eyedropperSupported, setEyedropperSupported] = React.useState(false);
|
|
4939
|
+
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
|
+
}, []);
|
|
4930
4948
|
const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
|
|
4931
4949
|
const lastEmitted = React.useRef(value);
|
|
4932
4950
|
React.useEffect(() => {
|
|
@@ -5122,6 +5140,15 @@ function ColorWheel({
|
|
|
5122
5140
|
if (next) commit(next.hsv, next.a);
|
|
5123
5141
|
}
|
|
5124
5142
|
function removeFavorite(hex) {
|
|
5143
|
+
setRemovingHexes((prev) => new Set(prev).add(hex));
|
|
5144
|
+
}
|
|
5145
|
+
function handleChipRemoveEnd(hex) {
|
|
5146
|
+
setRemovingHexes((prev) => {
|
|
5147
|
+
if (!prev.has(hex)) return prev;
|
|
5148
|
+
const next = new Set(prev);
|
|
5149
|
+
next.delete(hex);
|
|
5150
|
+
return next;
|
|
5151
|
+
});
|
|
5125
5152
|
onFavoritesChange?.(favorites.filter((h) => h !== hex));
|
|
5126
5153
|
}
|
|
5127
5154
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -5135,33 +5162,57 @@ function ColorWheel({
|
|
|
5135
5162
|
...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
|
|
5136
5163
|
},
|
|
5137
5164
|
children: [
|
|
5138
|
-
favorites.length > 0
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5158
|
-
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
+
(favorites.length > 0 || onFavoritesChange) && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5166
|
+
"div",
|
|
5167
|
+
{
|
|
5168
|
+
className: [ColorWheel_module_default.recents, favorites.length === 0 ? ColorWheel_module_default.recentsEmpty : ""].join(" "),
|
|
5169
|
+
style: { width: recentsGrown ? recentsContentWidth(favorites.length) : 0 },
|
|
5170
|
+
children: favorites.map((hex, i) => (
|
|
5171
|
+
// keyed by hex alone (not index) so an add/remove -- which
|
|
5172
|
+
// shifts every other item's index -- doesn't remount and replay
|
|
5173
|
+
// the entrance animation on chips that were already there; only
|
|
5174
|
+
// a genuinely new hex mounts fresh and animates in
|
|
5175
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5176
|
+
"div",
|
|
5177
|
+
{
|
|
5178
|
+
className: [ColorWheel_module_default.chipWrap, removingHexes.has(hex) ? ColorWheel_module_default.chipWrapRemoving : ""].join(" "),
|
|
5179
|
+
style: { animationDelay: removingHexes.has(hex) ? void 0 : `${i * 0.05}s` },
|
|
5180
|
+
onAnimationEnd: (e) => {
|
|
5181
|
+
if (e.target === e.currentTarget && e.animationName.includes("chipOut")) handleChipRemoveEnd(hex);
|
|
5182
|
+
},
|
|
5183
|
+
children: [
|
|
5184
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5185
|
+
"button",
|
|
5186
|
+
{
|
|
5187
|
+
type: "button",
|
|
5188
|
+
className: ColorWheel_module_default.chip,
|
|
5189
|
+
style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
|
|
5190
|
+
title: hex,
|
|
5191
|
+
"aria-label": `Apply color ${hex}`,
|
|
5192
|
+
onClick: () => applyFavorite(hex)
|
|
5193
|
+
}
|
|
5194
|
+
),
|
|
5195
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5196
|
+
"button",
|
|
5197
|
+
{
|
|
5198
|
+
type: "button",
|
|
5199
|
+
className: ColorWheel_module_default.chipRemove,
|
|
5200
|
+
"aria-label": `Remove ${hex} from favorites`,
|
|
5201
|
+
onClick: (e) => {
|
|
5202
|
+
e.stopPropagation();
|
|
5203
|
+
removeFavorite(hex);
|
|
5204
|
+
},
|
|
5205
|
+
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" }) })
|
|
5206
|
+
}
|
|
5207
|
+
)
|
|
5208
|
+
]
|
|
5209
|
+
},
|
|
5210
|
+
hex
|
|
5211
|
+
)
|
|
5212
|
+
))
|
|
5213
|
+
}
|
|
5214
|
+
),
|
|
5215
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: ColorWheel_module_default.picker, style: { height: arcVisible ? PICKER_HEIGHT_WITH_ARC : PICKER_HEIGHT_NO_ARC }, children: [
|
|
5165
5216
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5166
5217
|
"div",
|
|
5167
5218
|
{
|