@brightlocal/ui-components 2.11.0 → 2.13.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/component-meta.json +474 -27
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +16 -4
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +57 -53
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +7 -1
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +82 -81
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +221 -11
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +687 -406
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +14 -2
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +37 -37
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +3 -3
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +2 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +24 -3
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +121 -117
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +11 -0
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +43 -38
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +20 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +244 -238
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +5 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +207 -206
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +10 -0
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +96 -96
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +7 -2
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +38 -30
- package/dist/drawer.d.ts +2 -2
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +5 -0
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +15 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +313 -305
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +7 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -130
- package/dist/input-group.d.ts +1 -1
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +10 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +108 -106
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +36 -37
- package/dist/list.cjs +1 -1
- package/dist/list.d.ts +25 -4
- package/dist/list.d.ts.map +1 -1
- package/dist/list.js +71 -53
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +25 -22
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +17 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +32 -26
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +29 -3
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +26 -25
- package/dist/popover.cjs +1 -1
- package/dist/popover.js +7 -7
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +6 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +28 -20
- package/dist/resizable.d.ts +1 -1
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +17 -3
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +65 -58
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +16 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +38 -35
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +6 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +42 -41
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +13 -11
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +14 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +57 -39
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +25 -9
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +128 -113
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts +5 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +111 -110
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +1 -2
- package/dist/typography.d.ts.map +1 -1
- package/dist/typography.js +49 -50
- package/package.json +2 -3
- package/src/blocks/data-table.tsx +26 -9
- package/src/blocks/input-list.tsx +12 -1
- package/src/blocks/sidebar.tsx +638 -29
- package/src/components/breadcrumb.tsx +43 -26
- package/src/components/callout.tsx +5 -4
- package/src/components/carousel.tsx +33 -4
- package/src/components/chip.tsx +22 -2
- package/src/components/combobox.tsx +28 -3
- package/src/components/command.tsx +7 -1
- package/src/components/date-picker.tsx +17 -3
- package/src/components/dialog.tsx +17 -4
- package/src/components/drawer.tsx +2 -2
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/global-layout.tsx +15 -2
- package/src/components/input-chip.tsx +12 -1
- package/src/components/input-password.tsx +73 -49
- package/src/components/link.tsx +29 -17
- package/src/components/list.tsx +45 -2
- package/src/components/logo.tsx +10 -2
- package/src/components/map.tsx +23 -0
- package/src/components/pagination.tsx +44 -11
- package/src/components/popover.tsx +1 -1
- package/src/components/rating.tsx +21 -3
- package/src/components/select.tsx +33 -3
- package/src/components/separator.tsx +40 -25
- package/src/components/sheet.tsx +28 -20
- package/src/components/skeleton.tsx +13 -2
- package/src/components/table.tsx +39 -2
- package/src/components/tabs.tsx +195 -146
- package/src/components/text-reveal-motion.tsx +7 -1
- package/src/components/typography.tsx +6 -7
package/src/blocks/sidebar.tsx
CHANGED
|
@@ -18,6 +18,15 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
18
18
|
import { Button } from "../components/button";
|
|
19
19
|
import { Input } from "../components/input";
|
|
20
20
|
import { Separator } from "../components/separator";
|
|
21
|
+
import {
|
|
22
|
+
DropdownMenu,
|
|
23
|
+
DropdownMenuContent,
|
|
24
|
+
DropdownMenuItem,
|
|
25
|
+
DropdownMenuLabel,
|
|
26
|
+
DropdownMenuSeparator,
|
|
27
|
+
DropdownMenuTrigger,
|
|
28
|
+
} from "../components/dropdown-menu";
|
|
29
|
+
import { Popover, PopoverContent, PopoverTrigger } from "../components/popover";
|
|
21
30
|
import {
|
|
22
31
|
Sheet,
|
|
23
32
|
SheetContent,
|
|
@@ -40,6 +49,9 @@ import {
|
|
|
40
49
|
} from "../components/tooltip";
|
|
41
50
|
import { useIsBelowBreakpoint } from "../hooks/use-breakpoint";
|
|
42
51
|
|
|
52
|
+
const SIDEBAR_FOCUS_RING =
|
|
53
|
+
"focus-visible:[box-shadow:0_0_0_1px_color-mix(in_srgb,var(--color-sidebar-ring)_50%,transparent),0_0_0_3px_rgba(0,0,0,0.1)]";
|
|
54
|
+
|
|
43
55
|
/**
|
|
44
56
|
* Sidebar position variants
|
|
45
57
|
*/
|
|
@@ -391,8 +403,8 @@ const Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>(
|
|
|
391
403
|
collapsible = SidebarCollapsible.OFFCANVAS,
|
|
392
404
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- accepted for backward compat
|
|
393
405
|
embedded,
|
|
394
|
-
mobileTitle
|
|
395
|
-
mobileDescription
|
|
406
|
+
mobileTitle,
|
|
407
|
+
mobileDescription,
|
|
396
408
|
className,
|
|
397
409
|
children,
|
|
398
410
|
...props
|
|
@@ -435,9 +447,11 @@ const Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>(
|
|
|
435
447
|
} as React.CSSProperties
|
|
436
448
|
}
|
|
437
449
|
>
|
|
438
|
-
<SheetTitle className="sr-only">
|
|
450
|
+
<SheetTitle className="sr-only">
|
|
451
|
+
{mobileTitle ?? "Navigation"}
|
|
452
|
+
</SheetTitle>
|
|
439
453
|
<SheetDescription className="sr-only">
|
|
440
|
-
{mobileDescription}
|
|
454
|
+
{mobileDescription ?? "Main navigation menu"}
|
|
441
455
|
</SheetDescription>
|
|
442
456
|
<div className="flex h-full w-full flex-col">{children}</div>
|
|
443
457
|
</SheetContent>
|
|
@@ -488,6 +502,11 @@ interface SidebarTriggerProps extends Omit<
|
|
|
488
502
|
* @default "sidebar-trigger"
|
|
489
503
|
*/
|
|
490
504
|
dataHook?: string;
|
|
505
|
+
/**
|
|
506
|
+
* Accessible label for the toggle button.
|
|
507
|
+
* @default "Toggle Sidebar"
|
|
508
|
+
*/
|
|
509
|
+
toggleAriaLabel?: string;
|
|
491
510
|
}
|
|
492
511
|
|
|
493
512
|
const SidebarTrigger = React.forwardRef<
|
|
@@ -495,16 +514,24 @@ const SidebarTrigger = React.forwardRef<
|
|
|
495
514
|
SidebarTriggerProps
|
|
496
515
|
>(
|
|
497
516
|
(
|
|
498
|
-
{
|
|
517
|
+
{
|
|
518
|
+
className,
|
|
519
|
+
onClick,
|
|
520
|
+
dataHook = "sidebar-trigger",
|
|
521
|
+
toggleAriaLabel,
|
|
522
|
+
children,
|
|
523
|
+
...props
|
|
524
|
+
},
|
|
499
525
|
ref
|
|
500
526
|
) => {
|
|
501
527
|
const { toggleSidebar } = useSidebar();
|
|
528
|
+
const resolvedLabel = toggleAriaLabel ?? "Toggle Sidebar";
|
|
502
529
|
|
|
503
530
|
return (
|
|
504
531
|
<Button
|
|
505
532
|
ref={ref}
|
|
506
533
|
iconOnly
|
|
507
|
-
aria-label=
|
|
534
|
+
aria-label={resolvedLabel}
|
|
508
535
|
className={cn("h-7 w-7", className)}
|
|
509
536
|
data-slot="sidebar-trigger"
|
|
510
537
|
dataHook={dataHook}
|
|
@@ -517,7 +544,7 @@ const SidebarTrigger = React.forwardRef<
|
|
|
517
544
|
{...props}
|
|
518
545
|
>
|
|
519
546
|
{children || <PanelLeft />}
|
|
520
|
-
<span className="sr-only">
|
|
547
|
+
<span className="sr-only">{resolvedLabel}</span>
|
|
521
548
|
</Button>
|
|
522
549
|
);
|
|
523
550
|
}
|
|
@@ -527,16 +554,23 @@ SidebarTrigger.displayName = "SidebarTrigger";
|
|
|
527
554
|
/**
|
|
528
555
|
* Props for the SidebarRail component
|
|
529
556
|
*/
|
|
530
|
-
|
|
557
|
+
interface SidebarRailProps extends React.ComponentProps<"button"> {
|
|
558
|
+
/**
|
|
559
|
+
* Accessible label and tooltip for the rail toggle.
|
|
560
|
+
* @default "Toggle Sidebar"
|
|
561
|
+
*/
|
|
562
|
+
toggleAriaLabel?: string;
|
|
563
|
+
}
|
|
531
564
|
|
|
532
565
|
const SidebarRail = React.forwardRef<HTMLButtonElement, SidebarRailProps>(
|
|
533
|
-
({ className, ...props }, ref) => {
|
|
566
|
+
({ className, toggleAriaLabel, ...props }, ref) => {
|
|
534
567
|
const { toggleSidebar } = useSidebar();
|
|
568
|
+
const resolvedLabel = toggleAriaLabel ?? "Toggle Sidebar";
|
|
535
569
|
|
|
536
570
|
return (
|
|
537
571
|
<button
|
|
538
572
|
ref={ref}
|
|
539
|
-
aria-label=
|
|
573
|
+
aria-label={resolvedLabel}
|
|
540
574
|
className={cn(
|
|
541
575
|
"hover:after:bg-sidebar-border absolute inset-y-0 -right-4 z-20 hidden w-4 -translate-x-1/2 transition-transform ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-0.5 sm:flex",
|
|
542
576
|
"cursor-w-resize",
|
|
@@ -547,7 +581,7 @@ const SidebarRail = React.forwardRef<HTMLButtonElement, SidebarRailProps>(
|
|
|
547
581
|
)}
|
|
548
582
|
data-slot="sidebar-rail"
|
|
549
583
|
tabIndex={-1}
|
|
550
|
-
title=
|
|
584
|
+
title={resolvedLabel}
|
|
551
585
|
onClick={toggleSidebar}
|
|
552
586
|
{...props}
|
|
553
587
|
/>
|
|
@@ -609,7 +643,8 @@ const SidebarInput = React.forwardRef<
|
|
|
609
643
|
<Input
|
|
610
644
|
ref={ref}
|
|
611
645
|
className={cn(
|
|
612
|
-
"bg-background
|
|
646
|
+
"bg-background h-8 w-full shadow-none",
|
|
647
|
+
SIDEBAR_FOCUS_RING,
|
|
613
648
|
className
|
|
614
649
|
)}
|
|
615
650
|
data-slot="sidebar-input"
|
|
@@ -623,15 +658,15 @@ SidebarInput.displayName = "SidebarInput";
|
|
|
623
658
|
/**
|
|
624
659
|
* Props for the SidebarHeader component
|
|
625
660
|
*/
|
|
626
|
-
interface SidebarHeaderProps extends React.ComponentProps<"
|
|
661
|
+
interface SidebarHeaderProps extends React.ComponentProps<"header"> {
|
|
627
662
|
/** Data hook for automated testing */
|
|
628
663
|
dataHook?: string;
|
|
629
664
|
}
|
|
630
665
|
|
|
631
|
-
const SidebarHeader = React.forwardRef<
|
|
666
|
+
const SidebarHeader = React.forwardRef<HTMLElement, SidebarHeaderProps>(
|
|
632
667
|
({ className, dataHook, ...props }, ref) => {
|
|
633
668
|
return (
|
|
634
|
-
<
|
|
669
|
+
<header
|
|
635
670
|
ref={ref}
|
|
636
671
|
className={cn(
|
|
637
672
|
"pr-section-xs flex flex-col gap-2 pt-2 pb-9 pl-8",
|
|
@@ -649,15 +684,15 @@ SidebarHeader.displayName = "SidebarHeader";
|
|
|
649
684
|
/**
|
|
650
685
|
* Props for the SidebarFooter component
|
|
651
686
|
*/
|
|
652
|
-
interface SidebarFooterProps extends React.ComponentProps<"
|
|
687
|
+
interface SidebarFooterProps extends React.ComponentProps<"footer"> {
|
|
653
688
|
/** Data hook for automated testing */
|
|
654
689
|
dataHook?: string;
|
|
655
690
|
}
|
|
656
691
|
|
|
657
|
-
const SidebarFooter = React.forwardRef<
|
|
692
|
+
const SidebarFooter = React.forwardRef<HTMLElement, SidebarFooterProps>(
|
|
658
693
|
({ className, dataHook, ...props }, ref) => {
|
|
659
694
|
return (
|
|
660
|
-
<
|
|
695
|
+
<footer
|
|
661
696
|
ref={ref}
|
|
662
697
|
className={cn("flex flex-col gap-2 p-2", className)}
|
|
663
698
|
data-hook={dataHook}
|
|
@@ -707,11 +742,24 @@ interface SidebarContentProps extends Omit<React.ComponentProps<"div">, "dir"> {
|
|
|
707
742
|
const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
|
|
708
743
|
({ className, dataHook, ariaLabel = "Sidebar", children, ...props }, ref) => {
|
|
709
744
|
const { isMobile } = useSidebar();
|
|
745
|
+
|
|
746
|
+
const scrollAreaRef = React.useCallback(
|
|
747
|
+
(node: HTMLDivElement | null) => {
|
|
748
|
+
const viewport = node?.querySelector<HTMLElement>(
|
|
749
|
+
'[data-slot="scroll-area-viewport"]'
|
|
750
|
+
);
|
|
751
|
+
if (viewport) viewport.tabIndex = -1;
|
|
752
|
+
if (typeof ref === "function") ref(node);
|
|
753
|
+
else if (ref) ref.current = node;
|
|
754
|
+
},
|
|
755
|
+
[ref]
|
|
756
|
+
);
|
|
757
|
+
|
|
710
758
|
return (
|
|
711
759
|
<ScrollArea
|
|
712
|
-
ref={
|
|
760
|
+
ref={scrollAreaRef}
|
|
713
761
|
className={cn(
|
|
714
|
-
"min-h-0 flex-1 group-data-[collapsible=icon]:overflow-hidden
|
|
762
|
+
"min-h-0 flex-1 group-data-[collapsible=icon]:overflow-hidden [&_[data-slot=scroll-area-viewport]>div]:block!",
|
|
715
763
|
className
|
|
716
764
|
)}
|
|
717
765
|
dataHook={dataHook ?? "sidebar-content-scroll"}
|
|
@@ -755,7 +803,10 @@ const SidebarGroup = React.forwardRef<HTMLDivElement, SidebarGroupProps>(
|
|
|
755
803
|
SidebarGroup.displayName = "SidebarGroup";
|
|
756
804
|
|
|
757
805
|
const sidebarGroupLabelVariants = cva(
|
|
758
|
-
|
|
806
|
+
[
|
|
807
|
+
"flex h-8 shrink-0 items-center rounded-md px-2 font-medium text-sidebar-foreground/70 outline-none transition-[margin,opacity] duration-200 ease-linear [&>svg]:shrink-0 group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",
|
|
808
|
+
SIDEBAR_FOCUS_RING,
|
|
809
|
+
],
|
|
759
810
|
{
|
|
760
811
|
variants: {
|
|
761
812
|
size: {
|
|
@@ -911,7 +962,8 @@ const SidebarGroupAction = React.forwardRef<
|
|
|
911
962
|
<Comp
|
|
912
963
|
ref={ref}
|
|
913
964
|
className={cn(
|
|
914
|
-
"text-sidebar-foreground
|
|
965
|
+
"text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground absolute top-3.5 right-3 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none [&>svg]:shrink-0",
|
|
966
|
+
SIDEBAR_FOCUS_RING,
|
|
915
967
|
// Increases the hit area of the button on mobile.
|
|
916
968
|
"after:absolute after:-inset-2 after:md:hidden",
|
|
917
969
|
"group-data-[collapsible=icon]:hidden",
|
|
@@ -1047,7 +1099,10 @@ const SidebarCollapseIcon = React.forwardRef<
|
|
|
1047
1099
|
SidebarCollapseIcon.displayName = "SidebarCollapseIcon";
|
|
1048
1100
|
|
|
1049
1101
|
const sidebarMenuButtonVariants = cva(
|
|
1050
|
-
|
|
1102
|
+
[
|
|
1103
|
+
"peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-full px-6 py-2 text-left text-sm font-medium outline-none transition-[color,background-color,border-color,box-shadow,opacity,width,height,padding] duration-150 ease-in-out hover:bg-sidebar-accent hover:text-sidebar-accent-foreground 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-[active=true]:bg-sidebar-accent data-[active=true]:font-semibold data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 group-data-[collapsible=icon]:rounded-md [&>span:last-of-type]:truncate [&>svg]:shrink-0 [&>svg]:opacity-70 data-[active=true]:[&>svg]:opacity-100 group-data-[collapsible=icon]:[&>span]:hidden group-data-[collapsible=icon]:[&>div]:hidden",
|
|
1104
|
+
SIDEBAR_FOCUS_RING,
|
|
1105
|
+
],
|
|
1051
1106
|
{
|
|
1052
1107
|
variants: {
|
|
1053
1108
|
variant: {
|
|
@@ -1202,7 +1257,8 @@ const SidebarMenuAction = React.forwardRef<
|
|
|
1202
1257
|
<Comp
|
|
1203
1258
|
ref={ref}
|
|
1204
1259
|
className={cn(
|
|
1205
|
-
"text-sidebar-foreground
|
|
1260
|
+
"text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 transition-transform outline-none [&>svg]:shrink-0",
|
|
1261
|
+
SIDEBAR_FOCUS_RING,
|
|
1206
1262
|
// Increases the hit area of the button on mobile.
|
|
1207
1263
|
"after:absolute after:-inset-2 after:md:hidden",
|
|
1208
1264
|
"peer-data-[size=sm]/menu-button:top-1",
|
|
@@ -1298,13 +1354,13 @@ const SidebarMenuSkeleton = React.forwardRef<
|
|
|
1298
1354
|
SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
|
|
1299
1355
|
|
|
1300
1356
|
const sidebarMenuSubVariants = cva(
|
|
1301
|
-
"flex min-w-0 flex-col items-start gap-1
|
|
1357
|
+
"flex min-w-0 flex-col items-start gap-1 py-1 group-data-[collapsible=icon]:hidden",
|
|
1302
1358
|
{
|
|
1303
1359
|
variants: {
|
|
1304
1360
|
variant: {
|
|
1305
|
-
default: "",
|
|
1306
|
-
border: "
|
|
1307
|
-
indent: "
|
|
1361
|
+
default: "px-10",
|
|
1362
|
+
border: "border-l border-sidebar-border ml-10 pl-1 pr-10",
|
|
1363
|
+
indent: "px-10",
|
|
1308
1364
|
},
|
|
1309
1365
|
},
|
|
1310
1366
|
defaultVariants: {
|
|
@@ -1408,7 +1464,8 @@ const SidebarMenuSubButton = React.forwardRef<
|
|
|
1408
1464
|
<Comp
|
|
1409
1465
|
ref={ref}
|
|
1410
1466
|
className={cn(
|
|
1411
|
-
"text-sidebar-foreground
|
|
1467
|
+
"text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-foreground flex h-7 min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 transition-[color,background-color,box-shadow,opacity] duration-150 ease-in-out outline-none disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-of-type]:truncate [&>svg]:shrink-0",
|
|
1468
|
+
SIDEBAR_FOCUS_RING,
|
|
1412
1469
|
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
|
1413
1470
|
size === SidebarMenuSubButtonSize.SM && "text-xs",
|
|
1414
1471
|
size === SidebarMenuSubButtonSize.MD && "text-sm",
|
|
@@ -1603,9 +1660,548 @@ const SidebarDrawer = React.forwardRef<HTMLDivElement, SidebarDrawerProps>(
|
|
|
1603
1660
|
);
|
|
1604
1661
|
SidebarDrawer.displayName = "SidebarDrawer";
|
|
1605
1662
|
|
|
1663
|
+
/* -------------------------------------------------------------------------------------------------
|
|
1664
|
+
* SidebarHeaderButton (Small icon button for sidebar header actions)
|
|
1665
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
1666
|
+
|
|
1667
|
+
/**
|
|
1668
|
+
* Props for the SidebarHeaderButton component
|
|
1669
|
+
*/
|
|
1670
|
+
interface SidebarHeaderButtonProps extends Omit<
|
|
1671
|
+
React.ComponentProps<typeof Button>,
|
|
1672
|
+
"dataHook"
|
|
1673
|
+
> {
|
|
1674
|
+
/**
|
|
1675
|
+
* Data hook for automated testing
|
|
1676
|
+
* @default "sidebar-header-button"
|
|
1677
|
+
*/
|
|
1678
|
+
dataHook?: string;
|
|
1679
|
+
/**
|
|
1680
|
+
* Accessible label for the button
|
|
1681
|
+
*/
|
|
1682
|
+
"aria-label": string;
|
|
1683
|
+
}
|
|
1684
|
+
|
|
1685
|
+
const SidebarHeaderButton = React.forwardRef<
|
|
1686
|
+
React.ComponentRef<typeof Button>,
|
|
1687
|
+
SidebarHeaderButtonProps
|
|
1688
|
+
>(
|
|
1689
|
+
(
|
|
1690
|
+
{ className, dataHook = "sidebar-header-button", children, ...props },
|
|
1691
|
+
ref
|
|
1692
|
+
) => {
|
|
1693
|
+
return (
|
|
1694
|
+
<Button
|
|
1695
|
+
ref={ref}
|
|
1696
|
+
{...props}
|
|
1697
|
+
iconOnly
|
|
1698
|
+
className={cn(
|
|
1699
|
+
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground size-7 rounded-md shadow-none",
|
|
1700
|
+
SIDEBAR_FOCUS_RING,
|
|
1701
|
+
className
|
|
1702
|
+
)}
|
|
1703
|
+
data-slot="sidebar-header-button"
|
|
1704
|
+
dataHook={dataHook}
|
|
1705
|
+
size="sm"
|
|
1706
|
+
variant="ghost"
|
|
1707
|
+
>
|
|
1708
|
+
{children}
|
|
1709
|
+
</Button>
|
|
1710
|
+
);
|
|
1711
|
+
}
|
|
1712
|
+
);
|
|
1713
|
+
SidebarHeaderButton.displayName = "SidebarHeaderButton";
|
|
1714
|
+
|
|
1715
|
+
/* -------------------------------------------------------------------------------------------------
|
|
1716
|
+
* SidebarPopoverTrigger (Compact trigger for workspace/team switcher)
|
|
1717
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
1718
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* Props for the SidebarPopoverTrigger component
|
|
1721
|
+
*/
|
|
1722
|
+
interface SidebarPopoverTriggerProps extends React.ComponentProps<"button"> {
|
|
1723
|
+
/**
|
|
1724
|
+
* Data hook for automated testing
|
|
1725
|
+
* @default "sidebar-popover-trigger"
|
|
1726
|
+
*/
|
|
1727
|
+
dataHook?: string;
|
|
1728
|
+
/**
|
|
1729
|
+
* Icon element displayed in the trigger
|
|
1730
|
+
*/
|
|
1731
|
+
icon?: React.ReactNode;
|
|
1732
|
+
/**
|
|
1733
|
+
* Accessible label for the trigger button.
|
|
1734
|
+
* @default "Switch workspace"
|
|
1735
|
+
*/
|
|
1736
|
+
triggerAriaLabel?: string;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
const SidebarPopoverTrigger = React.forwardRef<
|
|
1740
|
+
HTMLButtonElement,
|
|
1741
|
+
SidebarPopoverTriggerProps
|
|
1742
|
+
>(
|
|
1743
|
+
(
|
|
1744
|
+
{
|
|
1745
|
+
className,
|
|
1746
|
+
dataHook = "sidebar-popover-trigger",
|
|
1747
|
+
icon,
|
|
1748
|
+
triggerAriaLabel,
|
|
1749
|
+
children,
|
|
1750
|
+
...props
|
|
1751
|
+
},
|
|
1752
|
+
ref
|
|
1753
|
+
) => {
|
|
1754
|
+
return (
|
|
1755
|
+
<button
|
|
1756
|
+
ref={ref}
|
|
1757
|
+
aria-label={triggerAriaLabel ?? "Switch workspace"}
|
|
1758
|
+
className={cn(
|
|
1759
|
+
"text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground flex items-center gap-2 rounded-md px-1.5 py-2 text-sm font-semibold transition-colors duration-200 ease-out outline-none",
|
|
1760
|
+
SIDEBAR_FOCUS_RING,
|
|
1761
|
+
className
|
|
1762
|
+
)}
|
|
1763
|
+
data-hook={dataHook}
|
|
1764
|
+
data-slot="sidebar-popover-trigger"
|
|
1765
|
+
type="button"
|
|
1766
|
+
{...props}
|
|
1767
|
+
>
|
|
1768
|
+
{icon && (
|
|
1769
|
+
<span className="bg-sidebar-primary text-sidebar-primary-foreground flex size-5 shrink-0 items-center justify-center rounded-md">
|
|
1770
|
+
{icon}
|
|
1771
|
+
</span>
|
|
1772
|
+
)}
|
|
1773
|
+
<span className="truncate">{children}</span>
|
|
1774
|
+
<ChevronDown className="shrink-0 opacity-50" size={16} />
|
|
1775
|
+
</button>
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
);
|
|
1779
|
+
SidebarPopoverTrigger.displayName = "SidebarPopoverTrigger";
|
|
1780
|
+
|
|
1781
|
+
/* -------------------------------------------------------------------------------------------------
|
|
1782
|
+
* SidebarPopoverMenuItem (Menu item inside the popover menu)
|
|
1783
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
1784
|
+
|
|
1785
|
+
/**
|
|
1786
|
+
* Props for the SidebarPopoverMenuItem component
|
|
1787
|
+
*/
|
|
1788
|
+
interface SidebarPopoverMenuItemProps extends React.ComponentProps<"button"> {
|
|
1789
|
+
/**
|
|
1790
|
+
* Data hook for automated testing
|
|
1791
|
+
*/
|
|
1792
|
+
dataHook?: string;
|
|
1793
|
+
/**
|
|
1794
|
+
* Icon element displayed in the icon box
|
|
1795
|
+
*/
|
|
1796
|
+
icon?: React.ReactNode;
|
|
1797
|
+
/**
|
|
1798
|
+
* Keyboard shortcut text shown on the right
|
|
1799
|
+
*/
|
|
1800
|
+
shortcut?: string;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
const SidebarPopoverMenuItem = React.forwardRef<
|
|
1804
|
+
HTMLButtonElement,
|
|
1805
|
+
SidebarPopoverMenuItemProps
|
|
1806
|
+
>(({ className, dataHook, icon, shortcut, children, ...props }, ref) => {
|
|
1807
|
+
return (
|
|
1808
|
+
<button
|
|
1809
|
+
ref={ref}
|
|
1810
|
+
className={cn(
|
|
1811
|
+
"text-popover-foreground hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground flex h-10 w-full items-center gap-2 rounded-xs p-2 text-sm transition-colors duration-150 ease-in-out outline-none",
|
|
1812
|
+
SIDEBAR_FOCUS_RING,
|
|
1813
|
+
className
|
|
1814
|
+
)}
|
|
1815
|
+
data-hook={dataHook}
|
|
1816
|
+
data-slot="sidebar-popover-menu-item"
|
|
1817
|
+
type="button"
|
|
1818
|
+
{...props}
|
|
1819
|
+
>
|
|
1820
|
+
{icon && (
|
|
1821
|
+
<span className="border-border flex size-6 shrink-0 items-center justify-center rounded-xs border [&_svg]:size-4">
|
|
1822
|
+
{icon}
|
|
1823
|
+
</span>
|
|
1824
|
+
)}
|
|
1825
|
+
<span className="min-w-px flex-1 truncate text-left">{children}</span>
|
|
1826
|
+
{shortcut && (
|
|
1827
|
+
<span className="text-popover-foreground/60 shrink-0 text-xs">
|
|
1828
|
+
{shortcut}
|
|
1829
|
+
</span>
|
|
1830
|
+
)}
|
|
1831
|
+
</button>
|
|
1832
|
+
);
|
|
1833
|
+
});
|
|
1834
|
+
SidebarPopoverMenuItem.displayName = "SidebarPopoverMenuItem";
|
|
1835
|
+
|
|
1836
|
+
/* -------------------------------------------------------------------------------------------------
|
|
1837
|
+
* SidebarPopoverMenu (Dropdown panel for workspace/team switcher)
|
|
1838
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
1839
|
+
|
|
1840
|
+
/**
|
|
1841
|
+
* Props for the SidebarPopoverMenu component
|
|
1842
|
+
*/
|
|
1843
|
+
interface SidebarPopoverMenuProps extends React.ComponentProps<"div"> {
|
|
1844
|
+
/**
|
|
1845
|
+
* Data hook for automated testing
|
|
1846
|
+
* @default "sidebar-popover-menu"
|
|
1847
|
+
*/
|
|
1848
|
+
dataHook?: string;
|
|
1849
|
+
/**
|
|
1850
|
+
* Group title displayed at the top of the menu.
|
|
1851
|
+
* @default "Teams"
|
|
1852
|
+
*/
|
|
1853
|
+
groupTitle?: string;
|
|
1854
|
+
/**
|
|
1855
|
+
* Items to render in the menu
|
|
1856
|
+
*/
|
|
1857
|
+
items?: Array<{
|
|
1858
|
+
label: string;
|
|
1859
|
+
icon?: React.ReactNode;
|
|
1860
|
+
shortcut?: string;
|
|
1861
|
+
onClick?: () => void;
|
|
1862
|
+
}>;
|
|
1863
|
+
/**
|
|
1864
|
+
* Label for the add action at the bottom.
|
|
1865
|
+
* @default "Add team"
|
|
1866
|
+
*/
|
|
1867
|
+
addActionLabel?: string;
|
|
1868
|
+
/**
|
|
1869
|
+
* Icon for the add action
|
|
1870
|
+
*/
|
|
1871
|
+
addActionIcon?: React.ReactNode;
|
|
1872
|
+
/**
|
|
1873
|
+
* Callback when add action is clicked
|
|
1874
|
+
*/
|
|
1875
|
+
onAddAction?: () => void;
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
const SidebarPopoverMenu = React.forwardRef<
|
|
1879
|
+
HTMLDivElement,
|
|
1880
|
+
SidebarPopoverMenuProps
|
|
1881
|
+
>(
|
|
1882
|
+
(
|
|
1883
|
+
{
|
|
1884
|
+
className,
|
|
1885
|
+
dataHook = "sidebar-popover-menu",
|
|
1886
|
+
groupTitle = "Teams",
|
|
1887
|
+
items,
|
|
1888
|
+
addActionLabel,
|
|
1889
|
+
addActionIcon,
|
|
1890
|
+
onAddAction,
|
|
1891
|
+
children,
|
|
1892
|
+
...props
|
|
1893
|
+
},
|
|
1894
|
+
ref
|
|
1895
|
+
) => {
|
|
1896
|
+
return (
|
|
1897
|
+
<div
|
|
1898
|
+
ref={ref}
|
|
1899
|
+
className={cn("flex flex-col", className)}
|
|
1900
|
+
data-hook={dataHook}
|
|
1901
|
+
data-slot="sidebar-popover-menu"
|
|
1902
|
+
{...props}
|
|
1903
|
+
>
|
|
1904
|
+
{children || (
|
|
1905
|
+
<>
|
|
1906
|
+
<div className="flex flex-col items-start p-1">
|
|
1907
|
+
{groupTitle && (
|
|
1908
|
+
<div className="flex w-full items-center px-2 py-1.5">
|
|
1909
|
+
<span className="text-muted-foreground flex-1 text-xs font-medium">
|
|
1910
|
+
{groupTitle}
|
|
1911
|
+
</span>
|
|
1912
|
+
</div>
|
|
1913
|
+
)}
|
|
1914
|
+
{items?.map((item, index) => (
|
|
1915
|
+
<SidebarPopoverMenuItem
|
|
1916
|
+
key={index}
|
|
1917
|
+
icon={item.icon}
|
|
1918
|
+
shortcut={item.shortcut}
|
|
1919
|
+
onClick={item.onClick}
|
|
1920
|
+
>
|
|
1921
|
+
{item.label}
|
|
1922
|
+
</SidebarPopoverMenuItem>
|
|
1923
|
+
))}
|
|
1924
|
+
</div>
|
|
1925
|
+
{onAddAction && (
|
|
1926
|
+
<>
|
|
1927
|
+
<Separator />
|
|
1928
|
+
<div className="flex flex-col items-start p-1">
|
|
1929
|
+
<SidebarPopoverMenuItem
|
|
1930
|
+
icon={addActionIcon || <Plus size={16} />}
|
|
1931
|
+
onClick={onAddAction}
|
|
1932
|
+
>
|
|
1933
|
+
{addActionLabel ?? "Add team"}
|
|
1934
|
+
</SidebarPopoverMenuItem>
|
|
1935
|
+
</div>
|
|
1936
|
+
</>
|
|
1937
|
+
)}
|
|
1938
|
+
</>
|
|
1939
|
+
)}
|
|
1940
|
+
</div>
|
|
1941
|
+
);
|
|
1942
|
+
}
|
|
1943
|
+
);
|
|
1944
|
+
SidebarPopoverMenu.displayName = "SidebarPopoverMenu";
|
|
1945
|
+
|
|
1946
|
+
/* -------------------------------------------------------------------------------------------------
|
|
1947
|
+
* SidebarSwitcher (Composed PopoverTrigger + PopoverMenu using DS Popover)
|
|
1948
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
1949
|
+
|
|
1950
|
+
/**
|
|
1951
|
+
* Props for the SidebarSwitcher component
|
|
1952
|
+
*/
|
|
1953
|
+
interface SidebarSwitcherProps {
|
|
1954
|
+
/**
|
|
1955
|
+
* Data hook for automated testing
|
|
1956
|
+
* @default "sidebar-switcher"
|
|
1957
|
+
*/
|
|
1958
|
+
dataHook?: string;
|
|
1959
|
+
/**
|
|
1960
|
+
* Icon for the trigger
|
|
1961
|
+
*/
|
|
1962
|
+
icon?: React.ReactNode;
|
|
1963
|
+
/**
|
|
1964
|
+
* Label displayed in the trigger
|
|
1965
|
+
*/
|
|
1966
|
+
label: string;
|
|
1967
|
+
/**
|
|
1968
|
+
* Accessible label for the trigger button.
|
|
1969
|
+
* @default "Switch workspace"
|
|
1970
|
+
*/
|
|
1971
|
+
triggerAriaLabel?: string;
|
|
1972
|
+
/**
|
|
1973
|
+
* Additional CSS classes for the trigger
|
|
1974
|
+
*/
|
|
1975
|
+
triggerClassName?: string;
|
|
1976
|
+
children?: React.ReactNode;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
function SidebarSwitcher({
|
|
1980
|
+
dataHook = "sidebar-switcher",
|
|
1981
|
+
icon,
|
|
1982
|
+
label,
|
|
1983
|
+
triggerAriaLabel,
|
|
1984
|
+
triggerClassName,
|
|
1985
|
+
children,
|
|
1986
|
+
}: SidebarSwitcherProps) {
|
|
1987
|
+
return (
|
|
1988
|
+
<Popover>
|
|
1989
|
+
<PopoverTrigger asChild>
|
|
1990
|
+
<SidebarPopoverTrigger
|
|
1991
|
+
className={triggerClassName}
|
|
1992
|
+
dataHook={`${dataHook}-trigger`}
|
|
1993
|
+
icon={icon}
|
|
1994
|
+
triggerAriaLabel={triggerAriaLabel}
|
|
1995
|
+
>
|
|
1996
|
+
{label}
|
|
1997
|
+
</SidebarPopoverTrigger>
|
|
1998
|
+
</PopoverTrigger>
|
|
1999
|
+
<PopoverContent
|
|
2000
|
+
align="start"
|
|
2001
|
+
className="w-[316px] p-0"
|
|
2002
|
+
dataHook={`${dataHook}-content`}
|
|
2003
|
+
side="bottom"
|
|
2004
|
+
sideOffset={4}
|
|
2005
|
+
>
|
|
2006
|
+
{children}
|
|
2007
|
+
</PopoverContent>
|
|
2008
|
+
</Popover>
|
|
2009
|
+
);
|
|
2010
|
+
}
|
|
2011
|
+
SidebarSwitcher.displayName = "SidebarSwitcher";
|
|
2012
|
+
|
|
2013
|
+
/* -------------------------------------------------------------------------------------------------
|
|
2014
|
+
* SidebarAccountDropdown (Account menu dropdown)
|
|
2015
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
2016
|
+
|
|
2017
|
+
/**
|
|
2018
|
+
* Props for the SidebarAccountDropdown component
|
|
2019
|
+
*/
|
|
2020
|
+
interface SidebarAccountDropdownProps {
|
|
2021
|
+
/**
|
|
2022
|
+
* Data hook for automated testing
|
|
2023
|
+
* @default "sidebar-account-dropdown"
|
|
2024
|
+
*/
|
|
2025
|
+
dataHook?: string;
|
|
2026
|
+
/**
|
|
2027
|
+
* User's display name
|
|
2028
|
+
*/
|
|
2029
|
+
name: string;
|
|
2030
|
+
/**
|
|
2031
|
+
* User's email address
|
|
2032
|
+
*/
|
|
2033
|
+
email: string;
|
|
2034
|
+
/**
|
|
2035
|
+
* Avatar element (use DS Avatar component)
|
|
2036
|
+
*/
|
|
2037
|
+
avatar?: React.ReactNode;
|
|
2038
|
+
/**
|
|
2039
|
+
* Menu items to render. Each group is separated by a divider.
|
|
2040
|
+
*/
|
|
2041
|
+
menuGroups?: Array<
|
|
2042
|
+
Array<{
|
|
2043
|
+
label: string;
|
|
2044
|
+
onClick?: () => void;
|
|
2045
|
+
icon?: React.ReactNode;
|
|
2046
|
+
}>
|
|
2047
|
+
>;
|
|
2048
|
+
/**
|
|
2049
|
+
* Accessible label for the account menu trigger.
|
|
2050
|
+
* @default "Account menu"
|
|
2051
|
+
*/
|
|
2052
|
+
triggerAriaLabel?: string;
|
|
2053
|
+
/**
|
|
2054
|
+
* Dropdown alignment
|
|
2055
|
+
* @default "end"
|
|
2056
|
+
*/
|
|
2057
|
+
align?: "start" | "center" | "end";
|
|
2058
|
+
/**
|
|
2059
|
+
* Dropdown side
|
|
2060
|
+
* @default "top"
|
|
2061
|
+
*/
|
|
2062
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
2063
|
+
children?: React.ReactNode;
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
function SidebarAccountDropdown({
|
|
2067
|
+
dataHook = "sidebar-account-dropdown",
|
|
2068
|
+
name,
|
|
2069
|
+
email,
|
|
2070
|
+
avatar,
|
|
2071
|
+
menuGroups,
|
|
2072
|
+
triggerAriaLabel,
|
|
2073
|
+
align = "end",
|
|
2074
|
+
side = "top",
|
|
2075
|
+
children,
|
|
2076
|
+
}: SidebarAccountDropdownProps) {
|
|
2077
|
+
return (
|
|
2078
|
+
<DropdownMenu>
|
|
2079
|
+
<DropdownMenuTrigger asChild>
|
|
2080
|
+
<SidebarMenuButton
|
|
2081
|
+
aria-label={triggerAriaLabel ?? "Account menu"}
|
|
2082
|
+
className="h-auto py-1.5"
|
|
2083
|
+
dataHook={`${dataHook}-button`}
|
|
2084
|
+
size={SidebarMenuButtonSize.LG}
|
|
2085
|
+
>
|
|
2086
|
+
{avatar}
|
|
2087
|
+
<div className="flex min-w-0 flex-1 flex-col gap-0.5 leading-none">
|
|
2088
|
+
<span className="truncate text-sm font-semibold">{name}</span>
|
|
2089
|
+
<span className="truncate text-xs font-normal">{email}</span>
|
|
2090
|
+
</div>
|
|
2091
|
+
</SidebarMenuButton>
|
|
2092
|
+
</DropdownMenuTrigger>
|
|
2093
|
+
<DropdownMenuContent
|
|
2094
|
+
align={align}
|
|
2095
|
+
className="w-56"
|
|
2096
|
+
dataHook={`${dataHook}-content`}
|
|
2097
|
+
side={side}
|
|
2098
|
+
sideOffset={4}
|
|
2099
|
+
>
|
|
2100
|
+
{children || (
|
|
2101
|
+
<>
|
|
2102
|
+
<DropdownMenuLabel className="flex items-center gap-2 px-1 py-1.5">
|
|
2103
|
+
{avatar}
|
|
2104
|
+
<div className="flex min-w-0 flex-1 flex-col gap-0.5 leading-none">
|
|
2105
|
+
<span className="truncate text-sm font-semibold">{name}</span>
|
|
2106
|
+
<span className="truncate text-xs font-normal">{email}</span>
|
|
2107
|
+
</div>
|
|
2108
|
+
</DropdownMenuLabel>
|
|
2109
|
+
{menuGroups?.map((group, groupIndex) => (
|
|
2110
|
+
<React.Fragment key={groupIndex}>
|
|
2111
|
+
<DropdownMenuSeparator />
|
|
2112
|
+
{group.map((item, itemIndex) => (
|
|
2113
|
+
<DropdownMenuItem key={itemIndex} onClick={item.onClick}>
|
|
2114
|
+
{item.icon}
|
|
2115
|
+
{item.label}
|
|
2116
|
+
</DropdownMenuItem>
|
|
2117
|
+
))}
|
|
2118
|
+
</React.Fragment>
|
|
2119
|
+
))}
|
|
2120
|
+
</>
|
|
2121
|
+
)}
|
|
2122
|
+
</DropdownMenuContent>
|
|
2123
|
+
</DropdownMenu>
|
|
2124
|
+
);
|
|
2125
|
+
}
|
|
2126
|
+
SidebarAccountDropdown.displayName = "SidebarAccountDropdown";
|
|
2127
|
+
|
|
2128
|
+
/* -------------------------------------------------------------------------------------------------
|
|
2129
|
+
* SidebarInboxItem (Notification/inbox item)
|
|
2130
|
+
* -----------------------------------------------------------------------------------------------*/
|
|
2131
|
+
|
|
2132
|
+
/**
|
|
2133
|
+
* Props for the SidebarInboxItem component
|
|
2134
|
+
*/
|
|
2135
|
+
interface SidebarInboxItemProps extends React.ComponentProps<"button"> {
|
|
2136
|
+
/**
|
|
2137
|
+
* Data hook for automated testing
|
|
2138
|
+
*/
|
|
2139
|
+
dataHook?: string;
|
|
2140
|
+
/**
|
|
2141
|
+
* Sender or person name
|
|
2142
|
+
*/
|
|
2143
|
+
senderName: string;
|
|
2144
|
+
/**
|
|
2145
|
+
* Notification title
|
|
2146
|
+
*/
|
|
2147
|
+
title: string;
|
|
2148
|
+
/**
|
|
2149
|
+
* Preview description text
|
|
2150
|
+
*/
|
|
2151
|
+
description?: string;
|
|
2152
|
+
/**
|
|
2153
|
+
* Timestamp string
|
|
2154
|
+
*/
|
|
2155
|
+
timestamp?: string;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
const SidebarInboxItem = React.forwardRef<
|
|
2159
|
+
HTMLButtonElement,
|
|
2160
|
+
SidebarInboxItemProps
|
|
2161
|
+
>(
|
|
2162
|
+
(
|
|
2163
|
+
{
|
|
2164
|
+
className,
|
|
2165
|
+
dataHook,
|
|
2166
|
+
senderName,
|
|
2167
|
+
title,
|
|
2168
|
+
description,
|
|
2169
|
+
timestamp,
|
|
2170
|
+
...props
|
|
2171
|
+
},
|
|
2172
|
+
ref
|
|
2173
|
+
) => {
|
|
2174
|
+
return (
|
|
2175
|
+
<button
|
|
2176
|
+
ref={ref}
|
|
2177
|
+
className={cn(
|
|
2178
|
+
"border-sidebar-border text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent flex w-full flex-col gap-2 border-b p-4 text-left transition-colors duration-150 ease-in-out outline-none",
|
|
2179
|
+
SIDEBAR_FOCUS_RING,
|
|
2180
|
+
className
|
|
2181
|
+
)}
|
|
2182
|
+
data-hook={dataHook}
|
|
2183
|
+
data-slot="sidebar-inbox-item"
|
|
2184
|
+
type="button"
|
|
2185
|
+
{...props}
|
|
2186
|
+
>
|
|
2187
|
+
<div className="flex w-full items-center justify-between text-sm">
|
|
2188
|
+
<span>{senderName}</span>
|
|
2189
|
+
{timestamp && <span>{timestamp}</span>}
|
|
2190
|
+
</div>
|
|
2191
|
+
<p className="w-full text-sm font-medium">{title}</p>
|
|
2192
|
+
{description && (
|
|
2193
|
+
<p className="w-full truncate text-xs">{description}</p>
|
|
2194
|
+
)}
|
|
2195
|
+
</button>
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
);
|
|
2199
|
+
SidebarInboxItem.displayName = "SidebarInboxItem";
|
|
2200
|
+
|
|
1606
2201
|
// Component exports
|
|
1607
2202
|
export {
|
|
1608
2203
|
Sidebar,
|
|
2204
|
+
SidebarAccountDropdown,
|
|
1609
2205
|
SidebarCollapseIcon,
|
|
1610
2206
|
/** @deprecated Use `SidebarTrigger` instead */
|
|
1611
2207
|
SidebarDrawer,
|
|
@@ -1616,6 +2212,8 @@ export {
|
|
|
1616
2212
|
SidebarGroupContent,
|
|
1617
2213
|
SidebarGroupLabel,
|
|
1618
2214
|
SidebarHeader,
|
|
2215
|
+
SidebarHeaderButton,
|
|
2216
|
+
SidebarInboxItem,
|
|
1619
2217
|
SidebarInput,
|
|
1620
2218
|
SidebarInset,
|
|
1621
2219
|
SidebarMenu,
|
|
@@ -1630,15 +2228,20 @@ export {
|
|
|
1630
2228
|
SidebarMenuSub,
|
|
1631
2229
|
SidebarMenuSubButton,
|
|
1632
2230
|
SidebarMenuSubItem,
|
|
2231
|
+
SidebarPopoverMenu,
|
|
2232
|
+
SidebarPopoverMenuItem,
|
|
2233
|
+
SidebarPopoverTrigger,
|
|
1633
2234
|
SidebarProvider,
|
|
1634
2235
|
SidebarRail,
|
|
1635
2236
|
SidebarSeparator,
|
|
2237
|
+
SidebarSwitcher,
|
|
1636
2238
|
SidebarTrigger,
|
|
1637
2239
|
useSidebar,
|
|
1638
2240
|
};
|
|
1639
2241
|
|
|
1640
2242
|
// Type exports
|
|
1641
2243
|
export type {
|
|
2244
|
+
SidebarAccountDropdownProps,
|
|
1642
2245
|
SidebarProviderProps,
|
|
1643
2246
|
SidebarProps,
|
|
1644
2247
|
/** @deprecated Use `SidebarTriggerProps` instead */
|
|
@@ -1648,6 +2251,8 @@ export type {
|
|
|
1648
2251
|
SidebarInsetProps,
|
|
1649
2252
|
SidebarInputProps,
|
|
1650
2253
|
SidebarHeaderProps,
|
|
2254
|
+
SidebarHeaderButtonProps,
|
|
2255
|
+
SidebarInboxItemProps,
|
|
1651
2256
|
SidebarFooterProps,
|
|
1652
2257
|
SidebarSeparatorProps,
|
|
1653
2258
|
SidebarContentProps,
|
|
@@ -1668,4 +2273,8 @@ export type {
|
|
|
1668
2273
|
SidebarMenuSubProps,
|
|
1669
2274
|
SidebarMenuSubItemProps,
|
|
1670
2275
|
SidebarMenuSubButtonProps,
|
|
2276
|
+
SidebarPopoverMenuProps,
|
|
2277
|
+
SidebarPopoverMenuItemProps,
|
|
2278
|
+
SidebarPopoverTriggerProps,
|
|
2279
|
+
SidebarSwitcherProps,
|
|
1671
2280
|
};
|