@kopexa/sidebar 17.1.73 → 17.2.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-3L2F566G.mjs +147 -0
- package/dist/chunk-CMYTESJM.mjs +274 -0
- package/dist/chunk-EIXUCY5M.mjs +458 -0
- package/dist/chunk-PZFEB2PM.mjs +109 -0
- package/dist/chunk-SDMGFB6V.mjs +14 -0
- package/dist/chunk-WA2NSEYE.mjs +41 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +984 -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 +147 -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 +504 -0
- package/dist/v2/components.mjs +32 -0
- package/dist/v2/context.d.mts +81 -0
- package/dist/v2/context.d.ts +81 -0
- package/dist/v2/context.js +167 -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 +691 -0
- package/dist/v2/from-config.mjs +11 -0
- package/dist/v2/index.d.mts +47 -0
- package/dist/v2/index.d.ts +47 -0
- package/dist/v2/index.js +1011 -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,504 @@
|
|
|
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/components.tsx
|
|
23
|
+
var components_exports = {};
|
|
24
|
+
__export(components_exports, {
|
|
25
|
+
SidebarV2Inset: () => SidebarV2Inset,
|
|
26
|
+
SidebarV2Panel: () => SidebarV2Panel,
|
|
27
|
+
SidebarV2PanelGroup: () => SidebarV2PanelGroup,
|
|
28
|
+
SidebarV2PanelItems: () => SidebarV2PanelItems,
|
|
29
|
+
SidebarV2PanelLabel: () => SidebarV2PanelLabel,
|
|
30
|
+
SidebarV2PanelLeaf: () => SidebarV2PanelLeaf,
|
|
31
|
+
SidebarV2Rail: () => SidebarV2Rail,
|
|
32
|
+
SidebarV2RailItem: () => SidebarV2RailItem,
|
|
33
|
+
SidebarV2RailLink: () => SidebarV2RailLink,
|
|
34
|
+
SidebarV2RailSpacer: () => SidebarV2RailSpacer,
|
|
35
|
+
SidebarV2Trigger: () => SidebarV2Trigger,
|
|
36
|
+
SidebarV2Workspace: () => SidebarV2Workspace
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(components_exports);
|
|
39
|
+
var import_button = require("@kopexa/button");
|
|
40
|
+
var import_icons = require("@kopexa/icons");
|
|
41
|
+
var import_shared_utils = require("@kopexa/shared-utils");
|
|
42
|
+
var import_theme = require("@kopexa/theme");
|
|
43
|
+
var import_tooltip2 = require("@kopexa/tooltip");
|
|
44
|
+
var import_react2 = require("react");
|
|
45
|
+
|
|
46
|
+
// src/v2/context.tsx
|
|
47
|
+
var import_react_utils = require("@kopexa/react-utils");
|
|
48
|
+
var import_tooltip = require("@kopexa/tooltip");
|
|
49
|
+
var import_use_is_mobile = require("@kopexa/use-is-mobile");
|
|
50
|
+
var import_react = require("react");
|
|
51
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
52
|
+
var PIN_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
53
|
+
var [Provider, useSidebarV2] = (0, import_react_utils.createContext)({
|
|
54
|
+
name: "SidebarV2Context",
|
|
55
|
+
errorMessage: "useSidebarV2 must be used within <SidebarV2> (the provider component)."
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// src/v2/types.ts
|
|
59
|
+
function panelItemHasChildren(item) {
|
|
60
|
+
return "children" in item && Array.isArray(item.children);
|
|
61
|
+
}
|
|
62
|
+
function panelItemIsSection(item) {
|
|
63
|
+
return "section" in item;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/v2/components.tsx
|
|
67
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
68
|
+
function SidebarV2Inset({
|
|
69
|
+
className,
|
|
70
|
+
...props
|
|
71
|
+
}) {
|
|
72
|
+
const { tone } = useSidebarV2();
|
|
73
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
74
|
+
"main",
|
|
75
|
+
{
|
|
76
|
+
"data-slot": "sidebar-v2-inset",
|
|
77
|
+
className: (0, import_shared_utils.cn)(
|
|
78
|
+
"relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background",
|
|
79
|
+
"md:m-2 md:rounded-xl md:shadow-sm",
|
|
80
|
+
// On a light surround the white card needs a hairline to define its
|
|
81
|
+
// edge; on the dark surround a border would read as a seam.
|
|
82
|
+
tone === "light" && "md:border md:border-border/70",
|
|
83
|
+
className
|
|
84
|
+
),
|
|
85
|
+
...props
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function SidebarV2Rail({ className, ...props }) {
|
|
90
|
+
const { tone } = useSidebarV2();
|
|
91
|
+
const light = tone === "light";
|
|
92
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
93
|
+
"nav",
|
|
94
|
+
{
|
|
95
|
+
"data-slot": "sidebar-v2-rail",
|
|
96
|
+
className: (0, import_shared_utils.cn)(
|
|
97
|
+
"flex w-(--kpx-rail-width) shrink-0 flex-col overflow-hidden bg-sidebar py-2 text-sidebar-foreground",
|
|
98
|
+
// Light tone: the dark rail floats as a rounded card on the light
|
|
99
|
+
// surround. Dark tone: full-height, flush to the edge.
|
|
100
|
+
light ? "m-2 rounded-2xl shadow-sm" : "h-full",
|
|
101
|
+
className
|
|
102
|
+
),
|
|
103
|
+
...props
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
function SidebarV2RailSpacer() {
|
|
108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { "aria-hidden": true, className: "flex-1" });
|
|
109
|
+
}
|
|
110
|
+
var SidebarV2Workspace = (0, import_react2.forwardRef)(({ name, role, logo, className, appearance = "rail", ...props }, ref) => {
|
|
111
|
+
if (appearance === "bar") {
|
|
112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
113
|
+
"button",
|
|
114
|
+
{
|
|
115
|
+
ref,
|
|
116
|
+
type: "button",
|
|
117
|
+
"data-slot": "sidebar-v2-workspace",
|
|
118
|
+
"aria-label": role ? `${name} \u2013 ${role}` : name,
|
|
119
|
+
className: (0, import_shared_utils.cn)(
|
|
120
|
+
"group/ws flex cursor-pointer items-center gap-2 rounded-lg py-1 pr-2 pl-1",
|
|
121
|
+
"outline-hidden ring-ring transition-colors hover:bg-foreground/5 focus-visible:ring-2",
|
|
122
|
+
className
|
|
123
|
+
),
|
|
124
|
+
...props,
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "flex size-7 shrink-0 items-center justify-center rounded-md bg-primary text-xs font-semibold text-primary-foreground", children: logo != null ? logo : name.charAt(0).toUpperCase() }),
|
|
127
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "flex min-w-0 flex-col text-left leading-tight", children: [
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "truncate text-sm font-semibold text-foreground", children: name }),
|
|
129
|
+
role && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "truncate text-xs text-muted-foreground", children: role })
|
|
130
|
+
] }),
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.ChevronDownIcon, { className: "size-4 shrink-0 text-muted-foreground" })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
137
|
+
"button",
|
|
138
|
+
{
|
|
139
|
+
ref,
|
|
140
|
+
type: "button",
|
|
141
|
+
"data-slot": "sidebar-v2-workspace",
|
|
142
|
+
"aria-label": role ? `${name} \u2013 ${role}` : name,
|
|
143
|
+
className: (0, import_shared_utils.cn)(
|
|
144
|
+
"group/ws relative mx-auto mt-1 flex cursor-pointer items-center justify-center rounded-lg p-1",
|
|
145
|
+
"outline-hidden ring-sidebar-ring transition-colors",
|
|
146
|
+
"hover:bg-sidebar-accent focus-visible:ring-2",
|
|
147
|
+
className
|
|
148
|
+
),
|
|
149
|
+
...props,
|
|
150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "relative flex size-9 shrink-0 items-center justify-center rounded-lg bg-primary text-sm font-semibold text-primary-foreground", children: [
|
|
151
|
+
logo != null ? logo : name.charAt(0).toUpperCase(),
|
|
152
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.ChevronDownIcon, { className: "absolute -right-1 -bottom-1 size-3.5 rounded-full bg-sidebar p-px text-sidebar-foreground/60" })
|
|
153
|
+
] })
|
|
154
|
+
}
|
|
155
|
+
);
|
|
156
|
+
});
|
|
157
|
+
SidebarV2Workspace.displayName = "SidebarV2Workspace";
|
|
158
|
+
function railButtonClasses(active) {
|
|
159
|
+
return (0, import_shared_utils.cn)(
|
|
160
|
+
"group/rail relative mx-auto flex size-11 shrink-0 cursor-pointer items-center justify-center rounded-xl",
|
|
161
|
+
"outline-hidden ring-sidebar-ring transition-colors",
|
|
162
|
+
"text-sidebar-foreground/85 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
163
|
+
"focus-visible:ring-2",
|
|
164
|
+
active && "bg-sidebar-accent text-sidebar-accent-foreground"
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
function RailInner({
|
|
168
|
+
icon: Icon,
|
|
169
|
+
active,
|
|
170
|
+
badge
|
|
171
|
+
}) {
|
|
172
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
173
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
174
|
+
"span",
|
|
175
|
+
{
|
|
176
|
+
"aria-hidden": true,
|
|
177
|
+
className: (0, import_shared_utils.cn)(
|
|
178
|
+
"absolute top-1/2 left-0 h-5 w-0.5 -translate-x-[0.6rem] -translate-y-1/2 rounded-r bg-primary transition-opacity",
|
|
179
|
+
active ? "opacity-100" : "opacity-0"
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Icon, { className: "size-5 shrink-0" }),
|
|
184
|
+
badge != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "absolute -top-0.5 -right-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-primary px-1 text-[0.5625rem] font-semibold text-primary-foreground", children: badge })
|
|
185
|
+
] });
|
|
186
|
+
}
|
|
187
|
+
function SidebarV2RailLink({
|
|
188
|
+
icon,
|
|
189
|
+
label,
|
|
190
|
+
href,
|
|
191
|
+
badge
|
|
192
|
+
}) {
|
|
193
|
+
const { renderLink, isActive, resetPanelSelection } = useSidebarV2();
|
|
194
|
+
const active = isActive(href);
|
|
195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip2.Tooltip, { content: label, side: "right", children: renderLink({
|
|
196
|
+
href,
|
|
197
|
+
className: railButtonClasses(active),
|
|
198
|
+
"data-active": active,
|
|
199
|
+
"aria-current": active ? "page" : void 0,
|
|
200
|
+
"aria-label": label,
|
|
201
|
+
// Navigating to a destination link clears any open panel preview,
|
|
202
|
+
// even when the route doesn't change (e.g. already on it).
|
|
203
|
+
onClick: resetPanelSelection,
|
|
204
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RailInner, { icon, label, active, badge })
|
|
205
|
+
}) });
|
|
206
|
+
}
|
|
207
|
+
function SidebarV2RailItem({
|
|
208
|
+
icon,
|
|
209
|
+
label,
|
|
210
|
+
active,
|
|
211
|
+
hasPanel,
|
|
212
|
+
onClick,
|
|
213
|
+
onMouseEnter,
|
|
214
|
+
onMouseLeave,
|
|
215
|
+
badge
|
|
216
|
+
}) {
|
|
217
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_tooltip2.Tooltip, { content: label, side: "right", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
218
|
+
"button",
|
|
219
|
+
{
|
|
220
|
+
type: "button",
|
|
221
|
+
"data-active": active,
|
|
222
|
+
"aria-label": label,
|
|
223
|
+
"aria-expanded": hasPanel ? active : void 0,
|
|
224
|
+
onClick,
|
|
225
|
+
onMouseEnter,
|
|
226
|
+
onMouseLeave,
|
|
227
|
+
className: railButtonClasses(active),
|
|
228
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(RailInner, { icon, label, active, badge })
|
|
229
|
+
}
|
|
230
|
+
) });
|
|
231
|
+
}
|
|
232
|
+
function SidebarV2Panel({
|
|
233
|
+
title,
|
|
234
|
+
subtitle,
|
|
235
|
+
floating,
|
|
236
|
+
hidePin,
|
|
237
|
+
action,
|
|
238
|
+
children,
|
|
239
|
+
className
|
|
240
|
+
}) {
|
|
241
|
+
const { togglePin, pinned, tone } = useSidebarV2();
|
|
242
|
+
const light = tone === "light";
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
"data-slot": "sidebar-v2-panel",
|
|
247
|
+
"data-floating": floating,
|
|
248
|
+
className: (0, import_shared_utils.cn)(
|
|
249
|
+
"flex h-full w-(--kpx-panel-width) shrink-0 flex-col",
|
|
250
|
+
// Surface. The flyout is a distinct floating card (white on light),
|
|
251
|
+
// so it reads as an overlay rather than a flat full-height slab.
|
|
252
|
+
floating ? light ? "bg-background text-foreground" : "bg-sidebar text-sidebar-foreground" : light ? "bg-muted text-foreground" : "bg-sidebar text-sidebar-foreground",
|
|
253
|
+
floating ? (
|
|
254
|
+
// Floating card: rounded, soft layered shadow, hairline ring.
|
|
255
|
+
(0, import_shared_utils.cn)(
|
|
256
|
+
"overflow-hidden rounded-2xl shadow-2xl shadow-black/20 ring-1",
|
|
257
|
+
light ? "ring-black/5" : "ring-white/10"
|
|
258
|
+
)
|
|
259
|
+
) : (
|
|
260
|
+
// Pinned: light blends into the surround (no border); dark keeps a
|
|
261
|
+
// hairline against the rail.
|
|
262
|
+
light ? "" : "border-l border-sidebar-border/40"
|
|
263
|
+
),
|
|
264
|
+
className
|
|
265
|
+
),
|
|
266
|
+
children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "flex items-start gap-2 px-3 pt-3 pb-1.5", children: [
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "min-w-0 flex-1", children: [
|
|
269
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
270
|
+
"div",
|
|
271
|
+
{
|
|
272
|
+
className: (0, import_shared_utils.cn)(
|
|
273
|
+
"truncate text-sm font-semibold",
|
|
274
|
+
light ? "text-foreground" : "text-sidebar-foreground"
|
|
275
|
+
),
|
|
276
|
+
children: title
|
|
277
|
+
}
|
|
278
|
+
),
|
|
279
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
280
|
+
"div",
|
|
281
|
+
{
|
|
282
|
+
className: (0, import_shared_utils.cn)(
|
|
283
|
+
"truncate text-xs",
|
|
284
|
+
light ? "text-muted-foreground" : "text-sidebar-foreground/70"
|
|
285
|
+
),
|
|
286
|
+
children: subtitle
|
|
287
|
+
}
|
|
288
|
+
)
|
|
289
|
+
] }),
|
|
290
|
+
action != null ? action : !hidePin && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
291
|
+
import_tooltip2.Tooltip,
|
|
292
|
+
{
|
|
293
|
+
content: pinned ? "Panel l\xF6sen" : "Panel anheften",
|
|
294
|
+
side: "bottom",
|
|
295
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
296
|
+
import_button.IconButton,
|
|
297
|
+
{
|
|
298
|
+
variant: "ghost",
|
|
299
|
+
size: "sm",
|
|
300
|
+
"aria-label": pinned ? "Panel l\xF6sen" : "Panel anheften",
|
|
301
|
+
onClick: togglePin,
|
|
302
|
+
className: (0, import_shared_utils.cn)(
|
|
303
|
+
"-mr-1 shrink-0",
|
|
304
|
+
light ? "text-muted-foreground hover:bg-foreground/5 hover:text-foreground" : "text-sidebar-foreground/60 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground"
|
|
305
|
+
),
|
|
306
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.PanelLeftIcon, { className: "size-4" })
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
] }),
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "flex min-h-0 flex-1 flex-col gap-0.5 overflow-auto p-2", children })
|
|
313
|
+
]
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
function panelRowLight(active) {
|
|
318
|
+
return (0, import_shared_utils.cn)(
|
|
319
|
+
"flex h-8 w-full items-center gap-2.5 rounded-md px-2 text-sm outline-hidden ring-ring transition-colors focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
320
|
+
active ? "bg-primary/10 font-medium text-primary" : "text-foreground/80 hover:bg-foreground/5"
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
function SidebarV2PanelLabel({
|
|
324
|
+
className,
|
|
325
|
+
...props
|
|
326
|
+
}) {
|
|
327
|
+
const { tone } = useSidebarV2();
|
|
328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
329
|
+
"div",
|
|
330
|
+
{
|
|
331
|
+
"data-slot": "sidebar-v2-panel-label",
|
|
332
|
+
className: (0, import_shared_utils.cn)(
|
|
333
|
+
"px-2 pt-3 pb-1 text-[0.6875rem] font-medium uppercase tracking-wide",
|
|
334
|
+
tone === "light" ? "text-muted-foreground" : "text-sidebar-foreground/50",
|
|
335
|
+
className
|
|
336
|
+
),
|
|
337
|
+
...props
|
|
338
|
+
}
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
function SidebarV2PanelLeaf({
|
|
342
|
+
item,
|
|
343
|
+
active: activeProp
|
|
344
|
+
}) {
|
|
345
|
+
const { renderLink, isActive, tone } = useSidebarV2();
|
|
346
|
+
const light = tone === "light";
|
|
347
|
+
const Icon = item.icon;
|
|
348
|
+
const active = activeProp != null ? activeProp : isActive(item.href);
|
|
349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: renderLink({
|
|
350
|
+
href: item.href,
|
|
351
|
+
"data-active": active,
|
|
352
|
+
"aria-current": active ? "page" : void 0,
|
|
353
|
+
className: light ? panelRowLight(active) : (0, import_theme.sidebarMenuButton)({ size: "md" }),
|
|
354
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
355
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
356
|
+
Icon,
|
|
357
|
+
{
|
|
358
|
+
className: (0, import_shared_utils.cn)(
|
|
359
|
+
light ? active ? void 0 : "text-muted-foreground" : "text-sidebar-foreground/75"
|
|
360
|
+
)
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "min-w-0 flex-1 truncate", children: item.label }),
|
|
364
|
+
item.badge != null && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
365
|
+
"span",
|
|
366
|
+
{
|
|
367
|
+
className: (0, import_shared_utils.cn)(
|
|
368
|
+
"ml-auto rounded-full px-1.5 text-[0.625rem] font-medium",
|
|
369
|
+
light ? "bg-foreground/10 text-foreground/70" : "bg-sidebar-accent text-sidebar-accent-foreground"
|
|
370
|
+
),
|
|
371
|
+
children: item.badge
|
|
372
|
+
}
|
|
373
|
+
)
|
|
374
|
+
] })
|
|
375
|
+
}) });
|
|
376
|
+
}
|
|
377
|
+
function SidebarV2PanelGroup({
|
|
378
|
+
item
|
|
379
|
+
}) {
|
|
380
|
+
var _a;
|
|
381
|
+
const { openGroup, toggleGroup, activeHref, renderLink, tone } = useSidebarV2();
|
|
382
|
+
const light = tone === "light";
|
|
383
|
+
const Icon = item.icon;
|
|
384
|
+
const key = (_a = item.value) != null ? _a : item.label;
|
|
385
|
+
let bestChildHref = null;
|
|
386
|
+
let bestLen = -1;
|
|
387
|
+
for (const c of item.children) {
|
|
388
|
+
if (activeHref === c.href) {
|
|
389
|
+
bestChildHref = c.href;
|
|
390
|
+
break;
|
|
391
|
+
}
|
|
392
|
+
if (activeHref.startsWith(`${c.href}/`) && c.href.length > bestLen) {
|
|
393
|
+
bestChildHref = c.href;
|
|
394
|
+
bestLen = c.href.length;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
const containsActive = bestChildHref !== null;
|
|
398
|
+
const open = openGroup === key || openGroup === null && containsActive;
|
|
399
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
401
|
+
"button",
|
|
402
|
+
{
|
|
403
|
+
type: "button",
|
|
404
|
+
"data-state": open ? "open" : "closed",
|
|
405
|
+
"aria-expanded": open,
|
|
406
|
+
onClick: () => toggleGroup(key),
|
|
407
|
+
className: (0, import_shared_utils.cn)(
|
|
408
|
+
light ? panelRowLight(false) : (0, import_theme.sidebarMenuButton)({ size: "md" }),
|
|
409
|
+
"cursor-pointer",
|
|
410
|
+
containsActive && (light ? "font-medium text-foreground" : "font-medium")
|
|
411
|
+
),
|
|
412
|
+
children: [
|
|
413
|
+
Icon && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
414
|
+
Icon,
|
|
415
|
+
{
|
|
416
|
+
className: light ? "text-muted-foreground" : "text-sidebar-foreground/75"
|
|
417
|
+
}
|
|
418
|
+
),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "min-w-0 flex-1 truncate text-left", children: item.label }),
|
|
420
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
421
|
+
import_icons.ChevronRightIcon,
|
|
422
|
+
{
|
|
423
|
+
className: (0, import_shared_utils.cn)(
|
|
424
|
+
"size-3.5! shrink-0 transition-transform",
|
|
425
|
+
light ? "text-muted-foreground" : "text-sidebar-foreground/60",
|
|
426
|
+
open && "rotate-90"
|
|
427
|
+
)
|
|
428
|
+
}
|
|
429
|
+
)
|
|
430
|
+
]
|
|
431
|
+
}
|
|
432
|
+
),
|
|
433
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
434
|
+
"div",
|
|
435
|
+
{
|
|
436
|
+
className: (0, import_shared_utils.cn)(
|
|
437
|
+
"my-0.5 ml-[1.05rem] flex flex-col border-l pl-3",
|
|
438
|
+
light ? "border-border" : "border-sidebar-border"
|
|
439
|
+
),
|
|
440
|
+
children: item.children.map((child) => {
|
|
441
|
+
const active = child.href === bestChildHref;
|
|
442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: renderLink({
|
|
443
|
+
href: child.href,
|
|
444
|
+
"data-active": active,
|
|
445
|
+
"aria-current": active ? "page" : void 0,
|
|
446
|
+
className: (0, import_shared_utils.cn)(
|
|
447
|
+
"relative block rounded-md px-2 py-1.5 text-[0.8125rem] outline-hidden transition-colors focus-visible:ring-2",
|
|
448
|
+
"before:absolute before:top-1/2 before:-left-3 before:h-px before:w-2.5",
|
|
449
|
+
light ? active ? "bg-primary/10 font-medium text-primary ring-ring before:bg-primary" : "text-muted-foreground ring-ring hover:bg-foreground/5 hover:text-foreground before:bg-border" : active ? "bg-sidebar-accent font-medium text-sidebar-accent-foreground ring-sidebar-ring before:bg-primary" : "text-sidebar-foreground/80 ring-sidebar-ring hover:bg-sidebar-accent/60 hover:text-sidebar-accent-foreground before:bg-sidebar-foreground/30"
|
|
450
|
+
),
|
|
451
|
+
children: child.label
|
|
452
|
+
}) }, child.href);
|
|
453
|
+
})
|
|
454
|
+
}
|
|
455
|
+
)
|
|
456
|
+
] });
|
|
457
|
+
}
|
|
458
|
+
function SidebarV2PanelItems({
|
|
459
|
+
items
|
|
460
|
+
}) {
|
|
461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: items.map((item, idx) => {
|
|
462
|
+
var _a;
|
|
463
|
+
if (panelItemIsSection(item)) {
|
|
464
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarV2PanelLabel, { children: item.section }, `section-${item.section}-${idx}`);
|
|
465
|
+
}
|
|
466
|
+
if (panelItemHasChildren(item)) {
|
|
467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarV2PanelGroup, { item }, (_a = item.value) != null ? _a : item.label);
|
|
468
|
+
}
|
|
469
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SidebarV2PanelLeaf, { item }, item.href);
|
|
470
|
+
}) });
|
|
471
|
+
}
|
|
472
|
+
function SidebarV2Trigger({
|
|
473
|
+
className,
|
|
474
|
+
...props
|
|
475
|
+
}) {
|
|
476
|
+
const { setDrawerOpen, drawerOpen } = useSidebarV2();
|
|
477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
478
|
+
import_button.IconButton,
|
|
479
|
+
{
|
|
480
|
+
variant: "ghost",
|
|
481
|
+
size: "md",
|
|
482
|
+
"aria-label": "Navigation \xF6ffnen",
|
|
483
|
+
onClick: () => setDrawerOpen(!drawerOpen),
|
|
484
|
+
className,
|
|
485
|
+
...props,
|
|
486
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons.PanelLeftIcon, { className: "size-5" })
|
|
487
|
+
}
|
|
488
|
+
);
|
|
489
|
+
}
|
|
490
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
491
|
+
0 && (module.exports = {
|
|
492
|
+
SidebarV2Inset,
|
|
493
|
+
SidebarV2Panel,
|
|
494
|
+
SidebarV2PanelGroup,
|
|
495
|
+
SidebarV2PanelItems,
|
|
496
|
+
SidebarV2PanelLabel,
|
|
497
|
+
SidebarV2PanelLeaf,
|
|
498
|
+
SidebarV2Rail,
|
|
499
|
+
SidebarV2RailItem,
|
|
500
|
+
SidebarV2RailLink,
|
|
501
|
+
SidebarV2RailSpacer,
|
|
502
|
+
SidebarV2Trigger,
|
|
503
|
+
SidebarV2Workspace
|
|
504
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
import {
|
|
4
|
+
SidebarV2Inset,
|
|
5
|
+
SidebarV2Panel,
|
|
6
|
+
SidebarV2PanelGroup,
|
|
7
|
+
SidebarV2PanelItems,
|
|
8
|
+
SidebarV2PanelLabel,
|
|
9
|
+
SidebarV2PanelLeaf,
|
|
10
|
+
SidebarV2Rail,
|
|
11
|
+
SidebarV2RailItem,
|
|
12
|
+
SidebarV2RailLink,
|
|
13
|
+
SidebarV2RailSpacer,
|
|
14
|
+
SidebarV2Trigger,
|
|
15
|
+
SidebarV2Workspace
|
|
16
|
+
} from "../chunk-EIXUCY5M.mjs";
|
|
17
|
+
import "../chunk-SDMGFB6V.mjs";
|
|
18
|
+
import "../chunk-3L2F566G.mjs";
|
|
19
|
+
export {
|
|
20
|
+
SidebarV2Inset,
|
|
21
|
+
SidebarV2Panel,
|
|
22
|
+
SidebarV2PanelGroup,
|
|
23
|
+
SidebarV2PanelItems,
|
|
24
|
+
SidebarV2PanelLabel,
|
|
25
|
+
SidebarV2PanelLeaf,
|
|
26
|
+
SidebarV2Rail,
|
|
27
|
+
SidebarV2RailItem,
|
|
28
|
+
SidebarV2RailLink,
|
|
29
|
+
SidebarV2RailSpacer,
|
|
30
|
+
SidebarV2Trigger,
|
|
31
|
+
SidebarV2Workspace
|
|
32
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { SidebarV2LinkProps } from './types.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Visual tone of the panel + content surround. The rail stays dark in both.
|
|
7
|
+
* - "dark": panel + surround share the dark sidebar surface (default).
|
|
8
|
+
* - "light": panel + surround go light (Gmail-style) against the dark rail.
|
|
9
|
+
*/
|
|
10
|
+
type SidebarV2Tone = "dark" | "light";
|
|
11
|
+
/** How the flyout opens when unpinned. */
|
|
12
|
+
type SidebarV2FlyoutTrigger = "click" | "hover";
|
|
13
|
+
type SidebarV2ContextValue = {
|
|
14
|
+
/** Visual tone of the panel + surround. */
|
|
15
|
+
tone: SidebarV2Tone;
|
|
16
|
+
/** Pinned = persistent two-column. Unpinned = rail only + flyout panel. */
|
|
17
|
+
pinned: boolean;
|
|
18
|
+
togglePin: () => void;
|
|
19
|
+
setPinned: (v: boolean) => void;
|
|
20
|
+
/** Pinned-mode preview: rail value the user selected to show without navigating. */
|
|
21
|
+
selectedRail: string | null;
|
|
22
|
+
setSelectedRail: (value: string | null) => void;
|
|
23
|
+
/** How the flyout opens when unpinned: "click" (default) or "hover". */
|
|
24
|
+
flyoutTrigger: SidebarV2FlyoutTrigger;
|
|
25
|
+
/** Rail value whose panel is shown as a flyout (unpinned only). null = closed. */
|
|
26
|
+
flyoutValue: string | null;
|
|
27
|
+
/** Toggle the flyout for a value (click semantics). */
|
|
28
|
+
openFlyout: (value: string) => void;
|
|
29
|
+
/** Set the flyout to a specific value or null (hover semantics, no toggle). */
|
|
30
|
+
setFlyout: (value: string | null) => void;
|
|
31
|
+
closeFlyout: () => void;
|
|
32
|
+
/** Clear any open/previewed panel (selection + flyout). */
|
|
33
|
+
resetPanelSelection: () => void;
|
|
34
|
+
/** Accordion: the single open L2 group key (auto-collapse). */
|
|
35
|
+
openGroup: string | null;
|
|
36
|
+
toggleGroup: (key: string) => void;
|
|
37
|
+
setOpenGroup: (key: string | null) => void;
|
|
38
|
+
/** Current route, supplied by host. Drives active state. */
|
|
39
|
+
activeHref: string;
|
|
40
|
+
/** True when href is the active route (exact or nested). */
|
|
41
|
+
isActive: (href: string) => boolean;
|
|
42
|
+
/** Host link renderer (e.g. next/link). */
|
|
43
|
+
renderLink: (props: SidebarV2LinkProps) => ReactNode;
|
|
44
|
+
isMobile: boolean;
|
|
45
|
+
drawerOpen: boolean;
|
|
46
|
+
setDrawerOpen: (v: boolean) => void;
|
|
47
|
+
/** DOM host of the panel zone — target for page-supplied panel content. */
|
|
48
|
+
panelHost: HTMLElement | null;
|
|
49
|
+
setPanelHost: (el: HTMLElement | null) => void;
|
|
50
|
+
/** True while a page/sub-layout is overriding the nav panel. */
|
|
51
|
+
panelOverrideActive: boolean;
|
|
52
|
+
/** Register a panel override; returns the unregister fn (call on unmount). */
|
|
53
|
+
registerPanelOverride: () => () => void;
|
|
54
|
+
/**
|
|
55
|
+
* True when the user is explicitly previewing nav (selected a rail domain in
|
|
56
|
+
* pinned mode, or opened a flyout). This takes precedence over a page override
|
|
57
|
+
* so nav stays reachable even on a route that supplies its own panel.
|
|
58
|
+
*/
|
|
59
|
+
navPreviewActive: boolean;
|
|
60
|
+
};
|
|
61
|
+
declare const useSidebarV2: () => SidebarV2ContextValue;
|
|
62
|
+
|
|
63
|
+
type SidebarV2ProviderProps = {
|
|
64
|
+
children: ReactNode;
|
|
65
|
+
/** Visual tone of the panel + surround (rail stays dark). Defaults to "dark". */
|
|
66
|
+
tone?: SidebarV2Tone;
|
|
67
|
+
/** How the flyout opens when unpinned: "click" (default) or "hover". */
|
|
68
|
+
flyoutTrigger?: SidebarV2FlyoutTrigger;
|
|
69
|
+
/** Current route path. Required for active-state derivation. */
|
|
70
|
+
activeHref: string;
|
|
71
|
+
/** Render function for navigational links. Defaults to a plain <a>. */
|
|
72
|
+
renderLink?: (props: SidebarV2LinkProps) => ReactNode;
|
|
73
|
+
/** Controlled pin state. */
|
|
74
|
+
pinned?: boolean;
|
|
75
|
+
onPinnedChange?: (v: boolean) => void;
|
|
76
|
+
/** Initial pin state when uncontrolled. */
|
|
77
|
+
defaultPinned?: boolean;
|
|
78
|
+
};
|
|
79
|
+
declare function SidebarV2Provider({ children, tone, flyoutTrigger, activeHref, renderLink, pinned: pinnedProp, onPinnedChange, defaultPinned, }: SidebarV2ProviderProps): react_jsx_runtime.JSX.Element;
|
|
80
|
+
|
|
81
|
+
export { type SidebarV2ContextValue, type SidebarV2FlyoutTrigger, SidebarV2Provider, type SidebarV2ProviderProps, type SidebarV2Tone, useSidebarV2 };
|