@expcat/tigercat-react 2.0.0-rc.2 → 2.0.4

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 (80) hide show
  1. package/dist/{chunk-JTFNGXOC.mjs → chunk-2ENQZECC.mjs} +53 -31
  2. package/dist/{chunk-O5RAMCBV.mjs → chunk-2JYJPNW3.mjs} +1 -1
  3. package/dist/{chunk-POP3TS4Q.mjs → chunk-2WGEHH5A.mjs} +57 -29
  4. package/dist/{chunk-K7MYQISG.mjs → chunk-54HN5BXW.mjs} +10 -4
  5. package/dist/chunk-5CKMYMTS.mjs +292 -0
  6. package/dist/{chunk-Y7K27DVV.mjs → chunk-6H5Y7Y6E.mjs} +42 -28
  7. package/dist/chunk-6MGQAJ62.mjs +203 -0
  8. package/dist/{chunk-TO2URY7X.mjs → chunk-7AFRHC7P.mjs} +90 -61
  9. package/dist/{chunk-MGQWVJHX.mjs → chunk-ALSOPYM5.mjs} +69 -62
  10. package/dist/{chunk-N6JNLJIN.mjs → chunk-BOGOQ44C.mjs} +6 -2
  11. package/dist/{chunk-Q327ESD2.mjs → chunk-BUXHI6UK.mjs} +17 -38
  12. package/dist/{chunk-TORX7SG4.mjs → chunk-CC7IOSNI.mjs} +10 -4
  13. package/dist/{chunk-OVE2ZUJJ.mjs → chunk-D33BIMGK.mjs} +1 -1
  14. package/dist/{chunk-PYDWF4ED.mjs → chunk-D3KP72UC.mjs} +34 -9
  15. package/dist/{chunk-ZEP7I6WB.mjs → chunk-DPWRXXXW.mjs} +16 -8
  16. package/dist/{chunk-44CQTGAN.mjs → chunk-E7OTDBI6.mjs} +2 -2
  17. package/dist/{chunk-DJ4PSDQS.mjs → chunk-FYINJRYN.mjs} +2 -2
  18. package/dist/{chunk-KFPQ6DIH.mjs → chunk-GV4F6X3C.mjs} +29 -25
  19. package/dist/chunk-HKAZXG74.mjs +308 -0
  20. package/dist/{chunk-QWUDJC6K.mjs → chunk-HOYBHB7B.mjs} +38 -17
  21. package/dist/{chunk-IZYFETUS.mjs → chunk-HS6KUPTI.mjs} +2 -2
  22. package/dist/{chunk-EKESN747.mjs → chunk-HSBN5MLS.mjs} +1 -1
  23. package/dist/{chunk-AJJJ6HWC.mjs → chunk-K4GIKSZE.mjs} +1 -1
  24. package/dist/{chunk-2UOGBS3C.mjs → chunk-KP6DEYWB.mjs} +27 -6
  25. package/dist/{chunk-PAN256RW.mjs → chunk-KVCI2346.mjs} +59 -55
  26. package/dist/{chunk-3O2WHF3U.mjs → chunk-NCHUEGUW.mjs} +2 -2
  27. package/dist/{chunk-VD55SSP7.mjs → chunk-PD6Q36OO.mjs} +14 -6
  28. package/dist/{chunk-5RVLBNLI.mjs → chunk-RJPNBYK5.mjs} +4 -4
  29. package/dist/{chunk-HXD7KMRP.mjs → chunk-UCBW5RJN.mjs} +31 -2
  30. package/dist/{chunk-5IHOOP5A.mjs → chunk-UD4DTVJZ.mjs} +64 -79
  31. package/dist/{chunk-A6JNS35U.mjs → chunk-UT5BV2VO.mjs} +2 -2
  32. package/dist/{chunk-K6GJMKJR.mjs → chunk-V6P7ZK6O.mjs} +3 -3
  33. package/dist/{chunk-4XGO3OSE.mjs → chunk-XE4YFBOZ.mjs} +12 -17
  34. package/dist/{chunk-YI7NQWUV.mjs → chunk-YI6YWH66.mjs} +14 -30
  35. package/dist/{chunk-SHCBCM2W.mjs → chunk-YIB6ZXZF.mjs} +142 -105
  36. package/dist/{chunk-SZBYEGKU.mjs → chunk-ZCGIZOMT.mjs} +1 -1
  37. package/dist/{chunk-S7IB6YST.mjs → chunk-ZG56T75O.mjs} +25 -40
  38. package/dist/{chunk-44BPUG24.mjs → chunk-ZH5ZBLAN.mjs} +38 -16
  39. package/dist/components/ActivityFeed.mjs +3 -3
  40. package/dist/components/AreaChart.mjs +1 -1
  41. package/dist/components/AutoComplete.mjs +2 -1
  42. package/dist/components/BarChart.mjs +1 -1
  43. package/dist/components/Cascader.mjs +2 -1
  44. package/dist/components/ColorPicker.mjs +2 -1
  45. package/dist/components/CommentThread.mjs +1 -1
  46. package/dist/components/CropUpload.mjs +4 -4
  47. package/dist/components/DataExport.mjs +3 -3
  48. package/dist/components/DataTableWithToolbar.mjs +6 -6
  49. package/dist/components/DatePicker.mjs +2 -1
  50. package/dist/components/Drawer.mjs +2 -2
  51. package/dist/components/Dropdown.mjs +2 -2
  52. package/dist/components/FormItem.mjs +2 -1
  53. package/dist/components/Image.mjs +5 -5
  54. package/dist/components/ImageCropper.mjs +1 -1
  55. package/dist/components/ImageGroup.mjs +3 -3
  56. package/dist/components/ImagePreview.mjs +2 -2
  57. package/dist/components/LineChart.mjs +1 -1
  58. package/dist/components/Loading.mjs +2 -2
  59. package/dist/components/Mentions.mjs +2 -1
  60. package/dist/components/Menu.mjs +2 -2
  61. package/dist/components/Modal.mjs +2 -2
  62. package/dist/components/NotificationCenter.mjs +3 -3
  63. package/dist/components/Popconfirm.mjs +3 -3
  64. package/dist/components/Popover.mjs +3 -3
  65. package/dist/components/ScatterChart.mjs +1 -1
  66. package/dist/components/Select.mjs +2 -1
  67. package/dist/components/Spotlight.mjs +2 -2
  68. package/dist/components/Table.mjs +3 -2
  69. package/dist/components/TimePicker.mjs +2 -1
  70. package/dist/components/Tooltip.mjs +3 -3
  71. package/dist/components/Tour.mjs +2 -2
  72. package/dist/components/TreeSelect.mjs +2 -1
  73. package/dist/components/Upload.mjs +1 -1
  74. package/dist/components/VirtualTable.mjs +1 -1
  75. package/dist/index.d.mts +1 -1
  76. package/dist/index.mjs +4 -2
  77. package/package.json +2 -2
  78. package/dist/chunk-KVARQQAG.mjs +0 -181
  79. package/dist/chunk-SEWNVIHH.mjs +0 -153
  80. package/dist/chunk-XIVU7TWX.mjs +0 -305
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Image
3
- } from "../chunk-ZEP7I6WB.mjs";
4
- import "../chunk-EKESN747.mjs";
5
- import "../chunk-SZBYEGKU.mjs";
6
- import "../chunk-S7IB6YST.mjs";
7
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-DPWRXXXW.mjs";
4
+ import "../chunk-HSBN5MLS.mjs";
5
+ import "../chunk-ZCGIZOMT.mjs";
6
+ import "../chunk-ZG56T75O.mjs";
7
+ import "../chunk-HKAZXG74.mjs";
8
8
  import "../chunk-YSIXURBW.mjs";
