@brightlocal/ui-components 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +1 -1
- package/dist/alert.cjs +1 -1
- package/dist/alert.js +1 -1
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +37 -306
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +392 -489
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +4 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +33 -33
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +5 -18
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +21 -23
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +75 -67
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +241 -194
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +3 -0
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +361 -366
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +5 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +47 -39
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +6 -0
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +79 -76
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +4 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +32 -31
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +26 -24
- package/dist/link.cjs +1 -1
- package/dist/link.js +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -4
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +17 -20
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +3 -0
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +31 -30
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts +6 -54
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +73 -84
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +8 -10
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +78 -86
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +10 -23
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +47 -55
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +19 -28
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +24 -40
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +3 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +57 -56
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +4 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +19 -21
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +5 -10
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +24 -26
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +17 -20
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +42 -45
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts +2 -12
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +37 -41
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +16 -12
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +56 -58
- package/dist/tabs.d.ts +27 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +19 -18
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.d.ts +57 -7
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +60 -67
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts +12 -26
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +18 -22
- package/package.json +2 -2
- package/src/blocks/data-table.tsx +1 -1
- package/src/blocks/sidebar.tsx +157 -532
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/calendar.tsx +6 -4
- package/src/components/centred-layout.tsx +11 -24
- package/src/components/checkbox.tsx +5 -6
- package/src/components/combobox.tsx +481 -301
- package/src/components/command.tsx +1 -1
- package/src/components/context-menu.tsx +1 -1
- package/src/components/date-picker.tsx +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/field.tsx +2 -0
- package/src/components/input-group.tsx +14 -2
- package/src/components/input-otp.tsx +17 -2
- package/src/components/input-password.tsx +7 -2
- package/src/components/input.tsx +11 -3
- package/src/components/link.tsx +1 -1
- package/src/components/logo.tsx +10 -8
- package/src/components/menubar.tsx +3 -1
- package/src/components/navigation-menu.tsx +37 -99
- package/src/components/pagination.tsx +13 -19
- package/src/components/radio-group.tsx +28 -38
- package/src/components/resizable.tsx +5 -43
- package/src/components/select.tsx +8 -3
- package/src/components/separator.tsx +5 -5
- package/src/components/sheet.tsx +6 -11
- package/src/components/sonner.tsx +24 -27
- package/src/components/switch.figma.tsx +7 -11
- package/src/components/switch.tsx +9 -19
- package/src/components/table.tsx +23 -18
- package/src/components/tabs.tsx +27 -3
- package/src/components/textarea.tsx +12 -5
- package/src/components/toggle-group.tsx +115 -86
- package/src/components/toggle.figma.tsx +13 -19
- package/src/components/toggle.tsx +32 -48
package/src/blocks/sidebar.tsx
CHANGED
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
Minus,
|
|
12
12
|
PanelLeft,
|
|
13
13
|
Ellipsis,
|
|
14
|
-
} from "
|
|
14
|
+
} from "@brightlocal/icons";
|
|
15
15
|
|
|
16
16
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
17
17
|
import { Button } from "../components/button";
|
|
18
18
|
import { Input } from "../components/input";
|
|
19
19
|
import { Separator } from "../components/separator";
|
|
20
|
-
import { Sheet, SheetContent
|
|
20
|
+
import { Sheet, SheetContent } from "../components/sheet";
|
|
21
21
|
import { Skeleton } from "../components/skeleton";
|
|
22
22
|
import {
|
|
23
23
|
Tooltip,
|
|
@@ -398,7 +398,7 @@ const Sidebar = React.forwardRef<HTMLDivElement, SidebarProps>(
|
|
|
398
398
|
data-hook={`${dataHook}-mobile-content`}
|
|
399
399
|
data-mobile="true"
|
|
400
400
|
data-sidebar="sidebar"
|
|
401
|
-
side=
|
|
401
|
+
side="left"
|
|
402
402
|
style={
|
|
403
403
|
{
|
|
404
404
|
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
|
@@ -457,80 +457,52 @@ Sidebar.displayName = "Sidebar";
|
|
|
457
457
|
/**
|
|
458
458
|
* Props for the SidebarTrigger component
|
|
459
459
|
*/
|
|
460
|
-
interface SidebarTriggerProps extends
|
|
460
|
+
interface SidebarTriggerProps extends Omit<
|
|
461
|
+
React.ComponentProps<typeof Button>,
|
|
462
|
+
"dataHook"
|
|
463
|
+
> {
|
|
461
464
|
/**
|
|
462
|
-
* Data hook for automated testing
|
|
463
|
-
*
|
|
464
|
-
*/
|
|
465
|
-
dataHook: string;
|
|
466
|
-
/**
|
|
467
|
-
* Tracking element identifier for analytics
|
|
468
|
-
* Defaults to "sidebar-trigger" if not provided
|
|
469
|
-
*/
|
|
470
|
-
trackingEl?: string;
|
|
471
|
-
/**
|
|
472
|
-
* Tracking label for analytics context
|
|
465
|
+
* Data hook for automated testing
|
|
466
|
+
* @default "sidebar-trigger"
|
|
473
467
|
*/
|
|
474
|
-
|
|
468
|
+
dataHook?: string;
|
|
475
469
|
}
|
|
476
470
|
|
|
477
471
|
const SidebarTrigger = React.forwardRef<
|
|
478
472
|
React.ElementRef<typeof Button>,
|
|
479
473
|
SidebarTriggerProps
|
|
480
|
-
>(
|
|
481
|
-
(
|
|
482
|
-
{ dataHook, trackingEl, trackingLabel, className, onClick, ...props },
|
|
483
|
-
ref
|
|
484
|
-
) => {
|
|
485
|
-
const { toggleSidebar } = useSidebar();
|
|
474
|
+
>(({ className, onClick, dataHook = "sidebar-trigger", ...props }, ref) => {
|
|
475
|
+
const { toggleSidebar } = useSidebar();
|
|
486
476
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
>
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
);
|
|
477
|
+
return (
|
|
478
|
+
<Button
|
|
479
|
+
ref={ref}
|
|
480
|
+
aria-label="Toggle Sidebar"
|
|
481
|
+
className={cn("h-7 w-7", className)}
|
|
482
|
+
data-slot="sidebar-trigger"
|
|
483
|
+
dataHook={dataHook}
|
|
484
|
+
size="sm"
|
|
485
|
+
variant="ghost"
|
|
486
|
+
onClick={(event) => {
|
|
487
|
+
onClick?.(event);
|
|
488
|
+
toggleSidebar();
|
|
489
|
+
}}
|
|
490
|
+
{...props}
|
|
491
|
+
>
|
|
492
|
+
<PanelLeft />
|
|
493
|
+
<span className="sr-only">Toggle Sidebar</span>
|
|
494
|
+
</Button>
|
|
495
|
+
);
|
|
496
|
+
});
|
|
510
497
|
SidebarTrigger.displayName = "SidebarTrigger";
|
|
511
498
|
|
|
512
499
|
/**
|
|
513
500
|
* Props for the SidebarRail component
|
|
514
501
|
*/
|
|
515
|
-
|
|
516
|
-
/**
|
|
517
|
-
* Data hook for automated testing (REQUIRED)
|
|
518
|
-
* Used to identify component in tests and E2E automation
|
|
519
|
-
*/
|
|
520
|
-
dataHook: string;
|
|
521
|
-
/**
|
|
522
|
-
* Tracking element identifier for analytics
|
|
523
|
-
* Defaults to "sidebar-rail" if not provided
|
|
524
|
-
*/
|
|
525
|
-
trackingEl?: string;
|
|
526
|
-
/**
|
|
527
|
-
* Tracking label for analytics context
|
|
528
|
-
*/
|
|
529
|
-
trackingLabel?: string;
|
|
530
|
-
}
|
|
502
|
+
type SidebarRailProps = React.ComponentProps<"button">;
|
|
531
503
|
|
|
532
504
|
const SidebarRail = React.forwardRef<HTMLButtonElement, SidebarRailProps>(
|
|
533
|
-
({
|
|
505
|
+
({ className, ...props }, ref) => {
|
|
534
506
|
const { toggleSidebar } = useSidebar();
|
|
535
507
|
|
|
536
508
|
return (
|
|
@@ -545,10 +517,7 @@ const SidebarRail = React.forwardRef<HTMLButtonElement, SidebarRailProps>(
|
|
|
545
517
|
"[[data-collapsible=offcanvas]_&]:-right-2",
|
|
546
518
|
className
|
|
547
519
|
)}
|
|
548
|
-
data-hook={dataHook}
|
|
549
520
|
data-slot="sidebar-rail"
|
|
550
|
-
data-tracking-el={trackingEl || "sidebar-rail"}
|
|
551
|
-
data-tracking-label={trackingLabel}
|
|
552
521
|
tabIndex={-1}
|
|
553
522
|
title="Toggle Sidebar"
|
|
554
523
|
onClick={toggleSidebar}
|
|
@@ -564,10 +533,10 @@ SidebarRail.displayName = "SidebarRail";
|
|
|
564
533
|
*/
|
|
565
534
|
interface SidebarInsetProps extends React.ComponentProps<"main"> {
|
|
566
535
|
/**
|
|
567
|
-
* Data hook for automated testing
|
|
536
|
+
* Data hook for automated testing
|
|
568
537
|
* Used to identify component in tests and E2E automation
|
|
569
538
|
*/
|
|
570
|
-
dataHook
|
|
539
|
+
dataHook?: string;
|
|
571
540
|
/**
|
|
572
541
|
* Tracking element identifier for analytics
|
|
573
542
|
* Defaults to "sidebar-inset" if not provided
|
|
@@ -580,7 +549,7 @@ interface SidebarInsetProps extends React.ComponentProps<"main"> {
|
|
|
580
549
|
}
|
|
581
550
|
|
|
582
551
|
const SidebarInset = React.forwardRef<HTMLDivElement, SidebarInsetProps>(
|
|
583
|
-
({ dataHook, trackingEl, trackingLabel,
|
|
552
|
+
({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
584
553
|
return (
|
|
585
554
|
<main
|
|
586
555
|
ref={ref}
|
|
@@ -602,27 +571,12 @@ SidebarInset.displayName = "SidebarInset";
|
|
|
602
571
|
/**
|
|
603
572
|
* Props for the SidebarInput component
|
|
604
573
|
*/
|
|
605
|
-
|
|
606
|
-
/**
|
|
607
|
-
* Data hook for automated testing (REQUIRED)
|
|
608
|
-
* Used to identify component in tests and E2E automation
|
|
609
|
-
*/
|
|
610
|
-
dataHook: string;
|
|
611
|
-
/**
|
|
612
|
-
* Tracking element identifier for analytics
|
|
613
|
-
* Defaults to "sidebar-input" if not provided
|
|
614
|
-
*/
|
|
615
|
-
trackingEl?: string;
|
|
616
|
-
/**
|
|
617
|
-
* Tracking label for analytics context
|
|
618
|
-
*/
|
|
619
|
-
trackingLabel?: string;
|
|
620
|
-
}
|
|
574
|
+
type SidebarInputProps = Omit<React.ComponentProps<typeof Input>, "dataHook">;
|
|
621
575
|
|
|
622
576
|
const SidebarInput = React.forwardRef<
|
|
623
577
|
React.ElementRef<typeof Input>,
|
|
624
578
|
SidebarInputProps
|
|
625
|
-
>(({
|
|
579
|
+
>(({ className, ...props }, ref) => {
|
|
626
580
|
return (
|
|
627
581
|
<Input
|
|
628
582
|
ref={ref}
|
|
@@ -631,9 +585,7 @@ const SidebarInput = React.forwardRef<
|
|
|
631
585
|
className
|
|
632
586
|
)}
|
|
633
587
|
data-slot="sidebar-input"
|
|
634
|
-
|
|
635
|
-
data-tracking-label={trackingLabel}
|
|
636
|
-
dataHook={dataHook}
|
|
588
|
+
dataHook="sidebar-input"
|
|
637
589
|
{...props}
|
|
638
590
|
/>
|
|
639
591
|
);
|
|
@@ -644,32 +596,18 @@ SidebarInput.displayName = "SidebarInput";
|
|
|
644
596
|
* Props for the SidebarHeader component
|
|
645
597
|
*/
|
|
646
598
|
interface SidebarHeaderProps extends React.ComponentProps<"div"> {
|
|
647
|
-
/**
|
|
648
|
-
|
|
649
|
-
* Used to identify component in tests and E2E automation
|
|
650
|
-
*/
|
|
651
|
-
dataHook: string;
|
|
652
|
-
/**
|
|
653
|
-
* Tracking element identifier for analytics
|
|
654
|
-
* Defaults to "sidebar-header" if not provided
|
|
655
|
-
*/
|
|
656
|
-
trackingEl?: string;
|
|
657
|
-
/**
|
|
658
|
-
* Tracking label for analytics context
|
|
659
|
-
*/
|
|
660
|
-
trackingLabel?: string;
|
|
599
|
+
/** Data hook for automated testing */
|
|
600
|
+
dataHook?: string;
|
|
661
601
|
}
|
|
662
602
|
|
|
663
603
|
const SidebarHeader = React.forwardRef<HTMLDivElement, SidebarHeaderProps>(
|
|
664
|
-
({
|
|
604
|
+
({ className, dataHook, ...props }, ref) => {
|
|
665
605
|
return (
|
|
666
606
|
<div
|
|
667
607
|
ref={ref}
|
|
668
608
|
className={cn("flex flex-col gap-2 p-2", className)}
|
|
669
609
|
data-hook={dataHook}
|
|
670
610
|
data-slot="sidebar-header"
|
|
671
|
-
data-tracking-el={trackingEl || "sidebar-header"}
|
|
672
|
-
data-tracking-label={trackingLabel}
|
|
673
611
|
{...props}
|
|
674
612
|
/>
|
|
675
613
|
);
|
|
@@ -681,32 +619,18 @@ SidebarHeader.displayName = "SidebarHeader";
|
|
|
681
619
|
* Props for the SidebarFooter component
|
|
682
620
|
*/
|
|
683
621
|
interface SidebarFooterProps extends React.ComponentProps<"div"> {
|
|
684
|
-
/**
|
|
685
|
-
|
|
686
|
-
* Used to identify component in tests and E2E automation
|
|
687
|
-
*/
|
|
688
|
-
dataHook: string;
|
|
689
|
-
/**
|
|
690
|
-
* Tracking element identifier for analytics
|
|
691
|
-
* Defaults to "sidebar-footer" if not provided
|
|
692
|
-
*/
|
|
693
|
-
trackingEl?: string;
|
|
694
|
-
/**
|
|
695
|
-
* Tracking label for analytics context
|
|
696
|
-
*/
|
|
697
|
-
trackingLabel?: string;
|
|
622
|
+
/** Data hook for automated testing */
|
|
623
|
+
dataHook?: string;
|
|
698
624
|
}
|
|
699
625
|
|
|
700
626
|
const SidebarFooter = React.forwardRef<HTMLDivElement, SidebarFooterProps>(
|
|
701
|
-
({
|
|
627
|
+
({ className, dataHook, ...props }, ref) => {
|
|
702
628
|
return (
|
|
703
629
|
<div
|
|
704
630
|
ref={ref}
|
|
705
631
|
className={cn("flex flex-col gap-2 p-2", className)}
|
|
706
632
|
data-hook={dataHook}
|
|
707
633
|
data-slot="sidebar-footer"
|
|
708
|
-
data-tracking-el={trackingEl || "sidebar-footer"}
|
|
709
|
-
data-tracking-label={trackingLabel}
|
|
710
634
|
{...props}
|
|
711
635
|
/>
|
|
712
636
|
);
|
|
@@ -717,27 +641,12 @@ SidebarFooter.displayName = "SidebarFooter";
|
|
|
717
641
|
/**
|
|
718
642
|
* Props for the SidebarSeparator component
|
|
719
643
|
*/
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Data hook for automated testing (REQUIRED)
|
|
723
|
-
* Used to identify component in tests and E2E automation
|
|
724
|
-
*/
|
|
725
|
-
dataHook: string;
|
|
726
|
-
/**
|
|
727
|
-
* Tracking element identifier for analytics
|
|
728
|
-
* Defaults to "sidebar-separator" if not provided
|
|
729
|
-
*/
|
|
730
|
-
trackingEl?: string;
|
|
731
|
-
/**
|
|
732
|
-
* Tracking label for analytics context
|
|
733
|
-
*/
|
|
734
|
-
trackingLabel?: string;
|
|
735
|
-
}
|
|
644
|
+
type SidebarSeparatorProps = React.ComponentProps<typeof Separator>;
|
|
736
645
|
|
|
737
646
|
const SidebarSeparator = React.forwardRef<
|
|
738
647
|
React.ElementRef<typeof Separator>,
|
|
739
648
|
SidebarSeparatorProps
|
|
740
|
-
>(({
|
|
649
|
+
>(({ className, ...props }, ref) => {
|
|
741
650
|
return (
|
|
742
651
|
<Separator
|
|
743
652
|
ref={ref}
|
|
@@ -745,10 +654,7 @@ const SidebarSeparator = React.forwardRef<
|
|
|
745
654
|
"bg-sidebar-border mx-2 w-auto group-data-[collapsible=icon]:mx-0",
|
|
746
655
|
className
|
|
747
656
|
)}
|
|
748
|
-
data-hook={dataHook}
|
|
749
657
|
data-slot="sidebar-separator"
|
|
750
|
-
data-tracking-el={trackingEl || "sidebar-separator"}
|
|
751
|
-
data-tracking-label={trackingLabel}
|
|
752
658
|
{...props}
|
|
753
659
|
/>
|
|
754
660
|
);
|
|
@@ -759,24 +665,12 @@ SidebarSeparator.displayName = "SidebarSeparator";
|
|
|
759
665
|
* Props for the SidebarContent component
|
|
760
666
|
*/
|
|
761
667
|
interface SidebarContentProps extends React.ComponentProps<"div"> {
|
|
762
|
-
/**
|
|
763
|
-
|
|
764
|
-
* Used to identify component in tests and E2E automation
|
|
765
|
-
*/
|
|
766
|
-
dataHook: string;
|
|
767
|
-
/**
|
|
768
|
-
* Tracking element identifier for analytics
|
|
769
|
-
* Defaults to "sidebar-content" if not provided
|
|
770
|
-
*/
|
|
771
|
-
trackingEl?: string;
|
|
772
|
-
/**
|
|
773
|
-
* Tracking label for analytics context
|
|
774
|
-
*/
|
|
775
|
-
trackingLabel?: string;
|
|
668
|
+
/** Data hook for automated testing */
|
|
669
|
+
dataHook?: string;
|
|
776
670
|
}
|
|
777
671
|
|
|
778
672
|
const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
|
|
779
|
-
({
|
|
673
|
+
({ className, dataHook, ...props }, ref) => {
|
|
780
674
|
return (
|
|
781
675
|
<div
|
|
782
676
|
ref={ref}
|
|
@@ -786,8 +680,6 @@ const SidebarContent = React.forwardRef<HTMLDivElement, SidebarContentProps>(
|
|
|
786
680
|
)}
|
|
787
681
|
data-hook={dataHook}
|
|
788
682
|
data-slot="sidebar-content"
|
|
789
|
-
data-tracking-el={trackingEl || "sidebar-content"}
|
|
790
|
-
data-tracking-label={trackingLabel}
|
|
791
683
|
{...props}
|
|
792
684
|
/>
|
|
793
685
|
);
|
|
@@ -799,32 +691,18 @@ SidebarContent.displayName = "SidebarContent";
|
|
|
799
691
|
* Props for the SidebarGroup component
|
|
800
692
|
*/
|
|
801
693
|
interface SidebarGroupProps extends React.ComponentProps<"div"> {
|
|
802
|
-
/**
|
|
803
|
-
|
|
804
|
-
* Used to identify component in tests and E2E automation
|
|
805
|
-
*/
|
|
806
|
-
dataHook: string;
|
|
807
|
-
/**
|
|
808
|
-
* Tracking element identifier for analytics
|
|
809
|
-
* Defaults to "sidebar-group" if not provided
|
|
810
|
-
*/
|
|
811
|
-
trackingEl?: string;
|
|
812
|
-
/**
|
|
813
|
-
* Tracking label for analytics context
|
|
814
|
-
*/
|
|
815
|
-
trackingLabel?: string;
|
|
694
|
+
/** Data hook for automated testing */
|
|
695
|
+
dataHook?: string;
|
|
816
696
|
}
|
|
817
697
|
|
|
818
698
|
const SidebarGroup = React.forwardRef<HTMLDivElement, SidebarGroupProps>(
|
|
819
|
-
({
|
|
699
|
+
({ className, dataHook, ...props }, ref) => {
|
|
820
700
|
return (
|
|
821
701
|
<div
|
|
822
702
|
ref={ref}
|
|
823
703
|
className={cn("relative flex w-full min-w-0 flex-col p-2", className)}
|
|
824
704
|
data-hook={dataHook}
|
|
825
705
|
data-slot="sidebar-group"
|
|
826
|
-
data-tracking-el={trackingEl || "sidebar-group"}
|
|
827
|
-
data-tracking-label={trackingLabel}
|
|
828
706
|
{...props}
|
|
829
707
|
/>
|
|
830
708
|
);
|
|
@@ -863,20 +741,8 @@ interface SidebarGroupLabelProps
|
|
|
863
741
|
extends
|
|
864
742
|
React.ComponentProps<"div">,
|
|
865
743
|
VariantProps<typeof sidebarGroupLabelVariants> {
|
|
866
|
-
/**
|
|
867
|
-
|
|
868
|
-
* Used to identify component in tests and E2E automation
|
|
869
|
-
*/
|
|
870
|
-
dataHook: string;
|
|
871
|
-
/**
|
|
872
|
-
* Tracking element identifier for analytics
|
|
873
|
-
* Defaults to "sidebar-group-label" if not provided
|
|
874
|
-
*/
|
|
875
|
-
trackingEl?: string;
|
|
876
|
-
/**
|
|
877
|
-
* Tracking label for analytics context
|
|
878
|
-
*/
|
|
879
|
-
trackingLabel?: string;
|
|
744
|
+
/** Data hook for automated testing */
|
|
745
|
+
dataHook?: string;
|
|
880
746
|
/**
|
|
881
747
|
* Render as a different element (Radix Slot pattern)
|
|
882
748
|
*/
|
|
@@ -911,10 +777,8 @@ const SidebarGroupLabel = React.forwardRef<
|
|
|
911
777
|
>(
|
|
912
778
|
(
|
|
913
779
|
{
|
|
914
|
-
dataHook,
|
|
915
|
-
trackingEl,
|
|
916
|
-
trackingLabel,
|
|
917
780
|
className,
|
|
781
|
+
dataHook,
|
|
918
782
|
asChild = false,
|
|
919
783
|
size = SidebarGroupLabelSize.SM,
|
|
920
784
|
variant = SidebarGroupLabelVariant.DEFAULT,
|
|
@@ -949,8 +813,6 @@ const SidebarGroupLabel = React.forwardRef<
|
|
|
949
813
|
className={cn(sidebarGroupLabelVariants({ size, variant }), className)}
|
|
950
814
|
data-hook={dataHook}
|
|
951
815
|
data-slot="sidebar-group-label"
|
|
952
|
-
data-tracking-el={trackingEl || "sidebar-group-label"}
|
|
953
|
-
data-tracking-label={trackingLabel}
|
|
954
816
|
data-variant={variant}
|
|
955
817
|
role={
|
|
956
818
|
variant !== SidebarGroupLabelVariant.DEFAULT ? "button" : undefined
|
|
@@ -988,20 +850,6 @@ SidebarGroupLabel.displayName = "SidebarGroupLabel";
|
|
|
988
850
|
* Props for the SidebarGroupAction component
|
|
989
851
|
*/
|
|
990
852
|
interface SidebarGroupActionProps extends React.ComponentProps<"button"> {
|
|
991
|
-
/**
|
|
992
|
-
* Data hook for automated testing (REQUIRED)
|
|
993
|
-
* Used to identify component in tests and E2E automation
|
|
994
|
-
*/
|
|
995
|
-
dataHook: string;
|
|
996
|
-
/**
|
|
997
|
-
* Tracking element identifier for analytics
|
|
998
|
-
* Defaults to "sidebar-group-action" if not provided
|
|
999
|
-
*/
|
|
1000
|
-
trackingEl?: string;
|
|
1001
|
-
/**
|
|
1002
|
-
* Tracking label for analytics context
|
|
1003
|
-
*/
|
|
1004
|
-
trackingLabel?: string;
|
|
1005
853
|
/**
|
|
1006
854
|
* Render as a different element (Radix Slot pattern)
|
|
1007
855
|
*/
|
|
@@ -1011,72 +859,43 @@ interface SidebarGroupActionProps extends React.ComponentProps<"button"> {
|
|
|
1011
859
|
const SidebarGroupAction = React.forwardRef<
|
|
1012
860
|
HTMLButtonElement,
|
|
1013
861
|
SidebarGroupActionProps
|
|
1014
|
-
>(
|
|
1015
|
-
|
|
1016
|
-
{
|
|
1017
|
-
dataHook,
|
|
1018
|
-
trackingEl,
|
|
1019
|
-
trackingLabel,
|
|
1020
|
-
className,
|
|
1021
|
-
asChild = false,
|
|
1022
|
-
...props
|
|
1023
|
-
},
|
|
1024
|
-
ref
|
|
1025
|
-
) => {
|
|
1026
|
-
const Comp = asChild ? Slot : "button";
|
|
862
|
+
>(({ className, asChild = false, ...props }, ref) => {
|
|
863
|
+
const Comp = asChild ? Slot : "button";
|
|
1027
864
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
/>
|
|
1044
|
-
);
|
|
1045
|
-
}
|
|
1046
|
-
);
|
|
865
|
+
return (
|
|
866
|
+
<Comp
|
|
867
|
+
ref={ref}
|
|
868
|
+
className={cn(
|
|
869
|
+
"text-sidebar-foreground ring-sidebar-ring 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 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
870
|
+
// Increases the hit area of the button on mobile.
|
|
871
|
+
"after:absolute after:-inset-2 after:md:hidden",
|
|
872
|
+
"group-data-[collapsible=icon]:hidden",
|
|
873
|
+
className
|
|
874
|
+
)}
|
|
875
|
+
data-slot="sidebar-group-action"
|
|
876
|
+
{...props}
|
|
877
|
+
/>
|
|
878
|
+
);
|
|
879
|
+
});
|
|
1047
880
|
SidebarGroupAction.displayName = "SidebarGroupAction";
|
|
1048
881
|
|
|
1049
882
|
/**
|
|
1050
883
|
* Props for the SidebarGroupContent component
|
|
1051
884
|
*/
|
|
1052
885
|
interface SidebarGroupContentProps extends React.ComponentProps<"div"> {
|
|
1053
|
-
/**
|
|
1054
|
-
|
|
1055
|
-
* Used to identify component in tests and E2E automation
|
|
1056
|
-
*/
|
|
1057
|
-
dataHook: string;
|
|
1058
|
-
/**
|
|
1059
|
-
* Tracking element identifier for analytics
|
|
1060
|
-
* Defaults to "sidebar-group-content" if not provided
|
|
1061
|
-
*/
|
|
1062
|
-
trackingEl?: string;
|
|
1063
|
-
/**
|
|
1064
|
-
* Tracking label for analytics context
|
|
1065
|
-
*/
|
|
1066
|
-
trackingLabel?: string;
|
|
886
|
+
/** Data hook for automated testing */
|
|
887
|
+
dataHook?: string;
|
|
1067
888
|
}
|
|
1068
889
|
|
|
1069
890
|
const SidebarGroupContent = React.forwardRef<
|
|
1070
891
|
HTMLDivElement,
|
|
1071
892
|
SidebarGroupContentProps
|
|
1072
|
-
>(({
|
|
893
|
+
>(({ className, dataHook, ...props }, ref) => (
|
|
1073
894
|
<div
|
|
1074
895
|
ref={ref}
|
|
1075
896
|
className={cn("w-full text-sm", className)}
|
|
1076
897
|
data-hook={dataHook}
|
|
1077
898
|
data-slot="sidebar-group-content"
|
|
1078
|
-
data-tracking-el={trackingEl || "sidebar-group-content"}
|
|
1079
|
-
data-tracking-label={trackingLabel}
|
|
1080
899
|
{...props}
|
|
1081
900
|
/>
|
|
1082
901
|
));
|
|
@@ -1086,31 +905,17 @@ SidebarGroupContent.displayName = "SidebarGroupContent";
|
|
|
1086
905
|
* Props for the SidebarMenu component
|
|
1087
906
|
*/
|
|
1088
907
|
interface SidebarMenuProps extends React.ComponentProps<"ul"> {
|
|
1089
|
-
/**
|
|
1090
|
-
|
|
1091
|
-
* Used to identify component in tests and E2E automation
|
|
1092
|
-
*/
|
|
1093
|
-
dataHook: string;
|
|
1094
|
-
/**
|
|
1095
|
-
* Tracking element identifier for analytics
|
|
1096
|
-
* Defaults to "sidebar-menu" if not provided
|
|
1097
|
-
*/
|
|
1098
|
-
trackingEl?: string;
|
|
1099
|
-
/**
|
|
1100
|
-
* Tracking label for analytics context
|
|
1101
|
-
*/
|
|
1102
|
-
trackingLabel?: string;
|
|
908
|
+
/** Data hook for automated testing */
|
|
909
|
+
dataHook?: string;
|
|
1103
910
|
}
|
|
1104
911
|
|
|
1105
912
|
const SidebarMenu = React.forwardRef<HTMLUListElement, SidebarMenuProps>(
|
|
1106
|
-
({
|
|
913
|
+
({ className, dataHook, ...props }, ref) => (
|
|
1107
914
|
<ul
|
|
1108
915
|
ref={ref}
|
|
1109
916
|
className={cn("flex w-full min-w-0 flex-col gap-1", className)}
|
|
1110
917
|
data-hook={dataHook}
|
|
1111
918
|
data-slot="sidebar-menu"
|
|
1112
|
-
data-tracking-el={trackingEl || "sidebar-menu"}
|
|
1113
|
-
data-tracking-label={trackingLabel}
|
|
1114
919
|
{...props}
|
|
1115
920
|
/>
|
|
1116
921
|
)
|
|
@@ -1121,31 +926,17 @@ SidebarMenu.displayName = "SidebarMenu";
|
|
|
1121
926
|
* Props for the SidebarMenuItem component
|
|
1122
927
|
*/
|
|
1123
928
|
interface SidebarMenuItemProps extends React.ComponentProps<"li"> {
|
|
1124
|
-
/**
|
|
1125
|
-
|
|
1126
|
-
* Used to identify component in tests and E2E automation
|
|
1127
|
-
*/
|
|
1128
|
-
dataHook: string;
|
|
1129
|
-
/**
|
|
1130
|
-
* Tracking element identifier for analytics
|
|
1131
|
-
* Defaults to "sidebar-menu-item" if not provided
|
|
1132
|
-
*/
|
|
1133
|
-
trackingEl?: string;
|
|
1134
|
-
/**
|
|
1135
|
-
* Tracking label for analytics context
|
|
1136
|
-
*/
|
|
1137
|
-
trackingLabel?: string;
|
|
929
|
+
/** Data hook for automated testing */
|
|
930
|
+
dataHook?: string;
|
|
1138
931
|
}
|
|
1139
932
|
|
|
1140
933
|
const SidebarMenuItem = React.forwardRef<HTMLLIElement, SidebarMenuItemProps>(
|
|
1141
|
-
({
|
|
934
|
+
({ className, dataHook, ...props }, ref) => (
|
|
1142
935
|
<li
|
|
1143
936
|
ref={ref}
|
|
1144
937
|
className={cn("group/menu-item relative", className)}
|
|
1145
938
|
data-hook={dataHook}
|
|
1146
939
|
data-slot="sidebar-menu-item"
|
|
1147
|
-
data-tracking-el={trackingEl || "sidebar-menu-item"}
|
|
1148
|
-
data-tracking-label={trackingLabel}
|
|
1149
940
|
{...props}
|
|
1150
941
|
/>
|
|
1151
942
|
)
|
|
@@ -1156,20 +947,6 @@ SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
|
1156
947
|
* Props for the SidebarCollapseIcon component
|
|
1157
948
|
*/
|
|
1158
949
|
interface SidebarCollapseIconProps extends React.ComponentProps<"svg"> {
|
|
1159
|
-
/**
|
|
1160
|
-
* Data hook for automated testing (REQUIRED)
|
|
1161
|
-
* Used to identify component in tests and E2E automation
|
|
1162
|
-
*/
|
|
1163
|
-
dataHook: string;
|
|
1164
|
-
/**
|
|
1165
|
-
* Tracking element identifier for analytics
|
|
1166
|
-
* Defaults to "sidebar-collapse-icon" if not provided
|
|
1167
|
-
*/
|
|
1168
|
-
trackingEl?: string;
|
|
1169
|
-
/**
|
|
1170
|
-
* Tracking label for analytics context
|
|
1171
|
-
*/
|
|
1172
|
-
trackingLabel?: string;
|
|
1173
950
|
/**
|
|
1174
951
|
* Icon type variant
|
|
1175
952
|
* @default SidebarCollapseIconType.CARET
|
|
@@ -1187,9 +964,6 @@ const SidebarCollapseIcon = React.forwardRef<
|
|
|
1187
964
|
>(
|
|
1188
965
|
(
|
|
1189
966
|
{
|
|
1190
|
-
dataHook,
|
|
1191
|
-
trackingEl,
|
|
1192
|
-
trackingLabel,
|
|
1193
967
|
type = SidebarCollapseIconType.CARET,
|
|
1194
968
|
isActive = false,
|
|
1195
969
|
className,
|
|
@@ -1204,10 +978,7 @@ const SidebarCollapseIcon = React.forwardRef<
|
|
|
1204
978
|
isActive && type === SidebarCollapseIconType.CARET && "rotate-90",
|
|
1205
979
|
className
|
|
1206
980
|
),
|
|
1207
|
-
"data-hook": dataHook,
|
|
1208
981
|
"data-slot": "sidebar-collapse-icon",
|
|
1209
|
-
"data-tracking-el": trackingEl || "sidebar-collapse-icon",
|
|
1210
|
-
"data-tracking-label": trackingLabel,
|
|
1211
982
|
...props,
|
|
1212
983
|
};
|
|
1213
984
|
|
|
@@ -1273,20 +1044,8 @@ interface SidebarMenuButtonProps
|
|
|
1273
1044
|
extends
|
|
1274
1045
|
React.ComponentProps<"button">,
|
|
1275
1046
|
VariantProps<typeof sidebarMenuButtonVariants> {
|
|
1276
|
-
/**
|
|
1277
|
-
|
|
1278
|
-
* Used to identify component in tests and E2E automation
|
|
1279
|
-
*/
|
|
1280
|
-
dataHook: string;
|
|
1281
|
-
/**
|
|
1282
|
-
* Tracking element identifier for analytics
|
|
1283
|
-
* Defaults to "sidebar-menu-button" if not provided
|
|
1284
|
-
*/
|
|
1285
|
-
trackingEl?: string;
|
|
1286
|
-
/**
|
|
1287
|
-
* Tracking label for analytics context
|
|
1288
|
-
*/
|
|
1289
|
-
trackingLabel?: string;
|
|
1047
|
+
/** Data hook for automated testing */
|
|
1048
|
+
dataHook?: string;
|
|
1290
1049
|
/**
|
|
1291
1050
|
* Render as a different element (Radix Slot pattern)
|
|
1292
1051
|
*/
|
|
@@ -1317,15 +1076,13 @@ const SidebarMenuButton = React.forwardRef<
|
|
|
1317
1076
|
>(
|
|
1318
1077
|
(
|
|
1319
1078
|
{
|
|
1320
|
-
dataHook,
|
|
1321
|
-
trackingEl,
|
|
1322
|
-
trackingLabel,
|
|
1323
1079
|
asChild = false,
|
|
1324
1080
|
isActive = false,
|
|
1325
1081
|
variant = SidebarMenuButtonVariant.SIMPLE,
|
|
1326
1082
|
size = SidebarMenuButtonSize.DEFAULT,
|
|
1327
1083
|
tooltip,
|
|
1328
1084
|
className,
|
|
1085
|
+
dataHook,
|
|
1329
1086
|
...props
|
|
1330
1087
|
},
|
|
1331
1088
|
ref
|
|
@@ -1341,8 +1098,6 @@ const SidebarMenuButton = React.forwardRef<
|
|
|
1341
1098
|
data-hook={dataHook}
|
|
1342
1099
|
data-size={size}
|
|
1343
1100
|
data-slot="sidebar-menu-button"
|
|
1344
|
-
data-tracking-el={trackingEl || "sidebar-menu-button"}
|
|
1345
|
-
data-tracking-label={trackingLabel}
|
|
1346
1101
|
data-variant={variant}
|
|
1347
1102
|
{...props}
|
|
1348
1103
|
/>
|
|
@@ -1355,7 +1110,7 @@ const SidebarMenuButton = React.forwardRef<
|
|
|
1355
1110
|
if (typeof tooltip === "string") {
|
|
1356
1111
|
tooltip = {
|
|
1357
1112
|
children: tooltip,
|
|
1358
|
-
dataHook:
|
|
1113
|
+
dataHook: "sidebar-menu-button-tooltip",
|
|
1359
1114
|
};
|
|
1360
1115
|
}
|
|
1361
1116
|
|
|
@@ -1384,20 +1139,6 @@ SidebarMenuButton.displayName = "SidebarMenuButton";
|
|
|
1384
1139
|
* Props for the SidebarMenuAction component
|
|
1385
1140
|
*/
|
|
1386
1141
|
interface SidebarMenuActionProps extends React.ComponentProps<"button"> {
|
|
1387
|
-
/**
|
|
1388
|
-
* Data hook for automated testing (REQUIRED)
|
|
1389
|
-
* Used to identify component in tests and E2E automation
|
|
1390
|
-
*/
|
|
1391
|
-
dataHook: string;
|
|
1392
|
-
/**
|
|
1393
|
-
* Tracking element identifier for analytics
|
|
1394
|
-
* Defaults to "sidebar-menu-action" if not provided
|
|
1395
|
-
*/
|
|
1396
|
-
trackingEl?: string;
|
|
1397
|
-
/**
|
|
1398
|
-
* Tracking label for analytics context
|
|
1399
|
-
*/
|
|
1400
|
-
trackingLabel?: string;
|
|
1401
1142
|
/**
|
|
1402
1143
|
* Render as a different element (Radix Slot pattern)
|
|
1403
1144
|
*/
|
|
@@ -1411,73 +1152,42 @@ interface SidebarMenuActionProps extends React.ComponentProps<"button"> {
|
|
|
1411
1152
|
const SidebarMenuAction = React.forwardRef<
|
|
1412
1153
|
HTMLButtonElement,
|
|
1413
1154
|
SidebarMenuActionProps
|
|
1414
|
-
>(
|
|
1415
|
-
|
|
1416
|
-
{
|
|
1417
|
-
dataHook,
|
|
1418
|
-
trackingEl,
|
|
1419
|
-
trackingLabel,
|
|
1420
|
-
className,
|
|
1421
|
-
asChild = false,
|
|
1422
|
-
showOnHover = false,
|
|
1423
|
-
...props
|
|
1424
|
-
},
|
|
1425
|
-
ref
|
|
1426
|
-
) => {
|
|
1427
|
-
const Comp = asChild ? Slot : "button";
|
|
1155
|
+
>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {
|
|
1156
|
+
const Comp = asChild ? Slot : "button";
|
|
1428
1157
|
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
/>
|
|
1452
|
-
);
|
|
1453
|
-
}
|
|
1454
|
-
);
|
|
1158
|
+
return (
|
|
1159
|
+
<Comp
|
|
1160
|
+
ref={ref}
|
|
1161
|
+
className={cn(
|
|
1162
|
+
"text-sidebar-foreground ring-sidebar-ring 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 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
1163
|
+
// Increases the hit area of the button on mobile.
|
|
1164
|
+
"after:absolute after:-inset-2 after:md:hidden",
|
|
1165
|
+
"peer-data-[size=sm]/menu-button:top-1",
|
|
1166
|
+
"peer-data-[size=default]/menu-button:top-1.5",
|
|
1167
|
+
"peer-data-[size=lg]/menu-button:top-2.5",
|
|
1168
|
+
"peer-data-[size=bigIcon]/menu-button:top-2.5",
|
|
1169
|
+
"peer-data-[size=tree]/menu-button:top-1.5",
|
|
1170
|
+
"group-data-[collapsible=icon]:hidden",
|
|
1171
|
+
showOnHover &&
|
|
1172
|
+
"peer-data-[active=true]/menu-button:text-sidebar-accent-foreground group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 md:opacity-0",
|
|
1173
|
+
className
|
|
1174
|
+
)}
|
|
1175
|
+
data-slot="sidebar-menu-action"
|
|
1176
|
+
{...props}
|
|
1177
|
+
/>
|
|
1178
|
+
);
|
|
1179
|
+
});
|
|
1455
1180
|
SidebarMenuAction.displayName = "SidebarMenuAction";
|
|
1456
1181
|
|
|
1457
1182
|
/**
|
|
1458
1183
|
* Props for the SidebarMenuBadge component
|
|
1459
1184
|
*/
|
|
1460
|
-
|
|
1461
|
-
/**
|
|
1462
|
-
* Data hook for automated testing (REQUIRED)
|
|
1463
|
-
* Used to identify component in tests and E2E automation
|
|
1464
|
-
*/
|
|
1465
|
-
dataHook: string;
|
|
1466
|
-
/**
|
|
1467
|
-
* Tracking element identifier for analytics
|
|
1468
|
-
* Defaults to "sidebar-menu-badge" if not provided
|
|
1469
|
-
*/
|
|
1470
|
-
trackingEl?: string;
|
|
1471
|
-
/**
|
|
1472
|
-
* Tracking label for analytics context
|
|
1473
|
-
*/
|
|
1474
|
-
trackingLabel?: string;
|
|
1475
|
-
}
|
|
1185
|
+
type SidebarMenuBadgeProps = React.ComponentProps<"div">;
|
|
1476
1186
|
|
|
1477
1187
|
const SidebarMenuBadge = React.forwardRef<
|
|
1478
1188
|
HTMLDivElement,
|
|
1479
1189
|
SidebarMenuBadgeProps
|
|
1480
|
-
>(({
|
|
1190
|
+
>(({ className, ...props }, ref) => (
|
|
1481
1191
|
<div
|
|
1482
1192
|
ref={ref}
|
|
1483
1193
|
className={cn(
|
|
@@ -1491,10 +1201,7 @@ const SidebarMenuBadge = React.forwardRef<
|
|
|
1491
1201
|
"group-data-[collapsible=icon]:hidden",
|
|
1492
1202
|
className
|
|
1493
1203
|
)}
|
|
1494
|
-
data-hook={dataHook}
|
|
1495
1204
|
data-slot="sidebar-menu-badge"
|
|
1496
|
-
data-tracking-el={trackingEl || "sidebar-menu-badge"}
|
|
1497
|
-
data-tracking-label={trackingLabel}
|
|
1498
1205
|
{...props}
|
|
1499
1206
|
/>
|
|
1500
1207
|
));
|
|
@@ -1504,20 +1211,6 @@ SidebarMenuBadge.displayName = "SidebarMenuBadge";
|
|
|
1504
1211
|
* Props for the SidebarMenuSkeleton component
|
|
1505
1212
|
*/
|
|
1506
1213
|
interface SidebarMenuSkeletonProps extends React.ComponentProps<"div"> {
|
|
1507
|
-
/**
|
|
1508
|
-
* Data hook for automated testing (REQUIRED)
|
|
1509
|
-
* Used to identify component in tests and E2E automation
|
|
1510
|
-
*/
|
|
1511
|
-
dataHook: string;
|
|
1512
|
-
/**
|
|
1513
|
-
* Tracking element identifier for analytics
|
|
1514
|
-
* Defaults to "sidebar-menu-skeleton" if not provided
|
|
1515
|
-
*/
|
|
1516
|
-
trackingEl?: string;
|
|
1517
|
-
/**
|
|
1518
|
-
* Tracking label for analytics context
|
|
1519
|
-
*/
|
|
1520
|
-
trackingLabel?: string;
|
|
1521
1214
|
/**
|
|
1522
1215
|
* Show icon skeleton placeholder
|
|
1523
1216
|
*/
|
|
@@ -1527,61 +1220,44 @@ interface SidebarMenuSkeletonProps extends React.ComponentProps<"div"> {
|
|
|
1527
1220
|
const SidebarMenuSkeleton = React.forwardRef<
|
|
1528
1221
|
HTMLDivElement,
|
|
1529
1222
|
SidebarMenuSkeletonProps
|
|
1530
|
-
>(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
)
|
|
1542
|
-
// Generate a stable random-looking width using useId
|
|
1543
|
-
const id = React.useId();
|
|
1544
|
-
const width = React.useMemo(() => {
|
|
1545
|
-
// Simple hash from id to get a deterministic "random" width between 50-90%
|
|
1546
|
-
let hash = 0;
|
|
1547
|
-
for (let i = 0; i < id.length; i++) {
|
|
1548
|
-
hash = (hash << 5) - hash + id.charCodeAt(i);
|
|
1549
|
-
hash |= 0;
|
|
1550
|
-
}
|
|
1551
|
-
return `${(Math.abs(hash) % 40) + 50}%`;
|
|
1552
|
-
}, [id]);
|
|
1223
|
+
>(({ className, showIcon = false, ...props }, ref) => {
|
|
1224
|
+
// Generate a stable random-looking width using useId
|
|
1225
|
+
const id = React.useId();
|
|
1226
|
+
const width = React.useMemo(() => {
|
|
1227
|
+
// Simple hash from id to get a deterministic "random" width between 50-90%
|
|
1228
|
+
let hash = 0;
|
|
1229
|
+
for (let i = 0; i < id.length; i++) {
|
|
1230
|
+
hash = (hash << 5) - hash + id.charCodeAt(i);
|
|
1231
|
+
hash |= 0;
|
|
1232
|
+
}
|
|
1233
|
+
return `${(Math.abs(hash) % 40) + 50}%`;
|
|
1234
|
+
}, [id]);
|
|
1553
1235
|
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
{...props}
|
|
1563
|
-
>
|
|
1564
|
-
{showIcon && (
|
|
1565
|
-
<Skeleton
|
|
1566
|
-
className="size-4 rounded-md"
|
|
1567
|
-
data-hook={`${dataHook}-icon`}
|
|
1568
|
-
data-slot="sidebar-menu-skeleton-icon"
|
|
1569
|
-
/>
|
|
1570
|
-
)}
|
|
1236
|
+
return (
|
|
1237
|
+
<div
|
|
1238
|
+
ref={ref}
|
|
1239
|
+
className={cn("flex h-8 items-center gap-2 rounded-md px-2", className)}
|
|
1240
|
+
data-slot="sidebar-menu-skeleton"
|
|
1241
|
+
{...props}
|
|
1242
|
+
>
|
|
1243
|
+
{showIcon && (
|
|
1571
1244
|
<Skeleton
|
|
1572
|
-
className="
|
|
1573
|
-
data-
|
|
1574
|
-
data-slot="sidebar-menu-skeleton-text"
|
|
1575
|
-
style={
|
|
1576
|
-
{
|
|
1577
|
-
"--skeleton-width": width,
|
|
1578
|
-
} as React.CSSProperties
|
|
1579
|
-
}
|
|
1245
|
+
className="size-4 rounded-md"
|
|
1246
|
+
data-slot="sidebar-menu-skeleton-icon"
|
|
1580
1247
|
/>
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1248
|
+
)}
|
|
1249
|
+
<Skeleton
|
|
1250
|
+
className="h-4 max-w-[--skeleton-width] flex-1"
|
|
1251
|
+
data-slot="sidebar-menu-skeleton-text"
|
|
1252
|
+
style={
|
|
1253
|
+
{
|
|
1254
|
+
"--skeleton-width": width,
|
|
1255
|
+
} as React.CSSProperties
|
|
1256
|
+
}
|
|
1257
|
+
/>
|
|
1258
|
+
</div>
|
|
1259
|
+
);
|
|
1260
|
+
});
|
|
1585
1261
|
SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";
|
|
1586
1262
|
|
|
1587
1263
|
const sidebarMenuSubVariants = cva(
|
|
@@ -1607,20 +1283,8 @@ interface SidebarMenuSubProps
|
|
|
1607
1283
|
extends
|
|
1608
1284
|
React.ComponentProps<"ul">,
|
|
1609
1285
|
VariantProps<typeof sidebarMenuSubVariants> {
|
|
1610
|
-
/**
|
|
1611
|
-
|
|
1612
|
-
* Used to identify component in tests and E2E automation
|
|
1613
|
-
*/
|
|
1614
|
-
dataHook: string;
|
|
1615
|
-
/**
|
|
1616
|
-
* Tracking element identifier for analytics
|
|
1617
|
-
* Defaults to "sidebar-menu-sub" if not provided
|
|
1618
|
-
*/
|
|
1619
|
-
trackingEl?: string;
|
|
1620
|
-
/**
|
|
1621
|
-
* Tracking label for analytics context
|
|
1622
|
-
*/
|
|
1623
|
-
trackingLabel?: string;
|
|
1286
|
+
/** Data hook for automated testing */
|
|
1287
|
+
dataHook?: string;
|
|
1624
1288
|
/**
|
|
1625
1289
|
* Visual variant
|
|
1626
1290
|
* @default SidebarMenuSubVariant.BORDER
|
|
@@ -1630,14 +1294,7 @@ interface SidebarMenuSubProps
|
|
|
1630
1294
|
|
|
1631
1295
|
const SidebarMenuSub = React.forwardRef<HTMLUListElement, SidebarMenuSubProps>(
|
|
1632
1296
|
(
|
|
1633
|
-
{
|
|
1634
|
-
dataHook,
|
|
1635
|
-
trackingEl,
|
|
1636
|
-
trackingLabel,
|
|
1637
|
-
className,
|
|
1638
|
-
variant = SidebarMenuSubVariant.BORDER,
|
|
1639
|
-
...props
|
|
1640
|
-
},
|
|
1297
|
+
{ className, variant = SidebarMenuSubVariant.BORDER, dataHook, ...props },
|
|
1641
1298
|
ref
|
|
1642
1299
|
) => (
|
|
1643
1300
|
<ul
|
|
@@ -1645,8 +1302,6 @@ const SidebarMenuSub = React.forwardRef<HTMLUListElement, SidebarMenuSubProps>(
|
|
|
1645
1302
|
className={cn(sidebarMenuSubVariants({ variant }), className)}
|
|
1646
1303
|
data-hook={dataHook}
|
|
1647
1304
|
data-slot="sidebar-menu-sub"
|
|
1648
|
-
data-tracking-el={trackingEl || "sidebar-menu-sub"}
|
|
1649
|
-
data-tracking-label={trackingLabel}
|
|
1650
1305
|
{...props}
|
|
1651
1306
|
/>
|
|
1652
1307
|
)
|
|
@@ -1657,32 +1312,18 @@ SidebarMenuSub.displayName = "SidebarMenuSub";
|
|
|
1657
1312
|
* Props for the SidebarMenuSubItem component
|
|
1658
1313
|
*/
|
|
1659
1314
|
interface SidebarMenuSubItemProps extends React.ComponentProps<"li"> {
|
|
1660
|
-
/**
|
|
1661
|
-
|
|
1662
|
-
* Used to identify component in tests and E2E automation
|
|
1663
|
-
*/
|
|
1664
|
-
dataHook: string;
|
|
1665
|
-
/**
|
|
1666
|
-
* Tracking element identifier for analytics
|
|
1667
|
-
* Defaults to "sidebar-menu-sub-item" if not provided
|
|
1668
|
-
*/
|
|
1669
|
-
trackingEl?: string;
|
|
1670
|
-
/**
|
|
1671
|
-
* Tracking label for analytics context
|
|
1672
|
-
*/
|
|
1673
|
-
trackingLabel?: string;
|
|
1315
|
+
/** Data hook for automated testing */
|
|
1316
|
+
dataHook?: string;
|
|
1674
1317
|
}
|
|
1675
1318
|
|
|
1676
1319
|
const SidebarMenuSubItem = React.forwardRef<
|
|
1677
1320
|
HTMLLIElement,
|
|
1678
1321
|
SidebarMenuSubItemProps
|
|
1679
|
-
>(({ dataHook,
|
|
1322
|
+
>(({ dataHook, ...props }, ref) => (
|
|
1680
1323
|
<li
|
|
1681
1324
|
ref={ref}
|
|
1682
1325
|
data-hook={dataHook}
|
|
1683
1326
|
data-slot="sidebar-menu-sub-item"
|
|
1684
|
-
data-tracking-el={trackingEl || "sidebar-menu-sub-item"}
|
|
1685
|
-
data-tracking-label={trackingLabel}
|
|
1686
1327
|
{...props}
|
|
1687
1328
|
/>
|
|
1688
1329
|
));
|
|
@@ -1692,20 +1333,8 @@ SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
|
|
1692
1333
|
* Props for the SidebarMenuSubButton component
|
|
1693
1334
|
*/
|
|
1694
1335
|
interface SidebarMenuSubButtonProps extends React.ComponentProps<"a"> {
|
|
1695
|
-
/**
|
|
1696
|
-
|
|
1697
|
-
* Used to identify component in tests and E2E automation
|
|
1698
|
-
*/
|
|
1699
|
-
dataHook: string;
|
|
1700
|
-
/**
|
|
1701
|
-
* Tracking element identifier for analytics
|
|
1702
|
-
* Defaults to "sidebar-menu-sub-button" if not provided
|
|
1703
|
-
*/
|
|
1704
|
-
trackingEl?: string;
|
|
1705
|
-
/**
|
|
1706
|
-
* Tracking label for analytics context
|
|
1707
|
-
*/
|
|
1708
|
-
trackingLabel?: string;
|
|
1336
|
+
/** Data hook for automated testing */
|
|
1337
|
+
dataHook?: string;
|
|
1709
1338
|
/**
|
|
1710
1339
|
* Render as a different element (Radix Slot pattern)
|
|
1711
1340
|
*/
|
|
@@ -1727,13 +1356,11 @@ const SidebarMenuSubButton = React.forwardRef<
|
|
|
1727
1356
|
>(
|
|
1728
1357
|
(
|
|
1729
1358
|
{
|
|
1730
|
-
dataHook,
|
|
1731
|
-
trackingEl,
|
|
1732
|
-
trackingLabel,
|
|
1733
1359
|
asChild = false,
|
|
1734
1360
|
size = SidebarMenuSubButtonSize.MD,
|
|
1735
1361
|
isActive,
|
|
1736
1362
|
className,
|
|
1363
|
+
dataHook,
|
|
1737
1364
|
...props
|
|
1738
1365
|
},
|
|
1739
1366
|
ref
|
|
@@ -1755,8 +1382,6 @@ const SidebarMenuSubButton = React.forwardRef<
|
|
|
1755
1382
|
data-hook={dataHook}
|
|
1756
1383
|
data-size={size}
|
|
1757
1384
|
data-slot="sidebar-menu-sub-button"
|
|
1758
|
-
data-tracking-el={trackingEl || "sidebar-menu-sub-button"}
|
|
1759
|
-
data-tracking-label={trackingLabel}
|
|
1760
1385
|
{...props}
|
|
1761
1386
|
/>
|
|
1762
1387
|
);
|