lecom-ui 2.0.5 → 2.0.8

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.
@@ -0,0 +1,554 @@
1
+ import * as React from 'react';
2
+ import { Button } from '../Button/Button.js';
3
+ import { Input } from '../Input/Input.js';
4
+ import { Separator } from '../Separator/Separator.js';
5
+ import { Sheet, SheetContent } from '../Sheet/Sheet.js';
6
+ import { Skeleton } from '../Skeleton/Skeleton.js';
7
+ import { TooltipProvider, Tooltip, TooltipTrigger, TooltipContent } from '../Tooltip/Tooltip.js';
8
+ import { useIsMobile } from '../../hooks/use-mobile.js';
9
+ import { cn } from '../../lib/utils.js';
10
+ import { Slot } from '@radix-ui/react-slot';
11
+ import { cva } from 'class-variance-authority';
12
+ import { PanelLeft } from 'lucide-react';
13
+
14
+ const SIDEBAR_COOKIE_NAME = "sidebar:state";
15
+ const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
16
+ const SIDEBAR_WIDTH = "20rem";
17
+ const SIDEBAR_WIDTH_MOBILE = "18rem";
18
+ const SIDEBAR_WIDTH_ICON = "4rem";
19
+ const SIDEBAR_KEYBOARD_SHORTCUT = "b";
20
+ const SidebarContext = React.createContext(null);
21
+ function useSidebar() {
22
+ const context = React.useContext(SidebarContext);
23
+ if (!context) {
24
+ throw new Error("useSidebar must be used within a SidebarProvider.");
25
+ }
26
+ return context;
27
+ }
28
+ const SidebarProvider = React.forwardRef(
29
+ ({
30
+ defaultOpen = true,
31
+ open: openProp,
32
+ onOpenChange: setOpenProp,
33
+ className,
34
+ style,
35
+ children,
36
+ ...props
37
+ }, ref) => {
38
+ const isMobile = useIsMobile();
39
+ const [openMobile, setOpenMobile] = React.useState(false);
40
+ const [_open, _setOpen] = React.useState(defaultOpen);
41
+ const open = openProp ?? _open;
42
+ const setOpen = React.useCallback(
43
+ (value) => {
44
+ const openState = typeof value === "function" ? value(open) : value;
45
+ if (setOpenProp) {
46
+ setOpenProp(openState);
47
+ } else {
48
+ _setOpen(openState);
49
+ }
50
+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
51
+ },
52
+ [setOpenProp, open]
53
+ );
54
+ const toggleSidebar = React.useCallback(
55
+ () => isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2),
56
+ [isMobile, setOpen, setOpenMobile]
57
+ );
58
+ React.useEffect(() => {
59
+ const handleKeyDown = (event) => {
60
+ if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
61
+ event.preventDefault();
62
+ toggleSidebar();
63
+ }
64
+ };
65
+ window.addEventListener("keydown", handleKeyDown);
66
+ return () => window.removeEventListener("keydown", handleKeyDown);
67
+ }, [toggleSidebar]);
68
+ const state = open ? "expanded" : "collapsed";
69
+ const contextValue = React.useMemo(
70
+ () => ({
71
+ state,
72
+ open,
73
+ setOpen,
74
+ isMobile,
75
+ openMobile,
76
+ setOpenMobile,
77
+ toggleSidebar
78
+ }),
79
+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
80
+ );
81
+ return /* @__PURE__ */ React.createElement(SidebarContext.Provider, { value: contextValue }, /* @__PURE__ */ React.createElement(TooltipProvider, { delayDuration: 0 }, /* @__PURE__ */ React.createElement(
82
+ "div",
83
+ {
84
+ style: {
85
+ "--sidebar-width": SIDEBAR_WIDTH,
86
+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
87
+ ...style
88
+ },
89
+ className: cn(
90
+ "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",
91
+ className
92
+ ),
93
+ ref,
94
+ ...props
95
+ },
96
+ children
97
+ )));
98
+ }
99
+ );
100
+ SidebarProvider.displayName = "SidebarProvider";
101
+ const Sidebar = React.forwardRef(
102
+ // eslint-disable-next-line complexity
103
+ ({
104
+ side = "left",
105
+ variant = "sidebar",
106
+ collapsible = "offcanvas",
107
+ className,
108
+ children,
109
+ ...props
110
+ }, ref) => {
111
+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
112
+ if (collapsible === "none") {
113
+ return /* @__PURE__ */ React.createElement(
114
+ "div",
115
+ {
116
+ className: cn(
117
+ "flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",
118
+ className
119
+ ),
120
+ ref,
121
+ ...props
122
+ },
123
+ children
124
+ );
125
+ }
126
+ if (isMobile) {
127
+ return /* @__PURE__ */ React.createElement(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props }, /* @__PURE__ */ React.createElement(
128
+ SheetContent,
129
+ {
130
+ "data-sidebar": "sidebar",
131
+ "data-mobile": "true",
132
+ className: "w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
133
+ style: {
134
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE
135
+ },
136
+ side
137
+ },
138
+ /* @__PURE__ */ React.createElement("div", { className: "flex h-full w-full flex-col" }, children)
139
+ ));
140
+ }
141
+ return /* @__PURE__ */ React.createElement(
142
+ "div",
143
+ {
144
+ ref,
145
+ className: "group peer hidden md:block text-sidebar-foreground",
146
+ "data-state": state,
147
+ "data-collapsible": state === "collapsed" ? collapsible : "",
148
+ "data-variant": variant,
149
+ "data-side": side
150
+ },
151
+ /* @__PURE__ */ React.createElement(
152
+ "div",
153
+ {
154
+ className: cn(
155
+ "duration-200 relative inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex border-grey-400",
156
+ side === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
157
+ // Adjust the padding for floating and inset variants.
158
+ variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]" : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",
159
+ className
160
+ ),
161
+ ...props
162
+ },
163
+ /* @__PURE__ */ React.createElement(
164
+ "div",
165
+ {
166
+ "data-sidebar": "sidebar",
167
+ className: "flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"
168
+ },
169
+ children
170
+ )
171
+ )
172
+ );
173
+ }
174
+ );
175
+ Sidebar.displayName = "Sidebar";
176
+ const SidebarTrigger = React.forwardRef(({ className, onClick, ...props }, ref) => {
177
+ const { toggleSidebar } = useSidebar();
178
+ return /* @__PURE__ */ React.createElement(
179
+ Button,
180
+ {
181
+ ref,
182
+ "data-sidebar": "trigger",
183
+ className: cn("h-7 w-7", className),
184
+ iconButton: true,
185
+ onClick: (event) => {
186
+ onClick?.(event);
187
+ toggleSidebar();
188
+ },
189
+ ...props
190
+ },
191
+ /* @__PURE__ */ React.createElement(PanelLeft, null),
192
+ /* @__PURE__ */ React.createElement("span", { className: "sr-only" }, "Toggle Sidebar")
193
+ );
194
+ });
195
+ SidebarTrigger.displayName = "SidebarTrigger";
196
+ const SidebarRail = React.forwardRef(({ className, ...props }, ref) => {
197
+ const { toggleSidebar } = useSidebar();
198
+ return /* @__PURE__ */ React.createElement(
199
+ "button",
200
+ {
201
+ ref,
202
+ "data-sidebar": "rail",
203
+ "aria-label": "Toggle Sidebar",
204
+ tabIndex: -1,
205
+ onClick: toggleSidebar,
206
+ title: "Toggle Sidebar",
207
+ className: cn(
208
+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex",
209
+ "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",
210
+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
211
+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",
212
+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
213
+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
214
+ className
215
+ ),
216
+ ...props
217
+ }
218
+ );
219
+ });
220
+ SidebarRail.displayName = "SidebarRail";
221
+ const SidebarInset = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
222
+ "main",
223
+ {
224
+ ref,
225
+ className: cn(
226
+ "relative flex min-h-svh flex-1 flex-col bg-background",
227
+ "peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",
228
+ className
229
+ ),
230
+ ...props
231
+ }
232
+ ));
233
+ SidebarInset.displayName = "SidebarInset";
234
+ const SidebarInput = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
235
+ Input,
236
+ {
237
+ ref,
238
+ "data-sidebar": "input",
239
+ className: cn(
240
+ "h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",
241
+ className
242
+ ),
243
+ ...props
244
+ }
245
+ ));
246
+ SidebarInput.displayName = "SidebarInput";
247
+ const SidebarHeader = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
248
+ "div",
249
+ {
250
+ ref,
251
+ "data-sidebar": "header",
252
+ className: cn("flex flex-col gap-2 p-2", className),
253
+ ...props
254
+ }
255
+ ));
256
+ SidebarHeader.displayName = "SidebarHeader";
257
+ const SidebarFooter = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
258
+ "div",
259
+ {
260
+ ref,
261
+ "data-sidebar": "footer",
262
+ className: cn("flex flex-col gap-2 p-2", className),
263
+ ...props
264
+ }
265
+ ));
266
+ SidebarFooter.displayName = "SidebarFooter";
267
+ const SidebarSeparator = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
268
+ Separator,
269
+ {
270
+ ref,
271
+ "data-sidebar": "separator",
272
+ className: cn("mx-2 w-auto bg-sidebar-border", className),
273
+ ...props
274
+ }
275
+ ));
276
+ SidebarSeparator.displayName = "SidebarSeparator";
277
+ const SidebarContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
278
+ "div",
279
+ {
280
+ ref,
281
+ "data-sidebar": "content",
282
+ className: cn(
283
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
284
+ className
285
+ ),
286
+ ...props
287
+ }
288
+ ));
289
+ SidebarContent.displayName = "SidebarContent";
290
+ const SidebarGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
291
+ "div",
292
+ {
293
+ ref,
294
+ "data-sidebar": "group",
295
+ className: cn("relative flex w-full min-w-0 flex-col p-3", className),
296
+ ...props
297
+ }
298
+ ));
299
+ SidebarGroup.displayName = "SidebarGroup";
300
+ const SidebarGroupLabel = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
301
+ const Comp = asChild ? Slot : "div";
302
+ return /* @__PURE__ */ React.createElement(
303
+ Comp,
304
+ {
305
+ ref,
306
+ "data-sidebar": "group-label",
307
+ className: cn(
308
+ "duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
309
+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
310
+ className
311
+ ),
312
+ ...props
313
+ }
314
+ );
315
+ });
316
+ SidebarGroupLabel.displayName = "SidebarGroupLabel";
317
+ const SidebarGroupAction = React.forwardRef(({ className, asChild = false, ...props }, ref) => {
318
+ const Comp = asChild ? Slot : "button";
319
+ return /* @__PURE__ */ React.createElement(
320
+ Comp,
321
+ {
322
+ ref,
323
+ "data-sidebar": "group-action",
324
+ className: cn(
325
+ "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
326
+ // Increases the hit area of the button on mobile.
327
+ "after:absolute after:-inset-2 after:md:hidden",
328
+ "group-data-[collapsible=icon]:hidden",
329
+ className
330
+ ),
331
+ ...props
332
+ }
333
+ );
334
+ });
335
+ SidebarGroupAction.displayName = "SidebarGroupAction";
336
+ const SidebarGroupContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
337
+ "div",
338
+ {
339
+ ref,
340
+ "data-sidebar": "group-content",
341
+ className: cn("w-full text-sm", className),
342
+ ...props
343
+ }
344
+ ));
345
+ SidebarGroupContent.displayName = "SidebarGroupContent";
346
+ const SidebarMenu = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
347
+ "ul",
348
+ {
349
+ ref,
350
+ "data-sidebar": "menu",
351
+ className: cn("flex w-full min-w-0 flex-col gap-6", className),
352
+ ...props
353
+ }
354
+ ));
355
+ SidebarMenu.displayName = "SidebarMenu";
356
+ const SidebarMenuItem = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
357
+ "li",
358
+ {
359
+ ref,
360
+ "data-sidebar": "menu-item",
361
+ className: cn("group/menu-item relative", className),
362
+ ...props
363
+ }
364
+ ));
365
+ SidebarMenuItem.displayName = "SidebarMenuItem";
366
+ const sidebarMenuButtonVariants = cva(
367
+ `peer/menu-button flex w-full items-center gap-4 overflow-hidden
368
+ rounded-full p-2 text-left font-roboto text-grey-800 outline-none ring-sidebar-ring transition-[width,height,padding]
369
+ hover:bg-blue-100 hover:text-sidebar-accent-foreground hover:cursor-pointer
370
+ focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground
371
+ disabled:pointer-events-none disabled:opacity-50
372
+ group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50
373
+ data-[active=true]:bg-blue-100 data-[active=true]:font-medium data-[active=true]:text-blue-600
374
+ data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground
375
+ group-data-[collapsible=icon]:!size-10 group-data-[collapsible=icon]:!p-2
376
+ [&>span:last-child]:truncate [&>svg]:size-6 [&>svg]:shrink-0`,
377
+ {
378
+ variants: {
379
+ variant: {
380
+ default: "hover:bg-blue-100 hover:text-blue-600",
381
+ 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))]"
382
+ },
383
+ size: {
384
+ default: "h-10 text-xl font-medium",
385
+ sm: "h-7",
386
+ lg: "h-12 group-data-[collapsible=icon]:!p-0"
387
+ }
388
+ },
389
+ defaultVariants: {
390
+ variant: "default",
391
+ size: "default"
392
+ }
393
+ }
394
+ );
395
+ const SidebarMenuButton = React.forwardRef(
396
+ // eslint-disable-next-line complexity
397
+ ({
398
+ asChild = false,
399
+ isActive = false,
400
+ variant = "default",
401
+ size = "default",
402
+ tooltip,
403
+ className,
404
+ ...props
405
+ }, ref) => {
406
+ const Comp = asChild ? Slot : "button";
407
+ const { isMobile, state } = useSidebar();
408
+ const button = /* @__PURE__ */ React.createElement(
409
+ Comp,
410
+ {
411
+ ref,
412
+ "data-sidebar": "menu-button",
413
+ "data-size": size,
414
+ "data-active": isActive,
415
+ className: cn(sidebarMenuButtonVariants({ variant, size }), className),
416
+ ...props
417
+ }
418
+ );
419
+ if (!tooltip) {
420
+ return button;
421
+ }
422
+ if (typeof tooltip === "string") {
423
+ tooltip = {
424
+ children: tooltip
425
+ };
426
+ }
427
+ return /* @__PURE__ */ React.createElement(Tooltip, null, /* @__PURE__ */ React.createElement(TooltipTrigger, { asChild: true }, button), /* @__PURE__ */ React.createElement(
428
+ TooltipContent,
429
+ {
430
+ sideOffset: 16,
431
+ side: "right",
432
+ align: "center",
433
+ color: "black",
434
+ hidden: state !== "collapsed" || isMobile,
435
+ ...tooltip
436
+ }
437
+ ));
438
+ }
439
+ );
440
+ SidebarMenuButton.displayName = "SidebarMenuButton";
441
+ const SidebarMenuAction = React.forwardRef(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
442
+ const Comp = asChild ? Slot : "button";
443
+ return /* @__PURE__ */ React.createElement(
444
+ Comp,
445
+ {
446
+ ref,
447
+ "data-sidebar": "menu-action",
448
+ className: cn(
449
+ "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",
450
+ // Increases the hit area of the button on mobile.
451
+ "after:absolute after:-inset-2 after:md:hidden",
452
+ "peer-data-[size=sm]/menu-button:top-1",
453
+ "peer-data-[size=default]/menu-button:top-1.5",
454
+ "peer-data-[size=lg]/menu-button:top-2.5",
455
+ "group-data-[collapsible=icon]:hidden",
456
+ showOnHover && "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",
457
+ className
458
+ ),
459
+ ...props
460
+ }
461
+ );
462
+ });
463
+ SidebarMenuAction.displayName = "SidebarMenuAction";
464
+ const SidebarMenuBadge = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
465
+ "div",
466
+ {
467
+ ref,
468
+ "data-sidebar": "menu-badge",
469
+ className: cn(
470
+ "absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none",
471
+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",
472
+ "peer-data-[size=sm]/menu-button:top-1",
473
+ "peer-data-[size=default]/menu-button:top-1.5",
474
+ "peer-data-[size=lg]/menu-button:top-2.5",
475
+ "group-data-[collapsible=icon]:hidden",
476
+ className
477
+ ),
478
+ ...props
479
+ }
480
+ ));
481
+ SidebarMenuBadge.displayName = "SidebarMenuBadge";
482
+ const SidebarMenuSkeleton = React.forwardRef(({ className, showIcon = false, ...props }, ref) => {
483
+ const width = React.useMemo(
484
+ () => `${Math.floor(Math.random() * 40) + 50}%`,
485
+ []
486
+ );
487
+ return /* @__PURE__ */ React.createElement(
488
+ "div",
489
+ {
490
+ ref,
491
+ "data-sidebar": "menu-skeleton",
492
+ className: cn("rounded-md h-8 flex gap-2 px-2 items-center", className),
493
+ ...props
494
+ },
495
+ showIcon && /* @__PURE__ */ React.createElement(
496
+ Skeleton,
497
+ {
498
+ className: "size-4 rounded-md",
499
+ "data-sidebar": "menu-skeleton-icon"
500
+ }
501
+ ),
502
+ /* @__PURE__ */ React.createElement(
503
+ Skeleton,
504
+ {
505
+ className: "h-4 flex-1 max-w-[--skeleton-width]",
506
+ "data-sidebar": "menu-skeleton-text",
507
+ style: {
508
+ "--skeleton-width": width
509
+ }
510
+ }
511
+ )
512
+ );
513
+ });
514
+ SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
515
+ const SidebarMenuSub = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ React.createElement(
516
+ "ul",
517
+ {
518
+ ref,
519
+ "data-sidebar": "menu-sub",
520
+ className: cn(
521
+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",
522
+ "group-data-[collapsible=icon]:hidden",
523
+ className
524
+ ),
525
+ ...props
526
+ }
527
+ ));
528
+ SidebarMenuSub.displayName = "SidebarMenuSub";
529
+ const SidebarMenuSubItem = React.forwardRef(({ ...props }, ref) => /* @__PURE__ */ React.createElement("li", { ref, ...props }));
530
+ SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
531
+ const SidebarMenuSubButton = React.forwardRef(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {
532
+ const Comp = asChild ? Slot : "a";
533
+ return /* @__PURE__ */ React.createElement(
534
+ Comp,
535
+ {
536
+ ref,
537
+ "data-sidebar": "menu-sub-button",
538
+ "data-size": size,
539
+ "data-active": isActive,
540
+ className: cn(
541
+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 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 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
542
+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
543
+ size === "sm" && "text-xs",
544
+ size === "md" && "text-sm",
545
+ "group-data-[collapsible=icon]:hidden",
546
+ className
547
+ ),
548
+ ...props
549
+ }
550
+ );
551
+ });
552
+ SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
553
+
554
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
@@ -0,0 +1,64 @@
1
+ import * as React from 'react';
2
+ import { cn } from '../../lib/utils.js';
3
+ import * as TooltipPrimitive from '@radix-ui/react-tooltip';
4
+ import { cva } from 'class-variance-authority';
5
+
6
+ const TooltipProvider = TooltipPrimitive.Provider;
7
+ const Tooltip = TooltipPrimitive.Root;
8
+ const TooltipTrigger = TooltipPrimitive.Trigger;
9
+ const TooltipArrow = TooltipPrimitive.Arrow;
10
+ const tooltipContentVariants = cva(
11
+ "z-50 overflow-hidden rounded-lg px-3 py-2 max-w-80 body-small-500 shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
12
+ {
13
+ variants: {
14
+ color: {
15
+ white: "bg-white text-grey-800 [&_.tooltip-arrow]:fill-white",
16
+ black: "bg-black text-white [&_.tooltip-arrow]:fill-black"
17
+ },
18
+ arrow: {
19
+ true: "",
20
+ false: ""
21
+ }
22
+ },
23
+ compoundVariants: [
24
+ {
25
+ color: "white",
26
+ arrow: false,
27
+ class: "border border-grey-100"
28
+ }
29
+ ],
30
+ defaultVariants: {
31
+ color: "white",
32
+ arrow: false
33
+ }
34
+ }
35
+ );
36
+ const TooltipContent = React.forwardRef(
37
+ ({
38
+ color = "white",
39
+ arrow = false,
40
+ side,
41
+ sideOffset = 4,
42
+ align,
43
+ alignOffset,
44
+ className,
45
+ children,
46
+ ...props
47
+ }, ref) => /* @__PURE__ */ React.createElement(
48
+ TooltipPrimitive.Content,
49
+ {
50
+ ref,
51
+ side,
52
+ align,
53
+ sideOffset,
54
+ alignOffset,
55
+ className: cn(tooltipContentVariants({ color, arrow, className })),
56
+ ...props
57
+ },
58
+ children,
59
+ arrow && /* @__PURE__ */ React.createElement(TooltipArrow, { className: "tooltip-arrow", width: 12, height: 6 })
60
+ )
61
+ );
62
+ TooltipContent.displayName = TooltipPrimitive.Content.displayName;
63
+
64
+ export { Tooltip, TooltipArrow, TooltipContent, TooltipProvider, TooltipTrigger };
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+
3
+ const MOBILE_BREAKPOINT = 768;
4
+ function useIsMobile() {
5
+ const [isMobile, setIsMobile] = React.useState(
6
+ undefined
7
+ );
8
+ React.useEffect(() => {
9
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
10
+ const onChange = () => {
11
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
12
+ };
13
+ mql.addEventListener("change", onChange);
14
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
15
+ return () => mql.removeEventListener("change", onChange);
16
+ }, []);
17
+ return !!isMobile;
18
+ }
19
+
20
+ export { useIsMobile };
package/dist/index.d.ts CHANGED
@@ -230,6 +230,11 @@ interface ModulesMenuProps {
230
230
  items?: Omit<ModulesMenuItem, 'bgColor' | 'textColor'>[];
231
231
  }