9
9
  import "../chunk-TGXBCKOU.mjs";
10
10
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ImageCropper
3
- } from "../chunk-VD55SSP7.mjs";
3
+ } from "../chunk-PD6Q36OO.mjs";
4
4
  import "../chunk-YSIXURBW.mjs";
5
5
  import "../chunk-TGXBCKOU.mjs";
6
6
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  ImageGroup,
3
3
  ImageGroupContext
4
- } from "../chunk-EKESN747.mjs";
5
- import "../chunk-SZBYEGKU.mjs";
6
- import "../chunk-SEWNVIHH.mjs";
4
+ } from "../chunk-HSBN5MLS.mjs";
5
+ import "../chunk-ZCGIZOMT.mjs";
6
+ import "../chunk-HKAZXG74.mjs";
7
7
  import "../chunk-YSIXURBW.mjs";
8
8
  import "../chunk-TGXBCKOU.mjs";
9
9
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ImagePreview
3
- } from "../chunk-SZBYEGKU.mjs";
4
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-ZCGIZOMT.mjs";
4
+ import "../chunk-HKAZXG74.mjs";
5
5
  import "../chunk-YSIXURBW.mjs";
6
6
  import "../chunk-TGXBCKOU.mjs";
7
7
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  LineChart,
3
3
  LineChart_default
