@fab1o978/react-ui 0.1.8 → 0.2.0

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.
Files changed (35) hide show
  1. package/dist/components/Badge/index.d.cts +3 -3
  2. package/dist/components/Badge/index.d.ts +3 -3
  3. package/dist/components/Button/index.d.cts +3 -3
  4. package/dist/components/Button/index.d.ts +3 -3
  5. package/dist/components/ColorPicker/index.d.cts +2 -2
  6. package/dist/components/ColorPicker/index.d.ts +2 -2
  7. package/dist/components/ColorWheel/index.cjs +671 -0
  8. package/dist/components/ColorWheel/index.cjs.map +1 -0
  9. package/dist/components/ColorWheel/index.css +494 -0
  10. package/dist/components/ColorWheel/index.css.map +1 -0
  11. package/dist/components/ColorWheel/index.d.cts +49 -0
  12. package/dist/components/ColorWheel/index.d.ts +49 -0
  13. package/dist/components/ColorWheel/index.js +669 -0
  14. package/dist/components/ColorWheel/index.js.map +1 -0
  15. package/dist/components/Input/index.d.cts +5 -5
  16. package/dist/components/Input/index.d.ts +5 -5
  17. package/dist/components/RainCanvas/index.d.cts +4 -4
  18. package/dist/components/RainCanvas/index.d.ts +4 -4
  19. package/dist/components/RichTextEditor/index.d.cts +6 -6
  20. package/dist/components/RichTextEditor/index.d.ts +6 -6
  21. package/dist/components/SliderControl/index.d.cts +4 -4
  22. package/dist/components/SliderControl/index.d.ts +4 -4
  23. package/dist/components/SlidingCounter/index.d.cts +2 -2
  24. package/dist/components/SlidingCounter/index.d.ts +2 -2
  25. package/dist/components/Timeline/index.d.cts +3 -3
  26. package/dist/components/Timeline/index.d.ts +3 -3
  27. package/dist/index.cjs +588 -0
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.css +494 -0
  30. package/dist/index.css.map +1 -1
  31. package/dist/index.d.cts +1 -0
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.js +589 -2
  34. package/dist/index.js.map +1 -1
  35. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import React, { useRef, useEffect, useState, useCallback } from 'react';
1
+ import React, { useRef, useEffect, useState, useCallback, useMemo } from 'react';
2
2
  import { jsxs, jsx, Fragment as Fragment$1 } from 'react/jsx-runtime';
3
3
  import { EditorProvider, useCurrentEditor } from '@tiptap/react';
4
4
  export { useCurrentEditor } from '@tiptap/react';
@@ -4687,6 +4687,593 @@ var PageBreakButton = () => {
4687
4687
  );
4688
4688
  };
4689
4689
 
