@purplle/sidebar 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/CHANGELOG.md +1 -1
- package/README.md +143 -39
- package/dist/prism-sidebar.js +822 -0
- package/dist/prism-sidebar.js.map +1 -0
- package/dist/prism-sidebar.umd.js +185 -0
- package/dist/prism-sidebar.umd.js.map +1 -0
- package/package.json +9 -8
- package/dist/sidebar.js +0 -544
- package/dist/sidebar.js.map +0 -1
- package/dist/sidebar.umd.js +0 -45
- package/dist/sidebar.umd.js.map +0 -1
|
@@ -0,0 +1,822 @@
|
|
|
1
|
+
function M(t) {
|
|
2
|
+
if (!t || typeof t != "object") return !1;
|
|
3
|
+
const e = t;
|
|
4
|
+
return typeof e.id < "u" && typeof e.name == "string";
|
|
5
|
+
}
|
|
6
|
+
function x(t) {
|
|
7
|
+
return t.filter((e) => M(e)).map((e) => {
|
|
8
|
+
const r = e.path ?? e.url, i = {
|
|
9
|
+
...e,
|
|
10
|
+
id: String(e.id),
|
|
11
|
+
...r ? { path: r } : {}
|
|
12
|
+
};
|
|
13
|
+
return Array.isArray(e.children) && (i.children = x(e.children)), i;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function N(t) {
|
|
17
|
+
if (Array.isArray(t)) return x(t);
|
|
18
|
+
if (!t || typeof t != "object") return [];
|
|
19
|
+
const e = t;
|
|
20
|
+
return Array.isArray(e.data?.menu) ? x(e.data.menu) : Array.isArray(e.menu) ? x(e.menu) : [];
|
|
21
|
+
}
|
|
22
|
+
async function L(t, e) {
|
|
23
|
+
if (!t.apiUrl) throw new Error("Missing apiUrl");
|
|
24
|
+
if (!t.token) throw new Error("Missing token");
|
|
25
|
+
const r = {
|
|
26
|
+
headers: {
|
|
27
|
+
Authorization: `Bearer ${t.token}`
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
e && (r.signal = e);
|
|
31
|
+
const i = await fetch(t.apiUrl, r);
|
|
32
|
+
if (!i.ok)
|
|
33
|
+
throw new Error(`Menu API failed with ${i.status}`);
|
|
34
|
+
let n;
|
|
35
|
+
try {
|
|
36
|
+
n = await i.json();
|
|
37
|
+
} catch {
|
|
38
|
+
throw new Error("Menu API returned non-JSON payload");
|
|
39
|
+
}
|
|
40
|
+
return N(n);
|
|
41
|
+
}
|
|
42
|
+
function _(t) {
|
|
43
|
+
return {
|
|
44
|
+
role: "navigation",
|
|
45
|
+
"aria-label": t
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function H(t) {
|
|
49
|
+
return t ? "page" : null;
|
|
50
|
+
}
|
|
51
|
+
function D(t) {
|
|
52
|
+
return t.key === "Enter" || t.key === " ";
|
|
53
|
+
}
|
|
54
|
+
function v(t) {
|
|
55
|
+
const e = t.trim();
|
|
56
|
+
return e && e.replace(/\/+$/, "") || "/";
|
|
57
|
+
}
|
|
58
|
+
function F(t) {
|
|
59
|
+
return t.split("?")[0]?.split("#")[0] ?? t;
|
|
60
|
+
}
|
|
61
|
+
function d(t, e) {
|
|
62
|
+
if (typeof t == "boolean") return t;
|
|
63
|
+
if (t == null || t === "") return e;
|
|
64
|
+
const r = String(t).toLowerCase();
|
|
65
|
+
return !["0", "false", "no", "off"].includes(r);
|
|
66
|
+
}
|
|
67
|
+
const a = {
|
|
68
|
+
token: "",
|
|
69
|
+
apiUrl: "",
|
|
70
|
+
baseUrl: "",
|
|
71
|
+
activePath: "",
|
|
72
|
+
target: "_top",
|
|
73
|
+
useShadowDom: !0,
|
|
74
|
+
ariaLabel: "Sidebar navigation",
|
|
75
|
+
collapsed: !0,
|
|
76
|
+
autoNavigate: !0,
|
|
77
|
+
width: "240px",
|
|
78
|
+
title: "P.R.I.S.M.",
|
|
79
|
+
subtitle: "Purplle Retail Intelligence & Sales Management",
|
|
80
|
+
homeUrl: "/",
|
|
81
|
+
logoutText: "Logout",
|
|
82
|
+
logoutPath: "/sentinel/logout",
|
|
83
|
+
error: ""
|
|
84
|
+
}, V = ["_self", "_blank", "_top"];
|
|
85
|
+
function B(t) {
|
|
86
|
+
const e = t.getAttribute("base-url") ?? (location?.origin || ""), r = {
|
|
87
|
+
target: P(t.getAttribute("target")),
|
|
88
|
+
baseUrl: e
|
|
89
|
+
}, i = t.getAttribute("token");
|
|
90
|
+
i !== null && (r.token = i);
|
|
91
|
+
const n = t.getAttribute("api-url") ?? t.getAttribute("api-base-url") ?? e + "/sentinel/api/v1/menu";
|
|
92
|
+
n !== null && (r.apiUrl = n);
|
|
93
|
+
const c = t.getAttribute("active-path");
|
|
94
|
+
c !== null && (r.activePath = c);
|
|
95
|
+
const f = t.getAttribute("aria-label");
|
|
96
|
+
f !== null && (r.ariaLabel = f);
|
|
97
|
+
const l = t.getAttribute("use-shadow-dom");
|
|
98
|
+
l !== null && (r.useShadowDom = d(l, !0));
|
|
99
|
+
const s = t.getAttribute("collapsed");
|
|
100
|
+
s !== null && (r.collapsed = d(s, !1));
|
|
101
|
+
const u = t.getAttribute("auto-navigate");
|
|
102
|
+
u !== null && (r.autoNavigate = d(u, !0));
|
|
103
|
+
const g = t.getAttribute("width");
|
|
104
|
+
g !== null && (r.width = g);
|
|
105
|
+
const h = t.getAttribute("title");
|
|
106
|
+
h !== null && (r.title = h);
|
|
107
|
+
const p = t.getAttribute("subtitle");
|
|
108
|
+
p !== null && (r.subtitle = p);
|
|
109
|
+
const b = t.getAttribute("home-url");
|
|
110
|
+
b !== null && (r.homeUrl = b);
|
|
111
|
+
const k = t.getAttribute("logout-text");
|
|
112
|
+
k !== null && (r.logoutText = k);
|
|
113
|
+
const S = t.getAttribute("logout-path");
|
|
114
|
+
S !== null && (r.logoutPath = S);
|
|
115
|
+
const A = t.getAttribute("error");
|
|
116
|
+
return A !== null && (r.error = A), r;
|
|
117
|
+
}
|
|
118
|
+
function R(t) {
|
|
119
|
+
const e = P(t.target);
|
|
120
|
+
return {
|
|
121
|
+
token: t.token?.trim() ?? a.token,
|
|
122
|
+
baseUrl: t.baseUrl?.trim() ?? a.baseUrl,
|
|
123
|
+
apiUrl: t.apiUrl?.replace(/\/+$/, "") ?? a.apiUrl,
|
|
124
|
+
activePath: t.activePath ? v(t.activePath) : a.activePath,
|
|
125
|
+
target: e,
|
|
126
|
+
useShadowDom: d(t.useShadowDom, a.useShadowDom),
|
|
127
|
+
ariaLabel: t.ariaLabel?.trim() || a.ariaLabel,
|
|
128
|
+
collapsed: d(t.collapsed, a.collapsed),
|
|
129
|
+
autoNavigate: d(t.autoNavigate, a.autoNavigate),
|
|
130
|
+
width: t.width?.trim() || a.width,
|
|
131
|
+
title: t.title?.trim() || a.title,
|
|
132
|
+
subtitle: t.subtitle?.trim() || a.subtitle,
|
|
133
|
+
homeUrl: t.homeUrl?.trim() || a.homeUrl,
|
|
134
|
+
logoutText: t.logoutText?.trim() || a.logoutText,
|
|
135
|
+
logoutPath: t.logoutPath?.trim() || a.logoutPath,
|
|
136
|
+
error: t.error?.trim() || a.error
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function U(t, e) {
|
|
140
|
+
const r = { ...t };
|
|
141
|
+
for (const i of Object.keys(e)) {
|
|
142
|
+
const n = e[i];
|
|
143
|
+
typeof n > "u" || (r[i] = n);
|
|
144
|
+
}
|
|
145
|
+
return R(r);
|
|
146
|
+
}
|
|
147
|
+
function P(t) {
|
|
148
|
+
if (!t) return a.target;
|
|
149
|
+
const e = t;
|
|
150
|
+
return V.includes(e) ? e : a.target;
|
|
151
|
+
}
|
|
152
|
+
const w = {
|
|
153
|
+
loaded: "sidebar-loaded",
|
|
154
|
+
error: "sidebar-error",
|
|
155
|
+
itemClick: "sidebar-item-click"
|
|
156
|
+
};
|
|
157
|
+
function W(t, e) {
|
|
158
|
+
t.dispatchEvent(new CustomEvent(w.loaded, { detail: e, bubbles: !0, composed: !0 }));
|
|
159
|
+
}
|
|
160
|
+
function j(t, e) {
|
|
161
|
+
t.dispatchEvent(new CustomEvent(w.error, { detail: e, bubbles: !0, composed: !0 }));
|
|
162
|
+
}
|
|
163
|
+
function q(t, e) {
|
|
164
|
+
t.dispatchEvent(new CustomEvent(w.itemClick, { detail: e, bubbles: !0, composed: !0 }));
|
|
165
|
+
}
|
|
166
|
+
function O(t) {
|
|
167
|
+
const e = String(t || "").trim();
|
|
168
|
+
return e || "#";
|
|
169
|
+
}
|
|
170
|
+
function X(t) {
|
|
171
|
+
return String(t || "").replace(/\/+$/, "");
|
|
172
|
+
}
|
|
173
|
+
function Y(t, e) {
|
|
174
|
+
const r = O(t);
|
|
175
|
+
if (r === "#") return "#";
|
|
176
|
+
if (/^(https?:)?\/\//.test(r) || r.startsWith("mailto:") || r.startsWith("tel:")) return r;
|
|
177
|
+
const i = X(e);
|
|
178
|
+
return i ? r.startsWith("/") ? `${i}${r}` : `${i}/${r}` : r;
|
|
179
|
+
}
|
|
180
|
+
function G(t, e) {
|
|
181
|
+
if (!e.autoNavigate) return;
|
|
182
|
+
const r = Y(t, e.baseUrl);
|
|
183
|
+
if (r !== "#") {
|
|
184
|
+
if (e.target === "_blank") {
|
|
185
|
+
window.open(r, "_blank", "noopener,noreferrer");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (e.target === "_top")
|
|
189
|
+
try {
|
|
190
|
+
if (window.top) {
|
|
191
|
+
window.top.location.href = r;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
} catch {
|
|
195
|
+
window.location.href = r;
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
window.location.href = r;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function Z() {
|
|
202
|
+
return {
|
|
203
|
+
loading: !1,
|
|
204
|
+
menu: [],
|
|
205
|
+
error: "",
|
|
206
|
+
activeId: null,
|
|
207
|
+
expandedIds: /* @__PURE__ */ new Set()
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
const J = `
|
|
211
|
+
@font-face {
|
|
212
|
+
font-family: 'Inter';
|
|
213
|
+
font-style: normal;
|
|
214
|
+
font-weight: 400;
|
|
215
|
+
font-display: swap;
|
|
216
|
+
src: url(https://fonts.gstatic.com/s/inter/v20/UcC73FwrK3iLTeHuS_nVMrMxCp50SjIa2JL7W0Q5n-wU.woff2) format('woff2');
|
|
217
|
+
unicode-range: U +0460 -052F, U +1C80 -1C8A, U +20B4, U +2DE0 -2DFF, U + A640-A69F, U + FE2E-FE2F;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
:host, prism-sidebar {
|
|
221
|
+
--prism-sidebar-width: 240px;
|
|
222
|
+
--prism-sidebar-bg: linear-gradient(rgb(156,0,173),rgb(89,0,99));
|
|
223
|
+
--prism-sidebar-text-color: #ffffff;
|
|
224
|
+
--prism-sidebar-border-color: rgba(255,255,255,.15);
|
|
225
|
+
--prism-sidebar-hover-bg: rgba(255,255,255,0.12);
|
|
226
|
+
--prism-sidebar-active-bg: rgba(255,255,255,.1);
|
|
227
|
+
--prism-sidebar-indent: 14px;
|
|
228
|
+
--prism-sidebar-font-family: Inter,'sans-serif',ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Helvetica,Arial,'Apple Color Emoji','Segoe UI Emoji';
|
|
229
|
+
font-feature-settings: normal;
|
|
230
|
+
line-height: 1.5;
|
|
231
|
+
display: block;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.prism-nav::-webkit-scrollbar {
|
|
235
|
+
display: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.hidden {
|
|
239
|
+
display: none !important;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@keyframes sidebar-spin {
|
|
243
|
+
to { transform: rotate(360deg); }
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.prism-loader-spinner {
|
|
247
|
+
width: 28px;
|
|
248
|
+
height: 28px;
|
|
249
|
+
display: inline-block;
|
|
250
|
+
border: 3px solid rgba(255,255,255,.35);
|
|
251
|
+
border-top-color: #ffffff;
|
|
252
|
+
border-radius: 9999px;
|
|
253
|
+
animation: sidebar-spin 1s linear infinite;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* layer: preflights */
|
|
257
|
+
*,::before,::after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / 0.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: ;}::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / 0.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: ;}
|
|
258
|
+
/* layer: default */
|
|
259
|
+
.\\[-ms-overflow-style\\:none\\]{-ms-overflow-style:none;}
|
|
260
|
+
.\\[background\\:var\\(--prism-sidebar-bg\\)\\]{background:var(--prism-sidebar-bg);}
|
|
261
|
+
.\\[border-top\\:1px_solid_\\#ffffff26\\]{border-top:1px solid #ffffff26;}
|
|
262
|
+
.\\[font-family\\:var\\(--prism-sidebar-font-family\\)\\]{font-family:var(--prism-sidebar-font-family);}
|
|
263
|
+
.\\[scrollbar-width\\:none\\]{scrollbar-width:none;}
|
|
264
|
+
.fixed{position:fixed;}
|
|
265
|
+
.bottom-0{bottom:0;}
|
|
266
|
+
.left-0{left:0;}
|
|
267
|
+
.top-0{top:0;}
|
|
268
|
+
.z-\\[1600\\]{z-index:1600;}
|
|
269
|
+
.mb-\\[16px\\]{margin-bottom:16px;}
|
|
270
|
+
.mb-\\[4px\\]{margin-bottom:4px;}
|
|
271
|
+
.mt-2{margin-top:0.5rem;}
|
|
272
|
+
.box-border{box-sizing:border-box;}
|
|
273
|
+
.block{display:block;}
|
|
274
|
+
.inline-block{display:inline-block;}
|
|
275
|
+
.h-\\[100vh\\]{height:100vh;}
|
|
276
|
+
.min-h-full{min-height:100%;}
|
|
277
|
+
.min-w-\\[var\\(--prism-sidebar-width\\)\\]{min-width:var(--prism-sidebar-width);}
|
|
278
|
+
.w-\\[var\\(--prism-sidebar-width\\)\\]{width:var(--prism-sidebar-width);}
|
|
279
|
+
.w-full{width:100%;}
|
|
280
|
+
.flex{display:flex;}
|
|
281
|
+
.flex-\\[1_1_0\\%\\]{flex:1 1 0%;}
|
|
282
|
+
.shrink-0{flex-shrink:0;}
|
|
283
|
+
.flex-col{flex-direction:column;}
|
|
284
|
+
.rotate-\\[180deg\\]{--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-rotate:180deg;transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}
|
|
285
|
+
.transform{transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}
|
|
286
|
+
.cursor-pointer{cursor:pointer;}
|
|
287
|
+
.items-center{align-items:center;}
|
|
288
|
+
.justify-center{justify-content:center;}
|
|
289
|
+
.justify-between{justify-content:space-between;}
|
|
290
|
+
.gap-\\[10px\\]{gap:10px;}
|
|
291
|
+
.gap-\\[12px\\]{gap:12px;}
|
|
292
|
+
.gap-\\[2px\\]{gap:2px;}
|
|
293
|
+
.gap-\\[4px\\]{gap:4px;}
|
|
294
|
+
.overflow-hidden{overflow:hidden;}
|
|
295
|
+
.overflow-y-auto{overflow-y:auto;}
|
|
296
|
+
.border{border-width:1px;}
|
|
297
|
+
.border-0{border-width:0px;}
|
|
298
|
+
.rounded-\\[6px\\]{border-radius:6px;}
|
|
299
|
+
.bg-transparent{background-color:transparent /* transparent */;}
|
|
300
|
+
.bg-white\\/10{background-color:rgb(255 255 255 / 0.1) /* #fff */;}
|
|
301
|
+
.hover\\:bg-\\[var\\(--prism-sidebar-hover-bg\\)\\]:hover{background-color:var(--prism-sidebar-hover-bg) /* var(--prism-sidebar-hover-bg) */;}
|
|
302
|
+
.hover\\:bg-white\\/10:hover{background-color:rgb(255 255 255 / 0.1) /* #fff */;}
|
|
303
|
+
.p-\\[20px\\]{padding:20px;}
|
|
304
|
+
.px-\\[10px\\]{padding-left:10px;padding-right:10px;}
|
|
305
|
+
.px-\\[12px\\]{padding-left:12px;padding-right:12px;}
|
|
306
|
+
.py-\\[10px\\]{padding-top:10px;padding-bottom:10px;}
|
|
307
|
+
.py-\\[8px\\]{padding-top:8px;padding-bottom:8px;}
|
|
308
|
+
.pl-\\[12px\\]{padding-left:12px;}
|
|
309
|
+
.pt-\\[4px\\]{padding-top:4px;}
|
|
310
|
+
.pt-2{padding-top:0.5rem;}
|
|
311
|
+
.text-center{text-align:center;}
|
|
312
|
+
.text-left{text-align:left;}
|
|
313
|
+
.text-\\[12\\.5px\\]{font-size:12.5px;}
|
|
314
|
+
.text-\\[12px\\]{font-size:12px;}
|
|
315
|
+
.text-\\[13px\\]{font-size:13px;}
|
|
316
|
+
.text-\\[14px\\]{font-size:14px;}
|
|
317
|
+
.text-\\[16px\\]{font-size:16px;}
|
|
318
|
+
.text-\\[30px\\]{font-size:30px;}
|
|
319
|
+
.text-\\[\\#ffd0d0\\]{--un-text-opacity:1;color:rgb(255 208 208 / var(--un-text-opacity)) /* #ffd0d0 */;}
|
|
320
|
+
.text-\\[rgba\\(255\\,255\\,255\\,\\.95\\)\\]{--un-text-opacity:.95;color:rgba(255, 255, 255, var(--un-text-opacity)) /* rgba(255,255,255,.95) */;}
|
|
321
|
+
.text-\\[var\\(--prism-sidebar-text-color\\)\\]{color:var(--prism-sidebar-text-color) /* var(--prism-sidebar-text-color) */;}
|
|
322
|
+
.text-white{--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity)) /* #fff */;}
|
|
323
|
+
.text-white\\/80{color:rgb(255 255 255 / 0.8) /* #fff */;}
|
|
324
|
+
.text-white\\/90{color:rgb(255 255 255 / 0.9) /* #fff */;}
|
|
325
|
+
.hover\\:text-white:hover{--un-text-opacity:1;color:rgb(255 255 255 / var(--un-text-opacity)) /* #fff */;}
|
|
326
|
+
.text-inherit{color:inherit;}
|
|
327
|
+
.font-bold{font-weight:700;}
|
|
328
|
+
.font-semibold{font-weight:600;}
|
|
329
|
+
.leading-\\[16px\\]{line-height:16px;}
|
|
330
|
+
.leading-\\[17px\\]{line-height:17px;}
|
|
331
|
+
.leading-\\[18px\\]{line-height:18px;}
|
|
332
|
+
.leading-\\[36px\\]{line-height:36px;}
|
|
333
|
+
.tracking-\\[2px\\]{letter-spacing:2px;}
|
|
334
|
+
.font-\\[500\\]{font-family:500;}
|
|
335
|
+
.font-\\[600\\]{font-family:600;}
|
|
336
|
+
.font-\\[800\\]{font-family:800;}
|
|
337
|
+
.no-underline{text-decoration:none;}
|
|
338
|
+
.hover\\:opacity-\\[\\.9\\]:hover{opacity:.9;}
|
|
339
|
+
.focus-visible\\:outline-\\[2px\\]:focus-visible{outline-width:2px;}
|
|
340
|
+
.focus-visible\\:outline-\\[\\#ffffff\\]:focus-visible{--un-outline-color-opacity:1;outline-color:rgb(255 255 255 / var(--un-outline-color-opacity)) /* #ffffff */;}
|
|
341
|
+
.focus-visible\\:outline-offset-\\[2px\\]:focus-visible{outline-offset:2px;}
|
|
342
|
+
.focus-visible\\:outline:focus-visible{outline-style:solid;}
|
|
343
|
+
.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;}
|
|
344
|
+
.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;}
|
|
345
|
+
.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;}
|
|
346
|
+
.duration-\\[150ms\\]{transition-duration:150ms;}
|
|
347
|
+
.duration-\\[200ms\\]{transition-duration:200ms;}
|
|
348
|
+
.ease-\\[cubic-bezier\\(\\.4\\,0\\,\\.2\\,1\\)\\]{transition-timing-function:cubic-bezier(.4,0,.2,1);}
|
|
349
|
+
`, o = {
|
|
350
|
+
sidebar: "fixed left-0 top-0 bottom-0 z-[1600] box-border [background:var(--prism-sidebar-bg)] text-[var(--prism-sidebar-text-color)] [font-family:var(--prism-sidebar-font-family)] p-[20px] h-[100vh] overflow-hidden flex flex-col gap-[12px] w-[var(--prism-sidebar-width)] min-w-[var(--prism-sidebar-width)]",
|
|
351
|
+
brand: "text-center text-inherit no-underline text-[30px] leading-[36px] font-[800] tracking-[2px] px-[10px] transition-opacity duration-[150ms] ease-[cubic-bezier(.4,0,.2,1)] hover:opacity-[.9] focus-visible:outline focus-visible:outline-[2px] focus-visible:outline-[#ffffff] focus-visible:outline-offset-[2px] font-bold",
|
|
352
|
+
subtitle: "text-center text-[12px] leading-[16px] px-[10px] mb-[16px]",
|
|
353
|
+
nav: "prism-nav flex-[1_1_0%] flex flex-col gap-[4px] overflow-y-auto [scrollbar-width:none] [-ms-overflow-style:none]",
|
|
354
|
+
footer: "mt-2 [border-top:1px_solid_#ffffff26] pt-2",
|
|
355
|
+
logout: "w-full box-border border-0 bg-transparent text-white/90 no-underline flex items-center gap-[10px] text-left text-[12.5px] leading-[17px] font-[600] py-[8px] px-[12px] rounded-[6px] cursor-pointer hover:bg-white/10 hover:text-white focus-visible:outline focus-visible:outline-[2px] focus-visible:outline-[#ffffff] focus-visible:outline-offset-[2px]",
|
|
356
|
+
state: "py-[8px] px-[10px] text-[14px]",
|
|
357
|
+
loaderWrap: "w-full min-h-full flex items-center justify-center",
|
|
358
|
+
loaderSpinner: "prism-loader-spinner",
|
|
359
|
+
error: "py-[8px] px-[10px] text-[14px] text-[#ffd0d0]",
|
|
360
|
+
group: "mb-[4px]",
|
|
361
|
+
groupTitle: "w-full bg-transparent border-0 text-[rgba(255,255,255,.95)] flex items-center justify-between text-left py-[10px] px-[12px] rounded-[6px] text-[13px] leading-[18px] font-semibold transition-colors cursor-pointer hover:bg-[var(--prism-sidebar-hover-bg)] focus-visible:outline focus-visible:outline-[2px] focus-visible:outline-[#ffffff] focus-visible:outline-offset-[2px]",
|
|
362
|
+
chevron: "flex shrink-0 transition-transform duration-[200ms] ease-[cubic-bezier(.4,0,.2,1)]",
|
|
363
|
+
chevronOpen: "flex shrink-0 transition-transform duration-[200ms] ease-[cubic-bezier(.4,0,.2,1)] rotate-[180deg]",
|
|
364
|
+
children: "flex flex-col gap-[2px] pt-[4px] pl-[12px]",
|
|
365
|
+
item: "text-white/80 no-underline flex items-center gap-[10px] text-left text-[12.5px] font-[500] py-[8px] px-[12px] rounded-[6px] transition-colors hover:text-white focus-visible:outline focus-visible:outline-[2px] focus-visible:outline-[#ffffff] focus-visible:outline-offset-[2px]",
|
|
366
|
+
itemActive: "text-white no-underline flex items-center gap-[10px] text-left text-[12.5px] font-[500] py-[8px] px-[12px] rounded-[6px] transition-colors hover:text-white focus-visible:outline focus-visible:outline-[2px] focus-visible:outline-[#ffffff] focus-visible:outline-offset-[2px] bg-white/10",
|
|
367
|
+
itemIcon: "flex shrink-0 text-[16px]"
|
|
368
|
+
};
|
|
369
|
+
function K(t, e) {
|
|
370
|
+
t.querySelectorAll("[data-action]").forEach((r) => {
|
|
371
|
+
r.addEventListener("click", (i) => e(i)), r.addEventListener("keydown", (i) => {
|
|
372
|
+
D(i) && (i.preventDefault(), e(i));
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
function Q(t, e) {
|
|
377
|
+
const r = t.currentTarget;
|
|
378
|
+
if (!(r instanceof HTMLElement)) return;
|
|
379
|
+
r instanceof HTMLAnchorElement && t.preventDefault();
|
|
380
|
+
const i = r.dataset.action;
|
|
381
|
+
if (i === "home") {
|
|
382
|
+
e.onStaticNavigation(e.homeUrl);
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
if (i === "logout") {
|
|
386
|
+
e.onStaticNavigation(e.logoutPath);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
const n = r.dataset.id;
|
|
390
|
+
if (n) {
|
|
391
|
+
if (i === "toggle") {
|
|
392
|
+
e.onToggle(n);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
i === "navigate" && e.onNavigate(n);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
function tt(t, e) {
|
|
399
|
+
t.has(e) ? t.delete(e) : t.add(e);
|
|
400
|
+
}
|
|
401
|
+
function $(t) {
|
|
402
|
+
const e = F(t || "").trim();
|
|
403
|
+
if (!e) return "/";
|
|
404
|
+
try {
|
|
405
|
+
return v(new URL(e, "http://localhost").pathname || "/");
|
|
406
|
+
} catch {
|
|
407
|
+
return v(e);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
function et(t, e) {
|
|
411
|
+
if (!t || !e) return !1;
|
|
412
|
+
if (t === e) return !0;
|
|
413
|
+
const r = t === "/" ? t : `${t}/`, i = e === "/" ? e : `${e}/`;
|
|
414
|
+
return r.endsWith(i) || i.endsWith(r);
|
|
415
|
+
}
|
|
416
|
+
function rt(t, e) {
|
|
417
|
+
const r = $(e || "/"), i = /* @__PURE__ */ new Set();
|
|
418
|
+
let n = null;
|
|
419
|
+
const c = (f, l) => {
|
|
420
|
+
for (const s of f) {
|
|
421
|
+
const u = String(s.id), g = s.path ? $(s.path) : "", h = et(g, r), p = Array.isArray(s.children) ? c(s.children, [...l, u]) : !1;
|
|
422
|
+
if (h || p) {
|
|
423
|
+
n = h ? u : n;
|
|
424
|
+
for (const b of l)
|
|
425
|
+
i.add(b);
|
|
426
|
+
return p && i.add(u), !0;
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
return !1;
|
|
430
|
+
};
|
|
431
|
+
return c(t, []), { activeId: n, expandedIds: i };
|
|
432
|
+
}
|
|
433
|
+
function it(t, e) {
|
|
434
|
+
return U(t, B(e));
|
|
435
|
+
}
|
|
436
|
+
function nt(t, e) {
|
|
437
|
+
return U(t, e);
|
|
438
|
+
}
|
|
439
|
+
function ot(t) {
|
|
440
|
+
return t.activePath || window.location.pathname;
|
|
441
|
+
}
|
|
442
|
+
function at(t, e) {
|
|
443
|
+
const r = ot(e), { activeId: i, expandedIds: n } = rt(t.menu, r);
|
|
444
|
+
t.activeId = i, t.expandedIds = n;
|
|
445
|
+
}
|
|
446
|
+
function st(t) {
|
|
447
|
+
t.loading = !0, t.error = "";
|
|
448
|
+
}
|
|
449
|
+
function lt(t) {
|
|
450
|
+
return t && t.abort(), new AbortController();
|
|
451
|
+
}
|
|
452
|
+
function ut(t, e, r) {
|
|
453
|
+
return t !== e || r.aborted;
|
|
454
|
+
}
|
|
455
|
+
function ct(t, e, r) {
|
|
456
|
+
return t !== e || r instanceof Error && r.name === "AbortError";
|
|
457
|
+
}
|
|
458
|
+
function ft(t, e) {
|
|
459
|
+
t.menu = e, t.loading = !1, t.error = "";
|
|
460
|
+
}
|
|
461
|
+
function dt(t, e) {
|
|
462
|
+
t.loading = !1, t.menu = [], t.error = e;
|
|
463
|
+
}
|
|
464
|
+
const ht = '<span class="anticon anticon-appstore"><svg viewBox="64 64 896 896" width="1em" height="1em" fill="currentColor"><path d="M464 144H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H212V212h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V160c0-8.8-7.2-16-16-16zm-52 268H612V212h200v200zM464 544H160c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H212V612h200v200zm452-268H560c-8.8 0-16 7.2-16 16v304c0 8.8 7.2 16 16 16h304c8.8 0 16-7.2 16-16V560c0-8.8-7.2-16-16-16zm-52 268H612V612h200v200z"></path></svg></span>', pt = '<span class="anticon anticon-logout"><svg viewBox="64 64 896 896" focusable="false" data-icon="logout" width="1em" height="1em" fill="currentColor" aria-hidden="true"><path d="M868 732h-70.3c-4.8 0-9.3 2.1-12.3 5.8-7 8.5-14.5 16.7-22.4 24.5a353.84 353.84 0 01-112.7 75.9A352.8 352.8 0 01512.4 866c-47.9 0-94.3-9.4-137.9-27.8a353.84 353.84 0 01-112.7-75.9 353.28 353.28 0 01-76-112.5C167.3 606.2 158 559.9 158 512s9.4-94.2 27.8-137.8c17.8-42.1 43.4-80 76-112.5s70.5-58.1 112.7-75.9c43.6-18.4 90-27.8 137.9-27.8 47.9 0 94.3 9.3 137.9 27.8 42.2 17.8 80.1 43.4 112.7 75.9 7.9 7.9 15.3 16.1 22.4 24.5 3 3.7 7.6 5.8 12.3 5.8H868c6.3 0 10.2-7 6.7-12.3C798 160.5 663.8 81.6 511.3 82 271.7 82.6 79.6 277.1 82 516.4 84.4 751.9 276.2 942 512.4 942c152.1 0 285.7-78.8 362.3-197.7 3.4-5.3-.4-12.3-6.7-12.3zm88.9-226.3L815 393.7c-5.3-4.2-13-.4-13 6.3v76H488c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h314v76c0 6.7 7.8 10.5 13 6.3l141.9-112a8 8 0 000-12.6z"></path></svg></span>', gt = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
|
|
465
|
+
function bt(t, e) {
|
|
466
|
+
const r = String(e.id);
|
|
467
|
+
return {
|
|
468
|
+
active: t.activeId === r,
|
|
469
|
+
expanded: t.expandedIds.has(r)
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
function y(t) {
|
|
473
|
+
return String(t.baseUrl || "").replace(/\/+$/, "");
|
|
474
|
+
}
|
|
475
|
+
function E(t, e) {
|
|
476
|
+
const r = String(e || "").trim();
|
|
477
|
+
return r ? /^(https?:)?\/\//.test(r) || r.startsWith("mailto:") || r.startsWith("tel:") || !t ? r : r.startsWith("/") ? `${t}${r}` : `${t}/${r}` : t;
|
|
478
|
+
}
|
|
479
|
+
function I(t, e, r) {
|
|
480
|
+
const i = bt(e, t), n = !!t.children?.length, c = y(r), f = E(c, t.path ?? "");
|
|
481
|
+
if (n) {
|
|
482
|
+
const s = i.expanded || !r.collapsed;
|
|
483
|
+
return `
|
|
484
|
+
<div class="${o.group}">
|
|
485
|
+
<button type="button" class="${o.groupTitle}" data-action="toggle" data-id="${t.id}" aria-expanded="${s}">
|
|
486
|
+
<span>${t.name}</span>
|
|
487
|
+
<span class="${s ? o.chevronOpen : o.chevron}">${gt}</span>
|
|
488
|
+
</button>
|
|
489
|
+
<div class="${s ? o.children : `${o.children} hidden`}">
|
|
490
|
+
${(t.children ?? []).map((u) => I(u, e, r)).join("")}
|
|
491
|
+
</div>
|
|
492
|
+
</div>
|
|
493
|
+
`;
|
|
494
|
+
}
|
|
495
|
+
const l = H(i.active);
|
|
496
|
+
return `
|
|
497
|
+
<a
|
|
498
|
+
href="${f}"
|
|
499
|
+
target="${r.target}"
|
|
500
|
+
class="${i.active ? o.itemActive : o.item}"
|
|
501
|
+
data-action="navigate"
|
|
502
|
+
data-id="${t.id}"
|
|
503
|
+
data-path="${f}"
|
|
504
|
+
${l ? `aria-current="${l}"` : ""}
|
|
505
|
+
>
|
|
506
|
+
<span class="${o.itemIcon}">${ht}</span>
|
|
507
|
+
${t.name}
|
|
508
|
+
</a>
|
|
509
|
+
`;
|
|
510
|
+
}
|
|
511
|
+
function xt(t, e, r) {
|
|
512
|
+
const i = y(t);
|
|
513
|
+
return `
|
|
514
|
+
<a href="${r(i || t.homeUrl)}" target="${t.target}" class="${o.brand}">
|
|
515
|
+
${e(t.title)}
|
|
516
|
+
</a>
|
|
517
|
+
<div class="${o.subtitle}">${e(t.subtitle)}</div>
|
|
518
|
+
`;
|
|
519
|
+
}
|
|
520
|
+
function vt(t, e, r) {
|
|
521
|
+
const i = y(t), n = E(i, t.logoutPath);
|
|
522
|
+
return `
|
|
523
|
+
<div class="${o.footer}">
|
|
524
|
+
<a href="${r(n)}" target="${t.target}" class="${o.logout}">
|
|
525
|
+
<span class="${o.itemIcon}">${pt}</span>
|
|
526
|
+
${e(t.logoutText)}
|
|
527
|
+
</a>
|
|
528
|
+
</div>
|
|
529
|
+
`;
|
|
530
|
+
}
|
|
531
|
+
function mt(t, e) {
|
|
532
|
+
const r = e.error;
|
|
533
|
+
return t.loading ? `<div id="sidebar-loader" class="${o.loaderWrap}" aria-label="Loading navigation"><span class="${o.loaderSpinner}" aria-hidden="true"></span></div>` : r ? `<div class="${o.error}">${r}</div>` : t.menu.length ? t.menu.map((i) => I(i, t, e)).join("") : `<div class="${o.state}"></div>`;
|
|
534
|
+
}
|
|
535
|
+
function m(t) {
|
|
536
|
+
return String(t || "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
537
|
+
}
|
|
538
|
+
function C(t) {
|
|
539
|
+
return m(t).replace(/"/g, """);
|
|
540
|
+
}
|
|
541
|
+
function T(t, e) {
|
|
542
|
+
for (const r of e) {
|
|
543
|
+
if (String(r.id) === t) return r;
|
|
544
|
+
if (r.children?.length) {
|
|
545
|
+
const i = T(t, r.children);
|
|
546
|
+
if (i) return i;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
function wt(t, e) {
|
|
552
|
+
const r = String(t || "").trim();
|
|
553
|
+
if (!(!r || r === "#")) {
|
|
554
|
+
if (e === "_blank") {
|
|
555
|
+
window.open(r, "_blank", "noopener,noreferrer");
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
if (e === "_top")
|
|
559
|
+
try {
|
|
560
|
+
if (window.top) {
|
|
561
|
+
window.top.location.href = r;
|
|
562
|
+
return;
|
|
563
|
+
}
|
|
564
|
+
} catch {
|
|
565
|
+
window.location.href = r;
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
window.location.href = r;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
class yt extends HTMLElement {
|
|
572
|
+
static observedAttributes = [
|
|
573
|
+
"token",
|
|
574
|
+
"api-url",
|
|
575
|
+
"base-url",
|
|
576
|
+
"active-path",
|
|
577
|
+
"target",
|
|
578
|
+
"use-shadow-dom",
|
|
579
|
+
"aria-label",
|
|
580
|
+
"collapsed",
|
|
581
|
+
"auto-navigate",
|
|
582
|
+
"width",
|
|
583
|
+
"title",
|
|
584
|
+
"subtitle",
|
|
585
|
+
"home-url",
|
|
586
|
+
"logout-text",
|
|
587
|
+
"logout-path",
|
|
588
|
+
"error"
|
|
589
|
+
];
|
|
590
|
+
config = R({});
|
|
591
|
+
state = Z();
|
|
592
|
+
renderRoot = null;
|
|
593
|
+
abortController = null;
|
|
594
|
+
refreshSequence = 0;
|
|
595
|
+
get token() {
|
|
596
|
+
return this.config.token;
|
|
597
|
+
}
|
|
598
|
+
set token(e) {
|
|
599
|
+
this.setConfig({ token: e });
|
|
600
|
+
}
|
|
601
|
+
get apiUrl() {
|
|
602
|
+
return this.config.apiUrl;
|
|
603
|
+
}
|
|
604
|
+
set apiUrl(e) {
|
|
605
|
+
this.setConfig({ apiUrl: e });
|
|
606
|
+
}
|
|
607
|
+
get activePath() {
|
|
608
|
+
return this.config.activePath;
|
|
609
|
+
}
|
|
610
|
+
set activePath(e) {
|
|
611
|
+
this.setActivePath(e);
|
|
612
|
+
}
|
|
613
|
+
get target() {
|
|
614
|
+
return this.config.target;
|
|
615
|
+
}
|
|
616
|
+
set target(e) {
|
|
617
|
+
this.setConfig({ target: e });
|
|
618
|
+
}
|
|
619
|
+
get useShadowDom() {
|
|
620
|
+
return this.config.useShadowDom;
|
|
621
|
+
}
|
|
622
|
+
set useShadowDom(e) {
|
|
623
|
+
this.setConfig({ useShadowDom: e });
|
|
624
|
+
}
|
|
625
|
+
get ariaLabel() {
|
|
626
|
+
return this.config.ariaLabel;
|
|
627
|
+
}
|
|
628
|
+
set ariaLabel(e) {
|
|
629
|
+
this.setConfig({ ariaLabel: e });
|
|
630
|
+
}
|
|
631
|
+
get collapsed() {
|
|
632
|
+
return this.config.collapsed;
|
|
633
|
+
}
|
|
634
|
+
set collapsed(e) {
|
|
635
|
+
this.setConfig({ collapsed: e });
|
|
636
|
+
}
|
|
637
|
+
get autoNavigate() {
|
|
638
|
+
return this.config.autoNavigate;
|
|
639
|
+
}
|
|
640
|
+
set autoNavigate(e) {
|
|
641
|
+
this.setConfig({ autoNavigate: e });
|
|
642
|
+
}
|
|
643
|
+
get width() {
|
|
644
|
+
return this.config.width;
|
|
645
|
+
}
|
|
646
|
+
set width(e) {
|
|
647
|
+
this.setConfig({ width: e });
|
|
648
|
+
}
|
|
649
|
+
get title() {
|
|
650
|
+
return this.config.title;
|
|
651
|
+
}
|
|
652
|
+
set title(e) {
|
|
653
|
+
this.setConfig({ title: e });
|
|
654
|
+
}
|
|
655
|
+
get subtitle() {
|
|
656
|
+
return this.config.subtitle;
|
|
657
|
+
}
|
|
658
|
+
set subtitle(e) {
|
|
659
|
+
this.setConfig({ subtitle: e });
|
|
660
|
+
}
|
|
661
|
+
get homeUrl() {
|
|
662
|
+
return this.config.homeUrl;
|
|
663
|
+
}
|
|
664
|
+
set homeUrl(e) {
|
|
665
|
+
this.setConfig({ homeUrl: e });
|
|
666
|
+
}
|
|
667
|
+
get logoutText() {
|
|
668
|
+
return this.config.logoutText;
|
|
669
|
+
}
|
|
670
|
+
set logoutText(e) {
|
|
671
|
+
this.setConfig({ logoutText: e });
|
|
672
|
+
}
|
|
673
|
+
get logoutPath() {
|
|
674
|
+
return this.config.logoutPath;
|
|
675
|
+
}
|
|
676
|
+
set logoutPath(e) {
|
|
677
|
+
this.setConfig({ logoutPath: e });
|
|
678
|
+
}
|
|
679
|
+
get error() {
|
|
680
|
+
return this.config.error;
|
|
681
|
+
}
|
|
682
|
+
set error(e) {
|
|
683
|
+
this.setConfig({ error: e });
|
|
684
|
+
}
|
|
685
|
+
connectedCallback() {
|
|
686
|
+
this.syncConfigFromHost(), this.ensureRenderRoot(), this.render(), this.refresh().catch(() => {
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
disconnectedCallback() {
|
|
690
|
+
this.abortController && this.abortController.abort();
|
|
691
|
+
}
|
|
692
|
+
attributeChangedCallback(e, r, i) {
|
|
693
|
+
if (r === i) return;
|
|
694
|
+
const n = this.config.useShadowDom;
|
|
695
|
+
if (this.syncConfigFromHost(), e === "use-shadow-dom" ? this.ensureRenderRoot() : n !== this.config.useShadowDom && this.ensureRenderRoot(), e === "token" || e === "api-url") {
|
|
696
|
+
this.render(), this.refresh().catch(() => {
|
|
697
|
+
});
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
this.rerenderWithMatchState();
|
|
701
|
+
}
|
|
702
|
+
async refresh() {
|
|
703
|
+
const e = ++this.refreshSequence;
|
|
704
|
+
this.prepareRefresh();
|
|
705
|
+
const r = this.resetAbortController();
|
|
706
|
+
try {
|
|
707
|
+
if (this.isRefreshStale(e, r)) return;
|
|
708
|
+
const i = await L(this.config, r);
|
|
709
|
+
if (this.isRefreshStale(e, r)) return;
|
|
710
|
+
this.finishRefreshSuccess(i), W(this, { menu: i });
|
|
711
|
+
} catch (i) {
|
|
712
|
+
if (this.shouldIgnoreRefreshError(e, i)) return;
|
|
713
|
+
const n = i instanceof Error ? i.message : "Failed to load menu";
|
|
714
|
+
this.finishRefreshFailure(n), j(this, { message: n });
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
setActivePath(e) {
|
|
718
|
+
this.updateConfigAndRender({ activePath: e });
|
|
719
|
+
}
|
|
720
|
+
setConfig(e) {
|
|
721
|
+
this.updateConfigAndRender(e);
|
|
722
|
+
}
|
|
723
|
+
updateConfigAndRender(e) {
|
|
724
|
+
const r = this.config.useShadowDom;
|
|
725
|
+
this.config = nt(this.config, e), r !== this.config.useShadowDom && this.ensureRenderRoot(), this.rerenderWithMatchState();
|
|
726
|
+
}
|
|
727
|
+
rerenderWithMatchState() {
|
|
728
|
+
this.applyMatchState(), this.render();
|
|
729
|
+
}
|
|
730
|
+
syncConfigFromHost() {
|
|
731
|
+
this.config = it(this.config, this);
|
|
732
|
+
}
|
|
733
|
+
prepareRefresh() {
|
|
734
|
+
st(this.state), this.render();
|
|
735
|
+
}
|
|
736
|
+
resetAbortController() {
|
|
737
|
+
return this.abortController = lt(this.abortController), this.abortController.signal;
|
|
738
|
+
}
|
|
739
|
+
isRefreshStale(e, r) {
|
|
740
|
+
return ut(e, this.refreshSequence, r);
|
|
741
|
+
}
|
|
742
|
+
shouldIgnoreRefreshError(e, r) {
|
|
743
|
+
return ct(e, this.refreshSequence, r);
|
|
744
|
+
}
|
|
745
|
+
finishRefreshSuccess(e) {
|
|
746
|
+
ft(this.state, e), this.rerenderWithMatchState();
|
|
747
|
+
}
|
|
748
|
+
finishRefreshFailure(e) {
|
|
749
|
+
dt(this.state, e), this.render();
|
|
750
|
+
}
|
|
751
|
+
ensureRenderRoot() {
|
|
752
|
+
if (this.config.useShadowDom) {
|
|
753
|
+
this.renderRoot = this.shadowRoot ?? this.attachShadow({ mode: "open" });
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
756
|
+
this.renderRoot = this;
|
|
757
|
+
}
|
|
758
|
+
applyMatchState() {
|
|
759
|
+
at(this.state, this.config);
|
|
760
|
+
}
|
|
761
|
+
render() {
|
|
762
|
+
this.renderRoot && (this.applyHostWidthStyles(), this.renderShell(), this.bindEvents(), this.ensureActiveItemInView());
|
|
763
|
+
}
|
|
764
|
+
applyHostWidthStyles() {
|
|
765
|
+
this.style.setProperty("width", this.config.width), this.style.setProperty("min-width", this.config.width), this.style.setProperty("--prism-sidebar-width", this.config.width);
|
|
766
|
+
}
|
|
767
|
+
renderShell() {
|
|
768
|
+
if (!this.renderRoot) return;
|
|
769
|
+
const e = _(this.config.ariaLabel), r = `
|
|
770
|
+
<style>${J}</style>
|
|
771
|
+
<aside class="${o.sidebar}" style="--prism-sidebar-width: ${this.config.width};">
|
|
772
|
+
${xt(this.config, m, C)}
|
|
773
|
+
<nav class="${o.nav}" role="${e.role}" aria-label="${e["aria-label"]}">
|
|
774
|
+
${mt(this.state, this.config)}
|
|
775
|
+
</nav>
|
|
776
|
+
${vt(this.config, m, C)}
|
|
777
|
+
</aside>
|
|
778
|
+
`;
|
|
779
|
+
this.renderRoot.innerHTML = r;
|
|
780
|
+
}
|
|
781
|
+
ensureActiveItemInView() {
|
|
782
|
+
if (!this.renderRoot || !this.state.activeId) return;
|
|
783
|
+
const e = this.renderRoot.querySelector('[data-action="navigate"][aria-current="page"]');
|
|
784
|
+
e && e.scrollIntoView({ block: "nearest" });
|
|
785
|
+
}
|
|
786
|
+
bindEvents() {
|
|
787
|
+
this.renderRoot && K(this.renderRoot, (e) => this.handleAction(e));
|
|
788
|
+
}
|
|
789
|
+
handleAction(e) {
|
|
790
|
+
Q(e, {
|
|
791
|
+
homeUrl: this.config.homeUrl,
|
|
792
|
+
logoutPath: this.config.logoutPath,
|
|
793
|
+
onStaticNavigation: (r) => this.handleStaticNavigation(r),
|
|
794
|
+
onToggle: (r) => this.handleToggleAction(r),
|
|
795
|
+
onNavigate: (r) => this.handleNavigateAction(r)
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
handleToggleAction(e) {
|
|
799
|
+
tt(this.state.expandedIds, e), this.render();
|
|
800
|
+
}
|
|
801
|
+
handleNavigateAction(e) {
|
|
802
|
+
const r = T(e, this.state.menu);
|
|
803
|
+
!r || !r.path || (this.state.activeId = e, this.render(), q(this, {
|
|
804
|
+
item: r,
|
|
805
|
+
resolvedPath: r.path,
|
|
806
|
+
target: this.config.target
|
|
807
|
+
}), G(r.path, this.config));
|
|
808
|
+
}
|
|
809
|
+
handleStaticNavigation(e) {
|
|
810
|
+
wt(e, this.config.target);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
const z = "prism-sidebar";
|
|
814
|
+
function kt() {
|
|
815
|
+
customElements.get(z) || customElements.define(z, yt);
|
|
816
|
+
}
|
|
817
|
+
export {
|
|
818
|
+
z as PRISM_SIDEBAR_TAG_NAME,
|
|
819
|
+
yt as PrismSidebarElement,
|
|
820
|
+
kt as registerPrismSidebar
|
|
821
|
+
};
|
|
822
|
+
//# sourceMappingURL=prism-sidebar.js.map
|