4
- } from "../chunk-3O2WHF3U.mjs";
4
+ } from "../chunk-NCHUEGUW.mjs";
5
5
  import "../chunk-DNOPEJ5I.mjs";
6
6
  import "../chunk-YORCCCQX.mjs";
7
7
  import "../chunk-RQSQXQN6.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Loading
3
- } from "../chunk-AJJJ6HWC.mjs";
4
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-K4GIKSZE.mjs";
4
+ import "../chunk-HKAZXG74.mjs";
5
5
  import "../chunk-YSIXURBW.mjs";
6
6
  import "../chunk-TGXBCKOU.mjs";
7
7
  export {
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  Mentions,
3
3
  Mentions_default
4
- } from "../chunk-Y7K27DVV.mjs";
4
+ } from "../chunk-6H5Y7Y6E.mjs";
5
+ import "../chunk-HKAZXG74.mjs";
5
6
  export {
6
7
  Mentions,
7
8
  Mentions_default as default
@@ -4,8 +4,8 @@ import {
4
4
  MenuItemGroup,
5
5
  SubMenu,
6
6
  useMenuContext
7
- } from "../chunk-Q327ESD2.mjs";
8
- import "../chunk-SEWNVIHH.mjs";
7
+ } from "../chunk-BUXHI6UK.mjs";
8
+ import "../chunk-HKAZXG74.mjs";
9
9
  export {
10
10
  Menu,
11
11
  MenuItem,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Modal
3
- } from "../chunk-K7MYQISG.mjs";
3
+ } from "../chunk-54HN5BXW.mjs";
4
4
  import "../chunk-5TE7KLE5.mjs";
5
5
  import "../chunk-ZJWUBR2X.mjs";
6
- import "../chunk-SEWNVIHH.mjs";
6
+ import "../chunk-HKAZXG74.mjs";
7
7
  import "../chunk-YSIXURBW.mjs";
8
8
  import "../chunk-TGXBCKOU.mjs";
9
9
  export {
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  NotificationCenter,
3
3
  NotificationCenter_default
4
- } from "../chunk-POP3TS4Q.mjs";
4
+ } from "../chunk-2WGEHH5A.mjs";
5
5
  import "../chunk-Z3CRHC5F.mjs";
6
6
  import "../chunk-QJE3MZBO.mjs";
7
7
  import "../chunk-HHIW7V7B.mjs";
8
8
  import "../chunk-Y5X3G2LD.mjs";
9
9
  import "../chunk-5TE7KLE5.mjs";
10
10
  import "../chunk-ZJWUBR2X.mjs";
11
- import "../chunk-AJJJ6HWC.mjs";
12
- import "../chunk-SEWNVIHH.mjs";
11
+ import "../chunk-K4GIKSZE.mjs";
13
12
  import "../chunk-HLS4CHWX.mjs";
14
13
  import "../chunk-IXV5YBCZ.mjs";
14
+ import "../chunk-HKAZXG74.mjs";
15
15
  import "../chunk-YSIXURBW.mjs";
