@kopexa/sidebar 17.1.74 → 17.2.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/chunk-AIRHHM7Z.mjs +151 -0
- package/dist/chunk-KLYPP6QE.mjs +272 -0
- package/dist/chunk-LCCZNS2E.mjs +41 -0
- package/dist/chunk-SDMGFB6V.mjs +14 -0
- package/dist/chunk-YVQVW5EP.mjs +103 -0
- package/dist/chunk-YW3JMPRU.mjs +329 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +851 -2
- package/dist/index.mjs +56 -1
- package/dist/v2/app-shell.d.mts +43 -0
- package/dist/v2/app-shell.d.ts +43 -0
- package/dist/v2/app-shell.js +142 -0
- package/dist/v2/app-shell.mjs +19 -0
- package/dist/v2/components.d.mts +78 -0
- package/dist/v2/components.d.ts +78 -0
- package/dist/v2/components.js +376 -0
- package/dist/v2/components.mjs +32 -0
- package/dist/v2/context.d.mts +84 -0
- package/dist/v2/context.d.ts +84 -0
- package/dist/v2/context.js +171 -0
- package/dist/v2/context.mjs +10 -0
- package/dist/v2/from-config.d.mts +12 -0
- package/dist/v2/from-config.d.ts +12 -0
- package/dist/v2/from-config.js +568 -0
- package/dist/v2/from-config.mjs +11 -0
- package/dist/v2/index.d.mts +48 -0
- package/dist/v2/index.d.ts +48 -0
- package/dist/v2/index.js +878 -0
- package/dist/v2/index.mjs +59 -0
- package/dist/v2/types.d.mts +80 -0
- package/dist/v2/types.d.ts +80 -0
- package/dist/v2/types.js +38 -0
- package/dist/v2/types.mjs +9 -0
- package/package.json +11 -11
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
"use client";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/v2/from-config.tsx
|
|
23
|
+
var from_config_exports = {};
|
|
24
|
+
__export(from_config_exports, {
|
|
25
|
+
SidebarV2FromConfig: () => SidebarV2FromConfig
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(from_config_exports);
|
|
28
|
+
var import_drawer = require("@kopexa/drawer");
|
|
29
|
+
var import_shared_utils2 = require("@kopexa/shared-utils");
|
|
30
|
+
var import_react3 = require("motion/react");
|
|
31
|
+
var import_react4 = require("react");
|
|
32
|
+
|
|
33
|
+
// src/v2/components.tsx
|
|
34
|
+
var import_button = require("@kopexa/button");
|
|
35
|
+
var import_icons = require("@kopexa/icons");
|
|
36
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
37
|
+
var import_theme2 = require("@kopexa/theme");
|
|
38
|
+
var import_tooltip2 = require("@kopexa/tooltip");
|
|
39
|
+
var import_react2 = require("react");
|
|
40
|
+
|
|
41
|
+
// src/v2/context.tsx
|
|
42
|
+
var import_react_utils = require("@kopexa/react-utils");
|
|
43
|
+
var import_theme = require("@kopexa/theme");
|
|
44
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
45
|
+
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
46
|
+
var import_react = require("react");
|
|
47
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
48
|
+
var PIN_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
49
|
+
var [Provider, useSidebarV2] = (0, import_react_utils.createContext)({
|
|
50
|
+
name: "SidebarV2Context",
|
|
51
|
+
errorMessage: "useSidebarV2 must be used within <SidebarV2> (the provider component)."
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/v2/types.ts
|
|
55
|
+
function panelItemHasChildren(item) {
|
|
56
|
+
return "children" in item && Array.isArray(item.children);
|
|
57
|
+
}
|
|
58
|
+
function panelItemIsSection(item) {
|
|
59
|
+
return "section" in item;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// src/v2/components.tsx
|
|
63
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
64
|
+
function SidebarV2Rail({ className, ...props }) {
|
|
65
|
+
const { styles } = useSidebarV2();
|
|
66
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
67
|
+
"nav",
|
|
68
|
+
{
|
|
69
|
+
"data-slot": "sidebar-v2-rail",
|
|
70
|
+
className: styles.rail({ className }),
|
|
71
|
+
...props
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
var SidebarV2Workspace = (0, import_react2.forwardRef)(({ name, role, logo, className, appearance = "rail", ...props }, ref) => {
|
|
76
|
+
const { styles } = useSidebarV2();
|
|
77
|
+
if (appearance === "bar") {
|
|
78
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
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.workspaceBar({ className }),
|
|
86
|
+
...props,
|
|
87
|
+
children: [
|
|
88
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.workspaceBarLogo(), children: logo != null ? logo : name.charAt(0).toUpperCase() }),
|
|
89
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: styles.workspaceBarText(), children: [
|
|
90
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.workspaceBarName(), children: name }),
|
|
91
|
+
role && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.workspaceBarRole(), children: role })
|
|
92
|
+
] }),
|
|
93
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.ChevronDownIcon, { className: styles.workspaceBarChevron() })
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
99
|
+
"button",
|
|
100
|
+
{
|
|
101
|
+
ref,
|
|
102
|
+
type: "button",
|
|
103
|
+
"data-slot": "sidebar-v2-workspace",
|
|
104
|
+
"aria-label": role ? `${name} \u2013 ${role}` : name,
|
|
105
|
+
className: styles.workspaceRail({ className }),
|
|
106
|
+
...props,
|
|
107
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: styles.workspaceRailLogo(), children: [
|
|
108
|
+
logo != null ? logo : name.charAt(0).toUpperCase(),
|
|
109
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.ChevronDownIcon, { className: styles.workspaceRailChevron() })
|
|
110
|
+
] })
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
SidebarV2Workspace.displayName = "SidebarV2Workspace";
|
|
115
|
+
function RailInner({
|
|
116
|
+
icon: Icon,
|
|
117
|
+
badge
|
|
118
|
+
}) {
|
|
119
|
+
const { styles } = useSidebarV2();
|
|
120
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { "aria-hidden": true, className: styles.railIndicator() }),
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: styles.railIcon() }),
|
|
123
|
+
badge != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.railBadge(), children: badge })
|
|
124
|
+
] });
|
|
125
|
+
}
|
|
126
|
+
function SidebarV2RailLink({
|
|
127
|
+
icon,
|
|
128
|
+
label,
|
|
129
|
+
href,
|
|
130
|
+
badge
|
|
131
|
+
}) {
|
|
132
|
+
const { renderLink, isActive, resetPanelSelection, styles } = useSidebarV2();
|
|
133
|
+
const active = isActive(href);
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip2.Tooltip, { content: label, side: "right", children: renderLink({
|
|
135
|
+
href,
|
|
136
|
+
className: styles.railButton(),
|
|
137
|
+
"data-active": active,
|
|
138
|
+
"aria-current": active ? "page" : void 0,
|
|
139
|
+
"aria-label": label,
|
|
140
|
+
// Navigating to a destination link clears any open panel preview,
|
|
141
|
+
// even when the route doesn't change (e.g. already on it).
|
|
142
|
+
onClick: resetPanelSelection,
|
|
143
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RailInner, { icon, badge })
|
|
144
|
+
}) });
|
|
145
|
+
}
|
|
146
|
+
function SidebarV2RailItem({
|
|
147
|
+
icon,
|
|
148
|
+
label,
|
|
149
|
+
active,
|
|
150
|
+
hasPanel,
|
|
151
|
+
onClick,
|
|
152
|
+
onMouseEnter,
|
|
153
|
+
onMouseLeave,
|
|
154
|
+
badge
|
|
155
|
+
}) {
|
|
156
|
+
const { styles } = useSidebarV2();
|
|
157
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip2.Tooltip, { content: label, side: "right", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
158
|
+
"button",
|
|
159
|
+
{
|
|
160
|
+
type: "button",
|
|
161
|
+
"data-active": active,
|
|
162
|
+
"aria-label": label,
|
|
163
|
+
"aria-expanded": hasPanel ? active : void 0,
|
|
164
|
+
onClick,
|
|
165
|
+
onMouseEnter,
|
|
166
|
+
onMouseLeave,
|
|
167
|
+
className: styles.railButton(),
|
|
168
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RailInner, { icon, badge })
|
|
169
|
+
}
|
|
170
|
+
) });
|
|
171
|
+
}
|
|
172
|
+
function SidebarV2Panel({
|
|
173
|
+
title,
|
|
174
|
+
subtitle,
|
|
175
|
+
floating,
|
|
176
|
+
hidePin,
|
|
177
|
+
action,
|
|
178
|
+
children,
|
|
179
|
+
className
|
|
180
|
+
}) {
|
|
181
|
+
const { togglePin, pinned, styles } = useSidebarV2();
|
|
182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
183
|
+
"div",
|
|
184
|
+
{
|
|
185
|
+
"data-slot": "sidebar-v2-panel",
|
|
186
|
+
"data-floating": floating ? "true" : "false",
|
|
187
|
+
className: styles.panel({ className }),
|
|
188
|
+
children: [
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: styles.panelHeader(), children: [
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
191
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: styles.panelTitle(), children: title }),
|
|
192
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: styles.panelSubtitle(), children: subtitle })
|
|
193
|
+
] }),
|
|
194
|
+
action != null ? action : !hidePin && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
195
|
+
import_tooltip2.Tooltip,
|
|
196
|
+
{
|
|
197
|
+
content: pinned ? "Panel l\xF6sen" : "Panel anheften",
|
|
198
|
+
side: "bottom",
|
|
199
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
200
|
+
import_button.IconButton,
|
|
201
|
+
{
|
|
202
|
+
variant: "ghost",
|
|
203
|
+
size: "sm",
|
|
204
|
+
"aria-label": pinned ? "Panel l\xF6sen" : "Panel anheften",
|
|
205
|
+
onClick: togglePin,
|
|
206
|
+
className: styles.panelPin(),
|
|
207
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.PanelLeftIcon, { className: "size-4" })
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
}
|
|
211
|
+
)
|
|
212
|
+
] }),
|
|
213
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: styles.panelBody(), children })
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
function SidebarV2PanelLabel({
|
|
219
|
+
className,
|
|
220
|
+
...props
|
|
221
|
+
}) {
|
|
222
|
+
const { styles } = useSidebarV2();
|
|
223
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
224
|
+
"div",
|
|
225
|
+
{
|
|
226
|
+
"data-slot": "sidebar-v2-panel-label",
|
|
227
|
+
className: styles.panelLabel({ className }),
|
|
228
|
+
...props
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
function SidebarV2PanelLeaf({
|
|
233
|
+
item,
|
|
234
|
+
active: activeProp
|
|
235
|
+
}) {
|
|
236
|
+
const { renderLink, isActive, tone, styles } = useSidebarV2();
|
|
237
|
+
const light = tone === "light";
|
|
238
|
+
const Icon = item.icon;
|
|
239
|
+
const active = activeProp != null ? activeProp : isActive(item.href);
|
|
240
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: renderLink({
|
|
241
|
+
href: item.href,
|
|
242
|
+
"data-active": active,
|
|
243
|
+
"aria-current": active ? "page" : void 0,
|
|
244
|
+
// Light tone uses the recipe's leaf slot (group/leaf + data-active);
|
|
245
|
+
// dark tone reuses the existing sidebarMenuButton recipe.
|
|
246
|
+
className: light ? styles.panelLeaf() : (0, import_theme2.sidebarMenuButton)({ size: "md" }),
|
|
247
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
248
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: styles.panelLeafIcon() }),
|
|
249
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.panelLeafLabel(), children: item.label }),
|
|
250
|
+
item.badge != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.panelLeafBadge(), children: item.badge })
|
|
251
|
+
] })
|
|
252
|
+
}) });
|
|
253
|
+
}
|
|
254
|
+
function SidebarV2PanelGroup({
|
|
255
|
+
item
|
|
256
|
+
}) {
|
|
257
|
+
var _a;
|
|
258
|
+
const { openGroup, toggleGroup, activeHref, renderLink, tone, styles } = useSidebarV2();
|
|
259
|
+
const light = tone === "light";
|
|
260
|
+
const Icon = item.icon;
|
|
261
|
+
const key = (_a = item.value) != null ? _a : item.label;
|
|
262
|
+
let bestChildHref = null;
|
|
263
|
+
let bestLen = -1;
|
|
264
|
+
for (const c of item.children) {
|
|
265
|
+
if (activeHref === c.href) {
|
|
266
|
+
bestChildHref = c.href;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
if (activeHref.startsWith(`${c.href}/`) && c.href.length > bestLen) {
|
|
270
|
+
bestChildHref = c.href;
|
|
271
|
+
bestLen = c.href.length;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
const containsActive = bestChildHref !== null;
|
|
275
|
+
const open = openGroup === key || openGroup === null && containsActive;
|
|
276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
277
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
278
|
+
"button",
|
|
279
|
+
{
|
|
280
|
+
type: "button",
|
|
281
|
+
"data-state": open ? "open" : "closed",
|
|
282
|
+
"data-contains-active": containsActive,
|
|
283
|
+
"aria-expanded": open,
|
|
284
|
+
onClick: () => toggleGroup(key),
|
|
285
|
+
className: (0, import_shared_utils.cn)(
|
|
286
|
+
light ? styles.panelLeaf() : (0, import_theme2.sidebarMenuButton)({ size: "md" }),
|
|
287
|
+
styles.panelGroupButton()
|
|
288
|
+
),
|
|
289
|
+
children: [
|
|
290
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: styles.panelGroupIcon() }),
|
|
291
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: styles.panelGroupLabel(), children: item.label }),
|
|
292
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.ChevronRightIcon, { className: styles.panelGroupChevron() })
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
),
|
|
296
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: styles.panelTree(), children: item.children.map((child) => {
|
|
297
|
+
const active = child.href === bestChildHref;
|
|
298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: renderLink({
|
|
299
|
+
href: child.href,
|
|
300
|
+
"data-active": active,
|
|
301
|
+
"aria-current": active ? "page" : void 0,
|
|
302
|
+
className: styles.subItem(),
|
|
303
|
+
children: child.label
|
|
304
|
+
}) }, child.href);
|
|
305
|
+
}) })
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
function SidebarV2PanelItems({
|
|
309
|
+
items
|
|
310
|
+
}) {
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: items.map((item, idx) => {
|
|
312
|
+
var _a;
|
|
313
|
+
if (panelItemIsSection(item)) {
|
|
314
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarV2PanelLabel, { children: item.section }, `section-${item.section}-${idx}`);
|
|
315
|
+
}
|
|
316
|
+
if (panelItemHasChildren(item)) {
|
|
317
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarV2PanelGroup, { item }, (_a = item.value) != null ? _a : item.label);
|
|
318
|
+
}
|
|
319
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarV2PanelLeaf, { item }, item.href);
|
|
320
|
+
}) });
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// src/v2/from-config.tsx
|
|
324
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
325
|
+
var RAIL_WIDTH = "4rem";
|
|
326
|
+
var PANEL_WIDTH = "15rem";
|
|
327
|
+
var railVars = {
|
|
328
|
+
"--kpx-rail-width": RAIL_WIDTH,
|
|
329
|
+
"--kpx-panel-width": PANEL_WIDTH
|
|
330
|
+
};
|
|
331
|
+
function entryValue(entry) {
|
|
332
|
+
var _a;
|
|
333
|
+
if (entry.type === "divider") return "divider";
|
|
334
|
+
return entry.type === "panel" ? (_a = entry.value) != null ? _a : entry.label : entry.label;
|
|
335
|
+
}
|
|
336
|
+
function SidebarV2FromConfig({
|
|
337
|
+
items,
|
|
338
|
+
header
|
|
339
|
+
}) {
|
|
340
|
+
var _a, _b, _c;
|
|
341
|
+
const {
|
|
342
|
+
pinned,
|
|
343
|
+
flyoutTrigger,
|
|
344
|
+
flyoutValue,
|
|
345
|
+
openFlyout,
|
|
346
|
+
setFlyout,
|
|
347
|
+
closeFlyout,
|
|
348
|
+
selectedRail,
|
|
349
|
+
setSelectedRail,
|
|
350
|
+
isActive,
|
|
351
|
+
isMobile,
|
|
352
|
+
drawerOpen,
|
|
353
|
+
setDrawerOpen,
|
|
354
|
+
setPanelHost,
|
|
355
|
+
panelOverrideActive,
|
|
356
|
+
navPreviewActive,
|
|
357
|
+
styles
|
|
358
|
+
} = useSidebarV2();
|
|
359
|
+
const hoverMode = flyoutTrigger === "hover" && !pinned && !isMobile;
|
|
360
|
+
const closeTimer = (0, import_react4.useRef)(null);
|
|
361
|
+
const cancelClose = (0, import_react4.useCallback)(() => {
|
|
362
|
+
if (closeTimer.current) clearTimeout(closeTimer.current);
|
|
363
|
+
closeTimer.current = null;
|
|
364
|
+
}, []);
|
|
365
|
+
const scheduleClose = (0, import_react4.useCallback)(() => {
|
|
366
|
+
cancelClose();
|
|
367
|
+
closeTimer.current = setTimeout(() => closeFlyout(), 160);
|
|
368
|
+
}, [cancelClose, closeFlyout]);
|
|
369
|
+
(0, import_react4.useEffect)(() => cancelClose, [cancelClose]);
|
|
370
|
+
(0, import_react4.useEffect)(() => {
|
|
371
|
+
if (pinned || isMobile || !flyoutValue) return;
|
|
372
|
+
const onPointerDown = (event) => {
|
|
373
|
+
const t = event.target;
|
|
374
|
+
if (!t) return;
|
|
375
|
+
if (t.closest('[data-slot="sidebar-v2-rail"]')) return;
|
|
376
|
+
if (t.closest('[data-floating="true"]')) return;
|
|
377
|
+
closeFlyout();
|
|
378
|
+
};
|
|
379
|
+
const onKeyDown = (event) => {
|
|
380
|
+
if (event.key === "Escape") closeFlyout();
|
|
381
|
+
};
|
|
382
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
383
|
+
document.addEventListener("keydown", onKeyDown);
|
|
384
|
+
return () => {
|
|
385
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
386
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
387
|
+
};
|
|
388
|
+
}, [pinned, isMobile, flyoutValue, closeFlyout]);
|
|
389
|
+
const panels = (0, import_react4.useMemo)(
|
|
390
|
+
() => items.filter(
|
|
391
|
+
(e) => e.type === "panel"
|
|
392
|
+
),
|
|
393
|
+
[items]
|
|
394
|
+
);
|
|
395
|
+
const activeRailValue = (0, import_react4.useMemo)(() => {
|
|
396
|
+
const match = panels.find(
|
|
397
|
+
(p) => p.items.some((item) => {
|
|
398
|
+
if (panelItemIsSection(item)) return false;
|
|
399
|
+
return panelItemHasChildren(item) ? item.children.some((c) => isActive(c.href)) : isActive(item.href);
|
|
400
|
+
})
|
|
401
|
+
);
|
|
402
|
+
return match ? entryValue(match) : null;
|
|
403
|
+
}, [panels, isActive]);
|
|
404
|
+
const shownValue = pinned ? selectedRail != null ? selectedRail : activeRailValue : flyoutValue;
|
|
405
|
+
const shownPanel = (_a = panels.find((p) => entryValue(p) === shownValue)) != null ? _a : null;
|
|
406
|
+
const topEntries = items.filter((e) => e.slot !== "bottom");
|
|
407
|
+
const bottomEntries = items.filter((e) => e.slot === "bottom");
|
|
408
|
+
function renderRailEntry(entry, index) {
|
|
409
|
+
if (entry.type === "divider") {
|
|
410
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
411
|
+
"div",
|
|
412
|
+
{
|
|
413
|
+
"aria-hidden": true,
|
|
414
|
+
className: styles.railDivider()
|
|
415
|
+
},
|
|
416
|
+
`rail-divider-${index}`
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
const value = entryValue(entry);
|
|
420
|
+
if (entry.type === "link") {
|
|
421
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
422
|
+
SidebarV2RailLink,
|
|
423
|
+
{
|
|
424
|
+
icon: entry.icon,
|
|
425
|
+
label: entry.label,
|
|
426
|
+
href: entry.href,
|
|
427
|
+
badge: entry.badge
|
|
428
|
+
},
|
|
429
|
+
value
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
if (entry.type === "action") {
|
|
433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
434
|
+
SidebarV2RailItem,
|
|
435
|
+
{
|
|
436
|
+
icon: entry.icon,
|
|
437
|
+
label: entry.label,
|
|
438
|
+
active: false,
|
|
439
|
+
onClick: entry.onSelect
|
|
440
|
+
},
|
|
441
|
+
value
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
const active = flyoutValue ? value === flyoutValue : value === (selectedRail != null ? selectedRail : activeRailValue);
|
|
445
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
446
|
+
SidebarV2RailItem,
|
|
447
|
+
{
|
|
448
|
+
icon: entry.icon,
|
|
449
|
+
label: entry.label,
|
|
450
|
+
active,
|
|
451
|
+
hasPanel: true,
|
|
452
|
+
onClick: () => {
|
|
453
|
+
if (pinned) setSelectedRail(value);
|
|
454
|
+
else openFlyout(value);
|
|
455
|
+
},
|
|
456
|
+
onMouseEnter: hoverMode ? () => {
|
|
457
|
+
cancelClose();
|
|
458
|
+
setFlyout(value);
|
|
459
|
+
} : void 0,
|
|
460
|
+
onMouseLeave: hoverMode ? scheduleClose : void 0
|
|
461
|
+
},
|
|
462
|
+
value
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
const railContent = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: styles.railScroll(), children: [
|
|
467
|
+
header && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
468
|
+
header,
|
|
469
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: styles.railHeaderDivider() })
|
|
470
|
+
] }),
|
|
471
|
+
topEntries.map(renderRailEntry)
|
|
472
|
+
] }),
|
|
473
|
+
bottomEntries.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: styles.railBottom(), children: bottomEntries.map(renderRailEntry) })
|
|
474
|
+
] });
|
|
475
|
+
const navData = pinned && shownPanel && (navPreviewActive || !panelOverrideActive) ? shownPanel : null;
|
|
476
|
+
const [bufferedPanel, setBufferedPanel] = (0, import_react4.useState)(navData);
|
|
477
|
+
(0, import_react4.useEffect)(() => {
|
|
478
|
+
if (navData) {
|
|
479
|
+
setBufferedPanel(navData);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const t = setTimeout(() => setBufferedPanel(null), 220);
|
|
483
|
+
return () => clearTimeout(t);
|
|
484
|
+
}, [navData]);
|
|
485
|
+
const navToRender = navData != null ? navData : bufferedPanel;
|
|
486
|
+
const renderNav = (!panelOverrideActive || navPreviewActive) && navToRender;
|
|
487
|
+
const panelContent = navToRender && renderNav ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
488
|
+
SidebarV2Panel,
|
|
489
|
+
{
|
|
490
|
+
title: (_b = navToRender.title) != null ? _b : navToRender.label,
|
|
491
|
+
subtitle: navToRender.subtitle,
|
|
492
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SidebarV2PanelItems, { items: navToRender.items })
|
|
493
|
+
},
|
|
494
|
+
entryValue(navToRender)
|
|
495
|
+
) : null;
|
|
496
|
+
const docked = Boolean(navData) || panelOverrideActive;
|
|
497
|
+
const showFlyout = !pinned && Boolean(shownPanel);
|
|
498
|
+
if (isMobile) {
|
|
499
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
500
|
+
import_drawer.Drawer.Root,
|
|
501
|
+
{
|
|
502
|
+
open: drawerOpen,
|
|
503
|
+
onOpenChange: setDrawerOpen,
|
|
504
|
+
placement: "left",
|
|
505
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_drawer.Drawer.Content, { className: styles.mobileDrawer(), children: [
|
|
506
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_drawer.Drawer.Header, { className: "sr-only", children: [
|
|
507
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_drawer.Drawer.Title, { children: "Navigation" }),
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_drawer.Drawer.Description, { children: "Hauptnavigation" })
|
|
509
|
+
] }),
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex h-full", style: railVars, children: [
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SidebarV2Rail, { children: railContent }),
|
|
512
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
513
|
+
"div",
|
|
514
|
+
{
|
|
515
|
+
ref: setPanelHost,
|
|
516
|
+
"data-slot": "sidebar-v2-panel-zone",
|
|
517
|
+
className: "flex min-h-0",
|
|
518
|
+
children: panelContent
|
|
519
|
+
}
|
|
520
|
+
)
|
|
521
|
+
] })
|
|
522
|
+
] })
|
|
523
|
+
}
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
527
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SidebarV2Rail, { style: { gridArea: "rail" }, children: railContent }),
|
|
528
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
529
|
+
"div",
|
|
530
|
+
{
|
|
531
|
+
ref: setPanelHost,
|
|
532
|
+
"data-slot": "sidebar-v2-panel-zone",
|
|
533
|
+
className: (0, import_shared_utils2.cn)(styles.panelZone(), pinned && "overflow-hidden"),
|
|
534
|
+
style: { gridArea: "panel", width: docked ? PANEL_WIDTH : "0px" },
|
|
535
|
+
children: [
|
|
536
|
+
panelContent,
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.AnimatePresence, { children: showFlyout && shownPanel && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
538
|
+
import_react3.motion.div,
|
|
539
|
+
{
|
|
540
|
+
"data-floating": "true",
|
|
541
|
+
className: styles.flyout(),
|
|
542
|
+
initial: { x: -14, opacity: 0 },
|
|
543
|
+
animate: { x: 0, opacity: 1 },
|
|
544
|
+
exit: { x: -14, opacity: 0 },
|
|
545
|
+
transition: { duration: 0.16, ease: "easeOut" },
|
|
546
|
+
onMouseEnter: hoverMode ? cancelClose : void 0,
|
|
547
|
+
onMouseLeave: hoverMode ? scheduleClose : void 0,
|
|
548
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
549
|
+
SidebarV2Panel,
|
|
550
|
+
{
|
|
551
|
+
floating: true,
|
|
552
|
+
title: (_c = shownPanel.title) != null ? _c : shownPanel.label,
|
|
553
|
+
subtitle: shownPanel.subtitle,
|
|
554
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SidebarV2PanelItems, { items: shownPanel.items })
|
|
555
|
+
}
|
|
556
|
+
)
|
|
557
|
+
},
|
|
558
|
+
"sidebar-v2-flyout"
|
|
559
|
+
) })
|
|
560
|
+
]
|
|
561
|
+
}
|
|
562
|
+
)
|
|
563
|
+
] });
|
|
564
|
+
}
|
|
565
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
566
|
+
0 && (module.exports = {
|
|
567
|
+
SidebarV2FromConfig
|
|
568
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { AppShell, AppShellAside, AppShellHeader, AppShellMain, AppShellPanelContent, AppShellPanelContentProps, AppShellRoot } from './app-shell.mjs';
|
|
2
|
+
import { SidebarV2Inset, SidebarV2Trigger, SidebarV2Rail, SidebarV2RailItem, SidebarV2RailLink, SidebarV2RailSpacer, SidebarV2Workspace, SidebarV2Panel, SidebarV2PanelItems, SidebarV2PanelLeaf, SidebarV2PanelGroup, SidebarV2PanelLabel } from './components.mjs';
|
|
3
|
+
export { SidebarV2WorkspaceProps } from './components.mjs';
|
|
4
|
+
import { SidebarV2Provider } from './context.mjs';
|
|
5
|
+
export { SidebarV2ContextValue, SidebarV2ProviderProps, SidebarV2Tone, useSidebarV2 } from './context.mjs';
|
|
6
|
+
import { SidebarV2FromConfig } from './from-config.mjs';
|
|
7
|
+
export { SidebarV2FromConfigProps } from './from-config.mjs';
|
|
8
|
+
export { SidebarV2Icon, SidebarV2LinkProps, SidebarV2Nav, SidebarV2PanelItem, SidebarV2RailEntry, SidebarV2SubItem } from './types.mjs';
|
|
9
|
+
import 'react';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
import '@kopexa/button';
|
|
12
|
+
import '@kopexa/theme';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* SidebarV2 — icon rail + expandable panel navigation context + primitives.
|
|
16
|
+
*
|
|
17
|
+
* The callable is the provider; sub-components hang off it as a namespace
|
|
18
|
+
* (assembled via direct assignment — never Object.assign, which breaks RSC
|
|
19
|
+
* client-reference proxies under "use client"/"use server").
|
|
20
|
+
*
|
|
21
|
+
* Layout is owned by <AppShell> (grid + zones).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <SidebarV2 tone="light" activeHref={pathname} renderLink={(p) => <Link {...p} />}>
|
|
25
|
+
* <AppShell>
|
|
26
|
+
* <AppShell.Header>…</AppShell.Header>
|
|
27
|
+
* <SidebarV2.FromConfig items={nav} header={<SidebarV2.Workspace … />} />
|
|
28
|
+
* <AppShell.Main>{children}</AppShell.Main>
|
|
29
|
+
* </AppShell>
|
|
30
|
+
* </SidebarV2>
|
|
31
|
+
*/
|
|
32
|
+
declare const SidebarV2: typeof SidebarV2Provider & {
|
|
33
|
+
FromConfig: typeof SidebarV2FromConfig;
|
|
34
|
+
Inset: typeof SidebarV2Inset;
|
|
35
|
+
Trigger: typeof SidebarV2Trigger;
|
|
36
|
+
Rail: typeof SidebarV2Rail;
|
|
37
|
+
RailItem: typeof SidebarV2RailItem;
|
|
38
|
+
RailLink: typeof SidebarV2RailLink;
|
|
39
|
+
RailSpacer: typeof SidebarV2RailSpacer;
|
|
40
|
+
Workspace: typeof SidebarV2Workspace;
|
|
41
|
+
Panel: typeof SidebarV2Panel;
|
|
42
|
+
PanelItems: typeof SidebarV2PanelItems;
|
|
43
|
+
PanelLeaf: typeof SidebarV2PanelLeaf;
|
|
44
|
+
PanelGroup: typeof SidebarV2PanelGroup;
|
|
45
|
+
PanelLabel: typeof SidebarV2PanelLabel;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { SidebarV2, SidebarV2FromConfig, SidebarV2Inset, SidebarV2Panel, SidebarV2PanelGroup, SidebarV2PanelItems, SidebarV2PanelLabel, SidebarV2PanelLeaf, SidebarV2Provider, SidebarV2Rail, SidebarV2RailItem, SidebarV2RailLink, SidebarV2RailSpacer, SidebarV2Trigger, SidebarV2Workspace };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export { AppShell, AppShellAside, AppShellHeader, AppShellMain, AppShellPanelContent, AppShellPanelContentProps, AppShellRoot } from './app-shell.js';
|
|
2
|
+
import { SidebarV2Inset, SidebarV2Trigger, SidebarV2Rail, SidebarV2RailItem, SidebarV2RailLink, SidebarV2RailSpacer, SidebarV2Workspace, SidebarV2Panel, SidebarV2PanelItems, SidebarV2PanelLeaf, SidebarV2PanelGroup, SidebarV2PanelLabel } from './components.js';
|
|
3
|
+
export { SidebarV2WorkspaceProps } from './components.js';
|
|
4
|
+
import { SidebarV2Provider } from './context.js';
|
|
5
|
+
export { SidebarV2ContextValue, SidebarV2ProviderProps, SidebarV2Tone, useSidebarV2 } from './context.js';
|
|
6
|
+
import { SidebarV2FromConfig } from './from-config.js';
|
|
7
|
+
export { SidebarV2FromConfigProps } from './from-config.js';
|
|
8
|
+
export { SidebarV2Icon, SidebarV2LinkProps, SidebarV2Nav, SidebarV2PanelItem, SidebarV2RailEntry, SidebarV2SubItem } from './types.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import 'react/jsx-runtime';
|
|
11
|
+
import '@kopexa/button';
|
|
12
|
+
import '@kopexa/theme';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* SidebarV2 — icon rail + expandable panel navigation context + primitives.
|
|
16
|
+
*
|
|
17
|
+
* The callable is the provider; sub-components hang off it as a namespace
|
|
18
|
+
* (assembled via direct assignment — never Object.assign, which breaks RSC
|
|
19
|
+
* client-reference proxies under "use client"/"use server").
|
|
20
|
+
*
|
|
21
|
+
* Layout is owned by <AppShell> (grid + zones).
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* <SidebarV2 tone="light" activeHref={pathname} renderLink={(p) => <Link {...p} />}>
|
|
25
|
+
* <AppShell>
|
|
26
|
+
* <AppShell.Header>…</AppShell.Header>
|
|
27
|
+
* <SidebarV2.FromConfig items={nav} header={<SidebarV2.Workspace … />} />
|
|
28
|
+
* <AppShell.Main>{children}</AppShell.Main>
|
|
29
|
+
* </AppShell>
|
|
30
|
+
* </SidebarV2>
|
|
31
|
+
*/
|
|
32
|
+
declare const SidebarV2: typeof SidebarV2Provider & {
|
|
33
|
+
FromConfig: typeof SidebarV2FromConfig;
|
|
34
|
+
Inset: typeof SidebarV2Inset;
|
|
35
|
+
Trigger: typeof SidebarV2Trigger;
|
|
36
|
+
Rail: typeof SidebarV2Rail;
|
|
37
|
+
RailItem: typeof SidebarV2RailItem;
|
|
38
|
+
RailLink: typeof SidebarV2RailLink;
|
|
39
|
+
RailSpacer: typeof SidebarV2RailSpacer;
|
|
40
|
+
Workspace: typeof SidebarV2Workspace;
|
|
41
|
+
Panel: typeof SidebarV2Panel;
|
|
42
|
+
PanelItems: typeof SidebarV2PanelItems;
|
|
43
|
+
PanelLeaf: typeof SidebarV2PanelLeaf;
|
|
44
|
+
PanelGroup: typeof SidebarV2PanelGroup;
|
|
45
|
+
PanelLabel: typeof SidebarV2PanelLabel;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { SidebarV2, SidebarV2FromConfig, SidebarV2Inset, SidebarV2Panel, SidebarV2PanelGroup, SidebarV2PanelItems, SidebarV2PanelLabel, SidebarV2PanelLeaf, SidebarV2Provider, SidebarV2Rail, SidebarV2RailItem, SidebarV2RailLink, SidebarV2RailSpacer, SidebarV2Trigger, SidebarV2Workspace };
|