232
232
 
233
+ interface SocialMenuProps {
234
+ customStyles: CustomStyles$2;
235
+ onOpenSocialMenuChange?: () => void;
236
+ }
237
+
233
238
  interface LanguageOption {
234
239
  id: string;
235
240
  name: string;
@@ -269,16 +274,32 @@ interface CustomStyles {
269
274
  interface HeaderProps extends React$1.HTMLAttributes<HTMLElement>, VariantProps<typeof headerVariants> {
270
275
  customStyles: CustomStyles;
271
276
  module?: string;
277
+ customImgSrc?: string;
278
+ socialMenu?: Omit<SocialMenuProps, 'customStyles'>;
272
279
  userMenu?: Omit<UserMenuProps, 'customStyles'>;
273
280
  helpMenu?: Omit<HelpMenuProps, 'customStyles'>;
274
281
  modulesMenu?: Omit<ModulesMenuProps, 'customStyles'>;
282
+ extraContent?: React$1.ReactNode;
275
283
  onOpenMenuChange?: () => void;
276
284
  }
277
- declare const Header: {
278
- ({ customStyles, module, userMenu, helpMenu, modulesMenu, onOpenMenuChange, className, ...props }: HeaderProps): React$1.JSX.Element;
285
+
286
+ interface SideBarProps {
287
+ items: {
288
+ title: string;
289
+ onClick?: () => void;
290
+ url?: string;
291
+ icon: React$1.ReactNode;
292
+ }[];
293
+ }
294
+ interface LayoutProps extends React$1.HTMLAttributes<HTMLDivElement> {
295
+ header: HeaderProps;
296
+ sideBar: SideBarProps;
297
+ }
298
+ declare const Layout: {
299
+ ({ children, header, sideBar }: LayoutProps): React$1.JSX.Element;
279
300
  displayName: string;
280
301
  };
281
302
 
282
303
  declare const Skeleton: ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => React$1.JSX.Element;
283
304
 
284
- export { type BgColor, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type Color, type ColorToken, type CustomStyles$1 as CustomStyles, type FillColor, type Fonts, Header, type HeaderProps, Skeleton, type TextColor, Typography, type TypographyProps, buttonVariants, colors, fonts, headerVariants, typographyVariants };
305
+ export { type BgColor, Button, type ButtonProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type Color, type ColorToken, type CustomStyles$1 as CustomStyles, type FillColor, type Fonts, Layout, type LayoutProps, type SideBarProps, Skeleton, type TextColor, Typography, type TypographyProps, buttonVariants, colors, fonts, typographyVariants };
package/dist/index.js CHANGED
@@ -3,5 +3,5 @@ export { fonts } from './tokens/fonts.js';
3
3
  export { Button, buttonVariants } from './components/Button/Button.js';
4
4
  export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from './components/Card/Card.js';
5
5
  export { Typography, typographyVariants } from './components/Typography/Typography.js';
6
- export { Header, headerVariants } from './components/Header/Header.js';
6
+ export { Layout } from './components/Layout/Layout.js';
7
7
  export { Skeleton } from './components/Skeleton/Skeleton.js';