16
16
  import "../chunk-TGXBCKOU.mjs";
17
17
  export {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Popconfirm
3
- } from "../chunk-4XGO3OSE.mjs";
4
- import "../chunk-S7IB6YST.mjs";
5
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-XE4YFBOZ.mjs";
4
+ import "../chunk-ZG56T75O.mjs";
5
+ import "../chunk-HKAZXG74.mjs";
6
6
  export {
7
7
  Popconfirm
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Popover
3
- } from "../chunk-QWUDJC6K.mjs";
4
- import "../chunk-S7IB6YST.mjs";
5
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-HOYBHB7B.mjs";
4
+ import "../chunk-ZG56T75O.mjs";
5
+ import "../chunk-HKAZXG74.mjs";
6
6
  export {
7
7
  Popover
8
8
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ScatterChart,
3
3
  ScatterChart_default
4
- } from "../chunk-44CQTGAN.mjs";
4
+ } from "../chunk-E7OTDBI6.mjs";
5
5
  import "../chunk-DNOPEJ5I.mjs";
6
6
  import "../chunk-YORCCCQX.mjs";
7
7
  import "../chunk-RQSQXQN6.mjs";
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Select
3
- } from "../chunk-PAN256RW.mjs";
3
+ } from "../chunk-KVCI2346.mjs";
4
+ import "../chunk-HKAZXG74.mjs";
4
5
  import "../chunk-YSIXURBW.mjs";
5
6
  import "../chunk-TGXBCKOU.mjs";
6
7
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Spotlight,
3
3
  Spotlight_default
4
- } from "../chunk-O5RAMCBV.mjs";
4
+ } from "../chunk-2JYJPNW3.mjs";
5
5
  import "../chunk-MEFARVQI.mjs";
6
- import "../chunk-SEWNVIHH.mjs";
6
+ import "../chunk-HKAZXG74.mjs";
7
7
  import "../chunk-YSIXURBW.mjs";
8
8
  import "../chunk-TGXBCKOU.mjs";
9
9
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Table
3
- } from "../chunk-N6JNLJIN.mjs";
4
- import "../chunk-PAN256RW.mjs";
3
+ } from "../chunk-BOGOQ44C.mjs";
4
+ import "../chunk-KVCI2346.mjs";
5
5
  import "../chunk-IIWUQK2P.mjs";
6
6
  import "../chunk-AKNWUI7K.mjs";
7
7
  import "../chunk-HHIW7V7B.mjs";
@@ -9,6 +9,7 @@ import "../chunk-W7BC4I2Y.mjs";
9
9
  import "../chunk-EPWAROC2.mjs";
10
10
  import "../chunk-OL3RXYMG.mjs";
11
11
  import "../chunk-MEFARVQI.mjs";
12
+ import "../chunk-HKAZXG74.mjs";
12
13
  import "../chunk-YSIXURBW.mjs";
13
14
  import "../chunk-TGXBCKOU.mjs";
14
15
  export {
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  TimePicker
3
- } from "../chunk-MGQWVJHX.mjs";
3
+ } from "../chunk-ALSOPYM5.mjs";
4
4
  import "../chunk-MEFARVQI.mjs";
5
+ import "../chunk-HKAZXG74.mjs";
5
6
  import "../chunk-YSIXURBW.mjs";
6
7
  import "../chunk-TGXBCKOU.mjs";
7
8
  export {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Tooltip
3
- } from "../chunk-2UOGBS3C.mjs";
4
- import "../chunk-S7IB6YST.mjs";
5
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-KP6DEYWB.mjs";
4
+ import "../chunk-ZG56T75O.mjs";
5
+ import "../chunk-HKAZXG74.mjs";
6
6
  export {
7
7
  Tooltip
8
8
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Tour
3
- } from "../chunk-5RVLBNLI.mjs";
4
- import "../chunk-SEWNVIHH.mjs";
3
+ } from "../chunk-RJPNBYK5.mjs";
5
4
  import "../chunk-FLYJVZED.mjs";
