@seekho/ui 0.1.32 → 0.1.34

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/index.js CHANGED
@@ -1,14 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var React8 = require('react');
3
+ var React10 = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
+ var ReactDOM = require('react-dom');
5
6
  var reactHotkeysHook = require('react-hotkeys-hook');
6
7
 
7
8
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
9
 
9
- var React8__default = /*#__PURE__*/_interopDefault(React8);
10
+ var React10__default = /*#__PURE__*/_interopDefault(React10);
11
+ var ReactDOM__default = /*#__PURE__*/_interopDefault(ReactDOM);
10
12
 
11
13
  var __defProp = Object.defineProperty;
14
+ var __defProps = Object.defineProperties;
15
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
16
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
17
  var __hasOwnProp = Object.prototype.hasOwnProperty;
14
18
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
@@ -24,6 +28,7 @@ var __spreadValues = (a, b) => {
24
28
  }
25
29
  return a;
26
30
  };
31
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
27
32
  var __objRest = (source, exclude) => {
28
33
  var target = {};
29
34
  for (var prop in source)
@@ -36,9 +41,9 @@ var __objRest = (source, exclude) => {
36
41
  }
37
42
  return target;
38
43
  };
39
- var AccordionContext = React8.createContext(null);
44
+ var AccordionContext = React10.createContext(null);
40
45
  var useAccordion = () => {
41
- const ctx = React8.useContext(AccordionContext);
46
+ const ctx = React10.useContext(AccordionContext);
42
47
  if (!ctx)
43
48
  throw new Error(
44
49
  "AccordionSummary / AccordionDetails must be used inside <Accordion>"
@@ -54,7 +59,7 @@ var Accordion = ({
54
59
  variant = "outlined",
55
60
  className
56
61
  }) => {
57
- const [internalExpanded, setInternalExpanded] = React8.useState(defaultExpanded);
62
+ const [internalExpanded, setInternalExpanded] = React10.useState(defaultExpanded);
58
63
  const isControlled = controlledExpanded !== void 0;
59
64
  const isExpanded = isControlled ? controlledExpanded : internalExpanded;
60
65
  const handleToggle = () => {
@@ -156,6 +161,62 @@ var AccordionDetails = ({
156
161
  }
157
162
  );
158
163
  };
164
+ var typeMap = {
165
+ success: "bg-green-100 text-green-500",
166
+ error: "bg-red-100 text-red-500",
167
+ warning: "bg-orange-100 text-orange-500",
168
+ default: "bg-gray-100 text-gray-500"
169
+ };
170
+ var Chip = ({
171
+ label,
172
+ type = "default",
173
+ style,
174
+ deleteIcon,
175
+ disabled = false,
176
+ className = "",
177
+ onClick,
178
+ onDelete
179
+ }) => {
180
+ var _a;
181
+ const typeClass = (_a = typeMap[type]) != null ? _a : typeMap.default;
182
+ const cursorClass = disabled ? "opacity-50 cursor-not-allowed" : onClick ? "cursor-pointer" : "cursor-default";
183
+ return /* @__PURE__ */ jsxRuntime.jsxs(
184
+ "div",
185
+ {
186
+ role: onClick ? "button" : void 0,
187
+ tabIndex: onClick && !disabled ? 0 : void 0,
188
+ style,
189
+ onClick: !disabled && onClick ? onClick : void 0,
190
+ className: `inline-flex items-center gap-1 rounded-full w-fit px-3 py-[6px] text-[12px] capitalize ${typeClass} ${cursorClass} ${className}`,
191
+ children: [
192
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "leading-none", children: label }),
193
+ onDelete && /* @__PURE__ */ jsxRuntime.jsx(
194
+ "span",
195
+ {
196
+ role: "button",
197
+ tabIndex: disabled ? -1 : 0,
198
+ onClick: (e) => {
199
+ e.stopPropagation();
200
+ if (!disabled) onDelete(e);
201
+ },
202
+ className: "flex items-center cursor-pointer ml-0.5 opacity-60 hover:opacity-100",
203
+ children: deleteIcon != null ? deleteIcon : /* @__PURE__ */ jsxRuntime.jsx(
204
+ "svg",
205
+ {
206
+ xmlns: "http://www.w3.org/2000/svg",
207
+ width: "16",
208
+ height: "16",
209
+ viewBox: "0 0 24 24",
210
+ fill: "currentColor",
211
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
212
+ }
213
+ )
214
+ }
215
+ )
216
+ ]
217
+ }
218
+ );
219
+ };
159
220
  function AutoComplete({
160
221
  label,
161
222
  value,
@@ -170,14 +231,14 @@ function AutoComplete({
170
231
  onChange,
171
232
  onInputChange
172
233
  }) {
173
- const inputId = React8.useId();
174
- const containerRef = React8.useRef(null);
175
- const listRef = React8.useRef(null);
176
- const [open, setOpen] = React8.useState(false);
177
- const [inputValue, setInputValue] = React8.useState(
234
+ const inputId = React10.useId();
235
+ const containerRef = React10.useRef(null);
236
+ const listRef = React10.useRef(null);
237
+ const [open, setOpen] = React10.useState(false);
238
+ const [inputValue, setInputValue] = React10.useState(
178
239
  value ? getOptionLabel(value) : ""
179
240
  );
180
- const [highlightedIndex, setHighlightedIndex] = React8.useState(-1);
241
+ const [highlightedIndex, setHighlightedIndex] = React10.useState(-1);
181
242
  const filteredOptions = options.filter(
182
243
  (option) => getOptionLabel(option).toLowerCase().includes(inputValue.toLowerCase())
183
244
  );
@@ -216,10 +277,10 @@ function AutoComplete({
216
277
  if (!value) return false;
217
278
  return isOptionEqualToValue ? isOptionEqualToValue(option, value) : getOptionLabel(option) === getOptionLabel(value);
218
279
  };
219
- React8.useEffect(() => {
280
+ React10.useEffect(() => {
220
281
  setInputValue(value ? getOptionLabel(value) : "");
221
282
  }, [value]);
222
- React8.useEffect(() => {
283
+ React10.useEffect(() => {
223
284
  const handleClickOutside = (e) => {
224
285
  if (containerRef.current && !containerRef.current.contains(e.target)) {
225
286
  setOpen(false);
@@ -396,7 +457,7 @@ function AutoComplete({
396
457
  isSelected({ option }) ? "font-semibold" : ""
397
458
  ].join(" ")
398
459
  };
399
- return renderOption ? /* @__PURE__ */ jsxRuntime.jsx(React8__default.default.Fragment, { children: renderOption(optionProps, option) }, idx) : /* @__PURE__ */ jsxRuntime.jsx(
460
+ return renderOption ? /* @__PURE__ */ jsxRuntime.jsx(React10__default.default.Fragment, { children: renderOption(optionProps, option) }, idx) : /* @__PURE__ */ jsxRuntime.jsx(
400
461
  "li",
401
462
  {
402
463
  onMouseDown: () => handleSelect({ option }),
@@ -639,7 +700,7 @@ var CustomAnchor = ({
639
700
  }
640
701
  );
641
702
  };
642
- var CustomInput = React8__default.default.forwardRef(
703
+ var CustomInput = React10__default.default.forwardRef(
643
704
  (_a, ref) => {
644
705
  var _b = _a, { label: _label, error, className, type } = _b, props = __objRest(_b, ["label", "error", "className", "type"]);
645
706
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -680,13 +741,13 @@ var Drawer = ({
680
741
  className,
681
742
  onClose
682
743
  }) => {
683
- React8.useEffect(() => {
744
+ React10.useEffect(() => {
684
745
  document.body.style.overflow = open ? "hidden" : "";
685
746
  return () => {
686
747
  document.body.style.overflow = "";
687
748
  };
688
749
  }, [open]);
689
- React8.useEffect(() => {
750
+ React10.useEffect(() => {
690
751
  const handleKeyDown = (e) => {
691
752
  if (e.key === "Escape" && open) onClose();
692
753
  };
@@ -819,6 +880,123 @@ var FilterDrawer = ({
819
880
  }
820
881
  );
821
882
  };
883
+ var GAP = 4;
884
+ var PAD = 6;
885
+ function reposition(menu, anchorEl, align) {
886
+ const rect = anchorEl.getBoundingClientRect();
887
+ const mw = menu.offsetWidth;
888
+ const mh = menu.offsetHeight;
889
+ const vw = window.innerWidth;
890
+ const vh = window.innerHeight;
891
+ let top = rect.bottom + GAP + mh > vh - PAD ? Math.max(PAD, rect.top - mh - GAP) : rect.bottom + GAP;
892
+ let left = align === "right" ? rect.right - mw : rect.left;
893
+ left = Math.max(PAD, Math.min(left, vw - mw - PAD));
894
+ menu.style.top = `${top}px`;
895
+ menu.style.left = `${left}px`;
896
+ menu.style.minWidth = `${rect.width}px`;
897
+ menu.style.opacity = "1";
898
+ }
899
+ var Menu = ({
900
+ anchorEl,
901
+ open,
902
+ onClose,
903
+ children,
904
+ align = "left",
905
+ className = ""
906
+ }) => {
907
+ const menuRef = React10.useRef(null);
908
+ const onCloseRef = React10.useRef(onClose);
909
+ React10.useEffect(() => {
910
+ onCloseRef.current = onClose;
911
+ });
912
+ React10.useEffect(() => {
913
+ if (!open || !anchorEl) return;
914
+ const id = requestAnimationFrame(() => {
915
+ if (menuRef.current) reposition(menuRef.current, anchorEl, align);
916
+ });
917
+ return () => cancelAnimationFrame(id);
918
+ }, [open, anchorEl, align]);
919
+ React10.useEffect(() => {
920
+ if (!open || !anchorEl) return;
921
+ const update = () => {
922
+ if (menuRef.current) reposition(menuRef.current, anchorEl, align);
923
+ };
924
+ window.addEventListener("scroll", update, true);
925
+ window.addEventListener("resize", update);
926
+ return () => {
927
+ window.removeEventListener("scroll", update, true);
928
+ window.removeEventListener("resize", update);
929
+ };
930
+ }, [open, anchorEl, align]);
931
+ React10.useEffect(() => {
932
+ if (!open) return;
933
+ const handleKey = (e) => {
934
+ if (e.key === "Escape") onCloseRef.current();
935
+ };
936
+ document.addEventListener("keydown", handleKey);
937
+ return () => document.removeEventListener("keydown", handleKey);
938
+ }, [open]);
939
+ React10.useEffect(() => {
940
+ if (!open) return;
941
+ const handleMouseDown = (e) => {
942
+ var _a;
943
+ if ((anchorEl == null ? void 0 : anchorEl.contains(e.target)) || ((_a = menuRef.current) == null ? void 0 : _a.contains(e.target)))
944
+ return;
945
+ onCloseRef.current();
946
+ };
947
+ document.addEventListener("mousedown", handleMouseDown);
948
+ return () => document.removeEventListener("mousedown", handleMouseDown);
949
+ }, [open, anchorEl]);
950
+ if (!open) return null;
951
+ return ReactDOM__default.default.createPortal(
952
+ /* @__PURE__ */ jsxRuntime.jsx(
953
+ "div",
954
+ {
955
+ ref: menuRef,
956
+ role: "menu",
957
+ style: {
958
+ position: "fixed",
959
+ top: -9999,
960
+ left: -9999,
961
+ opacity: 0,
962
+ zIndex: 9999,
963
+ transition: "opacity 100ms ease"
964
+ },
965
+ className: `bg-white rounded shadow-lg border border-gray-100 py-1 max-w-[calc(100vw-12px)] ${className}`,
966
+ children
967
+ }
968
+ ),
969
+ document.body
970
+ );
971
+ };
972
+ var MenuItem = ({
973
+ onClick,
974
+ children,
975
+ disabled = false,
976
+ selected = false,
977
+ icon,
978
+ className = ""
979
+ }) => {
980
+ return /* @__PURE__ */ jsxRuntime.jsxs(
981
+ "div",
982
+ {
983
+ role: "menuitem",
984
+ "aria-disabled": disabled,
985
+ onClick: disabled ? void 0 : onClick,
986
+ className: [
987
+ "px-3 py-2 flex gap-x-3 items-center text-[14px] tracking-wide min-w-0 w-full",
988
+ disabled ? "opacity-40 cursor-not-allowed" : "cursor-pointer hover:bg-gray-50",
989
+ selected ? "bg-gray-100 font-medium" : "",
990
+ className
991
+ ].filter(Boolean).join(" "),
992
+ children: [
993
+ icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex items-center shrink-0", children: icon }),
994
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 break-words", children })
995
+ ]
996
+ }
997
+ );
998
+ };
999
+ var MenuDivider = () => /* @__PURE__ */ jsxRuntime.jsx("hr", { className: "my-1 border-gray-100" });
822
1000
 
823
1001
  // src/utils/modalStack.ts
824
1002
  var stack = [];
@@ -846,8 +1024,8 @@ function Modal({
846
1024
  handleConfirmation,
847
1025
  handleConfirmationBtnText = "Confirm"
848
1026
  }) {
849
- const modalId = React8.useId();
850
- React8.useEffect(() => {
1027
+ const modalId = React10.useId();
1028
+ React10.useEffect(() => {
851
1029
  if (show) handlePushModal({ id: modalId });
852
1030
  return () => handlePopModal({ id: modalId });
853
1031
  }, [show, modalId]);
@@ -1081,9 +1259,9 @@ var MonthYearPicker = ({
1081
1259
  triggerClassName,
1082
1260
  dropdownClassName
1083
1261
  }) => {
1084
- const [isOpen, setIsOpen] = React8.useState(false);
1085
- const [pickerYear, setPickerYear] = React8.useState(year);
1086
- const ref = React8.useRef(null);
1262
+ const [isOpen, setIsOpen] = React10.useState(false);
1263
+ const [pickerYear, setPickerYear] = React10.useState(year);
1264
+ const ref = React10.useRef(null);
1087
1265
  const now = /* @__PURE__ */ new Date();
1088
1266
  const currentMonth = now.getMonth() + 1;
1089
1267
  const currentYear = now.getFullYear();
@@ -1116,10 +1294,10 @@ var MonthYearPicker = ({
1116
1294
  if (maxDate && pickerYear >= maxDate.year) return true;
1117
1295
  return false;
1118
1296
  };
1119
- React8.useEffect(() => {
1297
+ React10.useEffect(() => {
1120
1298
  setPickerYear(year);
1121
1299
  }, [year]);
1122
- React8.useEffect(() => {
1300
+ React10.useEffect(() => {
1123
1301
  const handleClickOutside = (e) => {
1124
1302
  if (ref.current && !ref.current.contains(e.target)) {
1125
1303
  setIsOpen(false);
@@ -1694,6 +1872,228 @@ var StagingAlert = ({
1694
1872
  ] })
1695
1873
  ] });
1696
1874
  };
1875
+ var sizeStyles = {
1876
+ small: { padding: "4px 10px", fontSize: "13px" },
1877
+ medium: { padding: "7px 14px", fontSize: "16px" },
1878
+ large: { padding: "10px 16px", fontSize: "16px" }
1879
+ };
1880
+ var Select = ({
1881
+ value,
1882
+ onChange,
1883
+ children,
1884
+ disabled = false,
1885
+ placeholder = "Select...",
1886
+ size = "medium",
1887
+ error = false,
1888
+ className = ""
1889
+ }) => {
1890
+ const [isOpen, setIsOpen] = React10.useState(false);
1891
+ const [dropdownStyle, setDropdownStyle] = React10.useState({});
1892
+ const [focusedIndex, setFocusedIndex] = React10.useState(-1);
1893
+ const triggerRef = React10.useRef(null);
1894
+ const dropdownRef = React10.useRef(null);
1895
+ const options = React10__default.default.Children.toArray(children).filter(Boolean).map((child) => {
1896
+ var _a, _b, _c, _d, _e;
1897
+ const c = child;
1898
+ return {
1899
+ value: (_b = (_a = c.props) == null ? void 0 : _a.value) != null ? _b : "",
1900
+ label: (_c = c.props) == null ? void 0 : _c.children,
1901
+ disabled: (_e = (_d = c.props) == null ? void 0 : _d.disabled) != null ? _e : false
1902
+ };
1903
+ });
1904
+ const selectedOption = options.find(
1905
+ (opt) => String(opt.value) === String(value)
1906
+ );
1907
+ const computePosition = React10.useCallback(() => {
1908
+ if (!triggerRef.current) return;
1909
+ const rect = triggerRef.current.getBoundingClientRect();
1910
+ const dropdownHeight = Math.min(options.length * 40, 240);
1911
+ const spaceBelow = window.innerHeight - rect.bottom;
1912
+ const openAbove = spaceBelow < dropdownHeight + 8 && rect.top > dropdownHeight;
1913
+ setDropdownStyle(__spreadProps(__spreadValues({
1914
+ position: "fixed"
1915
+ }, openAbove ? { bottom: window.innerHeight - rect.top + 2 } : { top: rect.bottom + 2 }), {
1916
+ left: rect.left,
1917
+ width: rect.width,
1918
+ zIndex: 9999
1919
+ }));
1920
+ }, [options.length]);
1921
+ React10.useEffect(() => {
1922
+ const handleClickOutside = (e) => {
1923
+ if (triggerRef.current && !triggerRef.current.contains(e.target) && (!dropdownRef.current || !dropdownRef.current.contains(e.target))) {
1924
+ setIsOpen(false);
1925
+ setFocusedIndex(-1);
1926
+ }
1927
+ };
1928
+ document.addEventListener("mousedown", handleClickOutside);
1929
+ return () => document.removeEventListener("mousedown", handleClickOutside);
1930
+ }, []);
1931
+ React10.useEffect(() => {
1932
+ if (!isOpen) return;
1933
+ const handleKeyDown = (e) => {
1934
+ if (e.key === "Escape") {
1935
+ setIsOpen(false);
1936
+ setFocusedIndex(-1);
1937
+ } else if (e.key === "ArrowDown") {
1938
+ e.preventDefault();
1939
+ setFocusedIndex((prev) => {
1940
+ var _a;
1941
+ let next = prev + 1;
1942
+ while (next < options.length && ((_a = options[next]) == null ? void 0 : _a.disabled)) next++;
1943
+ return next < options.length ? next : prev;
1944
+ });
1945
+ } else if (e.key === "ArrowUp") {
1946
+ e.preventDefault();
1947
+ setFocusedIndex((prev) => {
1948
+ var _a;
1949
+ let next = prev - 1;
1950
+ while (next >= 0 && ((_a = options[next]) == null ? void 0 : _a.disabled)) next--;
1951
+ return next >= 0 ? next : prev;
1952
+ });
1953
+ } else if (e.key === "Enter" && focusedIndex >= 0) {
1954
+ const opt = options[focusedIndex];
1955
+ if (opt && !opt.disabled) {
1956
+ onChange({ target: { value: opt.value } });
1957
+ setIsOpen(false);
1958
+ setFocusedIndex(-1);
1959
+ }
1960
+ }
1961
+ };
1962
+ document.addEventListener("keydown", handleKeyDown);
1963
+ return () => document.removeEventListener("keydown", handleKeyDown);
1964
+ }, [isOpen, focusedIndex, options, onChange]);
1965
+ React10.useEffect(() => {
1966
+ if (focusedIndex >= 0 && dropdownRef.current) {
1967
+ const item = dropdownRef.current.children[focusedIndex];
1968
+ item == null ? void 0 : item.scrollIntoView({ block: "nearest" });
1969
+ }
1970
+ }, [focusedIndex]);
1971
+ React10.useEffect(() => {
1972
+ if (!isOpen) return;
1973
+ window.addEventListener("scroll", computePosition, true);
1974
+ window.addEventListener("resize", computePosition);
1975
+ return () => {
1976
+ window.removeEventListener("scroll", computePosition, true);
1977
+ window.removeEventListener("resize", computePosition);
1978
+ };
1979
+ }, [isOpen, computePosition]);
1980
+ const handleOpen = () => {
1981
+ if (disabled) return;
1982
+ if (!isOpen) {
1983
+ computePosition();
1984
+ setFocusedIndex(
1985
+ options.findIndex((opt) => String(opt.value) === String(value))
1986
+ );
1987
+ }
1988
+ setIsOpen((prev) => !prev);
1989
+ };
1990
+ const handleSelect = (opt) => {
1991
+ if (opt.disabled) return;
1992
+ onChange({ target: { value: opt.value } });
1993
+ setIsOpen(false);
1994
+ setFocusedIndex(-1);
1995
+ };
1996
+ const borderColor = error ? "#ef4444" : isOpen ? "#534f8f" : "rgba(0,0,0,0.23)";
1997
+ const { padding, fontSize } = sizeStyles[size];
1998
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `relative ${className}`, ref: triggerRef, children: [
1999
+ /* @__PURE__ */ jsxRuntime.jsxs(
2000
+ "button",
2001
+ {
2002
+ type: "button",
2003
+ disabled,
2004
+ onClick: handleOpen,
2005
+ className: "w-full flex items-center justify-between rounded-md bg-white text-left outline-none disabled:opacity-50 disabled:cursor-not-allowed",
2006
+ style: { padding, border: `1px solid ${borderColor}`, transition: "border-color 0.15s ease" },
2007
+ children: [
2008
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate flex-1", style: { fontSize }, children: selectedOption ? selectedOption.label : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: placeholder }) }),
2009
+ /* @__PURE__ */ jsxRuntime.jsx(
2010
+ "svg",
2011
+ {
2012
+ xmlns: "http://www.w3.org/2000/svg",
2013
+ width: "18",
2014
+ height: "18",
2015
+ viewBox: "0 0 24 24",
2016
+ fill: "currentColor",
2017
+ className: `shrink-0 ml-2 text-gray-400 transition-transform duration-150 ${isOpen ? "rotate-180" : ""}`,
2018
+ children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z" })
2019
+ }
2020
+ )
2021
+ ]
2022
+ }
2023
+ ),
2024
+ isOpen && ReactDOM__default.default.createPortal(
2025
+ /* @__PURE__ */ jsxRuntime.jsx(
2026
+ "ul",
2027
+ {
2028
+ ref: dropdownRef,
2029
+ style: dropdownStyle,
2030
+ className: "bg-white shadow-lg rounded-md border border-gray-200 max-h-60 overflow-y-auto",
2031
+ children: options.map((opt, i) => /* @__PURE__ */ jsxRuntime.jsx(
2032
+ "li",
2033
+ {
2034
+ onClick: () => handleSelect(opt),
2035
+ className: `px-4 py-2 text-[14px] ${opt.disabled ? "text-gray-400 cursor-not-allowed" : String(opt.value) === String(value) ? "bg-purple-100 text-[#534f8f] font-medium cursor-pointer" : focusedIndex === i ? "bg-gray-100 text-gray-800 cursor-pointer" : "text-gray-800 hover:bg-gray-50 cursor-pointer"}`,
2036
+ children: opt.label
2037
+ },
2038
+ i
2039
+ ))
2040
+ }
2041
+ ),
2042
+ document.body
2043
+ )
2044
+ ] });
2045
+ };
2046
+
2047
+ // src/components/Select/SelectOption.tsx
2048
+ var SelectOption = (_props) => null;
2049
+ var Switch = ({
2050
+ checked,
2051
+ onChange,
2052
+ disabled = false,
2053
+ className = ""
2054
+ }) => {
2055
+ return /* @__PURE__ */ jsxRuntime.jsxs(
2056
+ "button",
2057
+ {
2058
+ type: "button",
2059
+ role: "switch",
2060
+ "aria-checked": checked,
2061
+ disabled,
2062
+ onClick: disabled ? void 0 : onChange,
2063
+ className: `relative inline-flex shrink-0 border-0 bg-transparent p-0 focus:outline-none ${disabled ? "opacity-40 cursor-not-allowed" : "cursor-pointer"} ${className}`,
2064
+ style: { width: 58, height: 38 },
2065
+ children: [
2066
+ /* @__PURE__ */ jsxRuntime.jsx(
2067
+ "span",
2068
+ {
2069
+ className: "absolute rounded-full transition-colors duration-200",
2070
+ style: {
2071
+ width: 34,
2072
+ height: 14,
2073
+ top: 12,
2074
+ left: 12,
2075
+ backgroundColor: checked ? "rgba(83,79,143,0.5)" : "rgba(0,0,0,0.38)"
2076
+ }
2077
+ }
2078
+ ),
2079
+ /* @__PURE__ */ jsxRuntime.jsx(
2080
+ "span",
2081
+ {
2082
+ className: "absolute rounded-full transition-all duration-200",
2083
+ style: {
2084
+ width: 20,
2085
+ height: 20,
2086
+ top: 9,
2087
+ left: checked ? 29 : 9,
2088
+ backgroundColor: checked ? "#534f8f" : "#fafafa",
2089
+ boxShadow: "0px 2px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 3px 0px rgba(0,0,0,0.12)"
2090
+ }
2091
+ }
2092
+ )
2093
+ ]
2094
+ }
2095
+ );
2096
+ };
1697
2097
  var SCROLL_STEP = 120;
1698
2098
  function Tabs({
1699
2099
  value,
@@ -1706,12 +2106,12 @@ function Tabs({
1706
2106
  className,
1707
2107
  "aria-label": ariaLabel
1708
2108
  }) {
1709
- const listRef = React8.useRef(null);
1710
- const [canScrollLeft, setCanScrollLeft] = React8.useState(false);
1711
- const [canScrollRight, setCanScrollRight] = React8.useState(false);
1712
- const tabRefs = React8.useRef([]);
1713
- const tabs = React8.Children.toArray(children).filter(
1714
- React8.isValidElement
2109
+ const listRef = React10.useRef(null);
2110
+ const [canScrollLeft, setCanScrollLeft] = React10.useState(false);
2111
+ const [canScrollRight, setCanScrollRight] = React10.useState(false);
2112
+ const tabRefs = React10.useRef([]);
2113
+ const tabs = React10.Children.toArray(children).filter(
2114
+ React10.isValidElement
1715
2115
  );
1716
2116
  function resolveIndex(val) {
1717
2117
  var _a;
@@ -1722,13 +2122,13 @@ function Tabs({
1722
2122
  return -1;
1723
2123
  }
1724
2124
  const selectedIndex = resolveIndex(value);
1725
- const updateScrollState = React8.useCallback(() => {
2125
+ const updateScrollState = React10.useCallback(() => {
1726
2126
  const el = listRef.current;
1727
2127
  if (!el) return;
1728
2128
  setCanScrollLeft(el.scrollLeft > 0);
1729
2129
  setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
1730
2130
  }, []);
1731
- React8.useEffect(() => {
2131
+ React10.useEffect(() => {
1732
2132
  const el = listRef.current;
1733
2133
  if (!el) return;
1734
2134
  updateScrollState();
@@ -1740,7 +2140,7 @@ function Tabs({
1740
2140
  ro.disconnect();
1741
2141
  };
1742
2142
  }, [updateScrollState]);
1743
- React8.useEffect(() => {
2143
+ React10.useEffect(() => {
1744
2144
  const el = tabRefs.current[selectedIndex];
1745
2145
  el == null ? void 0 : el.scrollIntoView({
1746
2146
  block: "nearest",
@@ -1795,7 +2195,7 @@ function Tabs({
1795
2195
  var _a;
1796
2196
  const tabValue = (_a = tab.props.value) != null ? _a : i;
1797
2197
  const selected = tabValue === value;
1798
- return React8.cloneElement(tab, {
2198
+ return React10.cloneElement(tab, {
1799
2199
  key: i,
1800
2200
  selected,
1801
2201
  onChange: (e) => {
@@ -1868,26 +2268,43 @@ function Tab({
1868
2268
  }
1869
2269
  );
1870
2270
  }
1871
- var placementClass = {
1872
- top: "bottom-full left-1/2 -translate-x-1/2 mb-2",
1873
- "top-start": "bottom-full left-0 mb-2",
1874
- "top-end": "bottom-full right-0 mb-2",
1875
- bottom: "top-full left-1/2 -translate-x-1/2 mt-2",
1876
- "bottom-start": "top-full left-0 mt-2",
1877
- "bottom-end": "top-full right-0 mt-2",
1878
- left: "right-full top-1/2 -translate-y-1/2 mr-2",
1879
- "left-start": "right-full top-0 mr-2",
1880
- "left-end": "right-full bottom-0 mr-2",
1881
- right: "left-full top-1/2 -translate-y-1/2 ml-2",
1882
- "right-start": "left-full top-0 ml-2",
1883
- "right-end": "left-full bottom-0 ml-2"
1884
- };
2271
+ var GAP2 = 8;
2272
+ var VIEWPORT_PADDING = 6;
1885
2273
  var arrowClass = {
1886
2274
  top: "top-full left-1/2 -translate-x-1/2 border-t-gray-600/80 border-x-transparent border-b-transparent",
1887
2275
  bottom: "bottom-full left-1/2 -translate-x-1/2 border-b-gray-600/80 border-x-transparent border-t-transparent",
1888
2276
  left: "left-full top-1/2 -translate-y-1/2 border-l-gray-600/80 border-y-transparent border-r-transparent",
1889
2277
  right: "right-full top-1/2 -translate-y-1/2 border-r-gray-600/80 border-y-transparent border-l-transparent"
1890
2278
  };
2279
+ function getPosition(trigger, tooltip, placement) {
2280
+ const tw = tooltip.offsetWidth;
2281
+ const th = tooltip.offsetHeight;
2282
+ const { top, left, right, bottom, width, height } = trigger;
2283
+ const positions = {
2284
+ top: { top: top - th - GAP2, left: left + width / 2 - tw / 2 },
2285
+ "top-start": { top: top - th - GAP2, left },
2286
+ "top-end": { top: top - th - GAP2, left: right - tw },
2287
+ bottom: { top: bottom + GAP2, left: left + width / 2 - tw / 2 },
2288
+ "bottom-start": { top: bottom + GAP2, left },
2289
+ "bottom-end": { top: bottom + GAP2, left: right - tw },
2290
+ left: { top: top + height / 2 - th / 2, left: left - tw - GAP2 },
2291
+ "left-start": { top, left: left - tw - GAP2 },
2292
+ "left-end": { top: bottom - th, left: left - tw - GAP2 },
2293
+ right: { top: top + height / 2 - th / 2, left: right + GAP2 },
2294
+ "right-start": { top, left: right + GAP2 },
2295
+ "right-end": { top: bottom - th, left: right + GAP2 }
2296
+ };
2297
+ const pos = positions[placement];
2298
+ pos.left = Math.max(
2299
+ VIEWPORT_PADDING,
2300
+ Math.min(pos.left, window.innerWidth - tw - VIEWPORT_PADDING)
2301
+ );
2302
+ pos.top = Math.max(
2303
+ VIEWPORT_PADDING,
2304
+ Math.min(pos.top, window.innerHeight - th - VIEWPORT_PADDING)
2305
+ );
2306
+ return pos;
2307
+ }
1891
2308
  function Tooltip({
1892
2309
  title,
1893
2310
  children,
@@ -1899,11 +2316,35 @@ function Tooltip({
1899
2316
  className,
1900
2317
  disabled = false
1901
2318
  }) {
1902
- const [visible, setVisible] = React8.useState(false);
2319
+ const [visible, setVisible] = React10.useState(false);
2320
+ const triggerRef = React10.useRef(null);
2321
+ const tooltipRef = React10.useRef(null);
2322
+ const enterTimer = React10.useRef(null);
2323
+ const leaveTimer = React10.useRef(null);
1903
2324
  const isControlled = controlledOpen !== void 0;
1904
2325
  const show = isControlled ? controlledOpen : visible;
1905
- const enterTimer = React8__default.default.useRef(null);
1906
- const leaveTimer = React8__default.default.useRef(null);
2326
+ const positionAndShow = React10.useCallback(() => {
2327
+ const tooltip = tooltipRef.current;
2328
+ const trigger2 = triggerRef.current;
2329
+ if (!tooltip || !trigger2) return;
2330
+ const pos = getPosition(
2331
+ trigger2.getBoundingClientRect(),
2332
+ tooltip,
2333
+ placement
2334
+ );
2335
+ tooltip.style.top = `${pos.top}px`;
2336
+ tooltip.style.left = `${pos.left}px`;
2337
+ tooltip.style.opacity = "1";
2338
+ }, [placement]);
2339
+ React10.useEffect(() => {
2340
+ if (!show) {
2341
+ const tooltip = tooltipRef.current;
2342
+ if (tooltip) tooltip.style.opacity = "0";
2343
+ return;
2344
+ }
2345
+ const id = requestAnimationFrame(positionAndShow);
2346
+ return () => cancelAnimationFrame(id);
2347
+ }, [show, positionAndShow]);
1907
2348
  const handleEnter = () => {
1908
2349
  if (disabled || isControlled) return;
1909
2350
  if (leaveTimer.current) clearTimeout(leaveTimer.current);
@@ -1914,47 +2355,79 @@ function Tooltip({
1914
2355
  if (enterTimer.current) clearTimeout(enterTimer.current);
1915
2356
  leaveTimer.current = setTimeout(() => setVisible(false), leaveDelay);
1916
2357
  };
2358
+ React10.useEffect(() => {
2359
+ return () => {
2360
+ if (enterTimer.current) clearTimeout(enterTimer.current);
2361
+ if (leaveTimer.current) clearTimeout(leaveTimer.current);
2362
+ };
2363
+ }, []);
2364
+ if (!React10__default.default.isValidElement(children)) return children;
1917
2365
  const side = placement.split("-")[0];
1918
- return /* @__PURE__ */ jsxRuntime.jsxs(
1919
- "div",
2366
+ const trigger = React10__default.default.cloneElement(
2367
+ children,
1920
2368
  {
1921
- className: "relative inline-flex",
1922
- onMouseEnter: handleEnter,
1923
- onMouseLeave: handleLeave,
1924
- onFocus: handleEnter,
1925
- onBlur: handleLeave,
1926
- children: [
1927
- children,
1928
- show && title && !disabled && /* @__PURE__ */ jsxRuntime.jsxs(
1929
- "div",
1930
- {
1931
- role: "tooltip",
1932
- className: [
1933
- "absolute z-[9999] max-w-[300px] px-2 py-1.5 whitespace-nowrap",
1934
- "bg-gray-600/80 text-white text-xs rounded shadow-md pointer-events-none",
1935
- "animate-in fade-in-0 zoom-in-95 duration-100",
1936
- placementClass[placement],
1937
- className || ""
1938
- ].join(" "),
1939
- children: [
1940
- arrow && /* @__PURE__ */ jsxRuntime.jsx(
1941
- "span",
1942
- {
1943
- className: ["absolute w-0 h-0 border-4", arrowClass[side]].join(
1944
- " "
1945
- )
1946
- }
1947
- ),
1948
- title
1949
- ]
1950
- }
1951
- )
1952
- ]
2369
+ ref: triggerRef,
2370
+ onMouseEnter: (e) => {
2371
+ var _a, _b;
2372
+ handleEnter();
2373
+ (_b = (_a = children.props).onMouseEnter) == null ? void 0 : _b.call(_a, e);
2374
+ },
2375
+ onMouseLeave: (e) => {
2376
+ var _a, _b;
2377
+ handleLeave();
2378
+ (_b = (_a = children.props).onMouseLeave) == null ? void 0 : _b.call(_a, e);
2379
+ },
2380
+ onFocus: (e) => {
2381
+ var _a, _b;
2382
+ handleEnter();
2383
+ (_b = (_a = children.props).onFocus) == null ? void 0 : _b.call(_a, e);
2384
+ },
2385
+ onBlur: (e) => {
2386
+ var _a, _b;
2387
+ handleLeave();
2388
+ (_b = (_a = children.props).onBlur) == null ? void 0 : _b.call(_a, e);
2389
+ }
1953
2390
  }
1954
2391
  );
2392
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2393
+ trigger,
2394
+ ReactDOM.createPortal(
2395
+ title ? /* @__PURE__ */ jsxRuntime.jsxs(
2396
+ "div",
2397
+ {
2398
+ ref: tooltipRef,
2399
+ role: "tooltip",
2400
+ style: {
2401
+ position: "fixed",
2402
+ top: -9999,
2403
+ left: -9999,
2404
+ opacity: 0,
2405
+ transition: "opacity 100ms ease"
2406
+ },
2407
+ className: [
2408
+ "z-[99] max-w-[300px] px-2 py-1.5",
2409
+ "bg-gray-600/80 text-white text-xs rounded shadow-md pointer-events-none",
2410
+ className || ""
2411
+ ].join(" "),
2412
+ children: [
2413
+ arrow && /* @__PURE__ */ jsxRuntime.jsx(
2414
+ "span",
2415
+ {
2416
+ className: ["absolute w-0 h-0 border-4", arrowClass[side]].join(
2417
+ " "
2418
+ )
2419
+ }
2420
+ ),
2421
+ title
2422
+ ]
2423
+ }
2424
+ ) : null,
2425
+ document.body
2426
+ )
2427
+ ] });
1955
2428
  }
1956
2429
  function useLocalStorage(key, initialValue) {
1957
- const [storedValue, setStoredValue] = React8.useState(() => {
2430
+ const [storedValue, setStoredValue] = React10.useState(() => {
1958
2431
  if (typeof window === "undefined") return initialValue;
1959
2432
  try {
1960
2433
  const item = window.localStorage.getItem(key);
@@ -1993,18 +2466,25 @@ exports.AccordionSummary = AccordionSummary;
1993
2466
  exports.AutoComplete = AutoComplete;
1994
2467
  exports.Breadcrumb = Breadcrumb;
1995
2468
  exports.ButtonLoader = ButtonLoader;
2469
+ exports.Chip = Chip;
1996
2470
  exports.CopyId = CopyId;
1997
2471
  exports.CustomAnchor = CustomAnchor;
1998
2472
  exports.CustomInput = CustomInput;
1999
2473
  exports.Drawer = Drawer;
2000
2474
  exports.FilterDrawer = FilterDrawer;
2001
2475
  exports.InputTitleWithRequired = InputTitleWithRequired;
2476
+ exports.Menu = Menu;
2477
+ exports.MenuDivider = MenuDivider;
2478
+ exports.MenuItem = MenuItem;
2002
2479
  exports.Modal = Modal;
2003
2480
  exports.MonthYearPicker = MonthYearPicker;
2004
2481
  exports.Pagination = Pagination;
2005
2482
  exports.ReadMore = ReadMore;
2006
2483
  exports.SearchBar = SearchBar;
2484
+ exports.Select = Select;
2485
+ exports.SelectOption = SelectOption;
2007
2486
  exports.StagingAlert = StagingAlert;
2487
+ exports.Switch = Switch;
2008
2488
  exports.Tab = Tab;
2009
2489
  exports.Tabs = Tabs;
2010
2490
  exports.Tooltip = Tooltip;