@mercurjs/admin 2.3.6-canary.4 → 2.3.6-canary.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{api-key-management-detail-P5C3F2D7.js → api-key-management-detail-ULNXV7YJ.js} +2 -2
- package/dist/{api-key-management-list-XV66E2LA.js → api-key-management-list-KPWCB7NX.js} +2 -2
- package/dist/attribute-list-FLTRNSFI.js +1 -1
- package/dist/{campaign-detail-4IEM5BGI.js → campaign-detail-WBWGUSMW.js} +2 -2
- package/dist/{campaign-list-ZRUBHJEA.js → campaign-list-M24QK43I.js} +2 -2
- package/dist/category-detail-3YY7FVY4.js +2 -2
- package/dist/{category-list-LESUC6ZK.js → category-list-AT66O7HI.js} +2 -2
- package/dist/{chunk-AZMXFIDY.js → chunk-7Y7YN7KG.js} +4 -4
- package/dist/{chunk-6ZMSV6PN.js → chunk-B4MSCLHO.js} +1 -1
- package/dist/{chunk-DUFGVZ6H.js → chunk-G4L2EPKT.js} +2 -2
- package/dist/{chunk-GDFMWKL6.js → chunk-HBQ7EHHM.js} +1 -1
- package/dist/{chunk-O3RDRDCO.js → chunk-QOMIRTO4.js} +4 -4
- package/dist/chunk-RX7RU7VV.js +2852 -0
- package/dist/{chunk-HGFMHWPB.js → chunk-SJEMUTO2.js} +1 -1
- package/dist/{chunk-RFENVF7Y.js → chunk-TXEOM3WC.js} +3 -3
- package/dist/{chunk-YM5X7CQL.js → chunk-VWK3K2CI.js} +4 -4
- package/dist/{chunk-VYSTJIAD.js → chunk-ZSXF4PEE.js} +1 -1
- package/dist/{collection-detail-CTXO7RMM.js → collection-detail-N7VZKBIJ.js} +3 -3
- package/dist/{collection-list-MWXFS7UY.js → collection-list-QQJAESFN.js} +3 -3
- package/dist/{commission-rule-detail-LFEZ5U6V.js → commission-rule-detail-CIE6TPXW.js} +2 -2
- package/dist/{commissions-list-PQUFPRZK.js → commissions-list-US6OMDVL.js} +2 -2
- package/dist/{customer-detail-ZYETGMFF.js → customer-detail-CGKGZE2N.js} +2 -2
- package/dist/{customer-group-detail-RPDRZGPZ.js → customer-group-detail-JMBR3D72.js} +2 -2
- package/dist/{customer-group-list-MZ7H4XLD.js → customer-group-list-GYEQ2GTL.js} +2 -2
- package/dist/{customer-list-46W5PJR3.js → customer-list-6X6RQDLK.js} +2 -2
- package/dist/home-RT4EIJFM.js +64 -0
- package/dist/index.js +415 -3196
- package/dist/{inventory-detail-MMONC625.js → inventory-detail-PMJN4E2D.js} +3 -3
- package/dist/{inventory-list-FN7FCI4W.js → inventory-list-XS3OFHLW.js} +2 -2
- package/dist/{location-detail-74247BA4.js → location-detail-DKBNATDD.js} +2 -2
- package/dist/location-list-JJN42JSH.js +1 -1
- package/dist/{marketplace-detail-JSUMZVZS.js → marketplace-detail-UYBZIFQW.js} +2 -2
- package/dist/{offers-6MDVGCJK.js → offers-RS4UORI3.js} +3 -3
- package/dist/{order-detail-U3HDRBBG.js → order-detail-XYHRY25Y.js} +3 -3
- package/dist/pages/index.js +53 -53
- package/dist/{price-list-create-RNVWVB5D.js → price-list-create-DRKZIV2D.js} +3 -3
- package/dist/{price-list-detail-WHJKFDYZ.js → price-list-detail-AML5XNDJ.js} +4 -4
- package/dist/{price-list-list-AM2GMQ7P.js → price-list-list-FPCLLS33.js} +2 -2
- package/dist/{price-list-prices-add-ZDKNOJRU.js → price-list-prices-add-HAYZV2XV.js} +3 -3
- package/dist/product-add-existing-attributes-VWM3LNIO.js +1 -1
- package/dist/{product-create-NVAKRIPS.js → product-create-73WXVANY.js} +2 -2
- package/dist/{product-detail-DZRYNPRT.js → product-detail-ZKQXB7PH.js} +3 -3
- package/dist/product-list-SYMPZR6W.js +2 -2
- package/dist/{product-tag-detail-HM2AWFGU.js → product-tag-detail-Q3CKJBVX.js} +3 -3
- package/dist/{product-tag-list-OBV7CZZL.js → product-tag-list-BNNJS67H.js} +3 -3
- package/dist/{product-type-detail-D3OYCXGR.js → product-type-detail-WZLA27WI.js} +3 -3
- package/dist/{product-type-list-LCLWJPIT.js → product-type-list-PAAE6ZSR.js} +2 -2
- package/dist/product-variant-detail-7B26FRNG.js +1 -1
- package/dist/{profile-detail-TQWGKYRK.js → profile-detail-GDQQJUWF.js} +2 -2
- package/dist/{promotion-detail-IC5LHRSY.js → promotion-detail-HOXUK5VG.js} +2 -2
- package/dist/{promotion-list-TVTDBBJ3.js → promotion-list-LJKKLZNU.js} +2 -2
- package/dist/{region-detail-IBLHFR57.js → region-detail-YTB7OEQU.js} +2 -2
- package/dist/{region-list-JTR3SEWI.js → region-list-JP3CZISQ.js} +2 -2
- package/dist/{reservation-detail-OCIIVYIN.js → reservation-detail-M42OB6BC.js} +2 -2
- package/dist/{reservation-list-JQFVSRW5.js → reservation-list-FQAWE7S5.js} +2 -2
- package/dist/return-reason-list-PKAJDA6A.js +1 -1
- package/dist/{review-list-E56WE7VS.js → review-list-5NGJJH23.js} +2 -2
- package/dist/sales-channel-detail-7GAGHWEP.js +2 -2
- package/dist/sales-channel-list-BCL62DTX.js +1 -1
- package/dist/{shipping-option-type-detail-BKMYJMQY.js → shipping-option-type-detail-2VDQWYDS.js} +2 -2
- package/dist/{shipping-option-type-list-R76AQI26.js → shipping-option-type-list-2XUYXURQ.js} +2 -2
- package/dist/{shipping-profile-detail-KPRFJE4V.js → shipping-profile-detail-7SE5GLQZ.js} +2 -2
- package/dist/{shipping-profiles-list-W25ZUWGV.js → shipping-profiles-list-GC6AK77V.js} +2 -2
- package/dist/{store-details-5FBLCWOV.js → store-details-MPTCI4VG.js} +4 -4
- package/dist/{store-list-MAT74WSB.js → store-list-LPKSZF2E.js} +2 -2
- package/dist/{tax-region-detail-O4DZFMT5.js → tax-region-detail-3CMIPIKA.js} +5 -5
- package/dist/{tax-region-list-ETNXAC2A.js → tax-region-list-U5JRCQZI.js} +4 -4
- package/dist/{tax-region-province-detail-LOOLLFNO.js → tax-region-province-detail-XTPJ6DZZ.js} +4 -4
- package/dist/{user-detail-MJ3ITMNK.js → user-detail-RD3T5WQT.js} +2 -2
- package/dist/{user-list-6IYBI6HY.js → user-list-X6UZ6UZM.js} +2 -2
- package/package.json +6 -6
- package/dist/home-I3OILW5Z.js +0 -16
- package/dist/{api-key-management-sales-channels-FS3KXQQ6.js → api-key-management-sales-channels-RBK66ZGC.js} +1 -1
- package/dist/{attribute-detail-KUJ337KW.js → attribute-detail-7PIMBKEE.js} +3 -3
- package/dist/{chunk-QK3HIMET.js → chunk-2IPSJDRD.js} +3 -3
- package/dist/{chunk-5EGLQSSH.js → chunk-36C3CNJC.js} +3 -3
- package/dist/{chunk-5VHQX7Q3.js → chunk-3CLWBE4O.js} +3 -3
- package/dist/{chunk-24JEBPKI.js → chunk-3JXOVOJI.js} +3 -3
- package/dist/{chunk-S4WDCOQD.js → chunk-4CYHJ72Y.js} +3 -3
- package/dist/{chunk-ZFPASY4R.js → chunk-4EQSS3YZ.js} +3 -3
- package/dist/{chunk-FS4E6GS6.js → chunk-4OCANHUL.js} +3 -3
- package/dist/{chunk-YHWDMARX.js → chunk-4RKWEFNY.js} +3 -3
- package/dist/{chunk-PFQO7UQG.js → chunk-545HIUP3.js} +3 -3
- package/dist/{chunk-DJ73BQSS.js → chunk-5H4KS6M3.js} +3 -3
- package/dist/{chunk-XGB456O5.js → chunk-5KTSSLBG.js} +3 -3
- package/dist/{chunk-EWDBPCX7.js → chunk-5LK5NAGN.js} +3 -3
- package/dist/{chunk-UXA6RZMP.js → chunk-7SHPS72O.js} +3 -3
- package/dist/{chunk-MQFPD5J4.js → chunk-AJCCPN5R.js} +3 -3
- package/dist/{chunk-26WXQ6LI.js → chunk-AUTG5JEE.js} +3 -3
- package/dist/{chunk-7ASAC2FM.js → chunk-B6XGTGMP.js} +3 -3
- package/dist/{chunk-OZKHBVDV.js → chunk-BVKPOXLT.js} +3 -3
- package/dist/{chunk-LXW3L56Z.js → chunk-CBLCX5UK.js} +3 -3
- package/dist/{chunk-KYVPZH3D.js → chunk-ESVFENTS.js} +3 -3
- package/dist/{chunk-JCRDVMIA.js → chunk-FV7B2OWJ.js} +3 -3
- package/dist/{chunk-DDZPK7BW.js → chunk-GWOZSV7A.js} +3 -3
- package/dist/{chunk-XXYVUV5F.js → chunk-HUJIVGX3.js} +3 -3
- package/dist/{chunk-LFFWPZQK.js → chunk-IAMX7JMM.js} +3 -3
- package/dist/{chunk-AGQ2BWD4.js → chunk-JODADMJ6.js} +3 -3
- package/dist/{chunk-I6HCTKMK.js → chunk-L3GVDREC.js} +3 -3
- package/dist/{chunk-ZGNLAPV6.js → chunk-LMBIFEA5.js} +3 -3
- package/dist/{chunk-VC2GAWL4.js → chunk-MKVEDGJ2.js} +3 -3
- package/dist/{chunk-G7444ISU.js → chunk-NOK2356Y.js} +3 -3
- package/dist/{chunk-FCOYAYQE.js → chunk-NUMVOUQQ.js} +3 -3
- package/dist/{chunk-NIDM2VQO.js → chunk-PH7TEL5B.js} +3 -3
- package/dist/{chunk-GR7S7WTT.js → chunk-QFYTIG3H.js} +3 -3
- package/dist/{chunk-5CKBM4RI.js → chunk-QPHY3XXC.js} +3 -3
- package/dist/{chunk-XAF7FKWZ.js → chunk-T3AKFW7T.js} +3 -3
- package/dist/{chunk-V6UH5UQT.js → chunk-TN3HCAJ2.js} +3 -3
- package/dist/{chunk-DOEBGZMA.js → chunk-UFFLSUK4.js} +3 -3
- package/dist/{chunk-IKDIEJZC.js → chunk-UZ2FWDJO.js} +3 -3
- package/dist/{chunk-XABVCD7R.js → chunk-VKDZAXLK.js} +3 -3
- package/dist/{chunk-ACEEFNIX.js → chunk-VM35P6LF.js} +3 -3
- package/dist/{chunk-LBFX6AVE.js → chunk-WJPWYQYV.js} +3 -3
- package/dist/{chunk-7QZFRDTU.js → chunk-X22JPPG6.js} +3 -3
- package/dist/{chunk-VTXMQTXK.js → chunk-YJJ6YXFA.js} +3 -3
- package/dist/{chunk-IHTYHAOC.js → chunk-ZPNRNL4X.js} +3 -3
- package/dist/{invite-6WUERQLW.js → invite-IZ2YTVPF.js} +1 -1
- package/dist/{location-sales-channels-TNP3C7UW.js → location-sales-channels-FT6TFVXJ.js} +1 -1
- package/dist/{login-2NBVRH4U.js → login-72TAMW53.js} +1 -1
- package/dist/{offer-detail-page-JGS52M66.js → offer-detail-page-XU6XK6YR.js} +4 -4
- package/dist/{order-create-claim-4CIL76V5.js → order-create-claim-PPUQXVYH.js} +3 -3
- package/dist/{order-create-edit-BFE4N7RN.js → order-create-edit-QH25BOIU.js} +3 -3
- package/dist/{order-create-exchange-CBQ5PA6M.js → order-create-exchange-5PCJ25LK.js} +3 -3
- package/dist/{order-create-return-USO7AS7R.js → order-create-return-ECGHPLEZ.js} +3 -3
- package/dist/{refund-reason-list-G5QJEYPW.js → refund-reason-list-3YLXKHJX.js} +2 -2
- package/dist/{user-invite-YVLFH6HU.js → user-invite-4JFF3NRW.js} +6 -6
|
@@ -0,0 +1,2852 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isClientError
|
|
3
|
+
} from "./chunk-C6SUTRP2.js";
|
|
4
|
+
import {
|
|
5
|
+
Thumbnail
|
|
6
|
+
} from "./chunk-U3I6S3RO.js";
|
|
7
|
+
import {
|
|
8
|
+
useProductTags
|
|
9
|
+
} from "./chunk-W5U6NPSN.js";
|
|
10
|
+
import {
|
|
11
|
+
useLogout
|
|
12
|
+
} from "./chunk-DSQRFZCO.js";
|
|
13
|
+
import {
|
|
14
|
+
useProductTypes
|
|
15
|
+
} from "./chunk-AEBQQ2EG.js";
|
|
16
|
+
import {
|
|
17
|
+
useMe
|
|
18
|
+
} from "./chunk-62YRQVR7.js";
|
|
19
|
+
import {
|
|
20
|
+
usePriceLists
|
|
21
|
+
} from "./chunk-56XMCNDS.js";
|
|
22
|
+
import {
|
|
23
|
+
useCollections
|
|
24
|
+
} from "./chunk-I4WBDDWN.js";
|
|
25
|
+
import {
|
|
26
|
+
useStore
|
|
27
|
+
} from "./chunk-3JN6NCCN.js";
|
|
28
|
+
import {
|
|
29
|
+
useCampaigns,
|
|
30
|
+
usePromotions
|
|
31
|
+
} from "./chunk-E5PC2WDZ.js";
|
|
32
|
+
import {
|
|
33
|
+
useStockLocations
|
|
34
|
+
} from "./chunk-H5E3CGD7.js";
|
|
35
|
+
import {
|
|
36
|
+
useOrders
|
|
37
|
+
} from "./chunk-DYCCRR7B.js";
|
|
38
|
+
import {
|
|
39
|
+
useCustomers
|
|
40
|
+
} from "./chunk-XWOFQSGH.js";
|
|
41
|
+
import {
|
|
42
|
+
useSellers
|
|
43
|
+
} from "./chunk-HRMANL53.js";
|
|
44
|
+
import {
|
|
45
|
+
useProductCategories
|
|
46
|
+
} from "./chunk-SQ7J4KTS.js";
|
|
47
|
+
import {
|
|
48
|
+
ConditionalTooltip
|
|
49
|
+
} from "./chunk-LAVHRER2.js";
|
|
50
|
+
import {
|
|
51
|
+
useDocumentDirection
|
|
52
|
+
} from "./chunk-Y7QKP6QU.js";
|
|
53
|
+
import {
|
|
54
|
+
Skeleton
|
|
55
|
+
} from "./chunk-INNFZYX2.js";
|
|
56
|
+
import {
|
|
57
|
+
useInventoryItems,
|
|
58
|
+
useProducts
|
|
59
|
+
} from "./chunk-Z476HUMI.js";
|
|
60
|
+
import {
|
|
61
|
+
queryClient
|
|
62
|
+
} from "./chunk-RHKRREUU.js";
|
|
63
|
+
|
|
64
|
+
// src/providers/theme-provider/theme-provider.tsx
|
|
65
|
+
import { useEffect, useState } from "react";
|
|
66
|
+
|
|
67
|
+
// src/providers/theme-provider/theme-context.tsx
|
|
68
|
+
import { createContext } from "react";
|
|
69
|
+
var ThemeContext = createContext(null);
|
|
70
|
+
|
|
71
|
+
// src/providers/theme-provider/theme-provider.tsx
|
|
72
|
+
import { jsx } from "react/jsx-runtime";
|
|
73
|
+
var THEME_KEY = "medusa_admin_theme";
|
|
74
|
+
function getDefaultValue() {
|
|
75
|
+
const persisted = localStorage?.getItem(THEME_KEY);
|
|
76
|
+
if (persisted) {
|
|
77
|
+
return persisted;
|
|
78
|
+
}
|
|
79
|
+
return "system";
|
|
80
|
+
}
|
|
81
|
+
function getThemeValue(selected) {
|
|
82
|
+
if (selected === "system") {
|
|
83
|
+
if (window !== void 0) {
|
|
84
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
85
|
+
}
|
|
86
|
+
return "light";
|
|
87
|
+
}
|
|
88
|
+
return selected;
|
|
89
|
+
}
|
|
90
|
+
var ThemeProvider = ({ children }) => {
|
|
91
|
+
const [state, setState] = useState(getDefaultValue());
|
|
92
|
+
const [value, setValue] = useState(getThemeValue(state));
|
|
93
|
+
const setTheme = (theme) => {
|
|
94
|
+
localStorage.setItem(THEME_KEY, theme);
|
|
95
|
+
const themeValue = getThemeValue(theme);
|
|
96
|
+
setState(theme);
|
|
97
|
+
setValue(themeValue);
|
|
98
|
+
};
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const html = document.querySelector("html");
|
|
101
|
+
if (html) {
|
|
102
|
+
const css = document.createElement("style");
|
|
103
|
+
css.appendChild(
|
|
104
|
+
document.createTextNode(
|
|
105
|
+
`* {
|
|
106
|
+
-webkit-transition: none !important;
|
|
107
|
+
-moz-transition: none !important;
|
|
108
|
+
-o-transition: none !important;
|
|
109
|
+
-ms-transition: none !important;
|
|
110
|
+
transition: none !important;
|
|
111
|
+
}`
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
document.head.appendChild(css);
|
|
115
|
+
html.classList.remove(value === "light" ? "dark" : "light");
|
|
116
|
+
html.classList.add(value);
|
|
117
|
+
html.style.colorScheme = value;
|
|
118
|
+
void window.getComputedStyle(css).opacity;
|
|
119
|
+
document.head.removeChild(css);
|
|
120
|
+
}
|
|
121
|
+
}, [value]);
|
|
122
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: { theme: state, setTheme }, children });
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
// src/components/utilities/error-boundary/error-boundary.tsx
|
|
126
|
+
import { ExclamationCircle } from "@medusajs/icons";
|
|
127
|
+
import { Text } from "@medusajs/ui";
|
|
128
|
+
import { useTranslation } from "react-i18next";
|
|
129
|
+
import { Navigate, useLocation, useRouteError } from "react-router-dom";
|
|
130
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
131
|
+
var ErrorBoundary = () => {
|
|
132
|
+
const error = useRouteError();
|
|
133
|
+
const location = useLocation();
|
|
134
|
+
const { t } = useTranslation();
|
|
135
|
+
let code = null;
|
|
136
|
+
if (isClientError(error)) {
|
|
137
|
+
if (error.status === 401) {
|
|
138
|
+
return /* @__PURE__ */ jsx2(Navigate, { to: "/login", state: { from: location }, replace: true });
|
|
139
|
+
}
|
|
140
|
+
code = error.status ?? null;
|
|
141
|
+
}
|
|
142
|
+
if (process.env.NODE_ENV === "development") {
|
|
143
|
+
console.error(error);
|
|
144
|
+
}
|
|
145
|
+
let title;
|
|
146
|
+
let message;
|
|
147
|
+
switch (code) {
|
|
148
|
+
case 400:
|
|
149
|
+
title = t("errorBoundary.badRequestTitle");
|
|
150
|
+
message = t("errorBoundary.badRequestMessage");
|
|
151
|
+
break;
|
|
152
|
+
case 404:
|
|
153
|
+
title = t("errorBoundary.notFoundTitle");
|
|
154
|
+
message = t("errorBoundary.notFoundMessage");
|
|
155
|
+
break;
|
|
156
|
+
case 500:
|
|
157
|
+
title = t("errorBoundary.internalServerErrorTitle");
|
|
158
|
+
message = t("errorBoundary.internalServerErrorMessage");
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
title = t("errorBoundary.defaultTitle");
|
|
162
|
+
message = t("errorBoundary.defaultMessage");
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
return /* @__PURE__ */ jsx2("div", { className: "flex size-full min-h-[calc(100vh-57px-24px)] items-center justify-center", children: /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-y-6", children: /* @__PURE__ */ jsxs("div", { className: "text-ui-fg-subtle flex flex-col items-center gap-y-3", children: [
|
|
166
|
+
/* @__PURE__ */ jsx2(ExclamationCircle, {}),
|
|
167
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-y-1", children: [
|
|
168
|
+
/* @__PURE__ */ jsx2(Text, { size: "small", leading: "compact", weight: "plus", children: title }),
|
|
169
|
+
/* @__PURE__ */ jsx2(
|
|
170
|
+
Text,
|
|
171
|
+
{
|
|
172
|
+
size: "small",
|
|
173
|
+
className: "text-ui-fg-muted text-balance text-center",
|
|
174
|
+
children: message
|
|
175
|
+
}
|
|
176
|
+
)
|
|
177
|
+
] })
|
|
178
|
+
] }) }) });
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
// src/utils/routes.ts
|
|
182
|
+
var createBranchRoute = (segment) => ({
|
|
183
|
+
path: segment,
|
|
184
|
+
children: []
|
|
185
|
+
});
|
|
186
|
+
var hoistBreadcrumb = (branch, handle, isIndex) => {
|
|
187
|
+
const branchHandle = branch.handle;
|
|
188
|
+
if (!isIndex || !handle?.breadcrumb || branchHandle?.breadcrumb) {
|
|
189
|
+
return handle;
|
|
190
|
+
}
|
|
191
|
+
branch.handle = { ...branchHandle, breadcrumb: handle.breadcrumb };
|
|
192
|
+
const { breadcrumb: _breadcrumb, ...rest } = handle;
|
|
193
|
+
return Object.keys(rest).length ? rest : void 0;
|
|
194
|
+
};
|
|
195
|
+
var createLeafRoute = (Component, loader, handle, path = "") => ({
|
|
196
|
+
path,
|
|
197
|
+
ErrorBoundary,
|
|
198
|
+
async lazy() {
|
|
199
|
+
const result = { Component };
|
|
200
|
+
if (loader) {
|
|
201
|
+
result.loader = loader;
|
|
202
|
+
}
|
|
203
|
+
if (handle) {
|
|
204
|
+
result.handle = handle;
|
|
205
|
+
}
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
var createParallelRoute = (path, Component, loader, handle) => ({
|
|
210
|
+
path,
|
|
211
|
+
async lazy() {
|
|
212
|
+
const result = { Component };
|
|
213
|
+
if (loader) {
|
|
214
|
+
result.loader = loader;
|
|
215
|
+
}
|
|
216
|
+
if (handle) {
|
|
217
|
+
result.handle = handle;
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
var processParallelRoutes = (parallelRoutes, currentFullPath) => {
|
|
223
|
+
return parallelRoutes?.map(({ path, Component, loader, handle }) => {
|
|
224
|
+
const childPath = path?.replace(currentFullPath, "").replace(/^\/+/, "");
|
|
225
|
+
if (!childPath) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
return createParallelRoute(childPath, Component, loader, handle);
|
|
229
|
+
}).filter(Boolean);
|
|
230
|
+
};
|
|
231
|
+
var addRoute = (pathSegments, Component, currentLevel, loader, handle, parallelRoutes, fullPath, componentPath) => {
|
|
232
|
+
if (!pathSegments.length) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const [currentSegment, ...remainingSegments] = pathSegments;
|
|
236
|
+
let route = currentLevel.find((r) => r.path === currentSegment);
|
|
237
|
+
if (!route) {
|
|
238
|
+
route = createBranchRoute(currentSegment);
|
|
239
|
+
currentLevel.push(route);
|
|
240
|
+
}
|
|
241
|
+
const currentFullPath = fullPath ? `${fullPath}/${currentSegment}` : currentSegment;
|
|
242
|
+
const isComponentSegment = currentFullPath === componentPath;
|
|
243
|
+
if (isComponentSegment || remainingSegments.length === 0) {
|
|
244
|
+
route.children || (route.children = []);
|
|
245
|
+
if (loader) {
|
|
246
|
+
route.loader = loader;
|
|
247
|
+
}
|
|
248
|
+
if (currentSegment === "*?" || currentSegment === "*") {
|
|
249
|
+
const leaf = createLeafRoute(Component, loader, handle, currentSegment);
|
|
250
|
+
leaf.children = processParallelRoutes(parallelRoutes, currentFullPath);
|
|
251
|
+
Object.assign(route, leaf);
|
|
252
|
+
} else {
|
|
253
|
+
const leafHandle = hoistBreadcrumb(route, handle, remainingSegments.length === 0);
|
|
254
|
+
const leaf = createLeafRoute(Component, loader, leafHandle);
|
|
255
|
+
leaf.children = processParallelRoutes(parallelRoutes, currentFullPath);
|
|
256
|
+
route.children.push(leaf);
|
|
257
|
+
}
|
|
258
|
+
if (remainingSegments.length > 0) {
|
|
259
|
+
addRoute(
|
|
260
|
+
remainingSegments,
|
|
261
|
+
Component,
|
|
262
|
+
route.children,
|
|
263
|
+
void 0,
|
|
264
|
+
void 0,
|
|
265
|
+
void 0,
|
|
266
|
+
currentFullPath
|
|
267
|
+
);
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
route.children || (route.children = []);
|
|
271
|
+
addRoute(
|
|
272
|
+
remainingSegments,
|
|
273
|
+
Component,
|
|
274
|
+
route.children,
|
|
275
|
+
loader,
|
|
276
|
+
handle,
|
|
277
|
+
parallelRoutes,
|
|
278
|
+
currentFullPath,
|
|
279
|
+
componentPath
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var createRouteMap = (routes, ignore) => {
|
|
284
|
+
const root = [];
|
|
285
|
+
routes.forEach(({ path, Component, loader, handle, children }) => {
|
|
286
|
+
const cleanedPath = ignore ? path.replace(ignore, "").replace(/^\/+/, "") : path.replace(/^\/+/, "");
|
|
287
|
+
const pathSegments = cleanedPath.split("/").filter(Boolean);
|
|
288
|
+
addRoute(
|
|
289
|
+
pathSegments,
|
|
290
|
+
Component,
|
|
291
|
+
root,
|
|
292
|
+
loader,
|
|
293
|
+
handle,
|
|
294
|
+
children,
|
|
295
|
+
void 0,
|
|
296
|
+
path
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
return root;
|
|
300
|
+
};
|
|
301
|
+
var settingsRouteRegex = /^\/settings\//;
|
|
302
|
+
var getRoutesByType = (routes, type) => {
|
|
303
|
+
return routes.filter((route) => {
|
|
304
|
+
if (type === "public") {
|
|
305
|
+
return route.isPublic === true;
|
|
306
|
+
}
|
|
307
|
+
if (type === "settings") {
|
|
308
|
+
return !route.isPublic && settingsRouteRegex.test(route.path);
|
|
309
|
+
}
|
|
310
|
+
return !route.isPublic && !settingsRouteRegex.test(route.path);
|
|
311
|
+
});
|
|
312
|
+
};
|
|
313
|
+
var getMenuItemsByType = (menuItems, type) => {
|
|
314
|
+
return menuItems.filter((item) => {
|
|
315
|
+
if (item.nested) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
if (type === "settings") {
|
|
319
|
+
return settingsRouteRegex.test(item.path);
|
|
320
|
+
}
|
|
321
|
+
return !settingsRouteRegex.test(item.path);
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
var filterMenuItemsByPermissions = (menuItems, { hasAnyPermission, hasAllPermissions }) => {
|
|
325
|
+
return menuItems.filter((item) => {
|
|
326
|
+
if (!item.permissions?.length) {
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
return item.requireAll ? hasAllPermissions(item.permissions) : hasAnyPermission(item.permissions);
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
var getNestedMenuItems = (menuItems, parentPath) => {
|
|
333
|
+
return menuItems.filter((item) => item.nested === parentPath).sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0));
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// src/components/layout/main-layout/main-layout.tsx
|
|
337
|
+
import {
|
|
338
|
+
BuildingStorefront,
|
|
339
|
+
Buildings,
|
|
340
|
+
CogSixTooth,
|
|
341
|
+
CreditCardRefresh,
|
|
342
|
+
CurrencyDollar,
|
|
343
|
+
EllipsisHorizontal as EllipsisHorizontal2,
|
|
344
|
+
MagnifyingGlass as MagnifyingGlass2,
|
|
345
|
+
OpenRectArrowOut as OpenRectArrowOut2,
|
|
346
|
+
ReceiptPercent,
|
|
347
|
+
ShoppingCart,
|
|
348
|
+
Tag,
|
|
349
|
+
Users
|
|
350
|
+
} from "@medusajs/icons";
|
|
351
|
+
import { Avatar as Avatar2, Divider, DropdownMenu as DropdownMenu3, Text as Text5, clx as clx5 } from "@medusajs/ui";
|
|
352
|
+
import { useMemo as useMemo4 } from "react";
|
|
353
|
+
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
354
|
+
import { Link as Link3, useLocation as useLocation5, useNavigate as useNavigate4 } from "react-router-dom";
|
|
355
|
+
|
|
356
|
+
// src/providers/search-provider/search-provider.tsx
|
|
357
|
+
import { useEffect as useEffect5, useState as useState5 } from "react";
|
|
358
|
+
|
|
359
|
+
// src/components/search/search.tsx
|
|
360
|
+
import {
|
|
361
|
+
Badge,
|
|
362
|
+
Button,
|
|
363
|
+
clx,
|
|
364
|
+
DropdownMenu,
|
|
365
|
+
IconButton,
|
|
366
|
+
Kbd,
|
|
367
|
+
Text as Text2
|
|
368
|
+
} from "@medusajs/ui";
|
|
369
|
+
import { Command } from "cmdk";
|
|
370
|
+
import { Dialog as RadixDialog } from "radix-ui";
|
|
371
|
+
import {
|
|
372
|
+
Children,
|
|
373
|
+
forwardRef,
|
|
374
|
+
Fragment,
|
|
375
|
+
useCallback as useCallback3,
|
|
376
|
+
useEffect as useEffect4,
|
|
377
|
+
useImperativeHandle,
|
|
378
|
+
useMemo as useMemo2,
|
|
379
|
+
useRef,
|
|
380
|
+
useState as useState4
|
|
381
|
+
} from "react";
|
|
382
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
383
|
+
import { useLocation as useLocation2, useNavigate as useNavigate2 } from "react-router-dom";
|
|
384
|
+
import {
|
|
385
|
+
ArrowUturnLeft,
|
|
386
|
+
MagnifyingGlass,
|
|
387
|
+
Plus,
|
|
388
|
+
Spinner,
|
|
389
|
+
TriangleDownMini
|
|
390
|
+
} from "@medusajs/icons";
|
|
391
|
+
import { matchSorter } from "match-sorter";
|
|
392
|
+
|
|
393
|
+
// src/components/search/constants.ts
|
|
394
|
+
var SEARCH_AREAS = [
|
|
395
|
+
"all",
|
|
396
|
+
"order",
|
|
397
|
+
"product",
|
|
398
|
+
"collection",
|
|
399
|
+
"category",
|
|
400
|
+
"inventory",
|
|
401
|
+
"customer",
|
|
402
|
+
"seller",
|
|
403
|
+
"promotion",
|
|
404
|
+
"campaign",
|
|
405
|
+
"priceList",
|
|
406
|
+
"productType",
|
|
407
|
+
"productTag",
|
|
408
|
+
"location",
|
|
409
|
+
"command",
|
|
410
|
+
"navigation"
|
|
411
|
+
];
|
|
412
|
+
var DEFAULT_SEARCH_LIMIT = 3;
|
|
413
|
+
var SEARCH_LIMIT_INCREMENT = 20;
|
|
414
|
+
|
|
415
|
+
// src/components/search/use-search-results.tsx
|
|
416
|
+
import { keepPreviousData } from "@tanstack/react-query";
|
|
417
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useMemo, useState as useState3 } from "react";
|
|
418
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
419
|
+
|
|
420
|
+
// src/providers/keybind-provider/hooks.tsx
|
|
421
|
+
import { default as debounceFn } from "lodash.debounce";
|
|
422
|
+
import { useCallback, useContext, useEffect as useEffect2, useState as useState2 } from "react";
|
|
423
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
424
|
+
import { useNavigate } from "react-router-dom";
|
|
425
|
+
|
|
426
|
+
// src/providers/keybind-provider/keybind-context.tsx
|
|
427
|
+
import { createContext as createContext2 } from "react";
|
|
428
|
+
var KeybindContext = createContext2(null);
|
|
429
|
+
|
|
430
|
+
// src/providers/keybind-provider/utils.ts
|
|
431
|
+
var findFirstPlatformMatch = (keys) => {
|
|
432
|
+
const match = Object.entries(keys).filter(
|
|
433
|
+
([, value]) => value.length > 0
|
|
434
|
+
)[0] ?? [];
|
|
435
|
+
return match.length ? {
|
|
436
|
+
platform: match[0],
|
|
437
|
+
keys: match[1]
|
|
438
|
+
} : null;
|
|
439
|
+
};
|
|
440
|
+
var getShortcutKeys = (shortcut) => {
|
|
441
|
+
const platform = "Mac";
|
|
442
|
+
const keys = shortcut.keys[platform];
|
|
443
|
+
if (!keys) {
|
|
444
|
+
const defaultPlatform = findFirstPlatformMatch(shortcut.keys);
|
|
445
|
+
console.warn(
|
|
446
|
+
`No keys found for platform "${platform}" in "${shortcut.label}" ${defaultPlatform ? `using keys for platform "${defaultPlatform.platform}"` : ""}`
|
|
447
|
+
);
|
|
448
|
+
return defaultPlatform ? defaultPlatform.keys : [];
|
|
449
|
+
}
|
|
450
|
+
return keys;
|
|
451
|
+
};
|
|
452
|
+
var keysMatch = (keys1, keys2) => {
|
|
453
|
+
return keys1.length === keys2.length && keys1.every(
|
|
454
|
+
(key, index) => key.toLowerCase() === keys2[index].toLowerCase()
|
|
455
|
+
);
|
|
456
|
+
};
|
|
457
|
+
var findShortcutIndex = (shortcuts, keys) => {
|
|
458
|
+
if (!keys.length) {
|
|
459
|
+
return -1;
|
|
460
|
+
}
|
|
461
|
+
let index = 0;
|
|
462
|
+
for (const shortcut of shortcuts) {
|
|
463
|
+
const shortcutKeys = getShortcutKeys(shortcut);
|
|
464
|
+
if (keysMatch(shortcutKeys, keys)) {
|
|
465
|
+
return index;
|
|
466
|
+
}
|
|
467
|
+
index++;
|
|
468
|
+
}
|
|
469
|
+
return -1;
|
|
470
|
+
};
|
|
471
|
+
var findShortcut = (shortcuts, keys) => {
|
|
472
|
+
const shortcutIndex = findShortcutIndex(shortcuts, keys);
|
|
473
|
+
return shortcutIndex > -1 ? shortcuts[shortcutIndex] : null;
|
|
474
|
+
};
|
|
475
|
+
var getShortcutWithDefaultValues = (shortcut, platform = "Mac") => {
|
|
476
|
+
const platforms = ["Mac", "Windows", "Linux"];
|
|
477
|
+
const defaultKeys = Object.values(shortcut.keys)[0] ?? shortcut.keys[platform];
|
|
478
|
+
const keys = platforms.reduce((acc, curr) => {
|
|
479
|
+
return {
|
|
480
|
+
...acc,
|
|
481
|
+
[curr]: shortcut.keys[curr] ?? defaultKeys
|
|
482
|
+
};
|
|
483
|
+
}, {});
|
|
484
|
+
return {
|
|
485
|
+
...shortcut,
|
|
486
|
+
keys,
|
|
487
|
+
_defaultKeys: shortcut.keys
|
|
488
|
+
};
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
// src/providers/keybind-provider/hooks.tsx
|
|
492
|
+
var useShortcuts = ({
|
|
493
|
+
shortcuts = [],
|
|
494
|
+
debounce
|
|
495
|
+
}) => {
|
|
496
|
+
const [keys, setKeys] = useState2([]);
|
|
497
|
+
const navigate = useNavigate();
|
|
498
|
+
const removeKeys = useCallback(
|
|
499
|
+
debounceFn(() => setKeys([]), debounce),
|
|
500
|
+
[]
|
|
501
|
+
);
|
|
502
|
+
const invokeShortcut = useCallback(
|
|
503
|
+
debounceFn((shortcut) => {
|
|
504
|
+
if (shortcut && shortcut.callback) {
|
|
505
|
+
shortcut.callback();
|
|
506
|
+
setKeys([]);
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
if (shortcut && shortcut.to) {
|
|
510
|
+
navigate(shortcut.to);
|
|
511
|
+
setKeys([]);
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
}, debounce / 2),
|
|
515
|
+
[]
|
|
516
|
+
);
|
|
517
|
+
useEffect2(() => {
|
|
518
|
+
if (keys.length > 0 && shortcuts.length > 0) {
|
|
519
|
+
const shortcut = findShortcut(shortcuts, keys);
|
|
520
|
+
invokeShortcut(shortcut);
|
|
521
|
+
}
|
|
522
|
+
return () => invokeShortcut.cancel();
|
|
523
|
+
}, [keys, shortcuts, invokeShortcut]);
|
|
524
|
+
useEffect2(() => {
|
|
525
|
+
const listener = (event) => {
|
|
526
|
+
const target = event.target;
|
|
527
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.contentEditable === "true") {
|
|
528
|
+
removeKeys();
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
setKeys((oldKeys) => [...oldKeys, event.key]);
|
|
532
|
+
removeKeys();
|
|
533
|
+
};
|
|
534
|
+
window.addEventListener("keydown", listener);
|
|
535
|
+
return () => {
|
|
536
|
+
window.removeEventListener("keydown", listener);
|
|
537
|
+
};
|
|
538
|
+
}, [removeKeys]);
|
|
539
|
+
};
|
|
540
|
+
var useGlobalShortcuts = () => {
|
|
541
|
+
const { t } = useTranslation2();
|
|
542
|
+
const navigate = useNavigate();
|
|
543
|
+
const { mutateAsync } = useLogout();
|
|
544
|
+
const handleLogout = async () => {
|
|
545
|
+
await mutateAsync(void 0, {
|
|
546
|
+
onSuccess: () => {
|
|
547
|
+
queryClient.clear();
|
|
548
|
+
navigate("/login");
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
};
|
|
552
|
+
const globalShortcuts = [
|
|
553
|
+
// Pages
|
|
554
|
+
{
|
|
555
|
+
keys: {
|
|
556
|
+
Mac: ["G", "O"]
|
|
557
|
+
},
|
|
558
|
+
label: t("app.keyboardShortcuts.navigation.goToOrders"),
|
|
559
|
+
type: "pageShortcut",
|
|
560
|
+
to: "/orders"
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
keys: {
|
|
564
|
+
Mac: ["G", "P"]
|
|
565
|
+
},
|
|
566
|
+
label: t("app.keyboardShortcuts.navigation.goToProducts"),
|
|
567
|
+
type: "pageShortcut",
|
|
568
|
+
to: "/products"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
keys: {
|
|
572
|
+
Mac: ["G", "C"]
|
|
573
|
+
},
|
|
574
|
+
label: t("app.keyboardShortcuts.navigation.goToCollections"),
|
|
575
|
+
type: "pageShortcut",
|
|
576
|
+
to: "/collections"
|
|
577
|
+
},
|
|
578
|
+
{
|
|
579
|
+
keys: {
|
|
580
|
+
Mac: ["G", "A"]
|
|
581
|
+
},
|
|
582
|
+
label: t("app.keyboardShortcuts.navigation.goToCategories"),
|
|
583
|
+
type: "pageShortcut",
|
|
584
|
+
to: "/categories"
|
|
585
|
+
},
|
|
586
|
+
{
|
|
587
|
+
keys: {
|
|
588
|
+
Mac: ["G", "U"]
|
|
589
|
+
},
|
|
590
|
+
label: t("app.keyboardShortcuts.navigation.goToCustomers"),
|
|
591
|
+
type: "pageShortcut",
|
|
592
|
+
to: "/customers"
|
|
593
|
+
},
|
|
594
|
+
{
|
|
595
|
+
keys: {
|
|
596
|
+
Mac: ["G", "I"]
|
|
597
|
+
},
|
|
598
|
+
label: t("app.keyboardShortcuts.navigation.goToInventory"),
|
|
599
|
+
type: "pageShortcut",
|
|
600
|
+
to: "/inventory"
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
keys: {
|
|
604
|
+
Mac: ["G", "L"]
|
|
605
|
+
},
|
|
606
|
+
label: t("app.keyboardShortcuts.navigation.goToPriceLists"),
|
|
607
|
+
type: "pageShortcut",
|
|
608
|
+
to: "/price-lists"
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
keys: {
|
|
612
|
+
Mac: ["G", "M"]
|
|
613
|
+
},
|
|
614
|
+
label: t("app.keyboardShortcuts.navigation.goToPromotions"),
|
|
615
|
+
type: "pageShortcut",
|
|
616
|
+
to: "/promotions"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
keys: {
|
|
620
|
+
Mac: ["G", "K"]
|
|
621
|
+
},
|
|
622
|
+
label: t("app.keyboardShortcuts.navigation.goToCampaigns"),
|
|
623
|
+
type: "pageShortcut",
|
|
624
|
+
to: "/campaigns"
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
keys: {
|
|
628
|
+
Mac: ["G", "S"]
|
|
629
|
+
},
|
|
630
|
+
label: t("app.keyboardShortcuts.navigation.goToSellers"),
|
|
631
|
+
type: "pageShortcut",
|
|
632
|
+
to: "/sellers"
|
|
633
|
+
},
|
|
634
|
+
{
|
|
635
|
+
keys: {
|
|
636
|
+
Mac: ["G", "Y"]
|
|
637
|
+
},
|
|
638
|
+
label: t("app.keyboardShortcuts.navigation.goToPayouts"),
|
|
639
|
+
type: "pageShortcut",
|
|
640
|
+
to: "/payouts"
|
|
641
|
+
},
|
|
642
|
+
// Settings
|
|
643
|
+
{
|
|
644
|
+
keys: {
|
|
645
|
+
Mac: ["G", ","]
|
|
646
|
+
},
|
|
647
|
+
label: t("app.keyboardShortcuts.settings.goToSettings"),
|
|
648
|
+
type: "settingShortcut",
|
|
649
|
+
to: "/settings"
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
keys: {
|
|
653
|
+
Mac: ["G", ",", "P"]
|
|
654
|
+
},
|
|
655
|
+
label: t("app.keyboardShortcuts.settings.goToProductTypes"),
|
|
656
|
+
type: "settingShortcut",
|
|
657
|
+
to: "/settings/product-types"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
keys: {
|
|
661
|
+
Mac: ["G", ",", "L"]
|
|
662
|
+
},
|
|
663
|
+
label: t("app.keyboardShortcuts.settings.goToLocations"),
|
|
664
|
+
type: "settingShortcut",
|
|
665
|
+
to: "/settings/locations"
|
|
666
|
+
},
|
|
667
|
+
// Commands
|
|
668
|
+
{
|
|
669
|
+
keys: {
|
|
670
|
+
Mac: ["B", "Y", "E"]
|
|
671
|
+
},
|
|
672
|
+
label: t("actions.logout"),
|
|
673
|
+
type: "commandShortcut",
|
|
674
|
+
callback: () => handleLogout()
|
|
675
|
+
}
|
|
676
|
+
];
|
|
677
|
+
return globalShortcuts;
|
|
678
|
+
};
|
|
679
|
+
|
|
680
|
+
// src/components/search/use-search-results.tsx
|
|
681
|
+
var useSearchResults = ({
|
|
682
|
+
q,
|
|
683
|
+
limit,
|
|
684
|
+
area = "all"
|
|
685
|
+
}) => {
|
|
686
|
+
const staticResults = useStaticSearchResults(area);
|
|
687
|
+
const { dynamicResults, isFetching } = useDynamicSearchResults(area, limit, q);
|
|
688
|
+
return {
|
|
689
|
+
staticResults,
|
|
690
|
+
dynamicResults,
|
|
691
|
+
isFetching
|
|
692
|
+
};
|
|
693
|
+
};
|
|
694
|
+
var useStaticSearchResults = (currentArea) => {
|
|
695
|
+
const globalCommands = useGlobalShortcuts();
|
|
696
|
+
const results = useMemo(() => {
|
|
697
|
+
const groups = /* @__PURE__ */ new Map();
|
|
698
|
+
globalCommands.forEach((command) => {
|
|
699
|
+
const group = groups.get(command.type) || [];
|
|
700
|
+
group.push(command);
|
|
701
|
+
groups.set(command.type, group);
|
|
702
|
+
});
|
|
703
|
+
let filteredGroups;
|
|
704
|
+
switch (currentArea) {
|
|
705
|
+
case "all":
|
|
706
|
+
filteredGroups = Array.from(groups);
|
|
707
|
+
break;
|
|
708
|
+
case "navigation":
|
|
709
|
+
filteredGroups = Array.from(groups).filter(
|
|
710
|
+
([type]) => type === "pageShortcut" || type === "settingShortcut"
|
|
711
|
+
);
|
|
712
|
+
break;
|
|
713
|
+
case "command":
|
|
714
|
+
filteredGroups = Array.from(groups).filter(
|
|
715
|
+
([type]) => type === "commandShortcut"
|
|
716
|
+
);
|
|
717
|
+
break;
|
|
718
|
+
default:
|
|
719
|
+
filteredGroups = [];
|
|
720
|
+
}
|
|
721
|
+
return filteredGroups.map(([title, items]) => ({
|
|
722
|
+
title,
|
|
723
|
+
items
|
|
724
|
+
}));
|
|
725
|
+
}, [globalCommands, currentArea]);
|
|
726
|
+
return results;
|
|
727
|
+
};
|
|
728
|
+
var useDynamicSearchResults = (currentArea, limit, q) => {
|
|
729
|
+
const { t } = useTranslation3();
|
|
730
|
+
const debouncedSearch = useDebouncedSearch(q, 300);
|
|
731
|
+
const isSearchEnabled = Boolean(debouncedSearch);
|
|
732
|
+
const orderResponse = useOrders(
|
|
733
|
+
{
|
|
734
|
+
q: debouncedSearch?.replace(/^#/, ""),
|
|
735
|
+
// Since we display the ID with a # prefix, it's natural for the user to include it in the search. This will however cause no results to be returned, so we remove the # prefix from the search query.
|
|
736
|
+
limit,
|
|
737
|
+
fields: "id,display_id,email"
|
|
738
|
+
},
|
|
739
|
+
{
|
|
740
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "order"),
|
|
741
|
+
placeholderData: keepPreviousData
|
|
742
|
+
}
|
|
743
|
+
);
|
|
744
|
+
const productResponse = useProducts(
|
|
745
|
+
{
|
|
746
|
+
q: debouncedSearch,
|
|
747
|
+
limit,
|
|
748
|
+
// TODO: Remove exclusion once we avoid including unnecessary relations by default in the query config
|
|
749
|
+
fields: "id,title,thumbnail,-type,-collection,-options,-tags,-images,-variants,-sales_channels"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "product"),
|
|
753
|
+
placeholderData: keepPreviousData
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
const categoryResponse = useProductCategories(
|
|
757
|
+
{
|
|
758
|
+
// TODO: Remove the OR condition once the list endpoint does not throw when q equals an empty string
|
|
759
|
+
q: debouncedSearch || void 0,
|
|
760
|
+
limit,
|
|
761
|
+
fields: "id,name"
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "category"),
|
|
765
|
+
placeholderData: keepPreviousData
|
|
766
|
+
}
|
|
767
|
+
);
|
|
768
|
+
const collectionResponse = useCollections(
|
|
769
|
+
{
|
|
770
|
+
q: debouncedSearch,
|
|
771
|
+
limit,
|
|
772
|
+
fields: "id,title"
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "collection"),
|
|
776
|
+
placeholderData: keepPreviousData
|
|
777
|
+
}
|
|
778
|
+
);
|
|
779
|
+
const customerResponse = useCustomers(
|
|
780
|
+
{
|
|
781
|
+
q: debouncedSearch,
|
|
782
|
+
limit,
|
|
783
|
+
fields: "id,email,first_name,last_name"
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "customer"),
|
|
787
|
+
placeholderData: keepPreviousData
|
|
788
|
+
}
|
|
789
|
+
);
|
|
790
|
+
const sellerResponse = useSellers(
|
|
791
|
+
{
|
|
792
|
+
q: debouncedSearch,
|
|
793
|
+
limit,
|
|
794
|
+
fields: "id,name"
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "seller"),
|
|
798
|
+
placeholderData: keepPreviousData
|
|
799
|
+
}
|
|
800
|
+
);
|
|
801
|
+
const inventoryResponse = useInventoryItems(
|
|
802
|
+
{
|
|
803
|
+
q: debouncedSearch,
|
|
804
|
+
limit,
|
|
805
|
+
fields: "id,title,sku"
|
|
806
|
+
},
|
|
807
|
+
{
|
|
808
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "inventory"),
|
|
809
|
+
placeholderData: keepPreviousData
|
|
810
|
+
}
|
|
811
|
+
);
|
|
812
|
+
const promotionResponse = usePromotions(
|
|
813
|
+
{
|
|
814
|
+
q: debouncedSearch,
|
|
815
|
+
limit,
|
|
816
|
+
fields: "id,code,status"
|
|
817
|
+
},
|
|
818
|
+
{
|
|
819
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "promotion"),
|
|
820
|
+
placeholderData: keepPreviousData
|
|
821
|
+
}
|
|
822
|
+
);
|
|
823
|
+
const campaignResponse = useCampaigns(
|
|
824
|
+
{
|
|
825
|
+
q: debouncedSearch,
|
|
826
|
+
limit,
|
|
827
|
+
fields: "id,name"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "campaign"),
|
|
831
|
+
placeholderData: keepPreviousData
|
|
832
|
+
}
|
|
833
|
+
);
|
|
834
|
+
const priceListResponse = usePriceLists(
|
|
835
|
+
{
|
|
836
|
+
q: debouncedSearch,
|
|
837
|
+
limit,
|
|
838
|
+
fields: "id,title"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "priceList"),
|
|
842
|
+
placeholderData: keepPreviousData
|
|
843
|
+
}
|
|
844
|
+
);
|
|
845
|
+
const productTypeResponse = useProductTypes(
|
|
846
|
+
{
|
|
847
|
+
q: debouncedSearch,
|
|
848
|
+
limit,
|
|
849
|
+
fields: "id,value"
|
|
850
|
+
},
|
|
851
|
+
{
|
|
852
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "productType"),
|
|
853
|
+
placeholderData: keepPreviousData
|
|
854
|
+
}
|
|
855
|
+
);
|
|
856
|
+
const productTagResponse = useProductTags(
|
|
857
|
+
{
|
|
858
|
+
q: debouncedSearch,
|
|
859
|
+
limit,
|
|
860
|
+
fields: "id,value"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "productTag"),
|
|
864
|
+
placeholderData: keepPreviousData
|
|
865
|
+
}
|
|
866
|
+
);
|
|
867
|
+
const locationResponse = useStockLocations(
|
|
868
|
+
{
|
|
869
|
+
q: debouncedSearch,
|
|
870
|
+
limit,
|
|
871
|
+
fields: "id,name"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
enabled: isSearchEnabled && isAreaEnabled(currentArea, "location"),
|
|
875
|
+
placeholderData: keepPreviousData
|
|
876
|
+
}
|
|
877
|
+
);
|
|
878
|
+
const responseMap = useMemo(
|
|
879
|
+
() => ({
|
|
880
|
+
order: orderResponse,
|
|
881
|
+
product: productResponse,
|
|
882
|
+
collection: collectionResponse,
|
|
883
|
+
category: categoryResponse,
|
|
884
|
+
inventory: inventoryResponse,
|
|
885
|
+
customer: customerResponse,
|
|
886
|
+
seller: sellerResponse,
|
|
887
|
+
promotion: promotionResponse,
|
|
888
|
+
campaign: campaignResponse,
|
|
889
|
+
priceList: priceListResponse,
|
|
890
|
+
productType: productTypeResponse,
|
|
891
|
+
productTag: productTagResponse,
|
|
892
|
+
location: locationResponse
|
|
893
|
+
}),
|
|
894
|
+
[
|
|
895
|
+
orderResponse,
|
|
896
|
+
productResponse,
|
|
897
|
+
inventoryResponse,
|
|
898
|
+
categoryResponse,
|
|
899
|
+
collectionResponse,
|
|
900
|
+
customerResponse,
|
|
901
|
+
sellerResponse,
|
|
902
|
+
promotionResponse,
|
|
903
|
+
campaignResponse,
|
|
904
|
+
priceListResponse,
|
|
905
|
+
productTypeResponse,
|
|
906
|
+
productTagResponse,
|
|
907
|
+
locationResponse
|
|
908
|
+
]
|
|
909
|
+
);
|
|
910
|
+
const results = useMemo(() => {
|
|
911
|
+
const groups = Object.entries(responseMap).map(([key, response]) => {
|
|
912
|
+
const area = key;
|
|
913
|
+
if (isAreaEnabled(currentArea, area) || currentArea === "all") {
|
|
914
|
+
return transformDynamicSearchResults(area, limit, t, response);
|
|
915
|
+
}
|
|
916
|
+
return null;
|
|
917
|
+
}).filter(Boolean);
|
|
918
|
+
return groups;
|
|
919
|
+
}, [responseMap, currentArea, limit, t]);
|
|
920
|
+
const isAreaFetching = useCallback2(
|
|
921
|
+
(area) => {
|
|
922
|
+
if (area === "all") {
|
|
923
|
+
return Object.values(responseMap).some(
|
|
924
|
+
(response) => response.isFetching
|
|
925
|
+
);
|
|
926
|
+
}
|
|
927
|
+
return isAreaEnabled(currentArea, area) && responseMap[area]?.isFetching;
|
|
928
|
+
},
|
|
929
|
+
[currentArea, responseMap]
|
|
930
|
+
);
|
|
931
|
+
const isFetching = useMemo(() => {
|
|
932
|
+
return isAreaFetching(currentArea);
|
|
933
|
+
}, [currentArea, isAreaFetching]);
|
|
934
|
+
const dynamicResults = q ? results.filter(
|
|
935
|
+
(group) => !!group && group.items.length > 0
|
|
936
|
+
) : [];
|
|
937
|
+
return {
|
|
938
|
+
dynamicResults,
|
|
939
|
+
isFetching
|
|
940
|
+
};
|
|
941
|
+
};
|
|
942
|
+
var useDebouncedSearch = (value, delay) => {
|
|
943
|
+
const [debouncedValue, setDebouncedValue] = useState3(value);
|
|
944
|
+
useEffect3(() => {
|
|
945
|
+
const handler = setTimeout(() => {
|
|
946
|
+
setDebouncedValue(value);
|
|
947
|
+
}, delay);
|
|
948
|
+
return () => {
|
|
949
|
+
clearTimeout(handler);
|
|
950
|
+
};
|
|
951
|
+
}, [value, delay]);
|
|
952
|
+
return debouncedValue;
|
|
953
|
+
};
|
|
954
|
+
function isAreaEnabled(area, currentArea) {
|
|
955
|
+
if (area === "all") {
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
if (area === currentArea) {
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
return false;
|
|
962
|
+
}
|
|
963
|
+
var transformMap = {
|
|
964
|
+
order: {
|
|
965
|
+
dataKey: "orders",
|
|
966
|
+
transform: (order) => ({
|
|
967
|
+
id: order.id,
|
|
968
|
+
title: `#${order.display_id}`,
|
|
969
|
+
subtitle: order.email ?? void 0,
|
|
970
|
+
to: `/orders/${order.id}`,
|
|
971
|
+
value: `order:${order.id}`
|
|
972
|
+
})
|
|
973
|
+
},
|
|
974
|
+
product: {
|
|
975
|
+
dataKey: "products",
|
|
976
|
+
transform: (product) => ({
|
|
977
|
+
id: product.id,
|
|
978
|
+
title: product.title,
|
|
979
|
+
to: `/products/${product.id}`,
|
|
980
|
+
thumbnail: product.thumbnail ?? void 0,
|
|
981
|
+
value: `product:${product.id}`
|
|
982
|
+
})
|
|
983
|
+
},
|
|
984
|
+
category: {
|
|
985
|
+
dataKey: "product_categories",
|
|
986
|
+
transform: (category) => ({
|
|
987
|
+
id: category.id,
|
|
988
|
+
title: category.name,
|
|
989
|
+
to: `/categories/${category.id}`,
|
|
990
|
+
value: `category:${category.id}`
|
|
991
|
+
})
|
|
992
|
+
},
|
|
993
|
+
inventory: {
|
|
994
|
+
dataKey: "inventory_items",
|
|
995
|
+
transform: (inventory) => ({
|
|
996
|
+
id: inventory.id,
|
|
997
|
+
title: inventory.title ?? "",
|
|
998
|
+
subtitle: inventory.sku ?? void 0,
|
|
999
|
+
to: `/inventory/${inventory.id}`,
|
|
1000
|
+
value: `inventory:${inventory.id}`
|
|
1001
|
+
})
|
|
1002
|
+
},
|
|
1003
|
+
customer: {
|
|
1004
|
+
dataKey: "customers",
|
|
1005
|
+
transform: (customer) => {
|
|
1006
|
+
const name = [customer.first_name, customer.last_name].filter(Boolean).join(" ");
|
|
1007
|
+
return {
|
|
1008
|
+
id: customer.id,
|
|
1009
|
+
title: name || customer.email,
|
|
1010
|
+
subtitle: name ? customer.email : void 0,
|
|
1011
|
+
to: `/customers/${customer.id}`,
|
|
1012
|
+
value: `customer:${customer.id}`
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
seller: {
|
|
1017
|
+
dataKey: "sellers",
|
|
1018
|
+
transform: (seller) => ({
|
|
1019
|
+
id: seller.id,
|
|
1020
|
+
title: seller.name,
|
|
1021
|
+
to: `/stores/${seller.id}`,
|
|
1022
|
+
value: `seller:${seller.id}`
|
|
1023
|
+
})
|
|
1024
|
+
},
|
|
1025
|
+
collection: {
|
|
1026
|
+
dataKey: "collections",
|
|
1027
|
+
transform: (collection) => ({
|
|
1028
|
+
id: collection.id,
|
|
1029
|
+
title: collection.title,
|
|
1030
|
+
to: `/collections/${collection.id}`,
|
|
1031
|
+
value: `collection:${collection.id}`
|
|
1032
|
+
})
|
|
1033
|
+
},
|
|
1034
|
+
promotion: {
|
|
1035
|
+
dataKey: "promotions",
|
|
1036
|
+
transform: (promotion) => ({
|
|
1037
|
+
id: promotion.id,
|
|
1038
|
+
title: promotion.code,
|
|
1039
|
+
to: `/promotions/${promotion.id}`,
|
|
1040
|
+
value: `promotion:${promotion.id}`
|
|
1041
|
+
})
|
|
1042
|
+
},
|
|
1043
|
+
campaign: {
|
|
1044
|
+
dataKey: "campaigns",
|
|
1045
|
+
transform: (campaign) => ({
|
|
1046
|
+
id: campaign.id,
|
|
1047
|
+
title: campaign.name,
|
|
1048
|
+
to: `/campaigns/${campaign.id}`,
|
|
1049
|
+
value: `campaign:${campaign.id}`
|
|
1050
|
+
})
|
|
1051
|
+
},
|
|
1052
|
+
priceList: {
|
|
1053
|
+
dataKey: "price_lists",
|
|
1054
|
+
transform: (priceList) => ({
|
|
1055
|
+
id: priceList.id,
|
|
1056
|
+
title: priceList.title,
|
|
1057
|
+
to: `/price-lists/${priceList.id}`,
|
|
1058
|
+
value: `priceList:${priceList.id}`
|
|
1059
|
+
})
|
|
1060
|
+
},
|
|
1061
|
+
productType: {
|
|
1062
|
+
dataKey: "product_types",
|
|
1063
|
+
transform: (productType) => ({
|
|
1064
|
+
id: productType.id,
|
|
1065
|
+
title: productType.value,
|
|
1066
|
+
to: `/product-types/${productType.id}`,
|
|
1067
|
+
value: `productType:${productType.id}`
|
|
1068
|
+
})
|
|
1069
|
+
},
|
|
1070
|
+
productTag: {
|
|
1071
|
+
dataKey: "product_tags",
|
|
1072
|
+
transform: (productTag) => ({
|
|
1073
|
+
id: productTag.id,
|
|
1074
|
+
title: productTag.value,
|
|
1075
|
+
to: `/product-tags/${productTag.id}`,
|
|
1076
|
+
value: `productTag:${productTag.id}`
|
|
1077
|
+
})
|
|
1078
|
+
},
|
|
1079
|
+
location: {
|
|
1080
|
+
dataKey: "stock_locations",
|
|
1081
|
+
transform: (location) => ({
|
|
1082
|
+
id: location.id,
|
|
1083
|
+
title: location.name,
|
|
1084
|
+
to: `/locations/${location.id}`,
|
|
1085
|
+
value: `location:${location.id}`
|
|
1086
|
+
})
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
function transformDynamicSearchResults(type, limit, t, response) {
|
|
1090
|
+
if (!response || !transformMap[type]) {
|
|
1091
|
+
return void 0;
|
|
1092
|
+
}
|
|
1093
|
+
const { dataKey, transform } = transformMap[type];
|
|
1094
|
+
const data = response[dataKey];
|
|
1095
|
+
if (!data || !Array.isArray(data)) {
|
|
1096
|
+
return void 0;
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
title: t(`app.search.groups.${type}`),
|
|
1100
|
+
area: type,
|
|
1101
|
+
hasMore: response.count > limit,
|
|
1102
|
+
count: response.count,
|
|
1103
|
+
items: data.map(transform)
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
// src/components/search/search.tsx
|
|
1108
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1109
|
+
var Search = () => {
|
|
1110
|
+
const [area, setArea] = useState4("all");
|
|
1111
|
+
const [search, setSearch] = useState4("");
|
|
1112
|
+
const [limit, setLimit] = useState4(DEFAULT_SEARCH_LIMIT);
|
|
1113
|
+
const { open, onOpenChange } = useSearch();
|
|
1114
|
+
const location = useLocation2();
|
|
1115
|
+
const { t } = useTranslation4();
|
|
1116
|
+
const navigate = useNavigate2();
|
|
1117
|
+
const inputRef = useRef(null);
|
|
1118
|
+
const listRef = useRef(null);
|
|
1119
|
+
const { staticResults, dynamicResults, isFetching } = useSearchResults({
|
|
1120
|
+
area,
|
|
1121
|
+
limit,
|
|
1122
|
+
q: search
|
|
1123
|
+
});
|
|
1124
|
+
const handleReset = useCallback3(() => {
|
|
1125
|
+
setArea("all");
|
|
1126
|
+
setSearch("");
|
|
1127
|
+
setLimit(DEFAULT_SEARCH_LIMIT);
|
|
1128
|
+
}, [setLimit]);
|
|
1129
|
+
const handleBack = () => {
|
|
1130
|
+
handleReset();
|
|
1131
|
+
inputRef.current?.focus();
|
|
1132
|
+
};
|
|
1133
|
+
const handleOpenChange = useCallback3(
|
|
1134
|
+
(open2) => {
|
|
1135
|
+
if (!open2) {
|
|
1136
|
+
handleReset();
|
|
1137
|
+
}
|
|
1138
|
+
onOpenChange(open2);
|
|
1139
|
+
},
|
|
1140
|
+
[onOpenChange, handleReset]
|
|
1141
|
+
);
|
|
1142
|
+
useEffect4(() => {
|
|
1143
|
+
handleOpenChange(false);
|
|
1144
|
+
}, [location.pathname, handleOpenChange]);
|
|
1145
|
+
const handleSelect = (item) => {
|
|
1146
|
+
handleOpenChange(false);
|
|
1147
|
+
if (item.to) {
|
|
1148
|
+
navigate(item.to);
|
|
1149
|
+
return;
|
|
1150
|
+
}
|
|
1151
|
+
if (item.callback) {
|
|
1152
|
+
item.callback();
|
|
1153
|
+
return;
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
const handleShowMore = (area2) => {
|
|
1157
|
+
if (area2 === "all") {
|
|
1158
|
+
setLimit(DEFAULT_SEARCH_LIMIT);
|
|
1159
|
+
} else {
|
|
1160
|
+
setLimit(SEARCH_LIMIT_INCREMENT);
|
|
1161
|
+
}
|
|
1162
|
+
setArea(area2);
|
|
1163
|
+
inputRef.current?.focus();
|
|
1164
|
+
};
|
|
1165
|
+
const handleLoadMore = () => {
|
|
1166
|
+
setLimit((l) => l + SEARCH_LIMIT_INCREMENT);
|
|
1167
|
+
};
|
|
1168
|
+
const filteredStaticResults = useMemo2(() => {
|
|
1169
|
+
const filteredResults = [];
|
|
1170
|
+
staticResults.forEach((group) => {
|
|
1171
|
+
const filteredItems = matchSorter(group.items, search, {
|
|
1172
|
+
keys: ["label"]
|
|
1173
|
+
});
|
|
1174
|
+
if (filteredItems.length === 0) {
|
|
1175
|
+
return;
|
|
1176
|
+
}
|
|
1177
|
+
filteredResults.push({
|
|
1178
|
+
...group,
|
|
1179
|
+
items: filteredItems
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1182
|
+
return filteredResults;
|
|
1183
|
+
}, [staticResults, search]);
|
|
1184
|
+
const handleSearch = (q) => {
|
|
1185
|
+
setSearch(q);
|
|
1186
|
+
listRef.current?.scrollTo({ top: 0 });
|
|
1187
|
+
};
|
|
1188
|
+
const showLoading = useMemo2(() => {
|
|
1189
|
+
return isFetching && !dynamicResults.length && !filteredStaticResults.length;
|
|
1190
|
+
}, [isFetching, dynamicResults, filteredStaticResults]);
|
|
1191
|
+
return /* @__PURE__ */ jsxs2(CommandDialog, { open, onOpenChange: handleOpenChange, children: [
|
|
1192
|
+
/* @__PURE__ */ jsx3(
|
|
1193
|
+
CommandInput,
|
|
1194
|
+
{
|
|
1195
|
+
isFetching,
|
|
1196
|
+
ref: inputRef,
|
|
1197
|
+
area,
|
|
1198
|
+
setArea,
|
|
1199
|
+
value: search,
|
|
1200
|
+
onValueChange: handleSearch,
|
|
1201
|
+
onBack: area !== "all" ? handleBack : void 0,
|
|
1202
|
+
placeholder: t("app.search.placeholder")
|
|
1203
|
+
}
|
|
1204
|
+
),
|
|
1205
|
+
/* @__PURE__ */ jsxs2(CommandList, { ref: listRef, children: [
|
|
1206
|
+
showLoading && /* @__PURE__ */ jsx3(CommandLoading, {}),
|
|
1207
|
+
dynamicResults.map((group) => {
|
|
1208
|
+
return /* @__PURE__ */ jsxs2(CommandGroup, { heading: group.title, children: [
|
|
1209
|
+
group.items.map((item) => {
|
|
1210
|
+
return /* @__PURE__ */ jsx3(
|
|
1211
|
+
CommandItem,
|
|
1212
|
+
{
|
|
1213
|
+
onSelect: () => handleSelect(item),
|
|
1214
|
+
value: item.value,
|
|
1215
|
+
className: "flex items-center justify-between",
|
|
1216
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
|
|
1217
|
+
item.thumbnail && /* @__PURE__ */ jsx3(
|
|
1218
|
+
Thumbnail,
|
|
1219
|
+
{
|
|
1220
|
+
alt: item.title,
|
|
1221
|
+
src: item.thumbnail,
|
|
1222
|
+
size: "small"
|
|
1223
|
+
}
|
|
1224
|
+
),
|
|
1225
|
+
/* @__PURE__ */ jsx3("span", { children: item.title }),
|
|
1226
|
+
item.subtitle && /* @__PURE__ */ jsx3("span", { className: "text-ui-fg-muted", children: item.subtitle })
|
|
1227
|
+
] })
|
|
1228
|
+
},
|
|
1229
|
+
item.id
|
|
1230
|
+
);
|
|
1231
|
+
}),
|
|
1232
|
+
group.hasMore && area === "all" && /* @__PURE__ */ jsx3(
|
|
1233
|
+
CommandItem,
|
|
1234
|
+
{
|
|
1235
|
+
onSelect: () => handleShowMore(group.area),
|
|
1236
|
+
hidden: true,
|
|
1237
|
+
value: `${group.title}:show:more`,
|
|
1238
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-muted flex items-center gap-x-3", children: [
|
|
1239
|
+
/* @__PURE__ */ jsx3(Plus, {}),
|
|
1240
|
+
/* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", weight: "plus", children: t("app.search.showMore") })
|
|
1241
|
+
] })
|
|
1242
|
+
}
|
|
1243
|
+
),
|
|
1244
|
+
group.hasMore && area === group.area && /* @__PURE__ */ jsx3(
|
|
1245
|
+
CommandItem,
|
|
1246
|
+
{
|
|
1247
|
+
onSelect: handleLoadMore,
|
|
1248
|
+
hidden: true,
|
|
1249
|
+
value: `${group.title}:load:more`,
|
|
1250
|
+
children: /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-muted flex items-center gap-x-3", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx3(Plus, {}),
|
|
1252
|
+
/* @__PURE__ */ jsx3(Text2, { size: "small", leading: "compact", weight: "plus", children: t("app.search.loadMore", {
|
|
1253
|
+
count: Math.min(
|
|
1254
|
+
SEARCH_LIMIT_INCREMENT,
|
|
1255
|
+
group.count - limit
|
|
1256
|
+
)
|
|
1257
|
+
}) })
|
|
1258
|
+
] })
|
|
1259
|
+
}
|
|
1260
|
+
)
|
|
1261
|
+
] }, group.title);
|
|
1262
|
+
}),
|
|
1263
|
+
filteredStaticResults.map((group) => {
|
|
1264
|
+
return /* @__PURE__ */ jsx3(
|
|
1265
|
+
CommandGroup,
|
|
1266
|
+
{
|
|
1267
|
+
heading: t(`app.keyboardShortcuts.${group.title}`),
|
|
1268
|
+
children: group.items.map((item) => {
|
|
1269
|
+
return /* @__PURE__ */ jsxs2(
|
|
1270
|
+
CommandItem,
|
|
1271
|
+
{
|
|
1272
|
+
onSelect: () => handleSelect(item),
|
|
1273
|
+
className: "flex items-center justify-between",
|
|
1274
|
+
children: [
|
|
1275
|
+
/* @__PURE__ */ jsx3("span", { children: item.label }),
|
|
1276
|
+
/* @__PURE__ */ jsx3("div", { className: "flex items-center gap-x-1.5", children: item.keys.Mac?.map((key, index) => {
|
|
1277
|
+
return /* @__PURE__ */ jsxs2(
|
|
1278
|
+
"div",
|
|
1279
|
+
{
|
|
1280
|
+
className: "flex items-center gap-x-1",
|
|
1281
|
+
children: [
|
|
1282
|
+
/* @__PURE__ */ jsx3(Kbd, { children: key }),
|
|
1283
|
+
index < (item.keys.Mac?.length || 0) - 1 && /* @__PURE__ */ jsx3("span", { className: "txt-compact-xsmall text-ui-fg-subtle", children: t("app.keyboardShortcuts.then") })
|
|
1284
|
+
]
|
|
1285
|
+
},
|
|
1286
|
+
index
|
|
1287
|
+
);
|
|
1288
|
+
}) })
|
|
1289
|
+
]
|
|
1290
|
+
},
|
|
1291
|
+
item.label
|
|
1292
|
+
);
|
|
1293
|
+
})
|
|
1294
|
+
},
|
|
1295
|
+
group.title
|
|
1296
|
+
);
|
|
1297
|
+
}),
|
|
1298
|
+
!showLoading && /* @__PURE__ */ jsx3(CommandEmpty, { q: search })
|
|
1299
|
+
] })
|
|
1300
|
+
] });
|
|
1301
|
+
};
|
|
1302
|
+
var CommandPalette = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
1303
|
+
Command,
|
|
1304
|
+
{
|
|
1305
|
+
shouldFilter: false,
|
|
1306
|
+
ref,
|
|
1307
|
+
className: clx(
|
|
1308
|
+
"bg-popover text-popover-foreground flex h-full w-full flex-col overflow-hidden rounded-md",
|
|
1309
|
+
className
|
|
1310
|
+
),
|
|
1311
|
+
...props
|
|
1312
|
+
}
|
|
1313
|
+
));
|
|
1314
|
+
CommandPalette.displayName = Command.displayName;
|
|
1315
|
+
var CommandDialog = ({ children, ...props }) => {
|
|
1316
|
+
const { t } = useTranslation4();
|
|
1317
|
+
const preserveHeight = useMemo2(() => {
|
|
1318
|
+
return props.isLoading && Children.count(children) === 0;
|
|
1319
|
+
}, [props.isLoading, children]);
|
|
1320
|
+
return /* @__PURE__ */ jsx3(RadixDialog.Root, { ...props, children: /* @__PURE__ */ jsxs2(RadixDialog.Portal, { children: [
|
|
1321
|
+
/* @__PURE__ */ jsx3(RadixDialog.Overlay, { className: "bg-ui-bg-overlay fixed inset-0" }),
|
|
1322
|
+
/* @__PURE__ */ jsxs2(
|
|
1323
|
+
RadixDialog.Content,
|
|
1324
|
+
{
|
|
1325
|
+
className: clx(
|
|
1326
|
+
"bg-ui-bg-base shadow-elevation-modal fixed left-[50%] top-[50%] flex max-h-[calc(100%-16px)] w-[calc(100%-16px)] min-w-0 max-w-2xl translate-x-[-50%] translate-y-[-50%] flex-col overflow-hidden rounded-xl p-0",
|
|
1327
|
+
{
|
|
1328
|
+
"h-[300px]": preserveHeight
|
|
1329
|
+
// Prevents the dialog from collapsing when loading async results and before the no results message is displayed
|
|
1330
|
+
}
|
|
1331
|
+
),
|
|
1332
|
+
children: [
|
|
1333
|
+
/* @__PURE__ */ jsx3(RadixDialog.Title, { className: "sr-only", children: t("app.search.title") }),
|
|
1334
|
+
/* @__PURE__ */ jsx3(RadixDialog.Description, { className: "sr-only", children: t("app.search.description") }),
|
|
1335
|
+
/* @__PURE__ */ jsx3(CommandPalette, { className: "[&_[cmdk-group-heading]]:text-muted-foreground flex h-full flex-col overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0", children }),
|
|
1336
|
+
/* @__PURE__ */ jsx3("div", { className: "bg-ui-bg-field text-ui-fg-subtle flex items-center justify-end border-t px-4 py-3", children: /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-3", children: [
|
|
1337
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
|
|
1338
|
+
/* @__PURE__ */ jsx3(Text2, { size: "xsmall", leading: "compact", children: t("app.search.navigation") }),
|
|
1339
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-1", children: [
|
|
1340
|
+
/* @__PURE__ */ jsx3(Kbd, { className: "bg-ui-bg-field-component", children: "\u2193" }),
|
|
1341
|
+
/* @__PURE__ */ jsx3(Kbd, { className: "bg-ui-bg-field-component", children: "\u2191" })
|
|
1342
|
+
] })
|
|
1343
|
+
] }),
|
|
1344
|
+
/* @__PURE__ */ jsx3("div", { className: "bg-ui-border-strong h-3 w-px" }),
|
|
1345
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-x-2", children: [
|
|
1346
|
+
/* @__PURE__ */ jsx3(Text2, { size: "xsmall", leading: "compact", children: t("app.search.openResult") }),
|
|
1347
|
+
/* @__PURE__ */ jsx3(Kbd, { className: "bg-ui-bg-field-component", children: "\u21B5" })
|
|
1348
|
+
] })
|
|
1349
|
+
] }) })
|
|
1350
|
+
]
|
|
1351
|
+
}
|
|
1352
|
+
)
|
|
1353
|
+
] }) });
|
|
1354
|
+
};
|
|
1355
|
+
var CommandInput = forwardRef(
|
|
1356
|
+
({
|
|
1357
|
+
className,
|
|
1358
|
+
value,
|
|
1359
|
+
onValueChange,
|
|
1360
|
+
area,
|
|
1361
|
+
setArea,
|
|
1362
|
+
isFetching,
|
|
1363
|
+
onBack,
|
|
1364
|
+
...props
|
|
1365
|
+
}, ref) => {
|
|
1366
|
+
const { t } = useTranslation4();
|
|
1367
|
+
const innerRef = useRef(null);
|
|
1368
|
+
const direction = useDocumentDirection();
|
|
1369
|
+
useImperativeHandle(
|
|
1370
|
+
ref,
|
|
1371
|
+
() => innerRef.current
|
|
1372
|
+
);
|
|
1373
|
+
return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col border-b", children: [
|
|
1374
|
+
/* @__PURE__ */ jsx3("div", { className: "px-4 pt-4", children: /* @__PURE__ */ jsxs2(DropdownMenu, { dir: direction, children: [
|
|
1375
|
+
/* @__PURE__ */ jsx3(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs2(
|
|
1376
|
+
Badge,
|
|
1377
|
+
{
|
|
1378
|
+
size: "2xsmall",
|
|
1379
|
+
className: "hover:bg-ui-bg-base-pressed transition-fg cursor-pointer",
|
|
1380
|
+
children: [
|
|
1381
|
+
t(`app.search.groups.${area}`),
|
|
1382
|
+
/* @__PURE__ */ jsx3(TriangleDownMini, { className: "text-ui-fg-muted" })
|
|
1383
|
+
]
|
|
1384
|
+
}
|
|
1385
|
+
) }),
|
|
1386
|
+
/* @__PURE__ */ jsx3(
|
|
1387
|
+
DropdownMenu.Content,
|
|
1388
|
+
{
|
|
1389
|
+
align: "start",
|
|
1390
|
+
className: "h-full max-h-[360px] overflow-auto",
|
|
1391
|
+
onCloseAutoFocus: (e) => {
|
|
1392
|
+
e.preventDefault();
|
|
1393
|
+
innerRef.current?.focus();
|
|
1394
|
+
},
|
|
1395
|
+
children: /* @__PURE__ */ jsx3(
|
|
1396
|
+
DropdownMenu.RadioGroup,
|
|
1397
|
+
{
|
|
1398
|
+
value: area,
|
|
1399
|
+
onValueChange: (v) => setArea(v),
|
|
1400
|
+
children: SEARCH_AREAS.map((area2) => /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
1401
|
+
area2 === "command" && /* @__PURE__ */ jsx3(DropdownMenu.Separator, {}),
|
|
1402
|
+
/* @__PURE__ */ jsx3(DropdownMenu.RadioItem, { value: area2, children: t(`app.search.groups.${area2}`) }),
|
|
1403
|
+
area2 === "all" && /* @__PURE__ */ jsx3(DropdownMenu.Separator, {})
|
|
1404
|
+
] }, area2))
|
|
1405
|
+
}
|
|
1406
|
+
)
|
|
1407
|
+
}
|
|
1408
|
+
)
|
|
1409
|
+
] }) }),
|
|
1410
|
+
/* @__PURE__ */ jsxs2("div", { className: "relative flex items-center gap-x-2 px-4 py-3", children: [
|
|
1411
|
+
onBack && /* @__PURE__ */ jsx3(
|
|
1412
|
+
IconButton,
|
|
1413
|
+
{
|
|
1414
|
+
type: "button",
|
|
1415
|
+
size: "small",
|
|
1416
|
+
variant: "transparent",
|
|
1417
|
+
onClick: onBack,
|
|
1418
|
+
children: /* @__PURE__ */ jsx3(ArrowUturnLeft, { className: "text-ui-fg-muted" })
|
|
1419
|
+
}
|
|
1420
|
+
),
|
|
1421
|
+
/* @__PURE__ */ jsx3(
|
|
1422
|
+
Command.Input,
|
|
1423
|
+
{
|
|
1424
|
+
ref: innerRef,
|
|
1425
|
+
value,
|
|
1426
|
+
onValueChange,
|
|
1427
|
+
className: clx(
|
|
1428
|
+
"placeholder:text-ui-fg-muted flex !h-6 w-full rounded-md bg-transparent text-sm outline-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
1429
|
+
className
|
|
1430
|
+
),
|
|
1431
|
+
...props
|
|
1432
|
+
}
|
|
1433
|
+
),
|
|
1434
|
+
/* @__PURE__ */ jsxs2("div", { className: "absolute end-4 top-1/2 flex -translate-y-1/2 items-center justify-end gap-x-2", children: [
|
|
1435
|
+
isFetching && /* @__PURE__ */ jsx3(Spinner, { className: "text-ui-fg-muted animate-spin" }),
|
|
1436
|
+
value && /* @__PURE__ */ jsx3(
|
|
1437
|
+
Button,
|
|
1438
|
+
{
|
|
1439
|
+
variant: "transparent",
|
|
1440
|
+
size: "small",
|
|
1441
|
+
className: "text-ui-fg-muted hover:text-ui-fg-subtle",
|
|
1442
|
+
type: "button",
|
|
1443
|
+
onClick: () => {
|
|
1444
|
+
onValueChange?.("");
|
|
1445
|
+
innerRef.current?.focus();
|
|
1446
|
+
},
|
|
1447
|
+
children: t("actions.clear")
|
|
1448
|
+
}
|
|
1449
|
+
)
|
|
1450
|
+
] })
|
|
1451
|
+
] })
|
|
1452
|
+
] });
|
|
1453
|
+
}
|
|
1454
|
+
);
|
|
1455
|
+
CommandInput.displayName = Command.Input.displayName;
|
|
1456
|
+
var CommandList = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
1457
|
+
Command.List,
|
|
1458
|
+
{
|
|
1459
|
+
ref,
|
|
1460
|
+
className: clx(
|
|
1461
|
+
"max-h-[300px] flex-1 overflow-y-auto overflow-x-hidden px-2 pb-4",
|
|
1462
|
+
className
|
|
1463
|
+
),
|
|
1464
|
+
...props
|
|
1465
|
+
}
|
|
1466
|
+
));
|
|
1467
|
+
CommandList.displayName = Command.List.displayName;
|
|
1468
|
+
var CommandEmpty = forwardRef((props, ref) => {
|
|
1469
|
+
const { t } = useTranslation4();
|
|
1470
|
+
return /* @__PURE__ */ jsx3(Command.Empty, { ref, className: "py-6 text-center text-sm", ...props, children: /* @__PURE__ */ jsxs2("div", { className: "text-ui-fg-subtle flex min-h-[236px] flex-col items-center justify-center gap-y-3", children: [
|
|
1471
|
+
/* @__PURE__ */ jsx3(MagnifyingGlass, { className: "text-ui-fg-subtle" }),
|
|
1472
|
+
/* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center justify-center gap-y-1", children: [
|
|
1473
|
+
/* @__PURE__ */ jsx3(Text2, { size: "small", weight: "plus", leading: "compact", children: props.q ? t("app.search.noResultsTitle") : t("app.search.emptySearchTitle") }),
|
|
1474
|
+
/* @__PURE__ */ jsx3(Text2, { size: "small", className: "text-ui-fg-muted", children: props.q ? t("app.search.noResultsMessage") : t("app.search.emptySearchMessage") })
|
|
1475
|
+
] })
|
|
1476
|
+
] }) });
|
|
1477
|
+
});
|
|
1478
|
+
CommandEmpty.displayName = Command.Empty.displayName;
|
|
1479
|
+
var CommandLoading = forwardRef((props, ref) => {
|
|
1480
|
+
return /* @__PURE__ */ jsxs2(
|
|
1481
|
+
Command.Loading,
|
|
1482
|
+
{
|
|
1483
|
+
ref,
|
|
1484
|
+
...props,
|
|
1485
|
+
className: "bg-ui-bg-base flex flex-col",
|
|
1486
|
+
children: [
|
|
1487
|
+
/* @__PURE__ */ jsx3("div", { className: "w-full px-2 pb-1 pt-3", children: /* @__PURE__ */ jsx3(Skeleton, { className: "h-5 w-10" }) }),
|
|
1488
|
+
Array.from({ length: 7 }).map((_, index) => /* @__PURE__ */ jsx3("div", { className: "w-full p-2", children: /* @__PURE__ */ jsx3(Skeleton, { className: "h-5 w-full" }) }, index))
|
|
1489
|
+
]
|
|
1490
|
+
}
|
|
1491
|
+
);
|
|
1492
|
+
});
|
|
1493
|
+
CommandLoading.displayName = Command.Loading.displayName;
|
|
1494
|
+
var CommandGroup = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
1495
|
+
Command.Group,
|
|
1496
|
+
{
|
|
1497
|
+
ref,
|
|
1498
|
+
className: clx(
|
|
1499
|
+
"text-ui-fg-base [&_[cmdk-group-heading]]:text-ui-fg-muted [&_[cmdk-group-heading]]:txt-compact-xsmall-plus overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1 [&_[cmdk-group-heading]]:pt-3 [&_[cmdk-item]]:py-2",
|
|
1500
|
+
className
|
|
1501
|
+
),
|
|
1502
|
+
...props
|
|
1503
|
+
}
|
|
1504
|
+
));
|
|
1505
|
+
CommandGroup.displayName = Command.Group.displayName;
|
|
1506
|
+
var CommandSeparator = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
1507
|
+
Command.Separator,
|
|
1508
|
+
{
|
|
1509
|
+
ref,
|
|
1510
|
+
className: clx("bg-border -mx-1 h-px", className),
|
|
1511
|
+
...props
|
|
1512
|
+
}
|
|
1513
|
+
));
|
|
1514
|
+
CommandSeparator.displayName = Command.Separator.displayName;
|
|
1515
|
+
var CommandItem = forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx3(
|
|
1516
|
+
Command.Item,
|
|
1517
|
+
{
|
|
1518
|
+
ref,
|
|
1519
|
+
className: clx(
|
|
1520
|
+
"aria-selected:bg-ui-bg-base-hover focus-visible:bg-ui-bg-base-hover txt-compact-small [&>svg]:text-ui-fg-subtle relative flex cursor-pointer select-none items-center gap-x-3 rounded-md p-2 outline-none data-[disabled=true]:pointer-events-none data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-50",
|
|
1521
|
+
className
|
|
1522
|
+
),
|
|
1523
|
+
...props
|
|
1524
|
+
}
|
|
1525
|
+
));
|
|
1526
|
+
CommandItem.displayName = Command.Item.displayName;
|
|
1527
|
+
|
|
1528
|
+
// src/providers/sidebar-provider/index.ts
|
|
1529
|
+
import {
|
|
1530
|
+
SIDEBAR_MENU_CONTENT,
|
|
1531
|
+
SIDEBAR_RAIL_FADE,
|
|
1532
|
+
SidebarProvider,
|
|
1533
|
+
useCollapsedSidebar,
|
|
1534
|
+
useExpandedSidebar,
|
|
1535
|
+
useSidebar,
|
|
1536
|
+
useSidebarMenuPlacement
|
|
1537
|
+
} from "@mercurjs/dashboard-shared";
|
|
1538
|
+
|
|
1539
|
+
// src/providers/search-provider/search-context.tsx
|
|
1540
|
+
import { createContext as createContext3 } from "react";
|
|
1541
|
+
var SearchContext = createContext3(null);
|
|
1542
|
+
|
|
1543
|
+
// src/providers/search-provider/search-provider.tsx
|
|
1544
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1545
|
+
var SearchProvider = ({ children }) => {
|
|
1546
|
+
const [open, setOpen] = useState5(false);
|
|
1547
|
+
const { mobile, toggle } = useSidebar();
|
|
1548
|
+
const toggleSearch = () => {
|
|
1549
|
+
const update = !open;
|
|
1550
|
+
if (update && mobile) {
|
|
1551
|
+
toggle("mobile");
|
|
1552
|
+
}
|
|
1553
|
+
setOpen(update);
|
|
1554
|
+
};
|
|
1555
|
+
useEffect5(() => {
|
|
1556
|
+
const onKeyDown = (e) => {
|
|
1557
|
+
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
|
|
1558
|
+
setOpen((prev) => !prev);
|
|
1559
|
+
}
|
|
1560
|
+
};
|
|
1561
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1562
|
+
return () => {
|
|
1563
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1564
|
+
};
|
|
1565
|
+
}, []);
|
|
1566
|
+
return /* @__PURE__ */ jsxs3(
|
|
1567
|
+
SearchContext.Provider,
|
|
1568
|
+
{
|
|
1569
|
+
value: {
|
|
1570
|
+
open,
|
|
1571
|
+
onOpenChange: setOpen,
|
|
1572
|
+
toggleSearch
|
|
1573
|
+
},
|
|
1574
|
+
children: [
|
|
1575
|
+
children,
|
|
1576
|
+
/* @__PURE__ */ jsx4(Search, {})
|
|
1577
|
+
]
|
|
1578
|
+
}
|
|
1579
|
+
);
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
// src/providers/search-provider/use-search.tsx
|
|
1583
|
+
import { useContext as useContext2 } from "react";
|
|
1584
|
+
var useSearch = () => {
|
|
1585
|
+
const context = useContext2(SearchContext);
|
|
1586
|
+
if (!context) {
|
|
1587
|
+
throw new Error("useSearch must be used within a SearchProvider");
|
|
1588
|
+
}
|
|
1589
|
+
return context;
|
|
1590
|
+
};
|
|
1591
|
+
|
|
1592
|
+
// src/components/layout/nav-item/nav-item.tsx
|
|
1593
|
+
import {
|
|
1594
|
+
useCallback as useCallback4,
|
|
1595
|
+
useEffect as useEffect6,
|
|
1596
|
+
useState as useState6
|
|
1597
|
+
} from "react";
|
|
1598
|
+
import { Kbd as Kbd2, Text as Text3, Tooltip, clx as clx2 } from "@medusajs/ui";
|
|
1599
|
+
import { Collapsible as RadixCollapsible } from "radix-ui";
|
|
1600
|
+
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
1601
|
+
import { NavLink, useLocation as useLocation3 } from "react-router-dom";
|
|
1602
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1603
|
+
var NestedNavLabel = ({
|
|
1604
|
+
label,
|
|
1605
|
+
translationNs
|
|
1606
|
+
}) => {
|
|
1607
|
+
const { t } = useTranslation5(translationNs);
|
|
1608
|
+
return /* @__PURE__ */ jsx5(Text3, { size: "small", weight: "plus", leading: "compact", children: translationNs ? t(label) : label });
|
|
1609
|
+
};
|
|
1610
|
+
var BASE_NAV_LINK_CLASSES = "text-ui-fg-subtle transition-fg hover:bg-ui-bg-subtle-hover flex items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 outline-none [&>svg]:text-ui-fg-subtle focus-visible:shadow-borders-focus";
|
|
1611
|
+
var ACTIVE_NAV_LINK_CLASSES = "bg-ui-bg-base shadow-elevation-card-rest text-ui-fg-base hover:bg-ui-bg-base";
|
|
1612
|
+
var NESTED_NAV_LINK_CLASSES = "pl-[34px] pr-2 py-1 w-full text-ui-fg-muted";
|
|
1613
|
+
var SETTING_NAV_LINK_CLASSES = "pl-2 py-1";
|
|
1614
|
+
var getIsOpen = (to, items, pathname) => {
|
|
1615
|
+
return [to, ...items?.map((i) => i.to) ?? []].some(
|
|
1616
|
+
(p) => pathname.startsWith(p)
|
|
1617
|
+
);
|
|
1618
|
+
};
|
|
1619
|
+
var NavItemTooltip = ({
|
|
1620
|
+
to,
|
|
1621
|
+
label,
|
|
1622
|
+
children
|
|
1623
|
+
}) => {
|
|
1624
|
+
const { t } = useTranslation5();
|
|
1625
|
+
const { state } = useSidebar();
|
|
1626
|
+
const globalShortcuts = useGlobalShortcuts();
|
|
1627
|
+
const shortcut = globalShortcuts.find((s) => s.to === to);
|
|
1628
|
+
if (state === "collapsed" && label) {
|
|
1629
|
+
return /* @__PURE__ */ jsx5(Tooltip, { content: label, side: "right", delayDuration: 0, children: /* @__PURE__ */ jsx5("div", { className: "w-full", children }) });
|
|
1630
|
+
}
|
|
1631
|
+
return /* @__PURE__ */ jsx5(
|
|
1632
|
+
ConditionalTooltip,
|
|
1633
|
+
{
|
|
1634
|
+
showTooltip: !!shortcut,
|
|
1635
|
+
maxWidth: 9999,
|
|
1636
|
+
content: /* @__PURE__ */ jsxs4("div", { className: "txt-compact-xsmall flex h-5 items-center justify-between gap-x-2 whitespace-nowrap", children: [
|
|
1637
|
+
/* @__PURE__ */ jsx5("span", { children: shortcut?.label }),
|
|
1638
|
+
/* @__PURE__ */ jsx5("div", { className: "flex items-center gap-x-1", children: shortcut?.keys.Mac?.map((key, index) => /* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-x-1", children: [
|
|
1639
|
+
/* @__PURE__ */ jsx5(Kbd2, { children: key }, key),
|
|
1640
|
+
index < (shortcut.keys.Mac?.length || 0) - 1 && /* @__PURE__ */ jsx5("span", { className: "txt-compact-xsmall text-ui-fg-muted", children: t("app.keyboardShortcuts.then") })
|
|
1641
|
+
] }, index)) })
|
|
1642
|
+
] }),
|
|
1643
|
+
side: "right",
|
|
1644
|
+
delayDuration: 1500,
|
|
1645
|
+
children: /* @__PURE__ */ jsx5("div", { className: "w-full", children })
|
|
1646
|
+
}
|
|
1647
|
+
);
|
|
1648
|
+
};
|
|
1649
|
+
var NavItem = ({
|
|
1650
|
+
icon,
|
|
1651
|
+
label,
|
|
1652
|
+
to,
|
|
1653
|
+
items,
|
|
1654
|
+
type = "core",
|
|
1655
|
+
from,
|
|
1656
|
+
translationNs
|
|
1657
|
+
}) => {
|
|
1658
|
+
const { t } = useTranslation5(translationNs);
|
|
1659
|
+
const { pathname } = useLocation3();
|
|
1660
|
+
const displayLabel = translationNs ? t(label) : label;
|
|
1661
|
+
const [open, setOpen] = useState6(getIsOpen(to, items, pathname));
|
|
1662
|
+
useEffect6(() => {
|
|
1663
|
+
setOpen(getIsOpen(to, items, pathname));
|
|
1664
|
+
}, [pathname, to, items]);
|
|
1665
|
+
const navLinkClassNames = useCallback4(
|
|
1666
|
+
({
|
|
1667
|
+
to: to2,
|
|
1668
|
+
isActive,
|
|
1669
|
+
isNested = false,
|
|
1670
|
+
isSetting: isSetting2 = false
|
|
1671
|
+
}) => {
|
|
1672
|
+
if (["core", "setting"].includes(type)) {
|
|
1673
|
+
isActive = pathname.startsWith(to2);
|
|
1674
|
+
if (isActive && !isNested && items?.length) {
|
|
1675
|
+
const nestedIsActive = items.some(
|
|
1676
|
+
(item) => pathname.startsWith(item.to)
|
|
1677
|
+
);
|
|
1678
|
+
if (nestedIsActive) {
|
|
1679
|
+
isActive = false;
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
return clx2(BASE_NAV_LINK_CLASSES, {
|
|
1684
|
+
[NESTED_NAV_LINK_CLASSES]: isNested,
|
|
1685
|
+
[ACTIVE_NAV_LINK_CLASSES]: isActive,
|
|
1686
|
+
[SETTING_NAV_LINK_CLASSES]: isSetting2
|
|
1687
|
+
});
|
|
1688
|
+
},
|
|
1689
|
+
[type, pathname, items]
|
|
1690
|
+
);
|
|
1691
|
+
const isSetting = type === "setting";
|
|
1692
|
+
return /* @__PURE__ */ jsxs4(
|
|
1693
|
+
"div",
|
|
1694
|
+
{
|
|
1695
|
+
className: "px-3",
|
|
1696
|
+
"data-testid": `sidebar-nav-item-${to.replace(/\//g, "-").replace(/^-/, "")}`,
|
|
1697
|
+
children: [
|
|
1698
|
+
/* @__PURE__ */ jsx5(NavItemTooltip, { to, label: displayLabel, children: /* @__PURE__ */ jsxs4(
|
|
1699
|
+
NavLink,
|
|
1700
|
+
{
|
|
1701
|
+
to,
|
|
1702
|
+
end: items?.some((i) => i.to === pathname),
|
|
1703
|
+
state: from ? {
|
|
1704
|
+
from
|
|
1705
|
+
} : void 0,
|
|
1706
|
+
className: ({ isActive }) => {
|
|
1707
|
+
return clx2(navLinkClassNames({ isActive, isSetting, to }), {
|
|
1708
|
+
"max-lg:hidden": !!items?.length
|
|
1709
|
+
});
|
|
1710
|
+
},
|
|
1711
|
+
"data-testid": `sidebar-nav-link-${to.replace(/\//g, "-").replace(/^-/, "")}`,
|
|
1712
|
+
children: [
|
|
1713
|
+
type !== "setting" && /* @__PURE__ */ jsx5("div", { className: "flex size-6 shrink-0 items-center justify-center", children: /* @__PURE__ */ jsx5(Icon, { icon, type }) }),
|
|
1714
|
+
/* @__PURE__ */ jsx5(
|
|
1715
|
+
Text3,
|
|
1716
|
+
{
|
|
1717
|
+
size: "small",
|
|
1718
|
+
weight: "plus",
|
|
1719
|
+
leading: "compact",
|
|
1720
|
+
className: clx2("shrink-0 whitespace-nowrap", SIDEBAR_RAIL_FADE),
|
|
1721
|
+
children: displayLabel
|
|
1722
|
+
}
|
|
1723
|
+
)
|
|
1724
|
+
]
|
|
1725
|
+
}
|
|
1726
|
+
) }),
|
|
1727
|
+
items && items.length > 0 && /* @__PURE__ */ jsxs4(
|
|
1728
|
+
RadixCollapsible.Root,
|
|
1729
|
+
{
|
|
1730
|
+
open,
|
|
1731
|
+
onOpenChange: setOpen,
|
|
1732
|
+
className: "group-data-[state=collapsed]/sidebar:hidden",
|
|
1733
|
+
children: [
|
|
1734
|
+
/* @__PURE__ */ jsxs4(
|
|
1735
|
+
RadixCollapsible.Trigger,
|
|
1736
|
+
{
|
|
1737
|
+
className: clx2(
|
|
1738
|
+
"flex w-full items-center gap-x-2 rounded-md py-0.5 pl-0.5 pr-2 text-ui-fg-subtle outline-none transition-fg hover:bg-ui-bg-subtle-hover hover:text-ui-fg-base lg:hidden",
|
|
1739
|
+
{ "pl-2": isSetting }
|
|
1740
|
+
),
|
|
1741
|
+
children: [
|
|
1742
|
+
/* @__PURE__ */ jsx5("div", { className: "flex size-6 items-center justify-center", children: /* @__PURE__ */ jsx5(Icon, { icon, type }) }),
|
|
1743
|
+
/* @__PURE__ */ jsx5(Text3, { size: "small", weight: "plus", leading: "compact", children: displayLabel })
|
|
1744
|
+
]
|
|
1745
|
+
}
|
|
1746
|
+
),
|
|
1747
|
+
/* @__PURE__ */ jsx5(RadixCollapsible.Content, { children: /* @__PURE__ */ jsx5(
|
|
1748
|
+
"div",
|
|
1749
|
+
{
|
|
1750
|
+
className: "flex flex-col gap-y-0.5 pb-2 pt-0.5",
|
|
1751
|
+
"data-testid": `sidebar-nav-nested-items-${to.replace(/\//g, "-").replace(/^-/, "")}`,
|
|
1752
|
+
children: /* @__PURE__ */ jsxs4("ul", { className: "flex flex-col gap-y-0.5", children: [
|
|
1753
|
+
/* @__PURE__ */ jsx5("li", { className: "flex w-full items-center gap-x-1 lg:hidden", children: /* @__PURE__ */ jsx5(NavItemTooltip, { to, children: /* @__PURE__ */ jsx5(
|
|
1754
|
+
NavLink,
|
|
1755
|
+
{
|
|
1756
|
+
to,
|
|
1757
|
+
end: true,
|
|
1758
|
+
className: ({ isActive }) => {
|
|
1759
|
+
return clx2(
|
|
1760
|
+
navLinkClassNames({
|
|
1761
|
+
to,
|
|
1762
|
+
isActive,
|
|
1763
|
+
isSetting,
|
|
1764
|
+
isNested: true
|
|
1765
|
+
})
|
|
1766
|
+
);
|
|
1767
|
+
},
|
|
1768
|
+
"data-testid": `sidebar-nav-link-nested-${to.replace(/\//g, "-").replace(/^-/, "")}`,
|
|
1769
|
+
children: /* @__PURE__ */ jsx5(Text3, { size: "small", weight: "plus", leading: "compact", children: displayLabel })
|
|
1770
|
+
}
|
|
1771
|
+
) }) }),
|
|
1772
|
+
items.map((item) => {
|
|
1773
|
+
return /* @__PURE__ */ jsx5("li", { className: "flex h-7 items-center", children: /* @__PURE__ */ jsx5(NavItemTooltip, { to: item.to, children: /* @__PURE__ */ jsx5(
|
|
1774
|
+
NavLink,
|
|
1775
|
+
{
|
|
1776
|
+
to: item.to,
|
|
1777
|
+
end: true,
|
|
1778
|
+
className: ({ isActive }) => {
|
|
1779
|
+
return clx2(
|
|
1780
|
+
navLinkClassNames({
|
|
1781
|
+
to: item.to,
|
|
1782
|
+
isActive,
|
|
1783
|
+
isSetting,
|
|
1784
|
+
isNested: true
|
|
1785
|
+
})
|
|
1786
|
+
);
|
|
1787
|
+
},
|
|
1788
|
+
"data-testid": `sidebar-nav-link-nested-${item.to.replace(/\//g, "-").replace(/^-/, "")}`,
|
|
1789
|
+
children: /* @__PURE__ */ jsx5(
|
|
1790
|
+
NestedNavLabel,
|
|
1791
|
+
{
|
|
1792
|
+
label: item.label,
|
|
1793
|
+
translationNs: item.translationNs
|
|
1794
|
+
}
|
|
1795
|
+
)
|
|
1796
|
+
}
|
|
1797
|
+
) }) }, item.to);
|
|
1798
|
+
})
|
|
1799
|
+
] })
|
|
1800
|
+
}
|
|
1801
|
+
) })
|
|
1802
|
+
]
|
|
1803
|
+
}
|
|
1804
|
+
)
|
|
1805
|
+
]
|
|
1806
|
+
}
|
|
1807
|
+
);
|
|
1808
|
+
};
|
|
1809
|
+
var Icon = ({ icon, type }) => {
|
|
1810
|
+
if (!icon) {
|
|
1811
|
+
return null;
|
|
1812
|
+
}
|
|
1813
|
+
return type === "extension" ? /* @__PURE__ */ jsx5("div", { className: "flex h-5 w-5 items-center justify-center rounded-[4px] bg-ui-bg-base shadow-borders-base", children: /* @__PURE__ */ jsx5("div", { className: "h-[15px] w-[15px] overflow-hidden rounded-sm", children: icon }) }) : icon;
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
// src/components/layout/shell/shell.tsx
|
|
1817
|
+
import { SidebarLeft, TriangleRightMini, XMark } from "@medusajs/icons";
|
|
1818
|
+
import { IconButton as IconButton2, clx as clx3 } from "@medusajs/ui";
|
|
1819
|
+
import { AnimatePresence } from "motion/react";
|
|
1820
|
+
import { Dialog as RadixDialog2 } from "radix-ui";
|
|
1821
|
+
import { useEffect as useEffect7, useState as useState8 } from "react";
|
|
1822
|
+
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
1823
|
+
import {
|
|
1824
|
+
Link,
|
|
1825
|
+
Outlet,
|
|
1826
|
+
useMatches,
|
|
1827
|
+
useNavigation
|
|
1828
|
+
} from "react-router-dom";
|
|
1829
|
+
import { WidgetZone } from "@mercurjs/dashboard-shared";
|
|
1830
|
+
|
|
1831
|
+
// src/providers/keybind-provider/keybind-provider.tsx
|
|
1832
|
+
import { useCallback as useCallback5, useMemo as useMemo3, useState as useState7 } from "react";
|
|
1833
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1834
|
+
var KeybindProvider = ({
|
|
1835
|
+
shortcuts,
|
|
1836
|
+
debounce = 500,
|
|
1837
|
+
children
|
|
1838
|
+
}) => {
|
|
1839
|
+
const [storeShortcuts, setStoreCommands] = useState7(
|
|
1840
|
+
shortcuts.map((shr) => getShortcutWithDefaultValues(shr))
|
|
1841
|
+
);
|
|
1842
|
+
const registerShortcut = useCallback5(
|
|
1843
|
+
(shortcut) => {
|
|
1844
|
+
setStoreCommands((prevShortcuts) => {
|
|
1845
|
+
const idx = findShortcutIndex(shortcuts, getShortcutKeys(shortcut));
|
|
1846
|
+
const newShortcuts = [...prevShortcuts];
|
|
1847
|
+
if (idx > -1) {
|
|
1848
|
+
newShortcuts[idx] = getShortcutWithDefaultValues(shortcut);
|
|
1849
|
+
return prevShortcuts;
|
|
1850
|
+
}
|
|
1851
|
+
return [...prevShortcuts, getShortcutWithDefaultValues(shortcut)];
|
|
1852
|
+
});
|
|
1853
|
+
},
|
|
1854
|
+
[shortcuts]
|
|
1855
|
+
);
|
|
1856
|
+
const getKeysByPlatform = useCallback5((command) => {
|
|
1857
|
+
return findFirstPlatformMatch(command.keys);
|
|
1858
|
+
}, []);
|
|
1859
|
+
useShortcuts({ shortcuts: storeShortcuts, debounce });
|
|
1860
|
+
const commandsContext = useMemo3(
|
|
1861
|
+
() => ({
|
|
1862
|
+
shortcuts: storeShortcuts,
|
|
1863
|
+
registerShortcut,
|
|
1864
|
+
getKeysByPlatform
|
|
1865
|
+
}),
|
|
1866
|
+
[storeShortcuts, registerShortcut, getKeysByPlatform]
|
|
1867
|
+
);
|
|
1868
|
+
return /* @__PURE__ */ jsx6(KeybindContext.Provider, { value: commandsContext, children });
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
// src/components/common/progress-bar/progress-bar.tsx
|
|
1872
|
+
import { motion } from "motion/react";
|
|
1873
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
1874
|
+
var ProgressBar = ({ duration = 2 }) => {
|
|
1875
|
+
return /* @__PURE__ */ jsx7(
|
|
1876
|
+
motion.div,
|
|
1877
|
+
{
|
|
1878
|
+
className: "bg-ui-fg-subtle size-full",
|
|
1879
|
+
initial: {
|
|
1880
|
+
width: "0%"
|
|
1881
|
+
},
|
|
1882
|
+
transition: {
|
|
1883
|
+
delay: 0.2,
|
|
1884
|
+
duration,
|
|
1885
|
+
ease: "linear"
|
|
1886
|
+
},
|
|
1887
|
+
animate: {
|
|
1888
|
+
width: "90%"
|
|
1889
|
+
},
|
|
1890
|
+
exit: {
|
|
1891
|
+
width: "100%",
|
|
1892
|
+
transition: { duration: 0.2, ease: "linear" }
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
);
|
|
1896
|
+
};
|
|
1897
|
+
|
|
1898
|
+
// src/components/layout/shell/shell.tsx
|
|
1899
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1900
|
+
var Shell = ({ children, rail = true }) => {
|
|
1901
|
+
const globalShortcuts = useGlobalShortcuts();
|
|
1902
|
+
const navigation = useNavigation();
|
|
1903
|
+
const loading = navigation.state === "loading";
|
|
1904
|
+
return /* @__PURE__ */ jsx8(KeybindProvider, { shortcuts: globalShortcuts, children: /* @__PURE__ */ jsxs5("div", { className: "relative flex h-screen flex-col items-start overflow-hidden lg:flex-row", children: [
|
|
1905
|
+
/* @__PURE__ */ jsx8(NavigationBar, { loading }),
|
|
1906
|
+
/* @__PURE__ */ jsxs5("div", { children: [
|
|
1907
|
+
/* @__PURE__ */ jsx8(MobileSidebarContainer, { children }),
|
|
1908
|
+
/* @__PURE__ */ jsx8(DesktopSidebarContainer, { rail, children })
|
|
1909
|
+
] }),
|
|
1910
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex h-screen w-full flex-col overflow-auto", children: [
|
|
1911
|
+
/* @__PURE__ */ jsx8(Topbar, {}),
|
|
1912
|
+
/* @__PURE__ */ jsx8(
|
|
1913
|
+
"main",
|
|
1914
|
+
{
|
|
1915
|
+
className: clx3(
|
|
1916
|
+
"flex h-full w-full flex-col items-center overflow-y-auto transition-opacity delay-200 duration-200",
|
|
1917
|
+
{
|
|
1918
|
+
"opacity-25": loading
|
|
1919
|
+
}
|
|
1920
|
+
),
|
|
1921
|
+
children: /* @__PURE__ */ jsx8(Gutter, { children: /* @__PURE__ */ jsx8(Outlet, {}) })
|
|
1922
|
+
}
|
|
1923
|
+
)
|
|
1924
|
+
] })
|
|
1925
|
+
] }) });
|
|
1926
|
+
};
|
|
1927
|
+
var NavigationBar = ({ loading }) => {
|
|
1928
|
+
const [showBar, setShowBar] = useState8(false);
|
|
1929
|
+
useEffect7(() => {
|
|
1930
|
+
let timeout;
|
|
1931
|
+
if (loading) {
|
|
1932
|
+
timeout = setTimeout(() => {
|
|
1933
|
+
setShowBar(true);
|
|
1934
|
+
}, 200);
|
|
1935
|
+
} else {
|
|
1936
|
+
setShowBar(false);
|
|
1937
|
+
}
|
|
1938
|
+
return () => {
|
|
1939
|
+
clearTimeout(timeout);
|
|
1940
|
+
};
|
|
1941
|
+
}, [loading]);
|
|
1942
|
+
return /* @__PURE__ */ jsx8("div", { className: "fixed inset-x-0 top-0 z-50 h-1", children: /* @__PURE__ */ jsx8(AnimatePresence, { children: showBar ? /* @__PURE__ */ jsx8(ProgressBar, {}) : null }) });
|
|
1943
|
+
};
|
|
1944
|
+
var Gutter = ({ children }) => {
|
|
1945
|
+
return /* @__PURE__ */ jsx8("div", { className: "flex w-full max-w-[1600px] flex-col gap-y-2 p-3", children });
|
|
1946
|
+
};
|
|
1947
|
+
var Breadcrumbs = () => {
|
|
1948
|
+
const matches = useMatches();
|
|
1949
|
+
const crumbs = matches.filter((match) => match.handle?.breadcrumb).map((match) => {
|
|
1950
|
+
const handle = match.handle;
|
|
1951
|
+
let label = void 0;
|
|
1952
|
+
try {
|
|
1953
|
+
label = handle.breadcrumb?.(match);
|
|
1954
|
+
} catch {
|
|
1955
|
+
}
|
|
1956
|
+
if (!label) {
|
|
1957
|
+
return null;
|
|
1958
|
+
}
|
|
1959
|
+
return {
|
|
1960
|
+
label,
|
|
1961
|
+
path: match.pathname
|
|
1962
|
+
};
|
|
1963
|
+
}).filter(Boolean);
|
|
1964
|
+
return /* @__PURE__ */ jsx8(
|
|
1965
|
+
"ol",
|
|
1966
|
+
{
|
|
1967
|
+
className: clx3(
|
|
1968
|
+
"text-ui-fg-muted txt-compact-small-plus flex select-none items-center"
|
|
1969
|
+
),
|
|
1970
|
+
children: crumbs.map((crumb, index) => {
|
|
1971
|
+
const isLast = index === crumbs.length - 1;
|
|
1972
|
+
const isSingle = crumbs.length === 1;
|
|
1973
|
+
return /* @__PURE__ */ jsxs5("li", { className: clx3("flex items-center"), children: [
|
|
1974
|
+
!isLast ? /* @__PURE__ */ jsx8(
|
|
1975
|
+
Link,
|
|
1976
|
+
{
|
|
1977
|
+
className: "transition-fg hover:text-ui-fg-subtle",
|
|
1978
|
+
to: crumb.path,
|
|
1979
|
+
children: crumb.label
|
|
1980
|
+
}
|
|
1981
|
+
) : /* @__PURE__ */ jsxs5("div", { children: [
|
|
1982
|
+
!isSingle && /* @__PURE__ */ jsx8("span", { className: "block lg:hidden", children: "..." }),
|
|
1983
|
+
/* @__PURE__ */ jsx8(
|
|
1984
|
+
"span",
|
|
1985
|
+
{
|
|
1986
|
+
className: clx3({
|
|
1987
|
+
"hidden lg:block": !isSingle
|
|
1988
|
+
}),
|
|
1989
|
+
children: crumb.label
|
|
1990
|
+
},
|
|
1991
|
+
index
|
|
1992
|
+
)
|
|
1993
|
+
] }),
|
|
1994
|
+
!isLast && /* @__PURE__ */ jsx8("span", { className: "mx-2", children: /* @__PURE__ */ jsx8(TriangleRightMini, { className: "rtl:rotate-180" }) })
|
|
1995
|
+
] }, index);
|
|
1996
|
+
})
|
|
1997
|
+
}
|
|
1998
|
+
);
|
|
1999
|
+
};
|
|
2000
|
+
var ToggleSidebar = () => {
|
|
2001
|
+
const { toggle, state } = useSidebar();
|
|
2002
|
+
return /* @__PURE__ */ jsxs5("div", { children: [
|
|
2003
|
+
/* @__PURE__ */ jsx8(
|
|
2004
|
+
IconButton2,
|
|
2005
|
+
{
|
|
2006
|
+
className: "hidden lg:flex",
|
|
2007
|
+
variant: "transparent",
|
|
2008
|
+
onClick: () => toggle("desktop"),
|
|
2009
|
+
size: "small",
|
|
2010
|
+
"aria-expanded": state === "expanded",
|
|
2011
|
+
children: /* @__PURE__ */ jsx8(SidebarLeft, { className: "text-ui-fg-muted rtl:rotate-180" })
|
|
2012
|
+
}
|
|
2013
|
+
),
|
|
2014
|
+
/* @__PURE__ */ jsx8(
|
|
2015
|
+
IconButton2,
|
|
2016
|
+
{
|
|
2017
|
+
className: "hidden max-lg:flex",
|
|
2018
|
+
variant: "transparent",
|
|
2019
|
+
onClick: () => toggle("mobile"),
|
|
2020
|
+
size: "small",
|
|
2021
|
+
children: /* @__PURE__ */ jsx8(SidebarLeft, { className: "text-ui-fg-muted rtl:rotate-180" })
|
|
2022
|
+
}
|
|
2023
|
+
)
|
|
2024
|
+
] });
|
|
2025
|
+
};
|
|
2026
|
+
var Topbar = () => {
|
|
2027
|
+
return /* @__PURE__ */ jsxs5("div", { className: "grid w-full grid-cols-2 border-b p-3", children: [
|
|
2028
|
+
/* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-x-1.5", children: [
|
|
2029
|
+
/* @__PURE__ */ jsx8(ToggleSidebar, {}),
|
|
2030
|
+
/* @__PURE__ */ jsx8(Breadcrumbs, {})
|
|
2031
|
+
] }),
|
|
2032
|
+
/* @__PURE__ */ jsx8("div", { className: "flex items-center justify-end gap-x-3", children: /* @__PURE__ */ jsx8(WidgetZone, { id: "topbar" }) })
|
|
2033
|
+
] });
|
|
2034
|
+
};
|
|
2035
|
+
var DesktopSidebarContainer = ({
|
|
2036
|
+
children,
|
|
2037
|
+
rail
|
|
2038
|
+
}) => {
|
|
2039
|
+
const { state } = useSidebar();
|
|
2040
|
+
return /* @__PURE__ */ jsx8(
|
|
2041
|
+
"div",
|
|
2042
|
+
{
|
|
2043
|
+
"data-state": state,
|
|
2044
|
+
className: clx3(
|
|
2045
|
+
"group/sidebar hidden h-screen w-[220px] shrink-0 overflow-x-hidden border-e lg:flex",
|
|
2046
|
+
"transition-[width] duration-200 ease-sidebar motion-reduce:transition-none",
|
|
2047
|
+
rail ? "data-[state=collapsed]:w-[52px]" : "data-[state=collapsed]:w-0 data-[state=collapsed]:border-e-0"
|
|
2048
|
+
),
|
|
2049
|
+
children: rail ? children : /* @__PURE__ */ jsx8("div", { className: "flex w-[220px] shrink-0", children })
|
|
2050
|
+
}
|
|
2051
|
+
);
|
|
2052
|
+
};
|
|
2053
|
+
var MobileSidebarContainer = ({ children }) => {
|
|
2054
|
+
const { t } = useTranslation6();
|
|
2055
|
+
const { mobile, toggle } = useSidebar();
|
|
2056
|
+
return /* @__PURE__ */ jsx8(RadixDialog2.Root, { open: mobile, onOpenChange: () => toggle("mobile"), children: /* @__PURE__ */ jsxs5(RadixDialog2.Portal, { children: [
|
|
2057
|
+
/* @__PURE__ */ jsx8(
|
|
2058
|
+
RadixDialog2.Overlay,
|
|
2059
|
+
{
|
|
2060
|
+
className: clx3(
|
|
2061
|
+
"bg-ui-bg-overlay fixed inset-0",
|
|
2062
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"
|
|
2063
|
+
)
|
|
2064
|
+
}
|
|
2065
|
+
),
|
|
2066
|
+
/* @__PURE__ */ jsxs5(
|
|
2067
|
+
RadixDialog2.Content,
|
|
2068
|
+
{
|
|
2069
|
+
className: clx3(
|
|
2070
|
+
"bg-ui-bg-subtle shadow-elevation-modal fixed inset-y-2 start-2 flex w-full max-w-[304px] flex-col overflow-hidden rounded-lg border-r",
|
|
2071
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-start-1/2 data-[state=open]:slide-in-from-start-1/2 duration-200"
|
|
2072
|
+
),
|
|
2073
|
+
children: [
|
|
2074
|
+
/* @__PURE__ */ jsxs5("div", { className: "p-3", children: [
|
|
2075
|
+
/* @__PURE__ */ jsx8(RadixDialog2.Close, { asChild: true, children: /* @__PURE__ */ jsx8(
|
|
2076
|
+
IconButton2,
|
|
2077
|
+
{
|
|
2078
|
+
size: "small",
|
|
2079
|
+
variant: "transparent",
|
|
2080
|
+
className: "text-ui-fg-subtle",
|
|
2081
|
+
children: /* @__PURE__ */ jsx8(XMark, {})
|
|
2082
|
+
}
|
|
2083
|
+
) }),
|
|
2084
|
+
/* @__PURE__ */ jsx8(RadixDialog2.Title, { className: "sr-only", children: t("app.nav.accessibility.title") }),
|
|
2085
|
+
/* @__PURE__ */ jsx8(RadixDialog2.Description, { className: "sr-only", children: t("app.nav.accessibility.description") })
|
|
2086
|
+
] }),
|
|
2087
|
+
children
|
|
2088
|
+
]
|
|
2089
|
+
}
|
|
2090
|
+
)
|
|
2091
|
+
] }) });
|
|
2092
|
+
};
|
|
2093
|
+
|
|
2094
|
+
// src/components/layout/user-menu/user-menu.tsx
|
|
2095
|
+
import {
|
|
2096
|
+
BookOpen,
|
|
2097
|
+
CircleHalfSolid,
|
|
2098
|
+
EllipsisHorizontal,
|
|
2099
|
+
Keyboard,
|
|
2100
|
+
OpenRectArrowOut,
|
|
2101
|
+
TimelineVertical,
|
|
2102
|
+
User as UserIcon,
|
|
2103
|
+
XMark as XMark2
|
|
2104
|
+
} from "@medusajs/icons";
|
|
2105
|
+
import {
|
|
2106
|
+
Avatar,
|
|
2107
|
+
DropdownMenu as DropdownMenu2,
|
|
2108
|
+
Heading,
|
|
2109
|
+
IconButton as IconButton3,
|
|
2110
|
+
Input,
|
|
2111
|
+
Kbd as Kbd3,
|
|
2112
|
+
Text as Text4,
|
|
2113
|
+
clx as clx4
|
|
2114
|
+
} from "@medusajs/ui";
|
|
2115
|
+
import { Dialog as RadixDialog3 } from "radix-ui";
|
|
2116
|
+
import { useTranslation as useTranslation7 } from "react-i18next";
|
|
2117
|
+
import { useState as useState9 } from "react";
|
|
2118
|
+
import { Link as Link2, useLocation as useLocation4, useNavigate as useNavigate3 } from "react-router-dom";
|
|
2119
|
+
|
|
2120
|
+
// src/providers/theme-provider/use-theme.tsx
|
|
2121
|
+
import { useContext as useContext3 } from "react";
|
|
2122
|
+
var useTheme = () => {
|
|
2123
|
+
const context = useContext3(ThemeContext);
|
|
2124
|
+
if (!context) {
|
|
2125
|
+
throw new Error("useTheme must be used within a ThemeProvider");
|
|
2126
|
+
}
|
|
2127
|
+
return context;
|
|
2128
|
+
};
|
|
2129
|
+
|
|
2130
|
+
// src/components/layout/user-menu/user-menu.tsx
|
|
2131
|
+
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2132
|
+
var UserMenu = () => {
|
|
2133
|
+
const { t } = useTranslation7();
|
|
2134
|
+
const location = useLocation4();
|
|
2135
|
+
const direction = useDocumentDirection();
|
|
2136
|
+
const menuPlacement = useSidebarMenuPlacement("end");
|
|
2137
|
+
const [openMenu, setOpenMenu] = useState9(false);
|
|
2138
|
+
const [openModal, setOpenModal] = useState9(false);
|
|
2139
|
+
const toggleModal = () => {
|
|
2140
|
+
setOpenMenu(false);
|
|
2141
|
+
setOpenModal(!openModal);
|
|
2142
|
+
};
|
|
2143
|
+
return /* @__PURE__ */ jsxs6("div", { "data-testid": "sidebar-user-menu", children: [
|
|
2144
|
+
/* @__PURE__ */ jsxs6(DropdownMenu2, { dir: direction, open: openMenu, onOpenChange: setOpenMenu, "data-testid": "sidebar-user-menu-dropdown", children: [
|
|
2145
|
+
/* @__PURE__ */ jsx9(UserBadge, {}),
|
|
2146
|
+
/* @__PURE__ */ jsxs6(DropdownMenu2.Content, { ...menuPlacement, className: SIDEBAR_MENU_CONTENT, "data-testid": "sidebar-user-menu-content", children: [
|
|
2147
|
+
/* @__PURE__ */ jsx9(UserItem, {}),
|
|
2148
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-1" }),
|
|
2149
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Item, { asChild: true, "data-testid": "sidebar-user-menu-profile-settings", children: /* @__PURE__ */ jsxs6(Link2, { to: "/settings/profile", state: { from: location.pathname }, children: [
|
|
2150
|
+
/* @__PURE__ */ jsx9(UserIcon, { className: "text-ui-fg-subtle me-2" }),
|
|
2151
|
+
t("app.menus.user.profileSettings")
|
|
2152
|
+
] }) }),
|
|
2153
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-2" }),
|
|
2154
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Item, { asChild: true, "data-testid": "sidebar-user-menu-documentation", children: /* @__PURE__ */ jsxs6(Link2, { to: "https://docs.mercurjs.com/welcome", target: "_blank", children: [
|
|
2155
|
+
/* @__PURE__ */ jsx9(BookOpen, { className: "text-ui-fg-subtle me-2" }),
|
|
2156
|
+
t("app.menus.user.documentation")
|
|
2157
|
+
] }) }),
|
|
2158
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Item, { asChild: true, "data-testid": "sidebar-user-menu-changelog", children: /* @__PURE__ */ jsxs6(Link2, { to: "https://www.mercurjs.com/updates", target: "_blank", children: [
|
|
2159
|
+
/* @__PURE__ */ jsx9(TimelineVertical, { className: "text-ui-fg-subtle me-2" }),
|
|
2160
|
+
t("app.menus.user.changelog")
|
|
2161
|
+
] }) }),
|
|
2162
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-3" }),
|
|
2163
|
+
/* @__PURE__ */ jsxs6(DropdownMenu2.Item, { onClick: toggleModal, "data-testid": "sidebar-user-menu-shortcuts", children: [
|
|
2164
|
+
/* @__PURE__ */ jsx9(Keyboard, { className: "text-ui-fg-subtle me-2" }),
|
|
2165
|
+
t("app.menus.user.shortcuts")
|
|
2166
|
+
] }),
|
|
2167
|
+
/* @__PURE__ */ jsx9(ThemeToggle, {}),
|
|
2168
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.Separator, { "data-testid": "sidebar-user-menu-separator-4" }),
|
|
2169
|
+
/* @__PURE__ */ jsx9(Logout, {})
|
|
2170
|
+
] })
|
|
2171
|
+
] }),
|
|
2172
|
+
/* @__PURE__ */ jsx9(GlobalKeybindsModal, { open: openModal, onOpenChange: setOpenModal })
|
|
2173
|
+
] });
|
|
2174
|
+
};
|
|
2175
|
+
var UserBadge = () => {
|
|
2176
|
+
const { user, isPending, isError, error } = useMe();
|
|
2177
|
+
const name = [user?.first_name, user?.last_name].filter(Boolean).join(" ");
|
|
2178
|
+
const displayName = name || user?.email;
|
|
2179
|
+
const fallback = displayName ? displayName[0].toUpperCase() : null;
|
|
2180
|
+
if (isPending) {
|
|
2181
|
+
return /* @__PURE__ */ jsxs6("button", { className: "shadow-borders-base flex max-w-[192px] select-none items-center gap-x-2 overflow-hidden text-ellipsis whitespace-nowrap rounded-full py-1 ps-1 pe-2.5", children: [
|
|
2182
|
+
/* @__PURE__ */ jsx9(Skeleton, { className: "h-5 w-5 rounded-full" }),
|
|
2183
|
+
/* @__PURE__ */ jsx9(Skeleton, { className: "h-[9px] w-[70px]" })
|
|
2184
|
+
] });
|
|
2185
|
+
}
|
|
2186
|
+
if (isError) {
|
|
2187
|
+
throw error;
|
|
2188
|
+
}
|
|
2189
|
+
return /* @__PURE__ */ jsx9("div", { className: "p-3", "data-testid": "sidebar-user-menu-badge", children: /* @__PURE__ */ jsxs6(
|
|
2190
|
+
DropdownMenu2.Trigger,
|
|
2191
|
+
{
|
|
2192
|
+
disabled: !user,
|
|
2193
|
+
className: clx4(
|
|
2194
|
+
"bg-ui-bg-subtle grid w-full cursor-pointer grid-cols-[24px_1fr_15px] items-center gap-2 rounded-md py-1 ps-0.5 pe-2 outline-none",
|
|
2195
|
+
"hover:bg-ui-bg-subtle-hover",
|
|
2196
|
+
"data-[state=open]:bg-ui-bg-subtle-hover",
|
|
2197
|
+
"focus-visible:shadow-borders-focus"
|
|
2198
|
+
),
|
|
2199
|
+
"data-testid": "sidebar-user-menu-trigger",
|
|
2200
|
+
children: [
|
|
2201
|
+
/* @__PURE__ */ jsx9("div", { className: "flex size-6 shrink-0 items-center justify-center", "data-testid": "sidebar-user-menu-avatar-container", children: fallback ? /* @__PURE__ */ jsx9(Avatar, { size: "xsmall", fallback, "data-testid": "sidebar-user-menu-avatar" }) : /* @__PURE__ */ jsx9(Skeleton, { className: "h-6 w-6 rounded-full" }) }),
|
|
2202
|
+
/* @__PURE__ */ jsx9("div", { className: clx4("flex items-center overflow-hidden whitespace-nowrap", SIDEBAR_RAIL_FADE), "data-testid": "sidebar-user-menu-name-container", children: displayName ? /* @__PURE__ */ jsx9(
|
|
2203
|
+
Text4,
|
|
2204
|
+
{
|
|
2205
|
+
size: "xsmall",
|
|
2206
|
+
weight: "plus",
|
|
2207
|
+
leading: "compact",
|
|
2208
|
+
className: "truncate",
|
|
2209
|
+
"data-testid": "sidebar-user-menu-name",
|
|
2210
|
+
children: displayName
|
|
2211
|
+
}
|
|
2212
|
+
) : /* @__PURE__ */ jsx9(Skeleton, { className: "h-[9px] w-[70px]" }) }),
|
|
2213
|
+
/* @__PURE__ */ jsx9(EllipsisHorizontal, { className: clx4("text-ui-fg-muted", SIDEBAR_RAIL_FADE) })
|
|
2214
|
+
]
|
|
2215
|
+
}
|
|
2216
|
+
) });
|
|
2217
|
+
};
|
|
2218
|
+
var ThemeToggle = () => {
|
|
2219
|
+
const { t } = useTranslation7();
|
|
2220
|
+
const { theme, setTheme } = useTheme();
|
|
2221
|
+
return /* @__PURE__ */ jsxs6(DropdownMenu2.SubMenu, { "data-testid": "sidebar-user-menu-theme-toggle", children: [
|
|
2222
|
+
/* @__PURE__ */ jsxs6(DropdownMenu2.SubMenuTrigger, { dir: "ltr", className: "rounded-md rtl:rotate-180", "data-testid": "sidebar-user-menu-theme-trigger", children: [
|
|
2223
|
+
/* @__PURE__ */ jsx9(CircleHalfSolid, { className: "text-ui-fg-subtle me-2" }),
|
|
2224
|
+
/* @__PURE__ */ jsx9("span", { className: "rtl:rotate-180", children: t("app.menus.user.theme.label") })
|
|
2225
|
+
] }),
|
|
2226
|
+
/* @__PURE__ */ jsx9(DropdownMenu2.SubMenuContent, { "data-testid": "sidebar-user-menu-theme-content", children: /* @__PURE__ */ jsxs6(DropdownMenu2.RadioGroup, { value: theme, "data-testid": "sidebar-user-menu-theme-radio-group", children: [
|
|
2227
|
+
/* @__PURE__ */ jsx9(
|
|
2228
|
+
DropdownMenu2.RadioItem,
|
|
2229
|
+
{
|
|
2230
|
+
value: "system",
|
|
2231
|
+
onClick: (e) => {
|
|
2232
|
+
e.preventDefault();
|
|
2233
|
+
setTheme("system");
|
|
2234
|
+
},
|
|
2235
|
+
"data-testid": "sidebar-user-menu-theme-system",
|
|
2236
|
+
children: t("app.menus.user.theme.system")
|
|
2237
|
+
}
|
|
2238
|
+
),
|
|
2239
|
+
/* @__PURE__ */ jsx9(
|
|
2240
|
+
DropdownMenu2.RadioItem,
|
|
2241
|
+
{
|
|
2242
|
+
value: "light",
|
|
2243
|
+
onClick: (e) => {
|
|
2244
|
+
e.preventDefault();
|
|
2245
|
+
setTheme("light");
|
|
2246
|
+
},
|
|
2247
|
+
"data-testid": "sidebar-user-menu-theme-light",
|
|
2248
|
+
children: t("app.menus.user.theme.light")
|
|
2249
|
+
}
|
|
2250
|
+
),
|
|
2251
|
+
/* @__PURE__ */ jsx9(
|
|
2252
|
+
DropdownMenu2.RadioItem,
|
|
2253
|
+
{
|
|
2254
|
+
value: "dark",
|
|
2255
|
+
onClick: (e) => {
|
|
2256
|
+
e.preventDefault();
|
|
2257
|
+
setTheme("dark");
|
|
2258
|
+
},
|
|
2259
|
+
"data-testid": "sidebar-user-menu-theme-dark",
|
|
2260
|
+
children: t("app.menus.user.theme.dark")
|
|
2261
|
+
}
|
|
2262
|
+
)
|
|
2263
|
+
] }) })
|
|
2264
|
+
] });
|
|
2265
|
+
};
|
|
2266
|
+
var Logout = () => {
|
|
2267
|
+
const { t } = useTranslation7();
|
|
2268
|
+
const navigate = useNavigate3();
|
|
2269
|
+
const { mutateAsync: logoutMutation } = useLogout();
|
|
2270
|
+
const handleLogout = async () => {
|
|
2271
|
+
await logoutMutation(void 0, {
|
|
2272
|
+
onSuccess: () => {
|
|
2273
|
+
queryClient.clear();
|
|
2274
|
+
navigate("/login");
|
|
2275
|
+
}
|
|
2276
|
+
});
|
|
2277
|
+
};
|
|
2278
|
+
return /* @__PURE__ */ jsx9(DropdownMenu2.Item, { onClick: handleLogout, "data-testid": "sidebar-user-menu-logout", children: /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-2", children: [
|
|
2279
|
+
/* @__PURE__ */ jsx9(OpenRectArrowOut, { className: "text-ui-fg-subtle" }),
|
|
2280
|
+
/* @__PURE__ */ jsx9("span", { children: t("app.menus.actions.logout") })
|
|
2281
|
+
] }) });
|
|
2282
|
+
};
|
|
2283
|
+
var GlobalKeybindsModal = (props) => {
|
|
2284
|
+
const { t } = useTranslation7();
|
|
2285
|
+
const globalShortcuts = useGlobalShortcuts();
|
|
2286
|
+
const [searchValue, onSearchValueChange] = useState9("");
|
|
2287
|
+
const searchResults = searchValue ? globalShortcuts.filter((shortcut) => {
|
|
2288
|
+
return shortcut.label.toLowerCase().includes(searchValue?.toLowerCase());
|
|
2289
|
+
}) : globalShortcuts;
|
|
2290
|
+
return /* @__PURE__ */ jsx9(RadixDialog3.Root, { ...props, "data-testid": "shortcuts-modal", children: /* @__PURE__ */ jsxs6(RadixDialog3.Portal, { children: [
|
|
2291
|
+
/* @__PURE__ */ jsx9(RadixDialog3.Overlay, { className: "bg-ui-bg-overlay fixed inset-0", "data-testid": "shortcuts-modal-overlay" }),
|
|
2292
|
+
/* @__PURE__ */ jsxs6(RadixDialog3.Content, { className: "bg-ui-bg-subtle shadow-elevation-modal fixed left-[50%] top-[50%] flex h-full max-h-[612px] w-full max-w-[560px] translate-x-[-50%] translate-y-[-50%] flex-col divide-y overflow-hidden rounded-lg", "data-testid": "shortcuts-modal-content", children: [
|
|
2293
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex flex-col gap-y-3 px-6 py-4", "data-testid": "shortcuts-modal-header", children: [
|
|
2294
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between", "data-testid": "shortcuts-modal-header-top", children: [
|
|
2295
|
+
/* @__PURE__ */ jsxs6("div", { "data-testid": "shortcuts-modal-title-container", children: [
|
|
2296
|
+
/* @__PURE__ */ jsx9(RadixDialog3.Title, { asChild: true, children: /* @__PURE__ */ jsx9(Heading, { "data-testid": "shortcuts-modal-title", children: t("app.menus.user.shortcuts") }) }),
|
|
2297
|
+
/* @__PURE__ */ jsx9(RadixDialog3.Description, { className: "sr-only", "data-testid": "shortcuts-modal-description" })
|
|
2298
|
+
] }),
|
|
2299
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-2", "data-testid": "shortcuts-modal-close-container", children: [
|
|
2300
|
+
/* @__PURE__ */ jsx9(Kbd3, { "data-testid": "shortcuts-modal-close-hint", children: "esc" }),
|
|
2301
|
+
/* @__PURE__ */ jsx9(RadixDialog3.Close, { asChild: true, children: /* @__PURE__ */ jsx9(IconButton3, { variant: "transparent", size: "small", "data-testid": "shortcuts-modal-close-button", children: /* @__PURE__ */ jsx9(XMark2, {}) }) })
|
|
2302
|
+
] })
|
|
2303
|
+
] }),
|
|
2304
|
+
/* @__PURE__ */ jsx9("div", { "data-testid": "shortcuts-modal-search-container", children: /* @__PURE__ */ jsx9(
|
|
2305
|
+
Input,
|
|
2306
|
+
{
|
|
2307
|
+
type: "search",
|
|
2308
|
+
value: searchValue,
|
|
2309
|
+
onChange: (e) => onSearchValueChange(e.target.value),
|
|
2310
|
+
"data-testid": "shortcuts-modal-search"
|
|
2311
|
+
}
|
|
2312
|
+
) })
|
|
2313
|
+
] }),
|
|
2314
|
+
/* @__PURE__ */ jsx9("div", { className: "flex flex-col divide-y overflow-y-auto", "data-testid": "shortcuts-modal-list", children: searchResults.map((shortcut, index) => {
|
|
2315
|
+
return /* @__PURE__ */ jsxs6(
|
|
2316
|
+
"div",
|
|
2317
|
+
{
|
|
2318
|
+
className: "text-ui-fg-subtle flex items-center justify-between px-6 py-3",
|
|
2319
|
+
"data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}`,
|
|
2320
|
+
children: [
|
|
2321
|
+
/* @__PURE__ */ jsx9(Text4, { size: "small", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-label`, children: shortcut.label }),
|
|
2322
|
+
/* @__PURE__ */ jsx9("div", { className: "flex items-center gap-x-1", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-keys`, children: shortcut.keys.Mac?.map((key, index2) => {
|
|
2323
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-1", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-key-${index2}`, children: [
|
|
2324
|
+
/* @__PURE__ */ jsx9(Kbd3, { "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-kbd-${index2}`, children: key }),
|
|
2325
|
+
index2 < (shortcut.keys.Mac?.length || 0) - 1 && /* @__PURE__ */ jsx9("span", { className: "txt-compact-xsmall text-ui-fg-subtle", "data-testid": `shortcut-item-${shortcut.label.toLowerCase().replace(/\s/g, "-")}-separator-${index2}`, children: t("app.keyboardShortcuts.then") })
|
|
2326
|
+
] }, index2);
|
|
2327
|
+
}) })
|
|
2328
|
+
]
|
|
2329
|
+
},
|
|
2330
|
+
index
|
|
2331
|
+
);
|
|
2332
|
+
}) })
|
|
2333
|
+
] })
|
|
2334
|
+
] }) });
|
|
2335
|
+
};
|
|
2336
|
+
var UserItem = () => {
|
|
2337
|
+
const { user, isPending, isError, error } = useMe();
|
|
2338
|
+
const loaded = !isPending && !!user;
|
|
2339
|
+
if (!loaded) {
|
|
2340
|
+
return /* @__PURE__ */ jsx9("div", {});
|
|
2341
|
+
}
|
|
2342
|
+
const name = [user.first_name, user.last_name].filter(Boolean).join(" ");
|
|
2343
|
+
const email = user.email;
|
|
2344
|
+
const fallback = name ? name[0].toUpperCase() : email[0].toUpperCase();
|
|
2345
|
+
const avatar = user.avatar_url;
|
|
2346
|
+
if (isError) {
|
|
2347
|
+
throw error;
|
|
2348
|
+
}
|
|
2349
|
+
return /* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-x-3 overflow-hidden px-2 py-1", "data-testid": "sidebar-user-menu-item", children: [
|
|
2350
|
+
/* @__PURE__ */ jsx9(
|
|
2351
|
+
Avatar,
|
|
2352
|
+
{
|
|
2353
|
+
size: "small",
|
|
2354
|
+
variant: "rounded",
|
|
2355
|
+
src: avatar || void 0,
|
|
2356
|
+
fallback,
|
|
2357
|
+
"data-testid": "sidebar-user-menu-item-avatar"
|
|
2358
|
+
}
|
|
2359
|
+
),
|
|
2360
|
+
/* @__PURE__ */ jsxs6("div", { className: "block w-full min-w-0 max-w-[187px] overflow-hidden whitespace-nowrap", "data-testid": "sidebar-user-menu-item-details", children: [
|
|
2361
|
+
/* @__PURE__ */ jsx9(
|
|
2362
|
+
Text4,
|
|
2363
|
+
{
|
|
2364
|
+
size: "small",
|
|
2365
|
+
weight: "plus",
|
|
2366
|
+
leading: "compact",
|
|
2367
|
+
className: "overflow-hidden text-ellipsis whitespace-nowrap",
|
|
2368
|
+
"data-testid": "sidebar-user-menu-item-name",
|
|
2369
|
+
children: name || email
|
|
2370
|
+
}
|
|
2371
|
+
),
|
|
2372
|
+
!!name && /* @__PURE__ */ jsx9(
|
|
2373
|
+
Text4,
|
|
2374
|
+
{
|
|
2375
|
+
size: "xsmall",
|
|
2376
|
+
leading: "compact",
|
|
2377
|
+
className: "text-ui-fg-subtle overflow-hidden text-ellipsis whitespace-nowrap",
|
|
2378
|
+
"data-testid": "sidebar-user-menu-item-email",
|
|
2379
|
+
children: email
|
|
2380
|
+
}
|
|
2381
|
+
)
|
|
2382
|
+
] })
|
|
2383
|
+
] });
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
// src/components/layout/main-layout/main-layout.tsx
|
|
2387
|
+
import menuItemsModule from "virtual:mercur/menu-items";
|
|
2388
|
+
import {
|
|
2389
|
+
applyNavOverrides,
|
|
2390
|
+
useExtension,
|
|
2391
|
+
usePermissions
|
|
2392
|
+
} from "@mercurjs/dashboard-shared";
|
|
2393
|
+
|
|
2394
|
+
// src/lib/permissions/route-permissions.ts
|
|
2395
|
+
var ROUTE_PERMISSIONS = {
|
|
2396
|
+
"/orders": "orders:view",
|
|
2397
|
+
"/products": "products:view",
|
|
2398
|
+
"/offers": "offers:view",
|
|
2399
|
+
"/collections": "product_collections:view",
|
|
2400
|
+
"/categories": "product_categories:view",
|
|
2401
|
+
"/inventory": "inventory_items:view",
|
|
2402
|
+
"/reservations": "reservations:view",
|
|
2403
|
+
"/customers": "customers:view",
|
|
2404
|
+
"/customer-groups": "customer_groups:view",
|
|
2405
|
+
"/promotions": "promotions:view",
|
|
2406
|
+
"/campaigns": "campaigns:view",
|
|
2407
|
+
"/price-lists": "price_lists:view",
|
|
2408
|
+
"/stores": "sellers:view",
|
|
2409
|
+
"/reviews": "reviews:view",
|
|
2410
|
+
"/payouts": "payouts:view",
|
|
2411
|
+
"/settings/regions": "regions:view",
|
|
2412
|
+
"/settings/marketplace": "store:view",
|
|
2413
|
+
"/settings/commissions": "commission_rates:view",
|
|
2414
|
+
"/settings/users": "users:view",
|
|
2415
|
+
"/settings/sales-channels": "sales_channels:view",
|
|
2416
|
+
"/settings/locations": "stock_locations:view",
|
|
2417
|
+
"/settings/product-tags": "product_tags:view",
|
|
2418
|
+
"/settings/product-types": "product_types:view",
|
|
2419
|
+
"/settings/attributes": "product_attributes:view",
|
|
2420
|
+
"/settings/shipping-profiles": "shipping_profiles:view",
|
|
2421
|
+
"/settings/shipping-option-types": "shipping_options:view",
|
|
2422
|
+
"/settings/return-reasons": "return_reasons:view",
|
|
2423
|
+
"/settings/refund-reasons": "refund_reasons:view",
|
|
2424
|
+
"/settings/tax-regions": "tax_regions:view",
|
|
2425
|
+
"/settings/publishable-api-keys": "api_keys:view",
|
|
2426
|
+
"/settings/secret-api-keys": "api_keys:view"
|
|
2427
|
+
};
|
|
2428
|
+
var getRoutePermission = (path) => ROUTE_PERMISSIONS[path];
|
|
2429
|
+
|
|
2430
|
+
// src/components/layout/main-layout/main-layout.tsx
|
|
2431
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2432
|
+
var navId = (to) => to.replace(/^\//, "");
|
|
2433
|
+
var toCoreNavItem = (route) => ({
|
|
2434
|
+
id: navId(route.to),
|
|
2435
|
+
label: route.label,
|
|
2436
|
+
to: route.to,
|
|
2437
|
+
icon: route.icon,
|
|
2438
|
+
items: route.items?.map((item) => ({
|
|
2439
|
+
id: navId(item.to),
|
|
2440
|
+
label: item.label,
|
|
2441
|
+
to: item.to
|
|
2442
|
+
}))
|
|
2443
|
+
});
|
|
2444
|
+
var MainLayout = () => {
|
|
2445
|
+
return /* @__PURE__ */ jsx10(Shell, { children: /* @__PURE__ */ jsx10(MainSidebar, {}) });
|
|
2446
|
+
};
|
|
2447
|
+
var allMenuItems = menuItemsModule.menuItems ?? [];
|
|
2448
|
+
var addNestedItems = (to, menuItems, items) => {
|
|
2449
|
+
const nestedItems = getNestedMenuItems(menuItems, to);
|
|
2450
|
+
if (nestedItems.length === 0) {
|
|
2451
|
+
return items;
|
|
2452
|
+
}
|
|
2453
|
+
const nestedNavItems = nestedItems.map((item) => ({
|
|
2454
|
+
label: item.label,
|
|
2455
|
+
to: item.path,
|
|
2456
|
+
translationNs: item.translationNs
|
|
2457
|
+
}));
|
|
2458
|
+
return [...items ?? [], ...nestedNavItems];
|
|
2459
|
+
};
|
|
2460
|
+
var useSidebarRoutes = () => {
|
|
2461
|
+
const coreRoutes = useCoreRoutes();
|
|
2462
|
+
const navOverrides = useExtension().getNavOverrides();
|
|
2463
|
+
const { hasAnyPermission, hasAllPermissions, hasPermission } = usePermissions();
|
|
2464
|
+
const canReach = ({ to }) => {
|
|
2465
|
+
const permission = getRoutePermission(to);
|
|
2466
|
+
return !permission || hasPermission(permission);
|
|
2467
|
+
};
|
|
2468
|
+
const visibleMenuItems = useMemo4(
|
|
2469
|
+
() => filterMenuItemsByPermissions(allMenuItems, {
|
|
2470
|
+
hasAnyPermission,
|
|
2471
|
+
hasAllPermissions
|
|
2472
|
+
}),
|
|
2473
|
+
[hasAnyPermission, hasAllPermissions]
|
|
2474
|
+
);
|
|
2475
|
+
const customMenuItems = getMenuItemsByType(visibleMenuItems, "main");
|
|
2476
|
+
const routesWithNested = applyNavOverrides(
|
|
2477
|
+
coreRoutes.map(toCoreNavItem),
|
|
2478
|
+
navOverrides
|
|
2479
|
+
).filter(canReach).map((route) => ({
|
|
2480
|
+
...route,
|
|
2481
|
+
items: addNestedItems(route.to, visibleMenuItems, route.items)?.filter(
|
|
2482
|
+
canReach
|
|
2483
|
+
)
|
|
2484
|
+
}));
|
|
2485
|
+
const customRoutesWithNested = customMenuItems.sort((a, b) => (a.rank ?? 0) - (b.rank ?? 0)).map((item) => ({
|
|
2486
|
+
label: item.label,
|
|
2487
|
+
to: item.path,
|
|
2488
|
+
icon: item.icon ? /* @__PURE__ */ jsx10(item.icon, {}) : void 0,
|
|
2489
|
+
translationNs: item.translationNs,
|
|
2490
|
+
items: addNestedItems(item.path, visibleMenuItems)
|
|
2491
|
+
}));
|
|
2492
|
+
return { routesWithNested, customRoutesWithNested };
|
|
2493
|
+
};
|
|
2494
|
+
var useLandingRoute = () => {
|
|
2495
|
+
const { routesWithNested, customRoutesWithNested } = useSidebarRoutes();
|
|
2496
|
+
const first = [...routesWithNested, ...customRoutesWithNested][0];
|
|
2497
|
+
return first?.to ?? "/settings/profile";
|
|
2498
|
+
};
|
|
2499
|
+
var MainSidebar = () => {
|
|
2500
|
+
const { routesWithNested, customRoutesWithNested } = useSidebarRoutes();
|
|
2501
|
+
return /* @__PURE__ */ jsx10(
|
|
2502
|
+
"aside",
|
|
2503
|
+
{
|
|
2504
|
+
className: "flex flex-1 flex-col justify-between overflow-y-auto overflow-x-hidden",
|
|
2505
|
+
"data-testid": "sidebar",
|
|
2506
|
+
children: /* @__PURE__ */ jsxs7("div", { className: "flex flex-1 flex-col", children: [
|
|
2507
|
+
/* @__PURE__ */ jsxs7(
|
|
2508
|
+
"div",
|
|
2509
|
+
{
|
|
2510
|
+
className: "sticky top-0 bg-ui-bg-subtle",
|
|
2511
|
+
"data-testid": "sidebar-header-section",
|
|
2512
|
+
children: [
|
|
2513
|
+
/* @__PURE__ */ jsx10(Header, {}),
|
|
2514
|
+
/* @__PURE__ */ jsx10("div", { className: "px-3", children: /* @__PURE__ */ jsx10(Divider, { variant: "dashed" }) })
|
|
2515
|
+
]
|
|
2516
|
+
}
|
|
2517
|
+
),
|
|
2518
|
+
/* @__PURE__ */ jsxs7("div", { className: "flex flex-1 flex-col justify-between", children: [
|
|
2519
|
+
/* @__PURE__ */ jsx10("div", { className: "flex flex-1 flex-col", children: /* @__PURE__ */ jsxs7(
|
|
2520
|
+
"nav",
|
|
2521
|
+
{
|
|
2522
|
+
className: "flex flex-col gap-y-1 py-3",
|
|
2523
|
+
"data-testid": "sidebar-core-routes",
|
|
2524
|
+
children: [
|
|
2525
|
+
/* @__PURE__ */ jsx10(Searchbar, {}),
|
|
2526
|
+
routesWithNested.map((route) => {
|
|
2527
|
+
return /* @__PURE__ */ jsx10(NavItem, { ...route }, route.to);
|
|
2528
|
+
}),
|
|
2529
|
+
customRoutesWithNested.map((route) => /* @__PURE__ */ jsx10(NavItem, { ...route }, route.to))
|
|
2530
|
+
]
|
|
2531
|
+
}
|
|
2532
|
+
) }),
|
|
2533
|
+
/* @__PURE__ */ jsx10(UtilitySection, {})
|
|
2534
|
+
] }),
|
|
2535
|
+
/* @__PURE__ */ jsx10(
|
|
2536
|
+
"div",
|
|
2537
|
+
{
|
|
2538
|
+
className: "sticky bottom-0 bg-ui-bg-subtle",
|
|
2539
|
+
"data-testid": "sidebar-user-section",
|
|
2540
|
+
children: /* @__PURE__ */ jsx10(UserSection, {})
|
|
2541
|
+
}
|
|
2542
|
+
)
|
|
2543
|
+
] })
|
|
2544
|
+
}
|
|
2545
|
+
);
|
|
2546
|
+
};
|
|
2547
|
+
var Logout2 = () => {
|
|
2548
|
+
const { t } = useTranslation8();
|
|
2549
|
+
const navigate = useNavigate4();
|
|
2550
|
+
const { mutateAsync: logoutMutation } = useLogout();
|
|
2551
|
+
const handleLogout = async () => {
|
|
2552
|
+
await logoutMutation(void 0, {
|
|
2553
|
+
onSuccess: () => {
|
|
2554
|
+
queryClient.clear();
|
|
2555
|
+
navigate("/login");
|
|
2556
|
+
}
|
|
2557
|
+
});
|
|
2558
|
+
};
|
|
2559
|
+
return /* @__PURE__ */ jsx10(
|
|
2560
|
+
DropdownMenu3.Item,
|
|
2561
|
+
{
|
|
2562
|
+
onClick: handleLogout,
|
|
2563
|
+
"data-testid": "sidebar-header-dropdown-logout",
|
|
2564
|
+
children: /* @__PURE__ */ jsxs7("div", { className: "flex items-center gap-x-2", children: [
|
|
2565
|
+
/* @__PURE__ */ jsx10(OpenRectArrowOut2, { className: "text-ui-fg-subtle" }),
|
|
2566
|
+
/* @__PURE__ */ jsx10("span", { children: t("app.menus.actions.logout") })
|
|
2567
|
+
] })
|
|
2568
|
+
}
|
|
2569
|
+
);
|
|
2570
|
+
};
|
|
2571
|
+
var Header = () => {
|
|
2572
|
+
const { t } = useTranslation8();
|
|
2573
|
+
const { store, isPending, isError, error } = useStore();
|
|
2574
|
+
const direction = useDocumentDirection();
|
|
2575
|
+
const menuPlacement = useSidebarMenuPlacement("start");
|
|
2576
|
+
const name = store?.name;
|
|
2577
|
+
const fallback = store?.name?.slice(0, 1).toUpperCase();
|
|
2578
|
+
const isLoaded = !isPending && !!store && !!name && !!fallback;
|
|
2579
|
+
if (isError) {
|
|
2580
|
+
throw error;
|
|
2581
|
+
}
|
|
2582
|
+
return /* @__PURE__ */ jsx10("div", { className: "w-full p-3", "data-testid": "sidebar-header-dropdown", children: /* @__PURE__ */ jsxs7(DropdownMenu3, { dir: direction, "data-testid": "sidebar-header-dropdown-menu", children: [
|
|
2583
|
+
/* @__PURE__ */ jsxs7(
|
|
2584
|
+
DropdownMenu3.Trigger,
|
|
2585
|
+
{
|
|
2586
|
+
disabled: !isLoaded,
|
|
2587
|
+
className: clx5(
|
|
2588
|
+
"grid w-full grid-cols-[24px_1fr_15px] items-center gap-x-3 rounded-md bg-ui-bg-subtle p-0.5 pe-2 outline-none transition-fg",
|
|
2589
|
+
"hover:bg-ui-bg-subtle-hover",
|
|
2590
|
+
"data-[state=open]:bg-ui-bg-subtle-hover",
|
|
2591
|
+
"focus-visible:shadow-borders-focus"
|
|
2592
|
+
),
|
|
2593
|
+
"data-testid": "sidebar-header-dropdown-trigger",
|
|
2594
|
+
children: [
|
|
2595
|
+
fallback ? /* @__PURE__ */ jsx10(
|
|
2596
|
+
Avatar2,
|
|
2597
|
+
{
|
|
2598
|
+
variant: "squared",
|
|
2599
|
+
size: "xsmall",
|
|
2600
|
+
fallback,
|
|
2601
|
+
"data-testid": "sidebar-header-dropdown-avatar"
|
|
2602
|
+
}
|
|
2603
|
+
) : /* @__PURE__ */ jsx10(Skeleton, { className: "h-6 w-6 rounded-md" }),
|
|
2604
|
+
/* @__PURE__ */ jsx10(
|
|
2605
|
+
"div",
|
|
2606
|
+
{
|
|
2607
|
+
className: clx5("block overflow-hidden whitespace-nowrap text-start", SIDEBAR_RAIL_FADE),
|
|
2608
|
+
"data-testid": "sidebar-header-dropdown-store-name",
|
|
2609
|
+
children: name ? /* @__PURE__ */ jsx10(
|
|
2610
|
+
Text5,
|
|
2611
|
+
{
|
|
2612
|
+
size: "small",
|
|
2613
|
+
weight: "plus",
|
|
2614
|
+
leading: "compact",
|
|
2615
|
+
className: "truncate",
|
|
2616
|
+
children: store.name
|
|
2617
|
+
}
|
|
2618
|
+
) : /* @__PURE__ */ jsx10(Skeleton, { className: "h-[9px] w-[120px]" })
|
|
2619
|
+
}
|
|
2620
|
+
),
|
|
2621
|
+
/* @__PURE__ */ jsx10(EllipsisHorizontal2, { className: clx5("text-ui-fg-muted", SIDEBAR_RAIL_FADE) })
|
|
2622
|
+
]
|
|
2623
|
+
}
|
|
2624
|
+
),
|
|
2625
|
+
isLoaded && /* @__PURE__ */ jsxs7(
|
|
2626
|
+
DropdownMenu3.Content,
|
|
2627
|
+
{
|
|
2628
|
+
...menuPlacement,
|
|
2629
|
+
className: SIDEBAR_MENU_CONTENT,
|
|
2630
|
+
"data-testid": "sidebar-header-dropdown-content",
|
|
2631
|
+
children: [
|
|
2632
|
+
/* @__PURE__ */ jsxs7(
|
|
2633
|
+
"div",
|
|
2634
|
+
{
|
|
2635
|
+
className: "flex items-center gap-x-3 px-2 py-1",
|
|
2636
|
+
"data-testid": "sidebar-header-dropdown-user-info",
|
|
2637
|
+
children: [
|
|
2638
|
+
/* @__PURE__ */ jsx10(
|
|
2639
|
+
Avatar2,
|
|
2640
|
+
{
|
|
2641
|
+
variant: "squared",
|
|
2642
|
+
size: "small",
|
|
2643
|
+
fallback,
|
|
2644
|
+
"data-testid": "sidebar-header-dropdown-user-avatar"
|
|
2645
|
+
}
|
|
2646
|
+
),
|
|
2647
|
+
/* @__PURE__ */ jsxs7(
|
|
2648
|
+
"div",
|
|
2649
|
+
{
|
|
2650
|
+
className: "flex flex-col overflow-hidden",
|
|
2651
|
+
"data-testid": "sidebar-header-dropdown-user-details",
|
|
2652
|
+
children: [
|
|
2653
|
+
/* @__PURE__ */ jsx10(
|
|
2654
|
+
Text5,
|
|
2655
|
+
{
|
|
2656
|
+
size: "small",
|
|
2657
|
+
weight: "plus",
|
|
2658
|
+
leading: "compact",
|
|
2659
|
+
className: "truncate",
|
|
2660
|
+
"data-testid": "sidebar-header-dropdown-user-name",
|
|
2661
|
+
children: name
|
|
2662
|
+
}
|
|
2663
|
+
),
|
|
2664
|
+
/* @__PURE__ */ jsx10(
|
|
2665
|
+
Text5,
|
|
2666
|
+
{
|
|
2667
|
+
size: "xsmall",
|
|
2668
|
+
leading: "compact",
|
|
2669
|
+
className: "text-ui-fg-subtle",
|
|
2670
|
+
"data-testid": "sidebar-header-dropdown-store-label",
|
|
2671
|
+
children: t("app.nav.main.marketplace")
|
|
2672
|
+
}
|
|
2673
|
+
)
|
|
2674
|
+
]
|
|
2675
|
+
}
|
|
2676
|
+
)
|
|
2677
|
+
]
|
|
2678
|
+
}
|
|
2679
|
+
),
|
|
2680
|
+
/* @__PURE__ */ jsx10(DropdownMenu3.Separator, { "data-testid": "sidebar-header-dropdown-separator-1" }),
|
|
2681
|
+
/* @__PURE__ */ jsx10(
|
|
2682
|
+
DropdownMenu3.Item,
|
|
2683
|
+
{
|
|
2684
|
+
className: "gap-x-2",
|
|
2685
|
+
asChild: true,
|
|
2686
|
+
"data-testid": "sidebar-header-dropdown-store-settings",
|
|
2687
|
+
children: /* @__PURE__ */ jsxs7(Link3, { to: "/settings/marketplace", children: [
|
|
2688
|
+
/* @__PURE__ */ jsx10(BuildingStorefront, { className: "text-ui-fg-subtle" }),
|
|
2689
|
+
t("app.nav.main.marketplaceSettings")
|
|
2690
|
+
] })
|
|
2691
|
+
}
|
|
2692
|
+
),
|
|
2693
|
+
/* @__PURE__ */ jsx10(DropdownMenu3.Separator, { "data-testid": "sidebar-header-dropdown-separator-2" }),
|
|
2694
|
+
/* @__PURE__ */ jsx10(Logout2, {})
|
|
2695
|
+
]
|
|
2696
|
+
}
|
|
2697
|
+
)
|
|
2698
|
+
] }) });
|
|
2699
|
+
};
|
|
2700
|
+
var useCoreRoutes = () => {
|
|
2701
|
+
const { t } = useTranslation8();
|
|
2702
|
+
return [
|
|
2703
|
+
{
|
|
2704
|
+
icon: /* @__PURE__ */ jsx10(ShoppingCart, {}),
|
|
2705
|
+
label: t("orders.domain"),
|
|
2706
|
+
to: "/orders",
|
|
2707
|
+
items: [
|
|
2708
|
+
// TODO: Enable when domin is introduced
|
|
2709
|
+
// {
|
|
2710
|
+
// label: t("draftOrders.domain"),
|
|
2711
|
+
// to: "/draft-orders",
|
|
2712
|
+
// },
|
|
2713
|
+
]
|
|
2714
|
+
},
|
|
2715
|
+
{
|
|
2716
|
+
icon: /* @__PURE__ */ jsx10(Tag, {}),
|
|
2717
|
+
label: t("products.domain"),
|
|
2718
|
+
to: "/products",
|
|
2719
|
+
items: [
|
|
2720
|
+
{
|
|
2721
|
+
label: t("offers.domain"),
|
|
2722
|
+
to: "/offers"
|
|
2723
|
+
},
|
|
2724
|
+
{
|
|
2725
|
+
label: t("collections.domain"),
|
|
2726
|
+
to: "/collections"
|
|
2727
|
+
},
|
|
2728
|
+
{
|
|
2729
|
+
label: t("categories.domain"),
|
|
2730
|
+
to: "/categories"
|
|
2731
|
+
}
|
|
2732
|
+
// TODO: Enable when domin is introduced
|
|
2733
|
+
// {
|
|
2734
|
+
// label: t("giftCards.domain"),
|
|
2735
|
+
// to: "/gift-cards",
|
|
2736
|
+
// },
|
|
2737
|
+
]
|
|
2738
|
+
},
|
|
2739
|
+
{
|
|
2740
|
+
icon: /* @__PURE__ */ jsx10(Buildings, {}),
|
|
2741
|
+
label: t("inventory.domain"),
|
|
2742
|
+
to: "/inventory",
|
|
2743
|
+
items: [
|
|
2744
|
+
{
|
|
2745
|
+
label: t("reservations.domain"),
|
|
2746
|
+
to: "/reservations"
|
|
2747
|
+
}
|
|
2748
|
+
]
|
|
2749
|
+
},
|
|
2750
|
+
{
|
|
2751
|
+
icon: /* @__PURE__ */ jsx10(Users, {}),
|
|
2752
|
+
label: t("customers.domain"),
|
|
2753
|
+
to: "/customers",
|
|
2754
|
+
items: [
|
|
2755
|
+
{
|
|
2756
|
+
label: t("customerGroups.domain"),
|
|
2757
|
+
to: "/customer-groups"
|
|
2758
|
+
}
|
|
2759
|
+
]
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
icon: /* @__PURE__ */ jsx10(ReceiptPercent, {}),
|
|
2763
|
+
label: t("promotions.domain"),
|
|
2764
|
+
to: "/promotions",
|
|
2765
|
+
items: [
|
|
2766
|
+
{
|
|
2767
|
+
label: t("campaigns.domain"),
|
|
2768
|
+
to: "/campaigns"
|
|
2769
|
+
}
|
|
2770
|
+
]
|
|
2771
|
+
},
|
|
2772
|
+
{
|
|
2773
|
+
icon: /* @__PURE__ */ jsx10(CurrencyDollar, {}),
|
|
2774
|
+
label: t("priceLists.domain"),
|
|
2775
|
+
to: "/price-lists"
|
|
2776
|
+
},
|
|
2777
|
+
{
|
|
2778
|
+
icon: /* @__PURE__ */ jsx10(BuildingStorefront, {}),
|
|
2779
|
+
label: t("stores.domain"),
|
|
2780
|
+
to: "/stores",
|
|
2781
|
+
items: [
|
|
2782
|
+
{
|
|
2783
|
+
label: t("reviews.domain"),
|
|
2784
|
+
to: "/reviews"
|
|
2785
|
+
}
|
|
2786
|
+
]
|
|
2787
|
+
},
|
|
2788
|
+
{
|
|
2789
|
+
icon: /* @__PURE__ */ jsx10(CreditCardRefresh, {}),
|
|
2790
|
+
label: t("payouts.domain"),
|
|
2791
|
+
to: "/payouts"
|
|
2792
|
+
}
|
|
2793
|
+
];
|
|
2794
|
+
};
|
|
2795
|
+
var Searchbar = () => {
|
|
2796
|
+
const { t } = useTranslation8();
|
|
2797
|
+
const { toggleSearch } = useSearch();
|
|
2798
|
+
return /* @__PURE__ */ jsx10("div", { className: "px-3", "data-testid": "sidebar-search", children: /* @__PURE__ */ jsxs7(
|
|
2799
|
+
"button",
|
|
2800
|
+
{
|
|
2801
|
+
onClick: toggleSearch,
|
|
2802
|
+
className: clx5(
|
|
2803
|
+
"flex w-full items-center gap-x-2.5 rounded-md bg-ui-bg-subtle px-2 py-1 text-ui-fg-subtle outline-none transition-[padding] duration-200 ease-sidebar motion-reduce:transition-none group-data-[state=collapsed]/sidebar:px-1",
|
|
2804
|
+
"hover:bg-ui-bg-subtle-hover",
|
|
2805
|
+
"focus-visible:shadow-borders-focus"
|
|
2806
|
+
),
|
|
2807
|
+
"data-testid": "sidebar-search-button",
|
|
2808
|
+
children: [
|
|
2809
|
+
/* @__PURE__ */ jsx10(MagnifyingGlass2, { className: "shrink-0" }),
|
|
2810
|
+
/* @__PURE__ */ jsx10("div", { className: clx5("flex-1 whitespace-nowrap text-start", SIDEBAR_RAIL_FADE), children: /* @__PURE__ */ jsx10(Text5, { size: "small", leading: "compact", weight: "plus", children: t("app.search.label") }) }),
|
|
2811
|
+
/* @__PURE__ */ jsx10(Text5, { size: "small", leading: "compact", className: clx5("text-ui-fg-muted", SIDEBAR_RAIL_FADE), children: "\u2318K" })
|
|
2812
|
+
]
|
|
2813
|
+
}
|
|
2814
|
+
) });
|
|
2815
|
+
};
|
|
2816
|
+
var UtilitySection = () => {
|
|
2817
|
+
const location = useLocation5();
|
|
2818
|
+
const { t } = useTranslation8();
|
|
2819
|
+
return /* @__PURE__ */ jsx10("div", { className: "flex flex-col gap-y-0.5 py-3", children: /* @__PURE__ */ jsx10(
|
|
2820
|
+
NavItem,
|
|
2821
|
+
{
|
|
2822
|
+
label: t("app.nav.settings.header"),
|
|
2823
|
+
to: "/settings",
|
|
2824
|
+
from: location.pathname,
|
|
2825
|
+
icon: /* @__PURE__ */ jsx10(CogSixTooth, {})
|
|
2826
|
+
}
|
|
2827
|
+
) });
|
|
2828
|
+
};
|
|
2829
|
+
var UserSection = () => {
|
|
2830
|
+
return /* @__PURE__ */ jsxs7("div", { children: [
|
|
2831
|
+
/* @__PURE__ */ jsx10("div", { className: "px-3", children: /* @__PURE__ */ jsx10(Divider, { variant: "dashed" }) }),
|
|
2832
|
+
/* @__PURE__ */ jsx10(UserMenu, {})
|
|
2833
|
+
] });
|
|
2834
|
+
};
|
|
2835
|
+
|
|
2836
|
+
export {
|
|
2837
|
+
ThemeProvider,
|
|
2838
|
+
SidebarProvider,
|
|
2839
|
+
useExpandedSidebar,
|
|
2840
|
+
SearchProvider,
|
|
2841
|
+
NavItem,
|
|
2842
|
+
Shell,
|
|
2843
|
+
UserMenu,
|
|
2844
|
+
ErrorBoundary,
|
|
2845
|
+
createRouteMap,
|
|
2846
|
+
getRoutesByType,
|
|
2847
|
+
getMenuItemsByType,
|
|
2848
|
+
filterMenuItemsByPermissions,
|
|
2849
|
+
getRoutePermission,
|
|
2850
|
+
MainLayout,
|
|
2851
|
+
useLandingRoute
|
|
2852
|
+
};
|