jett.admin.npmpackage 2.0.35 → 2.0.37
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/README.md +23 -2
- package/dist/index.css +402 -267
- package/dist/index.js +908 -528
- package/dist/index.mjs +911 -539
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -472,7 +472,6 @@ var CustomUpload = ({
|
|
|
472
472
|
};
|
|
473
473
|
|
|
474
474
|
// src/sideBar/SideBar.jsx
|
|
475
|
-
var import_lucide_react8 = require("lucide-react");
|
|
476
475
|
var import_react14 = __toESM(require("react"));
|
|
477
476
|
|
|
478
477
|
// ConstantUI.js
|
|
@@ -634,6 +633,12 @@ var navItemsConstant = [
|
|
|
634
633
|
window.location.href = "/market/";
|
|
635
634
|
}
|
|
636
635
|
},
|
|
636
|
+
{
|
|
637
|
+
label: "AuthMesh",
|
|
638
|
+
onClick: () => {
|
|
639
|
+
window.location.href = "/settings/authmesh";
|
|
640
|
+
}
|
|
641
|
+
},
|
|
637
642
|
{
|
|
638
643
|
label: "Audit",
|
|
639
644
|
onClick: () => {
|
|
@@ -665,102 +670,6 @@ var additionalItemsConstant = [
|
|
|
665
670
|
}
|
|
666
671
|
];
|
|
667
672
|
|
|
668
|
-
// src/sideBar/SideBar.jsx
|
|
669
|
-
var import_js_cookie = __toESM(require("js-cookie"));
|
|
670
|
-
|
|
671
|
-
// src/inputs/CustomSelect.jsx
|
|
672
|
-
var import_react11 = __toESM(require("react"));
|
|
673
|
-
var import_lucide_react5 = require("lucide-react");
|
|
674
|
-
var CustomSelect = ({
|
|
675
|
-
id = "custom-select",
|
|
676
|
-
label,
|
|
677
|
-
value,
|
|
678
|
-
onChange,
|
|
679
|
-
options,
|
|
680
|
-
placeholder = "Select...",
|
|
681
|
-
isRequired = false,
|
|
682
|
-
error,
|
|
683
|
-
heading,
|
|
684
|
-
disabled = false
|
|
685
|
-
}) => {
|
|
686
|
-
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
687
|
-
const [search, setSearch] = (0, import_react11.useState)("");
|
|
688
|
-
const wrapperRef = (0, import_react11.useRef)(null);
|
|
689
|
-
const handleBlur = (e) => {
|
|
690
|
-
var _a;
|
|
691
|
-
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
692
|
-
setOpen(false);
|
|
693
|
-
}
|
|
694
|
-
};
|
|
695
|
-
const filteredOptions = options.filter(
|
|
696
|
-
(opt) => opt.label.toLowerCase().includes(search.toLowerCase())
|
|
697
|
-
);
|
|
698
|
-
const handleSelect = (val) => {
|
|
699
|
-
onChange(val);
|
|
700
|
-
setOpen(false);
|
|
701
|
-
};
|
|
702
|
-
const selectedOption = options.find((opt) => opt.value === value);
|
|
703
|
-
return /* @__PURE__ */ import_react11.default.createElement(
|
|
704
|
-
"div",
|
|
705
|
-
{
|
|
706
|
-
className: "flex flex-col w-full relative",
|
|
707
|
-
ref: wrapperRef,
|
|
708
|
-
tabIndex: disabled ? -1 : 0,
|
|
709
|
-
onBlur: handleBlur,
|
|
710
|
-
id: `${id}-div-1`
|
|
711
|
-
},
|
|
712
|
-
heading && /* @__PURE__ */ import_react11.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
|
|
713
|
-
label && /* @__PURE__ */ import_react11.default.createElement(
|
|
714
|
-
"label",
|
|
715
|
-
{
|
|
716
|
-
className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
|
|
717
|
-
id: `${id}-label-1`
|
|
718
|
-
},
|
|
719
|
-
label,
|
|
720
|
-
" ",
|
|
721
|
-
isRequired && /* @__PURE__ */ import_react11.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
722
|
-
),
|
|
723
|
-
/* @__PURE__ */ import_react11.default.createElement(
|
|
724
|
-
"div",
|
|
725
|
-
{
|
|
726
|
-
onClick: () => !disabled && setOpen((prev) => !prev),
|
|
727
|
-
className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
|
|
728
|
-
${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
|
|
729
|
-
${error ? "border-red-500" : "border-gray-300"}
|
|
730
|
-
`,
|
|
731
|
-
id: `${id}-div-2`
|
|
732
|
-
},
|
|
733
|
-
/* @__PURE__ */ import_react11.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
|
|
734
|
-
/* @__PURE__ */ import_react11.default.createElement(
|
|
735
|
-
import_lucide_react5.ChevronDown,
|
|
736
|
-
{
|
|
737
|
-
className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
|
|
738
|
-
}
|
|
739
|
-
)
|
|
740
|
-
),
|
|
741
|
-
open && !disabled && /* @__PURE__ */ import_react11.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react11.default.createElement(
|
|
742
|
-
"input",
|
|
743
|
-
{
|
|
744
|
-
type: "text",
|
|
745
|
-
value: search,
|
|
746
|
-
onChange: (e) => setSearch(e.target.value),
|
|
747
|
-
placeholder: "Search...",
|
|
748
|
-
className: "flex-1 text-sm focus:outline-none",
|
|
749
|
-
id: `${id}-input-1`
|
|
750
|
-
}
|
|
751
|
-
)), /* @__PURE__ */ import_react11.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react11.default.createElement(
|
|
752
|
-
"li",
|
|
753
|
-
{
|
|
754
|
-
key: opt.value,
|
|
755
|
-
onClick: () => handleSelect(opt.value),
|
|
756
|
-
className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
|
|
757
|
-
id: `${id}-li-1`
|
|
758
|
-
},
|
|
759
|
-
opt.label
|
|
760
|
-
)) : /* @__PURE__ */ import_react11.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
|
|
761
|
-
);
|
|
762
|
-
};
|
|
763
|
-
|
|
764
673
|
// src/utils/cookieHelpers.js
|
|
765
674
|
var JETT_ID_COOKIE_NAME = "jett-id";
|
|
766
675
|
function getCookie(name) {
|
|
@@ -901,14 +810,14 @@ var switchProfile = async (profile) => {
|
|
|
901
810
|
};
|
|
902
811
|
|
|
903
812
|
// src/sideBar/SwitchProfileSection.jsx
|
|
904
|
-
var
|
|
813
|
+
var import_react12 = __toESM(require("react"));
|
|
905
814
|
var import_react_dom2 = require("react-dom");
|
|
906
|
-
var
|
|
815
|
+
var import_lucide_react6 = require("lucide-react");
|
|
907
816
|
|
|
908
817
|
// src/sideBar/LogoutConfirmModal.jsx
|
|
909
|
-
var
|
|
818
|
+
var import_react11 = __toESM(require("react"));
|
|
910
819
|
var import_react_dom = require("react-dom");
|
|
911
|
-
var
|
|
820
|
+
var import_lucide_react5 = require("lucide-react");
|
|
912
821
|
var LogoutConfirmModal = ({
|
|
913
822
|
id = "logout-confirm",
|
|
914
823
|
open,
|
|
@@ -921,14 +830,14 @@ var LogoutConfirmModal = ({
|
|
|
921
830
|
if (e.target === e.currentTarget && !loading) onCancel();
|
|
922
831
|
};
|
|
923
832
|
return (0, import_react_dom.createPortal)(
|
|
924
|
-
/* @__PURE__ */
|
|
833
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
925
834
|
"div",
|
|
926
835
|
{
|
|
927
836
|
className: "fixed inset-0 z-[10000] flex items-center justify-center bg-black/50",
|
|
928
837
|
onClick: handleOverlayClick,
|
|
929
838
|
id: `${id}-overlay`
|
|
930
839
|
},
|
|
931
|
-
/* @__PURE__ */
|
|
840
|
+
/* @__PURE__ */ import_react11.default.createElement("div", { className: "w-[360px] rounded-2xl bg-white dark:bg-[#18181b] p-6 text-center shadow-2xl", id: `${id}-dialog` }, /* @__PURE__ */ import_react11.default.createElement("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-950/40", id: `${id}-icon` }, /* @__PURE__ */ import_react11.default.createElement(import_lucide_react5.LogOut, { className: "text-blue-600", width: 28, height: 28 })), /* @__PURE__ */ import_react11.default.createElement("p", { className: "!text-[22px] !font-semibold text-gray-900 dark:text-white" }, "Are you sure you want to logout?"), /* @__PURE__ */ import_react11.default.createElement("div", { className: "mt-6 flex gap-3" }, /* @__PURE__ */ import_react11.default.createElement(
|
|
932
841
|
"button",
|
|
933
842
|
{
|
|
934
843
|
type: "button",
|
|
@@ -938,7 +847,7 @@ var LogoutConfirmModal = ({
|
|
|
938
847
|
id: `${id}-cancel-button`
|
|
939
848
|
},
|
|
940
849
|
"No, Keep me in"
|
|
941
|
-
), /* @__PURE__ */
|
|
850
|
+
), /* @__PURE__ */ import_react11.default.createElement(
|
|
942
851
|
"button",
|
|
943
852
|
{
|
|
944
853
|
type: "button",
|
|
@@ -963,12 +872,14 @@ var SwitchProfileSection = ({
|
|
|
963
872
|
onManageProfile,
|
|
964
873
|
onProfileSwitch,
|
|
965
874
|
onTmcSettings,
|
|
966
|
-
onLogout
|
|
875
|
+
onLogout,
|
|
876
|
+
collapsed = false,
|
|
877
|
+
scopeLabel = ""
|
|
967
878
|
}) => {
|
|
968
|
-
const [position, setPosition] = (0,
|
|
969
|
-
const [showLogoutConfirm, setShowLogoutConfirm] = (0,
|
|
970
|
-
const [switchingProfileId, setSwitchingProfileId] = (0,
|
|
971
|
-
const [switchError, setSwitchError] = (0,
|
|
879
|
+
const [position, setPosition] = (0, import_react12.useState)(null);
|
|
880
|
+
const [showLogoutConfirm, setShowLogoutConfirm] = (0, import_react12.useState)(false);
|
|
881
|
+
const [switchingProfileId, setSwitchingProfileId] = (0, import_react12.useState)(null);
|
|
882
|
+
const [switchError, setSwitchError] = (0, import_react12.useState)(null);
|
|
972
883
|
const jettIdData = getJettIdCookieData();
|
|
973
884
|
const userName = (jettIdData == null ? void 0 : jettIdData.UserName) || "";
|
|
974
885
|
const userEmail = (jettIdData == null ? void 0 : jettIdData.UserEmail) || "";
|
|
@@ -1001,14 +912,14 @@ var SwitchProfileSection = ({
|
|
|
1001
912
|
setSwitchingProfileId(null);
|
|
1002
913
|
}
|
|
1003
914
|
};
|
|
1004
|
-
(0,
|
|
915
|
+
(0, import_react12.useLayoutEffect)(() => {
|
|
1005
916
|
if (!open || !(anchorRef == null ? void 0 : anchorRef.current)) return;
|
|
1006
917
|
const updatePosition = () => {
|
|
1007
918
|
const rect = anchorRef.current.getBoundingClientRect();
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
bottom: window.innerHeight - rect.bottom
|
|
1011
|
-
|
|
919
|
+
const width = Math.min(296, window.innerWidth - 16);
|
|
920
|
+
setPosition(
|
|
921
|
+
collapsed ? { left: rect.right + 8, bottom: Math.max(8, window.innerHeight - rect.bottom) } : { left: Math.max(8, Math.min(rect.left + 12, window.innerWidth - width - 8)), bottom: window.innerHeight - rect.top - 4 }
|
|
922
|
+
);
|
|
1012
923
|
};
|
|
1013
924
|
updatePosition();
|
|
1014
925
|
window.addEventListener("resize", updatePosition);
|
|
@@ -1017,11 +928,11 @@ var SwitchProfileSection = ({
|
|
|
1017
928
|
window.removeEventListener("resize", updatePosition);
|
|
1018
929
|
window.removeEventListener("scroll", updatePosition, true);
|
|
1019
930
|
};
|
|
1020
|
-
}, [open, anchorRef]);
|
|
1021
|
-
(0,
|
|
931
|
+
}, [open, anchorRef, collapsed]);
|
|
932
|
+
(0, import_react12.useEffect)(() => {
|
|
1022
933
|
if (!open) setSwitchError(null);
|
|
1023
934
|
}, [open]);
|
|
1024
|
-
(0,
|
|
935
|
+
(0, import_react12.useEffect)(() => {
|
|
1025
936
|
if (!switchError) return;
|
|
1026
937
|
const timer = setTimeout(() => setSwitchError(null), 5e3);
|
|
1027
938
|
return () => clearTimeout(timer);
|
|
@@ -1031,66 +942,65 @@ var SwitchProfileSection = ({
|
|
|
1031
942
|
setShowLogoutConfirm(false);
|
|
1032
943
|
onLogout == null ? void 0 : onLogout();
|
|
1033
944
|
};
|
|
1034
|
-
return /* @__PURE__ */
|
|
1035
|
-
/* @__PURE__ */
|
|
945
|
+
return /* @__PURE__ */ import_react12.default.createElement(import_react12.default.Fragment, null, open && (0, import_react_dom2.createPortal)(
|
|
946
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "font-jett", "data-jett-shell": true }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "fixed inset-0 z-[9999]", onClick: onClose, id: `${id}-backdrop`, "aria-hidden": "true" }), /* @__PURE__ */ import_react12.default.createElement(
|
|
1036
947
|
"div",
|
|
1037
948
|
{
|
|
1038
|
-
|
|
949
|
+
role: "dialog",
|
|
950
|
+
"aria-label": "Account",
|
|
951
|
+
className: "fixed z-[9999] flex max-h-[75vh] w-[296px] max-w-[calc(100vw-16px)] flex-col overflow-hidden rounded-[10px] border border-jett-line bg-jett-surface text-jett-ink shadow-jett-pop",
|
|
1039
952
|
style: position ? { left: position.left, bottom: position.bottom } : { left: -9999, bottom: 0 },
|
|
1040
953
|
id: `${id}-panel`
|
|
1041
954
|
},
|
|
1042
|
-
/* @__PURE__ */
|
|
955
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "flex items-center gap-3 p-4", id: `${id}-header` }, /* @__PURE__ */ import_react12.default.createElement("span", { className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-jett-ink-800 text-[15px] font-semibold text-white", id: `${id}-avatar` }, userName ? userName.split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]).join("").toUpperCase() : "A"), /* @__PURE__ */ import_react12.default.createElement("div", { className: "min-w-0 flex-1", id: `${id}-header-text` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "truncate text-[14px] font-medium text-jett-ink-800" }, userName || "Admin"), userEmail && /* @__PURE__ */ import_react12.default.createElement("div", { className: "truncate text-[13px] text-jett-ink-500" }, userEmail), scopeLabel && /* @__PURE__ */ import_react12.default.createElement("span", { className: "mt-1.5 inline-flex rounded-full border border-jett-line bg-jett-fill px-[7px] py-px text-[11px] font-semibold text-jett-ink-600" }, scopeLabel))),
|
|
956
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "flex flex-col gap-0.5 px-2 pb-2" }, /* @__PURE__ */ import_react12.default.createElement(
|
|
1043
957
|
"button",
|
|
1044
958
|
{
|
|
1045
959
|
type: "button",
|
|
1046
960
|
onClick: onManageProfile,
|
|
1047
|
-
className: "
|
|
961
|
+
className: "flex w-full cursor-pointer items-center gap-2.5 rounded-[6px] border-0 bg-transparent p-2 text-left text-[14px] text-jett-ink-700 hover:bg-jett-canvas hover:text-jett-ink",
|
|
1048
962
|
id: `${id}-manage-profile-button`
|
|
1049
963
|
},
|
|
1050
|
-
"
|
|
964
|
+
/* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.UserRound, { width: 16, height: 16, strokeWidth: 1.8, className: "text-jett-ink-400", "aria-hidden": "true" }),
|
|
965
|
+
"Manage profile"
|
|
1051
966
|
)),
|
|
1052
|
-
/* @__PURE__ */
|
|
1053
|
-
/* @__PURE__ */ import_react13.default.createElement("div", { className: "overflow-y-auto scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react13.default.createElement("p", { className: "pb-4 text-[10px] font-bold tracking-wider text-[#737373] uppercase", id: `${id}-markets-label` }, "Your Markets"), switchError && /* @__PURE__ */ import_react13.default.createElement(
|
|
1054
|
-
"div",
|
|
1055
|
-
{
|
|
1056
|
-
className: "mb-3 rounded-lg border border-red-200 dark:border-red-900 bg-red-50 dark:bg-red-950/40 px-3 py-2 text-[12px] font-medium text-red-600",
|
|
1057
|
-
id: `${id}-switch-error`
|
|
1058
|
-
},
|
|
1059
|
-
switchError
|
|
1060
|
-
), /* @__PURE__ */ import_react13.default.createElement("div", { className: "flex flex-col gap-2 pb-4", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react13.default.createElement("p", { className: "px-2 py-2 text-[13px] text-gray-400", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
|
|
967
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "min-h-0 overflow-y-auto border-t border-jett-line-row px-4 py-3 scrollbar-hide", id: `${id}-body` }, /* @__PURE__ */ import_react12.default.createElement("div", { className: "text-[11px] font-semibold uppercase tracking-[0.06em] text-jett-ink-400", id: `${id}-markets-label` }, "Your markets"), switchError && /* @__PURE__ */ import_react12.default.createElement("div", { role: "alert", className: "mt-2 rounded-[6px] border border-[#fca5a5] bg-jett-danger-soft px-3 py-2 text-[12px] font-medium text-jett-danger", id: `${id}-switch-error` }, switchError), /* @__PURE__ */ import_react12.default.createElement("div", { className: "mt-2 flex flex-col gap-1", role: "list", id: `${id}-markets-list` }, markets.length === 0 && /* @__PURE__ */ import_react12.default.createElement("p", { className: "!m-0 py-1 text-[13px] text-jett-ink-500", id: `${id}-markets-empty` }, "No markets available"), markets.map((profile) => {
|
|
1061
968
|
const isCurrent = profile.ProfileId === currentProfileId;
|
|
1062
969
|
const isSwitching = switchingProfileId === profile.ProfileId;
|
|
1063
|
-
return /* @__PURE__ */
|
|
1064
|
-
"
|
|
970
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
971
|
+
"button",
|
|
1065
972
|
{
|
|
1066
973
|
key: profile.ProfileId,
|
|
974
|
+
type: "button",
|
|
975
|
+
role: "listitem",
|
|
1067
976
|
onClick: () => !isCurrent && handleProfileSwitch(profile),
|
|
1068
|
-
|
|
1069
|
-
|
|
977
|
+
disabled: isSwitching || !!switchingProfileId,
|
|
978
|
+
"aria-current": isCurrent || void 0,
|
|
979
|
+
className: `flex w-full items-center justify-between gap-2 rounded-[6px] border px-2.5 py-2 text-left transition-colors ${isCurrent ? "cursor-default border-jett-line bg-jett-fill" : "cursor-pointer border-transparent bg-transparent hover:bg-jett-canvas"} ${isSwitching ? "opacity-60" : ""}`,
|
|
1070
980
|
id: `${id}-market-${profile.ProfileId}`
|
|
1071
981
|
},
|
|
1072
|
-
/* @__PURE__ */
|
|
1073
|
-
isCurrent && /* @__PURE__ */
|
|
1074
|
-
isSwitching && /* @__PURE__ */
|
|
982
|
+
/* @__PURE__ */ import_react12.default.createElement("span", { className: `truncate text-[13px] text-jett-ink ${isCurrent ? "font-semibold" : "font-medium"}` }, profile.EntityName),
|
|
983
|
+
isCurrent && /* @__PURE__ */ import_react12.default.createElement("span", { className: "shrink-0 rounded-full bg-jett-brand-soft px-2 py-px text-[11px] font-semibold text-jett-brand-hover" }, "Signed in"),
|
|
984
|
+
isSwitching && /* @__PURE__ */ import_react12.default.createElement("span", { className: "shrink-0 text-[11px] text-jett-ink-400" }, "Switching\u2026")
|
|
1075
985
|
);
|
|
1076
986
|
}))),
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
|
|
1079
|
-
"div",
|
|
987
|
+
/* @__PURE__ */ import_react12.default.createElement("div", { className: "border-t border-jett-line-row p-2", id: `${id}-footer` }, /* @__PURE__ */ import_react12.default.createElement(
|
|
988
|
+
"button",
|
|
1080
989
|
{
|
|
990
|
+
type: "button",
|
|
1081
991
|
onClick: () => {
|
|
1082
992
|
onClose == null ? void 0 : onClose();
|
|
1083
993
|
setShowLogoutConfirm(true);
|
|
1084
994
|
},
|
|
1085
|
-
className: "flex items-center gap-
|
|
995
|
+
className: "flex w-full cursor-pointer items-center gap-2.5 rounded-[6px] border-0 bg-transparent p-2 text-left text-[14px] font-semibold text-jett-danger hover:bg-jett-danger-soft",
|
|
1086
996
|
id: `${id}-logout`
|
|
1087
997
|
},
|
|
1088
|
-
/* @__PURE__ */
|
|
1089
|
-
|
|
998
|
+
/* @__PURE__ */ import_react12.default.createElement(import_lucide_react6.LogOut, { width: 16, height: 16, strokeWidth: 1.8, "aria-hidden": "true" }),
|
|
999
|
+
"Log out"
|
|
1090
1000
|
))
|
|
1091
1001
|
)),
|
|
1092
1002
|
document.body
|
|
1093
|
-
), /* @__PURE__ */
|
|
1003
|
+
), /* @__PURE__ */ import_react12.default.createElement(
|
|
1094
1004
|
LogoutConfirmModal,
|
|
1095
1005
|
{
|
|
1096
1006
|
id: `${id}-logout-confirm`,
|
|
@@ -1101,11 +1011,339 @@ var SwitchProfileSection = ({
|
|
|
1101
1011
|
));
|
|
1102
1012
|
};
|
|
1103
1013
|
|
|
1014
|
+
// src/sideBar/CommandPalette.jsx
|
|
1015
|
+
var import_react13 = __toESM(require("react"));
|
|
1016
|
+
var import_react_dom3 = require("react-dom");
|
|
1017
|
+
var Kbd = ({ children, raised }) => /* @__PURE__ */ import_react13.default.createElement(
|
|
1018
|
+
"span",
|
|
1019
|
+
{
|
|
1020
|
+
className: `inline-block min-w-[20px] rounded-[4px] border border-jett-line-soft bg-jett-surface px-[5px] text-center text-[11px] leading-[18px] font-medium text-jett-ink-500 ${raised ? "border-b-2 !text-[12px] text-jett-ink-700" : ""}`
|
|
1021
|
+
},
|
|
1022
|
+
children
|
|
1023
|
+
);
|
|
1024
|
+
var CommandPalette = ({ id = "command-palette", open, onClose, commands }) => {
|
|
1025
|
+
const [q, setQ] = (0, import_react13.useState)("");
|
|
1026
|
+
const [idx, setIdx] = (0, import_react13.useState)(0);
|
|
1027
|
+
const inputRef = (0, import_react13.useRef)(null);
|
|
1028
|
+
const listRef = (0, import_react13.useRef)(null);
|
|
1029
|
+
(0, import_react13.useEffect)(() => {
|
|
1030
|
+
if (!open) return;
|
|
1031
|
+
setQ("");
|
|
1032
|
+
setIdx(0);
|
|
1033
|
+
const opener = document.activeElement;
|
|
1034
|
+
const t = setTimeout(() => {
|
|
1035
|
+
var _a;
|
|
1036
|
+
return (_a = inputRef.current) == null ? void 0 : _a.focus();
|
|
1037
|
+
}, 0);
|
|
1038
|
+
return () => {
|
|
1039
|
+
clearTimeout(t);
|
|
1040
|
+
if (opener && opener.focus && document.contains(opener)) opener.focus({ preventScroll: true });
|
|
1041
|
+
};
|
|
1042
|
+
}, [open]);
|
|
1043
|
+
const list = (0, import_react13.useMemo)(() => {
|
|
1044
|
+
const s = q.trim().toLowerCase();
|
|
1045
|
+
return s ? commands.filter((c) => (c.label + " " + (c.sub || "")).toLowerCase().includes(s)) : commands;
|
|
1046
|
+
}, [q, commands]);
|
|
1047
|
+
const cur = Math.min(idx, Math.max(0, list.length - 1));
|
|
1048
|
+
(0, import_react13.useEffect)(() => {
|
|
1049
|
+
var _a, _b;
|
|
1050
|
+
(_b = (_a = listRef.current) == null ? void 0 : _a.querySelector(`[data-idx="${cur}"]`)) == null ? void 0 : _b.scrollIntoView({ block: "nearest" });
|
|
1051
|
+
}, [cur]);
|
|
1052
|
+
if (!open || typeof document === "undefined") return null;
|
|
1053
|
+
const run = (c) => {
|
|
1054
|
+
var _a;
|
|
1055
|
+
onClose();
|
|
1056
|
+
(_a = c == null ? void 0 : c.run) == null ? void 0 : _a.call(c);
|
|
1057
|
+
};
|
|
1058
|
+
const onKey = (e) => {
|
|
1059
|
+
if (e.key === "ArrowDown") {
|
|
1060
|
+
e.preventDefault();
|
|
1061
|
+
setIdx((cur + 1) % Math.max(1, list.length));
|
|
1062
|
+
} else if (e.key === "ArrowUp") {
|
|
1063
|
+
e.preventDefault();
|
|
1064
|
+
setIdx((cur - 1 + list.length) % Math.max(1, list.length));
|
|
1065
|
+
} else if (e.key === "Enter") {
|
|
1066
|
+
e.preventDefault();
|
|
1067
|
+
run(list[cur]);
|
|
1068
|
+
} else if (e.key === "Tab") {
|
|
1069
|
+
e.preventDefault();
|
|
1070
|
+
}
|
|
1071
|
+
};
|
|
1072
|
+
return (0, import_react_dom3.createPortal)(
|
|
1073
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "font-jett", id }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[95] bg-[rgba(17,24,39,0.4)]", onClick: onClose, "aria-hidden": "true" }), /* @__PURE__ */ import_react13.default.createElement(
|
|
1074
|
+
"div",
|
|
1075
|
+
{
|
|
1076
|
+
role: "dialog",
|
|
1077
|
+
"aria-modal": "true",
|
|
1078
|
+
"aria-label": "Command palette",
|
|
1079
|
+
className: "fixed left-1/2 top-[12vh] z-[96] flex w-[calc(100%-32px)] max-w-[560px] -translate-x-1/2 flex-col overflow-hidden rounded-[12px] border border-jett-line bg-jett-surface shadow-jett-pop"
|
|
1080
|
+
},
|
|
1081
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "flex h-[52px] items-center gap-2.5 border-b border-jett-line-row px-4" }, /* @__PURE__ */ import_react13.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react13.default.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ import_react13.default.createElement("path", { d: "m20 20-3.5-3.5" })), /* @__PURE__ */ import_react13.default.createElement(
|
|
1082
|
+
"input",
|
|
1083
|
+
{
|
|
1084
|
+
ref: inputRef,
|
|
1085
|
+
type: "text",
|
|
1086
|
+
role: "combobox",
|
|
1087
|
+
"aria-expanded": "true",
|
|
1088
|
+
"aria-controls": `${id}-list`,
|
|
1089
|
+
"aria-activedescendant": list[cur] ? `${id}-opt-${cur}` : void 0,
|
|
1090
|
+
value: q,
|
|
1091
|
+
onChange: (e) => {
|
|
1092
|
+
setQ(e.target.value);
|
|
1093
|
+
setIdx(0);
|
|
1094
|
+
},
|
|
1095
|
+
onKeyDown: onKey,
|
|
1096
|
+
placeholder: "Search screens and actions",
|
|
1097
|
+
className: "h-full flex-1 border-0 bg-transparent p-0 text-[15px] text-jett-ink outline-none placeholder:text-jett-ink-400"
|
|
1098
|
+
}
|
|
1099
|
+
), /* @__PURE__ */ import_react13.default.createElement(Kbd, null, "Esc")),
|
|
1100
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { ref: listRef, id: `${id}-list`, role: "listbox", className: "flex max-h-[360px] flex-col gap-0.5 overflow-y-auto p-1.5" }, list.map((c, i) => /* @__PURE__ */ import_react13.default.createElement(
|
|
1101
|
+
"button",
|
|
1102
|
+
{
|
|
1103
|
+
key: c.label + (c.sub || ""),
|
|
1104
|
+
id: `${id}-opt-${i}`,
|
|
1105
|
+
"data-idx": i,
|
|
1106
|
+
role: "option",
|
|
1107
|
+
"aria-selected": i === cur,
|
|
1108
|
+
type: "button",
|
|
1109
|
+
tabIndex: -1,
|
|
1110
|
+
onClick: () => run(c),
|
|
1111
|
+
onMouseEnter: () => setIdx(i),
|
|
1112
|
+
className: `flex cursor-pointer items-center gap-3 rounded-[6px] border-0 px-2.5 py-[9px] text-left ${i === cur ? "bg-jett-fill" : "bg-transparent"}`
|
|
1113
|
+
},
|
|
1114
|
+
/* @__PURE__ */ import_react13.default.createElement("span", { className: "min-w-0 flex-1 truncate text-[14px] font-medium text-jett-ink" }, c.label),
|
|
1115
|
+
/* @__PURE__ */ import_react13.default.createElement("span", { className: "text-[12px] text-jett-ink-500" }, c.sub),
|
|
1116
|
+
/* @__PURE__ */ import_react13.default.createElement("span", { className: "flex min-w-[44px] justify-end gap-[3px]" }, (c.keys || []).map((k) => /* @__PURE__ */ import_react13.default.createElement(Kbd, { key: k }, k)))
|
|
1117
|
+
)), !list.length && /* @__PURE__ */ import_react13.default.createElement("div", { className: "px-2.5 py-6 text-center text-[14px] text-jett-ink-500" }, "No matches")),
|
|
1118
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "flex gap-4 border-t border-jett-line-row px-4 py-2.5 text-[12px] text-jett-ink-500" }, /* @__PURE__ */ import_react13.default.createElement("span", null, "\u2191 \u2193 to move"), /* @__PURE__ */ import_react13.default.createElement("span", null, "\u21B5 to open"), /* @__PURE__ */ import_react13.default.createElement("span", null, "? for all shortcuts"))
|
|
1119
|
+
)),
|
|
1120
|
+
document.body
|
|
1121
|
+
);
|
|
1122
|
+
};
|
|
1123
|
+
var ShortcutsSheet = ({ id = "shortcuts-sheet", open, onClose, sections }) => {
|
|
1124
|
+
const closeRef = (0, import_react13.useRef)(null);
|
|
1125
|
+
(0, import_react13.useEffect)(() => {
|
|
1126
|
+
if (!open) return;
|
|
1127
|
+
const opener = document.activeElement;
|
|
1128
|
+
const t = setTimeout(() => {
|
|
1129
|
+
var _a;
|
|
1130
|
+
return (_a = closeRef.current) == null ? void 0 : _a.focus();
|
|
1131
|
+
}, 0);
|
|
1132
|
+
return () => {
|
|
1133
|
+
clearTimeout(t);
|
|
1134
|
+
if (opener && opener.focus && document.contains(opener)) opener.focus({ preventScroll: true });
|
|
1135
|
+
};
|
|
1136
|
+
}, [open]);
|
|
1137
|
+
if (!open || typeof document === "undefined") return null;
|
|
1138
|
+
return (0, import_react_dom3.createPortal)(
|
|
1139
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "font-jett", id }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "fixed inset-0 z-[95] bg-[rgba(17,24,39,0.4)]", onClick: onClose, "aria-hidden": "true" }), /* @__PURE__ */ import_react13.default.createElement(
|
|
1140
|
+
"div",
|
|
1141
|
+
{
|
|
1142
|
+
role: "dialog",
|
|
1143
|
+
"aria-modal": "true",
|
|
1144
|
+
"aria-label": "Keyboard shortcuts",
|
|
1145
|
+
className: "fixed left-1/2 top-1/2 z-[96] max-h-[calc(100vh-64px)] w-[calc(100%-32px)] max-w-[640px] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-[12px] border border-jett-line bg-jett-surface shadow-jett-pop"
|
|
1146
|
+
},
|
|
1147
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "flex items-center justify-between border-b border-jett-line-row px-5 py-4" }, /* @__PURE__ */ import_react13.default.createElement("h2", { className: "!m-0 !text-[16px] !font-semibold text-jett-ink" }, "Keyboard shortcuts"), /* @__PURE__ */ import_react13.default.createElement(
|
|
1148
|
+
"button",
|
|
1149
|
+
{
|
|
1150
|
+
ref: closeRef,
|
|
1151
|
+
type: "button",
|
|
1152
|
+
onClick: onClose,
|
|
1153
|
+
title: "Close",
|
|
1154
|
+
"aria-label": "Close",
|
|
1155
|
+
className: "flex h-8 w-8 cursor-pointer items-center justify-center rounded-[6px] border-0 bg-transparent text-jett-ink-500 hover:bg-jett-fill"
|
|
1156
|
+
},
|
|
1157
|
+
/* @__PURE__ */ import_react13.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react13.default.createElement("path", { d: "M18 6 6 18M6 6l12 12" }))
|
|
1158
|
+
)),
|
|
1159
|
+
/* @__PURE__ */ import_react13.default.createElement("div", { className: "grid grid-cols-[repeat(auto-fit,minmax(260px,1fr))] gap-x-8 gap-y-2 px-5 pb-5 pt-2" }, sections.map((sec) => /* @__PURE__ */ import_react13.default.createElement("div", { key: sec.title, className: "flex flex-col" }, /* @__PURE__ */ import_react13.default.createElement("div", { className: "pb-1.5 pt-3 text-[11px] font-semibold uppercase tracking-[0.06em] text-jett-ink-400" }, sec.title), sec.rows.map((r) => /* @__PURE__ */ import_react13.default.createElement("div", { key: r.label, className: "flex items-center justify-between gap-3 border-b border-jett-line-row py-[7px]" }, /* @__PURE__ */ import_react13.default.createElement("span", { className: "text-[14px] text-jett-ink-700" }, r.label), /* @__PURE__ */ import_react13.default.createElement("span", { className: "flex items-center gap-1" }, r.keys.map((k) => /* @__PURE__ */ import_react13.default.createElement(Kbd, { key: k, raised: true }, k))))))))
|
|
1160
|
+
)),
|
|
1161
|
+
document.body
|
|
1162
|
+
);
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
// src/sideBar/navMatch.js
|
|
1166
|
+
var extractUrlFromOnClick = (onClick) => {
|
|
1167
|
+
if (!onClick || typeof onClick !== "function") return null;
|
|
1168
|
+
const funcString = onClick.toString();
|
|
1169
|
+
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
1170
|
+
if (!match) {
|
|
1171
|
+
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
1172
|
+
}
|
|
1173
|
+
if (match && match[1]) {
|
|
1174
|
+
try {
|
|
1175
|
+
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
1176
|
+
const url = new URL(match[1]);
|
|
1177
|
+
return {
|
|
1178
|
+
pathname: url.pathname,
|
|
1179
|
+
search: url.search,
|
|
1180
|
+
fullPath: url.pathname + url.search
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1183
|
+
if (match[1].startsWith("/")) {
|
|
1184
|
+
const url = new URL(match[1], window.location.origin);
|
|
1185
|
+
return {
|
|
1186
|
+
pathname: url.pathname,
|
|
1187
|
+
search: url.search,
|
|
1188
|
+
fullPath: url.pathname + url.search
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
return null;
|
|
1192
|
+
} catch {
|
|
1193
|
+
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
1194
|
+
if (pathMatch) {
|
|
1195
|
+
return {
|
|
1196
|
+
pathname: pathMatch[1],
|
|
1197
|
+
search: pathMatch[2] || "",
|
|
1198
|
+
fullPath: match[1]
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
return null;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return null;
|
|
1205
|
+
};
|
|
1206
|
+
var currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
1207
|
+
if (!menuUrlData || !currentPath) return false;
|
|
1208
|
+
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
1209
|
+
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
1210
|
+
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
1211
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1212
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
1213
|
+
const menuRole = menuParams.get("role");
|
|
1214
|
+
const currentRole = currentParams.get("role");
|
|
1215
|
+
if (menuRole && currentRole) {
|
|
1216
|
+
return menuRole === currentRole;
|
|
1217
|
+
}
|
|
1218
|
+
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
1219
|
+
return false;
|
|
1220
|
+
}
|
|
1221
|
+
return true;
|
|
1222
|
+
}
|
|
1223
|
+
if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
|
|
1224
|
+
return true;
|
|
1225
|
+
}
|
|
1226
|
+
if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
|
|
1227
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1228
|
+
if (currentPathParam === "supplier-list") {
|
|
1229
|
+
return true;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
|
|
1233
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1234
|
+
if (currentPathParam === "supplier-deals") {
|
|
1235
|
+
return true;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
if (normalizedMenuPath === "/corporate/trips") {
|
|
1239
|
+
if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
|
|
1240
|
+
return true;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
|
|
1244
|
+
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
1245
|
+
if (menuPathParam) {
|
|
1246
|
+
const pathRouteMap = {
|
|
1247
|
+
"offer": "/offer/offer",
|
|
1248
|
+
"voucher": "/voucher/voucher",
|
|
1249
|
+
"tag": "/tags/tags",
|
|
1250
|
+
"special-requests": "/corporate/special-requests",
|
|
1251
|
+
"pricing-policy": "/policies/pricing-policy",
|
|
1252
|
+
"supplier-list": "/supplier",
|
|
1253
|
+
"users": "/users/users"
|
|
1254
|
+
// Consumer Ecosystem Users (no role param)
|
|
1255
|
+
};
|
|
1256
|
+
const expectedRoute = pathRouteMap[menuPathParam];
|
|
1257
|
+
if (expectedRoute) {
|
|
1258
|
+
if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
|
|
1259
|
+
if (menuPathParam === "users") {
|
|
1260
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
1261
|
+
const currentRole = currentParams.get("role");
|
|
1262
|
+
return currentRole !== "admin";
|
|
1263
|
+
}
|
|
1264
|
+
return true;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
if (normalizedCurrentPath === "/orgselector") {
|
|
1269
|
+
const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
|
|
1270
|
+
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1271
|
+
if (menuPathParam2 && currentPathParam) {
|
|
1272
|
+
return menuPathParam2 === currentPathParam;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
1277
|
+
if (menuUrlData.search) {
|
|
1278
|
+
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1279
|
+
const currentParams = new URLSearchParams(currentSearch);
|
|
1280
|
+
for (const [key, value] of menuParams.entries()) {
|
|
1281
|
+
if (key === "auth") {
|
|
1282
|
+
continue;
|
|
1283
|
+
}
|
|
1284
|
+
if (currentParams.get(key) !== value) {
|
|
1285
|
+
return false;
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
return true;
|
|
1289
|
+
}
|
|
1290
|
+
return true;
|
|
1291
|
+
}
|
|
1292
|
+
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
1293
|
+
return true;
|
|
1294
|
+
}
|
|
1295
|
+
return false;
|
|
1296
|
+
};
|
|
1297
|
+
|
|
1104
1298
|
// src/sideBar/SideBar.jsx
|
|
1105
1299
|
var SCOPE_LABELS = {
|
|
1106
1300
|
TMC: "TMC Manager",
|
|
1107
1301
|
TMC_ENTITY: "TMC Entity Manager"
|
|
1108
1302
|
};
|
|
1303
|
+
var LS_COLLAPSED = "jett.sidebar.collapsed";
|
|
1304
|
+
var PHONE_MAX = 768;
|
|
1305
|
+
var AUTO_EXPAND = 1280;
|
|
1306
|
+
var GOTO = [
|
|
1307
|
+
["h", "Home"],
|
|
1308
|
+
["c", "Corporate"],
|
|
1309
|
+
["t", "Trips"],
|
|
1310
|
+
["r", "Special Request"],
|
|
1311
|
+
["b", "Booking & Invoices"],
|
|
1312
|
+
["e", "Pricing Engine"],
|
|
1313
|
+
["l", "Credit Management"],
|
|
1314
|
+
["s", "Suppliers List"],
|
|
1315
|
+
["d", "Supplier Deals"],
|
|
1316
|
+
["w", "Whitelabel"],
|
|
1317
|
+
["m", "Markets"],
|
|
1318
|
+
["p", "Users", "Settings"],
|
|
1319
|
+
["i", "AuthMesh"],
|
|
1320
|
+
["a", "Audit"]
|
|
1321
|
+
];
|
|
1322
|
+
var norm = (s) => String(s || "").trim().toLowerCase();
|
|
1323
|
+
var SOON_RX = /\s*\((coming )?soon\)\s*$/i;
|
|
1324
|
+
var cleanLabel = (s) => String(s || "").replace(SOON_RX, "");
|
|
1325
|
+
var isSoon = (o) => !!o.isDisabled || SOON_RX.test(o.label || "");
|
|
1326
|
+
var MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent || "");
|
|
1327
|
+
var MOD = MAC ? "\u2318" : "Ctrl";
|
|
1328
|
+
var readPref = () => {
|
|
1329
|
+
try {
|
|
1330
|
+
const v = localStorage.getItem(LS_COLLAPSED);
|
|
1331
|
+
return v === null ? null : v === "1";
|
|
1332
|
+
} catch {
|
|
1333
|
+
return null;
|
|
1334
|
+
}
|
|
1335
|
+
};
|
|
1336
|
+
var initials = (name) => String(name || "A").split(/\s+/).filter(Boolean).slice(0, 2).map((p) => p[0]).join("").toUpperCase() || "A";
|
|
1337
|
+
var Chevron = ({ open }) => /* @__PURE__ */ import_react14.default.createElement("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "shrink-0 transition-transform duration-150", style: { transform: open ? "rotate(90deg)" : "none" }, "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "m9 18 6-6-6-6" }));
|
|
1338
|
+
var LogoTile = ({ size = 28 }) => /* @__PURE__ */ import_react14.default.createElement(
|
|
1339
|
+
"div",
|
|
1340
|
+
{
|
|
1341
|
+
className: "flex shrink-0 items-center justify-center rounded-[6px] bg-jett-brand font-bold text-white",
|
|
1342
|
+
style: { width: size, height: size, fontSize: size >= 28 ? 13 : 12 },
|
|
1343
|
+
"aria-hidden": "true"
|
|
1344
|
+
},
|
|
1345
|
+
"J"
|
|
1346
|
+
);
|
|
1109
1347
|
var AppSideBar = ({
|
|
1110
1348
|
id = "side-bar",
|
|
1111
1349
|
username,
|
|
@@ -1122,100 +1360,80 @@ var AppSideBar = ({
|
|
|
1122
1360
|
const [authData, setAuthData] = (0, import_react14.useState)(null);
|
|
1123
1361
|
const [cookieUserName, setCookieUserName] = (0, import_react14.useState)(null);
|
|
1124
1362
|
const [scope, setScope] = (0, import_react14.useState)(null);
|
|
1125
|
-
const [selectedCountry, setSelectedCountry] = (0, import_react14.useState)("dubai");
|
|
1126
1363
|
const [isMobileMenuOpen, setIsMobileMenuOpen] = (0, import_react14.useState)(false);
|
|
1127
1364
|
const [isSwitchProfileOpen, setIsSwitchProfileOpen] = (0, import_react14.useState)(false);
|
|
1128
1365
|
const [openMenus, setOpenMenus] = (0, import_react14.useState)(/* @__PURE__ */ new Set());
|
|
1129
1366
|
const [activeMenuPath, setActiveMenuPath] = (0, import_react14.useState)(null);
|
|
1130
|
-
const [
|
|
1131
|
-
(0, import_react14.
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
const
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1367
|
+
const [width, setWidth] = (0, import_react14.useState)(() => typeof window === "undefined" ? 1440 : window.innerWidth);
|
|
1368
|
+
const [pref, setPref] = (0, import_react14.useState)(readPref);
|
|
1369
|
+
const [fly, setFly] = (0, import_react14.useState)(null);
|
|
1370
|
+
const [palOpen, setPalOpen] = (0, import_react14.useState)(false);
|
|
1371
|
+
const [helpOpen, setHelpOpen] = (0, import_react14.useState)(false);
|
|
1372
|
+
const [ready, setReady] = (0, import_react14.useState)(false);
|
|
1373
|
+
const gPending = (0, import_react14.useRef)(false);
|
|
1374
|
+
const gTimer = (0, import_react14.useRef)(null);
|
|
1375
|
+
const phone = width < PHONE_MAX;
|
|
1376
|
+
const collapsed = !phone && (pref === null ? width < AUTO_EXPAND : pref);
|
|
1140
1377
|
const toggleMenu = (menuKey) => {
|
|
1141
1378
|
setOpenMenus((prev) => {
|
|
1142
|
-
const
|
|
1143
|
-
if (
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
newSet.add(menuKey);
|
|
1147
|
-
}
|
|
1148
|
-
return newSet;
|
|
1379
|
+
const next = new Set(prev);
|
|
1380
|
+
if (next.has(menuKey)) next.delete(menuKey);
|
|
1381
|
+
else next.add(menuKey);
|
|
1382
|
+
return next;
|
|
1149
1383
|
});
|
|
1150
1384
|
};
|
|
1151
|
-
const isMenuOpen = (menuKey) =>
|
|
1152
|
-
|
|
1153
|
-
};
|
|
1385
|
+
const isMenuOpen = (menuKey) => openMenus.has(menuKey);
|
|
1386
|
+
const closeMobileMenu = () => setIsMobileMenuOpen(false);
|
|
1154
1387
|
const handleMenuClick = (item, index, e) => {
|
|
1155
|
-
if (item.isDropDown) {
|
|
1388
|
+
if (item.isDropDown || item.options && item.options.length) {
|
|
1156
1389
|
e.preventDefault();
|
|
1157
|
-
|
|
1158
|
-
toggleMenu(menuKey);
|
|
1159
|
-
setActiveMenuPath(`menu-${index}`);
|
|
1390
|
+
toggleMenu(`menu-${index}`);
|
|
1160
1391
|
} else {
|
|
1161
1392
|
setActiveMenuPath(`menu-${index}`);
|
|
1162
|
-
if (item.onClick)
|
|
1163
|
-
item.onClick(e);
|
|
1164
|
-
}
|
|
1393
|
+
if (item.onClick) item.onClick(e);
|
|
1165
1394
|
closeMobileMenu();
|
|
1166
1395
|
}
|
|
1167
1396
|
};
|
|
1168
|
-
const handleSubMenuClick = (option, optionsIndex,
|
|
1169
|
-
const parentMenuKey = `menu-${
|
|
1170
|
-
setOpenMenus((prev) =>
|
|
1171
|
-
const newSet = new Set(prev);
|
|
1172
|
-
newSet.add(parentMenuKey);
|
|
1173
|
-
return newSet;
|
|
1174
|
-
});
|
|
1397
|
+
const handleSubMenuClick = (option, optionsIndex, parentIndex2, e) => {
|
|
1398
|
+
const parentMenuKey = `menu-${parentIndex2}`;
|
|
1399
|
+
setOpenMenus((prev) => new Set(prev).add(parentMenuKey));
|
|
1175
1400
|
if (option.isDropDown) {
|
|
1176
1401
|
e.preventDefault();
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
|
|
1180
|
-
} else {
|
|
1181
|
-
setActiveMenuPath(`menu-${parentIndex}-option-${optionsIndex}`);
|
|
1182
|
-
if (option.onClick) {
|
|
1183
|
-
option.onClick();
|
|
1184
|
-
}
|
|
1185
|
-
closeMobileMenu();
|
|
1402
|
+
toggleMenu(`menu-${parentIndex2}-option-${optionsIndex}`);
|
|
1403
|
+
return;
|
|
1186
1404
|
}
|
|
1405
|
+
setActiveMenuPath(`menu-${parentIndex2}-option-${optionsIndex}`);
|
|
1406
|
+
setFly(null);
|
|
1407
|
+
if (option.onClick) option.onClick();
|
|
1408
|
+
closeMobileMenu();
|
|
1187
1409
|
};
|
|
1188
|
-
const handleSubSubMenuClick = (subOption,
|
|
1189
|
-
const parentMenuKey = `menu-${parentIndex}`;
|
|
1190
|
-
const subMenuKey = `menu-${parentIndex}-option-${optionsIndex}`;
|
|
1410
|
+
const handleSubSubMenuClick = (subOption, parentIndex2, optionsIndex) => {
|
|
1191
1411
|
setOpenMenus((prev) => {
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
return
|
|
1412
|
+
const next = new Set(prev);
|
|
1413
|
+
next.add(`menu-${parentIndex2}`);
|
|
1414
|
+
next.add(`menu-${parentIndex2}-option-${optionsIndex}`);
|
|
1415
|
+
return next;
|
|
1196
1416
|
});
|
|
1197
|
-
setActiveMenuPath(`menu-${
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
}
|
|
1417
|
+
setActiveMenuPath(`menu-${parentIndex2}-option-${optionsIndex}-sub-${subOption.label}`);
|
|
1418
|
+
setFly(null);
|
|
1419
|
+
if (subOption.onClick) subOption.onClick();
|
|
1201
1420
|
closeMobileMenu();
|
|
1202
1421
|
};
|
|
1203
1422
|
(0, import_react14.useEffect)(() => {
|
|
1204
1423
|
const storedAuthData = localStorage.getItem("authData");
|
|
1205
1424
|
if (storedAuthData) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1425
|
+
try {
|
|
1426
|
+
setAuthData(JSON.parse(storedAuthData));
|
|
1427
|
+
} catch {
|
|
1428
|
+
setAuthData(null);
|
|
1429
|
+
}
|
|
1208
1430
|
}
|
|
1209
|
-
}, [
|
|
1431
|
+
}, []);
|
|
1210
1432
|
(0, import_react14.useEffect)(() => {
|
|
1211
1433
|
const jettIdData = getJettIdCookieData();
|
|
1212
|
-
if (jettIdData == null ? void 0 : jettIdData.UserName)
|
|
1213
|
-
setCookieUserName(jettIdData.UserName);
|
|
1214
|
-
}
|
|
1434
|
+
if (jettIdData == null ? void 0 : jettIdData.UserName) setCookieUserName(jettIdData.UserName);
|
|
1215
1435
|
const cookieScope = getScopeFromJettIdCookie();
|
|
1216
|
-
if (cookieScope)
|
|
1217
|
-
setScope(cookieScope);
|
|
1218
|
-
}
|
|
1436
|
+
if (cookieScope) setScope(cookieScope);
|
|
1219
1437
|
}, []);
|
|
1220
1438
|
(0, import_react14.useEffect)(() => {
|
|
1221
1439
|
if (hasSwitchedProfileThisSession()) return;
|
|
@@ -1233,145 +1451,11 @@ var AppSideBar = ({
|
|
|
1233
1451
|
console.error("Auto TMC profile switch failed:", error);
|
|
1234
1452
|
});
|
|
1235
1453
|
}, []);
|
|
1236
|
-
const extractUrlFromOnClick = (onClick) => {
|
|
1237
|
-
if (!onClick || typeof onClick !== "function") return null;
|
|
1238
|
-
const funcString = onClick.toString();
|
|
1239
|
-
let match = funcString.match(/window\.location\.href\s*=\s*`([^`]+)`/);
|
|
1240
|
-
if (!match) {
|
|
1241
|
-
match = funcString.match(/window\.location\.href\s*=\s*["']([^"']+)["']/);
|
|
1242
|
-
}
|
|
1243
|
-
if (match && match[1]) {
|
|
1244
|
-
try {
|
|
1245
|
-
if (match[1].startsWith("http://") || match[1].startsWith("https://")) {
|
|
1246
|
-
const url = new URL(match[1]);
|
|
1247
|
-
return {
|
|
1248
|
-
pathname: url.pathname,
|
|
1249
|
-
search: url.search,
|
|
1250
|
-
fullPath: url.pathname + url.search
|
|
1251
|
-
};
|
|
1252
|
-
}
|
|
1253
|
-
if (match[1].startsWith("/")) {
|
|
1254
|
-
const url = new URL(match[1], window.location.origin);
|
|
1255
|
-
return {
|
|
1256
|
-
pathname: url.pathname,
|
|
1257
|
-
search: url.search,
|
|
1258
|
-
fullPath: url.pathname + url.search
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
return null;
|
|
1262
|
-
} catch {
|
|
1263
|
-
const pathMatch = match[1].match(/^([^?]+)(\?.*)?$/);
|
|
1264
|
-
if (pathMatch) {
|
|
1265
|
-
return {
|
|
1266
|
-
pathname: pathMatch[1],
|
|
1267
|
-
search: pathMatch[2] || "",
|
|
1268
|
-
fullPath: match[1]
|
|
1269
|
-
};
|
|
1270
|
-
}
|
|
1271
|
-
return null;
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
return null;
|
|
1275
|
-
};
|
|
1276
|
-
const currentUrlMatches = (menuUrlData, currentPath, currentSearch) => {
|
|
1277
|
-
if (!menuUrlData || !currentPath) return false;
|
|
1278
|
-
const normalizedMenuPath = menuUrlData.pathname.replace(/\/$/, "") || "/";
|
|
1279
|
-
const normalizedCurrentPath = currentPath.replace(/\/$/, "") || "/";
|
|
1280
|
-
if (normalizedMenuPath === "/users/users" && normalizedCurrentPath === "/users/users") {
|
|
1281
|
-
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1282
|
-
const currentParams = new URLSearchParams(currentSearch);
|
|
1283
|
-
const menuRole = menuParams.get("role");
|
|
1284
|
-
const currentRole = currentParams.get("role");
|
|
1285
|
-
if (menuRole && currentRole) {
|
|
1286
|
-
return menuRole === currentRole;
|
|
1287
|
-
}
|
|
1288
|
-
if (menuRole && !currentRole || !menuRole && currentRole) {
|
|
1289
|
-
return false;
|
|
1290
|
-
}
|
|
1291
|
-
return true;
|
|
1292
|
-
}
|
|
1293
|
-
if (normalizedMenuPath === "/corporate" && normalizedCurrentPath.startsWith("/org/organizations")) {
|
|
1294
|
-
return true;
|
|
1295
|
-
}
|
|
1296
|
-
if (normalizedMenuPath === "/supplier" && normalizedCurrentPath === "/orgselector") {
|
|
1297
|
-
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1298
|
-
if (currentPathParam === "supplier-list") {
|
|
1299
|
-
return true;
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
if (normalizedMenuPath === "/supplierdeals" && normalizedCurrentPath === "/orgselector") {
|
|
1303
|
-
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1304
|
-
if (currentPathParam === "supplier-deals") {
|
|
1305
|
-
return true;
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
if (normalizedMenuPath === "/corporate/trips") {
|
|
1309
|
-
if (normalizedCurrentPath.startsWith("/tripdetails") || normalizedCurrentPath.startsWith("/offline")) {
|
|
1310
|
-
return true;
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
if (normalizedMenuPath === "/orgselector" && menuUrlData.search) {
|
|
1314
|
-
const menuPathParam = new URLSearchParams(menuUrlData.search).get("path");
|
|
1315
|
-
if (menuPathParam) {
|
|
1316
|
-
const pathRouteMap = {
|
|
1317
|
-
"offer": "/offer/offer",
|
|
1318
|
-
"voucher": "/voucher/voucher",
|
|
1319
|
-
"tag": "/tags/tags",
|
|
1320
|
-
"special-requests": "/corporate/special-requests",
|
|
1321
|
-
"pricing-policy": "/policies/pricing-policy",
|
|
1322
|
-
"supplier-list": "/supplier",
|
|
1323
|
-
"users": "/users/users"
|
|
1324
|
-
// Consumer Ecosystem Users (no role param)
|
|
1325
|
-
};
|
|
1326
|
-
const expectedRoute = pathRouteMap[menuPathParam];
|
|
1327
|
-
if (expectedRoute) {
|
|
1328
|
-
if (normalizedCurrentPath === expectedRoute || normalizedCurrentPath.startsWith(expectedRoute + "/")) {
|
|
1329
|
-
if (menuPathParam === "users") {
|
|
1330
|
-
const currentParams = new URLSearchParams(currentSearch);
|
|
1331
|
-
const currentRole = currentParams.get("role");
|
|
1332
|
-
return currentRole !== "admin";
|
|
1333
|
-
}
|
|
1334
|
-
return true;
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
if (normalizedCurrentPath === "/orgselector") {
|
|
1339
|
-
const menuPathParam2 = new URLSearchParams(menuUrlData.search).get("path");
|
|
1340
|
-
const currentPathParam = new URLSearchParams(currentSearch).get("path");
|
|
1341
|
-
if (menuPathParam2 && currentPathParam) {
|
|
1342
|
-
return menuPathParam2 === currentPathParam;
|
|
1343
|
-
}
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
if (normalizedMenuPath === normalizedCurrentPath) {
|
|
1347
|
-
if (menuUrlData.search) {
|
|
1348
|
-
const menuParams = new URLSearchParams(menuUrlData.search);
|
|
1349
|
-
const currentParams = new URLSearchParams(currentSearch);
|
|
1350
|
-
for (const [key, value] of menuParams.entries()) {
|
|
1351
|
-
if (key === "auth") {
|
|
1352
|
-
continue;
|
|
1353
|
-
}
|
|
1354
|
-
if (currentParams.get(key) !== value) {
|
|
1355
|
-
return false;
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
return true;
|
|
1359
|
-
}
|
|
1360
|
-
return true;
|
|
1361
|
-
}
|
|
1362
|
-
if (normalizedCurrentPath.startsWith(normalizedMenuPath + "/")) {
|
|
1363
|
-
return true;
|
|
1364
|
-
}
|
|
1365
|
-
return false;
|
|
1366
|
-
};
|
|
1367
1454
|
const navItemsLocal = navItems ?? navItemsConstant;
|
|
1368
|
-
|
|
1455
|
+
void (additionalItems ?? additionalItemsConstant);
|
|
1369
1456
|
const logoFromCookie = getLogoFromJettIdCookie();
|
|
1370
1457
|
const logoUrlFromCookie = logoFromCookie ? buildLogoUrl(logoFromCookie.CDNBasePath, logoFromCookie.logoPath) : null;
|
|
1371
|
-
const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(
|
|
1372
|
-
authData.userInfo.CDNBasePath,
|
|
1373
|
-
authData.userInfo.OrgLogo
|
|
1374
|
-
) : null;
|
|
1458
|
+
const logoUrlFromUserInfo = ((_a = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _a.CDNBasePath) && ((_b = authData == null ? void 0 : authData.userInfo) == null ? void 0 : _b.OrgLogo) ? buildLogoUrl(authData.userInfo.CDNBasePath, authData.userInfo.OrgLogo) : null;
|
|
1375
1459
|
const sideBarLogoLocal = sideBarLogo ?? logoUrlFromCookie ?? logoUrlFromUserInfo ?? null;
|
|
1376
1460
|
const detectAndSetActiveMenu = (0, import_react14.useCallback)(() => {
|
|
1377
1461
|
const currentPath = window.location.pathname;
|
|
@@ -1390,15 +1474,13 @@ var AppSideBar = ({
|
|
|
1390
1474
|
if (option.onClick && typeof option.onClick === "function") {
|
|
1391
1475
|
const optionUrlData = extractUrlFromOnClick(option.onClick);
|
|
1392
1476
|
if (optionUrlData && currentUrlMatches(optionUrlData, currentPath, currentSearch)) {
|
|
1393
|
-
|
|
1394
|
-
newOpenMenus.add(menuKey);
|
|
1477
|
+
newOpenMenus.add(`menu-${index}`);
|
|
1395
1478
|
foundActivePath = `menu-${index}-option-${optionsIndex}`;
|
|
1396
1479
|
if (option.options && option.options.length > 0) {
|
|
1397
|
-
option.options.forEach((subOption
|
|
1480
|
+
option.options.forEach((subOption) => {
|
|
1398
1481
|
const subOptionUrlData = extractUrlFromOnClick(subOption.onClick);
|
|
1399
1482
|
if (subOptionUrlData && currentUrlMatches(subOptionUrlData, currentPath, currentSearch)) {
|
|
1400
|
-
|
|
1401
|
-
newOpenMenus.add(subMenuKey);
|
|
1483
|
+
newOpenMenus.add(`menu-${index}-option-${optionsIndex}`);
|
|
1402
1484
|
foundActivePath = `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
1403
1485
|
}
|
|
1404
1486
|
});
|
|
@@ -1413,185 +1495,379 @@ var AppSideBar = ({
|
|
|
1413
1495
|
setActiveMenuPath(foundActivePath);
|
|
1414
1496
|
}
|
|
1415
1497
|
}, [navItemsLocal]);
|
|
1416
|
-
const [currentUrl, setCurrentUrl] = (0, import_react14.useState)(
|
|
1417
|
-
() => window.location.pathname + window.location.search
|
|
1418
|
-
);
|
|
1419
1498
|
(0, import_react14.useEffect)(() => {
|
|
1420
1499
|
detectAndSetActiveMenu();
|
|
1421
|
-
setCurrentUrl(window.location.pathname + window.location.search);
|
|
1422
|
-
}, [detectAndSetActiveMenu]);
|
|
1423
|
-
(0, import_react14.useEffect)(() => {
|
|
1424
1500
|
let lastUrl = window.location.pathname + window.location.search;
|
|
1425
|
-
const
|
|
1501
|
+
const check = () => {
|
|
1426
1502
|
const newUrl = window.location.pathname + window.location.search;
|
|
1427
1503
|
if (newUrl !== lastUrl) {
|
|
1428
1504
|
lastUrl = newUrl;
|
|
1429
|
-
setCurrentUrl(newUrl);
|
|
1430
1505
|
detectAndSetActiveMenu();
|
|
1431
1506
|
}
|
|
1432
1507
|
};
|
|
1433
|
-
window.addEventListener("popstate",
|
|
1434
|
-
const
|
|
1435
|
-
const newUrl = window.location.pathname + window.location.search;
|
|
1436
|
-
if (newUrl !== lastUrl) {
|
|
1437
|
-
handleLocationChange();
|
|
1438
|
-
}
|
|
1439
|
-
}, 250);
|
|
1508
|
+
window.addEventListener("popstate", check);
|
|
1509
|
+
const interval = setInterval(check, 250);
|
|
1440
1510
|
return () => {
|
|
1441
|
-
window.removeEventListener("popstate",
|
|
1442
|
-
clearInterval(
|
|
1511
|
+
window.removeEventListener("popstate", check);
|
|
1512
|
+
clearInterval(interval);
|
|
1443
1513
|
};
|
|
1444
1514
|
}, [detectAndSetActiveMenu]);
|
|
1445
1515
|
(0, import_react14.useEffect)(() => {
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1516
|
+
const onResize = () => {
|
|
1517
|
+
setWidth(window.innerWidth);
|
|
1518
|
+
setFly(null);
|
|
1519
|
+
};
|
|
1520
|
+
window.addEventListener("resize", onResize);
|
|
1521
|
+
const r = requestAnimationFrame(() => requestAnimationFrame(() => setReady(true)));
|
|
1522
|
+
return () => {
|
|
1523
|
+
window.removeEventListener("resize", onResize);
|
|
1524
|
+
cancelAnimationFrame(r);
|
|
1525
|
+
};
|
|
1526
|
+
}, []);
|
|
1527
|
+
(0, import_react14.useEffect)(() => {
|
|
1528
|
+
if (!phone) setIsMobileMenuOpen(false);
|
|
1529
|
+
}, [phone]);
|
|
1530
|
+
const toggleCollapsed = (0, import_react14.useCallback)(() => {
|
|
1531
|
+
if (phone) return;
|
|
1532
|
+
const next = !collapsed;
|
|
1533
|
+
try {
|
|
1534
|
+
localStorage.setItem(LS_COLLAPSED, next ? "1" : "0");
|
|
1535
|
+
} catch {
|
|
1536
|
+
}
|
|
1537
|
+
setPref(next);
|
|
1538
|
+
setFly(null);
|
|
1539
|
+
setIsSwitchProfileOpen(false);
|
|
1540
|
+
}, [phone, collapsed]);
|
|
1541
|
+
const screens = (0, import_react14.useMemo)(() => {
|
|
1542
|
+
const out = [];
|
|
1543
|
+
navItemsLocal.forEach((item) => {
|
|
1544
|
+
if (item.options && item.options.length) {
|
|
1545
|
+
item.options.forEach((o) => {
|
|
1546
|
+
if (!isSoon(o) && o.onClick) out.push({ label: cleanLabel(o.label), group: item.label, run: () => o.onClick() });
|
|
1547
|
+
});
|
|
1548
|
+
} else if (item.onClick) {
|
|
1549
|
+
out.push({ label: cleanLabel(item.label), group: "", run: () => item.onClick() });
|
|
1550
|
+
}
|
|
1551
|
+
});
|
|
1552
|
+
return out;
|
|
1553
|
+
}, [navItemsLocal]);
|
|
1554
|
+
const gotoMap = (0, import_react14.useMemo)(() => {
|
|
1555
|
+
const m = {};
|
|
1556
|
+
GOTO.forEach(([key, label, group]) => {
|
|
1557
|
+
const s = screens.find((x) => norm(x.label) === norm(label) && (!group || norm(x.group) === norm(group)));
|
|
1558
|
+
if (s) m[key] = s;
|
|
1559
|
+
});
|
|
1560
|
+
return m;
|
|
1561
|
+
}, [screens]);
|
|
1562
|
+
const commands = (0, import_react14.useMemo)(() => {
|
|
1563
|
+
const keyOf = new Map(Object.entries(gotoMap).map(([k, s]) => [s, k.toUpperCase()]));
|
|
1564
|
+
const cmds = screens.map((s) => ({ label: s.label, sub: s.group, keys: keyOf.has(s) ? ["G", keyOf.get(s)] : [], run: s.run }));
|
|
1565
|
+
if (!phone) cmds.push({ label: collapsed ? "Expand sidebar" : "Collapse sidebar", sub: "Action", keys: ["["], run: toggleCollapsed });
|
|
1566
|
+
cmds.push({ label: "Keyboard shortcuts", sub: "Help", keys: ["?"], run: () => setHelpOpen(true) });
|
|
1567
|
+
return cmds;
|
|
1568
|
+
}, [screens, gotoMap, phone, collapsed, toggleCollapsed]);
|
|
1569
|
+
const helpSections = (0, import_react14.useMemo)(
|
|
1570
|
+
() => [
|
|
1571
|
+
{
|
|
1572
|
+
title: "Global",
|
|
1573
|
+
rows: [
|
|
1574
|
+
{ label: "Focus search on this page", keys: [MOD, "K"] },
|
|
1575
|
+
{ label: "Focus search (alternative)", keys: ["/"] },
|
|
1576
|
+
{ label: "Jump to any screen or action", keys: [MOD, "\u21E7", "K"] },
|
|
1577
|
+
{ label: "Collapse or expand sidebar", keys: ["["] },
|
|
1578
|
+
{ label: "Close menu, drawer or dialog", keys: ["Esc"] },
|
|
1579
|
+
{ label: "Show this list", keys: ["?"] }
|
|
1580
|
+
]
|
|
1581
|
+
},
|
|
1582
|
+
{ title: "Go to", rows: GOTO.filter(([k]) => gotoMap[k]).map(([k]) => ({ label: gotoMap[k].label, keys: ["G", k.toUpperCase()] })) },
|
|
1583
|
+
{
|
|
1584
|
+
title: "In the palette",
|
|
1585
|
+
rows: [
|
|
1586
|
+
{ label: "Move selection", keys: ["\u2191", "\u2193"] },
|
|
1587
|
+
{ label: "Open selected", keys: ["\u21B5"] }
|
|
1588
|
+
]
|
|
1589
|
+
}
|
|
1590
|
+
],
|
|
1591
|
+
[gotoMap]
|
|
1592
|
+
);
|
|
1593
|
+
const stateRef = (0, import_react14.useRef)({});
|
|
1594
|
+
stateRef.current = { palOpen, helpOpen, fly, isSwitchProfileOpen, isMobileMenuOpen, phone, gotoMap, toggleCollapsed };
|
|
1595
|
+
(0, import_react14.useEffect)(() => {
|
|
1596
|
+
const findSearch = () => Array.from(document.querySelectorAll('main input[type="search"], main input[placeholder^="Search"], input[type="search"], input[placeholder^="Search"]')).find(
|
|
1597
|
+
(el) => el.offsetParent !== null && !el.closest("[data-jett-shell]")
|
|
1598
|
+
);
|
|
1599
|
+
const onKey = (e) => {
|
|
1600
|
+
const s = stateRef.current;
|
|
1601
|
+
const t = e.target;
|
|
1602
|
+
const typing = t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName));
|
|
1603
|
+
const mod = e.metaKey || e.ctrlKey;
|
|
1604
|
+
const key = (e.key || "").toLowerCase();
|
|
1605
|
+
if (mod && key === "k") {
|
|
1606
|
+
e.preventDefault();
|
|
1607
|
+
const el = !e.shiftKey && !s.palOpen ? findSearch() : null;
|
|
1608
|
+
if (el && document.activeElement !== el) {
|
|
1609
|
+
setHelpOpen(false);
|
|
1610
|
+
el.focus();
|
|
1611
|
+
if (el.select) el.select();
|
|
1612
|
+
return;
|
|
1613
|
+
}
|
|
1614
|
+
setHelpOpen(false);
|
|
1615
|
+
setFly(null);
|
|
1616
|
+
setIsSwitchProfileOpen(false);
|
|
1617
|
+
setPalOpen((o) => !o);
|
|
1618
|
+
return;
|
|
1619
|
+
}
|
|
1620
|
+
if (e.key === "Escape") {
|
|
1621
|
+
const close = () => {
|
|
1622
|
+
e.preventDefault();
|
|
1623
|
+
e.stopImmediatePropagation();
|
|
1624
|
+
};
|
|
1625
|
+
if (s.palOpen) return close(), setPalOpen(false);
|
|
1626
|
+
if (s.helpOpen) return close(), setHelpOpen(false);
|
|
1627
|
+
if (s.fly) return close(), setFly(null);
|
|
1628
|
+
if (s.isSwitchProfileOpen) return close(), setIsSwitchProfileOpen(false);
|
|
1629
|
+
if (s.isMobileMenuOpen) return close(), setIsMobileMenuOpen(false);
|
|
1630
|
+
return;
|
|
1631
|
+
}
|
|
1632
|
+
if (typing || mod || e.altKey || s.palOpen) return;
|
|
1633
|
+
if (gPending.current) {
|
|
1634
|
+
gPending.current = false;
|
|
1635
|
+
clearTimeout(gTimer.current);
|
|
1636
|
+
const target = s.gotoMap[key];
|
|
1637
|
+
if (target) {
|
|
1638
|
+
e.preventDefault();
|
|
1639
|
+
target.run();
|
|
1640
|
+
}
|
|
1641
|
+
return;
|
|
1642
|
+
}
|
|
1643
|
+
if (key === "g" && !e.shiftKey) {
|
|
1644
|
+
gPending.current = true;
|
|
1645
|
+
gTimer.current = setTimeout(() => gPending.current = false, 1200);
|
|
1646
|
+
return;
|
|
1647
|
+
}
|
|
1648
|
+
if (e.key === "/") {
|
|
1649
|
+
const el = findSearch();
|
|
1650
|
+
if (el) {
|
|
1651
|
+
e.preventDefault();
|
|
1652
|
+
el.focus();
|
|
1653
|
+
if (el.select) el.select();
|
|
1654
|
+
}
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
if (e.key === "?") {
|
|
1658
|
+
e.preventDefault();
|
|
1659
|
+
setHelpOpen((o) => !o);
|
|
1660
|
+
return;
|
|
1661
|
+
}
|
|
1662
|
+
if (e.key === "[" && !s.phone) {
|
|
1663
|
+
e.preventDefault();
|
|
1664
|
+
s.toggleCollapsed();
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
window.addEventListener("keydown", onKey, true);
|
|
1668
|
+
return () => {
|
|
1669
|
+
window.removeEventListener("keydown", onKey, true);
|
|
1670
|
+
clearTimeout(gTimer.current);
|
|
1671
|
+
};
|
|
1672
|
+
}, []);
|
|
1673
|
+
const parentIndex = activeMenuPath ? Number((/^menu-(\d+)/.exec(activeMenuPath) || [])[1]) : -1;
|
|
1674
|
+
const activeLabel = (() => {
|
|
1675
|
+
var _a2, _b2;
|
|
1676
|
+
if (!activeMenuPath) return "JETT Admin";
|
|
1677
|
+
const m = /^menu-(\d+)(?:-option-(\d+))?/.exec(activeMenuPath);
|
|
1678
|
+
const item = navItemsLocal[Number(m == null ? void 0 : m[1])];
|
|
1679
|
+
if (!item) return "JETT Admin";
|
|
1680
|
+
return cleanLabel(m[2] !== void 0 ? (_b2 = (_a2 = item.options) == null ? void 0 : _a2[Number(m[2])]) == null ? void 0 : _b2.label : item.label) || "JETT Admin";
|
|
1681
|
+
})();
|
|
1682
|
+
const displayName = username || cookieUserName || "Admin";
|
|
1683
|
+
const scopeLabel = SCOPE_LABELS[scope] ?? scope ?? "";
|
|
1684
|
+
const expanded = !collapsed;
|
|
1685
|
+
const openFly = (index, e) => {
|
|
1686
|
+
var _a2, _b2;
|
|
1687
|
+
const r = e.currentTarget.getBoundingClientRect();
|
|
1688
|
+
const n = ((_b2 = (_a2 = navItemsLocal[index]) == null ? void 0 : _a2.options) == null ? void 0 : _b2.length) || 1;
|
|
1689
|
+
const top = Math.max(8, Math.min(r.top - 6, window.innerHeight - (n * 36 + 60)));
|
|
1690
|
+
setIsSwitchProfileOpen(false);
|
|
1691
|
+
setFly((f) => f && f.index === index ? null : { index, top });
|
|
1453
1692
|
};
|
|
1454
|
-
|
|
1693
|
+
const subItemClass = (active, soon) => `flex items-center justify-between gap-2 rounded-[6px] border-0 px-3 text-left !text-[14px] whitespace-nowrap w-full ${phone ? "py-[11px]" : "py-[6px]"} ${soon ? "cursor-default bg-transparent text-jett-ink-400" : active ? "cursor-pointer bg-jett-fill !font-semibold text-jett-ink" : "cursor-pointer bg-transparent !font-medium text-jett-ink-500 hover:bg-jett-fill hover:text-jett-ink"}`;
|
|
1694
|
+
const renderOptions = (item, index, inFlyout) => item.options.map((option, optionsIndex) => {
|
|
1695
|
+
const subKey = `menu-${index}-option-${optionsIndex}`;
|
|
1696
|
+
const active = activeMenuPath === subKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subKey}-`));
|
|
1697
|
+
const soon = isSoon(option);
|
|
1698
|
+
const hasKids = option.options && option.options.length > 0;
|
|
1699
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, id: `${id}-opt-${index}-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1700
|
+
"button",
|
|
1701
|
+
{
|
|
1702
|
+
type: "button",
|
|
1703
|
+
disabled: soon,
|
|
1704
|
+
"aria-disabled": soon || void 0,
|
|
1705
|
+
"aria-current": active && !hasKids ? "page" : void 0,
|
|
1706
|
+
"aria-expanded": hasKids ? isMenuOpen(subKey) : void 0,
|
|
1707
|
+
title: soon ? "Not available yet" : void 0,
|
|
1708
|
+
onClick: (e) => soon ? e.preventDefault() : handleSubMenuClick(option, optionsIndex, index, e),
|
|
1709
|
+
className: `${subItemClass(active, soon)} ${inFlyout ? "!py-[7px] !px-2.5" : ""}`
|
|
1710
|
+
},
|
|
1711
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: "truncate" }, cleanLabel(option.label)),
|
|
1712
|
+
soon && /* @__PURE__ */ import_react14.default.createElement("span", { className: "text-[11px] font-semibold text-jett-ink-400" }, "Soon"),
|
|
1713
|
+
hasKids && /* @__PURE__ */ import_react14.default.createElement(Chevron, { open: isMenuOpen(subKey) })
|
|
1714
|
+
), hasKids && isMenuOpen(subKey) && /* @__PURE__ */ import_react14.default.createElement("div", { className: "ml-3 flex flex-col gap-0.5 border-l border-jett-line pl-2" }, option.options.map((sub, subIndex) => {
|
|
1715
|
+
const subActive = activeMenuPath === `${subKey}-sub-${sub.label}`;
|
|
1716
|
+
return /* @__PURE__ */ import_react14.default.createElement("button", { key: subIndex, type: "button", "aria-current": subActive ? "page" : void 0, onClick: () => handleSubSubMenuClick(sub, index, optionsIndex), className: subItemClass(subActive, false) }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "truncate" }, cleanLabel(sub.label)));
|
|
1717
|
+
})));
|
|
1718
|
+
});
|
|
1719
|
+
const flyItem = fly ? navItemsLocal[fly.index] : null;
|
|
1720
|
+
return /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, phone && /* @__PURE__ */ import_react14.default.createElement("div", { "data-jett-shell": true, className: "font-jett fixed left-0 top-0 z-50 flex h-14 w-full items-center gap-2.5 border-b border-jett-line bg-jett-surface pl-1 pr-2", id: `${id}-div-1` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1455
1721
|
"button",
|
|
1456
1722
|
{
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
"aria-label": "
|
|
1723
|
+
type: "button",
|
|
1724
|
+
onClick: () => setIsMobileMenuOpen(true),
|
|
1725
|
+
"aria-label": "Open menu",
|
|
1726
|
+
title: "Open menu",
|
|
1727
|
+
className: "flex h-11 w-11 cursor-pointer items-center justify-center rounded-[8px] border-0 bg-transparent text-jett-ink-700 hover:bg-jett-fill",
|
|
1460
1728
|
id: `${id}-button-1`
|
|
1461
1729
|
},
|
|
1462
|
-
|
|
1463
|
-
), /* @__PURE__ */ import_react14.default.createElement("
|
|
1464
|
-
"
|
|
1730
|
+
/* @__PURE__ */ import_react14.default.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M4 6h16M4 12h16M4 18h16" }))
|
|
1731
|
+
), sideBarLogoLocal ? /* @__PURE__ */ import_react14.default.createElement("img", { src: sideBarLogoLocal, alt: "Logo", className: "h-[26px] max-w-[96px] object-contain", id: `${id}-img-1` }) : /* @__PURE__ */ import_react14.default.createElement(LogoTile, { size: 26 }), /* @__PURE__ */ import_react14.default.createElement("span", { className: "min-w-0 flex-1 truncate text-[15px] font-semibold text-jett-ink" }, activeLabel), /* @__PURE__ */ import_react14.default.createElement("button", { type: "button", onClick: () => setIsMobileMenuOpen(true), "aria-label": "Account", title: "Account", className: "flex h-11 w-11 cursor-pointer items-center justify-center border-0 bg-transparent" }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-8 w-8 items-center justify-center rounded-full bg-jett-ink-800 text-[12px] font-semibold text-white" }, initials(displayName)))), phone && isMobileMenuOpen && /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed inset-0 z-[69] bg-[rgba(17,24,39,0.5)]", onClick: closeMobileMenu, "aria-hidden": "true", id: `${id}-div-4` }), /* @__PURE__ */ import_react14.default.createElement(
|
|
1732
|
+
"aside",
|
|
1465
1733
|
{
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
width:
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
"div",
|
|
1475
|
-
{
|
|
1476
|
-
className: "fixed inset-0 bg-black/80 bg-opacity-50 z-40 md:hidden",
|
|
1477
|
-
onClick: closeMobileMenu,
|
|
1478
|
-
id: `${id}-div-4`
|
|
1479
|
-
}
|
|
1480
|
-
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1481
|
-
"div",
|
|
1482
|
-
{
|
|
1483
|
-
className: `fixed top-0 left-0 md:relative w-[320px] transition-all ease-in-out delay-100 bg-white dark:bg-[#18181b] border-r border-gray-200 dark:border-[#303036] flex flex-col p-4 pt-20 md:pt-4 h-full max-h-[100vh] xs:max-md:z-40 md:max-lg:w-[280px] ${isMobileMenuOpen ? "translate-x-0" : "-translate-x-full md:translate-x-0"}`,
|
|
1734
|
+
"data-jett-shell": true,
|
|
1735
|
+
"aria-label": "Main navigation",
|
|
1736
|
+
className: `font-jett flex h-screen flex-col border-r border-jett-line bg-jett-surface text-jett-ink ${phone ? "fixed left-0 top-0 z-[70] max-w-[86vw]" : "relative"} ${ready ? "transition-[width,transform] duration-200 ease-in-out" : ""}`,
|
|
1737
|
+
style: {
|
|
1738
|
+
width: phone ? 280 : collapsed ? 64 : 256,
|
|
1739
|
+
transform: phone && !isMobileMenuOpen ? "translateX(-100%)" : "none",
|
|
1740
|
+
boxShadow: phone && isMobileMenuOpen ? "var(--shadow-jett-drawer)" : "none"
|
|
1741
|
+
},
|
|
1484
1742
|
id: `${id}-div-5`
|
|
1485
1743
|
},
|
|
1486
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { className:
|
|
1487
|
-
"
|
|
1744
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: `flex h-16 shrink-0 items-center gap-2.5 border-b border-jett-line-row ${collapsed ? "justify-center px-0" : "px-6"}`, id: `${id}-div-6` }, expanded && sideBarLogoLocal ? /* @__PURE__ */ import_react14.default.createElement("img", { src: sideBarLogoLocal, alt: "Logo", className: "h-8 max-w-[168px] object-contain", id: `${id}-img-2` }) : /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement(LogoTile, null), expanded && /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1 whitespace-nowrap text-[15px] font-semibold tracking-[-0.01em] text-jett-ink" }, "JETT Admin")), phone && /* @__PURE__ */ import_react14.default.createElement(
|
|
1745
|
+
"button",
|
|
1488
1746
|
{
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
className: "
|
|
1494
|
-
|
|
1495
|
-
}
|
|
1496
|
-
))
|
|
1497
|
-
/* @__PURE__ */ import_react14.default.createElement("
|
|
1498
|
-
|
|
1747
|
+
type: "button",
|
|
1748
|
+
onClick: closeMobileMenu,
|
|
1749
|
+
"aria-label": "Close menu",
|
|
1750
|
+
title: "Close menu",
|
|
1751
|
+
className: "-mr-3 ml-auto flex h-11 w-11 cursor-pointer items-center justify-center rounded-[8px] border-0 bg-transparent text-jett-ink-500 hover:bg-jett-fill"
|
|
1752
|
+
},
|
|
1753
|
+
/* @__PURE__ */ import_react14.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "M18 6 6 18M6 6l12 12" }))
|
|
1754
|
+
)),
|
|
1755
|
+
/* @__PURE__ */ import_react14.default.createElement("nav", { className: "flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto overflow-x-hidden px-3 py-4 scrollbar-hide", id: `${id}-div-9` }, expanded ? /* @__PURE__ */ import_react14.default.createElement(
|
|
1756
|
+
"button",
|
|
1757
|
+
{
|
|
1758
|
+
type: "button",
|
|
1759
|
+
onClick: () => {
|
|
1760
|
+
closeMobileMenu();
|
|
1761
|
+
setPalOpen(true);
|
|
1762
|
+
},
|
|
1763
|
+
className: "mb-2.5 flex h-[34px] w-full shrink-0 cursor-pointer items-center gap-2.5 whitespace-nowrap rounded-[6px] border border-jett-line-soft bg-jett-canvas pl-3 pr-2 text-left text-[13px] text-jett-ink-500 hover:border-jett-line-control hover:text-jett-ink-700"
|
|
1764
|
+
},
|
|
1765
|
+
/* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "shrink-0", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "m20 20-3.5-3.5" })),
|
|
1766
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1" }, "Jump to\u2026"),
|
|
1767
|
+
!phone && /* @__PURE__ */ import_react14.default.createElement(Kbd, null, MAC ? "\u21E7\u2318K" : "Ctrl \u21E7 K")
|
|
1768
|
+
) : /* @__PURE__ */ import_react14.default.createElement(
|
|
1769
|
+
"button",
|
|
1770
|
+
{
|
|
1771
|
+
type: "button",
|
|
1772
|
+
onClick: () => setPalOpen(true),
|
|
1773
|
+
title: `Jump to ${MAC ? "\u21E7\u2318K" : "Ctrl \u21E7 K"}`,
|
|
1774
|
+
"aria-label": "Search or jump to",
|
|
1775
|
+
className: "mx-auto mb-2 flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-[8px] border border-jett-line-soft bg-jett-canvas text-jett-ink-500 hover:border-jett-line-control hover:text-jett-ink-700"
|
|
1776
|
+
},
|
|
1777
|
+
/* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("circle", { cx: "11", cy: "11", r: "7" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "m20 20-3.5-3.5" }))
|
|
1778
|
+
), navItemsLocal == null ? void 0 : navItemsLocal.map((item, index) => {
|
|
1499
1779
|
const menuKey = `menu-${index}`;
|
|
1780
|
+
const hasOptions = !!(item.options && item.options.length);
|
|
1500
1781
|
const isOpen = isMenuOpen(menuKey);
|
|
1501
|
-
const
|
|
1502
|
-
|
|
1503
|
-
|
|
1782
|
+
const isParent = index === parentIndex;
|
|
1783
|
+
const Icon = item.Icon;
|
|
1784
|
+
const iconEl = Icon ? /* @__PURE__ */ import_react14.default.createElement(Icon, { width: 18, height: 18, strokeWidth: 1.8, className: `shrink-0 ${isParent ? "text-jett-brand" : "text-jett-ink-400"}`, "aria-hidden": "true" }) : null;
|
|
1785
|
+
if (collapsed) {
|
|
1786
|
+
const flying = fly && fly.index === index;
|
|
1787
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
1788
|
+
"button",
|
|
1789
|
+
{
|
|
1790
|
+
key: index,
|
|
1791
|
+
type: "button",
|
|
1792
|
+
title: item.label,
|
|
1793
|
+
"aria-label": item.label,
|
|
1794
|
+
"aria-haspopup": hasOptions ? "menu" : void 0,
|
|
1795
|
+
"aria-expanded": hasOptions ? !!flying : void 0,
|
|
1796
|
+
onClick: (e) => hasOptions ? openFly(index, e) : handleMenuClick(item, index, e),
|
|
1797
|
+
className: `mx-auto flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-[8px] border-0 ${isParent ? "bg-jett-brand-soft" : flying ? "bg-jett-fill" : "bg-transparent hover:bg-jett-fill"}`,
|
|
1798
|
+
id: `${id}-div-12-${index}`
|
|
1799
|
+
},
|
|
1800
|
+
iconEl
|
|
1801
|
+
);
|
|
1802
|
+
}
|
|
1803
|
+
return /* @__PURE__ */ import_react14.default.createElement("div", { key: index, className: "flex flex-col gap-0.5", id: `${id}-div-11-${index}` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1804
|
+
"button",
|
|
1504
1805
|
{
|
|
1505
|
-
|
|
1806
|
+
type: "button",
|
|
1807
|
+
"aria-expanded": hasOptions ? isOpen : void 0,
|
|
1808
|
+
"aria-current": !hasOptions && isParent ? "page" : void 0,
|
|
1506
1809
|
onClick: (e) => handleMenuClick(item, index, e),
|
|
1507
|
-
|
|
1810
|
+
className: `flex w-full cursor-pointer items-center gap-3 whitespace-nowrap rounded-[6px] border-0 px-3 text-left !text-[14px] ${phone ? "py-3" : "py-2"} ${isParent ? "bg-jett-brand-soft !font-semibold text-jett-brand" : "bg-transparent !font-medium text-jett-ink-700 hover:bg-jett-fill"}`,
|
|
1811
|
+
id: `${id}-div-12-${index}`
|
|
1508
1812
|
},
|
|
1509
|
-
|
|
1510
|
-
/* @__PURE__ */ import_react14.default.createElement("span", { className: "
|
|
1511
|
-
|
|
1512
|
-
),
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
id: `${id}-div-15`
|
|
1517
|
-
},
|
|
1518
|
-
item.options.map((options, optionsIndex) => {
|
|
1519
|
-
const subMenuKey = `menu-${index}-option-${optionsIndex}`;
|
|
1520
|
-
const isSubMenuOpen = isMenuOpen(subMenuKey);
|
|
1521
|
-
const isSubActive = activeMenuPath === subMenuKey || (activeMenuPath == null ? void 0 : activeMenuPath.startsWith(`${subMenuKey}-`));
|
|
1522
|
-
const isDisabled = options.isDisabled;
|
|
1523
|
-
return /* @__PURE__ */ import_react14.default.createElement("div", { key: optionsIndex, className: "", id: `${id}-div-16-${optionsIndex}` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1524
|
-
"div",
|
|
1525
|
-
{
|
|
1526
|
-
className: `group flex items-center gap-3 py-2 px-3 ml-4 mr-2 rounded-md transition-colors duration-200 ${isDisabled ? "cursor-not-allowed opacity-70 text-gray-400 dark:text-gray-500" : `hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-600 dark:text-[#a1a1aa] cursor-pointer ${isSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`}`,
|
|
1527
|
-
onClick: (e) => {
|
|
1528
|
-
if (isDisabled) {
|
|
1529
|
-
e.preventDefault();
|
|
1530
|
-
return;
|
|
1531
|
-
}
|
|
1532
|
-
handleSubMenuClick(options, optionsIndex, index, e);
|
|
1533
|
-
},
|
|
1534
|
-
id: `${id}-div-17-${optionsIndex}`
|
|
1535
|
-
},
|
|
1536
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { id: `${id}-div-18-${optionsIndex}` }),
|
|
1537
|
-
/* @__PURE__ */ import_react14.default.createElement("span", { className: `!font-medium !text-[15px] ${isDisabled ? "!text-[#3f3f46cc] dark:!text-[#a1a1aa]" : "!text-[#3f3f46cc] dark:!text-[#a1a1aa]"}`, id: `${id}-span-2-${optionsIndex}` }, options.label),
|
|
1538
|
-
options.isDropDown && /* @__PURE__ */ import_react14.default.createElement(
|
|
1539
|
-
"div",
|
|
1540
|
-
{
|
|
1541
|
-
className: `ml-auto transition-all delay-75 ${isSubMenuOpen ? "rotate-180" : ""}`,
|
|
1542
|
-
id: `${id}-div-19-${optionsIndex}`
|
|
1543
|
-
},
|
|
1544
|
-
/* @__PURE__ */ import_react14.default.createElement(import_lucide_react8.ChevronDown, { width: 18, height: 18, className: "text-gray-400 dark:text-gray-500" })
|
|
1545
|
-
)
|
|
1546
|
-
), options.options && options.options.length > 0 && /* @__PURE__ */ import_react14.default.createElement(
|
|
1547
|
-
"div",
|
|
1548
|
-
{
|
|
1549
|
-
className: `ml-[20px] overflow-hidden flex flex-col transition-all duration-200 ${isSubMenuOpen ? "max-h-[1000px] min-h-[50px]" : "max-h-0"}`,
|
|
1550
|
-
id: `${id}-div-20-${optionsIndex}`
|
|
1551
|
-
},
|
|
1552
|
-
options.options.map((subOption, subIndex) => {
|
|
1553
|
-
const isSubSubActive = activeMenuPath === `menu-${index}-option-${optionsIndex}-sub-${subOption.label}`;
|
|
1554
|
-
return /* @__PURE__ */ import_react14.default.createElement(
|
|
1555
|
-
"div",
|
|
1556
|
-
{
|
|
1557
|
-
key: subIndex,
|
|
1558
|
-
className: `py-1.5 px-3 rounded-md hover:bg-[#f4f4f5] dark:hover:bg-[#27272a] text-gray-500 dark:text-[#71717a] font-medium text-base cursor-pointer ml-8 mr-2 transition-colors duration-200 ${isSubSubActive ? "bg-[#f4f4f5] dark:bg-[#27272a]" : ""}`,
|
|
1559
|
-
onClick: (e) => handleSubSubMenuClick(subOption, index, optionsIndex, e),
|
|
1560
|
-
id: `${id}-div-21-${subIndex}`
|
|
1561
|
-
},
|
|
1562
|
-
subOption.label
|
|
1563
|
-
);
|
|
1564
|
-
})
|
|
1565
|
-
));
|
|
1566
|
-
})
|
|
1567
|
-
));
|
|
1568
|
-
}))),
|
|
1569
|
-
/* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative mt-auto bg-[#fafafa] dark:bg-[#18181b] sticky bottom-0 mt-2", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1570
|
-
"div",
|
|
1813
|
+
iconEl,
|
|
1814
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1 truncate" }, item.label),
|
|
1815
|
+
hasOptions && /* @__PURE__ */ import_react14.default.createElement("span", { className: isParent ? "text-jett-brand" : "text-jett-ink-400" }, /* @__PURE__ */ import_react14.default.createElement(Chevron, { open: isOpen }))
|
|
1816
|
+
), hasOptions && isOpen && /* @__PURE__ */ import_react14.default.createElement("div", { className: "mb-1 ml-[27px] mt-0.5 flex flex-col gap-0.5 border-l border-jett-line pl-[13px]", id: `${id}-div-15-${index}` }, renderOptions(item, index, false)));
|
|
1817
|
+
})),
|
|
1818
|
+
!phone && /* @__PURE__ */ import_react14.default.createElement("div", { className: `flex shrink-0 flex-wrap gap-1 border-t border-jett-line-row px-3 py-2 ${collapsed ? "justify-center" : ""}` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1819
|
+
"button",
|
|
1571
1820
|
{
|
|
1572
|
-
|
|
1573
|
-
onClick: () =>
|
|
1574
|
-
|
|
1821
|
+
type: "button",
|
|
1822
|
+
onClick: () => setHelpOpen(true),
|
|
1823
|
+
title: "Keyboard shortcuts ?",
|
|
1824
|
+
"aria-label": "Keyboard shortcuts",
|
|
1825
|
+
className: `flex h-9 min-w-10 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-[6px] border-0 bg-transparent text-[13px] font-medium text-jett-ink-500 hover:bg-jett-fill hover:text-jett-ink ${collapsed ? "px-0" : "px-3"}`
|
|
1575
1826
|
},
|
|
1576
|
-
/* @__PURE__ */ import_react14.default.createElement("
|
|
1577
|
-
/* @__PURE__ */ import_react14.default.createElement(
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1827
|
+
/* @__PURE__ */ import_react14.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("rect", { x: "2", y: "6", width: "20", height: "12", rx: "2" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "M6 10h.01M10 10h.01M14 10h.01M18 10h.01M7 14h10" })),
|
|
1828
|
+
expanded && /* @__PURE__ */ import_react14.default.createElement(Kbd, null, "?")
|
|
1829
|
+
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1830
|
+
"button",
|
|
1831
|
+
{
|
|
1832
|
+
type: "button",
|
|
1833
|
+
onClick: toggleCollapsed,
|
|
1834
|
+
title: collapsed ? "Expand sidebar [" : "Collapse sidebar [",
|
|
1835
|
+
"aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
1836
|
+
"aria-pressed": collapsed,
|
|
1837
|
+
className: `flex h-9 min-w-10 cursor-pointer items-center justify-center gap-2.5 whitespace-nowrap rounded-[6px] border-0 bg-transparent text-[13px] font-medium text-jett-ink-500 hover:bg-jett-fill hover:text-jett-ink ${collapsed ? "px-0" : "flex-1 px-3"}`
|
|
1838
|
+
},
|
|
1839
|
+
/* @__PURE__ */ import_react14.default.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", style: { transform: collapsed ? "scaleX(-1)" : "none" }, "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }), /* @__PURE__ */ import_react14.default.createElement("path", { d: "M9 4v16M16 10l-2 2 2 2" })),
|
|
1840
|
+
expanded && /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("span", { className: "flex-1 text-left" }, "Collapse"), /* @__PURE__ */ import_react14.default.createElement(Kbd, null, "["))
|
|
1841
|
+
)),
|
|
1842
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { ref: profileCardRef, className: "relative shrink-0 border-t border-jett-line-row px-3 py-3", id: `${id}-div-22` }, /* @__PURE__ */ import_react14.default.createElement(
|
|
1843
|
+
"button",
|
|
1844
|
+
{
|
|
1845
|
+
type: "button",
|
|
1846
|
+
onClick: () => {
|
|
1847
|
+
setFly(null);
|
|
1848
|
+
setIsSwitchProfileOpen((prev) => !prev);
|
|
1582
1849
|
},
|
|
1583
|
-
|
|
1584
|
-
|
|
1850
|
+
title: displayName,
|
|
1851
|
+
"aria-haspopup": "dialog",
|
|
1852
|
+
"aria-expanded": isSwitchProfileOpen,
|
|
1853
|
+
className: `flex w-full cursor-pointer items-center gap-3 rounded-[8px] border border-transparent text-left ${collapsed ? "justify-center p-0" : "p-2.5"} ${isSwitchProfileOpen ? "bg-jett-fill" : "bg-transparent hover:bg-jett-fill"}`,
|
|
1854
|
+
id: `${id}-div-23`
|
|
1855
|
+
},
|
|
1856
|
+
/* @__PURE__ */ import_react14.default.createElement("span", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-jett-ink-800 text-[13px] font-semibold text-white", id: `${id}-span-3` }, initials(displayName)),
|
|
1857
|
+
expanded && /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("span", { className: "min-w-0 flex-1 whitespace-nowrap" }, /* @__PURE__ */ import_react14.default.createElement("span", { className: "block truncate text-[14px] font-medium text-jett-ink-800", id: `${id}-p-1` }, displayName), scopeLabel && /* @__PURE__ */ import_react14.default.createElement("span", { className: "block truncate text-[12px] text-jett-ink-500", id: `${id}-p-2` }, scopeLabel)), /* @__PURE__ */ import_react14.default.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true" }, /* @__PURE__ */ import_react14.default.createElement("path", { d: "m7 15 5 5 5-5M7 9l5-5 5 5" })))
|
|
1585
1858
|
), /* @__PURE__ */ import_react14.default.createElement(
|
|
1586
1859
|
SwitchProfileSection,
|
|
1587
1860
|
{
|
|
1588
1861
|
id: `${id}-switch-profile`,
|
|
1589
1862
|
open: isSwitchProfileOpen,
|
|
1590
1863
|
anchorRef: profileCardRef,
|
|
1864
|
+
collapsed,
|
|
1865
|
+
scopeLabel,
|
|
1591
1866
|
onClose: () => setIsSwitchProfileOpen(false),
|
|
1592
1867
|
onManageProfile: () => {
|
|
1593
1868
|
setIsSwitchProfileOpen(false);
|
|
1594
|
-
|
|
1869
|
+
if (onManageProfile) onManageProfile();
|
|
1870
|
+
else window.location.href = "/profile";
|
|
1595
1871
|
},
|
|
1596
1872
|
onProfileSwitch: (profile) => {
|
|
1597
1873
|
setIsSwitchProfileOpen(false);
|
|
@@ -1612,7 +1888,18 @@ var AppSideBar = ({
|
|
|
1612
1888
|
}
|
|
1613
1889
|
}
|
|
1614
1890
|
))
|
|
1615
|
-
))
|
|
1891
|
+
), collapsed && flyItem && /* @__PURE__ */ import_react14.default.createElement(import_react14.default.Fragment, null, /* @__PURE__ */ import_react14.default.createElement("div", { className: "fixed inset-0 z-[79]", onClick: () => setFly(null), "aria-hidden": "true" }), /* @__PURE__ */ import_react14.default.createElement(
|
|
1892
|
+
"div",
|
|
1893
|
+
{
|
|
1894
|
+
"data-jett-shell": true,
|
|
1895
|
+
role: "menu",
|
|
1896
|
+
"aria-label": flyItem.label,
|
|
1897
|
+
className: "font-jett fixed z-[80] flex w-[220px] flex-col gap-0.5 rounded-[10px] border border-jett-line bg-jett-surface p-1.5 shadow-jett-pop",
|
|
1898
|
+
style: { left: 72, top: fly.top }
|
|
1899
|
+
},
|
|
1900
|
+
/* @__PURE__ */ import_react14.default.createElement("div", { className: "px-2.5 pb-2 pt-1.5 text-[11px] font-semibold uppercase tracking-[0.06em] text-jett-ink-400" }, flyItem.label),
|
|
1901
|
+
renderOptions(flyItem, fly.index, true)
|
|
1902
|
+
)), /* @__PURE__ */ import_react14.default.createElement(CommandPalette, { id: `${id}-palette`, open: palOpen, onClose: () => setPalOpen(false), commands }), /* @__PURE__ */ import_react14.default.createElement(ShortcutsSheet, { id: `${id}-shortcuts`, open: helpOpen, onClose: () => setHelpOpen(false), sections: helpSections }));
|
|
1616
1903
|
};
|
|
1617
1904
|
|
|
1618
1905
|
// src/RightSheet/RightSheet.jsx
|
|
@@ -1711,8 +1998,101 @@ var CustomTable = ({
|
|
|
1711
1998
|
)), /* @__PURE__ */ import_react16.default.createElement("tbody", { id: `${id}-tbody-1` }, children))));
|
|
1712
1999
|
};
|
|
1713
2000
|
|
|
1714
|
-
// src/inputs/
|
|
2001
|
+
// src/inputs/CustomSelect.jsx
|
|
1715
2002
|
var import_react17 = __toESM(require("react"));
|
|
2003
|
+
var import_lucide_react7 = require("lucide-react");
|
|
2004
|
+
var CustomSelect = ({
|
|
2005
|
+
id = "custom-select",
|
|
2006
|
+
label,
|
|
2007
|
+
value,
|
|
2008
|
+
onChange,
|
|
2009
|
+
options,
|
|
2010
|
+
placeholder = "Select...",
|
|
2011
|
+
isRequired = false,
|
|
2012
|
+
error,
|
|
2013
|
+
heading,
|
|
2014
|
+
disabled = false
|
|
2015
|
+
}) => {
|
|
2016
|
+
const [open, setOpen] = (0, import_react17.useState)(false);
|
|
2017
|
+
const [search, setSearch] = (0, import_react17.useState)("");
|
|
2018
|
+
const wrapperRef = (0, import_react17.useRef)(null);
|
|
2019
|
+
const handleBlur = (e) => {
|
|
2020
|
+
var _a;
|
|
2021
|
+
if (!((_a = wrapperRef.current) == null ? void 0 : _a.contains(e.relatedTarget))) {
|
|
2022
|
+
setOpen(false);
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
const filteredOptions = options.filter(
|
|
2026
|
+
(opt) => opt.label.toLowerCase().includes(search.toLowerCase())
|
|
2027
|
+
);
|
|
2028
|
+
const handleSelect = (val) => {
|
|
2029
|
+
onChange(val);
|
|
2030
|
+
setOpen(false);
|
|
2031
|
+
};
|
|
2032
|
+
const selectedOption = options.find((opt) => opt.value === value);
|
|
2033
|
+
return /* @__PURE__ */ import_react17.default.createElement(
|
|
2034
|
+
"div",
|
|
2035
|
+
{
|
|
2036
|
+
className: "flex flex-col w-full relative",
|
|
2037
|
+
ref: wrapperRef,
|
|
2038
|
+
tabIndex: disabled ? -1 : 0,
|
|
2039
|
+
onBlur: handleBlur,
|
|
2040
|
+
id: `${id}-div-1`
|
|
2041
|
+
},
|
|
2042
|
+
heading && /* @__PURE__ */ import_react17.default.createElement("h3", { className: "text-lg font-semibold mb-1", id: `${id}-h3-1` }, heading),
|
|
2043
|
+
label && /* @__PURE__ */ import_react17.default.createElement(
|
|
2044
|
+
"label",
|
|
2045
|
+
{
|
|
2046
|
+
className: `font-medium text-sm mb-1 ${heading ? "text-[#737373] dark:text-white" : "text-black dark:text-white"}`,
|
|
2047
|
+
id: `${id}-label-1`
|
|
2048
|
+
},
|
|
2049
|
+
label,
|
|
2050
|
+
" ",
|
|
2051
|
+
isRequired && /* @__PURE__ */ import_react17.default.createElement("span", { className: "text-red-500", id: `${id}-span-1` }, "*")
|
|
2052
|
+
),
|
|
2053
|
+
/* @__PURE__ */ import_react17.default.createElement(
|
|
2054
|
+
"div",
|
|
2055
|
+
{
|
|
2056
|
+
onClick: () => !disabled && setOpen((prev) => !prev),
|
|
2057
|
+
className: `flex justify-between items-center rounded-md px-3 py-2 text-sm border h-10 cursor-pointer dark:border-[#303036] dark:bg-[#18181b] dark:text-white
|
|
2058
|
+
${disabled ? "bg-gray-100 text-gray-400" : "bg-white dark:bg-[#18181b] dark:text-white"}
|
|
2059
|
+
${error ? "border-red-500" : "border-gray-300"}
|
|
2060
|
+
`,
|
|
2061
|
+
id: `${id}-div-2`
|
|
2062
|
+
},
|
|
2063
|
+
/* @__PURE__ */ import_react17.default.createElement("span", { className: `${selectedOption ? "text-black dark:text-white" : "text-gray-400 dark:text-white"}`, id: `${id}-span-2` }, selectedOption ? selectedOption.label : placeholder),
|
|
2064
|
+
/* @__PURE__ */ import_react17.default.createElement(
|
|
2065
|
+
import_lucide_react7.ChevronDown,
|
|
2066
|
+
{
|
|
2067
|
+
className: `w-4 h-4 text-gray-500 transition-transform dark:text-white ${open ? "rotate-180" : ""}`
|
|
2068
|
+
}
|
|
2069
|
+
)
|
|
2070
|
+
),
|
|
2071
|
+
open && !disabled && /* @__PURE__ */ import_react17.default.createElement("div", { className: "absolute top-full mt-1 w-full bg-white border border-gray-200 rounded-lg shadow-lg z-10 max-h-60 overflow-y-auto dark:bg-[#18181b] dark:text-white", id: `${id}-div-3` }, /* @__PURE__ */ import_react17.default.createElement("div", { className: "flex items-center gap-2 p-2 border-b border-gray-200", id: `${id}-div-4` }, /* @__PURE__ */ import_react17.default.createElement(import_lucide_react7.Search, { size: 16, className: "text-gray-400" }), /* @__PURE__ */ import_react17.default.createElement(
|
|
2072
|
+
"input",
|
|
2073
|
+
{
|
|
2074
|
+
type: "text",
|
|
2075
|
+
value: search,
|
|
2076
|
+
onChange: (e) => setSearch(e.target.value),
|
|
2077
|
+
placeholder: "Search...",
|
|
2078
|
+
className: "flex-1 text-sm focus:outline-none",
|
|
2079
|
+
id: `${id}-input-1`
|
|
2080
|
+
}
|
|
2081
|
+
)), /* @__PURE__ */ import_react17.default.createElement("ul", { id: `${id}-ul-1` }, filteredOptions.length > 0 ? filteredOptions.map((opt) => /* @__PURE__ */ import_react17.default.createElement(
|
|
2082
|
+
"li",
|
|
2083
|
+
{
|
|
2084
|
+
key: opt.value,
|
|
2085
|
+
onClick: () => handleSelect(opt.value),
|
|
2086
|
+
className: `px-3 py-2 text-sm cursor-pointer hover:bg-gray-100 dark:hover:bg-[#27272a] ${value === opt.value ? "bg-gray-100 font-medium dark:bg-[#27272a] dark:text-white" : ""}`,
|
|
2087
|
+
id: `${id}-li-1`
|
|
2088
|
+
},
|
|
2089
|
+
opt.label
|
|
2090
|
+
)) : /* @__PURE__ */ import_react17.default.createElement("li", { className: "px-3 py-2 text-sm text-gray-400 dark:text-white", id: `${id}-li-2` }, "No results found")))
|
|
2091
|
+
);
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
// src/inputs/Dropdown.jsx
|
|
2095
|
+
var import_react18 = __toESM(require("react"));
|
|
1716
2096
|
var import_react_select = __toESM(require("react-select"));
|
|
1717
2097
|
var isDarkMode = () => typeof document !== "undefined" && document.documentElement.classList.contains("dark");
|
|
1718
2098
|
function buildStyles(isDark, error) {
|
|
@@ -1793,7 +2173,7 @@ function buildStyles(isDark, error) {
|
|
|
1793
2173
|
valueContainer: (base) => ({ ...base, padding: "2px 16px" })
|
|
1794
2174
|
};
|
|
1795
2175
|
}
|
|
1796
|
-
var Dropdown =
|
|
2176
|
+
var Dropdown = import_react18.default.forwardRef(
|
|
1797
2177
|
({
|
|
1798
2178
|
id = "dropdown",
|
|
1799
2179
|
options,
|
|
@@ -1814,9 +2194,9 @@ var Dropdown = import_react17.default.forwardRef(
|
|
|
1814
2194
|
value,
|
|
1815
2195
|
onChange
|
|
1816
2196
|
}, ref) => {
|
|
1817
|
-
const reactId = (0,
|
|
2197
|
+
const reactId = (0, import_react18.useId)();
|
|
1818
2198
|
const isDark = isDarkMode();
|
|
1819
|
-
const styles = (0,
|
|
2199
|
+
const styles = (0, import_react18.useMemo)(() => buildStyles(isDark, !!error), [isDark, error]);
|
|
1820
2200
|
const selectedValue = isMulti ? options.filter((o) => (value ?? []).includes(o.value)) : options.find((o) => o.value === value) ?? null;
|
|
1821
2201
|
const handleChange = (selected) => {
|
|
1822
2202
|
if (isMulti) {
|
|
@@ -1825,7 +2205,7 @@ var Dropdown = import_react17.default.forwardRef(
|
|
|
1825
2205
|
onChange((selected == null ? void 0 : selected.value) ?? null);
|
|
1826
2206
|
}
|
|
1827
2207
|
};
|
|
1828
|
-
return /* @__PURE__ */
|
|
2208
|
+
return /* @__PURE__ */ import_react18.default.createElement("div", { className: `flex flex-col gap-1 w-full ${className ?? ""}`, style, id: `${id}-div-1` }, heading && /* @__PURE__ */ import_react18.default.createElement("h3", { className: "text-lg font-semibold", id: `${id}-h3-1` }, heading), label && /* @__PURE__ */ import_react18.default.createElement(
|
|
1829
2209
|
"label",
|
|
1830
2210
|
{
|
|
1831
2211
|
htmlFor: reactId,
|
|
@@ -1833,8 +2213,8 @@ var Dropdown = import_react17.default.forwardRef(
|
|
|
1833
2213
|
id: `${id}-label-1`
|
|
1834
2214
|
},
|
|
1835
2215
|
label,
|
|
1836
|
-
isRequired && /* @__PURE__ */
|
|
1837
|
-
), /* @__PURE__ */
|
|
2216
|
+
isRequired && /* @__PURE__ */ import_react18.default.createElement("span", { className: "text-red-500 ml-0.5", id: `${id}-span-1` }, "*")
|
|
2217
|
+
), /* @__PURE__ */ import_react18.default.createElement(
|
|
1838
2218
|
import_react_select.default,
|
|
1839
2219
|
{
|
|
1840
2220
|
ref,
|
|
@@ -1859,7 +2239,7 @@ var Dropdown = import_react17.default.forwardRef(
|
|
|
1859
2239
|
Dropdown.displayName = "Dropdown";
|
|
1860
2240
|
|
|
1861
2241
|
// src/Calendar/Calendar.tsx
|
|
1862
|
-
var
|
|
2242
|
+
var import_react19 = __toESM(require("react"));
|
|
1863
2243
|
var import_dates = require("@mantine/dates");
|
|
1864
2244
|
var Calendar = (props) => {
|
|
1865
2245
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
@@ -1883,9 +2263,9 @@ var Calendar = (props) => {
|
|
|
1883
2263
|
datesProviderSettings.locale = locale;
|
|
1884
2264
|
}
|
|
1885
2265
|
const anchorDate = isRange ? ((_a = props.value) == null ? void 0 : _a[0]) ?? ((_b = props.value) == null ? void 0 : _b[1]) ?? ((_c = props.defaultValue) == null ? void 0 : _c[0]) ?? ((_d = props.defaultValue) == null ? void 0 : _d[1]) ?? void 0 : !isDateTime ? props.value ?? props.defaultValue ?? void 0 : void 0;
|
|
1886
|
-
const [displayDate, setDisplayDate] = (0,
|
|
2266
|
+
const [displayDate, setDisplayDate] = (0, import_react19.useState)(anchorDate ?? void 0);
|
|
1887
2267
|
const anchorTime = isRange ? ((_f = (_e = props.value) == null ? void 0 : _e[0]) == null ? void 0 : _f.getTime()) ?? ((_h = (_g = props.value) == null ? void 0 : _g[1]) == null ? void 0 : _h.getTime()) : !isDateTime ? (_i = props.value) == null ? void 0 : _i.getTime() : void 0;
|
|
1888
|
-
(0,
|
|
2268
|
+
(0, import_react19.useEffect)(() => {
|
|
1889
2269
|
if (anchorTime !== void 0) {
|
|
1890
2270
|
setDisplayDate(new Date(anchorTime));
|
|
1891
2271
|
}
|
|
@@ -1908,7 +2288,7 @@ var Calendar = (props) => {
|
|
|
1908
2288
|
onDateChange: setDisplayDate,
|
|
1909
2289
|
style: weekendColorStyle
|
|
1910
2290
|
};
|
|
1911
|
-
return /* @__PURE__ */
|
|
2291
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react19.default.createElement(import_dates.DatePicker, { ...datePickerProps2 }));
|
|
1912
2292
|
}
|
|
1913
2293
|
if (isDateTime) {
|
|
1914
2294
|
const dateTimePickerProps = {
|
|
@@ -1923,7 +2303,7 @@ var Calendar = (props) => {
|
|
|
1923
2303
|
error,
|
|
1924
2304
|
style: weekendColorStyle
|
|
1925
2305
|
};
|
|
1926
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react19.default.createElement(import_dates.DateTimePicker, { ...dateTimePickerProps }));
|
|
1927
2307
|
}
|
|
1928
2308
|
const datePickerProps = {
|
|
1929
2309
|
value: props.value,
|
|
@@ -1938,12 +2318,12 @@ var Calendar = (props) => {
|
|
|
1938
2318
|
onDateChange: setDisplayDate,
|
|
1939
2319
|
style: weekendColorStyle
|
|
1940
2320
|
};
|
|
1941
|
-
return /* @__PURE__ */
|
|
2321
|
+
return /* @__PURE__ */ import_react19.default.createElement(import_dates.DatesProvider, { settings: datesProviderSettings }, /* @__PURE__ */ import_react19.default.createElement(import_dates.DatePicker, { ...datePickerProps }));
|
|
1942
2322
|
};
|
|
1943
2323
|
|
|
1944
2324
|
// src/Pagination/Pagination.jsx
|
|
1945
|
-
var
|
|
1946
|
-
var
|
|
2325
|
+
var import_react20 = __toESM(require("react"));
|
|
2326
|
+
var import_lucide_react8 = require("lucide-react");
|
|
1947
2327
|
var Pagination = ({
|
|
1948
2328
|
id = "pagination",
|
|
1949
2329
|
data = [],
|
|
@@ -1967,26 +2347,26 @@ var Pagination = ({
|
|
|
1967
2347
|
componentProps = {},
|
|
1968
2348
|
...restProps
|
|
1969
2349
|
}) => {
|
|
1970
|
-
const [internalCurrentPage, setInternalCurrentPage] = (0,
|
|
1971
|
-
const [internalItemsPerPage, setInternalItemsPerPage] = (0,
|
|
2350
|
+
const [internalCurrentPage, setInternalCurrentPage] = (0, import_react20.useState)(1);
|
|
2351
|
+
const [internalItemsPerPage, setInternalItemsPerPage] = (0, import_react20.useState)(itemsPerPage);
|
|
1972
2352
|
const isControlled = controlledCurrentPage !== void 0;
|
|
1973
2353
|
const isItemsPerPageControlled = controlledOnItemsPerPageChange !== void 0;
|
|
1974
2354
|
const currentPage = isControlled ? controlledCurrentPage : internalCurrentPage;
|
|
1975
2355
|
const activeItemsPerPage = isItemsPerPageControlled ? itemsPerPage : internalItemsPerPage;
|
|
1976
2356
|
const totalItems = legacyTotalItems !== void 0 ? legacyTotalItems : data.length;
|
|
1977
|
-
const calculatedTotalPages = (0,
|
|
2357
|
+
const calculatedTotalPages = (0, import_react20.useMemo)(() => {
|
|
1978
2358
|
if (totalItems > 0 && activeItemsPerPage > 0) {
|
|
1979
2359
|
return Math.ceil(totalItems / activeItemsPerPage);
|
|
1980
2360
|
}
|
|
1981
2361
|
return 1;
|
|
1982
2362
|
}, [totalItems, activeItemsPerPage]);
|
|
1983
|
-
const paginatedData = (0,
|
|
2363
|
+
const paginatedData = (0, import_react20.useMemo)(() => {
|
|
1984
2364
|
if (!data || data.length === 0) return [];
|
|
1985
2365
|
const startIndex = (currentPage - 1) * activeItemsPerPage;
|
|
1986
2366
|
const endIndex = startIndex + activeItemsPerPage;
|
|
1987
2367
|
return data.slice(startIndex, endIndex);
|
|
1988
2368
|
}, [data, currentPage, activeItemsPerPage]);
|
|
1989
|
-
(0,
|
|
2369
|
+
(0, import_react20.useEffect)(() => {
|
|
1990
2370
|
if (!isControlled && currentPage > calculatedTotalPages && calculatedTotalPages > 0) {
|
|
1991
2371
|
setInternalCurrentPage(1);
|
|
1992
2372
|
}
|
|
@@ -2019,11 +2399,11 @@ var Pagination = ({
|
|
|
2019
2399
|
const endItem = totalItems !== void 0 ? Math.min(currentPage * activeItemsPerPage, totalItems) : null;
|
|
2020
2400
|
const renderContent = () => {
|
|
2021
2401
|
if (Component) {
|
|
2022
|
-
if (
|
|
2402
|
+
if (import_react20.default.isValidElement(Component)) {
|
|
2023
2403
|
const ComponentType = Component.type;
|
|
2024
2404
|
const elementProps = Component.props;
|
|
2025
2405
|
if (isTable) {
|
|
2026
|
-
return /* @__PURE__ */
|
|
2406
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
2027
2407
|
CustomTable,
|
|
2028
2408
|
{
|
|
2029
2409
|
tableHeader,
|
|
@@ -2031,7 +2411,7 @@ var Pagination = ({
|
|
|
2031
2411
|
id: `${id}-custom-table-1`
|
|
2032
2412
|
},
|
|
2033
2413
|
data.map((item, index) => {
|
|
2034
|
-
return /* @__PURE__ */
|
|
2414
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
2035
2415
|
ComponentType,
|
|
2036
2416
|
{
|
|
2037
2417
|
key: item.id || item._id || index,
|
|
@@ -2046,7 +2426,7 @@ var Pagination = ({
|
|
|
2046
2426
|
);
|
|
2047
2427
|
} else {
|
|
2048
2428
|
if (isTable) {
|
|
2049
|
-
return /* @__PURE__ */
|
|
2429
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
2050
2430
|
CustomTable,
|
|
2051
2431
|
{
|
|
2052
2432
|
tableHeader,
|
|
@@ -2054,7 +2434,7 @@ var Pagination = ({
|
|
|
2054
2434
|
id: `${id}-custom-table-2`
|
|
2055
2435
|
},
|
|
2056
2436
|
paginatedData.map((item, index) => {
|
|
2057
|
-
return /* @__PURE__ */
|
|
2437
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
2058
2438
|
ComponentType,
|
|
2059
2439
|
{
|
|
2060
2440
|
key: item.id || item._id || index,
|
|
@@ -2070,7 +2450,7 @@ var Pagination = ({
|
|
|
2070
2450
|
}
|
|
2071
2451
|
}
|
|
2072
2452
|
} else {
|
|
2073
|
-
return /* @__PURE__ */
|
|
2453
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
2074
2454
|
CustomTable,
|
|
2075
2455
|
{
|
|
2076
2456
|
tableHeader,
|
|
@@ -2078,7 +2458,7 @@ var Pagination = ({
|
|
|
2078
2458
|
id: `${id}-custom-table-3`
|
|
2079
2459
|
},
|
|
2080
2460
|
paginatedData.map((item, index) => {
|
|
2081
|
-
return /* @__PURE__ */
|
|
2461
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
2082
2462
|
Component,
|
|
2083
2463
|
{
|
|
2084
2464
|
key: item.id || item._id || index,
|
|
@@ -2094,7 +2474,7 @@ var Pagination = ({
|
|
|
2094
2474
|
}
|
|
2095
2475
|
return null;
|
|
2096
2476
|
};
|
|
2097
|
-
return /* @__PURE__ */
|
|
2477
|
+
return /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, /* @__PURE__ */ import_react20.default.createElement(import_react20.default.Fragment, null, renderContent()), /* @__PURE__ */ import_react20.default.createElement("div", { className: "flex flex-col sm:flex-row justify-between items-center gap-4 px-4 py-3 border-t border-[#e5e5e5] dark:border-[#303036] bg-white dark:bg-[#18181b] z-10", id: `${id}-div-1` }, totalItems !== void 0 && /* @__PURE__ */ import_react20.default.createElement("div", { className: "text-sm text-[#737373] dark:text-white", id: `${id}-div-2` }, "Showing ", startItem, " to ", endItem, " of ", totalItems, " entries"), /* @__PURE__ */ import_react20.default.createElement("div", { className: "flex items-center gap-2", id: `${id}-div-3` }, /* @__PURE__ */ import_react20.default.createElement(
|
|
2098
2478
|
"button",
|
|
2099
2479
|
{
|
|
2100
2480
|
onClick: () => handlePageChange(1),
|
|
@@ -2103,8 +2483,8 @@ var Pagination = ({
|
|
|
2103
2483
|
title: "First page",
|
|
2104
2484
|
id: `${id}-button-1`
|
|
2105
2485
|
},
|
|
2106
|
-
/* @__PURE__ */
|
|
2107
|
-
), /* @__PURE__ */
|
|
2486
|
+
/* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronsLeft, { size: 16 })
|
|
2487
|
+
), /* @__PURE__ */ import_react20.default.createElement(
|
|
2108
2488
|
"button",
|
|
2109
2489
|
{
|
|
2110
2490
|
onClick: () => handlePageChange(currentPage - 1),
|
|
@@ -2113,8 +2493,8 @@ var Pagination = ({
|
|
|
2113
2493
|
title: "Previous page",
|
|
2114
2494
|
id: `${id}-button-2`
|
|
2115
2495
|
},
|
|
2116
|
-
/* @__PURE__ */
|
|
2117
|
-
), getPageNumbers().map((pageNum) => /* @__PURE__ */
|
|
2496
|
+
/* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronLeft, { size: 16 })
|
|
2497
|
+
), getPageNumbers().map((pageNum) => /* @__PURE__ */ import_react20.default.createElement(
|
|
2118
2498
|
"button",
|
|
2119
2499
|
{
|
|
2120
2500
|
key: pageNum,
|
|
@@ -2123,7 +2503,7 @@ var Pagination = ({
|
|
|
2123
2503
|
id: `${id}-button-3`
|
|
2124
2504
|
},
|
|
2125
2505
|
pageNum
|
|
2126
|
-
)), /* @__PURE__ */
|
|
2506
|
+
)), /* @__PURE__ */ import_react20.default.createElement(
|
|
2127
2507
|
"button",
|
|
2128
2508
|
{
|
|
2129
2509
|
onClick: () => handlePageChange(currentPage + 1),
|
|
@@ -2132,8 +2512,8 @@ var Pagination = ({
|
|
|
2132
2512
|
title: "Next page",
|
|
2133
2513
|
id: `${id}-button-4`
|
|
2134
2514
|
},
|
|
2135
|
-
/* @__PURE__ */
|
|
2136
|
-
), /* @__PURE__ */
|
|
2515
|
+
/* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronRight, { size: 16 })
|
|
2516
|
+
), /* @__PURE__ */ import_react20.default.createElement(
|
|
2137
2517
|
"button",
|
|
2138
2518
|
{
|
|
2139
2519
|
onClick: () => handlePageChange(calculatedTotalPages),
|
|
@@ -2142,7 +2522,7 @@ var Pagination = ({
|
|
|
2142
2522
|
title: "Last page",
|
|
2143
2523
|
id: `${id}-button-5`
|
|
2144
2524
|
},
|
|
2145
|
-
/* @__PURE__ */
|
|
2525
|
+
/* @__PURE__ */ import_react20.default.createElement(import_lucide_react8.ChevronsRight, { size: 16 })
|
|
2146
2526
|
))));
|
|
2147
2527
|
};
|
|
2148
2528
|
// Annotate the CommonJS export names for ESM import in node:
|