@kopexa/sidebar 17.2.1 → 17.3.0
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/{chunk-YW3JMPRU.mjs → chunk-5VE25P3M.mjs} +61 -21
- package/dist/{chunk-LCCZNS2E.mjs → chunk-6H2EH7LL.mjs} +3 -3
- package/dist/chunk-BFZFZSUC.mjs +27 -0
- package/dist/{chunk-KLYPP6QE.mjs → chunk-G2J7EJQ6.mjs} +24 -15
- package/dist/{chunk-YVQVW5EP.mjs → chunk-WIP5GNGJ.mjs} +1 -1
- package/dist/{chunk-AIRHHM7Z.mjs → chunk-XBTONQ3L.mjs} +5 -1
- package/dist/index.js +88 -35
- package/dist/index.mjs +6 -6
- package/dist/v2/app-shell.mjs +3 -2
- package/dist/v2/components.d.mts +7 -1
- package/dist/v2/components.d.ts +7 -1
- package/dist/v2/components.js +69 -21
- package/dist/v2/components.mjs +3 -3
- package/dist/v2/context.js +16 -1
- package/dist/v2/context.mjs +2 -1
- package/dist/v2/from-config.js +85 -30
- package/dist/v2/from-config.mjs +4 -4
- package/dist/v2/index.js +88 -35
- package/dist/v2/index.mjs +6 -6
- package/dist/v2/types.d.mts +20 -1
- package/dist/v2/types.d.ts +20 -1
- package/dist/v2/types.js +17 -2
- package/dist/v2/types.mjs +7 -3
- package/package.json +11 -11
- package/dist/chunk-SDMGFB6V.mjs +0 -14
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
panelItemHasChildren,
|
|
4
|
-
panelItemIsSection
|
|
5
|
-
} from "./chunk-SDMGFB6V.mjs";
|
|
6
2
|
import {
|
|
7
3
|
useSidebarV2
|
|
8
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XBTONQ3L.mjs";
|
|
5
|
+
import {
|
|
6
|
+
normalizePath,
|
|
7
|
+
panelItemHasChildren,
|
|
8
|
+
panelItemIsSection,
|
|
9
|
+
pathMatchLength
|
|
10
|
+
} from "./chunk-BFZFZSUC.mjs";
|
|
9
11
|
|
|
10
12
|
// src/v2/components.tsx
|
|
11
13
|
import { IconButton } from "@kopexa/button";
|
|
@@ -17,7 +19,10 @@ import {
|
|
|
17
19
|
import { cn } from "@kopexa/shared-utils";
|
|
18
20
|
import { sidebarMenuButton } from "@kopexa/theme";
|
|
19
21
|
import { Tooltip } from "@kopexa/tooltip";
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
forwardRef,
|
|
24
|
+
useMemo
|
|
25
|
+
} from "react";
|
|
21
26
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
22
27
|
function SidebarV2Inset({
|
|
23
28
|
className,
|
|
@@ -222,31 +227,34 @@ function SidebarV2PanelLeaf({
|
|
|
222
227
|
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
223
228
|
Icon && /* @__PURE__ */ jsx(Icon, { className: styles.panelLeafIcon() }),
|
|
224
229
|
/* @__PURE__ */ jsx("span", { className: styles.panelLeafLabel(), children: item.label }),
|
|
230
|
+
item.tag && /* @__PURE__ */ jsx("span", { className: styles.panelLeafTag(), children: item.tag }),
|
|
225
231
|
item.badge != null && /* @__PURE__ */ jsx("span", { className: styles.panelLeafBadge(), children: item.badge })
|
|
226
232
|
] })
|
|
227
233
|
}) });
|
|
228
234
|
}
|
|
229
235
|
function SidebarV2PanelGroup({
|
|
230
|
-
item
|
|
236
|
+
item,
|
|
237
|
+
winningHref
|
|
231
238
|
}) {
|
|
232
239
|
var _a;
|
|
233
240
|
const { openGroup, toggleGroup, activeHref, renderLink, tone, styles } = useSidebarV2();
|
|
234
241
|
const light = tone === "light";
|
|
235
242
|
const Icon = item.icon;
|
|
236
243
|
const key = (_a = item.value) != null ? _a : item.label;
|
|
237
|
-
let
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
let winner = winningHref;
|
|
245
|
+
if (winner === void 0) {
|
|
246
|
+
const current = normalizePath(activeHref);
|
|
247
|
+
let len = -1;
|
|
248
|
+
winner = null;
|
|
249
|
+
for (const c of item.children) {
|
|
250
|
+
const l = pathMatchLength(current, c.href);
|
|
251
|
+
if (l > len) {
|
|
252
|
+
len = l;
|
|
253
|
+
winner = normalizePath(c.href);
|
|
254
|
+
}
|
|
247
255
|
}
|
|
248
256
|
}
|
|
249
|
-
const containsActive =
|
|
257
|
+
const containsActive = winner != null && item.children.some((c) => normalizePath(c.href) === winner);
|
|
250
258
|
const open = openGroup === key || openGroup === null && containsActive;
|
|
251
259
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
252
260
|
/* @__PURE__ */ jsxs(
|
|
@@ -269,7 +277,7 @@ function SidebarV2PanelGroup({
|
|
|
269
277
|
}
|
|
270
278
|
),
|
|
271
279
|
open && /* @__PURE__ */ jsx("div", { className: styles.panelTree(), children: item.children.map((child) => {
|
|
272
|
-
const active = child.href ===
|
|
280
|
+
const active = normalizePath(child.href) === winner;
|
|
273
281
|
return /* @__PURE__ */ jsx("span", { children: renderLink({
|
|
274
282
|
href: child.href,
|
|
275
283
|
"data-active": active,
|
|
@@ -283,15 +291,47 @@ function SidebarV2PanelGroup({
|
|
|
283
291
|
function SidebarV2PanelItems({
|
|
284
292
|
items
|
|
285
293
|
}) {
|
|
294
|
+
const { activeHref } = useSidebarV2();
|
|
295
|
+
const winningHref = useMemo(() => {
|
|
296
|
+
const current = normalizePath(activeHref);
|
|
297
|
+
let href = null;
|
|
298
|
+
let len = -1;
|
|
299
|
+
for (const item of items) {
|
|
300
|
+
if (panelItemIsSection(item)) continue;
|
|
301
|
+
const hrefs = panelItemHasChildren(item) ? item.children.map((c) => c.href) : [item.href];
|
|
302
|
+
for (const h of hrefs) {
|
|
303
|
+
const l = pathMatchLength(current, h);
|
|
304
|
+
if (l > len) {
|
|
305
|
+
len = l;
|
|
306
|
+
href = normalizePath(h);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return href;
|
|
311
|
+
}, [items, activeHref]);
|
|
286
312
|
return /* @__PURE__ */ jsx(Fragment, { children: items.map((item, idx) => {
|
|
287
313
|
var _a;
|
|
288
314
|
if (panelItemIsSection(item)) {
|
|
289
315
|
return /* @__PURE__ */ jsx(SidebarV2PanelLabel, { children: item.section }, `section-${item.section}-${idx}`);
|
|
290
316
|
}
|
|
291
317
|
if (panelItemHasChildren(item)) {
|
|
292
|
-
return /* @__PURE__ */ jsx(
|
|
318
|
+
return /* @__PURE__ */ jsx(
|
|
319
|
+
SidebarV2PanelGroup,
|
|
320
|
+
{
|
|
321
|
+
item,
|
|
322
|
+
winningHref
|
|
323
|
+
},
|
|
324
|
+
(_a = item.value) != null ? _a : item.label
|
|
325
|
+
);
|
|
293
326
|
}
|
|
294
|
-
return /* @__PURE__ */ jsx(
|
|
327
|
+
return /* @__PURE__ */ jsx(
|
|
328
|
+
SidebarV2PanelLeaf,
|
|
329
|
+
{
|
|
330
|
+
item,
|
|
331
|
+
active: winningHref != null && normalizePath(item.href) === winningHref
|
|
332
|
+
},
|
|
333
|
+
item.href
|
|
334
|
+
);
|
|
295
335
|
}) });
|
|
296
336
|
}
|
|
297
337
|
function SidebarV2Trigger({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
SidebarV2FromConfig
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-G2J7EJQ6.mjs";
|
|
5
5
|
import {
|
|
6
6
|
SidebarV2Inset,
|
|
7
7
|
SidebarV2Panel,
|
|
@@ -15,10 +15,10 @@ import {
|
|
|
15
15
|
SidebarV2RailSpacer,
|
|
16
16
|
SidebarV2Trigger,
|
|
17
17
|
SidebarV2Workspace
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-5VE25P3M.mjs";
|
|
19
19
|
import {
|
|
20
20
|
SidebarV2Provider
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-XBTONQ3L.mjs";
|
|
22
22
|
|
|
23
23
|
// src/v2/index.tsx
|
|
24
24
|
var SidebarV2 = SidebarV2Provider;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/v2/types.ts
|
|
4
|
+
function normalizePath(href) {
|
|
5
|
+
const path = href.split("#")[0].split("?")[0].replace(/\/+$/, "");
|
|
6
|
+
return path === "" ? "/" : path;
|
|
7
|
+
}
|
|
8
|
+
function pathMatchLength(currentPath, href) {
|
|
9
|
+
const target = normalizePath(href);
|
|
10
|
+
if (currentPath === target) return target.length;
|
|
11
|
+
if (target !== "/" && currentPath.startsWith(`${target}/`))
|
|
12
|
+
return target.length;
|
|
13
|
+
return -1;
|
|
14
|
+
}
|
|
15
|
+
function panelItemHasChildren(item) {
|
|
16
|
+
return "children" in item && Array.isArray(item.children);
|
|
17
|
+
}
|
|
18
|
+
function panelItemIsSection(item) {
|
|
19
|
+
return "section" in item;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
normalizePath,
|
|
24
|
+
pathMatchLength,
|
|
25
|
+
panelItemHasChildren,
|
|
26
|
+
panelItemIsSection
|
|
27
|
+
};
|
|
@@ -5,14 +5,16 @@ import {
|
|
|
5
5
|
SidebarV2Rail,
|
|
6
6
|
SidebarV2RailItem,
|
|
7
7
|
SidebarV2RailLink
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
panelItemHasChildren,
|
|
11
|
-
panelItemIsSection
|
|
12
|
-
} from "./chunk-SDMGFB6V.mjs";
|
|
8
|
+
} from "./chunk-5VE25P3M.mjs";
|
|
13
9
|
import {
|
|
14
10
|
useSidebarV2
|
|
15
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-XBTONQ3L.mjs";
|
|
12
|
+
import {
|
|
13
|
+
normalizePath,
|
|
14
|
+
panelItemHasChildren,
|
|
15
|
+
panelItemIsSection,
|
|
16
|
+
pathMatchLength
|
|
17
|
+
} from "./chunk-BFZFZSUC.mjs";
|
|
16
18
|
|
|
17
19
|
// src/v2/from-config.tsx
|
|
18
20
|
import { Drawer } from "@kopexa/drawer";
|
|
@@ -51,7 +53,7 @@ function SidebarV2FromConfig({
|
|
|
51
53
|
closeFlyout,
|
|
52
54
|
selectedRail,
|
|
53
55
|
setSelectedRail,
|
|
54
|
-
|
|
56
|
+
activeHref,
|
|
55
57
|
isMobile,
|
|
56
58
|
drawerOpen,
|
|
57
59
|
setDrawerOpen,
|
|
@@ -97,14 +99,21 @@ function SidebarV2FromConfig({
|
|
|
97
99
|
[items]
|
|
98
100
|
);
|
|
99
101
|
const activeRailValue = useMemo(() => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
102
|
+
var _a2, _b2;
|
|
103
|
+
const current = normalizePath(activeHref);
|
|
104
|
+
let best = null;
|
|
105
|
+
for (const p of panels) {
|
|
106
|
+
for (const item of p.items) {
|
|
107
|
+
if (panelItemIsSection(item)) continue;
|
|
108
|
+
const hrefs = panelItemHasChildren(item) ? item.children.map((c) => c.href) : [item.href];
|
|
109
|
+
for (const href of hrefs) {
|
|
110
|
+
const len = pathMatchLength(current, href);
|
|
111
|
+
if (len > ((_a2 = best == null ? void 0 : best.len) != null ? _a2 : -1)) best = { value: entryValue(p), len };
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return (_b2 = best == null ? void 0 : best.value) != null ? _b2 : null;
|
|
116
|
+
}, [panels, activeHref]);
|
|
108
117
|
const shownValue = pinned ? selectedRail != null ? selectedRail : activeRailValue : flyoutValue;
|
|
109
118
|
const shownPanel = (_a = panels.find((p) => entryValue(p) === shownValue)) != null ? _a : null;
|
|
110
119
|
const topEntries = items.filter((e) => e.slot !== "bottom");
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
normalizePath,
|
|
4
|
+
pathMatchLength
|
|
5
|
+
} from "./chunk-BFZFZSUC.mjs";
|
|
2
6
|
|
|
3
7
|
// src/v2/context.tsx
|
|
4
8
|
import { createContext } from "@kopexa/react-utils";
|
|
@@ -77,7 +81,7 @@ function SidebarV2Provider({
|
|
|
77
81
|
setOpenGroup((curr) => curr === key ? null : key);
|
|
78
82
|
}, []);
|
|
79
83
|
const isActive = useCallback(
|
|
80
|
-
(href) => activeHref
|
|
84
|
+
(href) => pathMatchLength(normalizePath(activeHref), href) >= 0,
|
|
81
85
|
[activeHref]
|
|
82
86
|
);
|
|
83
87
|
const value = useMemo(
|
package/dist/index.js
CHANGED
|
@@ -540,6 +540,27 @@ var import_theme2 = require("@kopexa/theme");
|
|
|
540
540
|
var import_tooltip2 = require("@kopexa/tooltip");
|
|
541
541
|
var import_use_is_mobile2 = require("@kopexa/use-is-mobile");
|
|
542
542
|
var import_react2 = require("react");
|
|
543
|
+
|
|
544
|
+
// src/v2/types.ts
|
|
545
|
+
function normalizePath(href) {
|
|
546
|
+
const path = href.split("#")[0].split("?")[0].replace(/\/+$/, "");
|
|
547
|
+
return path === "" ? "/" : path;
|
|
548
|
+
}
|
|
549
|
+
function pathMatchLength(currentPath, href) {
|
|
550
|
+
const target = normalizePath(href);
|
|
551
|
+
if (currentPath === target) return target.length;
|
|
552
|
+
if (target !== "/" && currentPath.startsWith(`${target}/`))
|
|
553
|
+
return target.length;
|
|
554
|
+
return -1;
|
|
555
|
+
}
|
|
556
|
+
function panelItemHasChildren(item) {
|
|
557
|
+
return "children" in item && Array.isArray(item.children);
|
|
558
|
+
}
|
|
559
|
+
function panelItemIsSection(item) {
|
|
560
|
+
return "section" in item;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// src/v2/context.tsx
|
|
543
564
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
544
565
|
var PIN_COOKIE = "kpx_sidebar_v2_pinned";
|
|
545
566
|
var PIN_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
@@ -606,7 +627,7 @@ function SidebarV2Provider({
|
|
|
606
627
|
setOpenGroup((curr) => curr === key ? null : key);
|
|
607
628
|
}, []);
|
|
608
629
|
const isActive = (0, import_react2.useCallback)(
|
|
609
|
-
(href) => activeHref
|
|
630
|
+
(href) => pathMatchLength(normalizePath(activeHref), href) >= 0,
|
|
610
631
|
[activeHref]
|
|
611
632
|
);
|
|
612
633
|
const value = (0, import_react2.useMemo)(
|
|
@@ -767,16 +788,6 @@ var import_shared_utils = require("@kopexa/shared-utils");
|
|
|
767
788
|
var import_theme3 = require("@kopexa/theme");
|
|
768
789
|
var import_tooltip3 = require("@kopexa/tooltip");
|
|
769
790
|
var import_react4 = require("react");
|
|
770
|
-
|
|
771
|
-
// src/v2/types.ts
|
|
772
|
-
function panelItemHasChildren(item) {
|
|
773
|
-
return "children" in item && Array.isArray(item.children);
|
|
774
|
-
}
|
|
775
|
-
function panelItemIsSection(item) {
|
|
776
|
-
return "section" in item;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
// src/v2/components.tsx
|
|
780
791
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
781
792
|
function SidebarV2Inset({
|
|
782
793
|
className,
|
|
@@ -981,31 +992,34 @@ function SidebarV2PanelLeaf({
|
|
|
981
992
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
982
993
|
Icon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Icon, { className: styles.panelLeafIcon() }),
|
|
983
994
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.panelLeafLabel(), children: item.label }),
|
|
995
|
+
item.tag && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.panelLeafTag(), children: item.tag }),
|
|
984
996
|
item.badge != null && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: styles.panelLeafBadge(), children: item.badge })
|
|
985
997
|
] })
|
|
986
998
|
}) });
|
|
987
999
|
}
|
|
988
1000
|
function SidebarV2PanelGroup({
|
|
989
|
-
item
|
|
1001
|
+
item,
|
|
1002
|
+
winningHref
|
|
990
1003
|
}) {
|
|
991
1004
|
var _a;
|
|
992
1005
|
const { openGroup, toggleGroup, activeHref, renderLink, tone, styles } = useSidebarV2();
|
|
993
1006
|
const light = tone === "light";
|
|
994
1007
|
const Icon = item.icon;
|
|
995
1008
|
const key = (_a = item.value) != null ? _a : item.label;
|
|
996
|
-
let
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1009
|
+
let winner = winningHref;
|
|
1010
|
+
if (winner === void 0) {
|
|
1011
|
+
const current = normalizePath(activeHref);
|
|
1012
|
+
let len = -1;
|
|
1013
|
+
winner = null;
|
|
1014
|
+
for (const c of item.children) {
|
|
1015
|
+
const l = pathMatchLength(current, c.href);
|
|
1016
|
+
if (l > len) {
|
|
1017
|
+
len = l;
|
|
1018
|
+
winner = normalizePath(c.href);
|
|
1019
|
+
}
|
|
1006
1020
|
}
|
|
1007
1021
|
}
|
|
1008
|
-
const containsActive =
|
|
1022
|
+
const containsActive = winner != null && item.children.some((c) => normalizePath(c.href) === winner);
|
|
1009
1023
|
const open = openGroup === key || openGroup === null && containsActive;
|
|
1010
1024
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
|
|
1011
1025
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
@@ -1028,7 +1042,7 @@ function SidebarV2PanelGroup({
|
|
|
1028
1042
|
}
|
|
1029
1043
|
),
|
|
1030
1044
|
open && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: styles.panelTree(), children: item.children.map((child) => {
|
|
1031
|
-
const active = child.href ===
|
|
1045
|
+
const active = normalizePath(child.href) === winner;
|
|
1032
1046
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: renderLink({
|
|
1033
1047
|
href: child.href,
|
|
1034
1048
|
"data-active": active,
|
|
@@ -1042,15 +1056,47 @@ function SidebarV2PanelGroup({
|
|
|
1042
1056
|
function SidebarV2PanelItems({
|
|
1043
1057
|
items
|
|
1044
1058
|
}) {
|
|
1059
|
+
const { activeHref } = useSidebarV2();
|
|
1060
|
+
const winningHref = (0, import_react4.useMemo)(() => {
|
|
1061
|
+
const current = normalizePath(activeHref);
|
|
1062
|
+
let href = null;
|
|
1063
|
+
let len = -1;
|
|
1064
|
+
for (const item of items) {
|
|
1065
|
+
if (panelItemIsSection(item)) continue;
|
|
1066
|
+
const hrefs = panelItemHasChildren(item) ? item.children.map((c) => c.href) : [item.href];
|
|
1067
|
+
for (const h of hrefs) {
|
|
1068
|
+
const l = pathMatchLength(current, h);
|
|
1069
|
+
if (l > len) {
|
|
1070
|
+
len = l;
|
|
1071
|
+
href = normalizePath(h);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
return href;
|
|
1076
|
+
}, [items, activeHref]);
|
|
1045
1077
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: items.map((item, idx) => {
|
|
1046
1078
|
var _a;
|
|
1047
1079
|
if (panelItemIsSection(item)) {
|
|
1048
1080
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SidebarV2PanelLabel, { children: item.section }, `section-${item.section}-${idx}`);
|
|
1049
1081
|
}
|
|
1050
1082
|
if (panelItemHasChildren(item)) {
|
|
1051
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1083
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1084
|
+
SidebarV2PanelGroup,
|
|
1085
|
+
{
|
|
1086
|
+
item,
|
|
1087
|
+
winningHref
|
|
1088
|
+
},
|
|
1089
|
+
(_a = item.value) != null ? _a : item.label
|
|
1090
|
+
);
|
|
1052
1091
|
}
|
|
1053
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1093
|
+
SidebarV2PanelLeaf,
|
|
1094
|
+
{
|
|
1095
|
+
item,
|
|
1096
|
+
active: winningHref != null && normalizePath(item.href) === winningHref
|
|
1097
|
+
},
|
|
1098
|
+
item.href
|
|
1099
|
+
);
|
|
1054
1100
|
}) });
|
|
1055
1101
|
}
|
|
1056
1102
|
function SidebarV2Trigger({
|
|
@@ -1103,7 +1149,7 @@ function SidebarV2FromConfig({
|
|
|
1103
1149
|
closeFlyout,
|
|
1104
1150
|
selectedRail,
|
|
1105
1151
|
setSelectedRail,
|
|
1106
|
-
|
|
1152
|
+
activeHref,
|
|
1107
1153
|
isMobile,
|
|
1108
1154
|
drawerOpen,
|
|
1109
1155
|
setDrawerOpen,
|
|
@@ -1149,14 +1195,21 @@ function SidebarV2FromConfig({
|
|
|
1149
1195
|
[items]
|
|
1150
1196
|
);
|
|
1151
1197
|
const activeRailValue = (0, import_react6.useMemo)(() => {
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1198
|
+
var _a2, _b2;
|
|
1199
|
+
const current = normalizePath(activeHref);
|
|
1200
|
+
let best = null;
|
|
1201
|
+
for (const p of panels) {
|
|
1202
|
+
for (const item of p.items) {
|
|
1203
|
+
if (panelItemIsSection(item)) continue;
|
|
1204
|
+
const hrefs = panelItemHasChildren(item) ? item.children.map((c) => c.href) : [item.href];
|
|
1205
|
+
for (const href of hrefs) {
|
|
1206
|
+
const len = pathMatchLength(current, href);
|
|
1207
|
+
if (len > ((_a2 = best == null ? void 0 : best.len) != null ? _a2 : -1)) best = { value: entryValue(p), len };
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
return (_b2 = best == null ? void 0 : best.value) != null ? _b2 : null;
|
|
1212
|
+
}, [panels, activeHref]);
|
|
1160
1213
|
const shownValue = pinned ? selectedRail != null ? selectedRail : activeRailValue : flyoutValue;
|
|
1161
1214
|
const shownPanel = (_a = panels.find((p) => entryValue(p) === shownValue)) != null ? _a : null;
|
|
1162
1215
|
const topEntries = items.filter((e) => e.slot !== "bottom");
|
package/dist/index.mjs
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./chunk-FPVGSRAX.mjs";
|
|
24
24
|
import {
|
|
25
25
|
SidebarV2
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-6H2EH7LL.mjs";
|
|
27
27
|
import {
|
|
28
28
|
AppShell,
|
|
29
29
|
AppShellAside,
|
|
@@ -31,10 +31,10 @@ import {
|
|
|
31
31
|
AppShellMain,
|
|
32
32
|
AppShellPanelContent,
|
|
33
33
|
AppShellRoot
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-WIP5GNGJ.mjs";
|
|
35
35
|
import {
|
|
36
36
|
SidebarV2FromConfig
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-G2J7EJQ6.mjs";
|
|
38
38
|
import {
|
|
39
39
|
SidebarV2Inset,
|
|
40
40
|
SidebarV2Panel,
|
|
@@ -48,12 +48,12 @@ import {
|
|
|
48
48
|
SidebarV2RailSpacer,
|
|
49
49
|
SidebarV2Trigger,
|
|
50
50
|
SidebarV2Workspace
|
|
51
|
-
} from "./chunk-
|
|
52
|
-
import "./chunk-SDMGFB6V.mjs";
|
|
51
|
+
} from "./chunk-5VE25P3M.mjs";
|
|
53
52
|
import {
|
|
54
53
|
SidebarV2Provider,
|
|
55
54
|
useSidebarV2
|
|
56
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-XBTONQ3L.mjs";
|
|
56
|
+
import "./chunk-BFZFZSUC.mjs";
|
|
57
57
|
export {
|
|
58
58
|
AppShell,
|
|
59
59
|
AppShellAside,
|
package/dist/v2/app-shell.mjs
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
AppShellMain,
|
|
8
8
|
AppShellPanelContent,
|
|
9
9
|
AppShellRoot
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import "../chunk-
|
|
10
|
+
} from "../chunk-WIP5GNGJ.mjs";
|
|
11
|
+
import "../chunk-XBTONQ3L.mjs";
|
|
12
|
+
import "../chunk-BFZFZSUC.mjs";
|
|
12
13
|
export {
|
|
13
14
|
AppShell,
|
|
14
15
|
AppShellAside,
|
package/dist/v2/components.d.mts
CHANGED
|
@@ -65,10 +65,16 @@ declare function SidebarV2PanelLeaf({ item, active: activeProp, }: {
|
|
|
65
65
|
/** Override the derived active state (e.g. for custom page routing rules). */
|
|
66
66
|
active?: boolean;
|
|
67
67
|
}): react_jsx_runtime.JSX.Element;
|
|
68
|
-
declare function SidebarV2PanelGroup({ item, }: {
|
|
68
|
+
declare function SidebarV2PanelGroup({ item, winningHref, }: {
|
|
69
69
|
item: Extract<SidebarV2PanelItem, {
|
|
70
70
|
children: unknown;
|
|
71
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Panel-level winning href (most-specific match across all sibling items).
|
|
74
|
+
* Provided by <SidebarV2PanelItems> so a sibling leaf can out-rank our children.
|
|
75
|
+
* Omit for standalone use — then the best child among our own is computed.
|
|
76
|
+
*/
|
|
77
|
+
winningHref?: string | null;
|
|
72
78
|
}): react_jsx_runtime.JSX.Element;
|
|
73
79
|
declare function SidebarV2PanelItems({ items, }: {
|
|
74
80
|
items: SidebarV2PanelItem[];
|
package/dist/v2/components.d.ts
CHANGED
|
@@ -65,10 +65,16 @@ declare function SidebarV2PanelLeaf({ item, active: activeProp, }: {
|
|
|
65
65
|
/** Override the derived active state (e.g. for custom page routing rules). */
|
|
66
66
|
active?: boolean;
|
|
67
67
|
}): react_jsx_runtime.JSX.Element;
|
|
68
|
-
declare function SidebarV2PanelGroup({ item, }: {
|
|
68
|
+
declare function SidebarV2PanelGroup({ item, winningHref, }: {
|
|
69
69
|
item: Extract<SidebarV2PanelItem, {
|
|
70
70
|
children: unknown;
|
|
71
71
|
}>;
|
|
72
|
+
/**
|
|
73
|
+
* Panel-level winning href (most-specific match across all sibling items).
|
|
74
|
+
* Provided by <SidebarV2PanelItems> so a sibling leaf can out-rank our children.
|
|
75
|
+
* Omit for standalone use — then the best child among our own is computed.
|
|
76
|
+
*/
|
|
77
|
+
winningHref?: string | null;
|
|
72
78
|
}): react_jsx_runtime.JSX.Element;
|
|
73
79
|
declare function SidebarV2PanelItems({ items, }: {
|
|
74
80
|
items: SidebarV2PanelItem[];
|