4690
- export { Badge, Button, ColorPicker, Highlight, HighlightButton, Input, PageBreak, PageBreakButton, RainCanvas, RichTextEditor, SliderControl, SlidingCounter, Timeline };
4690
+ // src/components/ColorWheel/ColorWheel.module.scss
4691
+ var ColorWheel_module_default = {
4692
+ root: "ColorWheel_module_root",
4693
+ recents: "ColorWheel_module_recents",
4694
+ chipWrap: "ColorWheel_module_chipWrap",
4695
+ chip: "ColorWheel_module_chip",
4696
+ chipRemove: "ColorWheel_module_chipRemove",
4697
+ picker: "ColorWheel_module_picker",
4698
+ glow: "ColorWheel_module_glow",
4699
+ modeToggle: "ColorWheel_module_modeToggle",
4700
+ modePill: "ColorWheel_module_modePill",
4701
+ modeButton: "ColorWheel_module_modeButton",
4702
+ active: "ColorWheel_module_active",
4703
+ stage: "ColorWheel_module_stage",
4704
+ stageShadow: "ColorWheel_module_stageShadow",
4705
+ ring: "ColorWheel_module_ring",
4706
+ hueHandlePivot: "ColorWheel_module_hueHandlePivot",
4707
+ hueHandle: "ColorWheel_module_hueHandle",
4708
+ alphaArcShadowWrap: "ColorWheel_module_alphaArcShadowWrap",
4709
+ alphaArcShadow: "ColorWheel_module_alphaArcShadow",
4710
+ alphaArc: "ColorWheel_module_alphaArc",
4711
+ alphaArcFill: "ColorWheel_module_alphaArcFill",
4712
+ alphaArcCap: "ColorWheel_module_alphaArcCap",
4713
+ alphaArcCapStart: "ColorWheel_module_alphaArcCapStart",
4714
+ alphaArcCapEnd: "ColorWheel_module_alphaArcCapEnd",
4715
+ alphaArcHandle: "ColorWheel_module_alphaArcHandle",
4716
+ currentDisc: "ColorWheel_module_currentDisc",
4717
+ discFill: "ColorWheel_module_discFill",
4718
+ currentHex: "ColorWheel_module_currentHex",
4719
+ currentHexInput: "ColorWheel_module_currentHexInput",
4720
+ copied: "ColorWheel_module_copied",
4721
+ discBadge: "ColorWheel_module_discBadge",
4722
+ discBadgeTop: "ColorWheel_module_discBadgeTop",
4723
+ pulse: "ColorWheel_module_pulse",
4724
+ discBadgeBottom: "ColorWheel_module_discBadgeBottom"
4725
+ };
4726
+ function usePointerDrag(ref, onMove, onEnd, onDraggingChange) {
4727
+ const onMoveRef = useRef(onMove);
4728
+ onMoveRef.current = onMove;
4729
+ const onEndRef = useRef(onEnd);
4730
+ onEndRef.current = onEnd;
4731
+ const onDraggingChangeRef = useRef(onDraggingChange);
4732
+ onDraggingChangeRef.current = onDraggingChange;
4733
+ useEffect(() => {
4734
+ const el = ref.current;
4735
+ if (!el) return;
4736
+ function pointerPos(e) {
4737
+ return { x: e.clientX, y: e.clientY };
4738
+ }
4739
+ function move(e) {
4740
+ onMoveRef.current(pointerPos(e));
4741
+ }
4742
+ function up() {
4743
+ onDraggingChangeRef.current?.(false);
4744
+ window.removeEventListener("pointermove", move);
4745
+ window.removeEventListener("pointerup", up);
4746
+ onEndRef.current?.();
4747
+ }
4748
+ function down(e) {
4749
+ const pe = e;
4750
+ pe.preventDefault();
4751
+ pe.stopPropagation();
4752
+ onDraggingChangeRef.current?.(true);
4753
+ onMoveRef.current(pointerPos(pe));
4754
+ window.addEventListener("pointermove", move);
4755
+ window.addEventListener("pointerup", up);
4756
+ }
4757
+ el.addEventListener("pointerdown", down);
4758
+ return () => {
4759
+ el.removeEventListener("pointerdown", down);
4760
+ window.removeEventListener("pointermove", move);
4761
+ window.removeEventListener("pointerup", up);
4762
+ };
4763
+ }, [ref]);
4764
+ }
4765
+ function useUnwrappedAngle(targetDeg) {
4766
+ const continuousRef = useRef(targetDeg);
4767
+ const targetMod = (targetDeg % 360 + 360) % 360;
4768
+ const currentMod = (continuousRef.current % 360 + 360) % 360;
4769
+ let delta = targetMod - currentMod;
4770
+ if (delta > 180) delta -= 360;
4771
+ else if (delta < -180) delta += 360;
4772
+ continuousRef.current += delta;
4773
+ return continuousRef.current;
4774
+ }
4775
+
4776
+ // src/components/ColorWheel/colorMath.ts
4777
+ function hsvToRgb(h, s, v) {
4778
+ s /= 100;
4779
+ v /= 100;
4780
+ const c = v * s;
4781
+ const x = c * (1 - Math.abs(h / 60 % 2 - 1));
4782
+ const m = v - c;
4783
+ let r, g, b;
4784
+ if (h < 60) {
4785
+ r = c;
4786
+ g = x;
4787
+ b = 0;
4788
+ } else if (h < 120) {
4789
+ r = x;
4790
+ g = c;
4791
+ b = 0;
4792
+ } else if (h < 180) {
4793
+ r = 0;
4794
+ g = c;
4795
+ b = x;
4796
+ } else if (h < 240) {
4797
+ r = 0;
4798
+ g = x;
4799
+ b = c;
4800
+ } else if (h < 300) {
4801
+ r = x;
4802
+ g = 0;
4803
+ b = c;
4804
+ } else {
4805
+ r = c;
4806
+ g = 0;
4807
+ b = x;
4808
+ }
4809
+ return {
4810
+ r: Math.round((r + m) * 255),
4811
+ g: Math.round((g + m) * 255),
4812
+ b: Math.round((b + m) * 255)
4813
+ };
4814
+ }
4815
+ function rgbToHsv(r, g, b) {
4816
+ r /= 255;
4817
+ g /= 255;
4818
+ b /= 255;
4819
+ const max = Math.max(r, g, b);
4820
+ const min = Math.min(r, g, b);
4821
+ const d = max - min;
4822
+ let h = 0;
4823
+ if (d !== 0) {
4824
+ if (max === r) h = (g - b) / d % 6;
4825
+ else if (max === g) h = (b - r) / d + 2;
4826
+ else h = (r - g) / d + 4;
4827
+ h *= 60;
4828
+ if (h < 0) h += 360;
4829
+ }
4830
+ const s = max === 0 ? 0 : d / max;
4831
+ return { h, s: s * 100, v: max * 100 };
4832
+ }
4833
+ function toHexByte(n) {
4834
+ const h = Math.max(0, Math.min(255, Math.round(n))).toString(16);
4835
+ return h.length === 1 ? "0" + h : h;
4836
+ }
4837
+ function rgbToHex(c) {
4838
+ return ("#" + toHexByte(c.r) + toHexByte(c.g) + toHexByte(c.b)).toUpperCase();
4839
+ }
4840
+ function hsvaToHex(hsv, a) {
4841
+ const rgb = hsvToRgb(hsv.h, hsv.s, hsv.v);
4842
+ let hex = rgbToHex(rgb);
4843
+ if (a < 1) hex += toHexByte(Math.round(a * 255));
4844
+ return hex;
4845
+ }
4846
+ function hexToHsva(input) {
4847
+ let clean = input.trim().replace(/^#/, "");
4848
+ if (/^[0-9a-fA-F]{3}$/.test(clean)) {
4849
+ clean = clean.split("").map((ch) => ch + ch).join("");
4850
+ }
4851
+ if (!/^[0-9a-fA-F]{6}$/.test(clean) && !/^[0-9a-fA-F]{8}$/.test(clean)) return null;
4852
+ const r = parseInt(clean.slice(0, 2), 16);
4853
+ const g = parseInt(clean.slice(2, 4), 16);
4854
+ const b = parseInt(clean.slice(4, 6), 16);
4855
+ const a = clean.length === 8 ? parseInt(clean.slice(6, 8), 16) / 255 : 1;
4856
+ return { hsv: rgbToHsv(r, g, b), a };
4857
+ }
4858
+ function clamp2(v, min, max) {
4859
+ return Math.min(max, Math.max(min, v));
4860
+ }
4861
+ function round2(n) {
4862
+ return Math.round(n * 100) / 100;
4863
+ }
4864
+ function angleDistance(a, b) {
4865
+ const d = Math.abs(a - b) % 360;
4866
+ return d > 180 ? 360 - d : d;
4867
+ }
4868
+ function relativeLuminance(c) {
4869
+ return (0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b) / 255;
4870
+ }
4871
+ var RING_SPECTRUM = "conic-gradient(from 180deg, hsl(0 100% 50%) 0%, hsl(60 100% 50%) 16.667%, hsl(120 100% 50%) 33.333%, hsl(180 100% 50%) 50%, hsl(240 100% 50%) 66.667%, hsl(300 100% 50%) 83.333%, hsl(360 100% 50%) 100%)";
4872
+ var RING_INNER_FRAC = 0.3382;
4873
+ var RING_OUTER_FRAC = 0.5;
4874
+ var ARC_A0 = 30;
4875
+ var ARC_A1 = 150;
4876
+ var ARC_HANDLE_R_FRAC = 152 / 380;
4877
+ var MODES_HSV = ["h", "s", "v"];
4878
+ var MODES_HSVA = ["h", "s", "v", "a"];
4879
+ function ringGradient(mode, hsv) {
4880
+ if (mode === "s") {
4881
+ const grey = rgbToHex(hsvToRgb(hsv.h, 0, hsv.v));
4882
+ const full = rgbToHex(hsvToRgb(hsv.h, 100, hsv.v));
4883
+ return `conic-gradient(from 180deg, ${grey} 0deg, ${full} 360deg)`;
4884
+ }
4885
+ if (mode === "v") {
4886
+ const bright = rgbToHex(hsvToRgb(hsv.h, hsv.s, 100));
4887
+ return `conic-gradient(from 180deg, #000000 0deg, ${bright} 360deg)`;
4888
+ }
4889
+ if (mode === "a") {
4890
+ const full = rgbToHex(hsvToRgb(hsv.h, hsv.s, hsv.v));
4891
+ return `conic-gradient(from 180deg, transparent 0deg, ${full} 360deg)`;
4892
+ }
4893
+ return RING_SPECTRUM;
4894
+ }
4895
+ var EMPTY_FAVORITES = [];
4896
+ function ColorWheel({
4897
+ value,
4898
+ onChange,
4899
+ favorites = EMPTY_FAVORITES,
4900
+ onFavoritesChange,
4901
+ maxFavorites = 5,
4902
+ showAlphaControl = true,
4903
+ alphaMode = "arc",
4904
+ theme = "system",
4905
+ size = 1,
4906
+ accent,
4907
+ className
4908
+ }) {
4909
+ const ringIsFourWay = showAlphaControl && alphaMode === "ring";
4910
+ const arcVisible = showAlphaControl && alphaMode === "arc";
4911
+ const modes = ringIsFourWay ? MODES_HSVA : MODES_HSV;
4912
+ const parsed = useMemo(() => hexToHsva(value), [value]);
4913
+ const [hsv, setHsv] = useState(() => parsed?.hsv ?? { h: 0, s: 0, v: 100 });
4914
+ const [alpha, setAlpha] = useState(() => parsed?.a ?? 1);
4915
+ const [mode, setMode] = useState("h");
4916
+ const [dragging, setDragging] = useState(false);
4917
+ const [copied, setCopied] = useState(false);
4918
+ const [pulseFavorite, setPulseFavorite] = useState(false);
4919
+ const [editing, setEditing] = useState(false);
4920
+ const [editValue, setEditValue] = useState("");
4921
+ const [eyedropperSupported, setEyedropperSupported] = useState(false);
4922
+ const accentVars = accent ? accentToCssVars(deriveAccent(accent), "colorwheel") : {};
4923
+ const lastEmitted = useRef(value);
4924
+ useEffect(() => {
4925
+ if (value === lastEmitted.current) return;
4926
+ const next = hexToHsva(value);
4927
+ if (next) {
4928
+ setHsv(next.hsv);
4929
+ setAlpha(next.a);
4930
+ }
4931
+ lastEmitted.current = value;
4932
+ }, [value]);
4933
+ useEffect(() => {
4934
+ setEyedropperSupported(typeof window !== "undefined" && "EyeDropper" in window);
4935
+ }, []);
4936
+ useEffect(() => {
4937
+ if (!ringIsFourWay && mode === "a") setMode("h");
4938
+ }, [ringIsFourWay, mode]);
4939
+ const stageRef = useRef(null);
4940
+ const alphaArcRef = useRef(null);
4941
+ const modeToggleRef = useRef(null);
4942
+ const hexInputRef = useRef(null);
4943
+ function commit(nextHsv, nextAlpha) {
4944
+ setHsv(nextHsv);
4945
+ setAlpha(nextAlpha);
4946
+ const hex = hsvaToHex(nextHsv, nextAlpha);
4947
+ lastEmitted.current = hex;
4948
+ onChange(hex);
4949
+ }
4950
+ const rgb = hsvToRgb(hsv.h, hsv.s, hsv.v);
4951
+ const solidHex = rgbToHex(rgb);
4952
+ const hexString = hsvaToHex(hsv, alpha);
4953
+ const luminance = relativeLuminance(rgb);
4954
+ const isLight = luminance > 0.58;
4955
+ const discText = isLight ? "#1A1913" : "#FFFFFF";
4956
+ const badgeBg = isLight ? "rgba(0,0,0,0.02)" : "rgba(255,255,255,0.03)";
4957
+ const badgeGrooveDark = isLight ? "rgba(0,0,0,0.2)" : "rgba(0,0,0,0.32)";
4958
+ const badgeGrooveLight = isLight ? "rgba(255,255,255,0.35)" : "rgba(255,255,255,0.12)";
4959
+ const badgeIcon = isLight ? "rgba(0,0,0,0.72)" : "rgba(255,255,255,0.88)";
4960
+ const badgeShadow = {
4961
+ background: badgeBg,
4962
+ color: badgeIcon,
4963
+ boxShadow: `inset 0 1px 1px ${badgeGrooveDark}, inset 0 -1px 1px ${badgeGrooveLight}`
4964
+ };
4965
+ const ringLogicalAngle = mode === "h" ? hsv.h : mode === "a" ? alpha * 360 : (mode === "s" ? hsv.s : hsv.v) / 100 * 360;
4966
+ const ringAngleFromTopDeg = useUnwrappedAngle(180 + ringLogicalAngle);
4967
+ const arcLogicalAngle = ARC_A1 - alpha * (ARC_A1 - ARC_A0);
4968
+ const arcAngleFromTop = (90 + arcLogicalAngle) * (Math.PI / 180);
4969
+ const arcHandleR = ARC_HANDLE_R_FRAC * 380;
4970
+ const arcHandleDx = arcHandleR * Math.sin(arcAngleFromTop);
4971
+ const arcHandleDy = -arcHandleR * Math.cos(arcAngleFromTop);
4972
+ function applyRingAngle(angle) {
4973
+ if (mode === "h") commit({ ...hsv, h: angle }, alpha);
4974
+ else if (mode === "s") commit({ ...hsv, s: angle / 360 * 100 }, alpha);
4975
+ else if (mode === "a") commit(hsv, angle / 360);
4976
+ else commit({ ...hsv, v: angle / 360 * 100 }, alpha);
4977
+ }
4978
+ const dragPrevAngleRef = useRef(null);
4979
+ const dragAccumRef = useRef(0);
4980
+ usePointerDrag(
4981
+ stageRef,
4982
+ (pos) => {
4983
+ const rect = stageRef.current.getBoundingClientRect();
4984
+ const cx = rect.left + rect.width / 2;
4985
+ const cy = rect.top + rect.height / 2;
4986
+ const dx = pos.x - cx;
4987
+ const dy = pos.y - cy;
4988
+ const dist = Math.hypot(dx, dy);
4989
+ if (dist < rect.width * RING_INNER_FRAC || dist > rect.width * RING_OUTER_FRAC) return;
4990
+ let angle = Math.atan2(dy, dx) * (180 / Math.PI) - 90;
4991
+ angle = (angle % 360 + 360) % 360;
4992
+ if (mode === "h") {
4993
+ applyRingAngle(angle);
4994
+ return;
4995
+ }
4996
+ if (dragPrevAngleRef.current === null) {
4997
+ dragAccumRef.current = angle;
4998
+ } else {
4999
+ let delta = angle - dragPrevAngleRef.current;
5000
+ if (delta > 180) delta -= 360;
5001
+ else if (delta < -180) delta += 360;
5002
+ dragAccumRef.current = clamp2(dragAccumRef.current + delta, 0, 360);
5003
+ }
5004
+ dragPrevAngleRef.current = angle;
5005
+ applyRingAngle(dragAccumRef.current);
5006
+ },
5007
+ void 0,
5008
+ (dragging2) => {
5009
+ if (!dragging2) dragPrevAngleRef.current = null;
5010
+ setDragging(dragging2);
5011
+ }
5012
+ );
5013
+ useEffect(() => {
5014
+ const el = stageRef.current;
5015
+ if (!el) return;
5016
+ function onWheel(e) {
5017
+ const rect = el.getBoundingClientRect();
5018
+ const cx = rect.left + rect.width / 2;
5019
+ const cy = rect.top + rect.height / 2;
5020
+ const dist = Math.hypot(e.clientX - cx, e.clientY - cy);
5021
+ if (dist < rect.width * RING_INNER_FRAC || dist > rect.width * RING_OUTER_FRAC) return;
5022
+ e.preventDefault();
5023
+ const dir = e.deltaY > 0 ? -1 : 1;
5024
+ if (mode === "h") commit({ ...hsv, h: (hsv.h + dir * 4 + 360) % 360 }, alpha);
5025
+ else if (mode === "s") commit({ ...hsv, s: clamp2(hsv.s + dir * 3, 0, 100) }, alpha);
5026
+ else if (mode === "a") commit(hsv, clamp2(round2(alpha + dir * 0.03), 0, 1));
5027
+ else commit({ ...hsv, v: clamp2(hsv.v + dir * 3, 0, 100) }, alpha);
5028
+ }
5029
+ el.addEventListener("wheel", onWheel, { passive: false });
5030
+ return () => el.removeEventListener("wheel", onWheel);
5031
+ }, [mode, hsv, alpha]);
5032
+ usePointerDrag(
5033
+ alphaArcRef,
5034
+ (pos) => {
5035
+ const rect = alphaArcRef.current.getBoundingClientRect();
5036
+ const cx = rect.left + rect.width / 2;
5037
+ const cy = rect.top + rect.height / 2;
5038
+ let angle = Math.atan2(pos.y - cy, pos.x - cx) * (180 / Math.PI);
5039
+ if (angle < 0) angle += 360;
5040
+ if (angle < ARC_A0 || angle > ARC_A1) {
5041
+ angle = angleDistance(angle, ARC_A0) < angleDistance(angle, ARC_A1) ? ARC_A0 : ARC_A1;
5042
+ }
5043
+ commit(hsv, round2((ARC_A1 - angle) / (ARC_A1 - ARC_A0)));
5044
+ },
5045
+ void 0,
5046
+ setDragging
5047
+ );
5048
+ useEffect(() => {
5049
+ const el = alphaArcRef.current;
5050
+ if (!el) return;
5051
+ function onWheel(e) {
5052
+ e.preventDefault();
5053
+ const dir = e.deltaY > 0 ? -1 : 1;
5054
+ commit(hsv, clamp2(round2(alpha + dir * 0.05), 0, 1));
5055
+ }
5056
+ el.addEventListener("wheel", onWheel, { passive: false });
5057
+ return () => el.removeEventListener("wheel", onWheel);
5058
+ }, [hsv, alpha]);
5059
+ useEffect(() => {
5060
+ const el = modeToggleRef.current;
5061
+ if (!el) return;
5062
+ function onWheel(e) {
5063
+ e.preventDefault();
5064
+ const idx = modes.indexOf(mode);
5065
+ const dir = e.deltaY > 0 ? -1 : 1;
5066
+ setMode(modes[clamp2(idx + dir, 0, modes.length - 1)]);
5067
+ }
5068
+ el.addEventListener("wheel", onWheel, { passive: false });
5069
+ return () => el.removeEventListener("wheel", onWheel);
5070
+ }, [mode, modes]);
5071
+ function handleDiscClick() {
5072
+ const done = () => {
5073
+ setCopied(true);
5074
+ setTimeout(() => setCopied(false), 900);
5075
+ };
5076
+ if (navigator.clipboard?.writeText) {
5077
+ navigator.clipboard.writeText(hexString).then(done, done);
5078
+ } else {
5079
+ done();
5080
+ }
5081
+ }
5082
+ function beginEdit(e) {
5083
+ e.stopPropagation();
5084
+ setEditValue(hexString);
5085
+ setEditing(true);
5086
+ requestAnimationFrame(() => {
5087
+ hexInputRef.current?.focus();
5088
+ hexInputRef.current?.setSelectionRange(1, hexString.length);
5089
+ });
5090
+ }
5091
+ function commitEdit(cancelled) {
5092
+ if (!cancelled) {
5093
+ const next = hexToHsva(editValue);
5094
+ if (next) commit(next.hsv, next.a);
5095
+ }
5096
+ setEditing(false);
5097
+ }
5098
+ function pickFromScreen() {
5099
+ const dropper = new window.EyeDropper();
5100
+ dropper.open().then((result) => {
5101
+ const next = hexToHsva(result.sRGBHex);
5102
+ if (next) commit(next.hsv, next.a);
5103
+ }).catch(() => {
5104
+ });
5105
+ }
5106
+ function saveFavorite() {
5107
+ const next = [hexString, ...favorites.filter((h) => h !== hexString)].slice(0, maxFavorites);
5108
+ onFavoritesChange?.(next);
5109
+ setPulseFavorite(false);
5110
+ requestAnimationFrame(() => setPulseFavorite(true));
5111
+ }
5112
+ function applyFavorite(hex) {
5113
+ const next = hexToHsva(hex);
5114
+ if (next) commit(next.hsv, next.a);
5115
+ }
5116
+ function removeFavorite(hex) {
5117
+ onFavoritesChange?.(favorites.filter((h) => h !== hex));
5118
+ }
5119
+ return /* @__PURE__ */ jsxs(
5120
+ "div",
5121
+ {
5122
+ className: [ColorWheel_module_default.root, className].filter(Boolean).join(" "),
5123
+ "data-theme": theme === "system" ? void 0 : theme,
5124
+ "data-dragging": dragging ? "true" : void 0,
5125
+ style: {
5126
+ ...accentVars,
5127
+ ...size !== 1 ? { transform: `scale(${size})`, transformOrigin: "top center" } : void 0
5128
+ },
5129
+ children: [
5130
+ favorites.length > 0 && /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.recents, children: favorites.map((hex, i) => /* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.chipWrap, style: { animationDelay: `${i * 0.02}s` }, children: [
5131
+ /* @__PURE__ */ jsx(
5132
+ "button",
5133
+ {
5134
+ type: "button",
5135
+ className: ColorWheel_module_default.chip,
5136
+ style: { background: hex.length > 7 ? hex.slice(0, 7) : hex },
5137
+ title: hex,
5138
+ "aria-label": `Apply color ${hex}`,
5139
+ onClick: () => applyFavorite(hex)
5140
+ }
5141
+ ),
5142
+ /* @__PURE__ */ jsx(
5143
+ "button",
5144
+ {
5145
+ type: "button",
5146
+ className: ColorWheel_module_default.chipRemove,
5147
+ "aria-label": `Remove ${hex} from favorites`,
5148
+ onClick: (e) => {
5149
+ e.stopPropagation();
5150
+ removeFavorite(hex);
5151
+ },
5152
+ 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" }) })
5153
+ }
5154
+ )
5155
+ ] }, hex + i)) }),
5156
+ /* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.picker, children: [
5157
+ /* @__PURE__ */ jsx(
5158
+ "div",
5159
+ {
5160
+ className: ColorWheel_module_default.glow,
5161
+ style: { background: `radial-gradient(closest-side, ${solidHex}, transparent 72%)` }
5162
+ }
5163
+ ),
5164
+ /* @__PURE__ */ jsxs(
5165
+ "div",
5166
+ {
5167
+ className: ColorWheel_module_default.modeToggle,
5168
+ ref: modeToggleRef,
5169
+ style: { width: modes.length * 28, gridTemplateColumns: `repeat(${modes.length}, 1fr)` },
5170
+ children: [
5171
+ /* @__PURE__ */ jsx(
5172
+ "div",
5173
+ {
5174
+ className: ColorWheel_module_default.modePill,
5175
+ style: {
5176
+ width: `calc(${100 / modes.length}% - 2px)`,
5177
+ transform: `translateX(calc(${modes.indexOf(mode)} * (100% + 1px)))`
5178
+ }
5179
+ }
5180
+ ),
5181
+ modes.map((m) => /* @__PURE__ */ jsx(
5182
+ "button",
5183
+ {
5184
+ type: "button",
5185
+ className: [ColorWheel_module_default.modeButton, mode === m ? ColorWheel_module_default.active : ""].join(" "),
5186
+ onClick: () => setMode(m),
5187
+ children: m.toUpperCase()
5188
+ },
5189
+ m
5190
+ ))
5191
+ ]
5192
+ }
5193
+ ),
5194
+ /* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.stage, ref: stageRef, children: [
5195
+ /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.stageShadow }),
5196
+ /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.ring, style: { background: ringGradient(mode, hsv) } }),
5197
+ /* @__PURE__ */ jsxs("div", { className: ColorWheel_module_default.currentDisc, onClick: handleDiscClick, children: [
5198
+ /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.discFill, style: { background: `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})` } }),
5199
+ !editing && /* @__PURE__ */ jsx("span", { className: [ColorWheel_module_default.currentHex, copied ? ColorWheel_module_default.copied : ""].join(" "), style: { color: discText }, onClick: beginEdit, children: copied ? "Copied" : hexString }),
5200
+ editing && /* @__PURE__ */ jsx(
5201
+ "input",
5202
+ {
5203
+ ref: hexInputRef,
5204
+ className: ColorWheel_module_default.currentHexInput,
5205
+ style: { color: discText },
5206
+ type: "text",
5207
+ inputMode: "text",
5208
+ autoComplete: "off",
5209
+ spellCheck: false,
5210
+ maxLength: 9,
5211
+ value: editValue,
5212
+ onClick: (e) => e.stopPropagation(),
5213
+ onChange: (e) => setEditValue(e.target.value),
5214
+ onKeyDown: (e) => {
5215
+ if (e.key === "Enter") hexInputRef.current?.blur();
5216
+ else if (e.key === "Escape") {
5217
+ commitEdit(true);
5218
+ }
5219
+ },
5220
+ onBlur: () => commitEdit(false)
5221
+ }
5222
+ )
5223
+ ] }),
5224
+ eyedropperSupported && /* @__PURE__ */ jsx(
5225
+ "button",
5226
+ {
5227
+ type: "button",
5228
+ className: [ColorWheel_module_default.discBadge, ColorWheel_module_default.discBadgeBottom].join(" "),
5229
+ style: badgeShadow,
5230
+ "aria-label": "Pick color from screen",
5231
+ onClick: pickFromScreen,
5232
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 32 32", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M27.7,3.3c-1.5-1.5-3.9-1.5-5.4,0L17,8.6l-1.3-1.3c-0.4-0.4-1-0.4-1.4,0s-0.4,1,0,1.4l1.3,1.3L5,20.6c-0.6,0.6-1,1.4-1.1,2.3C3.3,23.4,3,24.2,3,25c0,1.7,1.3,3,3,3c0.8,0,1.6-0.3,2.2-0.9C9,27,9.8,26.6,10.4,26L21,15.4l1.3,1.3c0.2,0.2,0.5,0.3,0.7,0.3s0.5-0.1,0.7-0.3c0.4-0.4,0.4-1,0-1.4L22.4,14l5.3-5.3C29.2,7.2,29.2,4.8,27.7,3.3z M9,24.6c-0.4,0.4-0.8,0.6-1.3,0.5c-0.4,0-0.7,0.2-0.9,0.5C6.7,25.8,6.3,26,6,26c-0.6,0-1-0.4-1-1c0-0.3,0.2-0.7,0.5-0.8c0.3-0.2,0.5-0.5,0.5-0.9c0-0.5,0.2-1,0.5-1.3L17,11.4l2.6,2.6L9,24.6z" }) })
5233
+ }
5234
+ ),
5235
+ /* @__PURE__ */ jsx(
5236
+ "button",
5237
+ {
5238
+ type: "button",
5239
+ className: [ColorWheel_module_default.discBadge, ColorWheel_module_default.discBadgeTop, pulseFavorite ? ColorWheel_module_default.pulse : ""].join(" "),
5240
+ style: badgeShadow,
5241
+ "aria-label": "Save current color to favorites",
5242
+ onClick: saveFavorite,
5243
+ onAnimationEnd: () => setPulseFavorite(false),
5244
+ children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2.2, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M12 5v14M5 12h14" }) })
5245
+ }
5246
+ ),
5247
+ /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.hueHandlePivot, style: { transform: `translate(-50%, -50%) rotate(${ringAngleFromTopDeg}deg)` }, children: /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.hueHandle, style: { background: solidHex } }) })
5248
+ ] }),
5249
+ /* @__PURE__ */ jsxs("div", { style: { display: arcVisible ? "contents" : "none" }, children: [
5250
+ /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.alphaArcShadowWrap, children: /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.alphaArcShadow }) }),
5251
+ /* @__PURE__ */ jsx("div", { className: ColorWheel_module_default.alphaArc, ref: alphaArcRef, children: /* @__PURE__ */ jsx(
5252
+ "div",
5253
+ {
5254
+ className: ColorWheel_module_default.alphaArcFill,
5255
+ style: { background: `conic-gradient(from 90deg, ${solidHex} 30deg, transparent 150deg)` }
5256
+ }
5257
+ ) }),
5258
+ /* @__PURE__ */ jsx("div", { className: [ColorWheel_module_default.alphaArcCap, ColorWheel_module_default.alphaArcCapStart].join(" "), style: { background: solidHex } }),
5259
+ /* @__PURE__ */ jsx("div", { className: [ColorWheel_module_default.alphaArcCap, ColorWheel_module_default.alphaArcCapEnd].join(" ") }),
5260
+ /* @__PURE__ */ jsx(
5261
+ "div",
5262
+ {
5263
+ className: ColorWheel_module_default.alphaArcHandle,
5264
+ style: {
5265
+ transform: `translate(calc(-50% + ${arcHandleDx}px), calc(-50% + ${arcHandleDy}px))`,
5266
+ background: solidHex
5267
+ }
5268
+ }
5269
+ )
5270
+ ] })
5271
+ ] })
5272
+ ]
5273
+ }
5274
+ );
5275
+ }
5276
+
5277
+ export { Badge, Button, ColorPicker, ColorWheel, Highlight, HighlightButton, Input, PageBreak, PageBreakButton, RainCanvas, RichTextEditor, SliderControl, SlidingCounter, Timeline };
4691
5278
  //# sourceMappingURL=index.js.map
4692
5279
  //# sourceMappingURL=index.js.map