@rqdhw3n/react-admin-layout 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +185 -182
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as n, Fragment as A, jsxs as o } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as V, useState as w, useEffect as M, useCallback as L, useMemo as U, useContext as Z, useRef as T } from "react";
|
|
3
3
|
import { useLocation as I, NavLink as ee } from "react-router-dom";
|
|
4
|
-
import { ChevronDown as H, X as te, Home as ne, ChevronRight as
|
|
4
|
+
import { ChevronDown as H, X as te, Home as ne, ChevronRight as re, Search as ae, Bell as ie, Sun as se, Moon as le, Settings as de, User as oe, LogOut as ce, Menu as me, PanelLeftOpen as J, PanelLeftClose as G } from "lucide-react";
|
|
5
5
|
function ue(e) {
|
|
6
6
|
if (typeof window > "u") return {};
|
|
7
7
|
try {
|
|
@@ -22,48 +22,48 @@ const Q = V(null);
|
|
|
22
22
|
function he({
|
|
23
23
|
children: e,
|
|
24
24
|
storageKey: t = "rqdhw3n-admin-layout",
|
|
25
|
-
defaultCollapsed:
|
|
26
|
-
permissions:
|
|
27
|
-
initialBreadcrumbs:
|
|
28
|
-
initialActivePath:
|
|
25
|
+
defaultCollapsed: r = !1,
|
|
26
|
+
permissions: a = {},
|
|
27
|
+
initialBreadcrumbs: l = [],
|
|
28
|
+
initialActivePath: s = "/",
|
|
29
29
|
initialDarkMode: i
|
|
30
30
|
}) {
|
|
31
31
|
const d = ue(t), [c, b] = w(
|
|
32
|
-
d.sidebarCollapsed ??
|
|
32
|
+
d.sidebarCollapsed ?? r
|
|
33
33
|
), [f, v] = w(!1), [h, m] = w(
|
|
34
34
|
d.darkMode ?? i ?? !1
|
|
35
|
-
), [p, N] = w(
|
|
35
|
+
), [p, N] = w(l), [C, g] = w(s);
|
|
36
36
|
M(() => {
|
|
37
37
|
be(t, { sidebarCollapsed: c, darkMode: h });
|
|
38
38
|
}, [t, c, h]), M(() => {
|
|
39
39
|
const y = document.documentElement;
|
|
40
40
|
h ? y.classList.add("dark") : y.classList.remove("dark");
|
|
41
41
|
}, [h]);
|
|
42
|
-
const S = L(() => b((y) => !y), []),
|
|
42
|
+
const S = L(() => b((y) => !y), []), x = L(() => v((y) => !y), []), P = L(() => m((y) => !y), []), B = U(
|
|
43
43
|
() => ({
|
|
44
44
|
sidebarCollapsed: c,
|
|
45
45
|
mobileOpen: f,
|
|
46
46
|
darkMode: h,
|
|
47
47
|
toggleSidebar: S,
|
|
48
48
|
setSidebarCollapsed: b,
|
|
49
|
-
toggleMobile:
|
|
49
|
+
toggleMobile: x,
|
|
50
50
|
setMobileOpen: v,
|
|
51
51
|
toggleDarkMode: P,
|
|
52
52
|
setDarkMode: m,
|
|
53
|
-
permissions:
|
|
53
|
+
permissions: a,
|
|
54
54
|
breadcrumbs: p,
|
|
55
55
|
setBreadcrumbs: N,
|
|
56
56
|
activePath: C,
|
|
57
|
-
setActivePath:
|
|
57
|
+
setActivePath: g
|
|
58
58
|
}),
|
|
59
59
|
[
|
|
60
60
|
c,
|
|
61
61
|
f,
|
|
62
62
|
h,
|
|
63
63
|
S,
|
|
64
|
-
|
|
64
|
+
x,
|
|
65
65
|
P,
|
|
66
|
-
|
|
66
|
+
a,
|
|
67
67
|
p,
|
|
68
68
|
C
|
|
69
69
|
]
|
|
@@ -80,49 +80,49 @@ function O() {
|
|
|
80
80
|
const {
|
|
81
81
|
sidebarCollapsed: e,
|
|
82
82
|
mobileOpen: t,
|
|
83
|
-
toggleSidebar:
|
|
84
|
-
setSidebarCollapsed:
|
|
85
|
-
toggleMobile:
|
|
86
|
-
setMobileOpen:
|
|
83
|
+
toggleSidebar: r,
|
|
84
|
+
setSidebarCollapsed: a,
|
|
85
|
+
toggleMobile: l,
|
|
86
|
+
setMobileOpen: s
|
|
87
87
|
} = k();
|
|
88
88
|
return {
|
|
89
89
|
collapsed: e,
|
|
90
90
|
mobileOpen: t,
|
|
91
|
-
toggle:
|
|
92
|
-
setCollapsed:
|
|
93
|
-
toggleMobile:
|
|
94
|
-
setMobileOpen:
|
|
95
|
-
closeMobile: () =>
|
|
91
|
+
toggle: r,
|
|
92
|
+
setCollapsed: a,
|
|
93
|
+
toggleMobile: l,
|
|
94
|
+
setMobileOpen: s,
|
|
95
|
+
closeMobile: () => s(!1)
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
98
|
function E(e) {
|
|
99
99
|
const t = e.split("/").filter(Boolean);
|
|
100
|
-
return t.length ? t.map((
|
|
101
|
-
const
|
|
102
|
-
return { label:
|
|
100
|
+
return t.length ? t.map((r, a) => {
|
|
101
|
+
const l = "/" + t.slice(0, a + 1).join("/");
|
|
102
|
+
return { label: r.replace(/-/g, " ").replace(/\b\w/g, (i) => i.toUpperCase()), path: a < t.length - 1 ? l : void 0 };
|
|
103
103
|
}) : [{ label: "Home", path: "/" }];
|
|
104
104
|
}
|
|
105
105
|
function W(e) {
|
|
106
|
-
var t,
|
|
107
|
-
if (typeof e == "string" || typeof e == "number")
|
|
106
|
+
var t, r, a = "";
|
|
107
|
+
if (typeof e == "string" || typeof e == "number") a += e;
|
|
108
108
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
109
|
-
var
|
|
110
|
-
for (t = 0; t <
|
|
111
|
-
} else for (
|
|
112
|
-
return
|
|
109
|
+
var l = e.length;
|
|
110
|
+
for (t = 0; t < l; t++) e[t] && (r = W(e[t])) && (a && (a += " "), a += r);
|
|
111
|
+
} else for (r in e) e[r] && (a && (a += " "), a += r);
|
|
112
|
+
return a;
|
|
113
113
|
}
|
|
114
114
|
function fe() {
|
|
115
|
-
for (var e, t,
|
|
116
|
-
return
|
|
115
|
+
for (var e, t, r = 0, a = "", l = arguments.length; r < l; r++) (e = arguments[r]) && (t = W(e)) && (a && (a += " "), a += t);
|
|
116
|
+
return a;
|
|
117
117
|
}
|
|
118
118
|
function u(...e) {
|
|
119
119
|
return fe(e);
|
|
120
120
|
}
|
|
121
121
|
function pe({ children: e }) {
|
|
122
|
-
const { pathname: t } = I(), { setActivePath:
|
|
122
|
+
const { pathname: t } = I(), { setActivePath: r, setBreadcrumbs: a, breadcrumbs: l } = k();
|
|
123
123
|
return M(() => {
|
|
124
|
-
|
|
125
|
-
}, [t,
|
|
124
|
+
r(t), l.length || a(E(t));
|
|
125
|
+
}, [t, r, a, l.length]), /* @__PURE__ */ n(A, { children: e });
|
|
126
126
|
}
|
|
127
127
|
function xe({ children: e, className: t }) {
|
|
128
128
|
return /* @__PURE__ */ n(
|
|
@@ -149,21 +149,21 @@ function ge(e) {
|
|
|
149
149
|
}
|
|
150
150
|
function ve(e, t) {
|
|
151
151
|
if (!t) return !0;
|
|
152
|
-
const { resource:
|
|
153
|
-
return
|
|
152
|
+
const { resource: r, action: a } = ge(t), l = e[r];
|
|
153
|
+
return l != null && l.length ? l.includes(a) || l.includes("*") : !1;
|
|
154
154
|
}
|
|
155
155
|
function D(e, t) {
|
|
156
|
-
return e.filter((
|
|
157
|
-
...
|
|
158
|
-
children:
|
|
159
|
-
})).filter((
|
|
160
|
-
var
|
|
161
|
-
return !((
|
|
156
|
+
return e.filter((r) => ve(t, r.permission)).map((r) => ({
|
|
157
|
+
...r,
|
|
158
|
+
children: r.children ? D(r.children, t) : void 0
|
|
159
|
+
})).filter((r) => {
|
|
160
|
+
var a;
|
|
161
|
+
return !((a = r.children) != null && a.length) || r.children.length > 0 || r.path;
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
function X({ label: e, children: t, collapsed:
|
|
165
|
-
return /* @__PURE__ */ o("div", { className: u("mb-4",
|
|
166
|
-
e && !
|
|
164
|
+
function X({ label: e, children: t, collapsed: r, className: a }) {
|
|
165
|
+
return /* @__PURE__ */ o("div", { className: u("mb-4", a), children: [
|
|
166
|
+
e && !r && /* @__PURE__ */ n("p", { className: "mb-2 px-3 text-[11px] font-semibold uppercase tracking-wider text-admin-muted", children: e }),
|
|
167
167
|
/* @__PURE__ */ n("ul", { className: "space-y-0.5", children: t })
|
|
168
168
|
] });
|
|
169
169
|
}
|
|
@@ -173,19 +173,19 @@ function z(e, t) {
|
|
|
173
173
|
function R({
|
|
174
174
|
item: e,
|
|
175
175
|
collapsed: t = !1,
|
|
176
|
-
depth:
|
|
177
|
-
activePath:
|
|
178
|
-
onNavigate:
|
|
179
|
-
LinkComponent:
|
|
176
|
+
depth: r = 0,
|
|
177
|
+
activePath: a = "/",
|
|
178
|
+
onNavigate: l,
|
|
179
|
+
LinkComponent: s,
|
|
180
180
|
onItemClick: i
|
|
181
181
|
}) {
|
|
182
|
-
var
|
|
183
|
-
const d = !!((
|
|
182
|
+
var g, S;
|
|
183
|
+
const d = !!((g = e.children) != null && g.length), c = e.path ? z(e.path, a) : !1, b = (S = e.children) == null ? void 0 : S.some((x) => x.path && z(x.path, a)), [f, v] = w(c || b), h = e.icon, m = u(
|
|
184
184
|
"group flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-sm font-medium transition-all duration-200",
|
|
185
185
|
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-admin-primary",
|
|
186
186
|
c || b ? "bg-admin-primary text-white shadow-sm" : "text-admin-muted hover:bg-admin-bg hover:text-admin-text",
|
|
187
187
|
e.disabled && "pointer-events-none opacity-50",
|
|
188
|
-
|
|
188
|
+
r > 0 && "text-[13px] py-2"
|
|
189
189
|
), p = /* @__PURE__ */ o(A, { children: [
|
|
190
190
|
h && /* @__PURE__ */ n(
|
|
191
191
|
h,
|
|
@@ -216,12 +216,12 @@ function R({
|
|
|
216
216
|
] })
|
|
217
217
|
] }), N = () => {
|
|
218
218
|
if (d) {
|
|
219
|
-
v((
|
|
219
|
+
v((x) => !x);
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
|
-
e.path && (
|
|
223
|
-
}, C = e.path && !d &&
|
|
224
|
-
|
|
222
|
+
e.path && (l == null || l(e.path), i == null || i());
|
|
223
|
+
}, C = e.path && !d && s ? /* @__PURE__ */ n(
|
|
224
|
+
s,
|
|
225
225
|
{
|
|
226
226
|
to: e.path,
|
|
227
227
|
className: m,
|
|
@@ -233,30 +233,30 @@ function R({
|
|
|
233
233
|
) : /* @__PURE__ */ n("button", { type: "button", className: m, onClick: N, disabled: e.disabled, children: p });
|
|
234
234
|
return /* @__PURE__ */ o("li", { children: [
|
|
235
235
|
C,
|
|
236
|
-
d && f && !t && /* @__PURE__ */ n("ul", { className: "mt-1 space-y-0.5 border-l border-admin-border ml-5 pl-2", children: e.children.map((
|
|
236
|
+
d && f && !t && /* @__PURE__ */ n("ul", { className: "mt-1 space-y-0.5 border-l border-admin-border ml-5 pl-2", children: e.children.map((x) => /* @__PURE__ */ n(
|
|
237
237
|
R,
|
|
238
238
|
{
|
|
239
|
-
item:
|
|
239
|
+
item: x,
|
|
240
240
|
collapsed: t,
|
|
241
|
-
depth:
|
|
242
|
-
activePath:
|
|
243
|
-
onNavigate:
|
|
244
|
-
LinkComponent:
|
|
241
|
+
depth: r + 1,
|
|
242
|
+
activePath: a,
|
|
243
|
+
onNavigate: l,
|
|
244
|
+
LinkComponent: s,
|
|
245
245
|
onItemClick: i
|
|
246
246
|
},
|
|
247
|
-
|
|
247
|
+
x.label + (x.path ?? "")
|
|
248
248
|
)) })
|
|
249
249
|
] });
|
|
250
250
|
}
|
|
251
251
|
function ye({
|
|
252
252
|
items: e,
|
|
253
253
|
appName: t = "Admin",
|
|
254
|
-
appLogo:
|
|
255
|
-
onNavigate:
|
|
256
|
-
activePath:
|
|
257
|
-
LinkComponent:
|
|
254
|
+
appLogo: r,
|
|
255
|
+
onNavigate: a,
|
|
256
|
+
activePath: l,
|
|
257
|
+
LinkComponent: s
|
|
258
258
|
}) {
|
|
259
|
-
const { mobileOpen: i, closeMobile: d } = O(), { permissions: c, activePath: b } = k(), f =
|
|
259
|
+
const { mobileOpen: i, closeMobile: d } = O(), { permissions: c, activePath: b } = k(), f = l ?? b, v = D(e, c);
|
|
260
260
|
if (M(() => {
|
|
261
261
|
if (!i) return;
|
|
262
262
|
const m = (p) => {
|
|
@@ -267,7 +267,7 @@ function ye({
|
|
|
267
267
|
};
|
|
268
268
|
}, [i, d]), !i) return null;
|
|
269
269
|
const h = (m) => {
|
|
270
|
-
|
|
270
|
+
a == null || a(m), d();
|
|
271
271
|
};
|
|
272
272
|
return /* @__PURE__ */ o("div", { className: "fixed inset-0 z-50 lg:hidden", role: "dialog", "aria-modal": "true", children: [
|
|
273
273
|
/* @__PURE__ */ n(
|
|
@@ -289,7 +289,7 @@ function ye({
|
|
|
289
289
|
children: [
|
|
290
290
|
/* @__PURE__ */ o("div", { className: "flex h-16 items-center justify-between border-b border-admin-border px-4", children: [
|
|
291
291
|
/* @__PURE__ */ o("div", { className: "flex items-center gap-3", children: [
|
|
292
|
-
|
|
292
|
+
r ?? /* @__PURE__ */ n("div", { className: "flex h-9 w-9 items-center justify-center rounded-xl bg-admin-primary text-sm font-bold text-white", children: t.charAt(0) }),
|
|
293
293
|
/* @__PURE__ */ n("span", { className: "font-semibold text-admin-text", children: t })
|
|
294
294
|
] }),
|
|
295
295
|
/* @__PURE__ */ n(
|
|
@@ -309,7 +309,7 @@ function ye({
|
|
|
309
309
|
item: m,
|
|
310
310
|
activePath: f,
|
|
311
311
|
onNavigate: h,
|
|
312
|
-
LinkComponent:
|
|
312
|
+
LinkComponent: s,
|
|
313
313
|
onItemClick: d
|
|
314
314
|
},
|
|
315
315
|
m.label + (m.path ?? "")
|
|
@@ -322,39 +322,39 @@ function ye({
|
|
|
322
322
|
function we({
|
|
323
323
|
items: e,
|
|
324
324
|
className: t,
|
|
325
|
-
LinkComponent:
|
|
326
|
-
onNavigate:
|
|
325
|
+
LinkComponent: r,
|
|
326
|
+
onNavigate: a
|
|
327
327
|
}) {
|
|
328
328
|
if (!e.length) return null;
|
|
329
|
-
const
|
|
329
|
+
const l = (s, i) => {
|
|
330
330
|
const d = u(
|
|
331
331
|
"text-sm transition-colors",
|
|
332
332
|
i ? "font-medium text-admin-text" : "text-admin-muted hover:text-admin-text"
|
|
333
333
|
);
|
|
334
|
-
return !
|
|
334
|
+
return !s.path || i ? /* @__PURE__ */ n("span", { className: d, children: s.label }) : r ? /* @__PURE__ */ n(r, { to: s.path, className: d, children: s.label }) : /* @__PURE__ */ n("button", { type: "button", className: d, onClick: () => a == null ? void 0 : a(s.path), children: s.label });
|
|
335
335
|
};
|
|
336
336
|
return /* @__PURE__ */ o("nav", { "aria-label": "Breadcrumb", className: u("flex items-center gap-1.5", t), children: [
|
|
337
337
|
/* @__PURE__ */ n(ne, { className: "h-4 w-4 text-admin-muted shrink-0", "aria-hidden": !0 }),
|
|
338
|
-
e.map((
|
|
338
|
+
e.map((s, i) => {
|
|
339
339
|
const d = i === e.length - 1;
|
|
340
340
|
return /* @__PURE__ */ o("span", { className: "flex items-center gap-1.5", children: [
|
|
341
|
-
/* @__PURE__ */ n(
|
|
342
|
-
s
|
|
343
|
-
] }, `${
|
|
341
|
+
/* @__PURE__ */ n(re, { className: "h-3.5 w-3.5 text-admin-muted", "aria-hidden": !0 }),
|
|
342
|
+
l(s, d)
|
|
343
|
+
] }, `${s.label}-${i}`);
|
|
344
344
|
})
|
|
345
345
|
] });
|
|
346
346
|
}
|
|
347
347
|
function Ne({
|
|
348
348
|
placeholder: e = "Search...",
|
|
349
349
|
onSearch: t,
|
|
350
|
-
className:
|
|
350
|
+
className: r
|
|
351
351
|
}) {
|
|
352
|
-
const [
|
|
352
|
+
const [a, l] = w("");
|
|
353
353
|
return /* @__PURE__ */ o("form", { onSubmit: (i) => {
|
|
354
|
-
i.preventDefault(), t == null || t(
|
|
355
|
-
}, className: u("relative w-full max-w-md",
|
|
354
|
+
i.preventDefault(), t == null || t(a.trim());
|
|
355
|
+
}, className: u("relative w-full max-w-md", r), children: [
|
|
356
356
|
/* @__PURE__ */ n(
|
|
357
|
-
|
|
357
|
+
ae,
|
|
358
358
|
{
|
|
359
359
|
className: "pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-admin-muted",
|
|
360
360
|
"aria-hidden": !0
|
|
@@ -364,8 +364,8 @@ function Ne({
|
|
|
364
364
|
"input",
|
|
365
365
|
{
|
|
366
366
|
type: "search",
|
|
367
|
-
value:
|
|
368
|
-
onChange: (i) =>
|
|
367
|
+
value: a,
|
|
368
|
+
onChange: (i) => l(i.target.value),
|
|
369
369
|
placeholder: e,
|
|
370
370
|
className: u(
|
|
371
371
|
"h-10 w-full rounded-xl border border-admin-border bg-admin-bg pl-10 pr-4 text-sm text-admin-text",
|
|
@@ -377,32 +377,32 @@ function Ne({
|
|
|
377
377
|
] });
|
|
378
378
|
}
|
|
379
379
|
function ke({ notifications: e = [], className: t }) {
|
|
380
|
-
const [
|
|
380
|
+
const [r, a] = w(!1), l = T(null), s = e.filter((i) => !i.read).length;
|
|
381
381
|
return M(() => {
|
|
382
382
|
const i = (d) => {
|
|
383
|
-
|
|
383
|
+
l.current && !l.current.contains(d.target) && a(!1);
|
|
384
384
|
};
|
|
385
385
|
return document.addEventListener("mousedown", i), () => document.removeEventListener("mousedown", i);
|
|
386
|
-
}, []), /* @__PURE__ */ o("div", { ref:
|
|
386
|
+
}, []), /* @__PURE__ */ o("div", { ref: l, className: u("relative", t), children: [
|
|
387
387
|
/* @__PURE__ */ o(
|
|
388
388
|
"button",
|
|
389
389
|
{
|
|
390
390
|
type: "button",
|
|
391
|
-
onClick: () =>
|
|
391
|
+
onClick: () => a((i) => !i),
|
|
392
392
|
className: u(
|
|
393
393
|
"relative inline-flex h-9 w-9 items-center justify-center rounded-lg border border-admin-border",
|
|
394
394
|
"bg-admin-surface text-admin-muted transition-colors hover:bg-admin-bg hover:text-admin-text",
|
|
395
395
|
"focus-visible:ring-2 focus-visible:ring-admin-primary"
|
|
396
396
|
),
|
|
397
|
-
"aria-label": `Notifications${
|
|
398
|
-
"aria-expanded":
|
|
397
|
+
"aria-label": `Notifications${s ? `, ${s} unread` : ""}`,
|
|
398
|
+
"aria-expanded": r,
|
|
399
399
|
children: [
|
|
400
400
|
/* @__PURE__ */ n(ie, { className: "h-4 w-4", "aria-hidden": !0 }),
|
|
401
|
-
|
|
401
|
+
s > 0 && /* @__PURE__ */ n("span", { className: "absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-red-500 px-1 text-[10px] font-bold text-white", children: s > 9 ? "9+" : s })
|
|
402
402
|
]
|
|
403
403
|
}
|
|
404
404
|
),
|
|
405
|
-
|
|
405
|
+
r && /* @__PURE__ */ o("div", { className: "absolute right-0 top-full z-50 mt-2 w-80 rounded-xl border border-admin-border bg-admin-surface shadow-admin-lg animate-fade-in", children: [
|
|
406
406
|
/* @__PURE__ */ n("div", { className: "border-b border-admin-border px-4 py-3", children: /* @__PURE__ */ n("p", { className: "text-sm font-semibold text-admin-text", children: "Notifications" }) }),
|
|
407
407
|
/* @__PURE__ */ n("ul", { className: "max-h-72 overflow-y-auto p-2", children: e.length === 0 ? /* @__PURE__ */ n("li", { className: "px-3 py-6 text-center text-sm text-admin-muted", children: "No notifications" }) : e.map((i) => /* @__PURE__ */ o(
|
|
408
408
|
"li",
|
|
@@ -423,20 +423,20 @@ function ke({ notifications: e = [], className: t }) {
|
|
|
423
423
|
] });
|
|
424
424
|
}
|
|
425
425
|
function Ce() {
|
|
426
|
-
const { darkMode: e, toggleDarkMode: t, setDarkMode:
|
|
426
|
+
const { darkMode: e, toggleDarkMode: t, setDarkMode: r } = k();
|
|
427
427
|
return {
|
|
428
428
|
isDark: e,
|
|
429
429
|
toggle: t,
|
|
430
|
-
setDarkMode:
|
|
430
|
+
setDarkMode: r
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
function Se({ className: e }) {
|
|
434
|
-
const { isDark: t, toggle:
|
|
434
|
+
const { isDark: t, toggle: r } = Ce();
|
|
435
435
|
return /* @__PURE__ */ n(
|
|
436
436
|
"button",
|
|
437
437
|
{
|
|
438
438
|
type: "button",
|
|
439
|
-
onClick:
|
|
439
|
+
onClick: r,
|
|
440
440
|
className: u(
|
|
441
441
|
"inline-flex h-9 w-9 items-center justify-center rounded-lg border border-admin-border",
|
|
442
442
|
"bg-admin-surface text-admin-muted transition-colors hover:bg-admin-bg hover:text-admin-text",
|
|
@@ -444,30 +444,30 @@ function Se({ className: e }) {
|
|
|
444
444
|
e
|
|
445
445
|
),
|
|
446
446
|
"aria-label": t ? "Switch to light mode" : "Switch to dark mode",
|
|
447
|
-
children: t ? /* @__PURE__ */ n(
|
|
447
|
+
children: t ? /* @__PURE__ */ n(se, { className: "h-4 w-4", "aria-hidden": !0 }) : /* @__PURE__ */ n(le, { className: "h-4 w-4", "aria-hidden": !0 })
|
|
448
448
|
}
|
|
449
449
|
);
|
|
450
450
|
}
|
|
451
|
-
function Me({ user: e, onLogout: t, onSettings:
|
|
452
|
-
const [
|
|
451
|
+
function Me({ user: e, onLogout: t, onSettings: r, className: a }) {
|
|
452
|
+
const [l, s] = w(!1), i = T(null);
|
|
453
453
|
M(() => {
|
|
454
454
|
const c = (b) => {
|
|
455
|
-
i.current && !i.current.contains(b.target) &&
|
|
455
|
+
i.current && !i.current.contains(b.target) && s(!1);
|
|
456
456
|
};
|
|
457
457
|
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
458
458
|
}, []);
|
|
459
459
|
const d = e.name.split(" ").map((c) => c[0]).join("").slice(0, 2).toUpperCase();
|
|
460
|
-
return /* @__PURE__ */ o("div", { ref: i, className: u("relative",
|
|
460
|
+
return /* @__PURE__ */ o("div", { ref: i, className: u("relative", a), children: [
|
|
461
461
|
/* @__PURE__ */ o(
|
|
462
462
|
"button",
|
|
463
463
|
{
|
|
464
464
|
type: "button",
|
|
465
|
-
onClick: () =>
|
|
465
|
+
onClick: () => s((c) => !c),
|
|
466
466
|
className: u(
|
|
467
467
|
"flex items-center gap-2 rounded-xl border border-admin-border bg-admin-surface px-2 py-1.5",
|
|
468
468
|
"transition-colors hover:bg-admin-bg focus-visible:ring-2 focus-visible:ring-admin-primary"
|
|
469
469
|
),
|
|
470
|
-
"aria-expanded":
|
|
470
|
+
"aria-expanded": l,
|
|
471
471
|
"aria-haspopup": "menu",
|
|
472
472
|
children: [
|
|
473
473
|
e.avatar ? /* @__PURE__ */ n("img", { src: e.avatar, alt: "", className: "h-8 w-8 rounded-lg object-cover" }) : /* @__PURE__ */ n("div", { className: "flex h-8 w-8 items-center justify-center rounded-lg bg-admin-primary text-xs font-semibold text-white", children: d }),
|
|
@@ -479,7 +479,7 @@ function Me({ user: e, onLogout: t, onSettings: a, className: r }) {
|
|
|
479
479
|
]
|
|
480
480
|
}
|
|
481
481
|
),
|
|
482
|
-
|
|
482
|
+
l && /* @__PURE__ */ o(
|
|
483
483
|
"div",
|
|
484
484
|
{
|
|
485
485
|
role: "menu",
|
|
@@ -492,7 +492,7 @@ function Me({ user: e, onLogout: t, onSettings: a, className: r }) {
|
|
|
492
492
|
role: "menuitem",
|
|
493
493
|
className: "flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-admin-text hover:bg-admin-bg",
|
|
494
494
|
onClick: () => {
|
|
495
|
-
|
|
495
|
+
r == null || r(), s(!1);
|
|
496
496
|
},
|
|
497
497
|
children: [
|
|
498
498
|
/* @__PURE__ */ n(de, { className: "h-4 w-4 text-admin-muted" }),
|
|
@@ -520,7 +520,7 @@ function Me({ user: e, onLogout: t, onSettings: a, className: r }) {
|
|
|
520
520
|
role: "menuitem",
|
|
521
521
|
className: "flex w-full items-center gap-2 rounded-lg px-3 py-2 text-sm text-red-600 hover:bg-red-50 dark:hover:bg-red-950/30",
|
|
522
522
|
onClick: () => {
|
|
523
|
-
t == null || t(),
|
|
523
|
+
t == null || t(), s(!1);
|
|
524
524
|
},
|
|
525
525
|
children: [
|
|
526
526
|
/* @__PURE__ */ n(ce, { className: "h-4 w-4" }),
|
|
@@ -536,10 +536,10 @@ function Me({ user: e, onLogout: t, onSettings: a, className: r }) {
|
|
|
536
536
|
function Pe({
|
|
537
537
|
user: e,
|
|
538
538
|
notifications: t = [],
|
|
539
|
-
onSearch:
|
|
540
|
-
searchPlaceholder:
|
|
541
|
-
showSearch:
|
|
542
|
-
className:
|
|
539
|
+
onSearch: r,
|
|
540
|
+
searchPlaceholder: a = "Search...",
|
|
541
|
+
showSearch: l = !0,
|
|
542
|
+
className: s,
|
|
543
543
|
breadcrumbs: i = [],
|
|
544
544
|
onMenuClick: d,
|
|
545
545
|
sidebarCollapsed: c,
|
|
@@ -551,7 +551,7 @@ function Pe({
|
|
|
551
551
|
className: u(
|
|
552
552
|
"sticky top-0 z-40 flex h-16 shrink-0 items-center gap-4 border-b border-admin-border",
|
|
553
553
|
"admin-glass bg-admin-surface px-4 lg:px-6",
|
|
554
|
-
|
|
554
|
+
s
|
|
555
555
|
),
|
|
556
556
|
children: [
|
|
557
557
|
/* @__PURE__ */ n(
|
|
@@ -576,7 +576,7 @@ function Pe({
|
|
|
576
576
|
),
|
|
577
577
|
/* @__PURE__ */ n("div", { className: "hidden min-w-0 flex-1 md:block", children: /* @__PURE__ */ n(we, { items: i }) }),
|
|
578
578
|
/* @__PURE__ */ o("div", { className: "flex flex-1 items-center justify-end gap-2 sm:gap-3", children: [
|
|
579
|
-
|
|
579
|
+
l && /* @__PURE__ */ n("div", { className: "hidden flex-1 sm:flex sm:max-w-md", children: /* @__PURE__ */ n(Ne, { placeholder: a, onSearch: r }) }),
|
|
580
580
|
/* @__PURE__ */ n(Se, {}),
|
|
581
581
|
/* @__PURE__ */ n(ke, { notifications: t }),
|
|
582
582
|
e && /* @__PURE__ */ n(Me, { user: e })
|
|
@@ -588,23 +588,24 @@ function Pe({
|
|
|
588
588
|
function Le({
|
|
589
589
|
items: e,
|
|
590
590
|
collapsed: t,
|
|
591
|
-
appName:
|
|
592
|
-
appLogo:
|
|
593
|
-
className:
|
|
594
|
-
onNavigate:
|
|
591
|
+
appName: r = "Admin",
|
|
592
|
+
appLogo: a,
|
|
593
|
+
className: l,
|
|
594
|
+
onNavigate: s,
|
|
595
595
|
activePath: i,
|
|
596
596
|
LinkComponent: d
|
|
597
597
|
}) {
|
|
598
|
-
const { collapsed: c, toggle: b, closeMobile: f } = O(), { permissions: v, activePath: h } = k(), m = t ?? c, p = i ?? h, N = D(e, v), C = (
|
|
599
|
-
|
|
598
|
+
const { collapsed: c, toggle: b, closeMobile: f } = O(), { permissions: v, activePath: h } = k(), m = t ?? c, p = i ?? h, N = D(e, v), C = (g) => {
|
|
599
|
+
s == null || s(g), f();
|
|
600
600
|
};
|
|
601
601
|
return /* @__PURE__ */ o(
|
|
602
602
|
"aside",
|
|
603
603
|
{
|
|
604
604
|
className: u(
|
|
605
|
-
"hidden lg:flex flex-col border-r border-admin-border bg-admin-surface
|
|
605
|
+
"hidden lg:flex shrink-0 flex-col border-r border-admin-border bg-admin-surface",
|
|
606
|
+
"h-screen sticky top-0 transition-[width] duration-300 ease-in-out",
|
|
606
607
|
m ? "w-[var(--admin-sidebar-collapsed)]" : "w-[var(--admin-sidebar-width)]",
|
|
607
|
-
|
|
608
|
+
l
|
|
608
609
|
),
|
|
609
610
|
"aria-label": "Sidebar navigation",
|
|
610
611
|
children: [
|
|
@@ -617,8 +618,8 @@ function Le({
|
|
|
617
618
|
),
|
|
618
619
|
children: [
|
|
619
620
|
/* @__PURE__ */ o("div", { className: u("flex items-center gap-3 min-w-0", m && "justify-center"), children: [
|
|
620
|
-
|
|
621
|
-
!m && /* @__PURE__ */ n("span", { className: "truncate text-base font-semibold text-admin-text", children:
|
|
621
|
+
a ?? /* @__PURE__ */ n("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-admin-primary text-sm font-bold text-white shadow-admin", children: r.charAt(0) }),
|
|
622
|
+
!m && /* @__PURE__ */ n("span", { className: "truncate text-base font-semibold text-admin-text", children: r })
|
|
622
623
|
] }),
|
|
623
624
|
!m && /* @__PURE__ */ n(
|
|
624
625
|
"button",
|
|
@@ -643,16 +644,16 @@ function Le({
|
|
|
643
644
|
children: /* @__PURE__ */ n(J, { className: "h-4 w-4" })
|
|
644
645
|
}
|
|
645
646
|
) }),
|
|
646
|
-
/* @__PURE__ */ n("nav", { className: "flex-1 overflow-y-auto p-3", children: /* @__PURE__ */ n(X, { collapsed: m, children: N.map((
|
|
647
|
+
/* @__PURE__ */ n("nav", { className: "flex-1 overflow-y-auto p-3", children: /* @__PURE__ */ n(X, { collapsed: m, children: N.map((g) => /* @__PURE__ */ n(
|
|
647
648
|
R,
|
|
648
649
|
{
|
|
649
|
-
item:
|
|
650
|
+
item: g,
|
|
650
651
|
collapsed: m,
|
|
651
652
|
activePath: p,
|
|
652
653
|
onNavigate: C,
|
|
653
654
|
LinkComponent: d
|
|
654
655
|
},
|
|
655
|
-
|
|
656
|
+
g.label + (g.path ?? "")
|
|
656
657
|
)) }) })
|
|
657
658
|
]
|
|
658
659
|
}
|
|
@@ -661,10 +662,10 @@ function Le({
|
|
|
661
662
|
function F({
|
|
662
663
|
children: e,
|
|
663
664
|
sidebarItems: t,
|
|
664
|
-
appName:
|
|
665
|
-
appLogo:
|
|
666
|
-
user:
|
|
667
|
-
notifications:
|
|
665
|
+
appName: r = "Admin",
|
|
666
|
+
appLogo: a,
|
|
667
|
+
user: l,
|
|
668
|
+
notifications: s = [],
|
|
668
669
|
footer: i,
|
|
669
670
|
showFooter: d = !0,
|
|
670
671
|
showSearch: c = !0,
|
|
@@ -678,9 +679,9 @@ function F({
|
|
|
678
679
|
enableRouter: C = !1
|
|
679
680
|
}) {
|
|
680
681
|
const {
|
|
681
|
-
sidebarCollapsed:
|
|
682
|
+
sidebarCollapsed: g,
|
|
682
683
|
toggleSidebar: S,
|
|
683
|
-
toggleMobile:
|
|
684
|
+
toggleMobile: x,
|
|
684
685
|
breadcrumbs: P,
|
|
685
686
|
setBreadcrumbs: B,
|
|
686
687
|
activePath: y,
|
|
@@ -689,94 +690,96 @@ function F({
|
|
|
689
690
|
Y(j), v || B(E(j)), p == null || p(j), _();
|
|
690
691
|
};
|
|
691
692
|
return /* @__PURE__ */ o("div", { className: "admin-layout-root min-h-screen bg-admin-bg text-admin-text", children: [
|
|
692
|
-
/* @__PURE__ */ n(
|
|
693
|
-
Le,
|
|
694
|
-
{
|
|
695
|
-
items: t,
|
|
696
|
-
appName: a,
|
|
697
|
-
appLogo: r,
|
|
698
|
-
activePath: $,
|
|
699
|
-
onNavigate: q,
|
|
700
|
-
LinkComponent: N
|
|
701
|
-
}
|
|
702
|
-
),
|
|
703
693
|
/* @__PURE__ */ n(
|
|
704
694
|
ye,
|
|
705
695
|
{
|
|
706
696
|
items: t,
|
|
707
|
-
appName:
|
|
708
|
-
appLogo:
|
|
697
|
+
appName: r,
|
|
698
|
+
appLogo: a,
|
|
709
699
|
activePath: $,
|
|
710
700
|
onNavigate: q,
|
|
711
701
|
LinkComponent: N
|
|
712
702
|
}
|
|
713
703
|
),
|
|
714
|
-
/* @__PURE__ */ o("div", { className:
|
|
704
|
+
/* @__PURE__ */ o("div", { className: "flex min-h-screen w-full", children: [
|
|
715
705
|
/* @__PURE__ */ n(
|
|
716
|
-
|
|
706
|
+
Le,
|
|
717
707
|
{
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
onMenuClick: g,
|
|
725
|
-
sidebarCollapsed: x,
|
|
726
|
-
onToggleSidebar: S
|
|
708
|
+
items: t,
|
|
709
|
+
appName: r,
|
|
710
|
+
appLogo: a,
|
|
711
|
+
activePath: $,
|
|
712
|
+
onNavigate: q,
|
|
713
|
+
LinkComponent: N
|
|
727
714
|
}
|
|
728
715
|
),
|
|
729
|
-
/* @__PURE__ */
|
|
730
|
-
|
|
716
|
+
/* @__PURE__ */ o("div", { className: "flex min-h-screen min-w-0 flex-1 flex-col", children: [
|
|
717
|
+
/* @__PURE__ */ n(
|
|
718
|
+
Pe,
|
|
719
|
+
{
|
|
720
|
+
user: l,
|
|
721
|
+
notifications: s,
|
|
722
|
+
onSearch: f,
|
|
723
|
+
searchPlaceholder: b,
|
|
724
|
+
showSearch: c,
|
|
725
|
+
breadcrumbs: K,
|
|
726
|
+
onMenuClick: x,
|
|
727
|
+
sidebarCollapsed: g,
|
|
728
|
+
onToggleSidebar: S
|
|
729
|
+
}
|
|
730
|
+
),
|
|
731
|
+
/* @__PURE__ */ n("main", { className: u("flex-1 p-4 lg:p-6", h), children: e }),
|
|
732
|
+
d && /* @__PURE__ */ n(xe, { children: i })
|
|
733
|
+
] })
|
|
731
734
|
] })
|
|
732
735
|
] });
|
|
733
736
|
}
|
|
734
|
-
function
|
|
737
|
+
function Ee(e) {
|
|
735
738
|
const {
|
|
736
739
|
storageKey: t = "rqdhw3n-admin-layout",
|
|
737
|
-
defaultCollapsed:
|
|
738
|
-
initialDarkMode:
|
|
739
|
-
permissions:
|
|
740
|
-
breadcrumbs:
|
|
740
|
+
defaultCollapsed: r = !1,
|
|
741
|
+
initialDarkMode: a = !1,
|
|
742
|
+
permissions: l = {},
|
|
743
|
+
breadcrumbs: s = [],
|
|
741
744
|
activePath: i = "/",
|
|
742
745
|
enableRouter: d = !1,
|
|
743
746
|
children: c,
|
|
744
747
|
...b
|
|
745
748
|
} = e, f = U(
|
|
746
|
-
() =>
|
|
747
|
-
[
|
|
749
|
+
() => s.length ? s : E(i),
|
|
750
|
+
[s, i]
|
|
748
751
|
);
|
|
749
752
|
return /* @__PURE__ */ n(
|
|
750
753
|
he,
|
|
751
754
|
{
|
|
752
755
|
storageKey: t,
|
|
753
|
-
defaultCollapsed:
|
|
754
|
-
permissions:
|
|
756
|
+
defaultCollapsed: r,
|
|
757
|
+
permissions: l,
|
|
755
758
|
initialBreadcrumbs: f,
|
|
756
759
|
initialActivePath: i,
|
|
757
|
-
initialDarkMode:
|
|
760
|
+
initialDarkMode: a,
|
|
758
761
|
children: d ? /* @__PURE__ */ n(pe, { children: /* @__PURE__ */ n(F, { ...b, enableRouter: d, children: c }) }) : /* @__PURE__ */ n(F, { ...b, enableRouter: d, children: c })
|
|
759
762
|
}
|
|
760
763
|
);
|
|
761
764
|
}
|
|
762
|
-
function
|
|
763
|
-
return /* @__PURE__ */ n(ee, { to: e, className: t, onClick:
|
|
765
|
+
function De({ to: e, className: t, children: r, onClick: a }) {
|
|
766
|
+
return /* @__PURE__ */ n(ee, { to: e, className: t, onClick: a, children: r });
|
|
764
767
|
}
|
|
765
|
-
function
|
|
768
|
+
function Re() {
|
|
766
769
|
return k();
|
|
767
770
|
}
|
|
768
|
-
function
|
|
769
|
-
const { breadcrumbs: e, setBreadcrumbs: t } = k(),
|
|
770
|
-
(
|
|
771
|
+
function $e() {
|
|
772
|
+
const { breadcrumbs: e, setBreadcrumbs: t } = k(), r = L(
|
|
773
|
+
(a) => t(a),
|
|
771
774
|
[t]
|
|
772
775
|
);
|
|
773
776
|
return {
|
|
774
777
|
items: e,
|
|
775
|
-
setBreadcrumbs:
|
|
778
|
+
setBreadcrumbs: r
|
|
776
779
|
};
|
|
777
780
|
}
|
|
778
781
|
export {
|
|
779
|
-
|
|
782
|
+
Ee as AdminLayout,
|
|
780
783
|
pe as AdminLayoutRouterSync,
|
|
781
784
|
we as Breadcrumbs,
|
|
782
785
|
xe as Footer,
|
|
@@ -785,7 +788,7 @@ export {
|
|
|
785
788
|
Pe as Navbar,
|
|
786
789
|
Ne as NavbarSearch,
|
|
787
790
|
ke as NotificationMenu,
|
|
788
|
-
|
|
791
|
+
De as RouterLink,
|
|
789
792
|
Le as Sidebar,
|
|
790
793
|
X as SidebarGroup,
|
|
791
794
|
R as SidebarItem,
|
|
@@ -795,10 +798,10 @@ export {
|
|
|
795
798
|
D as filterSidebarByPermissions,
|
|
796
799
|
E as generateBreadcrumbsFromPath,
|
|
797
800
|
ve as hasPermission,
|
|
798
|
-
|
|
801
|
+
$e as useBreadcrumbs,
|
|
799
802
|
Ce as useDarkMode,
|
|
800
803
|
k as useLayoutContext,
|
|
801
|
-
|
|
804
|
+
Re as useLayoutState,
|
|
802
805
|
O as useSidebar
|
|
803
806
|
};
|
|
804
807
|
//# sourceMappingURL=index.js.map
|