@warmio/ui 1.3.0 → 1.5.2
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/LICENSES/fluid-functionalism.txt +24 -0
- package/README.md +9 -5
- package/dist/badge.js +1 -1
- package/dist/button.js +1 -1
- package/dist/chunks/{chunk-IOUIACNV.js → chunk-2CO2BZLI.js} +20 -85
- package/dist/chunks/{chunk-ICC7GQXS.js → chunk-3AVFUXCV.js} +8 -6
- package/dist/chunks/{chunk-DHZWXYDX.js → chunk-6V6K5G72.js} +7 -13
- package/dist/chunks/{chunk-YTDMREDR.js → chunk-A2NLFM6R.js} +62 -36
- package/dist/chunks/chunk-B47G2BJV.js +534 -0
- package/dist/chunks/chunk-F74Y4WRX.js +239 -0
- package/dist/chunks/chunk-GY4XJ6EX.js +129 -0
- package/dist/chunks/chunk-HQTC542T.js +1079 -0
- package/dist/chunks/{chunk-BG6USQSY.js → chunk-IK5RHPN3.js} +20 -8
- package/dist/chunks/chunk-JXSJTIX7.js +133 -0
- package/dist/chunks/{chunk-CIYWFBEJ.js → chunk-OU7YQUU2.js} +15 -32
- package/dist/dropdown-menu.js +3 -1
- package/dist/index.js +11 -9
- package/dist/logo.js +1 -1
- package/dist/product-header.js +1 -1
- package/dist/product-header.types.d.ts +12 -10
- package/dist/sheet.js +3 -2
- package/dist/sidebar.js +4 -2
- package/dist/text.js +1 -1
- package/package.json +5 -3
- package/types/badge.d.ts +10 -2
- package/types/index.d.ts +113 -8
- package/types/sidebar.d.ts +1 -0
- package/types/text.d.ts +3 -0
- package/dist/chunks/chunk-GKEYV2XW.js +0 -10
- package/dist/chunks/chunk-LHHUTDZR.js +0 -749
- package/dist/chunks/chunk-P3AJ2REZ.js +0 -1083
|
@@ -0,0 +1,1079 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FluidMenuHighlights
|
|
3
|
+
} from "./chunk-F74Y4WRX.js";
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Sheet,
|
|
7
|
+
SheetContent,
|
|
8
|
+
SheetDescription,
|
|
9
|
+
SheetHeader,
|
|
10
|
+
SheetTitle
|
|
11
|
+
} from "./chunk-A2NLFM6R.js";
|
|
12
|
+
import {
|
|
13
|
+
FluidOverlay
|
|
14
|
+
} from "./chunk-JXSJTIX7.js";
|
|
15
|
+
import {
|
|
16
|
+
cn
|
|
17
|
+
} from "./chunk-VIB7OX7D.js";
|
|
18
|
+
|
|
19
|
+
// ../ui/src/warmio/sidebar.tsx
|
|
20
|
+
import * as React6 from "react";
|
|
21
|
+
|
|
22
|
+
// ../ui/src/components/sidebar.tsx
|
|
23
|
+
import * as React4 from "react";
|
|
24
|
+
import { flushSync } from "react-dom";
|
|
25
|
+
import { cva } from "class-variance-authority";
|
|
26
|
+
|
|
27
|
+
// ../ui/src/hooks/use-mobile.ts
|
|
28
|
+
import * as React from "react";
|
|
29
|
+
var MOBILE_BREAKPOINT = 768;
|
|
30
|
+
function getIsMobileSnapshot() {
|
|
31
|
+
return window.innerWidth < MOBILE_BREAKPOINT;
|
|
32
|
+
}
|
|
33
|
+
function getServerIsMobileSnapshot() {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
function subscribeToMobileChanges(onStoreChange) {
|
|
37
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
38
|
+
mql.addEventListener("change", onStoreChange);
|
|
39
|
+
return () => mql.removeEventListener("change", onStoreChange);
|
|
40
|
+
}
|
|
41
|
+
function useIsMobile() {
|
|
42
|
+
return React.useSyncExternalStore(
|
|
43
|
+
subscribeToMobileChanges,
|
|
44
|
+
getIsMobileSnapshot,
|
|
45
|
+
getServerIsMobileSnapshot
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// ../ui/src/lib/render-slot.tsx
|
|
50
|
+
import * as React2 from "react";
|
|
51
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
52
|
+
function RenderSlot({
|
|
53
|
+
asChild = false,
|
|
54
|
+
children,
|
|
55
|
+
defaultTagName,
|
|
56
|
+
render,
|
|
57
|
+
ref,
|
|
58
|
+
...props
|
|
59
|
+
}) {
|
|
60
|
+
const resolvedRender = render ?? (asChild && React2.isValidElement(children) ? children : void 0);
|
|
61
|
+
return useRender({
|
|
62
|
+
defaultTagName,
|
|
63
|
+
render: resolvedRender,
|
|
64
|
+
ref,
|
|
65
|
+
props: {
|
|
66
|
+
...props,
|
|
67
|
+
children: resolvedRender ? void 0 : children
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ../ui/src/warmio/tooltip.tsx
|
|
73
|
+
import * as React3 from "react";
|
|
74
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
75
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
76
|
+
function Tooltip({
|
|
77
|
+
delay: _delay,
|
|
78
|
+
closeDelay: _closeDelay,
|
|
79
|
+
followCursor,
|
|
80
|
+
...props
|
|
81
|
+
}) {
|
|
82
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Root, { ...props, trackCursorAxis: followCursor ?? "none" });
|
|
83
|
+
}
|
|
84
|
+
function TooltipTrigger({
|
|
85
|
+
asChild = false,
|
|
86
|
+
children,
|
|
87
|
+
render,
|
|
88
|
+
className: _className,
|
|
89
|
+
style: _style,
|
|
90
|
+
delay: _delay,
|
|
91
|
+
closeDelay: _closeDelay,
|
|
92
|
+
...props
|
|
93
|
+
}) {
|
|
94
|
+
const resolvedRender = render ?? (asChild && React3.isValidElement(children) ? children : void 0);
|
|
95
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", render: resolvedRender, ...props, children: resolvedRender ? void 0 : children });
|
|
96
|
+
}
|
|
97
|
+
function TooltipContent({
|
|
98
|
+
side = "top",
|
|
99
|
+
align = "center",
|
|
100
|
+
alignOffset = 0,
|
|
101
|
+
sideOffset = 4,
|
|
102
|
+
children,
|
|
103
|
+
ref,
|
|
104
|
+
render,
|
|
105
|
+
...props
|
|
106
|
+
}) {
|
|
107
|
+
const contentProps = { ...props };
|
|
108
|
+
Reflect.deleteProperty(contentProps, "className");
|
|
109
|
+
Reflect.deleteProperty(contentProps, "style");
|
|
110
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
111
|
+
TooltipPrimitive.Positioner,
|
|
112
|
+
{
|
|
113
|
+
side,
|
|
114
|
+
align,
|
|
115
|
+
alignOffset,
|
|
116
|
+
sideOffset,
|
|
117
|
+
className: "isolate z-[var(--z-popover)]",
|
|
118
|
+
children: /* @__PURE__ */ jsxs(
|
|
119
|
+
TooltipPrimitive.Popup,
|
|
120
|
+
{
|
|
121
|
+
...contentProps,
|
|
122
|
+
ref,
|
|
123
|
+
"data-slot": "tooltip-content",
|
|
124
|
+
className: "pointer-events-none z-[var(--z-popover)] inline-flex w-fit min-w-[140px] max-w-xs origin-(--transform-origin) rounded-lg bg-chart-tooltip-background text-chart-tooltip-foreground **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-[calc(var(--z-popover)+1)] **:data-[slot=kbd]:rounded-lg",
|
|
125
|
+
render: (props2, state) => /* @__PURE__ */ jsx(
|
|
126
|
+
FluidOverlay,
|
|
127
|
+
{
|
|
128
|
+
props: props2,
|
|
129
|
+
state,
|
|
130
|
+
render,
|
|
131
|
+
motion: "tooltip",
|
|
132
|
+
side: state.side,
|
|
133
|
+
tier: "fast"
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
children: [
|
|
137
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2 px-4 py-2 text-xs", children }),
|
|
138
|
+
/* @__PURE__ */ jsx(
|
|
139
|
+
TooltipPrimitive.Arrow,
|
|
140
|
+
{
|
|
141
|
+
"data-slot": "tooltip-arrow",
|
|
142
|
+
className: "h-2 w-4 bg-chart-tooltip-background data-[side=top]:top-full data-[side=top]:-translate-y-px data-[side=top]:[clip-path:polygon(0_0,100%_0,50%_100%)] data-[side=bottom]:bottom-full data-[side=bottom]:translate-y-px data-[side=bottom]:[clip-path:polygon(50%_0,100%_100%,0_100%)] data-[side=left]:left-full data-[side=left]:h-4 data-[side=left]:w-2 data-[side=left]:-translate-x-px data-[side=left]:[clip-path:polygon(0_0,100%_50%,0_100%)] data-[side=right]:right-full data-[side=right]:h-4 data-[side=right]:w-2 data-[side=right]:translate-x-px data-[side=right]:[clip-path:polygon(100%_0,100%_100%,0_50%)] data-[side=inline-start]:left-full data-[side=inline-start]:h-4 data-[side=inline-start]:w-2 data-[side=inline-start]:-translate-x-px data-[side=inline-start]:[clip-path:polygon(0_0,100%_50%,0_100%)] data-[side=inline-end]:right-full data-[side=inline-end]:h-4 data-[side=inline-end]:w-2 data-[side=inline-end]:translate-x-px data-[side=inline-end]:[clip-path:polygon(100%_0,100%_100%,0_50%)]"
|
|
143
|
+
}
|
|
144
|
+
)
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
) });
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// ../ui/src/components/sidebar.tsx
|
|
153
|
+
import { MenuIcon, PanelLeftIcon } from "lucide-react";
|
|
154
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
155
|
+
var SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
156
|
+
var SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
157
|
+
function readSidebarCookie(cookie) {
|
|
158
|
+
const match = cookie.match(/(?:^|; )sidebar_state=(true|false)(?:;|$)/);
|
|
159
|
+
if (!match) return null;
|
|
160
|
+
return match[1] === "true";
|
|
161
|
+
}
|
|
162
|
+
var SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
163
|
+
var SIDEBAR_HOVER_CLOSE_DELAY_MS = 200;
|
|
164
|
+
var TABLET_ICON_SIDEBAR_QUERY = "(min-width: 768px) and (max-width: 1279px)";
|
|
165
|
+
var getServerForceIconSidebarSnapshot = () => false;
|
|
166
|
+
function isSidebarHoverRetentionTarget(target) {
|
|
167
|
+
if (!(target instanceof Element)) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
return Boolean(
|
|
171
|
+
target.closest(
|
|
172
|
+
'[data-slot="sidebar-container"], [data-radix-popper-content-wrapper], [data-slot="dropdown-menu-content"], [data-sidebar-collapsed-popover="true"]'
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
var SidebarContext = React4.createContext(null);
|
|
177
|
+
function useSidebar() {
|
|
178
|
+
const context = React4.use(SidebarContext);
|
|
179
|
+
if (!context) {
|
|
180
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
181
|
+
}
|
|
182
|
+
return context;
|
|
183
|
+
}
|
|
184
|
+
function subscribeToForceIconSidebar(onStoreChange) {
|
|
185
|
+
const mql = window.matchMedia(TABLET_ICON_SIDEBAR_QUERY);
|
|
186
|
+
mql.addEventListener("change", onStoreChange);
|
|
187
|
+
return () => mql.removeEventListener("change", onStoreChange);
|
|
188
|
+
}
|
|
189
|
+
function getForceIconSidebarSnapshot() {
|
|
190
|
+
return window.matchMedia(TABLET_ICON_SIDEBAR_QUERY).matches;
|
|
191
|
+
}
|
|
192
|
+
function useForceIconSidebar(forceIconAtTablet) {
|
|
193
|
+
const isTablet = React4.useSyncExternalStore(
|
|
194
|
+
subscribeToForceIconSidebar,
|
|
195
|
+
getForceIconSidebarSnapshot,
|
|
196
|
+
getServerForceIconSidebarSnapshot
|
|
197
|
+
);
|
|
198
|
+
return forceIconAtTablet && isTablet;
|
|
199
|
+
}
|
|
200
|
+
function SidebarProvider({
|
|
201
|
+
defaultOpen = true,
|
|
202
|
+
open: openProp,
|
|
203
|
+
onOpenChange: setOpenProp,
|
|
204
|
+
className,
|
|
205
|
+
style,
|
|
206
|
+
forceIconAtTablet = false,
|
|
207
|
+
allowUserCollapse = true,
|
|
208
|
+
expandOnHover = false,
|
|
209
|
+
children,
|
|
210
|
+
...props
|
|
211
|
+
}) {
|
|
212
|
+
const isMobile = useIsMobile();
|
|
213
|
+
const forceIcon = useForceIconSidebar(forceIconAtTablet);
|
|
214
|
+
const [openMobile, setOpenMobile] = React4.useState(false);
|
|
215
|
+
const [hoverExpanded, setHoverExpandedState] = React4.useState(false);
|
|
216
|
+
const [sidebarMotionEnabled, setSidebarMotionEnabled] = React4.useState(expandOnHover);
|
|
217
|
+
const [_open, _setOpen] = React4.useReducer(
|
|
218
|
+
(_, nextOpen) => nextOpen,
|
|
219
|
+
defaultOpen
|
|
220
|
+
);
|
|
221
|
+
const cookieHydratedRef = React4.useRef(false);
|
|
222
|
+
const sidebarWrapperRef = React4.useRef(null);
|
|
223
|
+
const hydrateSidebarCookie = (node) => {
|
|
224
|
+
sidebarWrapperRef.current = node;
|
|
225
|
+
};
|
|
226
|
+
React4.useLayoutEffect(() => {
|
|
227
|
+
if (expandOnHover || cookieHydratedRef.current) return;
|
|
228
|
+
const stored = readSidebarCookie(document.cookie);
|
|
229
|
+
if (stored === null) return;
|
|
230
|
+
cookieHydratedRef.current = true;
|
|
231
|
+
_setOpen(stored);
|
|
232
|
+
}, [expandOnHover]);
|
|
233
|
+
const open = openProp ?? _open;
|
|
234
|
+
const setOpen = React4.useCallback(
|
|
235
|
+
(openState) => {
|
|
236
|
+
if (!allowUserCollapse) {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (setOpenProp) {
|
|
240
|
+
setOpenProp(openState);
|
|
241
|
+
} else {
|
|
242
|
+
_setOpen(openState);
|
|
243
|
+
}
|
|
244
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
245
|
+
},
|
|
246
|
+
[allowUserCollapse, setOpenProp]
|
|
247
|
+
);
|
|
248
|
+
const setHoverExpanded = React4.useCallback(
|
|
249
|
+
(expanded) => {
|
|
250
|
+
if (!expandOnHover) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
setHoverExpandedState(expanded);
|
|
254
|
+
},
|
|
255
|
+
[expandOnHover]
|
|
256
|
+
);
|
|
257
|
+
const toggleSidebar = React4.useCallback(() => {
|
|
258
|
+
if (!allowUserCollapse) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
if (expandOnHover && isMobile === false) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
setSidebarMotionEnabled(true);
|
|
265
|
+
return isMobile ? setOpenMobile((open2) => !open2) : setOpen(!open);
|
|
266
|
+
}, [allowUserCollapse, expandOnHover, isMobile, open, setOpen]);
|
|
267
|
+
const toggleSidebarEvent = React4.useEffectEvent(toggleSidebar);
|
|
268
|
+
let state = open ? "expanded" : "collapsed";
|
|
269
|
+
if (forceIcon && isMobile === false) {
|
|
270
|
+
state = "collapsed";
|
|
271
|
+
}
|
|
272
|
+
if (expandOnHover && isMobile === false) {
|
|
273
|
+
state = hoverExpanded ? "expanded" : "collapsed";
|
|
274
|
+
}
|
|
275
|
+
const contextValue = React4.useMemo(
|
|
276
|
+
() => ({
|
|
277
|
+
state,
|
|
278
|
+
open,
|
|
279
|
+
setOpen,
|
|
280
|
+
isMobile,
|
|
281
|
+
openMobile,
|
|
282
|
+
setOpenMobile,
|
|
283
|
+
toggleSidebar,
|
|
284
|
+
sidebarMotionEnabled,
|
|
285
|
+
expandOnHover,
|
|
286
|
+
setHoverExpanded
|
|
287
|
+
}),
|
|
288
|
+
[
|
|
289
|
+
state,
|
|
290
|
+
open,
|
|
291
|
+
setOpen,
|
|
292
|
+
isMobile,
|
|
293
|
+
openMobile,
|
|
294
|
+
setOpenMobile,
|
|
295
|
+
toggleSidebar,
|
|
296
|
+
sidebarMotionEnabled,
|
|
297
|
+
expandOnHover,
|
|
298
|
+
setHoverExpanded
|
|
299
|
+
]
|
|
300
|
+
);
|
|
301
|
+
React4.useEffect(() => {
|
|
302
|
+
if (!allowUserCollapse || expandOnHover) {
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
const handleKeyDown = (event) => {
|
|
306
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
307
|
+
event.preventDefault();
|
|
308
|
+
toggleSidebarEvent();
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
312
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
313
|
+
}, [allowUserCollapse, expandOnHover]);
|
|
314
|
+
return /* @__PURE__ */ jsx2(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx2(
|
|
315
|
+
"div",
|
|
316
|
+
{
|
|
317
|
+
ref: hydrateSidebarCookie,
|
|
318
|
+
"data-slot": "sidebar-wrapper",
|
|
319
|
+
"data-force-icon-at-tablet": forceIconAtTablet ? "true" : void 0,
|
|
320
|
+
style,
|
|
321
|
+
className: cn(
|
|
322
|
+
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
|
|
323
|
+
className
|
|
324
|
+
),
|
|
325
|
+
...props,
|
|
326
|
+
children
|
|
327
|
+
}
|
|
328
|
+
) });
|
|
329
|
+
}
|
|
330
|
+
function useSidebarHoverExpand({
|
|
331
|
+
expandOnHover,
|
|
332
|
+
isMobile,
|
|
333
|
+
setHoverExpanded,
|
|
334
|
+
state
|
|
335
|
+
}) {
|
|
336
|
+
const closeTimeoutRef = React4.useRef(null);
|
|
337
|
+
const clearHoverCloseTimeout = () => {
|
|
338
|
+
if (closeTimeoutRef.current !== null) {
|
|
339
|
+
clearTimeout(closeTimeoutRef.current);
|
|
340
|
+
closeTimeoutRef.current = null;
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
const openFromHover = () => {
|
|
344
|
+
if (!expandOnHover || isMobile) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
clearHoverCloseTimeout();
|
|
348
|
+
if (state === "expanded") {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
flushSync(() => {
|
|
352
|
+
setHoverExpanded(true);
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
const scheduleCloseFromHover = () => {
|
|
356
|
+
if (!expandOnHover || isMobile) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
clearHoverCloseTimeout();
|
|
360
|
+
closeTimeoutRef.current = setTimeout(() => {
|
|
361
|
+
closeTimeoutRef.current = null;
|
|
362
|
+
const activeElement = document.activeElement;
|
|
363
|
+
const retainExpandedFocus = activeElement instanceof Element && Boolean(
|
|
364
|
+
activeElement.closest(
|
|
365
|
+
'[data-radix-popper-content-wrapper], [data-slot="dropdown-menu-content"], [data-sidebar-collapsed-popover="true"], [data-sidebar-hide-when-collapsed="true"]'
|
|
366
|
+
)
|
|
367
|
+
);
|
|
368
|
+
const pointerInside = Boolean(
|
|
369
|
+
document.querySelector(
|
|
370
|
+
'[data-slot="sidebar-container"]:hover, [data-radix-popper-content-wrapper]:hover, [data-slot="dropdown-menu-content"]:hover, [data-sidebar-collapsed-popover="true"]:hover'
|
|
371
|
+
)
|
|
372
|
+
);
|
|
373
|
+
if (pointerInside) {
|
|
374
|
+
return;
|
|
375
|
+
}
|
|
376
|
+
if (retainExpandedFocus || document.querySelector(
|
|
377
|
+
'[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-trigger"][aria-expanded="true"]'
|
|
378
|
+
)) {
|
|
379
|
+
scheduleCloseFromHover();
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
setHoverExpanded(false);
|
|
383
|
+
}, SIDEBAR_HOVER_CLOSE_DELAY_MS);
|
|
384
|
+
};
|
|
385
|
+
const clearHoverCloseTimeoutEvent = React4.useEffectEvent(clearHoverCloseTimeout);
|
|
386
|
+
const scheduleCloseFromHoverEvent = React4.useEffectEvent(scheduleCloseFromHover);
|
|
387
|
+
React4.useEffect(() => () => clearHoverCloseTimeoutEvent(), []);
|
|
388
|
+
React4.useEffect(() => {
|
|
389
|
+
if (!expandOnHover || isMobile || state !== "expanded") {
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const handlePointerOver = (event) => {
|
|
393
|
+
if (isSidebarHoverRetentionTarget(event.target)) {
|
|
394
|
+
clearHoverCloseTimeoutEvent();
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const handlePointerOut = (event) => {
|
|
398
|
+
if (isSidebarHoverRetentionTarget(event.relatedTarget)) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
if (isSidebarHoverRetentionTarget(event.target)) {
|
|
402
|
+
scheduleCloseFromHoverEvent();
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
document.addEventListener("pointerover", handlePointerOver);
|
|
406
|
+
document.addEventListener("pointerout", handlePointerOut);
|
|
407
|
+
return () => {
|
|
408
|
+
document.removeEventListener("pointerover", handlePointerOver);
|
|
409
|
+
document.removeEventListener("pointerout", handlePointerOut);
|
|
410
|
+
};
|
|
411
|
+
}, [expandOnHover, isMobile, state]);
|
|
412
|
+
React4.useEffect(() => {
|
|
413
|
+
if (!expandOnHover || isMobile || state !== "expanded") {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
const handleKeyDown = (event) => {
|
|
417
|
+
if (event.key !== "Escape" || event.defaultPrevented) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
if (document.querySelector(
|
|
421
|
+
'[data-radix-popper-content-wrapper], [data-slot="dropdown-menu-content"]'
|
|
422
|
+
)) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
event.preventDefault();
|
|
426
|
+
clearHoverCloseTimeoutEvent();
|
|
427
|
+
const activeElement = document.activeElement;
|
|
428
|
+
if (activeElement instanceof HTMLElement && activeElement.closest('[data-sidebar-hide-when-collapsed="true"]')) {
|
|
429
|
+
const hoverSidebar = activeElement.closest('[data-slot="sidebar"]');
|
|
430
|
+
if (hoverSidebar instanceof HTMLElement) {
|
|
431
|
+
for (const control of hoverSidebar.querySelectorAll(
|
|
432
|
+
'a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
433
|
+
)) {
|
|
434
|
+
if (!control.closest('[data-sidebar-hide-when-collapsed="true"]')) {
|
|
435
|
+
control.focus();
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
setHoverExpanded(false);
|
|
442
|
+
};
|
|
443
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
444
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
445
|
+
}, [expandOnHover, isMobile, setHoverExpanded, state]);
|
|
446
|
+
return { openFromHover, scheduleCloseFromHover };
|
|
447
|
+
}
|
|
448
|
+
function getDesktopSidebarMotionClassNames(sidebarMotionEnabled, expandOnHover) {
|
|
449
|
+
if (!sidebarMotionEnabled) {
|
|
450
|
+
return { container: null, gap: null };
|
|
451
|
+
}
|
|
452
|
+
if (expandOnHover) {
|
|
453
|
+
return {
|
|
454
|
+
container: "transition-[width] duration-300 ease-out motion-reduce:transition-none",
|
|
455
|
+
gap: null
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
container: "transition-[left,right,width] duration-300 ease-linear motion-reduce:transition-none",
|
|
460
|
+
gap: "transition-[width] duration-300 ease-linear motion-reduce:transition-none"
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function getDesktopSidebarGapClassName(expandOnHover, variant, motionClassName) {
|
|
464
|
+
if (expandOnHover) {
|
|
465
|
+
return "relative w-(--sidebar-width-icon) bg-transparent group-data-[side=right]:rotate-180";
|
|
466
|
+
}
|
|
467
|
+
const collapsedIconWidthClassName = variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)";
|
|
468
|
+
return cn(
|
|
469
|
+
"relative w-(--sidebar-width) bg-transparent",
|
|
470
|
+
motionClassName,
|
|
471
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
472
|
+
"group-data-[side=right]:rotate-180",
|
|
473
|
+
collapsedIconWidthClassName
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
function getDesktopSidebarContainerClassName(expandOnHover, variant, motionClassName, className) {
|
|
477
|
+
const collapsedIconClassName = variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l";
|
|
478
|
+
return cn(
|
|
479
|
+
"fixed inset-y-0 hidden h-svh w-(--sidebar-width) data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
|
|
480
|
+
expandOnHover ? "z-[var(--z-sidebar-overlay)]" : "z-10",
|
|
481
|
+
motionClassName,
|
|
482
|
+
collapsedIconClassName,
|
|
483
|
+
className
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
function Sidebar({
|
|
487
|
+
side = "left",
|
|
488
|
+
variant = "sidebar",
|
|
489
|
+
collapsible = "offcanvas",
|
|
490
|
+
className,
|
|
491
|
+
children,
|
|
492
|
+
dir,
|
|
493
|
+
onPointerEnter,
|
|
494
|
+
onPointerLeave,
|
|
495
|
+
onMouseEnter,
|
|
496
|
+
onMouseLeave,
|
|
497
|
+
onFocusCapture,
|
|
498
|
+
onBlurCapture,
|
|
499
|
+
...props
|
|
500
|
+
}) {
|
|
501
|
+
const {
|
|
502
|
+
isMobile,
|
|
503
|
+
state,
|
|
504
|
+
openMobile,
|
|
505
|
+
setOpenMobile,
|
|
506
|
+
sidebarMotionEnabled,
|
|
507
|
+
expandOnHover,
|
|
508
|
+
setHoverExpanded
|
|
509
|
+
} = useSidebar();
|
|
510
|
+
const resolvedCollapsible = expandOnHover && collapsible !== "none" ? "icon" : collapsible;
|
|
511
|
+
const { openFromHover, scheduleCloseFromHover } = useSidebarHoverExpand({
|
|
512
|
+
expandOnHover,
|
|
513
|
+
isMobile,
|
|
514
|
+
setHoverExpanded,
|
|
515
|
+
state
|
|
516
|
+
});
|
|
517
|
+
const desktopMotionClassNames = getDesktopSidebarMotionClassNames(
|
|
518
|
+
sidebarMotionEnabled,
|
|
519
|
+
expandOnHover
|
|
520
|
+
);
|
|
521
|
+
if (resolvedCollapsible === "none") {
|
|
522
|
+
return /* @__PURE__ */ jsx2(
|
|
523
|
+
"div",
|
|
524
|
+
{
|
|
525
|
+
"data-slot": "sidebar",
|
|
526
|
+
className: cn(
|
|
527
|
+
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
|
528
|
+
className
|
|
529
|
+
),
|
|
530
|
+
...props,
|
|
531
|
+
children
|
|
532
|
+
}
|
|
533
|
+
);
|
|
534
|
+
}
|
|
535
|
+
if (isMobile) {
|
|
536
|
+
return /* @__PURE__ */ jsx2(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxs2(
|
|
537
|
+
SheetContent,
|
|
538
|
+
{
|
|
539
|
+
dir,
|
|
540
|
+
"data-sidebar": "sidebar",
|
|
541
|
+
"data-mobile": "true",
|
|
542
|
+
className: "w-[var(--sidebar-width-mobile)] bg-sidebar p-0 text-sidebar-foreground dark:bg-card",
|
|
543
|
+
showCloseButton: false,
|
|
544
|
+
side,
|
|
545
|
+
children: [
|
|
546
|
+
/* @__PURE__ */ jsxs2(SheetHeader, { className: "sr-only", children: [
|
|
547
|
+
/* @__PURE__ */ jsx2(SheetTitle, { children: "Sidebar" }),
|
|
548
|
+
/* @__PURE__ */ jsx2(SheetDescription, { children: "Displays the mobile sidebar." })
|
|
549
|
+
] }),
|
|
550
|
+
/* @__PURE__ */ jsx2("div", { className: "flex h-full w-full flex-col", children })
|
|
551
|
+
]
|
|
552
|
+
}
|
|
553
|
+
) });
|
|
554
|
+
}
|
|
555
|
+
return /* @__PURE__ */ jsxs2(
|
|
556
|
+
"div",
|
|
557
|
+
{
|
|
558
|
+
className: "group peer hidden text-sidebar-foreground md:block",
|
|
559
|
+
"data-state": state,
|
|
560
|
+
"data-collapsible": state === "collapsed" ? resolvedCollapsible : "",
|
|
561
|
+
"data-expand-on-hover": expandOnHover ? "true" : void 0,
|
|
562
|
+
"data-variant": variant,
|
|
563
|
+
"data-side": side,
|
|
564
|
+
"data-slot": "sidebar",
|
|
565
|
+
children: [
|
|
566
|
+
/* @__PURE__ */ jsx2(
|
|
567
|
+
"div",
|
|
568
|
+
{
|
|
569
|
+
"data-slot": "sidebar-gap",
|
|
570
|
+
className: getDesktopSidebarGapClassName(
|
|
571
|
+
expandOnHover,
|
|
572
|
+
variant,
|
|
573
|
+
desktopMotionClassNames.gap
|
|
574
|
+
)
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
/* @__PURE__ */ jsx2(
|
|
578
|
+
"div",
|
|
579
|
+
{
|
|
580
|
+
"data-slot": "sidebar-container",
|
|
581
|
+
"data-side": side,
|
|
582
|
+
className: getDesktopSidebarContainerClassName(
|
|
583
|
+
expandOnHover,
|
|
584
|
+
variant,
|
|
585
|
+
desktopMotionClassNames.container,
|
|
586
|
+
className
|
|
587
|
+
),
|
|
588
|
+
...props,
|
|
589
|
+
onPointerEnter: (event) => {
|
|
590
|
+
onPointerEnter?.(event);
|
|
591
|
+
openFromHover();
|
|
592
|
+
},
|
|
593
|
+
onMouseEnter: (event) => {
|
|
594
|
+
onMouseEnter?.(event);
|
|
595
|
+
openFromHover();
|
|
596
|
+
},
|
|
597
|
+
onPointerLeave: (event) => {
|
|
598
|
+
onPointerLeave?.(event);
|
|
599
|
+
scheduleCloseFromHover();
|
|
600
|
+
},
|
|
601
|
+
onMouseLeave: (event) => {
|
|
602
|
+
onMouseLeave?.(event);
|
|
603
|
+
scheduleCloseFromHover();
|
|
604
|
+
},
|
|
605
|
+
onFocusCapture: (event) => {
|
|
606
|
+
onFocusCapture?.(event);
|
|
607
|
+
openFromHover();
|
|
608
|
+
},
|
|
609
|
+
onBlurCapture: (event) => {
|
|
610
|
+
onBlurCapture?.(event);
|
|
611
|
+
if (isSidebarHoverRetentionTarget(event.relatedTarget)) {
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
scheduleCloseFromHover();
|
|
615
|
+
},
|
|
616
|
+
children: /* @__PURE__ */ jsx2(
|
|
617
|
+
"div",
|
|
618
|
+
{
|
|
619
|
+
"data-sidebar": "sidebar",
|
|
620
|
+
"data-slot": "sidebar-inner",
|
|
621
|
+
className: cn(
|
|
622
|
+
"flex size-full flex-col bg-sidebar",
|
|
623
|
+
variant === "floating" && "overflow-hidden rounded-[var(--warm-inset-radius,1.5rem)] [corner-shape:squircle] border border-[var(--warm-inset-border)] bg-[var(--warm-inset-frame,var(--card))] [--card-background:var(--warm-inset-frame,var(--card))] [--warm-inset-border:var(--warm-card-default-border-outer,var(--warm-inset-border-base))] [--card-edge-border:var(--warm-card-default-border-outer,var(--border))] shadow-card-edge"
|
|
624
|
+
),
|
|
625
|
+
children
|
|
626
|
+
}
|
|
627
|
+
)
|
|
628
|
+
}
|
|
629
|
+
)
|
|
630
|
+
]
|
|
631
|
+
}
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
function SidebarTrigger({ className, onClick, ...props }) {
|
|
635
|
+
const { isMobile, toggleSidebar } = useSidebar();
|
|
636
|
+
return /* @__PURE__ */ jsxs2(
|
|
637
|
+
Button,
|
|
638
|
+
{
|
|
639
|
+
"data-sidebar": "trigger",
|
|
640
|
+
"data-slot": "sidebar-trigger",
|
|
641
|
+
variant: "ghost",
|
|
642
|
+
size: "icon-sm",
|
|
643
|
+
className: cn(className),
|
|
644
|
+
onClick: (event) => {
|
|
645
|
+
onClick?.(event);
|
|
646
|
+
toggleSidebar();
|
|
647
|
+
},
|
|
648
|
+
...props,
|
|
649
|
+
children: [
|
|
650
|
+
isMobile ? /* @__PURE__ */ jsx2(MenuIcon, {}) : /* @__PURE__ */ jsx2(PanelLeftIcon, {}),
|
|
651
|
+
/* @__PURE__ */ jsx2("span", { className: "sr-only", children: "Toggle Sidebar" })
|
|
652
|
+
]
|
|
653
|
+
}
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
function SidebarInset({ className, ...props }) {
|
|
657
|
+
return /* @__PURE__ */ jsx2(
|
|
658
|
+
"main",
|
|
659
|
+
{
|
|
660
|
+
"data-slot": "sidebar-inset",
|
|
661
|
+
className: cn(
|
|
662
|
+
"relative flex min-h-0 w-full flex-1 flex-col md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
663
|
+
className
|
|
664
|
+
),
|
|
665
|
+
...props
|
|
666
|
+
}
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
function SidebarHeader({ className, ...props }) {
|
|
670
|
+
return /* @__PURE__ */ jsx2(
|
|
671
|
+
"div",
|
|
672
|
+
{
|
|
673
|
+
"data-slot": "sidebar-header",
|
|
674
|
+
"data-sidebar": "header",
|
|
675
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
676
|
+
...props
|
|
677
|
+
}
|
|
678
|
+
);
|
|
679
|
+
}
|
|
680
|
+
function SidebarFooter({ className, ...props }) {
|
|
681
|
+
return /* @__PURE__ */ jsx2(
|
|
682
|
+
"div",
|
|
683
|
+
{
|
|
684
|
+
"data-slot": "sidebar-footer",
|
|
685
|
+
"data-sidebar": "footer",
|
|
686
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
687
|
+
...props
|
|
688
|
+
}
|
|
689
|
+
);
|
|
690
|
+
}
|
|
691
|
+
function SidebarContent({ className, ...props }) {
|
|
692
|
+
return /* @__PURE__ */ jsx2(
|
|
693
|
+
"div",
|
|
694
|
+
{
|
|
695
|
+
"data-slot": "sidebar-content",
|
|
696
|
+
"data-sidebar": "content",
|
|
697
|
+
className: cn(
|
|
698
|
+
"no-scrollbar flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
699
|
+
className
|
|
700
|
+
),
|
|
701
|
+
...props
|
|
702
|
+
}
|
|
703
|
+
);
|
|
704
|
+
}
|
|
705
|
+
function SidebarGroup({ className, ...props }) {
|
|
706
|
+
return /* @__PURE__ */ jsx2(
|
|
707
|
+
"div",
|
|
708
|
+
{
|
|
709
|
+
"data-slot": "sidebar-group",
|
|
710
|
+
"data-sidebar": "group",
|
|
711
|
+
className: cn("relative flex w-full min-w-0 flex-col p-2", className),
|
|
712
|
+
...props
|
|
713
|
+
}
|
|
714
|
+
);
|
|
715
|
+
}
|
|
716
|
+
function SidebarGroupLabel({
|
|
717
|
+
className,
|
|
718
|
+
asChild = false,
|
|
719
|
+
render,
|
|
720
|
+
...props
|
|
721
|
+
}) {
|
|
722
|
+
return /* @__PURE__ */ jsx2(
|
|
723
|
+
RenderSlot,
|
|
724
|
+
{
|
|
725
|
+
defaultTagName: "div",
|
|
726
|
+
asChild,
|
|
727
|
+
render,
|
|
728
|
+
"data-slot": "sidebar-group-label",
|
|
729
|
+
"data-sidebar": "group-label",
|
|
730
|
+
className: cn(
|
|
731
|
+
"flex h-8 shrink-0 items-center rounded-lg px-2 text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:mt-0 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
732
|
+
className
|
|
733
|
+
),
|
|
734
|
+
...props
|
|
735
|
+
}
|
|
736
|
+
);
|
|
737
|
+
}
|
|
738
|
+
function SidebarGroupContent({ className, ...props }) {
|
|
739
|
+
return /* @__PURE__ */ jsx2(
|
|
740
|
+
"div",
|
|
741
|
+
{
|
|
742
|
+
"data-slot": "sidebar-group-content",
|
|
743
|
+
"data-sidebar": "group-content",
|
|
744
|
+
className: cn("w-full", className),
|
|
745
|
+
...props
|
|
746
|
+
}
|
|
747
|
+
);
|
|
748
|
+
}
|
|
749
|
+
var sidebarMenuSpacingClassName = {
|
|
750
|
+
default: "gap-2",
|
|
751
|
+
roomy: "gap-2",
|
|
752
|
+
collapsed: "gap-0"
|
|
753
|
+
};
|
|
754
|
+
function SidebarMenu({ className, spacing = "default", children, ...props }) {
|
|
755
|
+
return /* @__PURE__ */ jsxs2(
|
|
756
|
+
"ul",
|
|
757
|
+
{
|
|
758
|
+
"data-slot": "sidebar-menu",
|
|
759
|
+
"data-sidebar": "menu",
|
|
760
|
+
"data-fluid-menu": "sidebar",
|
|
761
|
+
className: cn(
|
|
762
|
+
"relative isolate flex w-full min-w-0 flex-col [&_[data-fluid-menu-item]:is(:hover,:active,:focus-visible,[data-active],[data-open],[data-popup-open])]:bg-transparent!",
|
|
763
|
+
sidebarMenuSpacingClassName[spacing],
|
|
764
|
+
className
|
|
765
|
+
),
|
|
766
|
+
...props,
|
|
767
|
+
children: [
|
|
768
|
+
children,
|
|
769
|
+
/* @__PURE__ */ jsx2(FluidMenuHighlights, { kind: "sidebar" })
|
|
770
|
+
]
|
|
771
|
+
}
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
775
|
+
return /* @__PURE__ */ jsx2(
|
|
776
|
+
"li",
|
|
777
|
+
{
|
|
778
|
+
"data-slot": "sidebar-menu-item",
|
|
779
|
+
"data-sidebar": "menu-item",
|
|
780
|
+
className: cn("group/menu-item relative", className),
|
|
781
|
+
...props
|
|
782
|
+
}
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
var sidebarMenuButtonVariants = cva(
|
|
786
|
+
"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-lg p-2 text-left ring-sidebar-ring outline-hidden transition-[width,height,padding,background-color,color,box-shadow] duration-160 ease-out motion-reduce:transition-none group-has-data-[sidebar=menu-action]/menu-item:pr-4 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-inset active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:rounded-full data-active:bg-[var(--button-primary-bg)] data-active:bg-[image:var(--button-primary-gradient)] data-active:text-[color:var(--button-primary-foreground)] data-active:shadow-[var(--button-primary-shadow)] data-active:hover:bg-[var(--button-primary-hover)] data-active:hover:bg-[image:var(--button-primary-gradient-hover)] data-active:hover:text-[color:var(--button-primary-foreground)] [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:transition-[color,stroke-width] [&_svg]:duration-80 group-hover/menu-item:[&_svg]:stroke-[2] group-focus-within/menu-item:[&_svg]:stroke-[2] [&>span:last-child]:truncate",
|
|
787
|
+
{
|
|
788
|
+
variants: {
|
|
789
|
+
variant: {
|
|
790
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
791
|
+
outline: "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]"
|
|
792
|
+
},
|
|
793
|
+
size: {
|
|
794
|
+
default: "h-8",
|
|
795
|
+
sm: "h-7",
|
|
796
|
+
lg: "h-12 group-data-[collapsible=icon]:p-0!"
|
|
797
|
+
}
|
|
798
|
+
},
|
|
799
|
+
defaultVariants: {
|
|
800
|
+
variant: "default",
|
|
801
|
+
size: "default"
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
function SidebarMenuButton({
|
|
806
|
+
asChild = false,
|
|
807
|
+
isActive = false,
|
|
808
|
+
variant = "default",
|
|
809
|
+
size = "default",
|
|
810
|
+
tooltip,
|
|
811
|
+
className,
|
|
812
|
+
render,
|
|
813
|
+
...props
|
|
814
|
+
}) {
|
|
815
|
+
const { isMobile, state } = useSidebar();
|
|
816
|
+
const button = /* @__PURE__ */ jsx2(
|
|
817
|
+
RenderSlot,
|
|
818
|
+
{
|
|
819
|
+
defaultTagName: "button",
|
|
820
|
+
asChild,
|
|
821
|
+
render,
|
|
822
|
+
"data-slot": "sidebar-menu-button",
|
|
823
|
+
"data-sidebar": "menu-button",
|
|
824
|
+
"data-size": size,
|
|
825
|
+
"data-active": isActive ? "" : void 0,
|
|
826
|
+
className: cn(sidebarMenuButtonVariants({ variant, size }), className),
|
|
827
|
+
...props
|
|
828
|
+
}
|
|
829
|
+
);
|
|
830
|
+
if (!tooltip || state !== "collapsed" || isMobile) {
|
|
831
|
+
return button;
|
|
832
|
+
}
|
|
833
|
+
const tooltipContent = typeof tooltip === "string" ? { children: tooltip } : tooltip;
|
|
834
|
+
return /* @__PURE__ */ jsxs2(Tooltip, { children: [
|
|
835
|
+
/* @__PURE__ */ jsx2(TooltipTrigger, { asChild: true, children: button }),
|
|
836
|
+
/* @__PURE__ */ jsx2(TooltipContent, { side: "right", align: "center", ...tooltipContent })
|
|
837
|
+
] });
|
|
838
|
+
}
|
|
839
|
+
function SidebarMenuBadge({ className, ...props }) {
|
|
840
|
+
return /* @__PURE__ */ jsx2(
|
|
841
|
+
"div",
|
|
842
|
+
{
|
|
843
|
+
"data-slot": "sidebar-menu-badge",
|
|
844
|
+
"data-sidebar": "menu-badge",
|
|
845
|
+
className: cn(
|
|
846
|
+
"pointer-events-none absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-lg px-2 text-sidebar-foreground tabular-nums select-none group-data-[collapsible=icon]:hidden peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5 peer-data-[size=sm]/menu-button:top-1 peer-data-active/menu-button:text-sidebar-accent-foreground",
|
|
847
|
+
className
|
|
848
|
+
),
|
|
849
|
+
...props
|
|
850
|
+
}
|
|
851
|
+
);
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// ../ui/src/warmio/sidebar-compositions.tsx
|
|
855
|
+
import * as React5 from "react";
|
|
856
|
+
import { ChevronUp, UserRound } from "lucide-react";
|
|
857
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
858
|
+
function SidebarBrand({ actions, collapsed, expanded }) {
|
|
859
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex w-full items-center justify-between gap-2 px-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0", children: [
|
|
860
|
+
/* @__PURE__ */ jsxs3("div", { className: "relative flex shrink-0 items-center rounded-lg focus-within:ring-2 focus-within:ring-sidebar-ring focus-within:outline-hidden group-data-[collapsible=icon]:size-8", children: [
|
|
861
|
+
React5.cloneElement(expanded, {
|
|
862
|
+
className: "flex shrink-0 items-center text-sidebar-foreground transition-colors hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:opacity-0"
|
|
863
|
+
}),
|
|
864
|
+
/* @__PURE__ */ jsx3(
|
|
865
|
+
"span",
|
|
866
|
+
{
|
|
867
|
+
"aria-hidden": "true",
|
|
868
|
+
className: "pointer-events-none absolute inset-0 hidden size-8 items-center justify-center rounded-lg text-sidebar-foreground group-data-[collapsible=icon]:flex",
|
|
869
|
+
inert: true,
|
|
870
|
+
children: React5.cloneElement(collapsed, {
|
|
871
|
+
className: "flex size-full items-center justify-center"
|
|
872
|
+
})
|
|
873
|
+
}
|
|
874
|
+
)
|
|
875
|
+
] }),
|
|
876
|
+
actions ? /* @__PURE__ */ jsx3(
|
|
877
|
+
"div",
|
|
878
|
+
{
|
|
879
|
+
className: "flex items-center gap-2 group-data-[collapsible=icon]:hidden",
|
|
880
|
+
"data-sidebar-hide-when-collapsed": "true",
|
|
881
|
+
children: actions
|
|
882
|
+
}
|
|
883
|
+
) : null
|
|
884
|
+
] });
|
|
885
|
+
}
|
|
886
|
+
var SidebarAccountTrigger = React5.forwardRef(function SidebarAccountTrigger2({ avatar, className: _className, email, label, style: _style, ...props }, ref) {
|
|
887
|
+
return /* @__PURE__ */ jsxs3(SidebarMenuButton2, { ...props, ref, presentation: "account", children: [
|
|
888
|
+
/* @__PURE__ */ jsx3(
|
|
889
|
+
"div",
|
|
890
|
+
{
|
|
891
|
+
"data-slot": "sidebar-account-avatar",
|
|
892
|
+
className: "grid size-8 shrink-0 place-items-center rounded-lg bg-sidebar-primary text-xs font-medium text-sidebar-primary-foreground group-data-[collapsible=icon]:size-8 group-data-[collapsible=icon]:rounded-full",
|
|
893
|
+
children: avatar ?? /* @__PURE__ */ jsx3(UserRound, { className: "size-4", "aria-hidden": "true" })
|
|
894
|
+
}
|
|
895
|
+
),
|
|
896
|
+
/* @__PURE__ */ jsxs3("div", { className: "min-w-0 flex-1 text-left group-data-[collapsible=icon]:hidden", children: [
|
|
897
|
+
/* @__PURE__ */ jsx3("div", { "data-slot": "sidebar-account-label", className: "truncate", title: label, children: label }),
|
|
898
|
+
/* @__PURE__ */ jsx3(
|
|
899
|
+
"div",
|
|
900
|
+
{
|
|
901
|
+
"data-slot": "sidebar-account-email",
|
|
902
|
+
className: "truncate text-sidebar-foreground/60",
|
|
903
|
+
title: email,
|
|
904
|
+
children: email
|
|
905
|
+
}
|
|
906
|
+
)
|
|
907
|
+
] }),
|
|
908
|
+
/* @__PURE__ */ jsx3(ChevronUp, { className: "ml-auto size-4 group-data-[collapsible=icon]:hidden" })
|
|
909
|
+
] });
|
|
910
|
+
});
|
|
911
|
+
SidebarAccountTrigger.displayName = "WarmSidebarAccountTrigger";
|
|
912
|
+
|
|
913
|
+
// ../ui/src/warmio/sidebar.tsx
|
|
914
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
915
|
+
function SidebarProvider2({
|
|
916
|
+
className: _className,
|
|
917
|
+
presentation,
|
|
918
|
+
style: _style,
|
|
919
|
+
...props
|
|
920
|
+
}) {
|
|
921
|
+
const presentationClassName = presentation === "mockup" ? "min-h-0 [--sidebar-width:16rem]" : presentation === "preview" ? "min-h-full" : "h-svh min-h-0 overflow-auto";
|
|
922
|
+
return /* @__PURE__ */ jsx4(SidebarProvider, { ...props, className: presentationClassName });
|
|
923
|
+
}
|
|
924
|
+
function Sidebar2({
|
|
925
|
+
className: _className,
|
|
926
|
+
presentation,
|
|
927
|
+
style: _style,
|
|
928
|
+
variant,
|
|
929
|
+
...props
|
|
930
|
+
}) {
|
|
931
|
+
return /* @__PURE__ */ jsx4(
|
|
932
|
+
Sidebar,
|
|
933
|
+
{
|
|
934
|
+
...props,
|
|
935
|
+
variant: presentation === "product" ? "floating" : variant ?? "sidebar"
|
|
936
|
+
}
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
function SidebarInset2({
|
|
940
|
+
className: _className,
|
|
941
|
+
presentation,
|
|
942
|
+
style: _style,
|
|
943
|
+
...props
|
|
944
|
+
}) {
|
|
945
|
+
return /* @__PURE__ */ jsx4(
|
|
946
|
+
SidebarInset,
|
|
947
|
+
{
|
|
948
|
+
...props,
|
|
949
|
+
className: presentation === "product" ? "min-h-0 min-w-0 overflow-auto" : void 0
|
|
950
|
+
}
|
|
951
|
+
);
|
|
952
|
+
}
|
|
953
|
+
function SidebarHeader2({
|
|
954
|
+
className: _className,
|
|
955
|
+
presentation,
|
|
956
|
+
style: _style,
|
|
957
|
+
...props
|
|
958
|
+
}) {
|
|
959
|
+
const className = presentation === "product" ? "h-[var(--header-height)] justify-end p-2" : presentation === "mockup" ? "h-14 justify-center border-b border-border p-2" : void 0;
|
|
960
|
+
return /* @__PURE__ */ jsx4(SidebarHeader, { ...props, className });
|
|
961
|
+
}
|
|
962
|
+
function SidebarContent2({
|
|
963
|
+
className: _className,
|
|
964
|
+
presentation,
|
|
965
|
+
style: _style,
|
|
966
|
+
...props
|
|
967
|
+
}) {
|
|
968
|
+
const className = presentation === "product" ? "pb-0" : presentation === "mockup" ? "px-2 py-4" : void 0;
|
|
969
|
+
return /* @__PURE__ */ jsx4(SidebarContent, { ...props, className });
|
|
970
|
+
}
|
|
971
|
+
function SidebarFooter2({
|
|
972
|
+
className: _className,
|
|
973
|
+
presentation,
|
|
974
|
+
style: _style,
|
|
975
|
+
...props
|
|
976
|
+
}) {
|
|
977
|
+
const className = presentation === "product" ? "p-2" : void 0;
|
|
978
|
+
return /* @__PURE__ */ jsx4(SidebarFooter, { ...props, className });
|
|
979
|
+
}
|
|
980
|
+
function SidebarGroup2({
|
|
981
|
+
className: _className,
|
|
982
|
+
collapsed = false,
|
|
983
|
+
presentation,
|
|
984
|
+
style: _style,
|
|
985
|
+
...props
|
|
986
|
+
}) {
|
|
987
|
+
const className = presentation === "navigation" || presentation === "navigation-primary" ? `${collapsed ? "items-center " : ""}px-2 py-2` : presentation === "mockup" ? "py-2" : void 0;
|
|
988
|
+
return /* @__PURE__ */ jsx4(SidebarGroup, { ...props, className });
|
|
989
|
+
}
|
|
990
|
+
function SidebarGroupContent2({
|
|
991
|
+
className: _className,
|
|
992
|
+
style: _style,
|
|
993
|
+
...props
|
|
994
|
+
}) {
|
|
995
|
+
return /* @__PURE__ */ jsx4(SidebarGroupContent, { ...props });
|
|
996
|
+
}
|
|
997
|
+
function SidebarGroupLabel2({
|
|
998
|
+
className: _className,
|
|
999
|
+
presentation,
|
|
1000
|
+
style: _style,
|
|
1001
|
+
...props
|
|
1002
|
+
}) {
|
|
1003
|
+
const className = presentation === "navigation" ? "px-2 tabular-nums text-sidebar-foreground/60" : void 0;
|
|
1004
|
+
return /* @__PURE__ */ jsx4(SidebarGroupLabel, { ...props, "data-presentation": presentation, className });
|
|
1005
|
+
}
|
|
1006
|
+
function SidebarMenu2({ className: _className, style: _style, ...props }) {
|
|
1007
|
+
return /* @__PURE__ */ jsx4(SidebarMenu, { ...props });
|
|
1008
|
+
}
|
|
1009
|
+
function SidebarMenuItem2({
|
|
1010
|
+
className: _className,
|
|
1011
|
+
style: _style,
|
|
1012
|
+
...props
|
|
1013
|
+
}) {
|
|
1014
|
+
return /* @__PURE__ */ jsx4(SidebarMenuItem, { ...props });
|
|
1015
|
+
}
|
|
1016
|
+
var SidebarMenuButton2 = React6.forwardRef(
|
|
1017
|
+
function SidebarMenuButton3({ className: _className, collapsed = false, disabled, presentation, style: _style, ...props }, ref) {
|
|
1018
|
+
return /* @__PURE__ */ jsx4(
|
|
1019
|
+
SidebarMenuButton,
|
|
1020
|
+
{
|
|
1021
|
+
...props,
|
|
1022
|
+
disabled,
|
|
1023
|
+
ref,
|
|
1024
|
+
"data-fluid-menu-disabled": presentation === "disabled" || void 0,
|
|
1025
|
+
className: cn(
|
|
1026
|
+
(collapsed || presentation === "previewCollapsed") && "mx-auto size-8 gap-0 p-2",
|
|
1027
|
+
presentation === "account" && "h-12 group-data-[collapsible=icon]:mx-auto group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0! group-data-[collapsible=icon]:p-0!",
|
|
1028
|
+
presentation === "navigation" && "text-sidebar-foreground hover:text-sidebar-foreground active:text-sidebar-foreground data-open:hover:text-sidebar-foreground data-active:text-[color:var(--button-primary-foreground)]",
|
|
1029
|
+
(disabled || presentation === "disabled") && "text-muted-foreground/60"
|
|
1030
|
+
)
|
|
1031
|
+
}
|
|
1032
|
+
);
|
|
1033
|
+
}
|
|
1034
|
+
);
|
|
1035
|
+
SidebarMenuButton2.displayName = "WarmSidebarMenuButton";
|
|
1036
|
+
function SidebarMenuBadge2({
|
|
1037
|
+
className: _className,
|
|
1038
|
+
presentation,
|
|
1039
|
+
style: _style,
|
|
1040
|
+
...props
|
|
1041
|
+
}) {
|
|
1042
|
+
return /* @__PURE__ */ jsx4(
|
|
1043
|
+
SidebarMenuBadge,
|
|
1044
|
+
{
|
|
1045
|
+
...props,
|
|
1046
|
+
className: cn(
|
|
1047
|
+
"text-sidebar-foreground peer-hover/menu-button:text-sidebar-foreground peer-data-active/menu-button:text-[color:var(--button-primary-foreground)]",
|
|
1048
|
+
presentation === "attention" && "animate-pulse"
|
|
1049
|
+
)
|
|
1050
|
+
}
|
|
1051
|
+
);
|
|
1052
|
+
}
|
|
1053
|
+
function SidebarTrigger2({
|
|
1054
|
+
className: _className,
|
|
1055
|
+
style: _style,
|
|
1056
|
+
...props
|
|
1057
|
+
}) {
|
|
1058
|
+
return /* @__PURE__ */ jsx4(SidebarTrigger, { ...props });
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
export {
|
|
1062
|
+
useSidebar,
|
|
1063
|
+
SidebarBrand,
|
|
1064
|
+
SidebarAccountTrigger,
|
|
1065
|
+
SidebarProvider2 as SidebarProvider,
|
|
1066
|
+
Sidebar2 as Sidebar,
|
|
1067
|
+
SidebarInset2 as SidebarInset,
|
|
1068
|
+
SidebarHeader2 as SidebarHeader,
|
|
1069
|
+
SidebarContent2 as SidebarContent,
|
|
1070
|
+
SidebarFooter2 as SidebarFooter,
|
|
1071
|
+
SidebarGroup2 as SidebarGroup,
|
|
1072
|
+
SidebarGroupContent2 as SidebarGroupContent,
|
|
1073
|
+
SidebarGroupLabel2 as SidebarGroupLabel,
|
|
1074
|
+
SidebarMenu2 as SidebarMenu,
|
|
1075
|
+
SidebarMenuItem2 as SidebarMenuItem,
|
|
1076
|
+
SidebarMenuButton2 as SidebarMenuButton,
|
|
1077
|
+
SidebarMenuBadge2 as SidebarMenuBadge,
|
|
1078
|
+
SidebarTrigger2 as SidebarTrigger
|
|
1079
|
+
};
|