@kopexa/sidebar 17.2.0 → 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-5VE25P3M.mjs +369 -0
- package/dist/{chunk-WA2NSEYE.mjs → chunk-6H2EH7LL.mjs} +3 -3
- package/dist/chunk-BFZFZSUC.mjs +27 -0
- package/dist/{chunk-CMYTESJM.mjs → chunk-G2J7EJQ6.mjs} +33 -26
- package/dist/{chunk-PZFEB2PM.mjs → chunk-WIP5GNGJ.mjs} +9 -15
- package/dist/{chunk-3L2F566G.mjs → chunk-XBTONQ3L.mjs} +9 -1
- package/dist/index.js +170 -250
- package/dist/index.mjs +6 -6
- package/dist/v2/app-shell.js +9 -14
- 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 +128 -208
- package/dist/v2/components.mjs +3 -3
- package/dist/v2/context.d.mts +3 -0
- package/dist/v2/context.d.ts +3 -0
- package/dist/v2/context.js +20 -1
- package/dist/v2/context.mjs +2 -1
- package/dist/v2/from-config.js +151 -219
- package/dist/v2/from-config.mjs +4 -4
- package/dist/v2/index.d.mts +1 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +170 -250
- 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-EIXUCY5M.mjs +0 -458
- package/dist/chunk-SDMGFB6V.mjs +0 -14
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
useSidebarV2
|
|
4
|
+
} from "./chunk-XBTONQ3L.mjs";
|
|
5
|
+
import {
|
|
6
|
+
normalizePath,
|
|
7
|
+
panelItemHasChildren,
|
|
8
|
+
panelItemIsSection,
|
|
9
|
+
pathMatchLength
|
|
10
|
+
} from "./chunk-BFZFZSUC.mjs";
|
|
11
|
+
|
|
12
|
+
// src/v2/components.tsx
|
|
13
|
+
import { IconButton } from "@kopexa/button";
|
|
14
|
+
import {
|
|
15
|
+
ChevronDownIcon,
|
|
16
|
+
ChevronRightIcon,
|
|
17
|
+
PanelLeftIcon
|
|
18
|
+
} from "@kopexa/icons";
|
|
19
|
+
import { cn } from "@kopexa/shared-utils";
|
|
20
|
+
import { sidebarMenuButton } from "@kopexa/theme";
|
|
21
|
+
import { Tooltip } from "@kopexa/tooltip";
|
|
22
|
+
import {
|
|
23
|
+
forwardRef,
|
|
24
|
+
useMemo
|
|
25
|
+
} from "react";
|
|
26
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
27
|
+
function SidebarV2Inset({
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}) {
|
|
31
|
+
const { styles } = useSidebarV2();
|
|
32
|
+
return /* @__PURE__ */ jsx(
|
|
33
|
+
"main",
|
|
34
|
+
{
|
|
35
|
+
"data-slot": "sidebar-v2-inset",
|
|
36
|
+
className: styles.inset({ className }),
|
|
37
|
+
...props
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function SidebarV2Rail({ className, ...props }) {
|
|
42
|
+
const { styles } = useSidebarV2();
|
|
43
|
+
return /* @__PURE__ */ jsx(
|
|
44
|
+
"nav",
|
|
45
|
+
{
|
|
46
|
+
"data-slot": "sidebar-v2-rail",
|
|
47
|
+
className: styles.rail({ className }),
|
|
48
|
+
...props
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
function SidebarV2RailSpacer() {
|
|
53
|
+
return /* @__PURE__ */ jsx("div", { "aria-hidden": true, className: "flex-1" });
|
|
54
|
+
}
|
|
55
|
+
var SidebarV2Workspace = forwardRef(({ name, role, logo, className, appearance = "rail", ...props }, ref) => {
|
|
56
|
+
const { styles } = useSidebarV2();
|
|
57
|
+
if (appearance === "bar") {
|
|
58
|
+
return /* @__PURE__ */ jsxs(
|
|
59
|
+
"button",
|
|
60
|
+
{
|
|
61
|
+
ref,
|
|
62
|
+
type: "button",
|
|
63
|
+
"data-slot": "sidebar-v2-workspace",
|
|
64
|
+
"aria-label": role ? `${name} \u2013 ${role}` : name,
|
|
65
|
+
className: styles.workspaceBar({ className }),
|
|
66
|
+
...props,
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsx("span", { className: styles.workspaceBarLogo(), children: logo != null ? logo : name.charAt(0).toUpperCase() }),
|
|
69
|
+
/* @__PURE__ */ jsxs("span", { className: styles.workspaceBarText(), children: [
|
|
70
|
+
/* @__PURE__ */ jsx("span", { className: styles.workspaceBarName(), children: name }),
|
|
71
|
+
role && /* @__PURE__ */ jsx("span", { className: styles.workspaceBarRole(), children: role })
|
|
72
|
+
] }),
|
|
73
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: styles.workspaceBarChevron() })
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ jsx(
|
|
79
|
+
"button",
|
|
80
|
+
{
|
|
81
|
+
ref,
|
|
82
|
+
type: "button",
|
|
83
|
+
"data-slot": "sidebar-v2-workspace",
|
|
84
|
+
"aria-label": role ? `${name} \u2013 ${role}` : name,
|
|
85
|
+
className: styles.workspaceRail({ className }),
|
|
86
|
+
...props,
|
|
87
|
+
children: /* @__PURE__ */ jsxs("span", { className: styles.workspaceRailLogo(), children: [
|
|
88
|
+
logo != null ? logo : name.charAt(0).toUpperCase(),
|
|
89
|
+
/* @__PURE__ */ jsx(ChevronDownIcon, { className: styles.workspaceRailChevron() })
|
|
90
|
+
] })
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
SidebarV2Workspace.displayName = "SidebarV2Workspace";
|
|
95
|
+
function RailInner({
|
|
96
|
+
icon: Icon,
|
|
97
|
+
badge
|
|
98
|
+
}) {
|
|
99
|
+
const { styles } = useSidebarV2();
|
|
100
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
101
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, className: styles.railIndicator() }),
|
|
102
|
+
/* @__PURE__ */ jsx(Icon, { className: styles.railIcon() }),
|
|
103
|
+
badge != null && /* @__PURE__ */ jsx("span", { className: styles.railBadge(), children: badge })
|
|
104
|
+
] });
|
|
105
|
+
}
|
|
106
|
+
function SidebarV2RailLink({
|
|
107
|
+
icon,
|
|
108
|
+
label,
|
|
109
|
+
href,
|
|
110
|
+
badge
|
|
111
|
+
}) {
|
|
112
|
+
const { renderLink, isActive, resetPanelSelection, styles } = useSidebarV2();
|
|
113
|
+
const active = isActive(href);
|
|
114
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, side: "right", children: renderLink({
|
|
115
|
+
href,
|
|
116
|
+
className: styles.railButton(),
|
|
117
|
+
"data-active": active,
|
|
118
|
+
"aria-current": active ? "page" : void 0,
|
|
119
|
+
"aria-label": label,
|
|
120
|
+
// Navigating to a destination link clears any open panel preview,
|
|
121
|
+
// even when the route doesn't change (e.g. already on it).
|
|
122
|
+
onClick: resetPanelSelection,
|
|
123
|
+
children: /* @__PURE__ */ jsx(RailInner, { icon, badge })
|
|
124
|
+
}) });
|
|
125
|
+
}
|
|
126
|
+
function SidebarV2RailItem({
|
|
127
|
+
icon,
|
|
128
|
+
label,
|
|
129
|
+
active,
|
|
130
|
+
hasPanel,
|
|
131
|
+
onClick,
|
|
132
|
+
onMouseEnter,
|
|
133
|
+
onMouseLeave,
|
|
134
|
+
badge
|
|
135
|
+
}) {
|
|
136
|
+
const { styles } = useSidebarV2();
|
|
137
|
+
return /* @__PURE__ */ jsx(Tooltip, { content: label, side: "right", children: /* @__PURE__ */ jsx(
|
|
138
|
+
"button",
|
|
139
|
+
{
|
|
140
|
+
type: "button",
|
|
141
|
+
"data-active": active,
|
|
142
|
+
"aria-label": label,
|
|
143
|
+
"aria-expanded": hasPanel ? active : void 0,
|
|
144
|
+
onClick,
|
|
145
|
+
onMouseEnter,
|
|
146
|
+
onMouseLeave,
|
|
147
|
+
className: styles.railButton(),
|
|
148
|
+
children: /* @__PURE__ */ jsx(RailInner, { icon, badge })
|
|
149
|
+
}
|
|
150
|
+
) });
|
|
151
|
+
}
|
|
152
|
+
function SidebarV2Panel({
|
|
153
|
+
title,
|
|
154
|
+
subtitle,
|
|
155
|
+
floating,
|
|
156
|
+
hidePin,
|
|
157
|
+
action,
|
|
158
|
+
children,
|
|
159
|
+
className
|
|
160
|
+
}) {
|
|
161
|
+
const { togglePin, pinned, styles } = useSidebarV2();
|
|
162
|
+
return /* @__PURE__ */ jsxs(
|
|
163
|
+
"div",
|
|
164
|
+
{
|
|
165
|
+
"data-slot": "sidebar-v2-panel",
|
|
166
|
+
"data-floating": floating ? "true" : "false",
|
|
167
|
+
className: styles.panel({ className }),
|
|
168
|
+
children: [
|
|
169
|
+
/* @__PURE__ */ jsxs("div", { className: styles.panelHeader(), children: [
|
|
170
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
171
|
+
title && /* @__PURE__ */ jsx("div", { className: styles.panelTitle(), children: title }),
|
|
172
|
+
subtitle && /* @__PURE__ */ jsx("div", { className: styles.panelSubtitle(), children: subtitle })
|
|
173
|
+
] }),
|
|
174
|
+
action != null ? action : !hidePin && /* @__PURE__ */ jsx(
|
|
175
|
+
Tooltip,
|
|
176
|
+
{
|
|
177
|
+
content: pinned ? "Panel l\xF6sen" : "Panel anheften",
|
|
178
|
+
side: "bottom",
|
|
179
|
+
children: /* @__PURE__ */ jsx(
|
|
180
|
+
IconButton,
|
|
181
|
+
{
|
|
182
|
+
variant: "ghost",
|
|
183
|
+
size: "sm",
|
|
184
|
+
"aria-label": pinned ? "Panel l\xF6sen" : "Panel anheften",
|
|
185
|
+
onClick: togglePin,
|
|
186
|
+
className: styles.panelPin(),
|
|
187
|
+
children: /* @__PURE__ */ jsx(PanelLeftIcon, { className: "size-4" })
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }),
|
|
193
|
+
/* @__PURE__ */ jsx("div", { className: styles.panelBody(), children })
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
function SidebarV2PanelLabel({
|
|
199
|
+
className,
|
|
200
|
+
...props
|
|
201
|
+
}) {
|
|
202
|
+
const { styles } = useSidebarV2();
|
|
203
|
+
return /* @__PURE__ */ jsx(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
"data-slot": "sidebar-v2-panel-label",
|
|
207
|
+
className: styles.panelLabel({ className }),
|
|
208
|
+
...props
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
function SidebarV2PanelLeaf({
|
|
213
|
+
item,
|
|
214
|
+
active: activeProp
|
|
215
|
+
}) {
|
|
216
|
+
const { renderLink, isActive, tone, styles } = useSidebarV2();
|
|
217
|
+
const light = tone === "light";
|
|
218
|
+
const Icon = item.icon;
|
|
219
|
+
const active = activeProp != null ? activeProp : isActive(item.href);
|
|
220
|
+
return /* @__PURE__ */ jsx(Fragment, { children: renderLink({
|
|
221
|
+
href: item.href,
|
|
222
|
+
"data-active": active,
|
|
223
|
+
"aria-current": active ? "page" : void 0,
|
|
224
|
+
// Light tone uses the recipe's leaf slot (group/leaf + data-active);
|
|
225
|
+
// dark tone reuses the existing sidebarMenuButton recipe.
|
|
226
|
+
className: light ? styles.panelLeaf() : sidebarMenuButton({ size: "md" }),
|
|
227
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
228
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: styles.panelLeafIcon() }),
|
|
229
|
+
/* @__PURE__ */ jsx("span", { className: styles.panelLeafLabel(), children: item.label }),
|
|
230
|
+
item.tag && /* @__PURE__ */ jsx("span", { className: styles.panelLeafTag(), children: item.tag }),
|
|
231
|
+
item.badge != null && /* @__PURE__ */ jsx("span", { className: styles.panelLeafBadge(), children: item.badge })
|
|
232
|
+
] })
|
|
233
|
+
}) });
|
|
234
|
+
}
|
|
235
|
+
function SidebarV2PanelGroup({
|
|
236
|
+
item,
|
|
237
|
+
winningHref
|
|
238
|
+
}) {
|
|
239
|
+
var _a;
|
|
240
|
+
const { openGroup, toggleGroup, activeHref, renderLink, tone, styles } = useSidebarV2();
|
|
241
|
+
const light = tone === "light";
|
|
242
|
+
const Icon = item.icon;
|
|
243
|
+
const key = (_a = item.value) != null ? _a : item.label;
|
|
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
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const containsActive = winner != null && item.children.some((c) => normalizePath(c.href) === winner);
|
|
258
|
+
const open = openGroup === key || openGroup === null && containsActive;
|
|
259
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
260
|
+
/* @__PURE__ */ jsxs(
|
|
261
|
+
"button",
|
|
262
|
+
{
|
|
263
|
+
type: "button",
|
|
264
|
+
"data-state": open ? "open" : "closed",
|
|
265
|
+
"data-contains-active": containsActive,
|
|
266
|
+
"aria-expanded": open,
|
|
267
|
+
onClick: () => toggleGroup(key),
|
|
268
|
+
className: cn(
|
|
269
|
+
light ? styles.panelLeaf() : sidebarMenuButton({ size: "md" }),
|
|
270
|
+
styles.panelGroupButton()
|
|
271
|
+
),
|
|
272
|
+
children: [
|
|
273
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: styles.panelGroupIcon() }),
|
|
274
|
+
/* @__PURE__ */ jsx("span", { className: styles.panelGroupLabel(), children: item.label }),
|
|
275
|
+
/* @__PURE__ */ jsx(ChevronRightIcon, { className: styles.panelGroupChevron() })
|
|
276
|
+
]
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
open && /* @__PURE__ */ jsx("div", { className: styles.panelTree(), children: item.children.map((child) => {
|
|
280
|
+
const active = normalizePath(child.href) === winner;
|
|
281
|
+
return /* @__PURE__ */ jsx("span", { children: renderLink({
|
|
282
|
+
href: child.href,
|
|
283
|
+
"data-active": active,
|
|
284
|
+
"aria-current": active ? "page" : void 0,
|
|
285
|
+
className: styles.subItem(),
|
|
286
|
+
children: child.label
|
|
287
|
+
}) }, child.href);
|
|
288
|
+
}) })
|
|
289
|
+
] });
|
|
290
|
+
}
|
|
291
|
+
function SidebarV2PanelItems({
|
|
292
|
+
items
|
|
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]);
|
|
312
|
+
return /* @__PURE__ */ jsx(Fragment, { children: items.map((item, idx) => {
|
|
313
|
+
var _a;
|
|
314
|
+
if (panelItemIsSection(item)) {
|
|
315
|
+
return /* @__PURE__ */ jsx(SidebarV2PanelLabel, { children: item.section }, `section-${item.section}-${idx}`);
|
|
316
|
+
}
|
|
317
|
+
if (panelItemHasChildren(item)) {
|
|
318
|
+
return /* @__PURE__ */ jsx(
|
|
319
|
+
SidebarV2PanelGroup,
|
|
320
|
+
{
|
|
321
|
+
item,
|
|
322
|
+
winningHref
|
|
323
|
+
},
|
|
324
|
+
(_a = item.value) != null ? _a : item.label
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
return /* @__PURE__ */ jsx(
|
|
328
|
+
SidebarV2PanelLeaf,
|
|
329
|
+
{
|
|
330
|
+
item,
|
|
331
|
+
active: winningHref != null && normalizePath(item.href) === winningHref
|
|
332
|
+
},
|
|
333
|
+
item.href
|
|
334
|
+
);
|
|
335
|
+
}) });
|
|
336
|
+
}
|
|
337
|
+
function SidebarV2Trigger({
|
|
338
|
+
className,
|
|
339
|
+
...props
|
|
340
|
+
}) {
|
|
341
|
+
const { setDrawerOpen, drawerOpen } = useSidebarV2();
|
|
342
|
+
return /* @__PURE__ */ jsx(
|
|
343
|
+
IconButton,
|
|
344
|
+
{
|
|
345
|
+
variant: "ghost",
|
|
346
|
+
size: "md",
|
|
347
|
+
"aria-label": "Navigation \xF6ffnen",
|
|
348
|
+
onClick: () => setDrawerOpen(!drawerOpen),
|
|
349
|
+
className,
|
|
350
|
+
...props,
|
|
351
|
+
children: /* @__PURE__ */ jsx(PanelLeftIcon, { className: "size-5" })
|
|
352
|
+
}
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export {
|
|
357
|
+
SidebarV2Inset,
|
|
358
|
+
SidebarV2Rail,
|
|
359
|
+
SidebarV2RailSpacer,
|
|
360
|
+
SidebarV2Workspace,
|
|
361
|
+
SidebarV2RailLink,
|
|
362
|
+
SidebarV2RailItem,
|
|
363
|
+
SidebarV2Panel,
|
|
364
|
+
SidebarV2PanelLabel,
|
|
365
|
+
SidebarV2PanelLeaf,
|
|
366
|
+
SidebarV2PanelGroup,
|
|
367
|
+
SidebarV2PanelItems,
|
|
368
|
+
SidebarV2Trigger
|
|
369
|
+
};
|
|
@@ -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,13 +53,14 @@ function SidebarV2FromConfig({
|
|
|
51
53
|
closeFlyout,
|
|
52
54
|
selectedRail,
|
|
53
55
|
setSelectedRail,
|
|
54
|
-
|
|
56
|
+
activeHref,
|
|
55
57
|
isMobile,
|
|
56
58
|
drawerOpen,
|
|
57
59
|
setDrawerOpen,
|
|
58
60
|
setPanelHost,
|
|
59
61
|
panelOverrideActive,
|
|
60
|
-
navPreviewActive
|
|
62
|
+
navPreviewActive,
|
|
63
|
+
styles
|
|
61
64
|
} = useSidebarV2();
|
|
62
65
|
const hoverMode = flyoutTrigger === "hover" && !pinned && !isMobile;
|
|
63
66
|
const closeTimer = useRef(null);
|
|
@@ -96,14 +99,21 @@ function SidebarV2FromConfig({
|
|
|
96
99
|
[items]
|
|
97
100
|
);
|
|
98
101
|
const activeRailValue = useMemo(() => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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]);
|
|
107
117
|
const shownValue = pinned ? selectedRail != null ? selectedRail : activeRailValue : flyoutValue;
|
|
108
118
|
const shownPanel = (_a = panels.find((p) => entryValue(p) === shownValue)) != null ? _a : null;
|
|
109
119
|
const topEntries = items.filter((e) => e.slot !== "bottom");
|
|
@@ -114,7 +124,7 @@ function SidebarV2FromConfig({
|
|
|
114
124
|
"div",
|
|
115
125
|
{
|
|
116
126
|
"aria-hidden": true,
|
|
117
|
-
className:
|
|
127
|
+
className: styles.railDivider()
|
|
118
128
|
},
|
|
119
129
|
`rail-divider-${index}`
|
|
120
130
|
);
|
|
@@ -166,14 +176,14 @@ function SidebarV2FromConfig({
|
|
|
166
176
|
);
|
|
167
177
|
}
|
|
168
178
|
const railContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
|
-
/* @__PURE__ */ jsxs("div", { className:
|
|
179
|
+
/* @__PURE__ */ jsxs("div", { className: styles.railScroll(), children: [
|
|
170
180
|
header && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
171
181
|
header,
|
|
172
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
182
|
+
/* @__PURE__ */ jsx("div", { className: styles.railHeaderDivider() })
|
|
173
183
|
] }),
|
|
174
184
|
topEntries.map(renderRailEntry)
|
|
175
185
|
] }),
|
|
176
|
-
bottomEntries.length > 0 && /* @__PURE__ */ jsx("div", { className:
|
|
186
|
+
bottomEntries.length > 0 && /* @__PURE__ */ jsx("div", { className: styles.railBottom(), children: bottomEntries.map(renderRailEntry) })
|
|
177
187
|
] });
|
|
178
188
|
const navData = pinned && shownPanel && (navPreviewActive || !panelOverrideActive) ? shownPanel : null;
|
|
179
189
|
const [bufferedPanel, setBufferedPanel] = useState(navData);
|
|
@@ -205,7 +215,7 @@ function SidebarV2FromConfig({
|
|
|
205
215
|
open: drawerOpen,
|
|
206
216
|
onOpenChange: setDrawerOpen,
|
|
207
217
|
placement: "left",
|
|
208
|
-
children: /* @__PURE__ */ jsxs(Drawer.Content, { className:
|
|
218
|
+
children: /* @__PURE__ */ jsxs(Drawer.Content, { className: styles.mobileDrawer(), children: [
|
|
209
219
|
/* @__PURE__ */ jsxs(Drawer.Header, { className: "sr-only", children: [
|
|
210
220
|
/* @__PURE__ */ jsx(Drawer.Title, { children: "Navigation" }),
|
|
211
221
|
/* @__PURE__ */ jsx(Drawer.Description, { children: "Hauptnavigation" })
|
|
@@ -233,10 +243,7 @@ function SidebarV2FromConfig({
|
|
|
233
243
|
{
|
|
234
244
|
ref: setPanelHost,
|
|
235
245
|
"data-slot": "sidebar-v2-panel-zone",
|
|
236
|
-
className: cn(
|
|
237
|
-
"relative shrink-0 transition-[width] duration-200 ease-out motion-reduce:transition-none",
|
|
238
|
-
pinned && "overflow-hidden"
|
|
239
|
-
),
|
|
246
|
+
className: cn(styles.panelZone(), pinned && "overflow-hidden"),
|
|
240
247
|
style: { gridArea: "panel", width: docked ? PANEL_WIDTH : "0px" },
|
|
241
248
|
children: [
|
|
242
249
|
panelContent,
|
|
@@ -244,7 +251,7 @@ function SidebarV2FromConfig({
|
|
|
244
251
|
motion.div,
|
|
245
252
|
{
|
|
246
253
|
"data-floating": "true",
|
|
247
|
-
className:
|
|
254
|
+
className: styles.flyout(),
|
|
248
255
|
initial: { x: -14, opacity: 0 },
|
|
249
256
|
animate: { x: 0, opacity: 1 },
|
|
250
257
|
exit: { x: -14, opacity: 0 },
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import {
|
|
3
3
|
useSidebarV2
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-XBTONQ3L.mjs";
|
|
5
5
|
|
|
6
6
|
// src/v2/app-shell.tsx
|
|
7
|
-
import { cn } from "@kopexa/shared-utils";
|
|
8
7
|
import {
|
|
9
8
|
useEffect
|
|
10
9
|
} from "react";
|
|
@@ -18,17 +17,13 @@ function AppShellRoot({
|
|
|
18
17
|
children,
|
|
19
18
|
...props
|
|
20
19
|
}) {
|
|
21
|
-
const { tone } = useSidebarV2();
|
|
20
|
+
const { tone, styles } = useSidebarV2();
|
|
22
21
|
return /* @__PURE__ */ jsx(
|
|
23
22
|
"div",
|
|
24
23
|
{
|
|
25
24
|
"data-slot": "app-shell",
|
|
26
25
|
"data-tone": tone,
|
|
27
|
-
className:
|
|
28
|
-
"relative isolate grid h-svh w-full overflow-hidden antialiased",
|
|
29
|
-
tone === "light" ? "bg-muted text-foreground" : "bg-sidebar text-sidebar-foreground",
|
|
30
|
-
className
|
|
31
|
-
),
|
|
26
|
+
className: styles.shell({ className }),
|
|
32
27
|
style: {
|
|
33
28
|
"--kpx-rail-width": RAIL_WIDTH,
|
|
34
29
|
"--kpx-panel-width": PANEL_WIDTH,
|
|
@@ -47,26 +42,24 @@ function AppShellHeader({
|
|
|
47
42
|
style,
|
|
48
43
|
...props
|
|
49
44
|
}) {
|
|
45
|
+
const { styles } = useSidebarV2();
|
|
50
46
|
return /* @__PURE__ */ jsx(
|
|
51
47
|
"header",
|
|
52
48
|
{
|
|
53
49
|
"data-slot": "app-shell-header",
|
|
54
|
-
className:
|
|
50
|
+
className: styles.header({ className }),
|
|
55
51
|
style: { gridArea: "header", ...style },
|
|
56
52
|
...props
|
|
57
53
|
}
|
|
58
54
|
);
|
|
59
55
|
}
|
|
60
56
|
function AppShellMain({ className, style, ...props }) {
|
|
57
|
+
const { styles } = useSidebarV2();
|
|
61
58
|
return /* @__PURE__ */ jsx(
|
|
62
59
|
"main",
|
|
63
60
|
{
|
|
64
61
|
"data-slot": "app-shell-main",
|
|
65
|
-
className:
|
|
66
|
-
"relative flex min-h-0 min-w-0 flex-col overflow-hidden bg-background",
|
|
67
|
-
"m-2 rounded-xl shadow-sm",
|
|
68
|
-
className
|
|
69
|
-
),
|
|
62
|
+
className: styles.main({ className }),
|
|
70
63
|
style: { gridArea: "main", ...style },
|
|
71
64
|
...props
|
|
72
65
|
}
|
|
@@ -77,11 +70,12 @@ function AppShellAside({
|
|
|
77
70
|
style,
|
|
78
71
|
...props
|
|
79
72
|
}) {
|
|
73
|
+
const { styles } = useSidebarV2();
|
|
80
74
|
return /* @__PURE__ */ jsx(
|
|
81
75
|
"aside",
|
|
82
76
|
{
|
|
83
77
|
"data-slot": "app-shell-aside",
|
|
84
|
-
className:
|
|
78
|
+
className: styles.aside({ className }),
|
|
85
79
|
style: { gridArea: "aside", ...style },
|
|
86
80
|
...props
|
|
87
81
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
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";
|
|
9
|
+
import { sidebarV2 } from "@kopexa/theme";
|
|
5
10
|
import { TooltipProvider } from "@kopexa/tooltip";
|
|
6
11
|
import { useIsMobile } from "@kopexa/use-is-mobile";
|
|
7
12
|
import {
|
|
@@ -46,6 +51,7 @@ function SidebarV2Provider({
|
|
|
46
51
|
}, []);
|
|
47
52
|
const panelOverrideActive = overrideCount > 0;
|
|
48
53
|
const navPreviewActive = pinned ? selectedRail !== null : flyoutValue !== null;
|
|
54
|
+
const styles = useMemo(() => sidebarV2({ tone }), [tone]);
|
|
49
55
|
const setPinned = useCallback(
|
|
50
56
|
(value2) => {
|
|
51
57
|
onPinnedChange == null ? void 0 : onPinnedChange(value2);
|
|
@@ -75,12 +81,13 @@ function SidebarV2Provider({
|
|
|
75
81
|
setOpenGroup((curr) => curr === key ? null : key);
|
|
76
82
|
}, []);
|
|
77
83
|
const isActive = useCallback(
|
|
78
|
-
(href) => activeHref
|
|
84
|
+
(href) => pathMatchLength(normalizePath(activeHref), href) >= 0,
|
|
79
85
|
[activeHref]
|
|
80
86
|
);
|
|
81
87
|
const value = useMemo(
|
|
82
88
|
() => ({
|
|
83
89
|
tone,
|
|
90
|
+
styles,
|
|
84
91
|
pinned,
|
|
85
92
|
togglePin,
|
|
86
93
|
setPinned,
|
|
@@ -109,6 +116,7 @@ function SidebarV2Provider({
|
|
|
109
116
|
}),
|
|
110
117
|
[
|
|
111
118
|
tone,
|
|
119
|
+
styles,
|
|
112
120
|
pinned,
|
|
113
121
|
togglePin,
|
|
114
122
|
setPinned,
|