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