@seekho/ui 0.1.21 → 0.1.24
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.d.mts +96 -2
- package/dist/index.d.ts +96 -2
- package/dist/index.js +926 -54
- package/dist/index.mjs +923 -57
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React2, { createContext, useState, useId, useRef, useEffect, useContext } from 'react';
|
|
2
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
|
+
import React2, { createContext, useState, useId, useRef, useEffect, Children, isValidElement, useCallback, cloneElement, useContext } from 'react';
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { useHotkeys } from 'react-hotkeys-hook';
|
|
4
|
+
import { createPortal } from 'react-dom';
|
|
4
5
|
|
|
5
6
|
var __defProp = Object.defineProperty;
|
|
6
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
@@ -737,6 +738,7 @@ var FilterDrawer = ({
|
|
|
737
738
|
title,
|
|
738
739
|
anchor = "right",
|
|
739
740
|
children,
|
|
741
|
+
drawerClassName,
|
|
740
742
|
childrenClassName,
|
|
741
743
|
applyBtnText = "Apply",
|
|
742
744
|
clearBtnText = "Clear",
|
|
@@ -744,63 +746,73 @@ var FilterDrawer = ({
|
|
|
744
746
|
handleApplyFilters,
|
|
745
747
|
handleClearFilters
|
|
746
748
|
}) => {
|
|
747
|
-
return /* @__PURE__ */ jsx(
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
749
|
+
return /* @__PURE__ */ jsx(
|
|
750
|
+
Drawer,
|
|
751
|
+
{
|
|
752
|
+
open,
|
|
753
|
+
anchor,
|
|
754
|
+
onClose: handleClose,
|
|
755
|
+
className: drawerClassName || "w-full lg:w-[450px]",
|
|
756
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative h-full bg-white flex flex-col justify-between", children: [
|
|
757
|
+
/* @__PURE__ */ jsxs("div", { className: "px-3 py-2.5 bg-gray-100 flex justify-between items-center z-10", children: [
|
|
758
|
+
/* @__PURE__ */ jsx("h6", { className: "text-lg font-bold flex items-center gap-1", children: title }),
|
|
759
|
+
/* @__PURE__ */ jsx(
|
|
760
|
+
"button",
|
|
757
761
|
{
|
|
758
|
-
|
|
759
|
-
className: "
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
762
|
+
onClick: handleClose,
|
|
763
|
+
className: "cursor-pointer text-gray-600 hover:text-gray-900 transition-colors",
|
|
764
|
+
children: /* @__PURE__ */ jsxs(
|
|
765
|
+
"svg",
|
|
766
|
+
{
|
|
767
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
768
|
+
className: "w-[24px] h-[24px]",
|
|
769
|
+
viewBox: "0 0 24 24",
|
|
770
|
+
fill: "none",
|
|
771
|
+
stroke: "currentColor",
|
|
772
|
+
strokeWidth: "2",
|
|
773
|
+
strokeLinecap: "round",
|
|
774
|
+
strokeLinejoin: "round",
|
|
775
|
+
children: [
|
|
776
|
+
/* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
777
|
+
/* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
)
|
|
770
781
|
}
|
|
771
782
|
)
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
783
|
+
] }),
|
|
784
|
+
/* @__PURE__ */ jsx(
|
|
785
|
+
"div",
|
|
786
|
+
{
|
|
787
|
+
id: "HideScroll",
|
|
788
|
+
className: [
|
|
789
|
+
"flex-1 overflow-auto px-2 pb-3",
|
|
790
|
+
childrenClassName || ""
|
|
791
|
+
].join(" "),
|
|
792
|
+
children
|
|
793
|
+
}
|
|
794
|
+
),
|
|
795
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-x-2 py-3 px-4 justify-end bg-gray-100 border-gray-300", children: [
|
|
796
|
+
/* @__PURE__ */ jsx(
|
|
797
|
+
"button",
|
|
798
|
+
{
|
|
799
|
+
onClick: handleClearFilters,
|
|
800
|
+
className: "!px-10 py-2 bg-white !text-[15px] text-black rounded-lg",
|
|
801
|
+
children: clearBtnText
|
|
802
|
+
}
|
|
803
|
+
),
|
|
804
|
+
/* @__PURE__ */ jsx(
|
|
805
|
+
"button",
|
|
806
|
+
{
|
|
807
|
+
onClick: handleApplyFilters,
|
|
808
|
+
className: "!px-10 py-2 bg-skprimary !text-[15px] text-white rounded-lg",
|
|
809
|
+
children: applyBtnText
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] })
|
|
813
|
+
] })
|
|
814
|
+
}
|
|
815
|
+
);
|
|
804
816
|
};
|
|
805
817
|
|
|
806
818
|
// src/utils/modalStack.ts
|
|
@@ -951,6 +963,564 @@ function Modal({
|
|
|
951
963
|
}
|
|
952
964
|
) });
|
|
953
965
|
}
|
|
966
|
+
var MONTHS_SHORT = [
|
|
967
|
+
"Jan",
|
|
968
|
+
"Feb",
|
|
969
|
+
"Mar",
|
|
970
|
+
"Apr",
|
|
971
|
+
"May",
|
|
972
|
+
"Jun",
|
|
973
|
+
"Jul",
|
|
974
|
+
"Aug",
|
|
975
|
+
"Sep",
|
|
976
|
+
"Oct",
|
|
977
|
+
"Nov",
|
|
978
|
+
"Dec"
|
|
979
|
+
];
|
|
980
|
+
var MONTHS_FULL = [
|
|
981
|
+
"January",
|
|
982
|
+
"February",
|
|
983
|
+
"March",
|
|
984
|
+
"April",
|
|
985
|
+
"May",
|
|
986
|
+
"June",
|
|
987
|
+
"July",
|
|
988
|
+
"August",
|
|
989
|
+
"September",
|
|
990
|
+
"October",
|
|
991
|
+
"November",
|
|
992
|
+
"December"
|
|
993
|
+
];
|
|
994
|
+
var colorMap = {
|
|
995
|
+
skprimary: {
|
|
996
|
+
triggerOpen: "border-skprimary bg-skprimary/10 text-skprimary",
|
|
997
|
+
triggerIcon: "text-skprimary",
|
|
998
|
+
monthSelected: "bg-skprimary text-white shadow-sm",
|
|
999
|
+
monthHover: "hover:bg-skprimary/10 hover:text-skprimary"
|
|
1000
|
+
},
|
|
1001
|
+
blue: {
|
|
1002
|
+
triggerOpen: "border-blue-400 bg-blue-50 text-blue-600",
|
|
1003
|
+
triggerIcon: "text-blue-500",
|
|
1004
|
+
monthSelected: "bg-blue-600 text-white shadow-sm",
|
|
1005
|
+
monthHover: "hover:bg-blue-50 hover:text-blue-600"
|
|
1006
|
+
},
|
|
1007
|
+
green: {
|
|
1008
|
+
triggerOpen: "border-green-400 bg-green-50 text-green-600",
|
|
1009
|
+
triggerIcon: "text-green-500",
|
|
1010
|
+
monthSelected: "bg-green-600 text-white shadow-sm",
|
|
1011
|
+
monthHover: "hover:bg-green-50 hover:text-green-600"
|
|
1012
|
+
},
|
|
1013
|
+
purple: {
|
|
1014
|
+
triggerOpen: "border-purple-400 bg-purple-50 text-purple-600",
|
|
1015
|
+
triggerIcon: "text-purple-500",
|
|
1016
|
+
monthSelected: "bg-purple-600 text-white shadow-sm",
|
|
1017
|
+
monthHover: "hover:bg-purple-50 hover:text-purple-600"
|
|
1018
|
+
},
|
|
1019
|
+
red: {
|
|
1020
|
+
triggerOpen: "border-red-400 bg-red-50 text-red-600",
|
|
1021
|
+
triggerIcon: "text-red-500",
|
|
1022
|
+
monthSelected: "bg-red-600 text-white shadow-sm",
|
|
1023
|
+
monthHover: "hover:bg-red-50 hover:text-red-600"
|
|
1024
|
+
},
|
|
1025
|
+
orange: {
|
|
1026
|
+
triggerOpen: "border-orange-400 bg-orange-50 text-orange-600",
|
|
1027
|
+
triggerIcon: "text-orange-500",
|
|
1028
|
+
monthSelected: "bg-orange-600 text-white shadow-sm",
|
|
1029
|
+
monthHover: "hover:bg-orange-50 hover:text-orange-600"
|
|
1030
|
+
},
|
|
1031
|
+
pink: {
|
|
1032
|
+
triggerOpen: "border-pink-400 bg-pink-50 text-pink-600",
|
|
1033
|
+
triggerIcon: "text-pink-500",
|
|
1034
|
+
monthSelected: "bg-pink-600 text-white shadow-sm",
|
|
1035
|
+
monthHover: "hover:bg-pink-50 hover:text-pink-600"
|
|
1036
|
+
},
|
|
1037
|
+
teal: {
|
|
1038
|
+
triggerOpen: "border-teal-400 bg-teal-50 text-teal-600",
|
|
1039
|
+
triggerIcon: "text-teal-500",
|
|
1040
|
+
monthSelected: "bg-teal-600 text-white shadow-sm",
|
|
1041
|
+
monthHover: "hover:bg-teal-50 hover:text-teal-600"
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
var triggerSizeClass = {
|
|
1045
|
+
sm: "px-2.5 py-1 text-[12px] gap-x-1.5",
|
|
1046
|
+
md: "px-3 py-1.5 text-[13px] gap-x-2",
|
|
1047
|
+
lg: "px-4 py-2 text-[14px] gap-x-2"
|
|
1048
|
+
};
|
|
1049
|
+
var iconSizeClass = {
|
|
1050
|
+
sm: "w-3 h-3",
|
|
1051
|
+
md: "w-3.5 h-3.5",
|
|
1052
|
+
lg: "w-4 h-4"
|
|
1053
|
+
};
|
|
1054
|
+
var triggerVariantBase = {
|
|
1055
|
+
outlined: "border border-gray-200 bg-white text-gray-600 hover:border-gray-300 hover:bg-gray-50",
|
|
1056
|
+
ghost: "border border-transparent bg-transparent text-gray-600 hover:bg-gray-100",
|
|
1057
|
+
plain: "border border-transparent bg-transparent text-gray-600 hover:text-gray-900"
|
|
1058
|
+
};
|
|
1059
|
+
var isAfter = (a, b) => a.year > b.year || a.year === b.year && a.month > b.month;
|
|
1060
|
+
var isBefore = (a, b) => a.year < b.year || a.year === b.year && a.month < b.month;
|
|
1061
|
+
var isSame = (a, b) => a.year === b.year && a.month === b.month;
|
|
1062
|
+
var MonthYearPicker = ({
|
|
1063
|
+
month,
|
|
1064
|
+
year,
|
|
1065
|
+
onChange,
|
|
1066
|
+
disableFuture = true,
|
|
1067
|
+
disablePast = false,
|
|
1068
|
+
minDate,
|
|
1069
|
+
maxDate,
|
|
1070
|
+
placement = "right",
|
|
1071
|
+
variant = "outlined",
|
|
1072
|
+
size = "md",
|
|
1073
|
+
color = "skprimary",
|
|
1074
|
+
disabled = false,
|
|
1075
|
+
className,
|
|
1076
|
+
triggerClassName,
|
|
1077
|
+
dropdownClassName
|
|
1078
|
+
}) => {
|
|
1079
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1080
|
+
const [pickerYear, setPickerYear] = useState(year);
|
|
1081
|
+
const ref = useRef(null);
|
|
1082
|
+
const now = /* @__PURE__ */ new Date();
|
|
1083
|
+
const currentMonth = now.getMonth() + 1;
|
|
1084
|
+
const currentYear = now.getFullYear();
|
|
1085
|
+
const theme = colorMap[color];
|
|
1086
|
+
const handleToggle = () => {
|
|
1087
|
+
if (disabled) return;
|
|
1088
|
+
setIsOpen((prev) => !prev);
|
|
1089
|
+
};
|
|
1090
|
+
const handleSelectMonth = (monthIndex) => {
|
|
1091
|
+
onChange({ month: monthIndex + 1, year: pickerYear });
|
|
1092
|
+
setIsOpen(false);
|
|
1093
|
+
};
|
|
1094
|
+
const handlePrevYear = () => setPickerYear((y) => y - 1);
|
|
1095
|
+
const handleNextYear = () => setPickerYear((y) => y + 1);
|
|
1096
|
+
const isMonthDisabled = (monthIndex) => {
|
|
1097
|
+
const candidate = { month: monthIndex + 1, year: pickerYear };
|
|
1098
|
+
const today = { month: currentMonth, year: currentYear };
|
|
1099
|
+
if (disableFuture && isAfter(candidate, today)) return true;
|
|
1100
|
+
if (disablePast && isBefore(candidate, today)) return true;
|
|
1101
|
+
if (minDate && isBefore(candidate, minDate)) return true;
|
|
1102
|
+
if (maxDate && isAfter(candidate, maxDate)) return true;
|
|
1103
|
+
return false;
|
|
1104
|
+
};
|
|
1105
|
+
const isPrevYearDisabled = () => {
|
|
1106
|
+
if (minDate && pickerYear - 1 < minDate.year) return true;
|
|
1107
|
+
return false;
|
|
1108
|
+
};
|
|
1109
|
+
const isNextYearDisabled = () => {
|
|
1110
|
+
if (disableFuture && pickerYear >= currentYear) return true;
|
|
1111
|
+
if (maxDate && pickerYear >= maxDate.year) return true;
|
|
1112
|
+
return false;
|
|
1113
|
+
};
|
|
1114
|
+
useEffect(() => {
|
|
1115
|
+
setPickerYear(year);
|
|
1116
|
+
}, [year]);
|
|
1117
|
+
useEffect(() => {
|
|
1118
|
+
const handleClickOutside = (e) => {
|
|
1119
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
1120
|
+
setIsOpen(false);
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
1124
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
1125
|
+
}, []);
|
|
1126
|
+
return /* @__PURE__ */ jsxs(
|
|
1127
|
+
"div",
|
|
1128
|
+
{
|
|
1129
|
+
ref,
|
|
1130
|
+
className: ["relative inline-block", className || ""].join(" "),
|
|
1131
|
+
children: [
|
|
1132
|
+
/* @__PURE__ */ jsxs(
|
|
1133
|
+
"button",
|
|
1134
|
+
{
|
|
1135
|
+
type: "button",
|
|
1136
|
+
onClick: handleToggle,
|
|
1137
|
+
disabled,
|
|
1138
|
+
className: [
|
|
1139
|
+
"flex items-center font-medium rounded-lg transition-all",
|
|
1140
|
+
triggerSizeClass[size],
|
|
1141
|
+
isOpen ? theme.triggerOpen : triggerVariantBase[variant],
|
|
1142
|
+
disabled ? "opacity-40 cursor-not-allowed pointer-events-none" : "cursor-pointer",
|
|
1143
|
+
triggerClassName || ""
|
|
1144
|
+
].join(" "),
|
|
1145
|
+
children: [
|
|
1146
|
+
/* @__PURE__ */ jsx(
|
|
1147
|
+
"svg",
|
|
1148
|
+
{
|
|
1149
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1150
|
+
className: [
|
|
1151
|
+
iconSizeClass[size],
|
|
1152
|
+
isOpen ? theme.triggerIcon : "text-gray-400"
|
|
1153
|
+
].join(" "),
|
|
1154
|
+
fill: "none",
|
|
1155
|
+
viewBox: "0 0 24 24",
|
|
1156
|
+
stroke: "currentColor",
|
|
1157
|
+
children: /* @__PURE__ */ jsx(
|
|
1158
|
+
"path",
|
|
1159
|
+
{
|
|
1160
|
+
strokeLinecap: "round",
|
|
1161
|
+
strokeLinejoin: "round",
|
|
1162
|
+
strokeWidth: 2,
|
|
1163
|
+
d: "M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"
|
|
1164
|
+
}
|
|
1165
|
+
)
|
|
1166
|
+
}
|
|
1167
|
+
),
|
|
1168
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1169
|
+
MONTHS_FULL[month - 1],
|
|
1170
|
+
", ",
|
|
1171
|
+
year
|
|
1172
|
+
] }),
|
|
1173
|
+
/* @__PURE__ */ jsx(
|
|
1174
|
+
"svg",
|
|
1175
|
+
{
|
|
1176
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1177
|
+
className: [
|
|
1178
|
+
iconSizeClass[size],
|
|
1179
|
+
"transition-transform",
|
|
1180
|
+
isOpen ? `rotate-180 ${theme.triggerIcon}` : "text-gray-400"
|
|
1181
|
+
].join(" "),
|
|
1182
|
+
fill: "none",
|
|
1183
|
+
viewBox: "0 0 24 24",
|
|
1184
|
+
stroke: "currentColor",
|
|
1185
|
+
children: /* @__PURE__ */ jsx(
|
|
1186
|
+
"path",
|
|
1187
|
+
{
|
|
1188
|
+
strokeLinecap: "round",
|
|
1189
|
+
strokeLinejoin: "round",
|
|
1190
|
+
strokeWidth: 2.5,
|
|
1191
|
+
d: "M19 9l-7 7-7-7"
|
|
1192
|
+
}
|
|
1193
|
+
)
|
|
1194
|
+
}
|
|
1195
|
+
)
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
),
|
|
1199
|
+
isOpen && /* @__PURE__ */ jsxs(
|
|
1200
|
+
"div",
|
|
1201
|
+
{
|
|
1202
|
+
className: [
|
|
1203
|
+
"absolute top-[calc(100%+8px)] z-50",
|
|
1204
|
+
"bg-white border border-gray-100 rounded-2xl shadow-xl p-4 w-[240px]",
|
|
1205
|
+
placement === "right" ? "left-0" : "right-0",
|
|
1206
|
+
dropdownClassName || ""
|
|
1207
|
+
].join(" "),
|
|
1208
|
+
children: [
|
|
1209
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4 px-1", children: [
|
|
1210
|
+
/* @__PURE__ */ jsx(
|
|
1211
|
+
"button",
|
|
1212
|
+
{
|
|
1213
|
+
type: "button",
|
|
1214
|
+
onClick: handlePrevYear,
|
|
1215
|
+
disabled: isPrevYearDisabled(),
|
|
1216
|
+
className: [
|
|
1217
|
+
"w-7 h-7 flex items-center justify-center rounded-full text-lg leading-none",
|
|
1218
|
+
isPrevYearDisabled() ? "text-gray-200 cursor-not-allowed" : "hover:bg-gray-100 text-gray-500"
|
|
1219
|
+
].join(" "),
|
|
1220
|
+
children: "\u2039"
|
|
1221
|
+
}
|
|
1222
|
+
),
|
|
1223
|
+
/* @__PURE__ */ jsx("span", { className: "text-[14px] font-semibold text-gray-800 tracking-wide", children: pickerYear }),
|
|
1224
|
+
/* @__PURE__ */ jsx(
|
|
1225
|
+
"button",
|
|
1226
|
+
{
|
|
1227
|
+
type: "button",
|
|
1228
|
+
onClick: handleNextYear,
|
|
1229
|
+
disabled: isNextYearDisabled(),
|
|
1230
|
+
className: [
|
|
1231
|
+
"w-7 h-7 flex items-center justify-center rounded-full text-lg leading-none",
|
|
1232
|
+
isNextYearDisabled() ? "text-gray-200 cursor-not-allowed" : "hover:bg-gray-100 text-gray-500"
|
|
1233
|
+
].join(" "),
|
|
1234
|
+
children: "\u203A"
|
|
1235
|
+
}
|
|
1236
|
+
)
|
|
1237
|
+
] }),
|
|
1238
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-3 gap-1", children: MONTHS_SHORT.map((m, i) => {
|
|
1239
|
+
const isSelected = isSame(
|
|
1240
|
+
{ month: i + 1, year: pickerYear },
|
|
1241
|
+
{ month, year }
|
|
1242
|
+
);
|
|
1243
|
+
const isDisabled = isMonthDisabled(i);
|
|
1244
|
+
return /* @__PURE__ */ jsx(
|
|
1245
|
+
"button",
|
|
1246
|
+
{
|
|
1247
|
+
type: "button",
|
|
1248
|
+
disabled: isDisabled,
|
|
1249
|
+
onClick: () => !isDisabled && handleSelectMonth(i),
|
|
1250
|
+
className: [
|
|
1251
|
+
"py-2 rounded-xl text-[12px] font-medium transition-colors",
|
|
1252
|
+
isDisabled ? "text-gray-300 cursor-not-allowed" : isSelected ? theme.monthSelected : `text-gray-600 ${theme.monthHover}`
|
|
1253
|
+
].join(" "),
|
|
1254
|
+
children: m
|
|
1255
|
+
},
|
|
1256
|
+
m
|
|
1257
|
+
);
|
|
1258
|
+
}) })
|
|
1259
|
+
]
|
|
1260
|
+
}
|
|
1261
|
+
)
|
|
1262
|
+
]
|
|
1263
|
+
}
|
|
1264
|
+
);
|
|
1265
|
+
};
|
|
1266
|
+
function range(start, end) {
|
|
1267
|
+
return Array.from(
|
|
1268
|
+
{ length: Math.max(end - start + 1, 0) },
|
|
1269
|
+
(_, i) => start + i
|
|
1270
|
+
);
|
|
1271
|
+
}
|
|
1272
|
+
function buildItems(count, page, siblingCount, boundaryCount, showFirstButton, showLastButton, hidePrevButton, hideNextButton) {
|
|
1273
|
+
const startPages = range(1, Math.min(boundaryCount, count));
|
|
1274
|
+
const endPages = range(
|
|
1275
|
+
Math.max(count - boundaryCount + 1, boundaryCount + 1),
|
|
1276
|
+
count
|
|
1277
|
+
);
|
|
1278
|
+
const siblingsStart = Math.max(
|
|
1279
|
+
Math.min(page - siblingCount, count - boundaryCount - siblingCount * 2 - 1),
|
|
1280
|
+
boundaryCount + 2
|
|
1281
|
+
);
|
|
1282
|
+
const siblingsEnd = Math.min(
|
|
1283
|
+
Math.max(page + siblingCount, boundaryCount + siblingCount * 2 + 2),
|
|
1284
|
+
endPages.length > 0 ? endPages[0] - 2 : count - 1
|
|
1285
|
+
);
|
|
1286
|
+
const items = [];
|
|
1287
|
+
if (showFirstButton) items.push("first");
|
|
1288
|
+
if (!hidePrevButton) items.push("previous");
|
|
1289
|
+
items.push(...startPages);
|
|
1290
|
+
if (siblingsStart > boundaryCount + 2) {
|
|
1291
|
+
items.push("start-ellipsis");
|
|
1292
|
+
} else if (boundaryCount + 1 < count - boundaryCount) {
|
|
1293
|
+
items.push(boundaryCount + 1);
|
|
1294
|
+
}
|
|
1295
|
+
items.push(...range(siblingsStart, siblingsEnd));
|
|
1296
|
+
if (siblingsEnd < count - boundaryCount - 1) {
|
|
1297
|
+
items.push("end-ellipsis");
|
|
1298
|
+
} else if (count - boundaryCount > boundaryCount) {
|
|
1299
|
+
items.push(count - boundaryCount);
|
|
1300
|
+
}
|
|
1301
|
+
items.push(...endPages);
|
|
1302
|
+
if (!hideNextButton) items.push("next");
|
|
1303
|
+
if (showLastButton) items.push("last");
|
|
1304
|
+
return items;
|
|
1305
|
+
}
|
|
1306
|
+
var iconSize = {
|
|
1307
|
+
small: "w-3 h-3",
|
|
1308
|
+
medium: "w-4 h-4",
|
|
1309
|
+
large: "w-5 h-5"
|
|
1310
|
+
};
|
|
1311
|
+
function ChevronFirst({ size }) {
|
|
1312
|
+
return /* @__PURE__ */ jsxs(
|
|
1313
|
+
"svg",
|
|
1314
|
+
{
|
|
1315
|
+
viewBox: "0 0 24 24",
|
|
1316
|
+
className: iconSize[size],
|
|
1317
|
+
fill: "none",
|
|
1318
|
+
stroke: "currentColor",
|
|
1319
|
+
strokeWidth: "2",
|
|
1320
|
+
strokeLinecap: "round",
|
|
1321
|
+
strokeLinejoin: "round",
|
|
1322
|
+
"aria-hidden": "true",
|
|
1323
|
+
children: [
|
|
1324
|
+
/* @__PURE__ */ jsx("polyline", { points: "11 17 6 12 11 7" }),
|
|
1325
|
+
/* @__PURE__ */ jsx("polyline", { points: "18 17 13 12 18 7" })
|
|
1326
|
+
]
|
|
1327
|
+
}
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
function ChevronLast({ size }) {
|
|
1331
|
+
return /* @__PURE__ */ jsxs(
|
|
1332
|
+
"svg",
|
|
1333
|
+
{
|
|
1334
|
+
viewBox: "0 0 24 24",
|
|
1335
|
+
className: iconSize[size],
|
|
1336
|
+
fill: "none",
|
|
1337
|
+
stroke: "currentColor",
|
|
1338
|
+
strokeWidth: "2",
|
|
1339
|
+
strokeLinecap: "round",
|
|
1340
|
+
strokeLinejoin: "round",
|
|
1341
|
+
"aria-hidden": "true",
|
|
1342
|
+
children: [
|
|
1343
|
+
/* @__PURE__ */ jsx("polyline", { points: "13 17 18 12 13 7" }),
|
|
1344
|
+
/* @__PURE__ */ jsx("polyline", { points: "6 17 11 12 6 7" })
|
|
1345
|
+
]
|
|
1346
|
+
}
|
|
1347
|
+
);
|
|
1348
|
+
}
|
|
1349
|
+
function ChevronLeft({ size }) {
|
|
1350
|
+
return /* @__PURE__ */ jsx(
|
|
1351
|
+
"svg",
|
|
1352
|
+
{
|
|
1353
|
+
viewBox: "0 0 24 24",
|
|
1354
|
+
className: iconSize[size],
|
|
1355
|
+
fill: "none",
|
|
1356
|
+
stroke: "currentColor",
|
|
1357
|
+
strokeWidth: "2",
|
|
1358
|
+
strokeLinecap: "round",
|
|
1359
|
+
strokeLinejoin: "round",
|
|
1360
|
+
"aria-hidden": "true",
|
|
1361
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "15 18 9 12 15 6" })
|
|
1362
|
+
}
|
|
1363
|
+
);
|
|
1364
|
+
}
|
|
1365
|
+
function ChevronRight({ size }) {
|
|
1366
|
+
return /* @__PURE__ */ jsx(
|
|
1367
|
+
"svg",
|
|
1368
|
+
{
|
|
1369
|
+
viewBox: "0 0 24 24",
|
|
1370
|
+
className: iconSize[size],
|
|
1371
|
+
fill: "none",
|
|
1372
|
+
stroke: "currentColor",
|
|
1373
|
+
strokeWidth: "2",
|
|
1374
|
+
strokeLinecap: "round",
|
|
1375
|
+
strokeLinejoin: "round",
|
|
1376
|
+
"aria-hidden": "true",
|
|
1377
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
1378
|
+
}
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
var Pagination = ({
|
|
1382
|
+
count,
|
|
1383
|
+
page,
|
|
1384
|
+
onChange,
|
|
1385
|
+
siblingCount = 1,
|
|
1386
|
+
boundaryCount = 1,
|
|
1387
|
+
showFirstButton = false,
|
|
1388
|
+
showLastButton = false,
|
|
1389
|
+
hidePrevButton = false,
|
|
1390
|
+
hideNextButton = false,
|
|
1391
|
+
disabled = false,
|
|
1392
|
+
size = "medium",
|
|
1393
|
+
variant = "text",
|
|
1394
|
+
shape = "rounded",
|
|
1395
|
+
className
|
|
1396
|
+
}) => {
|
|
1397
|
+
if (count < 1) return null;
|
|
1398
|
+
const items = buildItems(
|
|
1399
|
+
count,
|
|
1400
|
+
page,
|
|
1401
|
+
siblingCount,
|
|
1402
|
+
boundaryCount,
|
|
1403
|
+
showFirstButton,
|
|
1404
|
+
showLastButton,
|
|
1405
|
+
hidePrevButton,
|
|
1406
|
+
hideNextButton
|
|
1407
|
+
);
|
|
1408
|
+
const sizeClasses = {
|
|
1409
|
+
small: "h-7 min-w-[1.75rem] text-xs",
|
|
1410
|
+
medium: "h-8 min-w-[2rem] text-sm",
|
|
1411
|
+
large: "h-10 min-w-[2.5rem] text-base"
|
|
1412
|
+
};
|
|
1413
|
+
const shapeClasses = {
|
|
1414
|
+
circular: "rounded-full",
|
|
1415
|
+
rounded: "rounded-md"
|
|
1416
|
+
};
|
|
1417
|
+
const getButtonClasses = (isActive, isItemDisabled) => {
|
|
1418
|
+
const base = "inline-flex items-center justify-center font-medium select-none transition-colors duration-150 focus:outline-none focus-visible:ring-2 focus-visible:ring-skprimary focus-visible:ring-offset-1 px-1";
|
|
1419
|
+
const sz = sizeClasses[size];
|
|
1420
|
+
const sh = shapeClasses[shape];
|
|
1421
|
+
const borderClass = variant === "outlined" ? isActive ? "border border-skprimary" : "border border-gray-300" : "";
|
|
1422
|
+
let stateClass;
|
|
1423
|
+
if (isActive) {
|
|
1424
|
+
stateClass = cn(
|
|
1425
|
+
"bg-skprimary text-white",
|
|
1426
|
+
isItemDisabled && "opacity-60"
|
|
1427
|
+
);
|
|
1428
|
+
} else if (isItemDisabled) {
|
|
1429
|
+
stateClass = "text-gray-400 cursor-not-allowed";
|
|
1430
|
+
} else {
|
|
1431
|
+
stateClass = "text-gray-700 hover:bg-skprimary/10 hover:text-skprimary cursor-pointer";
|
|
1432
|
+
}
|
|
1433
|
+
return cn(base, sz, sh, borderClass, stateClass);
|
|
1434
|
+
};
|
|
1435
|
+
const handleClick = (targetPage) => {
|
|
1436
|
+
if (!disabled && targetPage !== page && targetPage >= 1 && targetPage <= count) {
|
|
1437
|
+
onChange(targetPage);
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
return /* @__PURE__ */ jsx("nav", { "aria-label": "pagination", className: cn("flex items-center", className), children: /* @__PURE__ */ jsx("ul", { className: "flex items-center gap-1 list-none m-0 p-0", children: items.map((item, index) => {
|
|
1441
|
+
if (item === "start-ellipsis" || item === "end-ellipsis") {
|
|
1442
|
+
return /* @__PURE__ */ jsx("li", { "aria-hidden": "true", children: /* @__PURE__ */ jsx(
|
|
1443
|
+
"span",
|
|
1444
|
+
{
|
|
1445
|
+
className: cn(
|
|
1446
|
+
"inline-flex items-center justify-center text-gray-500",
|
|
1447
|
+
sizeClasses[size]
|
|
1448
|
+
),
|
|
1449
|
+
children: "\u2026"
|
|
1450
|
+
}
|
|
1451
|
+
) }, item);
|
|
1452
|
+
}
|
|
1453
|
+
if (item === "first") {
|
|
1454
|
+
const isItemDisabled = disabled || page <= 1;
|
|
1455
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
1456
|
+
"button",
|
|
1457
|
+
{
|
|
1458
|
+
type: "button",
|
|
1459
|
+
"aria-label": "Go to first page",
|
|
1460
|
+
disabled: isItemDisabled,
|
|
1461
|
+
onClick: () => handleClick(1),
|
|
1462
|
+
className: getButtonClasses(false, isItemDisabled),
|
|
1463
|
+
children: /* @__PURE__ */ jsx(ChevronFirst, { size })
|
|
1464
|
+
}
|
|
1465
|
+
) }, "first");
|
|
1466
|
+
}
|
|
1467
|
+
if (item === "last") {
|
|
1468
|
+
const isItemDisabled = disabled || page >= count;
|
|
1469
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
1470
|
+
"button",
|
|
1471
|
+
{
|
|
1472
|
+
type: "button",
|
|
1473
|
+
"aria-label": "Go to last page",
|
|
1474
|
+
disabled: isItemDisabled,
|
|
1475
|
+
onClick: () => handleClick(count),
|
|
1476
|
+
className: getButtonClasses(false, isItemDisabled),
|
|
1477
|
+
children: /* @__PURE__ */ jsx(ChevronLast, { size })
|
|
1478
|
+
}
|
|
1479
|
+
) }, "last");
|
|
1480
|
+
}
|
|
1481
|
+
if (item === "previous") {
|
|
1482
|
+
const isItemDisabled = disabled || page <= 1;
|
|
1483
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
1484
|
+
"button",
|
|
1485
|
+
{
|
|
1486
|
+
type: "button",
|
|
1487
|
+
"aria-label": "Go to previous page",
|
|
1488
|
+
disabled: isItemDisabled,
|
|
1489
|
+
onClick: () => handleClick(page - 1),
|
|
1490
|
+
className: getButtonClasses(false, isItemDisabled),
|
|
1491
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { size })
|
|
1492
|
+
}
|
|
1493
|
+
) }, "previous");
|
|
1494
|
+
}
|
|
1495
|
+
if (item === "next") {
|
|
1496
|
+
const isItemDisabled = disabled || page >= count;
|
|
1497
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
1498
|
+
"button",
|
|
1499
|
+
{
|
|
1500
|
+
type: "button",
|
|
1501
|
+
"aria-label": "Go to next page",
|
|
1502
|
+
disabled: isItemDisabled,
|
|
1503
|
+
onClick: () => handleClick(page + 1),
|
|
1504
|
+
className: getButtonClasses(false, isItemDisabled),
|
|
1505
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { size })
|
|
1506
|
+
}
|
|
1507
|
+
) }, "next");
|
|
1508
|
+
}
|
|
1509
|
+
const isActive = item === page;
|
|
1510
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
1511
|
+
"button",
|
|
1512
|
+
{
|
|
1513
|
+
type: "button",
|
|
1514
|
+
"aria-label": `Go to page ${item}`,
|
|
1515
|
+
"aria-current": isActive ? "page" : void 0,
|
|
1516
|
+
disabled,
|
|
1517
|
+
onClick: () => handleClick(item),
|
|
1518
|
+
className: getButtonClasses(isActive, disabled && !isActive),
|
|
1519
|
+
children: item
|
|
1520
|
+
}
|
|
1521
|
+
) }, `${item}-${index}`);
|
|
1522
|
+
}) }) });
|
|
1523
|
+
};
|
|
954
1524
|
function ReadMore({
|
|
955
1525
|
readMore,
|
|
956
1526
|
index,
|
|
@@ -1119,6 +1689,302 @@ var StagingAlert = ({
|
|
|
1119
1689
|
] })
|
|
1120
1690
|
] });
|
|
1121
1691
|
};
|
|
1692
|
+
var SCROLL_STEP = 120;
|
|
1693
|
+
function Tabs({
|
|
1694
|
+
value,
|
|
1695
|
+
onChange,
|
|
1696
|
+
children,
|
|
1697
|
+
variant = "standard",
|
|
1698
|
+
scrollButtons = "auto",
|
|
1699
|
+
allowScrollButtonsMobile = false,
|
|
1700
|
+
className,
|
|
1701
|
+
"aria-label": ariaLabel
|
|
1702
|
+
}) {
|
|
1703
|
+
const listRef = useRef(null);
|
|
1704
|
+
const [canScrollLeft, setCanScrollLeft] = useState(false);
|
|
1705
|
+
const [canScrollRight, setCanScrollRight] = useState(false);
|
|
1706
|
+
const tabRefs = useRef([]);
|
|
1707
|
+
const tabs = Children.toArray(children).filter(isValidElement);
|
|
1708
|
+
function resolveIndex(val) {
|
|
1709
|
+
var _a;
|
|
1710
|
+
for (let i = 0; i < tabs.length; i++) {
|
|
1711
|
+
const tabVal = (_a = tabs[i].props.value) != null ? _a : i;
|
|
1712
|
+
if (tabVal === val) return i;
|
|
1713
|
+
}
|
|
1714
|
+
return -1;
|
|
1715
|
+
}
|
|
1716
|
+
const selectedIndex = resolveIndex(value);
|
|
1717
|
+
const updateScrollState = useCallback(() => {
|
|
1718
|
+
const el = listRef.current;
|
|
1719
|
+
if (!el) return;
|
|
1720
|
+
setCanScrollLeft(el.scrollLeft > 0);
|
|
1721
|
+
setCanScrollRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
|
|
1722
|
+
}, []);
|
|
1723
|
+
useEffect(() => {
|
|
1724
|
+
const el = listRef.current;
|
|
1725
|
+
if (!el) return;
|
|
1726
|
+
updateScrollState();
|
|
1727
|
+
el.addEventListener("scroll", updateScrollState);
|
|
1728
|
+
const ro = new ResizeObserver(updateScrollState);
|
|
1729
|
+
ro.observe(el);
|
|
1730
|
+
return () => {
|
|
1731
|
+
el.removeEventListener("scroll", updateScrollState);
|
|
1732
|
+
ro.disconnect();
|
|
1733
|
+
};
|
|
1734
|
+
}, [updateScrollState]);
|
|
1735
|
+
useEffect(() => {
|
|
1736
|
+
const el = tabRefs.current[selectedIndex];
|
|
1737
|
+
el == null ? void 0 : el.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "smooth" });
|
|
1738
|
+
}, [selectedIndex]);
|
|
1739
|
+
const scroll = (dir) => {
|
|
1740
|
+
var _a;
|
|
1741
|
+
(_a = listRef.current) == null ? void 0 : _a.scrollBy({
|
|
1742
|
+
left: dir === "left" ? -SCROLL_STEP : SCROLL_STEP,
|
|
1743
|
+
behavior: "smooth"
|
|
1744
|
+
});
|
|
1745
|
+
};
|
|
1746
|
+
const showButtons = variant === "scrollable" && scrollButtons !== false;
|
|
1747
|
+
const mobileHideClass = allowScrollButtonsMobile ? "" : "hidden sm:flex";
|
|
1748
|
+
const showLeft = showButtons && (scrollButtons === true || scrollButtons === "auto" && canScrollLeft);
|
|
1749
|
+
const showRight = showButtons && (scrollButtons === true || scrollButtons === "auto" && canScrollRight);
|
|
1750
|
+
const listClass = [
|
|
1751
|
+
"relative flex overflow-x-auto overflow-y-hidden scrollbar-none scroll-smooth",
|
|
1752
|
+
variant === "fullWidth" ? "w-full" : ""
|
|
1753
|
+
].join(" ");
|
|
1754
|
+
return /* @__PURE__ */ jsxs(
|
|
1755
|
+
"div",
|
|
1756
|
+
{
|
|
1757
|
+
role: "tablist",
|
|
1758
|
+
"aria-label": ariaLabel,
|
|
1759
|
+
className: [
|
|
1760
|
+
"relative flex items-center border-b border-gray-200",
|
|
1761
|
+
className || ""
|
|
1762
|
+
].join(" "),
|
|
1763
|
+
children: [
|
|
1764
|
+
showLeft && /* @__PURE__ */ jsx(
|
|
1765
|
+
"button",
|
|
1766
|
+
{
|
|
1767
|
+
onClick: () => scroll("left"),
|
|
1768
|
+
"aria-label": "scroll left",
|
|
1769
|
+
className: [
|
|
1770
|
+
"shrink-0 flex items-center justify-center w-8 h-full",
|
|
1771
|
+
"text-gray-500 hover:text-gray-800 transition-colors",
|
|
1772
|
+
mobileHideClass
|
|
1773
|
+
].join(" "),
|
|
1774
|
+
children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) })
|
|
1775
|
+
}
|
|
1776
|
+
),
|
|
1777
|
+
/* @__PURE__ */ jsx("div", { ref: listRef, className: listClass, children: tabs.map((tab, i) => {
|
|
1778
|
+
var _a;
|
|
1779
|
+
const tabValue = (_a = tab.props.value) != null ? _a : i;
|
|
1780
|
+
const selected = tabValue === value;
|
|
1781
|
+
return cloneElement(tab, {
|
|
1782
|
+
key: i,
|
|
1783
|
+
selected,
|
|
1784
|
+
onChange: (e) => {
|
|
1785
|
+
onChange(e, tabValue);
|
|
1786
|
+
},
|
|
1787
|
+
tabRef: (el) => {
|
|
1788
|
+
tabRefs.current[i] = el;
|
|
1789
|
+
},
|
|
1790
|
+
className: [
|
|
1791
|
+
tab.props.className || "",
|
|
1792
|
+
variant === "fullWidth" ? "flex-1" : ""
|
|
1793
|
+
].join(" ").trim(),
|
|
1794
|
+
activeClassName: tab.props.activeClassName
|
|
1795
|
+
});
|
|
1796
|
+
}) }),
|
|
1797
|
+
showRight && /* @__PURE__ */ jsx(
|
|
1798
|
+
"button",
|
|
1799
|
+
{
|
|
1800
|
+
onClick: () => scroll("right"),
|
|
1801
|
+
"aria-label": "scroll right",
|
|
1802
|
+
className: [
|
|
1803
|
+
"shrink-0 flex items-center justify-center w-8 h-full",
|
|
1804
|
+
"text-gray-500 hover:text-gray-800 transition-colors",
|
|
1805
|
+
mobileHideClass
|
|
1806
|
+
].join(" "),
|
|
1807
|
+
children: /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) })
|
|
1808
|
+
}
|
|
1809
|
+
)
|
|
1810
|
+
]
|
|
1811
|
+
}
|
|
1812
|
+
);
|
|
1813
|
+
}
|
|
1814
|
+
function handleAllyProps({ index }) {
|
|
1815
|
+
return {
|
|
1816
|
+
id: `tab-${index}`,
|
|
1817
|
+
"aria-controls": `tabpanel-${index}`
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
function Tab({
|
|
1821
|
+
label,
|
|
1822
|
+
disabled = false,
|
|
1823
|
+
className,
|
|
1824
|
+
activeClassName,
|
|
1825
|
+
selected = false,
|
|
1826
|
+
onChange,
|
|
1827
|
+
tabRef
|
|
1828
|
+
}) {
|
|
1829
|
+
return /* @__PURE__ */ jsx(
|
|
1830
|
+
"button",
|
|
1831
|
+
{
|
|
1832
|
+
ref: tabRef,
|
|
1833
|
+
role: "tab",
|
|
1834
|
+
"aria-selected": selected,
|
|
1835
|
+
disabled,
|
|
1836
|
+
onClick: onChange,
|
|
1837
|
+
className: [
|
|
1838
|
+
"relative shrink-0 inline-flex items-center justify-center",
|
|
1839
|
+
"px-4 py-2 text-sm font-semibold transition-all duration-150 select-none",
|
|
1840
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40",
|
|
1841
|
+
selected ? "text-primary bg-[rgb(218,219,254)] border border-b-0 border-primary rounded-t-lg z-10" : "text-gray-500 hover:text-gray-700 border border-transparent",
|
|
1842
|
+
disabled ? "opacity-40 cursor-not-allowed pointer-events-none" : "cursor-pointer",
|
|
1843
|
+
className || "",
|
|
1844
|
+
selected ? activeClassName || "" : ""
|
|
1845
|
+
].join(" "),
|
|
1846
|
+
children: label
|
|
1847
|
+
}
|
|
1848
|
+
);
|
|
1849
|
+
}
|
|
1850
|
+
var GAP = 8;
|
|
1851
|
+
function computePosition(triggerRect, tooltipEl, placement) {
|
|
1852
|
+
const tw = tooltipEl.offsetWidth;
|
|
1853
|
+
const th = tooltipEl.offsetHeight;
|
|
1854
|
+
const { top, left, right, bottom, width, height } = triggerRect;
|
|
1855
|
+
const map = {
|
|
1856
|
+
top: { top: top - th - GAP, left: left + width / 2 - tw / 2 },
|
|
1857
|
+
"top-start": { top: top - th - GAP, left },
|
|
1858
|
+
"top-end": { top: top - th - GAP, left: right - tw },
|
|
1859
|
+
bottom: { top: bottom + GAP, left: left + width / 2 - tw / 2 },
|
|
1860
|
+
"bottom-start": { top: bottom + GAP, left },
|
|
1861
|
+
"bottom-end": { top: bottom + GAP, left: right - tw },
|
|
1862
|
+
left: { top: top + height / 2 - th / 2, left: left - tw - GAP },
|
|
1863
|
+
"left-start": { top, left: left - tw - GAP },
|
|
1864
|
+
"left-end": { top: bottom - th, left: left - tw - GAP },
|
|
1865
|
+
right: { top: top + height / 2 - th / 2, left: right + GAP },
|
|
1866
|
+
"right-start": { top, left: right + GAP },
|
|
1867
|
+
"right-end": { top: bottom - th, left: right + GAP }
|
|
1868
|
+
};
|
|
1869
|
+
return map[placement];
|
|
1870
|
+
}
|
|
1871
|
+
var arrowSideClass = {
|
|
1872
|
+
top: "bottom-0 left-1/2 -translate-x-1/2 translate-y-full border-t-gray-600/80 border-x-transparent border-b-transparent",
|
|
1873
|
+
bottom: "top-0 left-1/2 -translate-x-1/2 -translate-y-full border-b-gray-600/80 border-x-transparent border-t-transparent",
|
|
1874
|
+
left: "right-0 top-1/2 -translate-y-1/2 translate-x-full border-l-gray-600/80 border-y-transparent border-r-transparent",
|
|
1875
|
+
right: "left-0 top-1/2 -translate-y-1/2 -translate-x-full border-r-gray-600/80 border-y-transparent border-l-transparent"
|
|
1876
|
+
};
|
|
1877
|
+
function Tooltip({
|
|
1878
|
+
title,
|
|
1879
|
+
children,
|
|
1880
|
+
placement = "top",
|
|
1881
|
+
arrow = false,
|
|
1882
|
+
open: controlledOpen,
|
|
1883
|
+
enterDelay = 100,
|
|
1884
|
+
leaveDelay = 0,
|
|
1885
|
+
className,
|
|
1886
|
+
disabled = false
|
|
1887
|
+
}) {
|
|
1888
|
+
const [internalVisible, setInternalVisible] = useState(false);
|
|
1889
|
+
const [coords, setCoords] = useState({ top: 0, left: 0 });
|
|
1890
|
+
const triggerRef = useRef(null);
|
|
1891
|
+
const tooltipRef = useRef(null);
|
|
1892
|
+
const enterTimer = useRef(null);
|
|
1893
|
+
const leaveTimer = useRef(null);
|
|
1894
|
+
const isControlled = controlledOpen !== void 0;
|
|
1895
|
+
const visible = isControlled ? controlledOpen : internalVisible;
|
|
1896
|
+
const updatePosition = useCallback(() => {
|
|
1897
|
+
if (!triggerRef.current || !tooltipRef.current) return;
|
|
1898
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
1899
|
+
const pos = computePosition(rect, tooltipRef.current, placement);
|
|
1900
|
+
setCoords(pos);
|
|
1901
|
+
}, [placement]);
|
|
1902
|
+
useEffect(() => {
|
|
1903
|
+
if (!visible) return;
|
|
1904
|
+
updatePosition();
|
|
1905
|
+
window.addEventListener("scroll", updatePosition, true);
|
|
1906
|
+
window.addEventListener("resize", updatePosition);
|
|
1907
|
+
return () => {
|
|
1908
|
+
window.removeEventListener("scroll", updatePosition, true);
|
|
1909
|
+
window.removeEventListener("resize", updatePosition);
|
|
1910
|
+
};
|
|
1911
|
+
}, [visible, updatePosition]);
|
|
1912
|
+
const show = useCallback(() => {
|
|
1913
|
+
if (disabled || isControlled) return;
|
|
1914
|
+
if (leaveTimer.current) clearTimeout(leaveTimer.current);
|
|
1915
|
+
enterTimer.current = setTimeout(() => setInternalVisible(true), enterDelay);
|
|
1916
|
+
}, [disabled, isControlled, enterDelay]);
|
|
1917
|
+
const hide = useCallback(() => {
|
|
1918
|
+
if (isControlled) return;
|
|
1919
|
+
if (enterTimer.current) clearTimeout(enterTimer.current);
|
|
1920
|
+
leaveTimer.current = setTimeout(
|
|
1921
|
+
() => setInternalVisible(false),
|
|
1922
|
+
leaveDelay
|
|
1923
|
+
);
|
|
1924
|
+
}, [isControlled, leaveDelay]);
|
|
1925
|
+
useEffect(() => {
|
|
1926
|
+
return () => {
|
|
1927
|
+
if (enterTimer.current) clearTimeout(enterTimer.current);
|
|
1928
|
+
if (leaveTimer.current) clearTimeout(leaveTimer.current);
|
|
1929
|
+
};
|
|
1930
|
+
}, []);
|
|
1931
|
+
if (!isValidElement(children)) return children;
|
|
1932
|
+
const child = children;
|
|
1933
|
+
const trigger = cloneElement(child, {
|
|
1934
|
+
ref: triggerRef,
|
|
1935
|
+
onMouseEnter: (e) => {
|
|
1936
|
+
var _a, _b;
|
|
1937
|
+
show();
|
|
1938
|
+
(_b = (_a = child.props).onMouseEnter) == null ? void 0 : _b.call(_a, e);
|
|
1939
|
+
},
|
|
1940
|
+
onMouseLeave: (e) => {
|
|
1941
|
+
var _a, _b;
|
|
1942
|
+
hide();
|
|
1943
|
+
(_b = (_a = child.props).onMouseLeave) == null ? void 0 : _b.call(_a, e);
|
|
1944
|
+
},
|
|
1945
|
+
onFocus: (e) => {
|
|
1946
|
+
var _a, _b;
|
|
1947
|
+
show();
|
|
1948
|
+
(_b = (_a = child.props).onFocus) == null ? void 0 : _b.call(_a, e);
|
|
1949
|
+
},
|
|
1950
|
+
onBlur: (e) => {
|
|
1951
|
+
var _a, _b;
|
|
1952
|
+
hide();
|
|
1953
|
+
(_b = (_a = child.props).onBlur) == null ? void 0 : _b.call(_a, e);
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
const side = placement.split("-")[0];
|
|
1957
|
+
const tooltipNode = visible && title ? /* @__PURE__ */ jsxs(
|
|
1958
|
+
"div",
|
|
1959
|
+
{
|
|
1960
|
+
ref: tooltipRef,
|
|
1961
|
+
role: "tooltip",
|
|
1962
|
+
style: { top: coords.top, left: coords.left },
|
|
1963
|
+
className: [
|
|
1964
|
+
"fixed z-[9999] max-w-[300px] px-2 py-1.5",
|
|
1965
|
+
"bg-gray-600/80 text-white text-xs rounded",
|
|
1966
|
+
"shadow-md pointer-events-none",
|
|
1967
|
+
"animate-in fade-in-0 zoom-in-95 duration-100",
|
|
1968
|
+
className || ""
|
|
1969
|
+
].join(" "),
|
|
1970
|
+
children: [
|
|
1971
|
+
arrow && /* @__PURE__ */ jsx(
|
|
1972
|
+
"span",
|
|
1973
|
+
{
|
|
1974
|
+
className: ["absolute w-0 h-0 border-4", arrowSideClass[side]].join(
|
|
1975
|
+
" "
|
|
1976
|
+
)
|
|
1977
|
+
}
|
|
1978
|
+
),
|
|
1979
|
+
title
|
|
1980
|
+
]
|
|
1981
|
+
}
|
|
1982
|
+
) : null;
|
|
1983
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1984
|
+
trigger,
|
|
1985
|
+
createPortal(tooltipNode, document.body)
|
|
1986
|
+
] });
|
|
1987
|
+
}
|
|
1122
1988
|
function useLocalStorage(key, initialValue) {
|
|
1123
1989
|
const [storedValue, setStoredValue] = useState(() => {
|
|
1124
1990
|
if (typeof window === "undefined") return initialValue;
|
|
@@ -1153,4 +2019,4 @@ function useLocalStorage(key, initialValue) {
|
|
|
1153
2019
|
return [storedValue, setValue, remove];
|
|
1154
2020
|
}
|
|
1155
2021
|
|
|
1156
|
-
export { Accordion, AccordionDetails, AccordionSummary, AutoComplete, Breadcrumb, ButtonLoader, CopyId, CustomAnchor, CustomInput, Drawer, FilterDrawer, InputTitleWithRequired, Modal, ReadMore, SearchBar, StagingAlert, cn, handleCopyTextToClipboard, useLocalStorage };
|
|
2022
|
+
export { Accordion, AccordionDetails, AccordionSummary, AutoComplete, Breadcrumb, ButtonLoader, CopyId, CustomAnchor, CustomInput, Drawer, FilterDrawer, InputTitleWithRequired, Modal, MonthYearPicker, Pagination, ReadMore, SearchBar, StagingAlert, Tab, Tabs, Tooltip, cn, handleAllyProps, handleCopyTextToClipboard, useLocalStorage };
|