5
+ import "../chunk-HKAZXG74.mjs";
6
6
  import "../chunk-YSIXURBW.mjs";
7
7
  import "../chunk-TGXBCKOU.mjs";
8
8
  export {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  TreeSelect
3
- } from "../chunk-TO2URY7X.mjs";
3
+ } from "../chunk-7AFRHC7P.mjs";
4
+ import "../chunk-HKAZXG74.mjs";
4
5
  import "../chunk-YSIXURBW.mjs";
5
6
  import "../chunk-TGXBCKOU.mjs";
6
7
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Upload
3
- } from "../chunk-HXD7KMRP.mjs";
3
+ } from "../chunk-UCBW5RJN.mjs";
4
4
  import "../chunk-MEFARVQI.mjs";
5
5
  import "../chunk-YSIXURBW.mjs";
6
6
  import "../chunk-TGXBCKOU.mjs";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  VirtualTable,
3
3
  VirtualTable_default
4
- } from "../chunk-KFPQ6DIH.mjs";
4
+ } from "../chunk-GV4F6X3C.mjs";
5
5
  import "../chunk-YSIXURBW.mjs";
6
6
  import "../chunk-TGXBCKOU.mjs";
7
7
  export {
package/dist/index.d.mts CHANGED
@@ -150,6 +150,6 @@ import 'react';
150
150
  * React components for Tigercat UI library
151
151
  */
152
152
 
153
- declare const version = "2.0.0-rc.2";
153
+ declare const version = "2.0.0";
154
154
 
155
155
  export { version };
package/dist/index.mjs CHANGED
@@ -693,6 +693,8 @@ export {
693
693
  getAnchorLinkListClasses,
694
694
  getAnchorTargetElement,
695
695
  getAnchorWrapperClasses,
696
+ getAnchoredOverlayLayoutClasses,
697
+ getAnchoredOverlayTabTarget,
696
698
  getAreaGradientPrefix,
697
699
  getArrowStyles,
698
700
  getAutoCompleteInputClasses,
@@ -1109,7 +1111,6 @@ export {
1109
1111
  getStepsContainerClasses,
1110
1112
  getSubMenuExpandIconClasses,
1111
1113
  getSubMenuTitleClasses,
1112
- getSubmenuPopupZIndex,
1113
1114
  getSunburstGradientPrefix,
1114
1115
  getSvgDefaultAttrs,
1115
1116
  getSwitchClasses,
@@ -1553,7 +1554,6 @@ export {
1553
1554
  popconfirmQuestionIconPath,
1554
1555
  popconfirmSuccessIconPath,
1555
1556
  popconfirmWarningIconPath,
1556
- positionMentionsDropdown,
1557
1557
  prefersReducedMotion,
1558
1558
  prepareUploadFiles,
1559
1559
  prevIconPath,
@@ -1606,6 +1606,7 @@ export {
1606
1606
  rateInactiveColor,
1607
1607
  readFileAsDataUrl,
1608
1608
  redoFormHistory,
1609
+ registerEscapeDismiss,
1609
1610
  registerImageGroupItem,
1610
1611
  removeCssVarsCached,
1611
1612
  renderMarkdownInline,
@@ -1637,6 +1638,7 @@ export {
1637
1638
  resizeCropRect,
1638
1639
  resizePanes,
1639
1640
  resolveAffixTarget,
1641
+ resolveAnchoredOverlayTarget,
1640
1642
  resolveCardPadding,
1641
1643
  resolveCarouselSwipeDirection,
1642
1644
  resolveChartPalette,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expcat/tigercat-react",
3
- "version": "2.0.0-rc.2",
3
+ "version": "2.0.4",
4
4
  "description": "React components for Tigercat UI library",
5
5
  "license": "MIT",
6
6
  "author": "Yizhe Wang",
@@ -782,7 +782,7 @@
782
782
  "access": "public"
783
783
  },
784
784
  "dependencies": {
785
- "@expcat/tigercat-core": "2.0.0-rc.2"
785
+ "@expcat/tigercat-core": "2.0.4"
786
786
  },
787
787
  "devDependencies": {
788
788
  "@types/node": "^26.1.1",
@@ -1,181 +0,0 @@
1
- // src/components/ColorPicker.tsx
2
- import { useState, useMemo, useRef, useEffect } from "react";
3
- import {
4
- colorPickerBaseClasses,
5
- getColorPickerTriggerClasses,
6
- colorPickerPanelClasses,
7
- colorPickerInputClasses,
8
- colorPickerPresetClasses,
9
- hexToRgb,
10
- rgbToHex,
11
- rgbToHsv,
12
- hsvToRgb,
13
- formatColorString,
14
- parseColorInput,
15
- classNames
16
- } from "@expcat/tigercat-core";
17
- import { jsx, jsxs } from "react/jsx-runtime";
18
- var ColorPicker = ({
19
- value = "#2563eb",
20
- disabled = false,
21
- size = "md",
22
- showAlpha = false,
23
- format = "hex",
24
- presets,
25
- className,
26
- onChange
27
- }) => {
28
- const [isOpen, setIsOpen] = useState(false);
29
- const [alpha, setAlpha] = useState(1);
30
- const containerRef = useRef(null);
31
- const rgb = useMemo(() => hexToRgb(value), [value]);
32
- const hsv = useMemo(() => rgbToHsv(rgb.r, rgb.g, rgb.b), [rgb]);
33
- const displayValue = useMemo(
34
- () => formatColorString(rgb.r, rgb.g, rgb.b, format, showAlpha ? alpha : void 0),
35
- [rgb, format, showAlpha, alpha]
36
- );
37
- const swatchColor = showAlpha ? `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})` : value;
38
- const [inputValue, setInputValue] = useState(displayValue);
39
- useEffect(() => {
40
- setInputValue(displayValue);
41
- }, [displayValue]);
42
- function togglePanel() {
43
- if (disabled) return;
44
- setIsOpen((v) => !v);
45
- }
46
- function handleTriggerKeyDown(e) {
47
- if (disabled) return;
48
- if (e.key === "Enter" || e.key === " " || e.key === "Spacebar") {
49
- e.preventDefault();
50
- setIsOpen((v) => !v);
51
- } else if (e.key === "Escape" && isOpen) {
52
- setIsOpen(false);
53
- }
54
- }
55
- function handleHueChange(e) {
56
- const hue = Number(e.target.value);
57
- const { r, g, b } = hsvToRgb(hue, hsv.s, hsv.v);
58
- const hex = rgbToHex(r, g, b);
59
- onChange?.(hex);
60
- }
61
- function handleInputChange(e) {
62
- const val = e.target.value;
63
- setInputValue(val);
64
- const hex = parseColorInput(val);
65
- if (hex) {
66
- onChange?.(hex);
67
- }
68
- }
69
- function handleAlphaChange(e) {
70
- setAlpha(Number(e.target.value) / 100);
71
- }
72
- function handlePresetClick(color) {
73
- onChange?.(color);
74
- }
75
- function handlePresetKeyDown(e, color) {
76
- if (e.key === "Enter" || e.key === " " || e.key === "Spacebar") {
77
- e.preventDefault();
78
- handlePresetClick(color);
79
- }
80
- }
81
- useEffect(() => {
82
- if (!isOpen) return;
83
- function handleClickOutside(e) {
84
- if (containerRef.current && !containerRef.current.contains(e.target)) {
85
- setIsOpen(false);
86
- }
87
- }
88
- document.addEventListener("click", handleClickOutside);
89
- return () => document.removeEventListener("click", handleClickOutside);
90
- }, [isOpen]);
91
- return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: classNames(colorPickerBaseClasses, className), children: [
92
- /* @__PURE__ */ jsx(
93
- "div",
94
- {
95
- className: getColorPickerTriggerClasses(size, disabled),
96
- style: { backgroundColor: swatchColor },
97
- role: "button",
98
- "aria-label": "Pick color",
99
- "aria-haspopup": "dialog",
100
- "aria-expanded": isOpen,
101
- "aria-disabled": disabled || void 0,
102
- tabIndex: disabled ? -1 : 0,
103
- onClick: togglePanel,
104
- onKeyDown: handleTriggerKeyDown
105
- }
106
- ),
107
- isOpen && /* @__PURE__ */ jsxs("div", { className: colorPickerPanelClasses, children: [
108
- /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
109
- /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1", children: "Hue" }),
110
- /* @__PURE__ */ jsx(
111
- "input",
112
- {
113
- type: "range",
114
- min: 0,
115
- max: 360,
116
- value: hsv.h,
117
- className: "w-full h-2 rounded-full cursor-pointer accent-[var(--tiger-primary,#2563eb)]",
118
- "aria-label": "Hue",
119
- onChange: handleHueChange
120
- }
121
- )
122
- ] }),
123
- showAlpha && /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
124
- /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1", children: "Alpha" }),
125
- /* @__PURE__ */ jsx(
126
- "input",
127
- {
128
- type: "range",
129
- min: 0,
130
- max: 100,
131
- value: Math.round(alpha * 100),
132
- className: "w-full h-2 rounded-full cursor-pointer accent-[var(--tiger-primary,#2563eb)]",
133
- "aria-label": "Alpha",
134
- onChange: handleAlphaChange
135
- }
136
- )
137
- ] }),
138
- /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
139
- /* @__PURE__ */ jsx("label", { className: "block text-xs text-[var(--tiger-text-muted,#6b7280)] mb-1 uppercase", children: format }),
140
- /* @__PURE__ */ jsx(
141
- "input",
142
- {
143
- type: "text",
144
- className: colorPickerInputClasses,
145
- value: inputValue,
146
- "aria-label": "Color value",
147
- onChange: handleInputChange
148
- }
149
- )
150
- ] }),
151
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 mb-2", children: [
152
- /* @__PURE__ */ jsx(
153
- "div",
154
- {
155
- className: "w-8 h-8 rounded border border-[var(--tiger-border,#d1d5db)]",
156
- style: { backgroundColor: swatchColor },
157
- "aria-label": "Color preview"
158
- }
159
- ),
160
- /* @__PURE__ */ jsx("span", { className: "text-xs font-mono text-[var(--tiger-text,#111827)]", children: displayValue })
161
- ] }),
162
- presets && presets.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-1", children: presets.map((color) => /* @__PURE__ */ jsx(
163
- "div",
164
- {
165
- className: colorPickerPresetClasses,
166
- style: { backgroundColor: color },
167
- role: "button",
168
- tabIndex: 0,
169
- "aria-label": `Select ${color}`,
170
- onClick: () => handlePresetClick(color),
171
- onKeyDown: (e) => handlePresetKeyDown(e, color)
172
- },
173
- color
174
- )) })
175
- ] })
176
- ] });
177
- };
178
-
179
- export {
180
- ColorPicker
181
- };
@@ -1,153 +0,0 @@
1
- // src/utils/overlay.ts
2
- import { useEffect, useRef, useState, useCallback } from "react";
3
- import { createPortal } from "react-dom";
4
- import {
5
- getFocusTrapNavigation,
6
- getFocusableElements,
7
- isEscapeKey,
8
- isEventOutside,
9
- lockBodyScroll,
10
- isBrowser,
11
- computeFloatingPosition,
12
- autoUpdateFloating
13
- } from "@expcat/tigercat-core";
14
- function useClickOutside({
15
- enabled,
16
- refs,
17
- onOutsideClick,
18
- defer = false
19
- }) {
20
- useEffect(() => {
21
- if (!enabled) return;
22
- const handler = (event) => {
23
- const elements = refs.map((ref) => ref?.current);
24
- if (isEventOutside(event, elements)) {
25
- onOutsideClick();
26
- }
27
- };
28
- const attach = () => document.addEventListener("click", handler);
29
- const detach = () => document.removeEventListener("click", handler);
30
- if (!defer) {
31
- attach();
32
- return () => detach();
33
- }
34
- const timer = window.setTimeout(() => attach(), 0);
35
- return () => {
36
- window.clearTimeout(timer);
37
- detach();
38
- };
39
- }, [enabled, refs, onOutsideClick, defer]);
40
- }
41
- function useEscapeKey({ enabled, onEscape }) {
42
- useEffect(() => {
43
- if (!enabled) return;
44
- const handler = (event) => {
45
- if (event.defaultPrevented) return;
46
- if (!isEscapeKey(event)) return;
47
- onEscape();
48
- };
49
- document.addEventListener("keydown", handler);
50
- return () => document.removeEventListener("keydown", handler);
51
- }, [enabled, onEscape]);
52
- }
53
- function useBodyScrollLock({ enabled }) {
54
- useEffect(() => {
55
- if (!enabled) return;
56
- return lockBodyScroll();
57
- }, [enabled]);
58
- }
59
- function renderBodyPortal(node) {
60
- if (!isBrowser()) return null;
61
- return createPortal(node, document.body);
62
- }
63
- function useFocusTrap({ enabled, containerRef }) {
64
- useEffect(() => {
65
- const container = containerRef.current;
66
- if (!enabled || !container) return;
67
- const handler = (event) => {
68
- const focusables = getFocusableElements(container);
69
- const activeElement = container.ownerDocument?.activeElement ?? document.activeElement;
70
- const nav = getFocusTrapNavigation(event, focusables, activeElement);
71
- if (!nav.shouldHandle || !nav.next) return;
72
- event.preventDefault();
73
- nav.next.focus();
74
- };
75
- container.addEventListener("keydown", handler);
76
- return () => container.removeEventListener("keydown", handler);
77
- }, [enabled, containerRef]);
78
- }
79
- function useFloating(options) {
80
- const {
81
- referenceRef,
82
- floatingRef,
83
- enabled,
84
- placement: initialPlacement = "bottom",
85
- offset: offsetDistance = 8,
86
- arrowRef,
87
- onPlacementChange
88
- } = options;
89
- const [x, setX] = useState(0);
90
- const [y, setY] = useState(0);
91
- const [placement, setPlacement] = useState(initialPlacement);
92
- const [arrowX, setArrowX] = useState(void 0);
93
- const [arrowY, setArrowY] = useState(void 0);
94
- const onPlacementChangeRef = useRef(onPlacementChange);
95
- onPlacementChangeRef.current = onPlacementChange;
96
- const update = useCallback(async () => {
97
- const reference = referenceRef.current;
98
- const floating = floatingRef.current;
99
- if (!reference || !floating) return;
100
- const floatingOptions = {
101
- placement: initialPlacement,
102
- offset: offsetDistance,
103
- flip: true,
104
- shift: true,
105
- arrowElement: arrowRef?.current
106
- };
107
- const result = await computeFloatingPosition(
108
- reference,
109
- floating,
110
- floatingOptions
111
- );
112
- setX(result.x);
113
- setY(result.y);
114
- setPlacement((prev) => {
115
- if (prev !== result.placement) {
116
- onPlacementChangeRef.current?.(result.placement);
117
- return result.placement;
118
- }
119
- return prev;
120
- });
121
- if (result.arrow) {
122
- setArrowX(result.arrow.x);
123
- setArrowY(result.arrow.y);
124
- }
125
- }, [referenceRef, floatingRef, initialPlacement, offsetDistance, arrowRef]);
126
- useEffect(() => {
127
- const reference = referenceRef.current;
128
- const floating = floatingRef.current;
129
- if (!enabled || !reference || !floating) return;
130
- update();
131
- const cleanup = autoUpdateFloating(reference, floating, update);
132
- return () => {
133
- cleanup();
134
- };
135
- }, [enabled, referenceRef, floatingRef, update]);
136
- return {
137
- x,
138
- y,
139
- placement,
140
- arrowX,
141
- arrowY,
142
- update
143
- };
144
- }
145
-
146
- export {
147
- useClickOutside,
148
- useEscapeKey,
149
- useBodyScrollLock,
150
- renderBodyPortal,
151
- useFocusTrap,
152
- useFloating
153
- };