@mastra/playground-ui 55.0.0 → 55.1.0-alpha.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/components/DataPanel.cjs.js +1 -1
- package/dist/components/DataPanel.es.js +1 -1
- package/dist/components/MainSidebar.cjs.js +26 -737
- package/dist/components/MainSidebar.cjs.js.map +1 -1
- package/dist/components/MainSidebar.es.js +4 -714
- package/dist/components/MainSidebar.es.js.map +1 -1
- package/dist/{data-panel-tSErqolu.cjs → data-panel-Bzws5n5c.cjs} +25 -8
- package/dist/data-panel-Bzws5n5c.cjs.map +1 -0
- package/dist/{data-panel-5iuux0r_.js → data-panel-C-H4tAEw.js} +25 -8
- package/dist/data-panel-C-H4tAEw.js.map +1 -0
- package/dist/domains/traces/components/span-data-panel-view.cjs.js +3 -2
- package/dist/domains/traces/components/span-data-panel-view.cjs.js.map +1 -1
- package/dist/domains/traces/components/span-data-panel-view.es.js +3 -2
- package/dist/domains/traces/components/span-data-panel-view.es.js.map +1 -1
- package/dist/domains/traces/components/thread-trace/thread-trace-details.cjs.js +1 -1
- package/dist/domains/traces/components/thread-trace/thread-trace-details.es.js +1 -1
- package/dist/domains/traces/components/trace-data-panel-view.cjs.js +12 -11
- package/dist/domains/traces/components/trace-data-panel-view.cjs.js.map +1 -1
- package/dist/domains/traces/components/trace-data-panel-view.es.js +13 -12
- package/dist/domains/traces/components/trace-data-panel-view.es.js.map +1 -1
- package/dist/domains/traces/components/trace-span-timeline.cjs.js +1 -1
- package/dist/domains/traces/components/trace-span-timeline.cjs.js.map +1 -1
- package/dist/domains/traces/components/trace-span-timeline.es.js +1 -1
- package/dist/domains/traces/components/trace-span-timeline.es.js.map +1 -1
- package/dist/domains/traces/components/trace-span-tree.cjs.js +1 -1
- package/dist/domains/traces/components/trace-span-tree.cjs.js.map +1 -1
- package/dist/domains/traces/components/trace-span-tree.es.js +1 -1
- package/dist/domains/traces/components/trace-span-tree.es.js.map +1 -1
- package/dist/main-sidebar-link-active-BK4RR4Az.js +719 -0
- package/dist/main-sidebar-link-active-BK4RR4Az.js.map +1 -0
- package/dist/main-sidebar-link-active-DLGDYeTJ.cjs +736 -0
- package/dist/main-sidebar-link-active-DLGDYeTJ.cjs.map +1 -0
- package/dist/new/sidebar.cjs.js +457 -0
- package/dist/new/sidebar.cjs.js.map +1 -0
- package/dist/new/sidebar.d.ts +2 -0
- package/dist/new/sidebar.es.js +440 -0
- package/dist/new/sidebar.es.js.map +1 -0
- package/dist/src/ds/components/DataPanel/data-panel-close-button.d.ts +3 -1
- package/dist/src/ds/components/DataPanel/data-panel-content.d.ts +3 -1
- package/dist/src/ds/components/DataPanel/data-panel-next-prev-nav.d.ts +3 -1
- package/dist/src/ds/new/sidebar/index.d.ts +12 -0
- package/dist/src/ds/new/sidebar/sidebar-new-brand.d.ts +6 -0
- package/dist/src/ds/new/sidebar/sidebar-new-footer.d.ts +3 -0
- package/dist/src/ds/new/sidebar/sidebar-new-header.d.ts +3 -0
- package/dist/src/ds/new/sidebar/sidebar-new-meter.d.ts +34 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-header.d.ts +11 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-stack-context.d.ts +8 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-stack-page-classes.d.ts +1 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-stack-root-view.d.ts +3 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-stack-root.d.ts +7 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-stack-view.d.ts +9 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav-stack.d.ts +10 -0
- package/dist/src/ds/new/sidebar/sidebar-new-nav.d.ts +3 -0
- package/dist/src/ds/new/sidebar/sidebar-new-root.d.ts +5 -0
- package/dist/src/ds/new/sidebar/sidebar-new-section-link.d.ts +8 -0
- package/dist/src/ds/new/sidebar/sidebar-new-sections.d.ts +8 -0
- package/dist/src/ds/new/sidebar/sidebar-new-trigger.d.ts +3 -0
- package/dist/src/ds/new/sidebar/sidebar-new.d.ts +36 -0
- package/dist/src/ds/new/sidebar/sidebar-new.stories.d.ts +6 -0
- package/dist/style.css +118 -0
- package/package.json +13 -7
- package/theme.css +48 -0
- package/dist/data-panel-5iuux0r_.js.map +0 -1
- package/dist/data-panel-tSErqolu.cjs.map +0 -1
|
@@ -4,88 +4,14 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
4
4
|
|
|
5
5
|
const jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
const utils_cn = require('../cn-DnbTIGXa.cjs');
|
|
7
|
-
const
|
|
8
|
-
const React = require('react');
|
|
9
|
-
const scrollArea = require('../scroll-area-DK4w_mMg.cjs');
|
|
7
|
+
const mainSidebarLinkActive = require('../main-sidebar-link-active-DLGDYeTJ.cjs');
|
|
10
8
|
const reactVisuallyHidden = require('@radix-ui/react-visually-hidden');
|
|
11
|
-
const
|
|
12
|
-
const tooltip = require('../tooltip-BsSNtmxl.cjs');
|
|
13
|
-
const drawer = require('../drawer-Bq7j_MiM.cjs');
|
|
14
|
-
const primitives_resizeHandleIndicator = require('../primitives/resize-handle-indicator.cjs.js');
|
|
15
|
-
const kbd = require('../kbd-BaoBQUlL.cjs');
|
|
9
|
+
const React = require('react');
|
|
16
10
|
|
|
17
11
|
function MainSidebarBottom({ className, children, ...props }) {
|
|
18
12
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: utils_cn.cn("mt-auto", className), ...props, children });
|
|
19
13
|
}
|
|
20
14
|
|
|
21
|
-
const MainSidebarContext = React.createContext(null);
|
|
22
|
-
const MobileDrawerContext = React.createContext(null);
|
|
23
|
-
function useMaybeSidebarState() {
|
|
24
|
-
return React.useContext(MainSidebarContext);
|
|
25
|
-
}
|
|
26
|
-
function useMainSidebar() {
|
|
27
|
-
const ctx = React.useContext(MainSidebarContext);
|
|
28
|
-
const drawer = React.useContext(MobileDrawerContext);
|
|
29
|
-
if (!ctx || !drawer) {
|
|
30
|
-
throw new Error("useMainSidebar must be used within a MainSidebarProvider.");
|
|
31
|
-
}
|
|
32
|
-
return { ...ctx, ...drawer };
|
|
33
|
-
}
|
|
34
|
-
function useMaybeSidebar() {
|
|
35
|
-
const ctx = React.useContext(MainSidebarContext);
|
|
36
|
-
const drawer = React.useContext(MobileDrawerContext);
|
|
37
|
-
if (!ctx || !drawer) return null;
|
|
38
|
-
return { ...ctx, ...drawer };
|
|
39
|
-
}
|
|
40
|
-
function useMobileDrawer() {
|
|
41
|
-
const drawer = React.useContext(MobileDrawerContext);
|
|
42
|
-
if (!drawer) throw new Error("useMobileDrawer must be used within a MainSidebarProvider.");
|
|
43
|
-
return drawer;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function MainSidebarMobileTrigger({
|
|
47
|
-
className,
|
|
48
|
-
icon,
|
|
49
|
-
"aria-label": ariaLabel = "Open navigation menu",
|
|
50
|
-
onClick,
|
|
51
|
-
...props
|
|
52
|
-
}) {
|
|
53
|
-
const { isMobile, setOpenMobile } = useMainSidebar();
|
|
54
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
55
|
-
"button",
|
|
56
|
-
{
|
|
57
|
-
type: "button",
|
|
58
|
-
"aria-label": ariaLabel,
|
|
59
|
-
"aria-hidden": !isMobile,
|
|
60
|
-
tabIndex: isMobile ? 0 : -1,
|
|
61
|
-
"data-mobile-only": true,
|
|
62
|
-
...props,
|
|
63
|
-
onClick: (event) => {
|
|
64
|
-
onClick?.(event);
|
|
65
|
-
if (!event.defaultPrevented) setOpenMobile(true);
|
|
66
|
-
},
|
|
67
|
-
className: utils_cn.cn(
|
|
68
|
-
"inline-flex size-10 items-center justify-center rounded-md",
|
|
69
|
-
// compound selector, not `in-*` — its `:where()` ties with a consumer's later `.inline-flex`
|
|
70
|
-
"[[data-sidebar-mobile='false']_&]:hidden",
|
|
71
|
-
"text-neutral4 hover:bg-sidebar-nav-hover hover:text-neutral6",
|
|
72
|
-
"focus-visible:ring-1 focus-visible:ring-accent1 focus-visible:outline-hidden",
|
|
73
|
-
className
|
|
74
|
-
),
|
|
75
|
-
children: icon ?? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MenuIcon, { className: "size-5" })
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function MainSidebarNav({
|
|
81
|
-
"aria-label": ariaLabel = "Main",
|
|
82
|
-
children,
|
|
83
|
-
className,
|
|
84
|
-
...props
|
|
85
|
-
}) {
|
|
86
|
-
return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": ariaLabel, className: utils_cn.cn("flex min-h-0 flex-1 flex-col", className), ...props, children: /* @__PURE__ */ jsxRuntime.jsx(scrollArea.ScrollArea, { className: "min-h-0 flex-1", viewPortClassName: "px-0.5", children }) });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
15
|
function MainSidebarNavHeader({
|
|
90
16
|
children,
|
|
91
17
|
className,
|
|
@@ -95,7 +21,7 @@ function MainSidebarNavHeader({
|
|
|
95
21
|
LinkComponent: LinkProp,
|
|
96
22
|
...props
|
|
97
23
|
}) {
|
|
98
|
-
const ctx = useMaybeSidebarState();
|
|
24
|
+
const ctx = mainSidebarLinkActive.useMaybeSidebarState();
|
|
99
25
|
const state = stateProp ?? ctx?.state ?? "default";
|
|
100
26
|
const isMobile = ctx?.isMobile ?? false;
|
|
101
27
|
const Link = LinkProp ?? ctx?.LinkComponent ?? "a";
|
|
@@ -126,398 +52,18 @@ function MainSidebarNavHeader({
|
|
|
126
52
|
] }) });
|
|
127
53
|
}
|
|
128
54
|
|
|
129
|
-
function MainSidebarNavLabel({ children, className, state: stateProp, ...rest }) {
|
|
130
|
-
const ctx = useMaybeSidebarState();
|
|
131
|
-
const state = stateProp ?? ctx?.state ?? "default";
|
|
132
|
-
if (state === "collapsed") {
|
|
133
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden, { children });
|
|
134
|
-
}
|
|
135
|
-
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...rest, className: utils_cn.cn("min-w-0 flex-1 truncate text-left font-[450]", className), children });
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const navItemVariants = index.cva("flex min-w-0 cursor-pointer items-center rounded-lg whitespace-nowrap", {
|
|
139
|
-
variants: {
|
|
140
|
-
size: {
|
|
141
|
-
default: "h-8 text-ui-md",
|
|
142
|
-
sm: "h-7 text-ui-sm",
|
|
143
|
-
lg: "h-9 text-ui-md"
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
defaultVariants: {
|
|
147
|
-
size: "sm"
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
const nestedExpandedItemClasses = (level) => {
|
|
151
|
-
if (level <= 0) return "w-full gap-2 py-1 px-3 justify-start";
|
|
152
|
-
if (level === 1) return "w-full gap-2 py-1 pr-3 pl-8 justify-start text-ui-sm h-8";
|
|
153
|
-
if (level === 2) return "w-full gap-2 py-1 pr-3 pl-10 justify-start text-ui-sm h-8";
|
|
154
|
-
return "w-full gap-2 py-1 pr-3 pl-12 justify-start text-ui-sm h-8";
|
|
155
|
-
};
|
|
156
|
-
const idleSurface = utils_cn.cn(
|
|
157
|
-
"rounded-lg text-neutral3 [&_svg]:text-neutral3/70",
|
|
158
|
-
"hover:bg-sidebar-nav-hover hover:text-neutral6 [&:hover_svg]:text-neutral5"
|
|
159
|
-
);
|
|
160
|
-
const activeSurface = "bg-sidebar-nav-active text-neutral6 hover:bg-sidebar-nav-active hover:text-neutral6 [&_svg]:text-neutral6 [&:hover_svg]:text-neutral6";
|
|
161
|
-
const featuredSurface = utils_cn.cn(
|
|
162
|
-
"my-2 border border-accent1/30 bg-accent1Dark text-accent1 hover:bg-accent1Darker hover:text-accent1",
|
|
163
|
-
"dark:border-transparent dark:bg-accent1 dark:text-black dark:hover:bg-accent1/90 dark:hover:text-black",
|
|
164
|
-
"[&_svg]:text-accent1 dark:[&_svg]:text-black/75 [&:hover_svg]:text-accent1 dark:[&:hover_svg]:text-black"
|
|
165
|
-
);
|
|
166
|
-
const navRowSurfaceClasses = ({ isActive, isFeatured }) => utils_cn.cn(idleSurface, isActive && activeSurface, isFeatured && featuredSurface);
|
|
167
|
-
const navItemLayoutClasses = ({ isCollapsed, level = 0, size }) => utils_cn.cn(
|
|
168
|
-
navItemVariants({ size }),
|
|
169
|
-
"transition-all duration-normal ease-out-custom motion-reduce:transition-none",
|
|
170
|
-
"[&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:transition-colors [&_svg]:duration-normal motion-reduce:[&_svg]:transition-none",
|
|
171
|
-
"focus-visible:shadow-focus-ring focus-visible:ring-1 focus-visible:ring-accent1 focus-visible:outline-hidden",
|
|
172
|
-
!isCollapsed && nestedExpandedItemClasses(level),
|
|
173
|
-
isCollapsed && "w-full justify-center p-0"
|
|
174
|
-
);
|
|
175
|
-
const navItemClasses = ({ isActive, isCollapsed, isFeatured, level, size } = {}) => utils_cn.cn(
|
|
176
|
-
navItemLayoutClasses({ isCollapsed, level, size }),
|
|
177
|
-
navRowSurfaceClasses({ isActive, isFeatured }),
|
|
178
|
-
isCollapsed && !isActive && "[&_svg]:text-neutral3"
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
function MainSidebarNavLink({
|
|
182
|
-
link,
|
|
183
|
-
state: stateProp,
|
|
184
|
-
children,
|
|
185
|
-
isActive,
|
|
186
|
-
size,
|
|
187
|
-
render,
|
|
188
|
-
action,
|
|
189
|
-
className,
|
|
190
|
-
LinkComponent: LinkProp,
|
|
191
|
-
level: levelProp,
|
|
192
|
-
subItems,
|
|
193
|
-
asChild = false,
|
|
194
|
-
...props
|
|
195
|
-
}) {
|
|
196
|
-
if (render && asChild) {
|
|
197
|
-
throw new Error("MainSidebarNavLink accepts either `render` or `asChild`, not both.");
|
|
198
|
-
}
|
|
199
|
-
const ctx = useMaybeSidebarState();
|
|
200
|
-
const state = stateProp ?? ctx?.state ?? "default";
|
|
201
|
-
const Link = LinkProp ?? ctx?.LinkComponent ?? "a";
|
|
202
|
-
const isCollapsed = state === "collapsed";
|
|
203
|
-
const isFeatured = link?.variant === "featured";
|
|
204
|
-
const level = levelProp ?? (link?.indent ? 1 : 0);
|
|
205
|
-
const rowAction = isCollapsed ? void 0 : action;
|
|
206
|
-
const itemClassName = rowAction ? utils_cn.cn(navItemLayoutClasses({ level, size }), "flex-1 pr-1") : navItemClasses({ isActive, isCollapsed, isFeatured, level, size });
|
|
207
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("li", { ...props, className: utils_cn.cn("relative flex min-w-0 flex-col", className), children: [
|
|
208
|
-
/* @__PURE__ */ jsxRuntime.jsx(NavRowBody, { action: rowAction, surfaceClassName: navRowSurfaceClasses({ isActive, isFeatured }), children: /* @__PURE__ */ jsxRuntime.jsx(NavRowTooltip, { label: navTooltipLabel(link, isCollapsed), children: navInteractiveRow({ render, asChild, children, link, state, Link, className: itemClassName }) }) }),
|
|
209
|
-
!isCollapsed && subItems
|
|
210
|
-
] });
|
|
211
|
-
}
|
|
212
|
-
function navInteractiveRow({
|
|
213
|
-
render,
|
|
214
|
-
asChild,
|
|
215
|
-
children,
|
|
216
|
-
link,
|
|
217
|
-
state,
|
|
218
|
-
Link,
|
|
219
|
-
className
|
|
220
|
-
}) {
|
|
221
|
-
if (render) return React.cloneElement(render, { className: utils_cn.cn(className, render.props.className) });
|
|
222
|
-
if (asChild) {
|
|
223
|
-
if (!React.isValidElement(children)) {
|
|
224
|
-
throw new Error(
|
|
225
|
-
"MainSidebarNavLink requires a valid React element child when `asChild` is true so it can apply `SlottedNavChildProps` and merge `itemClassName`."
|
|
226
|
-
);
|
|
227
|
-
}
|
|
228
|
-
return React.cloneElement(children, { className: utils_cn.cn(className, children.props.className) });
|
|
229
|
-
}
|
|
230
|
-
if (!link) return children;
|
|
231
|
-
const externalParams = /^(https?:)?\/\//.test(link.url) ? { target: "_blank", rel: "noreferrer" } : {};
|
|
232
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Link, { href: link.url, ...externalParams, className, children: [
|
|
233
|
-
link.icon,
|
|
234
|
-
/* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavLabel, { state, children: link.name }),
|
|
235
|
-
children
|
|
236
|
-
] });
|
|
237
|
-
}
|
|
238
|
-
function navTooltipLabel(link, isCollapsed) {
|
|
239
|
-
if (!link) return void 0;
|
|
240
|
-
if (link.tooltipMsg) return isCollapsed ? `${link.name} | ${link.tooltipMsg}` : link.tooltipMsg;
|
|
241
|
-
return isCollapsed ? link.name : void 0;
|
|
242
|
-
}
|
|
243
|
-
function NavRowTooltip({ label, children }) {
|
|
244
|
-
if (!label || !React.isValidElement(children)) return children;
|
|
245
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
246
|
-
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipTrigger, { render: children }),
|
|
247
|
-
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipContent, { side: "right", align: "center", sideOffset: 16, children: label })
|
|
248
|
-
] });
|
|
249
|
-
}
|
|
250
|
-
function NavRowBody({
|
|
251
|
-
action,
|
|
252
|
-
surfaceClassName,
|
|
253
|
-
children
|
|
254
|
-
}) {
|
|
255
|
-
if (!action) return children;
|
|
256
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: utils_cn.cn("flex min-w-0 items-center pr-1", surfaceClassName), children: [
|
|
257
|
-
children,
|
|
258
|
-
action
|
|
259
|
-
] });
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
function MainSidebarNavList({ className, children, ...props }) {
|
|
263
|
-
return /* @__PURE__ */ jsxRuntime.jsx("ul", { className: utils_cn.cn("grid grid-cols-[minmax(0,1fr)] content-center items-start gap-0.5", className), ...props, children });
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function MainSidebarNavSection({ className, children, ...props }) {
|
|
267
|
-
return /* @__PURE__ */ jsxRuntime.jsx("section", { className: utils_cn.cn("relative grid grid-cols-[minmax(0,1fr)] content-center items-start", className), ...props, children });
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function MainSidebarNavSeparator({ className, ...props }) {
|
|
271
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
272
|
-
"div",
|
|
273
|
-
{
|
|
274
|
-
role: "separator",
|
|
275
|
-
"aria-orientation": "horizontal",
|
|
276
|
-
className: utils_cn.cn(
|
|
277
|
-
"relative min-h-5",
|
|
278
|
-
'[&:after]:absolute [&:after]:inset-x-3 [&:after]:top-1/2 [&:after]:block [&:after]:h-0 [&:after]:border-t [&:after]:border-border1 [&:after]:content-[""]',
|
|
279
|
-
className
|
|
280
|
-
),
|
|
281
|
-
...props
|
|
282
|
-
}
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const KEYBOARD_STEP = 10;
|
|
287
|
-
const DRAG_THRESHOLD = 5;
|
|
288
|
-
function MainSidebarRoot({ children, className }) {
|
|
289
|
-
const {
|
|
290
|
-
state,
|
|
291
|
-
width,
|
|
292
|
-
minWidth,
|
|
293
|
-
maxWidth,
|
|
294
|
-
collapseBelow,
|
|
295
|
-
collapsedWidth,
|
|
296
|
-
isMobile,
|
|
297
|
-
openMobile,
|
|
298
|
-
setOpenMobile,
|
|
299
|
-
setWidth,
|
|
300
|
-
collapse,
|
|
301
|
-
expand,
|
|
302
|
-
commit,
|
|
303
|
-
toggleSidebar,
|
|
304
|
-
setGestureActive
|
|
305
|
-
} = useMainSidebar();
|
|
306
|
-
const isCollapsed = state === "collapsed";
|
|
307
|
-
const isHidden = isCollapsed && collapsedWidth === 0;
|
|
308
|
-
const draggedRef = React.useRef(false);
|
|
309
|
-
const dragCleanupRef = React.useRef(null);
|
|
310
|
-
React.useEffect(() => {
|
|
311
|
-
return () => {
|
|
312
|
-
dragCleanupRef.current?.();
|
|
313
|
-
dragCleanupRef.current = null;
|
|
314
|
-
};
|
|
315
|
-
}, []);
|
|
316
|
-
const onPointerDown = React.useCallback(
|
|
317
|
-
(event) => {
|
|
318
|
-
if (event.button !== 0) return;
|
|
319
|
-
event.preventDefault();
|
|
320
|
-
draggedRef.current = false;
|
|
321
|
-
setGestureActive(true);
|
|
322
|
-
const startX = event.clientX;
|
|
323
|
-
const handle = event.currentTarget;
|
|
324
|
-
const pointerId = event.pointerId;
|
|
325
|
-
try {
|
|
326
|
-
handle.setPointerCapture(pointerId);
|
|
327
|
-
} catch {
|
|
328
|
-
}
|
|
329
|
-
const sidebarEl = handle.parentElement;
|
|
330
|
-
const sidebarLeft = sidebarEl ? sidebarEl.getBoundingClientRect().left : 0;
|
|
331
|
-
const prevCursor = document.body.style.cursor;
|
|
332
|
-
const prevUserSelect = document.body.style.userSelect;
|
|
333
|
-
const onMove = (ev) => {
|
|
334
|
-
if (ev.pointerId !== pointerId) return;
|
|
335
|
-
const dx = ev.clientX - startX;
|
|
336
|
-
if (!draggedRef.current) {
|
|
337
|
-
if (Math.abs(dx) <= DRAG_THRESHOLD) return;
|
|
338
|
-
draggedRef.current = true;
|
|
339
|
-
document.body.style.cursor = "col-resize";
|
|
340
|
-
document.body.style.userSelect = "none";
|
|
341
|
-
}
|
|
342
|
-
const cursorWidth = ev.clientX - sidebarLeft;
|
|
343
|
-
if (collapseBelow > 0 && cursorWidth < collapseBelow) {
|
|
344
|
-
collapse();
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
expand();
|
|
348
|
-
setWidth(cursorWidth);
|
|
349
|
-
};
|
|
350
|
-
const cleanup = (ev) => {
|
|
351
|
-
if (ev && ev.pointerId !== pointerId) return;
|
|
352
|
-
window.removeEventListener("pointermove", onMove);
|
|
353
|
-
window.removeEventListener("pointerup", cleanup);
|
|
354
|
-
window.removeEventListener("pointercancel", cleanup);
|
|
355
|
-
document.body.style.cursor = prevCursor;
|
|
356
|
-
document.body.style.userSelect = prevUserSelect;
|
|
357
|
-
setGestureActive(false);
|
|
358
|
-
commit();
|
|
359
|
-
dragCleanupRef.current = null;
|
|
360
|
-
};
|
|
361
|
-
dragCleanupRef.current = () => cleanup();
|
|
362
|
-
window.addEventListener("pointermove", onMove);
|
|
363
|
-
window.addEventListener("pointerup", cleanup);
|
|
364
|
-
window.addEventListener("pointercancel", cleanup);
|
|
365
|
-
},
|
|
366
|
-
[collapseBelow, setWidth, expand, collapse, commit, setGestureActive]
|
|
367
|
-
);
|
|
368
|
-
const onClick = React.useCallback(() => {
|
|
369
|
-
if (draggedRef.current) {
|
|
370
|
-
draggedRef.current = false;
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
toggleSidebar();
|
|
374
|
-
}, [toggleSidebar]);
|
|
375
|
-
const onKeyDown = React.useCallback(
|
|
376
|
-
(event) => {
|
|
377
|
-
switch (event.key) {
|
|
378
|
-
case "Enter":
|
|
379
|
-
case " ": {
|
|
380
|
-
event.preventDefault();
|
|
381
|
-
toggleSidebar();
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
case "ArrowLeft": {
|
|
385
|
-
event.preventDefault();
|
|
386
|
-
if (isCollapsed) return;
|
|
387
|
-
setWidth(width - KEYBOARD_STEP);
|
|
388
|
-
commit();
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
case "ArrowRight": {
|
|
392
|
-
event.preventDefault();
|
|
393
|
-
if (isCollapsed) {
|
|
394
|
-
expand();
|
|
395
|
-
commit();
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
setWidth(width + KEYBOARD_STEP);
|
|
399
|
-
commit();
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
case "Home": {
|
|
403
|
-
event.preventDefault();
|
|
404
|
-
expand();
|
|
405
|
-
setWidth(minWidth);
|
|
406
|
-
commit();
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
case "End": {
|
|
410
|
-
event.preventDefault();
|
|
411
|
-
expand();
|
|
412
|
-
setWidth(maxWidth);
|
|
413
|
-
commit();
|
|
414
|
-
return;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
[isCollapsed, width, minWidth, maxWidth, setWidth, expand, commit, toggleSidebar]
|
|
419
|
-
);
|
|
420
|
-
const closeOnAnchor = React.useCallback(
|
|
421
|
-
(event) => {
|
|
422
|
-
const anchor = event.target.closest("a");
|
|
423
|
-
if (!anchor || !anchor.hasAttribute("href")) return;
|
|
424
|
-
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
|
|
425
|
-
if (anchor.target === "_blank" || anchor.hasAttribute("download")) return;
|
|
426
|
-
setOpenMobile(false);
|
|
427
|
-
},
|
|
428
|
-
[setOpenMobile]
|
|
429
|
-
);
|
|
430
|
-
if (isMobile) {
|
|
431
|
-
return /* @__PURE__ */ jsxRuntime.jsx(drawer.Drawer, { side: "left", open: openMobile, onOpenChange: setOpenMobile, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
432
|
-
drawer.DrawerContent,
|
|
433
|
-
{
|
|
434
|
-
className: utils_cn.cn(
|
|
435
|
-
"w-3/4 max-w-(--sidebar-width-mobile) overflow-hidden rounded-none border-0 bg-surface2 shadow-xl",
|
|
436
|
-
className
|
|
437
|
-
),
|
|
438
|
-
children: [
|
|
439
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(drawer.DrawerTitle, { children: "Navigation" }) }),
|
|
440
|
-
/* @__PURE__ */ jsxRuntime.jsx(reactVisuallyHidden.VisuallyHidden, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(drawer.DrawerDescription, { children: "Primary site navigation drawer" }) }),
|
|
441
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { onClick: closeOnAnchor, className: "flex h-full min-h-0 flex-col overflow-hidden px-3 py-2", children })
|
|
442
|
-
]
|
|
443
|
-
}
|
|
444
|
-
) });
|
|
445
|
-
}
|
|
446
|
-
const currentWidth = isCollapsed ? collapsedWidth : width;
|
|
447
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
448
|
-
"div",
|
|
449
|
-
{
|
|
450
|
-
className: utils_cn.cn(
|
|
451
|
-
"sidebar-layout group/sidebar relative min-h-0 shrink-0 self-stretch",
|
|
452
|
-
"w-(--sidebar-width)",
|
|
453
|
-
"transition-[width] duration-220 ease-[cubic-bezier(0.32,0.72,0,1)]",
|
|
454
|
-
"motion-reduce:transition-none",
|
|
455
|
-
"in-data-[sidebar-gesture=active]:transition-none",
|
|
456
|
-
className,
|
|
457
|
-
// Order matters for tailwind-merge: these win over consumer-supplied border classes.
|
|
458
|
-
isHidden && "border-r-0 border-transparent"
|
|
459
|
-
),
|
|
460
|
-
children: [
|
|
461
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
462
|
-
"div",
|
|
463
|
-
{
|
|
464
|
-
className: utils_cn.cn(
|
|
465
|
-
"flex h-full min-h-0 flex-col overflow-hidden",
|
|
466
|
-
"transition-opacity duration-200 motion-reduce:transition-none",
|
|
467
|
-
"px-2",
|
|
468
|
-
isHidden && "pointer-events-none px-0 opacity-0"
|
|
469
|
-
),
|
|
470
|
-
children
|
|
471
|
-
}
|
|
472
|
-
),
|
|
473
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
474
|
-
"div",
|
|
475
|
-
{
|
|
476
|
-
role: "separator",
|
|
477
|
-
"aria-orientation": "vertical",
|
|
478
|
-
"aria-valuenow": isCollapsed ? void 0 : currentWidth,
|
|
479
|
-
"aria-valuemin": isCollapsed ? void 0 : minWidth,
|
|
480
|
-
"aria-valuemax": isCollapsed ? void 0 : maxWidth,
|
|
481
|
-
"aria-valuetext": isCollapsed ? "collapsed" : `${currentWidth} pixels`,
|
|
482
|
-
"aria-label": `Resize sidebar. Arrow keys to resize, Enter to ${isCollapsed ? "expand" : "collapse"}.`,
|
|
483
|
-
tabIndex: 0,
|
|
484
|
-
onPointerDown,
|
|
485
|
-
onClick,
|
|
486
|
-
onKeyDown,
|
|
487
|
-
className: utils_cn.cn(
|
|
488
|
-
"group absolute top-0 -right-1 z-10 h-full w-2 cursor-col-resize touch-none",
|
|
489
|
-
"flex items-center justify-center",
|
|
490
|
-
"focus-visible:outline-hidden"
|
|
491
|
-
),
|
|
492
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
493
|
-
primitives_resizeHandleIndicator.ResizeHandleIndicator,
|
|
494
|
-
{
|
|
495
|
-
className: utils_cn.cn(
|
|
496
|
-
"group-hover:opacity-100",
|
|
497
|
-
"group-focus-visible:via-accent1 group-focus-visible:opacity-100",
|
|
498
|
-
"in-data-[sidebar-gesture=active]:via-neutral6/45 in-data-[sidebar-gesture=active]:opacity-100"
|
|
499
|
-
)
|
|
500
|
-
}
|
|
501
|
-
)
|
|
502
|
-
}
|
|
503
|
-
)
|
|
504
|
-
]
|
|
505
|
-
}
|
|
506
|
-
);
|
|
507
|
-
}
|
|
508
|
-
|
|
509
55
|
function getLinkKey(link) {
|
|
510
56
|
return `${link.url}:${link.name}`;
|
|
511
57
|
}
|
|
512
58
|
function MainSidebarSectionLink({ link, activeCandidates, level = 0, isActive }) {
|
|
513
59
|
const childLinks = link.children ?? [];
|
|
514
60
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
515
|
-
MainSidebarNavLink,
|
|
61
|
+
mainSidebarLinkActive.MainSidebarNavLink,
|
|
516
62
|
{
|
|
517
63
|
link,
|
|
518
64
|
isActive: isActive?.(link, activeCandidates) ?? link.isActive,
|
|
519
65
|
level,
|
|
520
|
-
subItems: childLinks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavList, { className: "mt-0.5", children: childLinks.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
subItems: childLinks.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(mainSidebarLinkActive.MainSidebarNavList, { className: "mt-0.5", children: childLinks.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
521
67
|
MainSidebarSectionLink,
|
|
522
68
|
{
|
|
523
69
|
link: child,
|
|
@@ -536,15 +82,15 @@ function MainSidebarSections({ sections, isActive, className }) {
|
|
|
536
82
|
const showSeparator = section.links.length > 0 && section.separator;
|
|
537
83
|
const headerId = section.title ? `${baseId}-${section.key}` : void 0;
|
|
538
84
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
539
|
-
MainSidebarNavSection,
|
|
85
|
+
mainSidebarLinkActive.MainSidebarNavSection,
|
|
540
86
|
{
|
|
541
87
|
className,
|
|
542
88
|
"aria-labelledby": headerId,
|
|
543
89
|
"aria-label": !headerId ? section.key : void 0,
|
|
544
90
|
children: [
|
|
545
|
-
showSeparator ? /* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavSeparator, {}) : null,
|
|
91
|
+
showSeparator ? /* @__PURE__ */ jsxRuntime.jsx(mainSidebarLinkActive.MainSidebarNavSeparator, {}) : null,
|
|
546
92
|
section.title ? /* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavHeader, { id: headerId, href: section.href, isActive: section.isHeaderActive, children: section.title }) : null,
|
|
547
|
-
/* @__PURE__ */ jsxRuntime.jsx(MainSidebarNavList, { children: section.links.map((link) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
+
/* @__PURE__ */ jsxRuntime.jsx(mainSidebarLinkActive.MainSidebarNavList, { children: section.links.map((link) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
548
94
|
MainSidebarSectionLink,
|
|
549
95
|
{
|
|
550
96
|
link,
|
|
@@ -560,285 +106,28 @@ function MainSidebarSections({ sections, isActive, className }) {
|
|
|
560
106
|
}) });
|
|
561
107
|
}
|
|
562
108
|
|
|
563
|
-
|
|
564
|
-
const { desktopState, toggleSidebar } = useMainSidebar();
|
|
565
|
-
const isCollapsed = desktopState === "collapsed";
|
|
566
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(tooltip.Tooltip, { children: [
|
|
567
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
568
|
-
tooltip.TooltipTrigger,
|
|
569
|
-
{
|
|
570
|
-
render: /* @__PURE__ */ jsxRuntime.jsx(
|
|
571
|
-
"button",
|
|
572
|
-
{
|
|
573
|
-
type: "button",
|
|
574
|
-
"aria-label": "Toggle sidebar",
|
|
575
|
-
"aria-expanded": !isCollapsed,
|
|
576
|
-
...props,
|
|
577
|
-
onClick: (event) => {
|
|
578
|
-
onClick?.(event);
|
|
579
|
-
if (!event.defaultPrevented) toggleSidebar();
|
|
580
|
-
},
|
|
581
|
-
className: utils_cn.cn(
|
|
582
|
-
"flex items-center justify-center rounded-md text-neutral3",
|
|
583
|
-
"size-7",
|
|
584
|
-
isCollapsed ? "mx-auto" : "ml-auto",
|
|
585
|
-
"hover:bg-sidebar-nav-hover hover:text-neutral6",
|
|
586
|
-
"transition-all duration-normal ease-out-custom",
|
|
587
|
-
"focus-visible:shadow-focus-ring focus-visible:ring-1 focus-visible:ring-accent1 focus-visible:outline-hidden",
|
|
588
|
-
"[&_svg]:size-4 [&_svg]:text-neutral3 [&_svg]:transition-transform [&_svg]:duration-normal [&:hover_svg]:text-neutral5",
|
|
589
|
-
className
|
|
590
|
-
),
|
|
591
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
592
|
-
lucideReact.PanelRightIcon,
|
|
593
|
-
{
|
|
594
|
-
className: utils_cn.cn({
|
|
595
|
-
"rotate-180": isCollapsed
|
|
596
|
-
})
|
|
597
|
-
}
|
|
598
|
-
)
|
|
599
|
-
}
|
|
600
|
-
)
|
|
601
|
-
}
|
|
602
|
-
),
|
|
603
|
-
/* @__PURE__ */ jsxRuntime.jsx(tooltip.TooltipContent, { children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
604
|
-
"Toggle Sidebar",
|
|
605
|
-
/* @__PURE__ */ jsxRuntime.jsx(kbd.Kbd, { size: "xs", children: "[" })
|
|
606
|
-
] }) })
|
|
607
|
-
] });
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
const SIDEBAR_STATE_KEY = "sidebar:state";
|
|
611
|
-
const SIDEBAR_WIDTH_KEY = "sidebar:width";
|
|
612
|
-
const SIDEBAR_WIDTH_VAR = "--sidebar-width";
|
|
613
|
-
const clamp = (v, lo, hi) => Math.min(hi, Math.max(lo, v));
|
|
614
|
-
const useIsoLayoutEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
615
|
-
function MainSidebarProvider({
|
|
616
|
-
children,
|
|
617
|
-
defaultState = "default",
|
|
618
|
-
defaultWidth = 240,
|
|
619
|
-
minWidth = 200,
|
|
620
|
-
maxWidth = 480,
|
|
621
|
-
collapseBelow,
|
|
622
|
-
collapsedWidth = 64,
|
|
623
|
-
disableKeyboardShortcut = true,
|
|
624
|
-
storageKey,
|
|
625
|
-
mobileBreakpoint = 1024,
|
|
626
|
-
mobileWidth = 360,
|
|
627
|
-
LinkComponent
|
|
628
|
-
}) {
|
|
629
|
-
const safeMin = Math.max(0, Math.min(minWidth, maxWidth));
|
|
630
|
-
const safeMax = Math.max(safeMin, maxWidth);
|
|
631
|
-
const safeCollapsed = Math.max(0, Math.min(collapsedWidth, safeMax));
|
|
632
|
-
const safeDefault = clamp(defaultWidth, safeMin, safeMax);
|
|
633
|
-
const safeCollapseBelow = collapseBelow ?? safeMin;
|
|
634
|
-
const stateStorageKey = storageKey ? `${storageKey}:${SIDEBAR_STATE_KEY}` : SIDEBAR_STATE_KEY;
|
|
635
|
-
const widthStorageKey = storageKey ? `${storageKey}:${SIDEBAR_WIDTH_KEY}` : SIDEBAR_WIDTH_KEY;
|
|
636
|
-
const readInitial = () => {
|
|
637
|
-
if (typeof window === "undefined") return { state: defaultState, width: safeDefault };
|
|
638
|
-
try {
|
|
639
|
-
let nextState = defaultState;
|
|
640
|
-
let nextWidth = safeDefault;
|
|
641
|
-
const storedState = window.localStorage.getItem(stateStorageKey);
|
|
642
|
-
if (storedState === "collapsed" || storedState === "default") nextState = storedState;
|
|
643
|
-
const storedWidth = window.localStorage.getItem(widthStorageKey);
|
|
644
|
-
if (storedWidth !== null) {
|
|
645
|
-
const parsed = Number(storedWidth);
|
|
646
|
-
if (Number.isFinite(parsed)) nextWidth = clamp(parsed, safeMin, safeMax);
|
|
647
|
-
}
|
|
648
|
-
return { state: nextState, width: nextWidth };
|
|
649
|
-
} catch {
|
|
650
|
-
return { state: defaultState, width: safeDefault };
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
const initialRef = React.useRef(null);
|
|
654
|
-
if (initialRef.current === null) initialRef.current = readInitial();
|
|
655
|
-
const initial = initialRef.current;
|
|
656
|
-
const [state, setState] = React.useState(initial.state);
|
|
657
|
-
const [width, setWidthState] = React.useState(initial.width);
|
|
658
|
-
const [isMobile, setIsMobile] = React.useState(false);
|
|
659
|
-
const [openMobile, setOpenMobile] = React.useState(false);
|
|
660
|
-
const widthRef = React.useRef(initial.width);
|
|
661
|
-
const stateRef = React.useRef(initial.state);
|
|
662
|
-
stateRef.current = state;
|
|
663
|
-
const scopeRef = React.useRef(null);
|
|
664
|
-
React.useEffect(() => {
|
|
665
|
-
if (typeof window === "undefined") return;
|
|
666
|
-
const mq = window.matchMedia(`(max-width: ${mobileBreakpoint - 1}px)`);
|
|
667
|
-
const update = () => setIsMobile(mq.matches);
|
|
668
|
-
update();
|
|
669
|
-
mq.addEventListener("change", update);
|
|
670
|
-
return () => mq.removeEventListener("change", update);
|
|
671
|
-
}, [mobileBreakpoint]);
|
|
672
|
-
React.useEffect(() => {
|
|
673
|
-
if (!isMobile && openMobile) setOpenMobile(false);
|
|
674
|
-
}, [isMobile, openMobile]);
|
|
675
|
-
const writeCssVar = React.useCallback((px) => {
|
|
676
|
-
const el = scopeRef.current;
|
|
677
|
-
if (el) el.style.setProperty(SIDEBAR_WIDTH_VAR, `${px}px`);
|
|
678
|
-
}, []);
|
|
679
|
-
useIsoLayoutEffect(() => {
|
|
680
|
-
writeCssVar(state === "collapsed" ? safeCollapsed : widthRef.current);
|
|
681
|
-
}, [state, safeCollapsed, writeCssVar]);
|
|
682
|
-
const persistState = React.useCallback(
|
|
683
|
-
(next) => {
|
|
684
|
-
try {
|
|
685
|
-
window.localStorage.setItem(stateStorageKey, next);
|
|
686
|
-
} catch {
|
|
687
|
-
}
|
|
688
|
-
},
|
|
689
|
-
[stateStorageKey]
|
|
690
|
-
);
|
|
691
|
-
const toggleSidebar = React.useCallback(() => {
|
|
692
|
-
if (isMobile) {
|
|
693
|
-
setOpenMobile((prev) => !prev);
|
|
694
|
-
return;
|
|
695
|
-
}
|
|
696
|
-
setState((prev) => {
|
|
697
|
-
const next = prev === "default" ? "collapsed" : "default";
|
|
698
|
-
stateRef.current = next;
|
|
699
|
-
persistState(next);
|
|
700
|
-
return next;
|
|
701
|
-
});
|
|
702
|
-
}, [isMobile, persistState]);
|
|
703
|
-
const setWidth = React.useCallback(
|
|
704
|
-
(next) => {
|
|
705
|
-
const clamped = clamp(next, safeMin, safeMax);
|
|
706
|
-
widthRef.current = clamped;
|
|
707
|
-
writeCssVar(clamped);
|
|
708
|
-
},
|
|
709
|
-
[safeMin, safeMax, writeCssVar]
|
|
710
|
-
);
|
|
711
|
-
const collapse = React.useCallback(() => {
|
|
712
|
-
stateRef.current = "collapsed";
|
|
713
|
-
persistState("collapsed");
|
|
714
|
-
setState("collapsed");
|
|
715
|
-
}, [persistState]);
|
|
716
|
-
const expand = React.useCallback(() => {
|
|
717
|
-
stateRef.current = "default";
|
|
718
|
-
persistState("default");
|
|
719
|
-
setState("default");
|
|
720
|
-
}, [persistState]);
|
|
721
|
-
const commit = React.useCallback(() => {
|
|
722
|
-
setWidthState(widthRef.current);
|
|
723
|
-
try {
|
|
724
|
-
window.localStorage.setItem(stateStorageKey, stateRef.current);
|
|
725
|
-
window.localStorage.setItem(widthStorageKey, String(widthRef.current));
|
|
726
|
-
} catch {
|
|
727
|
-
}
|
|
728
|
-
}, [stateStorageKey, widthStorageKey]);
|
|
729
|
-
const setGestureActive = React.useCallback((active) => {
|
|
730
|
-
const el = scopeRef.current;
|
|
731
|
-
if (!el) return;
|
|
732
|
-
if (active) el.setAttribute("data-sidebar-gesture", "active");
|
|
733
|
-
else el.removeAttribute("data-sidebar-gesture");
|
|
734
|
-
}, []);
|
|
735
|
-
React.useEffect(() => {
|
|
736
|
-
if (disableKeyboardShortcut) return;
|
|
737
|
-
const onKeyDown = (ev) => {
|
|
738
|
-
if (ev.code !== "KeyB") return;
|
|
739
|
-
if (!(ev.metaKey || ev.ctrlKey)) return;
|
|
740
|
-
if (ev.altKey || ev.shiftKey) return;
|
|
741
|
-
const target = ev.target;
|
|
742
|
-
if (target) {
|
|
743
|
-
const tag = target.tagName;
|
|
744
|
-
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return;
|
|
745
|
-
if (target.isContentEditable) return;
|
|
746
|
-
}
|
|
747
|
-
ev.preventDefault();
|
|
748
|
-
toggleSidebar();
|
|
749
|
-
};
|
|
750
|
-
window.addEventListener("keydown", onKeyDown);
|
|
751
|
-
return () => window.removeEventListener("keydown", onKeyDown);
|
|
752
|
-
}, [disableKeyboardShortcut, toggleSidebar]);
|
|
753
|
-
const effectiveState = isMobile ? "default" : state;
|
|
754
|
-
const contextValue = React.useMemo(
|
|
755
|
-
() => ({
|
|
756
|
-
state: effectiveState,
|
|
757
|
-
desktopState: state,
|
|
758
|
-
width,
|
|
759
|
-
minWidth: safeMin,
|
|
760
|
-
maxWidth: safeMax,
|
|
761
|
-
collapseBelow: safeCollapseBelow,
|
|
762
|
-
collapsedWidth: safeCollapsed,
|
|
763
|
-
isMobile,
|
|
764
|
-
toggleSidebar,
|
|
765
|
-
setWidth,
|
|
766
|
-
collapse,
|
|
767
|
-
expand,
|
|
768
|
-
commit,
|
|
769
|
-
setGestureActive,
|
|
770
|
-
LinkComponent
|
|
771
|
-
}),
|
|
772
|
-
[
|
|
773
|
-
effectiveState,
|
|
774
|
-
state,
|
|
775
|
-
width,
|
|
776
|
-
safeMin,
|
|
777
|
-
safeMax,
|
|
778
|
-
safeCollapseBelow,
|
|
779
|
-
safeCollapsed,
|
|
780
|
-
isMobile,
|
|
781
|
-
toggleSidebar,
|
|
782
|
-
setWidth,
|
|
783
|
-
collapse,
|
|
784
|
-
expand,
|
|
785
|
-
commit,
|
|
786
|
-
setGestureActive,
|
|
787
|
-
LinkComponent
|
|
788
|
-
]
|
|
789
|
-
);
|
|
790
|
-
const drawerValue = React.useMemo(() => ({ openMobile, setOpenMobile }), [openMobile]);
|
|
791
|
-
const scopeStyle = {
|
|
792
|
-
[SIDEBAR_WIDTH_VAR]: `${initial.state === "collapsed" ? safeCollapsed : initial.width}px`,
|
|
793
|
-
["--sidebar-width-mobile"]: `${mobileWidth}px`,
|
|
794
|
-
display: "contents"
|
|
795
|
-
};
|
|
796
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
797
|
-
"div",
|
|
798
|
-
{
|
|
799
|
-
ref: scopeRef,
|
|
800
|
-
"data-sidebar-scope": true,
|
|
801
|
-
"data-sidebar-state": state,
|
|
802
|
-
"data-sidebar-mobile": isMobile ? "true" : "false",
|
|
803
|
-
style: scopeStyle,
|
|
804
|
-
suppressHydrationWarning: true,
|
|
805
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(MainSidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(MobileDrawerContext.Provider, { value: drawerValue, children }) })
|
|
806
|
-
}
|
|
807
|
-
);
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
function getIsLinkActive(link, pathname, siblings = []) {
|
|
811
|
-
const matches = (url) => pathname === url || pathname.startsWith(url + "/");
|
|
812
|
-
const flattenLinks = (links) => links.flatMap((item) => [item, ...flattenLinks(item.children ?? [])]);
|
|
813
|
-
if (!matches(link.url)) return false;
|
|
814
|
-
const competingLinks = [...flattenLinks(link.children ?? []), ...flattenLinks(siblings)];
|
|
815
|
-
return !competingLinks.some(
|
|
816
|
-
(other) => other.url !== link.url && other.url.length > link.url.length && matches(other.url)
|
|
817
|
-
);
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
const MainSidebar = Object.assign(MainSidebarRoot, {
|
|
109
|
+
const MainSidebar = Object.assign(mainSidebarLinkActive.MainSidebarRoot, {
|
|
821
110
|
Bottom: MainSidebarBottom,
|
|
822
|
-
Nav: MainSidebarNav,
|
|
823
|
-
NavSection: MainSidebarNavSection,
|
|
824
|
-
NavLink: MainSidebarNavLink,
|
|
825
|
-
NavLabel: MainSidebarNavLabel,
|
|
111
|
+
Nav: mainSidebarLinkActive.MainSidebarNav,
|
|
112
|
+
NavSection: mainSidebarLinkActive.MainSidebarNavSection,
|
|
113
|
+
NavLink: mainSidebarLinkActive.MainSidebarNavLink,
|
|
114
|
+
NavLabel: mainSidebarLinkActive.MainSidebarNavLabel,
|
|
826
115
|
NavHeader: MainSidebarNavHeader,
|
|
827
|
-
NavList: MainSidebarNavList,
|
|
828
|
-
NavSeparator: MainSidebarNavSeparator,
|
|
116
|
+
NavList: mainSidebarLinkActive.MainSidebarNavList,
|
|
117
|
+
NavSeparator: mainSidebarLinkActive.MainSidebarNavSeparator,
|
|
829
118
|
Sections: MainSidebarSections,
|
|
830
|
-
Trigger: MainSidebarTrigger,
|
|
831
|
-
MobileTrigger: MainSidebarMobileTrigger
|
|
119
|
+
Trigger: mainSidebarLinkActive.MainSidebarTrigger,
|
|
120
|
+
MobileTrigger: mainSidebarLinkActive.MainSidebarMobileTrigger
|
|
832
121
|
});
|
|
833
122
|
|
|
123
|
+
exports.MainSidebarMobileTrigger = mainSidebarLinkActive.MainSidebarMobileTrigger;
|
|
124
|
+
exports.MainSidebarProvider = mainSidebarLinkActive.MainSidebarProvider;
|
|
125
|
+
exports.MainSidebarTrigger = mainSidebarLinkActive.MainSidebarTrigger;
|
|
126
|
+
exports.getIsLinkActive = mainSidebarLinkActive.getIsLinkActive;
|
|
127
|
+
exports.navItemClasses = mainSidebarLinkActive.navItemClasses;
|
|
128
|
+
exports.useMainSidebar = mainSidebarLinkActive.useMainSidebar;
|
|
129
|
+
exports.useMaybeSidebar = mainSidebarLinkActive.useMaybeSidebar;
|
|
130
|
+
exports.useMaybeSidebarState = mainSidebarLinkActive.useMaybeSidebarState;
|
|
131
|
+
exports.useMobileDrawer = mainSidebarLinkActive.useMobileDrawer;
|
|
834
132
|
exports.MainSidebar = MainSidebar;
|
|
835
|
-
exports.MainSidebarMobileTrigger = MainSidebarMobileTrigger;
|
|
836
|
-
exports.MainSidebarProvider = MainSidebarProvider;
|
|
837
|
-
exports.MainSidebarTrigger = MainSidebarTrigger;
|
|
838
|
-
exports.getIsLinkActive = getIsLinkActive;
|
|
839
|
-
exports.navItemClasses = navItemClasses;
|
|
840
|
-
exports.useMainSidebar = useMainSidebar;
|
|
841
|
-
exports.useMaybeSidebar = useMaybeSidebar;
|
|
842
|
-
exports.useMaybeSidebarState = useMaybeSidebarState;
|
|
843
|
-
exports.useMobileDrawer = useMobileDrawer;
|
|
844
133
|
//# sourceMappingURL=MainSidebar.cjs.js.map
|