@arolariu/components 0.1.2 → 0.3.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/DEBUGGING.md +396 -396
- package/LICENSE.md +21 -21
- package/changelog.md +120 -118
- package/dist/components/ui/accordion.d.ts +6 -6
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +20 -28
- package/dist/components/ui/accordion.js.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts +19 -13
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.js +40 -63
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts +7 -8
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +18 -21
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/aspect-ratio.d.ts +1 -2
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
- package/dist/components/ui/aspect-ratio.js +1 -8
- package/dist/components/ui/aspect-ratio.js.map +1 -1
- package/dist/components/ui/avatar.d.ts +5 -5
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/avatar.js +17 -20
- package/dist/components/ui/avatar.js.map +1 -1
- package/dist/components/ui/background-beams.d.ts.map +1 -1
- package/dist/components/ui/background-beams.js +6 -6
- package/dist/components/ui/background-beams.js.map +1 -1
- package/dist/components/ui/badge.d.ts +7 -7
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +9 -12
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts +17 -9
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.js +32 -39
- package/dist/components/ui/breadcrumb.js.map +1 -1
- package/dist/components/ui/bubble-background.d.ts +1 -1
- package/dist/components/ui/bubble-background.d.ts.map +1 -1
- package/dist/components/ui/bubble-background.js +13 -13
- package/dist/components/ui/bubble-background.js.map +1 -1
- package/dist/components/ui/button-group.d.ts +13 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button-group.js +47 -0
- package/dist/components/ui/button-group.js.map +1 -0
- package/dist/components/ui/button.d.ts +8 -7
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +16 -15
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/calendar.js +22 -22
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/card.d.ts +7 -8
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +33 -46
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/carousel.d.ts +7 -8
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +30 -21
- package/dist/components/ui/carousel.js.map +1 -1
- package/dist/components/ui/chart.d.ts +37 -29
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/chart.js +29 -27
- package/dist/components/ui/chart.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts +2 -2
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +11 -13
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/collapsible.d.ts +4 -5
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/collapsible.js +3 -20
- package/dist/components/ui/collapsible.js.map +1 -1
- package/dist/components/ui/command.d.ts +79 -17
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/command.js +52 -77
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.d.ts +23 -21
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/context-menu.js +60 -104
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/counting-number.d.ts +1 -1
- package/dist/components/ui/counting-number.d.ts.map +1 -1
- package/dist/components/ui/counting-number.js +4 -3
- package/dist/components/ui/counting-number.js.map +1 -1
- package/dist/components/ui/dialog.d.ts +17 -13
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +38 -66
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dot-background.d.ts +10 -17
- package/dist/components/ui/dot-background.d.ts.map +1 -1
- package/dist/components/ui/dot-background.js +2 -2
- package/dist/components/ui/dot-background.js.map +1 -1
- package/dist/components/ui/drawer.d.ts +20 -11
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +37 -62
- package/dist/components/ui/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +23 -21
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +65 -109
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdrawer.d.ts +3 -3
- package/dist/components/ui/dropdrawer.d.ts.map +1 -1
- package/dist/components/ui/dropdrawer.js +13 -16
- package/dist/components/ui/dropdrawer.js.map +1 -1
- package/dist/components/ui/empty.d.ts +13 -0
- package/dist/components/ui/empty.d.ts.map +1 -0
- package/dist/components/ui/empty.js +65 -0
- package/dist/components/ui/empty.js.map +1 -0
- package/dist/components/ui/field.d.ts +25 -0
- package/dist/components/ui/field.d.ts.map +1 -0
- package/dist/components/ui/field.js +135 -0
- package/dist/components/ui/field.js.map +1 -0
- package/dist/components/ui/fireworks-background.d.ts.map +1 -1
- package/dist/components/ui/fireworks-background.js +1 -1
- package/dist/components/ui/fireworks-background.js.map +1 -1
- package/dist/components/ui/flip-button.d.ts +1 -1
- package/dist/components/ui/flip-button.d.ts.map +1 -1
- package/dist/components/ui/flip-button.js +3 -3
- package/dist/components/ui/flip-button.js.map +1 -1
- package/dist/components/ui/form.d.ts +7 -8
- package/dist/components/ui/form.d.ts.map +1 -1
- package/dist/components/ui/form.js +29 -28
- package/dist/components/ui/form.js.map +1 -1
- package/dist/components/ui/gradient-background.d.ts +1 -1
- package/dist/components/ui/gradient-background.d.ts.map +1 -1
- package/dist/components/ui/gradient-background.js +2 -2
- package/dist/components/ui/gradient-background.js.map +1 -1
- package/dist/components/ui/gradient-text.d.ts +1 -1
- package/dist/components/ui/gradient-text.d.ts.map +1 -1
- package/dist/components/ui/gradient-text.js +5 -5
- package/dist/components/ui/gradient-text.js.map +1 -1
- package/dist/components/ui/highlight-text.d.ts +1 -1
- package/dist/components/ui/highlight-text.d.ts.map +1 -1
- package/dist/components/ui/highlight-text.js +3 -3
- package/dist/components/ui/highlight-text.js.map +1 -1
- package/dist/components/ui/hole-background.d.ts.map +1 -1
- package/dist/components/ui/hole-background.js +11 -10
- package/dist/components/ui/hole-background.js.map +1 -1
- package/dist/components/ui/hover-card.d.ts +5 -5
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/hover-card.js +12 -26
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +17 -0
- package/dist/components/ui/input-group.d.ts.map +1 -0
- package/dist/components/ui/input-group.js +91 -0
- package/dist/components/ui/input-group.js.map +1 -0
- package/dist/components/ui/input-otp.d.ts +31 -8
- package/dist/components/ui/input-otp.d.ts.map +1 -1
- package/dist/components/ui/input-otp.js +24 -27
- package/dist/components/ui/input-otp.js.map +1 -1
- package/dist/components/ui/input.d.ts +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +7 -8
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/item.d.ts +24 -0
- package/dist/components/ui/item.d.ts.map +1 -0
- package/dist/components/ui/item.js +122 -0
- package/dist/components/ui/item.js.map +1 -0
- package/dist/components/ui/kbd.d.ts +5 -0
- package/dist/components/ui/kbd.d.ts.map +1 -0
- package/dist/components/ui/kbd.js +21 -0
- package/dist/components/ui/kbd.js.map +1 -0
- package/dist/components/ui/label.d.ts +3 -2
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +9 -8
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/menubar.d.ts +20 -18
- package/dist/components/ui/menubar.d.ts.map +1 -1
- package/dist/components/ui/menubar.js +75 -95
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts +11 -13
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.js +39 -58
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination.d.ts +25 -10
- package/dist/components/ui/pagination.d.ts.map +1 -1
- package/dist/components/ui/pagination.js +33 -41
- package/dist/components/ui/pagination.js.map +1 -1
- package/dist/components/ui/popover.d.ts +6 -6
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/popover.js +10 -26
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/progress.d.ts +2 -2
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/progress.js +8 -10
- package/dist/components/ui/progress.js.map +1 -1
- package/dist/components/ui/radio-group.d.ts +3 -3
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group.js +17 -20
- package/dist/components/ui/radio-group.js.map +1 -1
- package/dist/components/ui/resizable.d.ts +21 -6
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +9 -21
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/ripple-button.d.ts +1 -1
- package/dist/components/ui/ripple-button.d.ts.map +1 -1
- package/dist/components/ui/ripple-button.js +4 -4
- package/dist/components/ui/ripple-button.js.map +1 -1
- package/dist/components/ui/scratcher.d.ts.map +1 -1
- package/dist/components/ui/scratcher.js +7 -5
- package/dist/components/ui/scratcher.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts +3 -3
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +14 -18
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts +11 -13
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +55 -78
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts +2 -2
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +7 -8
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/sheet.d.ts +24 -12
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet.js +56 -68
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.d.ts +35 -39
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/sidebar.js +115 -124
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/skeleton.d.ts +1 -1
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/skeleton.js +2 -3
- package/dist/components/ui/skeleton.js.map +1 -1
- package/dist/components/ui/slider.d.ts +2 -2
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/slider.js +12 -31
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/sonner.d.ts +4 -2
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/sonner.js +8 -5
- package/dist/components/ui/sonner.js.map +1 -1
- package/dist/components/ui/spinner.d.ts +4 -0
- package/dist/components/ui/spinner.d.ts.map +1 -0
- package/dist/components/ui/spinner.js +16 -0
- package/dist/components/ui/spinner.js.map +1 -0
- package/dist/components/ui/switch.d.ts +2 -2
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +8 -10
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/table.d.ts +9 -9
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/table.js +40 -49
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.d.ts +6 -6
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/tabs.js +18 -27
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/textarea.d.ts +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +7 -8
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toggle-group.d.ts +9 -4
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle-group.js +12 -16
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts +9 -6
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +8 -9
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts +6 -6
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +14 -39
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/components/ui/typewriter.d.ts.map +1 -1
- package/dist/components/ui/typewriter.js +9 -9
- package/dist/components/ui/typewriter.js.map +1 -1
- package/dist/hooks/useIsMobile.d.ts +2 -5
- package/dist/hooks/useIsMobile.d.ts.map +1 -1
- package/dist/hooks/useIsMobile.js +1 -1
- package/dist/hooks/useIsMobile.js.map +1 -1
- package/dist/hooks/useWindowSize.d.ts +0 -1
- package/dist/hooks/useWindowSize.d.ts.map +1 -1
- package/dist/hooks/useWindowSize.js +1 -1
- package/dist/hooks/useWindowSize.js.map +1 -1
- package/dist/index.css +841 -1128
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +43 -37
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -5
- package/dist/lib/utilities.d.ts +9 -0
- package/dist/lib/utilities.d.ts.map +1 -0
- package/dist/lib/{utils.js → utilities.js} +1 -1
- package/dist/lib/utilities.js.map +1 -0
- package/package.json +121 -90
- package/{README.md → readme.md} +627 -627
- package/src/components/ui/accordion.tsx +55 -66
- package/src/components/ui/alert-dialog.tsx +124 -160
- package/src/components/ui/alert.tsx +56 -69
- package/src/components/ui/aspect-ratio.tsx +7 -12
- package/src/components/ui/avatar.tsx +43 -53
- package/src/components/ui/background-beams.tsx +145 -142
- package/src/components/ui/badge.tsx +39 -48
- package/src/components/ui/breadcrumb.tsx +94 -117
- package/src/components/ui/bubble-background.tsx +170 -189
- package/src/components/ui/button-group.tsx +69 -0
- package/src/components/ui/button.tsx +55 -61
- package/src/components/ui/calendar.tsx +175 -216
- package/src/components/ui/card.tsx +64 -97
- package/src/components/ui/carousel.tsx +216 -241
- package/src/components/ui/chart.tsx +293 -385
- package/src/components/ui/checkbox.tsx +27 -32
- package/src/components/ui/collapsible.tsx +11 -34
- package/src/components/ui/command.tsx +138 -184
- package/src/components/ui/context-menu.tsx +186 -255
- package/src/components/ui/counting-number.tsx +92 -108
- package/src/components/ui/dialog.tsx +106 -146
- package/src/components/ui/dot-background.tsx +153 -158
- package/src/components/ui/drawer.tsx +105 -141
- package/src/components/ui/dropdown-menu.tsx +188 -260
- package/src/components/ui/dropdrawer.tsx +865 -973
- package/src/components/ui/empty.tsx +86 -0
- package/src/components/ui/field.tsx +198 -0
- package/src/components/ui/fireworks-background.tsx +325 -378
- package/src/components/ui/flip-button.tsx +89 -110
- package/src/components/ui/form.tsx +144 -174
- package/src/components/ui/gradient-background.tsx +30 -43
- package/src/components/ui/gradient-text.tsx +62 -65
- package/src/components/ui/highlight-text.tsx +54 -71
- package/src/components/ui/hole-background.tsx +326 -361
- package/src/components/ui/hover-card.tsx +29 -44
- package/src/components/ui/input-group.tsx +145 -0
- package/src/components/ui/input-otp.tsx +66 -77
- package/src/components/ui/input.tsx +21 -22
- package/src/components/ui/item.tsx +163 -0
- package/src/components/ui/kbd.tsx +31 -0
- package/src/components/ui/label.tsx +23 -24
- package/src/components/ui/menubar.tsx +233 -279
- package/src/components/ui/navigation-menu.tsx +120 -171
- package/src/components/ui/pagination.tsx +92 -129
- package/src/components/ui/popover.tsx +33 -48
- package/src/components/ui/progress.tsx +24 -31
- package/src/components/ui/radio-group.tsx +43 -45
- package/src/components/ui/resizable.tsx +38 -56
- package/src/components/ui/ripple-button.tsx +90 -111
- package/src/components/ui/scratcher.tsx +167 -171
- package/src/components/ui/scroll-area.tsx +42 -58
- package/src/components/ui/select.tsx +145 -191
- package/src/components/ui/separator.tsx +26 -28
- package/src/components/ui/sheet.tsx +112 -145
- package/src/components/ui/sidebar.tsx +664 -729
- package/src/components/ui/skeleton.tsx +15 -19
- package/src/components/ui/slider.tsx +23 -63
- package/src/components/ui/sonner.tsx +36 -26
- package/src/components/ui/spinner.tsx +18 -0
- package/src/components/ui/switch.tsx +28 -31
- package/src/components/ui/table.tsx +93 -119
- package/src/components/ui/tabs.tsx +54 -66
- package/src/components/ui/textarea.tsx +21 -20
- package/src/components/ui/toggle-group.tsx +53 -73
- package/src/components/ui/toggle.tsx +44 -47
- package/src/components/ui/tooltip.tsx +32 -61
- package/src/components/ui/typewriter.tsx +173 -188
- package/src/hooks/useIsMobile.tsx +42 -45
- package/src/hooks/useWindowSize.tsx +66 -72
- package/src/index.css +67 -67
- package/src/index.ts +342 -408
- package/src/lib/utilities.ts +12 -0
- package/dist/lib/utils.d.ts +0 -7
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js.map +0 -1
- package/src/lib/utils.ts +0 -10
|
@@ -1,973 +1,865 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
//
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
>
|
|
474
|
-
<
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
if (
|
|
625
|
-
|
|
626
|
-
child,
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
//
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
// Get the title
|
|
868
|
-
const title = typeof children === "string" ? children : "Submenu";
|
|
869
|
-
|
|
870
|
-
// Navigate to the submenu
|
|
871
|
-
if (navigateToSubmenu) {
|
|
872
|
-
navigateToSubmenu(submenuId, title);
|
|
873
|
-
}
|
|
874
|
-
};
|
|
875
|
-
|
|
876
|
-
// Combine onClick handlers
|
|
877
|
-
const combinedOnClick = (e: React.MouseEvent) => {
|
|
878
|
-
// Call the original onClick if provided
|
|
879
|
-
const typedProps = props as Record<string, unknown>;
|
|
880
|
-
if (typedProps["onClick"]) {
|
|
881
|
-
const originalOnClick = typedProps[
|
|
882
|
-
"onClick"
|
|
883
|
-
] as React.MouseEventHandler<HTMLDivElement>;
|
|
884
|
-
originalOnClick(e as React.MouseEvent<HTMLDivElement>);
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
// Call our navigation handler
|
|
888
|
-
handleClick(e);
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
// Remove onClick from props to avoid duplicate handlers
|
|
892
|
-
const { ...restProps } = props as Record<string, unknown>;
|
|
893
|
-
|
|
894
|
-
// Don't wrap in DrawerClose for submenu triggers
|
|
895
|
-
return (
|
|
896
|
-
<div
|
|
897
|
-
ref={itemRef}
|
|
898
|
-
data-slot="drop-drawer-sub-trigger"
|
|
899
|
-
data-inset={inset}
|
|
900
|
-
className={cn(
|
|
901
|
-
"flex cursor-pointer items-center justify-between px-4 py-4",
|
|
902
|
-
// Only apply margin, background and rounded corners if not in a group
|
|
903
|
-
!isInsideGroup &&
|
|
904
|
-
"bg-neutral-100 dark:bg-neutral-100 mx-2 my-1.5 rounded-md dark:bg-neutral-800 dark:dark:bg-neutral-800",
|
|
905
|
-
// For items in a group, don't add background but add more padding
|
|
906
|
-
isInsideGroup && "bg-transparent py-4",
|
|
907
|
-
inset && "pl-8",
|
|
908
|
-
className,
|
|
909
|
-
)}
|
|
910
|
-
onClick={combinedOnClick}
|
|
911
|
-
{...restProps}
|
|
912
|
-
>
|
|
913
|
-
<div className="flex items-center gap-2">{children}</div>
|
|
914
|
-
<ChevronRightIcon className="h-5 w-5" />
|
|
915
|
-
</div>
|
|
916
|
-
);
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
return (
|
|
920
|
-
<DropdownMenuSubTrigger
|
|
921
|
-
data-slot="drop-drawer-sub-trigger"
|
|
922
|
-
data-inset={inset}
|
|
923
|
-
className={className}
|
|
924
|
-
inset={inset}
|
|
925
|
-
{...props}
|
|
926
|
-
>
|
|
927
|
-
{children}
|
|
928
|
-
</DropdownMenuSubTrigger>
|
|
929
|
-
);
|
|
930
|
-
}
|
|
931
|
-
|
|
932
|
-
function DropDrawerSubContent({
|
|
933
|
-
className,
|
|
934
|
-
sideOffset = 4,
|
|
935
|
-
children,
|
|
936
|
-
...props
|
|
937
|
-
}: React.ComponentProps<typeof DropdownMenuSubContent>) {
|
|
938
|
-
const { isMobile } = useDropDrawerContext();
|
|
939
|
-
|
|
940
|
-
if (isMobile) {
|
|
941
|
-
// For mobile, we don't render the content directly
|
|
942
|
-
// It will be rendered by the DropDrawerContent component when active
|
|
943
|
-
return null;
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
return (
|
|
947
|
-
<DropdownMenuSubContent
|
|
948
|
-
data-slot="drop-drawer-sub-content"
|
|
949
|
-
sideOffset={sideOffset}
|
|
950
|
-
className={cn(
|
|
951
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 p-1 shadow-lg dark:border-neutral-800",
|
|
952
|
-
className,
|
|
953
|
-
)}
|
|
954
|
-
{...props}
|
|
955
|
-
>
|
|
956
|
-
{children}
|
|
957
|
-
</DropdownMenuSubContent>
|
|
958
|
-
);
|
|
959
|
-
}
|
|
960
|
-
|
|
961
|
-
export {
|
|
962
|
-
DropDrawer,
|
|
963
|
-
DropDrawerContent,
|
|
964
|
-
DropDrawerFooter,
|
|
965
|
-
DropDrawerGroup,
|
|
966
|
-
DropDrawerItem,
|
|
967
|
-
DropDrawerLabel,
|
|
968
|
-
DropDrawerSeparator,
|
|
969
|
-
DropDrawerSub,
|
|
970
|
-
DropDrawerSubContent,
|
|
971
|
-
DropDrawerSubTrigger,
|
|
972
|
-
DropDrawerTrigger,
|
|
973
|
-
};
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
/* eslint-disable */
|
|
4
|
+
|
|
5
|
+
import {ChevronLeftIcon, ChevronRightIcon} from "lucide-react";
|
|
6
|
+
import {AnimatePresence, motion, Transition} from "motion/react";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
|
|
9
|
+
import {Drawer, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger} from "@/components/ui/drawer";
|
|
10
|
+
import {
|
|
11
|
+
DropdownMenu,
|
|
12
|
+
DropdownMenuContent,
|
|
13
|
+
DropdownMenuItem,
|
|
14
|
+
DropdownMenuLabel,
|
|
15
|
+
DropdownMenuSeparator,
|
|
16
|
+
DropdownMenuSub,
|
|
17
|
+
DropdownMenuSubContent,
|
|
18
|
+
DropdownMenuSubTrigger,
|
|
19
|
+
DropdownMenuTrigger,
|
|
20
|
+
} from "@/components/ui/dropdown-menu";
|
|
21
|
+
import {useIsMobile} from "@/hooks/useIsMobile";
|
|
22
|
+
import {cn} from "@/lib/utilities";
|
|
23
|
+
|
|
24
|
+
const DropDrawerContext = React.createContext<{isMobile: boolean}>({
|
|
25
|
+
isMobile: false,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const useDropDrawerContext = () => {
|
|
29
|
+
const context = React.useContext(DropDrawerContext);
|
|
30
|
+
if (!context) {
|
|
31
|
+
throw new Error("DropDrawer components cannot be rendered outside the Context");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
function DropDrawer({children, ...props}: React.ComponentProps<typeof Drawer> | React.ComponentProps<typeof DropdownMenu>) {
|
|
37
|
+
const isMobile = useIsMobile();
|
|
38
|
+
const DropdownComponent = isMobile ? Drawer : DropdownMenu;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<DropDrawerContext.Provider value={{isMobile}}>
|
|
42
|
+
<DropdownComponent
|
|
43
|
+
data-slot='drop-drawer'
|
|
44
|
+
{...(isMobile && {autoFocus: true})}
|
|
45
|
+
{...props}>
|
|
46
|
+
{children}
|
|
47
|
+
</DropdownComponent>
|
|
48
|
+
</DropDrawerContext.Provider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function DropDrawerTrigger({
|
|
53
|
+
className,
|
|
54
|
+
children,
|
|
55
|
+
...props
|
|
56
|
+
}: React.ComponentProps<typeof DrawerTrigger> | React.ComponentProps<typeof DropdownMenuTrigger>) {
|
|
57
|
+
const {isMobile} = useDropDrawerContext();
|
|
58
|
+
const TriggerComponent = isMobile ? DrawerTrigger : DropdownMenuTrigger;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<TriggerComponent
|
|
62
|
+
data-slot='drop-drawer-trigger'
|
|
63
|
+
className={className}
|
|
64
|
+
{...props}>
|
|
65
|
+
{children}
|
|
66
|
+
</TriggerComponent>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function DropDrawerContent({
|
|
71
|
+
className,
|
|
72
|
+
children,
|
|
73
|
+
...props
|
|
74
|
+
}: React.ComponentProps<typeof DrawerContent> | React.ComponentProps<typeof DropdownMenuContent>) {
|
|
75
|
+
const {isMobile} = useDropDrawerContext();
|
|
76
|
+
const [activeSubmenu, setActiveSubmenu] = React.useState<string | null>(null);
|
|
77
|
+
const [submenuTitle, setSubmenuTitle] = React.useState<string | null>(null);
|
|
78
|
+
const [submenuStack, setSubmenuStack] = React.useState<{id: string; title: string}[]>([]);
|
|
79
|
+
// Add animation direction state
|
|
80
|
+
const [animationDirection, setAnimationDirection] = React.useState<"forward" | "backward">("forward");
|
|
81
|
+
|
|
82
|
+
// Create a ref to store submenu content by ID
|
|
83
|
+
const submenuContentRef = React.useRef<Map<string, React.ReactNode[]>>(new Map());
|
|
84
|
+
|
|
85
|
+
// Function to navigate to a submenu
|
|
86
|
+
const navigateToSubmenu = React.useCallback((id: string, title: string) => {
|
|
87
|
+
// Set animation direction to forward when navigating to a submenu
|
|
88
|
+
setAnimationDirection("forward");
|
|
89
|
+
setActiveSubmenu(id);
|
|
90
|
+
setSubmenuTitle(title);
|
|
91
|
+
setSubmenuStack((prev) => [...prev, {id, title}]);
|
|
92
|
+
}, []);
|
|
93
|
+
|
|
94
|
+
// Function to go back to previous menu
|
|
95
|
+
const goBack = React.useCallback(() => {
|
|
96
|
+
// Set animation direction to backward when going back
|
|
97
|
+
setAnimationDirection("backward");
|
|
98
|
+
|
|
99
|
+
if (submenuStack.length <= 1) {
|
|
100
|
+
// If we're at the first level, go back to main menu
|
|
101
|
+
setActiveSubmenu(null);
|
|
102
|
+
setSubmenuTitle(null);
|
|
103
|
+
setSubmenuStack([]);
|
|
104
|
+
} else {
|
|
105
|
+
// Go back to previous submenu
|
|
106
|
+
const newStack = [...submenuStack];
|
|
107
|
+
newStack.pop(); // Remove current
|
|
108
|
+
const previous = newStack[newStack.length - 1];
|
|
109
|
+
setActiveSubmenu(previous.id);
|
|
110
|
+
setSubmenuTitle(previous.title);
|
|
111
|
+
setSubmenuStack(newStack);
|
|
112
|
+
}
|
|
113
|
+
}, [submenuStack]);
|
|
114
|
+
|
|
115
|
+
// Function to register submenu content
|
|
116
|
+
const registerSubmenuContent = React.useCallback((id: string, content: React.ReactNode[]) => {
|
|
117
|
+
submenuContentRef.current.set(id, content);
|
|
118
|
+
}, []);
|
|
119
|
+
|
|
120
|
+
// Function to extract submenu content
|
|
121
|
+
const extractSubmenuContent = React.useCallback((elements: React.ReactNode, targetId: string): React.ReactNode[] => {
|
|
122
|
+
const result: React.ReactNode[] = [];
|
|
123
|
+
|
|
124
|
+
// Recursive function to search through all children
|
|
125
|
+
const findSubmenuContent = (node: React.ReactNode) => {
|
|
126
|
+
// Skip if not a valid element
|
|
127
|
+
if (!React.isValidElement(node)) return;
|
|
128
|
+
|
|
129
|
+
const element = node as React.ReactElement;
|
|
130
|
+
// Use a more specific type to avoid 'any'
|
|
131
|
+
const props = element.props as {
|
|
132
|
+
id?: string;
|
|
133
|
+
"data-submenu-id"?: string;
|
|
134
|
+
children?: React.ReactNode;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Check if this is a DropDrawerSub
|
|
138
|
+
if (element.type === DropDrawerSub) {
|
|
139
|
+
// Get all possible ID values
|
|
140
|
+
const elementId = props.id;
|
|
141
|
+
const dataSubmenuId = props["data-submenu-id"];
|
|
142
|
+
|
|
143
|
+
// If this is the submenu we're looking for
|
|
144
|
+
if (elementId === targetId || dataSubmenuId === targetId) {
|
|
145
|
+
// Find the SubContent within this Sub
|
|
146
|
+
if (props.children) {
|
|
147
|
+
React.Children.forEach(props.children, (child) => {
|
|
148
|
+
if (React.isValidElement(child) && child.type === DropDrawerSubContent) {
|
|
149
|
+
// Add all children of the SubContent to the result
|
|
150
|
+
const subContentProps = child.props as {
|
|
151
|
+
children?: React.ReactNode;
|
|
152
|
+
};
|
|
153
|
+
if (subContentProps.children) {
|
|
154
|
+
React.Children.forEach(subContentProps.children, (contentChild) => {
|
|
155
|
+
result.push(contentChild);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return; // Found what we needed, no need to search deeper
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// If this element has children, search through them
|
|
166
|
+
if (props.children) {
|
|
167
|
+
if (Array.isArray(props.children)) {
|
|
168
|
+
props.children.forEach((child: React.ReactNode) => findSubmenuContent(child));
|
|
169
|
+
} else {
|
|
170
|
+
findSubmenuContent(props.children);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// Start the search from the root elements
|
|
176
|
+
if (Array.isArray(elements)) {
|
|
177
|
+
elements.forEach((child) => findSubmenuContent(child));
|
|
178
|
+
} else {
|
|
179
|
+
findSubmenuContent(elements);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return result;
|
|
183
|
+
}, []);
|
|
184
|
+
|
|
185
|
+
// Get submenu content (either from cache or extract it)
|
|
186
|
+
const getSubmenuContent = React.useCallback(
|
|
187
|
+
(id: string) => {
|
|
188
|
+
// Check if we have the content in our ref
|
|
189
|
+
const cachedContent = submenuContentRef.current.get(id || "");
|
|
190
|
+
if (cachedContent && cachedContent.length > 0) {
|
|
191
|
+
return cachedContent;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// If not in cache, extract it
|
|
195
|
+
const submenuContent = extractSubmenuContent(children, id);
|
|
196
|
+
|
|
197
|
+
if (submenuContent.length === 0) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Store in cache for future use
|
|
202
|
+
if (id) {
|
|
203
|
+
submenuContentRef.current.set(id, submenuContent);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return submenuContent;
|
|
207
|
+
},
|
|
208
|
+
[children, extractSubmenuContent],
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
// Animation variants for Framer Motion
|
|
212
|
+
const variants = {
|
|
213
|
+
enter: (direction: "forward" | "backward") => ({
|
|
214
|
+
x: direction === "forward" ? "100%" : "-100%",
|
|
215
|
+
opacity: 0,
|
|
216
|
+
}),
|
|
217
|
+
center: {
|
|
218
|
+
x: 0,
|
|
219
|
+
opacity: 1,
|
|
220
|
+
},
|
|
221
|
+
exit: (direction: "forward" | "backward") => ({
|
|
222
|
+
x: direction === "forward" ? "-100%" : "100%",
|
|
223
|
+
opacity: 0,
|
|
224
|
+
}),
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// Animation transition
|
|
228
|
+
const transition = {
|
|
229
|
+
duration: 0.3,
|
|
230
|
+
ease: [0.25, 0.1, 0.25, 1.0], // cubic-bezier easing
|
|
231
|
+
} satisfies Transition;
|
|
232
|
+
|
|
233
|
+
if (isMobile) {
|
|
234
|
+
return (
|
|
235
|
+
<SubmenuContext.Provider
|
|
236
|
+
value={{
|
|
237
|
+
activeSubmenu,
|
|
238
|
+
setActiveSubmenu: (id) => {
|
|
239
|
+
if (id === null) {
|
|
240
|
+
setActiveSubmenu(null);
|
|
241
|
+
setSubmenuTitle(null);
|
|
242
|
+
setSubmenuStack([]);
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
submenuTitle,
|
|
246
|
+
setSubmenuTitle,
|
|
247
|
+
navigateToSubmenu,
|
|
248
|
+
registerSubmenuContent,
|
|
249
|
+
}}>
|
|
250
|
+
<DrawerContent
|
|
251
|
+
data-slot='drop-drawer-content'
|
|
252
|
+
className={cn("max-h-[90vh]", className)}
|
|
253
|
+
{...props}>
|
|
254
|
+
{activeSubmenu ? (
|
|
255
|
+
<>
|
|
256
|
+
<DrawerHeader>
|
|
257
|
+
<div className='flex items-center gap-2'>
|
|
258
|
+
<button
|
|
259
|
+
onClick={goBack}
|
|
260
|
+
className='rounded-full p-1 hover:bg-neutral-100/50 dark:hover:bg-neutral-800/50'>
|
|
261
|
+
<ChevronLeftIcon className='h-5 w-5' />
|
|
262
|
+
</button>
|
|
263
|
+
<DrawerTitle>{submenuTitle || "Submenu"}</DrawerTitle>
|
|
264
|
+
</div>
|
|
265
|
+
</DrawerHeader>
|
|
266
|
+
<div className='relative max-h-[70vh] flex-1 overflow-y-auto'>
|
|
267
|
+
{/* Use AnimatePresence to handle exit animations */}
|
|
268
|
+
<AnimatePresence
|
|
269
|
+
initial={false}
|
|
270
|
+
mode='wait'
|
|
271
|
+
custom={animationDirection}>
|
|
272
|
+
<motion.div
|
|
273
|
+
key={activeSubmenu || "main"}
|
|
274
|
+
custom={animationDirection}
|
|
275
|
+
variants={variants}
|
|
276
|
+
initial='enter'
|
|
277
|
+
animate='center'
|
|
278
|
+
exit='exit'
|
|
279
|
+
transition={transition}
|
|
280
|
+
className='h-full w-full space-y-1.5 pb-6'>
|
|
281
|
+
{activeSubmenu ? getSubmenuContent(activeSubmenu) : children}
|
|
282
|
+
</motion.div>
|
|
283
|
+
</AnimatePresence>
|
|
284
|
+
</div>
|
|
285
|
+
</>
|
|
286
|
+
) : (
|
|
287
|
+
<>
|
|
288
|
+
<DrawerHeader className='sr-only'>
|
|
289
|
+
<DrawerTitle>Menu</DrawerTitle>
|
|
290
|
+
</DrawerHeader>
|
|
291
|
+
<div className='max-h-[70vh] overflow-y-auto'>
|
|
292
|
+
<AnimatePresence
|
|
293
|
+
initial={false}
|
|
294
|
+
mode='wait'
|
|
295
|
+
custom={animationDirection}>
|
|
296
|
+
<motion.div
|
|
297
|
+
key='main-menu'
|
|
298
|
+
custom={animationDirection}
|
|
299
|
+
variants={variants}
|
|
300
|
+
initial='enter'
|
|
301
|
+
animate='center'
|
|
302
|
+
exit='exit'
|
|
303
|
+
transition={transition}
|
|
304
|
+
className='w-full space-y-1.5 pb-6'>
|
|
305
|
+
{children}
|
|
306
|
+
</motion.div>
|
|
307
|
+
</AnimatePresence>
|
|
308
|
+
</div>
|
|
309
|
+
</>
|
|
310
|
+
)}
|
|
311
|
+
</DrawerContent>
|
|
312
|
+
</SubmenuContext.Provider>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
return (
|
|
317
|
+
<SubmenuContext.Provider
|
|
318
|
+
value={{
|
|
319
|
+
activeSubmenu,
|
|
320
|
+
setActiveSubmenu,
|
|
321
|
+
submenuTitle,
|
|
322
|
+
setSubmenuTitle,
|
|
323
|
+
registerSubmenuContent,
|
|
324
|
+
}}>
|
|
325
|
+
<DropdownMenuContent
|
|
326
|
+
data-slot='drop-drawer-content'
|
|
327
|
+
align='end'
|
|
328
|
+
sideOffset={4}
|
|
329
|
+
className={cn("max-h-[var(--radix-dropdown-menu-content-available-height)] min-w-[220px] overflow-y-auto", className)}
|
|
330
|
+
{...props}>
|
|
331
|
+
{children}
|
|
332
|
+
</DropdownMenuContent>
|
|
333
|
+
</SubmenuContext.Provider>
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function DropDrawerItem({
|
|
338
|
+
className,
|
|
339
|
+
children,
|
|
340
|
+
onSelect,
|
|
341
|
+
onClick,
|
|
342
|
+
icon,
|
|
343
|
+
inset,
|
|
344
|
+
disabled,
|
|
345
|
+
...props
|
|
346
|
+
}: React.ComponentProps<typeof DropdownMenuItem> & {
|
|
347
|
+
icon?: React.ReactNode;
|
|
348
|
+
}) {
|
|
349
|
+
const {isMobile} = useDropDrawerContext();
|
|
350
|
+
|
|
351
|
+
// Define hooks outside of conditionals to follow React rules
|
|
352
|
+
// Check if this item is inside a group by looking at parent elements
|
|
353
|
+
const isInGroup = React.useCallback((element: HTMLElement | null): boolean => {
|
|
354
|
+
if (!element) return false;
|
|
355
|
+
|
|
356
|
+
// Check if any parent has a data-drop-drawer-group attribute
|
|
357
|
+
let parent = element.parentElement;
|
|
358
|
+
while (parent) {
|
|
359
|
+
if (parent.hasAttribute("data-drop-drawer-group")) {
|
|
360
|
+
return true;
|
|
361
|
+
}
|
|
362
|
+
parent = parent.parentElement;
|
|
363
|
+
}
|
|
364
|
+
return false;
|
|
365
|
+
}, []);
|
|
366
|
+
|
|
367
|
+
// Create a ref to check if the item is in a group
|
|
368
|
+
const itemRef = React.useRef<HTMLDivElement>(null);
|
|
369
|
+
const [isInsideGroup, setIsInsideGroup] = React.useState(false);
|
|
370
|
+
|
|
371
|
+
React.useEffect(() => {
|
|
372
|
+
// Only run this effect in mobile mode
|
|
373
|
+
if (!isMobile) return;
|
|
374
|
+
|
|
375
|
+
// Use a short timeout to ensure the DOM is fully rendered
|
|
376
|
+
const timer = setTimeout(() => {
|
|
377
|
+
if (itemRef.current) {
|
|
378
|
+
setIsInsideGroup(isInGroup(itemRef.current));
|
|
379
|
+
}
|
|
380
|
+
}, 0);
|
|
381
|
+
|
|
382
|
+
return () => clearTimeout(timer);
|
|
383
|
+
}, [isInGroup, isMobile]);
|
|
384
|
+
|
|
385
|
+
if (isMobile) {
|
|
386
|
+
const handleClick = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
387
|
+
if (disabled) return;
|
|
388
|
+
if (onClick) onClick(e);
|
|
389
|
+
if (onSelect) onSelect(e as unknown as Event);
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// Only wrap in DrawerClose if it's not a submenu item
|
|
393
|
+
const content = (
|
|
394
|
+
<div
|
|
395
|
+
ref={itemRef}
|
|
396
|
+
data-slot='drop-drawer-item'
|
|
397
|
+
data-inset={inset}
|
|
398
|
+
data-disabled={disabled}
|
|
399
|
+
className={cn(
|
|
400
|
+
"flex cursor-pointer items-center justify-between px-4 py-4",
|
|
401
|
+
// Only apply margin, background and rounded corners if not in a group
|
|
402
|
+
!isInsideGroup && "mx-2 my-1.5 rounded-md bg-neutral-100 dark:bg-neutral-100 dark:bg-neutral-800 dark:dark:bg-neutral-800",
|
|
403
|
+
// For items in a group, don't add background but add more padding
|
|
404
|
+
isInsideGroup && "bg-transparent py-4",
|
|
405
|
+
inset && "pl-8",
|
|
406
|
+
disabled && "pointer-events-none opacity-50",
|
|
407
|
+
className,
|
|
408
|
+
)}
|
|
409
|
+
onClick={handleClick}
|
|
410
|
+
aria-disabled={disabled}
|
|
411
|
+
{...props}>
|
|
412
|
+
<div className='flex items-center gap-2'>{children}</div>
|
|
413
|
+
{icon && <div className='flex-shrink-0'>{icon}</div>}
|
|
414
|
+
</div>
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
// Check if this is inside a submenu
|
|
418
|
+
const isInSubmenu =
|
|
419
|
+
(props as Record<string, unknown>)["data-parent-submenu-id"] || (props as Record<string, unknown>)["data-parent-submenu"];
|
|
420
|
+
|
|
421
|
+
if (isInSubmenu) {
|
|
422
|
+
return content;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return <DrawerClose asChild>{content}</DrawerClose>;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return (
|
|
429
|
+
<DropdownMenuItem
|
|
430
|
+
data-slot='drop-drawer-item'
|
|
431
|
+
data-inset={inset}
|
|
432
|
+
className={className}
|
|
433
|
+
onSelect={onSelect}
|
|
434
|
+
onClick={onClick as React.MouseEventHandler<HTMLDivElement>}
|
|
435
|
+
inset={inset}
|
|
436
|
+
disabled={disabled}
|
|
437
|
+
{...props}>
|
|
438
|
+
<div className='flex w-full items-center justify-between'>
|
|
439
|
+
<div>{children}</div>
|
|
440
|
+
{icon && <div>{icon}</div>}
|
|
441
|
+
</div>
|
|
442
|
+
</DropdownMenuItem>
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function DropDrawerSeparator({className, ...props}: React.ComponentProps<typeof DropdownMenuSeparator>) {
|
|
447
|
+
const {isMobile} = useDropDrawerContext();
|
|
448
|
+
|
|
449
|
+
// For mobile, render a simple divider
|
|
450
|
+
if (isMobile) {
|
|
451
|
+
return null;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// For desktop, use the standard dropdown separator
|
|
455
|
+
return (
|
|
456
|
+
<DropdownMenuSeparator
|
|
457
|
+
data-slot='drop-drawer-separator'
|
|
458
|
+
className={className}
|
|
459
|
+
{...props}
|
|
460
|
+
/>
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function DropDrawerLabel({
|
|
465
|
+
className,
|
|
466
|
+
children,
|
|
467
|
+
...props
|
|
468
|
+
}: React.ComponentProps<typeof DropdownMenuLabel> | React.ComponentProps<typeof DrawerTitle>) {
|
|
469
|
+
const {isMobile} = useDropDrawerContext();
|
|
470
|
+
|
|
471
|
+
if (isMobile) {
|
|
472
|
+
return (
|
|
473
|
+
<DrawerHeader className='p-0'>
|
|
474
|
+
<DrawerTitle
|
|
475
|
+
data-slot='drop-drawer-label'
|
|
476
|
+
className={cn("px-4 py-2 text-sm font-medium text-neutral-500 dark:text-neutral-400", className)}
|
|
477
|
+
{...props}>
|
|
478
|
+
{children}
|
|
479
|
+
</DrawerTitle>
|
|
480
|
+
</DrawerHeader>
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return (
|
|
485
|
+
<DropdownMenuLabel
|
|
486
|
+
data-slot='drop-drawer-label'
|
|
487
|
+
className={className}
|
|
488
|
+
{...props}>
|
|
489
|
+
{children}
|
|
490
|
+
</DropdownMenuLabel>
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
function DropDrawerFooter({className, children, ...props}: React.ComponentProps<typeof DrawerFooter> | React.ComponentProps<"div">) {
|
|
495
|
+
const {isMobile} = useDropDrawerContext();
|
|
496
|
+
|
|
497
|
+
if (isMobile) {
|
|
498
|
+
return (
|
|
499
|
+
<DrawerFooter
|
|
500
|
+
data-slot='drop-drawer-footer'
|
|
501
|
+
className={cn("p-4", className)}
|
|
502
|
+
{...props}>
|
|
503
|
+
{children}
|
|
504
|
+
</DrawerFooter>
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// No direct equivalent in DropdownMenu, so we'll just render a div
|
|
509
|
+
return (
|
|
510
|
+
<div
|
|
511
|
+
data-slot='drop-drawer-footer'
|
|
512
|
+
className={cn("p-2", className)}
|
|
513
|
+
{...props}>
|
|
514
|
+
{children}
|
|
515
|
+
</div>
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function DropDrawerGroup({
|
|
520
|
+
className,
|
|
521
|
+
children,
|
|
522
|
+
...props
|
|
523
|
+
}: React.ComponentProps<"div"> & {
|
|
524
|
+
children: React.ReactNode;
|
|
525
|
+
}) {
|
|
526
|
+
const {isMobile} = useDropDrawerContext();
|
|
527
|
+
|
|
528
|
+
// Add separators between children on mobile
|
|
529
|
+
const childrenWithSeparators = React.useMemo(() => {
|
|
530
|
+
if (!isMobile) return children;
|
|
531
|
+
|
|
532
|
+
const childArray = React.Children.toArray(children);
|
|
533
|
+
|
|
534
|
+
// Filter out any existing separators
|
|
535
|
+
const filteredChildren = childArray.filter((child) => React.isValidElement(child) && child.type !== DropDrawerSeparator);
|
|
536
|
+
|
|
537
|
+
// Add separators between items
|
|
538
|
+
return filteredChildren.flatMap((child, index) => {
|
|
539
|
+
if (index === filteredChildren.length - 1) return [child];
|
|
540
|
+
return [
|
|
541
|
+
child,
|
|
542
|
+
<div
|
|
543
|
+
key={`separator-${index}`}
|
|
544
|
+
className='h-px bg-neutral-200 dark:bg-neutral-800'
|
|
545
|
+
aria-hidden='true'
|
|
546
|
+
/>,
|
|
547
|
+
];
|
|
548
|
+
});
|
|
549
|
+
}, [children, isMobile]);
|
|
550
|
+
|
|
551
|
+
if (isMobile) {
|
|
552
|
+
return (
|
|
553
|
+
<div
|
|
554
|
+
data-drop-drawer-group
|
|
555
|
+
data-slot='drop-drawer-group'
|
|
556
|
+
role='group'
|
|
557
|
+
className={cn(
|
|
558
|
+
"mx-2 my-3 overflow-hidden rounded-xl bg-neutral-100 dark:bg-neutral-100 dark:bg-neutral-800 dark:dark:bg-neutral-800",
|
|
559
|
+
className,
|
|
560
|
+
)}
|
|
561
|
+
{...props}>
|
|
562
|
+
{childrenWithSeparators}
|
|
563
|
+
</div>
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// On desktop, use a div with proper role and attributes
|
|
568
|
+
return (
|
|
569
|
+
<div
|
|
570
|
+
data-drop-drawer-group
|
|
571
|
+
data-slot='drop-drawer-group'
|
|
572
|
+
role='group'
|
|
573
|
+
className={className}
|
|
574
|
+
{...props}>
|
|
575
|
+
{children}
|
|
576
|
+
</div>
|
|
577
|
+
);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Context for managing submenu state on mobile
|
|
581
|
+
interface SubmenuContextType {
|
|
582
|
+
activeSubmenu: string | null;
|
|
583
|
+
setActiveSubmenu: (id: string | null) => void;
|
|
584
|
+
submenuTitle: string | null;
|
|
585
|
+
setSubmenuTitle: (title: string | null) => void;
|
|
586
|
+
navigateToSubmenu?: (id: string, title: string) => void;
|
|
587
|
+
registerSubmenuContent?: (id: string, content: React.ReactNode[]) => void;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
const SubmenuContext = React.createContext<SubmenuContextType>({
|
|
591
|
+
activeSubmenu: null,
|
|
592
|
+
setActiveSubmenu: () => {},
|
|
593
|
+
submenuTitle: null,
|
|
594
|
+
setSubmenuTitle: () => {},
|
|
595
|
+
navigateToSubmenu: undefined,
|
|
596
|
+
registerSubmenuContent: undefined,
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
// Submenu components
|
|
600
|
+
// Counter for generating simple numeric IDs
|
|
601
|
+
let submenuIdCounter = 0;
|
|
602
|
+
|
|
603
|
+
function DropDrawerSub({
|
|
604
|
+
children,
|
|
605
|
+
id,
|
|
606
|
+
...props
|
|
607
|
+
}: React.ComponentProps<typeof DropdownMenuSub> & {
|
|
608
|
+
id?: string;
|
|
609
|
+
}) {
|
|
610
|
+
const {isMobile} = useDropDrawerContext();
|
|
611
|
+
const {registerSubmenuContent} = React.useContext(SubmenuContext);
|
|
612
|
+
|
|
613
|
+
// Generate a simple numeric ID instead of using React.useId()
|
|
614
|
+
const [generatedId] = React.useState(() => `submenu-${submenuIdCounter++}`);
|
|
615
|
+
const submenuId = id || generatedId;
|
|
616
|
+
|
|
617
|
+
// Extract submenu content to register with parent
|
|
618
|
+
React.useEffect(() => {
|
|
619
|
+
if (!registerSubmenuContent) return;
|
|
620
|
+
|
|
621
|
+
// Find the SubContent within this Sub
|
|
622
|
+
const contentItems: React.ReactNode[] = [];
|
|
623
|
+
React.Children.forEach(children, (child) => {
|
|
624
|
+
if (React.isValidElement(child) && child.type === DropDrawerSubContent) {
|
|
625
|
+
// Add all children of the SubContent to the result
|
|
626
|
+
React.Children.forEach((child.props as {children?: React.ReactNode}).children, (contentChild) => {
|
|
627
|
+
contentItems.push(contentChild);
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
// Register the content with the parent
|
|
633
|
+
if (contentItems.length > 0) {
|
|
634
|
+
registerSubmenuContent(submenuId, contentItems);
|
|
635
|
+
}
|
|
636
|
+
}, [children, registerSubmenuContent, submenuId]);
|
|
637
|
+
|
|
638
|
+
if (isMobile) {
|
|
639
|
+
// For mobile, we'll use the context to manage submenu state
|
|
640
|
+
// Process children to pass the submenu ID to the trigger and content
|
|
641
|
+
const processedChildren = React.Children.map(children, (child) => {
|
|
642
|
+
if (!React.isValidElement(child)) return child;
|
|
643
|
+
|
|
644
|
+
if (child.type === DropDrawerSubTrigger) {
|
|
645
|
+
return React.cloneElement(
|
|
646
|
+
child as React.ReactElement,
|
|
647
|
+
{
|
|
648
|
+
...(child.props as object),
|
|
649
|
+
"data-parent-submenu-id": submenuId,
|
|
650
|
+
"data-submenu-id": submenuId,
|
|
651
|
+
// Use only data attributes, not custom props
|
|
652
|
+
"data-parent-submenu": submenuId,
|
|
653
|
+
} as React.HTMLAttributes<HTMLElement>,
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
if (child.type === DropDrawerSubContent) {
|
|
658
|
+
return React.cloneElement(
|
|
659
|
+
child as React.ReactElement,
|
|
660
|
+
{
|
|
661
|
+
...(child.props as object),
|
|
662
|
+
"data-parent-submenu-id": submenuId,
|
|
663
|
+
"data-submenu-id": submenuId,
|
|
664
|
+
// Use only data attributes, not custom props
|
|
665
|
+
"data-parent-submenu": submenuId,
|
|
666
|
+
} as React.HTMLAttributes<HTMLElement>,
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
return child;
|
|
671
|
+
});
|
|
672
|
+
|
|
673
|
+
return (
|
|
674
|
+
<div
|
|
675
|
+
data-slot='drop-drawer-sub'
|
|
676
|
+
data-submenu-id={submenuId}
|
|
677
|
+
id={submenuId}>
|
|
678
|
+
{processedChildren}
|
|
679
|
+
</div>
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// For desktop, pass the generated ID to the DropdownMenuSub
|
|
684
|
+
return (
|
|
685
|
+
<DropdownMenuSub
|
|
686
|
+
data-slot='drop-drawer-sub'
|
|
687
|
+
data-submenu-id={submenuId}
|
|
688
|
+
// Don't pass id to DropdownMenuSub as it doesn't accept this prop
|
|
689
|
+
{...props}>
|
|
690
|
+
{children}
|
|
691
|
+
</DropdownMenuSub>
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
function DropDrawerSubTrigger({
|
|
696
|
+
className,
|
|
697
|
+
inset,
|
|
698
|
+
children,
|
|
699
|
+
...props
|
|
700
|
+
}: React.ComponentProps<typeof DropdownMenuSubTrigger> & {
|
|
701
|
+
icon?: React.ReactNode;
|
|
702
|
+
}) {
|
|
703
|
+
const {isMobile} = useDropDrawerContext();
|
|
704
|
+
const {navigateToSubmenu} = React.useContext(SubmenuContext);
|
|
705
|
+
|
|
706
|
+
// Define hooks outside of conditionals to follow React rules
|
|
707
|
+
// Check if this item is inside a group by looking at parent elements
|
|
708
|
+
const isInGroup = React.useCallback((element: HTMLElement | null): boolean => {
|
|
709
|
+
if (!element) return false;
|
|
710
|
+
|
|
711
|
+
// Check if any parent has a data-drop-drawer-group attribute
|
|
712
|
+
let parent = element.parentElement;
|
|
713
|
+
while (parent) {
|
|
714
|
+
if (parent.hasAttribute("data-drop-drawer-group")) {
|
|
715
|
+
return true;
|
|
716
|
+
}
|
|
717
|
+
parent = parent.parentElement;
|
|
718
|
+
}
|
|
719
|
+
return false;
|
|
720
|
+
}, []);
|
|
721
|
+
|
|
722
|
+
// Create a ref to check if the item is in a group
|
|
723
|
+
const itemRef = React.useRef<HTMLDivElement>(null);
|
|
724
|
+
const [isInsideGroup, setIsInsideGroup] = React.useState(false);
|
|
725
|
+
|
|
726
|
+
React.useEffect(() => {
|
|
727
|
+
// Only run this effect in mobile mode
|
|
728
|
+
if (!isMobile) return;
|
|
729
|
+
|
|
730
|
+
// Use a short timeout to ensure the DOM is fully rendered
|
|
731
|
+
const timer = setTimeout(() => {
|
|
732
|
+
if (itemRef.current) {
|
|
733
|
+
setIsInsideGroup(isInGroup(itemRef.current));
|
|
734
|
+
}
|
|
735
|
+
}, 0);
|
|
736
|
+
|
|
737
|
+
return () => clearTimeout(timer);
|
|
738
|
+
}, [isInGroup, isMobile]);
|
|
739
|
+
|
|
740
|
+
if (isMobile) {
|
|
741
|
+
// Find the parent submenu ID
|
|
742
|
+
const handleClick = (e: React.MouseEvent) => {
|
|
743
|
+
e.preventDefault();
|
|
744
|
+
e.stopPropagation();
|
|
745
|
+
|
|
746
|
+
// Get the closest parent with data-submenu-id attribute
|
|
747
|
+
const element = e.currentTarget as HTMLElement;
|
|
748
|
+
let submenuId: string | null = null;
|
|
749
|
+
|
|
750
|
+
// First check if the element itself has the data attribute
|
|
751
|
+
if (element.closest("[data-submenu-id]")) {
|
|
752
|
+
const closestElement = element.closest("[data-submenu-id]");
|
|
753
|
+
const id = closestElement?.getAttribute("data-submenu-id");
|
|
754
|
+
if (id) {
|
|
755
|
+
submenuId = id;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
// If not found, try props
|
|
760
|
+
if (!submenuId) {
|
|
761
|
+
submenuId =
|
|
762
|
+
((props as Record<string, unknown>)["data-parent-submenu-id"] as string)
|
|
763
|
+
|| ((props as Record<string, unknown>)["data-parent-submenu"] as string);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
if (!submenuId) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
// Get the title
|
|
771
|
+
const title = typeof children === "string" ? children : "Submenu";
|
|
772
|
+
|
|
773
|
+
// Navigate to the submenu
|
|
774
|
+
if (navigateToSubmenu) {
|
|
775
|
+
navigateToSubmenu(submenuId, title);
|
|
776
|
+
}
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
// Combine onClick handlers
|
|
780
|
+
const combinedOnClick = (e: React.MouseEvent) => {
|
|
781
|
+
// Call the original onClick if provided
|
|
782
|
+
const typedProps = props as Record<string, unknown>;
|
|
783
|
+
if (typedProps["onClick"]) {
|
|
784
|
+
const originalOnClick = typedProps["onClick"] as React.MouseEventHandler<HTMLDivElement>;
|
|
785
|
+
originalOnClick(e as React.MouseEvent<HTMLDivElement>);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
// Call our navigation handler
|
|
789
|
+
handleClick(e);
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
// Remove onClick from props to avoid duplicate handlers
|
|
793
|
+
const {...restProps} = props as Record<string, unknown>;
|
|
794
|
+
|
|
795
|
+
// Don't wrap in DrawerClose for submenu triggers
|
|
796
|
+
return (
|
|
797
|
+
<div
|
|
798
|
+
ref={itemRef}
|
|
799
|
+
data-slot='drop-drawer-sub-trigger'
|
|
800
|
+
data-inset={inset}
|
|
801
|
+
className={cn(
|
|
802
|
+
"flex cursor-pointer items-center justify-between px-4 py-4",
|
|
803
|
+
// Only apply margin, background and rounded corners if not in a group
|
|
804
|
+
!isInsideGroup && "mx-2 my-1.5 rounded-md bg-neutral-100 dark:bg-neutral-100 dark:bg-neutral-800 dark:dark:bg-neutral-800",
|
|
805
|
+
// For items in a group, don't add background but add more padding
|
|
806
|
+
isInsideGroup && "bg-transparent py-4",
|
|
807
|
+
inset && "pl-8",
|
|
808
|
+
className,
|
|
809
|
+
)}
|
|
810
|
+
onClick={combinedOnClick}
|
|
811
|
+
{...restProps}>
|
|
812
|
+
<div className='flex items-center gap-2'>{children}</div>
|
|
813
|
+
<ChevronRightIcon className='h-5 w-5' />
|
|
814
|
+
</div>
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
return (
|
|
819
|
+
<DropdownMenuSubTrigger
|
|
820
|
+
data-slot='drop-drawer-sub-trigger'
|
|
821
|
+
data-inset={inset}
|
|
822
|
+
className={className}
|
|
823
|
+
inset={inset}
|
|
824
|
+
{...props}>
|
|
825
|
+
{children}
|
|
826
|
+
</DropdownMenuSubTrigger>
|
|
827
|
+
);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
function DropDrawerSubContent({className, sideOffset = 4, children, ...props}: React.ComponentProps<typeof DropdownMenuSubContent>) {
|
|
831
|
+
const {isMobile} = useDropDrawerContext();
|
|
832
|
+
|
|
833
|
+
if (isMobile) {
|
|
834
|
+
// For mobile, we don't render the content directly
|
|
835
|
+
// It will be rendered by the DropDrawerContent component when active
|
|
836
|
+
return null;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
return (
|
|
840
|
+
<DropdownMenuSubContent
|
|
841
|
+
data-slot='drop-drawer-sub-content'
|
|
842
|
+
sideOffset={sideOffset}
|
|
843
|
+
className={cn(
|
|
844
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border border-neutral-200 p-1 shadow-lg dark:border-neutral-800",
|
|
845
|
+
className,
|
|
846
|
+
)}
|
|
847
|
+
{...props}>
|
|
848
|
+
{children}
|
|
849
|
+
</DropdownMenuSubContent>
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
export {
|
|
854
|
+
DropDrawer,
|
|
855
|
+
DropDrawerContent,
|
|
856
|
+
DropDrawerFooter,
|
|
857
|
+
DropDrawerGroup,
|
|
858
|
+
DropDrawerItem,
|
|
859
|
+
DropDrawerLabel,
|
|
860
|
+
DropDrawerSeparator,
|
|
861
|
+
DropDrawerSub,
|
|
862
|
+
DropDrawerSubContent,
|
|
863
|
+
DropDrawerSubTrigger,
|
|
864
|
+
DropDrawerTrigger,
|
|
865
|
+
};
|