@surreal-ui/react 0.5.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.
Files changed (125) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/dist/index.js +11307 -0
  3. package/package.json +38 -0
  4. package/src/components/GlassmorphismAlert.tsx +40 -0
  5. package/src/components/GlassmorphismButton.tsx +20 -0
  6. package/src/components/GlassmorphismCard.tsx +43 -0
  7. package/src/components/GlassmorphismEmptyState.tsx +20 -0
  8. package/src/components/GlassmorphismInputGroup.tsx +148 -0
  9. package/src/components/GlassmorphismMenubar.tsx +96 -0
  10. package/src/components/GlassmorphismScrollArea.tsx +67 -0
  11. package/src/components/GlassmorphismTable.tsx +61 -0
  12. package/src/components/GlassmorphismTypography.tsx +31 -0
  13. package/src/components/MinimalistAccordion.tsx +215 -0
  14. package/src/components/MinimalistAlert.tsx +40 -0
  15. package/src/components/MinimalistAlertDialog.tsx +317 -0
  16. package/src/components/MinimalistAspectRatio.tsx +30 -0
  17. package/src/components/MinimalistAvatar.tsx +149 -0
  18. package/src/components/MinimalistBadge.tsx +49 -0
  19. package/src/components/MinimalistBreadcrumb.tsx +105 -0
  20. package/src/components/MinimalistButton.tsx +86 -0
  21. package/src/components/MinimalistButtonGroup.tsx +85 -0
  22. package/src/components/MinimalistCalendar.tsx +352 -0
  23. package/src/components/MinimalistCard.tsx +89 -0
  24. package/src/components/MinimalistCarousel.tsx +266 -0
  25. package/src/components/MinimalistChart.tsx +296 -0
  26. package/src/components/MinimalistCheckbox.tsx +117 -0
  27. package/src/components/MinimalistCodeBlock.tsx +203 -0
  28. package/src/components/MinimalistCollapsible.tsx +134 -0
  29. package/src/components/MinimalistCommand.tsx +344 -0
  30. package/src/components/MinimalistContextMenu.tsx +400 -0
  31. package/src/components/MinimalistDialog.tsx +269 -0
  32. package/src/components/MinimalistDrawer.tsx +216 -0
  33. package/src/components/MinimalistDropdownMenu.tsx +431 -0
  34. package/src/components/MinimalistEmpty.tsx +105 -0
  35. package/src/components/MinimalistEmptyState.tsx +34 -0
  36. package/src/components/MinimalistField.tsx +275 -0
  37. package/src/components/MinimalistForm.tsx +203 -0
  38. package/src/components/MinimalistHoverCard.tsx +48 -0
  39. package/src/components/MinimalistInput.tsx +24 -0
  40. package/src/components/MinimalistInputGroup.tsx +180 -0
  41. package/src/components/MinimalistInputOtp.tsx +189 -0
  42. package/src/components/MinimalistItem.tsx +181 -0
  43. package/src/components/MinimalistKbd.tsx +46 -0
  44. package/src/components/MinimalistLabel.tsx +19 -0
  45. package/src/components/MinimalistMenubar.tsx +491 -0
  46. package/src/components/MinimalistNativeSelect.tsx +77 -0
  47. package/src/components/MinimalistNavigationMenu.tsx +198 -0
  48. package/src/components/MinimalistPagination.tsx +152 -0
  49. package/src/components/MinimalistPopover.tsx +228 -0
  50. package/src/components/MinimalistProgress.tsx +39 -0
  51. package/src/components/MinimalistRadioGroup.tsx +115 -0
  52. package/src/components/MinimalistRangeCalendar.tsx +396 -0
  53. package/src/components/MinimalistResizable.tsx +54 -0
  54. package/src/components/MinimalistScrollArea.tsx +41 -0
  55. package/src/components/MinimalistSelect.tsx +265 -0
  56. package/src/components/MinimalistSeparator.tsx +45 -0
  57. package/src/components/MinimalistSheet.tsx +247 -0
  58. package/src/components/MinimalistSidebar.tsx +637 -0
  59. package/src/components/MinimalistSkeleton.tsx +16 -0
  60. package/src/components/MinimalistSlider.tsx +213 -0
  61. package/src/components/MinimalistSonner.tsx +41 -0
  62. package/src/components/MinimalistSpinner.tsx +39 -0
  63. package/src/components/MinimalistSwitch.tsx +92 -0
  64. package/src/components/MinimalistTable.tsx +65 -0
  65. package/src/components/MinimalistTabs.tsx +166 -0
  66. package/src/components/MinimalistTextarea.tsx +24 -0
  67. package/src/components/MinimalistToggle.tsx +74 -0
  68. package/src/components/MinimalistToggleGroup.tsx +196 -0
  69. package/src/components/MinimalistTooltip.tsx +172 -0
  70. package/src/components/MinimalistTypography.tsx +33 -0
  71. package/src/components/NeubrutalismCard.tsx +3 -0
  72. package/src/components/NeubrutalismItem.tsx +48 -0
  73. package/src/components/ShadcnAccordion.tsx +215 -0
  74. package/src/components/ShadcnAlertDialog.tsx +317 -0
  75. package/src/components/ShadcnAspectRatio.tsx +30 -0
  76. package/src/components/ShadcnAvatar.tsx +149 -0
  77. package/src/components/ShadcnBadge.tsx +49 -0
  78. package/src/components/ShadcnBreadcrumb.tsx +105 -0
  79. package/src/components/ShadcnButton.tsx +86 -0
  80. package/src/components/ShadcnButtonGroup.tsx +85 -0
  81. package/src/components/ShadcnCalendar.tsx +352 -0
  82. package/src/components/ShadcnCarousel.tsx +266 -0
  83. package/src/components/ShadcnChart.tsx +296 -0
  84. package/src/components/ShadcnCheckbox.tsx +117 -0
  85. package/src/components/ShadcnCodeBlock.tsx +203 -0
  86. package/src/components/ShadcnCollapsible.tsx +134 -0
  87. package/src/components/ShadcnCommand.tsx +344 -0
  88. package/src/components/ShadcnContextMenu.tsx +400 -0
  89. package/src/components/ShadcnDialog.tsx +269 -0
  90. package/src/components/ShadcnDrawer.tsx +216 -0
  91. package/src/components/ShadcnDropdownMenu.tsx +431 -0
  92. package/src/components/ShadcnEmpty.tsx +105 -0
  93. package/src/components/ShadcnField.tsx +275 -0
  94. package/src/components/ShadcnForm.tsx +203 -0
  95. package/src/components/ShadcnHoverCard.tsx +48 -0
  96. package/src/components/ShadcnInput.tsx +24 -0
  97. package/src/components/ShadcnInputGroup.tsx +180 -0
  98. package/src/components/ShadcnInputOtp.tsx +189 -0
  99. package/src/components/ShadcnItem.tsx +181 -0
  100. package/src/components/ShadcnKbd.tsx +46 -0
  101. package/src/components/ShadcnLabel.tsx +19 -0
  102. package/src/components/ShadcnMenubar.tsx +491 -0
  103. package/src/components/ShadcnNativeSelect.tsx +77 -0
  104. package/src/components/ShadcnNavigationMenu.tsx +198 -0
  105. package/src/components/ShadcnPagination.tsx +152 -0
  106. package/src/components/ShadcnPopover.tsx +228 -0
  107. package/src/components/ShadcnProgress.tsx +39 -0
  108. package/src/components/ShadcnRadioGroup.tsx +115 -0
  109. package/src/components/ShadcnRangeCalendar.tsx +396 -0
  110. package/src/components/ShadcnSelect.tsx +265 -0
  111. package/src/components/ShadcnSeparator.tsx +45 -0
  112. package/src/components/ShadcnSheet.tsx +247 -0
  113. package/src/components/ShadcnSidebar.tsx +637 -0
  114. package/src/components/ShadcnSkeleton.tsx +16 -0
  115. package/src/components/ShadcnSlider.tsx +213 -0
  116. package/src/components/ShadcnSonner.tsx +41 -0
  117. package/src/components/ShadcnSpinner.tsx +39 -0
  118. package/src/components/ShadcnSwitch.tsx +92 -0
  119. package/src/components/ShadcnTabs.tsx +166 -0
  120. package/src/components/ShadcnTextarea.tsx +24 -0
  121. package/src/components/ShadcnToggle.tsx +74 -0
  122. package/src/components/ShadcnToggleGroup.tsx +196 -0
  123. package/src/components/ShadcnTooltip.tsx +172 -0
  124. package/src/index.ts +124 -0
  125. package/tsconfig.json +10 -0
@@ -0,0 +1,198 @@
1
+ import * as React from 'react';
2
+ import { ChevronDown } from 'lucide-react';
3
+ import { cn, cva } from '@surreal-ui/core';
4
+
5
+ export const navigationMenuTriggerStyle = cva(
6
+ 'rounded-lg px-2.5 py-1.5 text-sm font-medium transition-all hover:bg-muted focus:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 disabled:opacity-50 data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted group/navigation-menu-trigger inline-flex h-9 w-max items-center justify-center outline-none disabled:pointer-events-none',
7
+ );
8
+
9
+ interface NavigationMenuContextValue {
10
+ openItem: string | null;
11
+ setOpenItem: (id: string | null) => void;
12
+ }
13
+
14
+ const NavigationMenuContext = React.createContext<NavigationMenuContextValue>({
15
+ openItem: null,
16
+ setOpenItem: () => {},
17
+ });
18
+
19
+ export interface ShadcnNavigationMenuProps extends React.ComponentProps<'nav'> {
20
+ viewport?: boolean;
21
+ }
22
+
23
+ export function ShadcnNavigationMenu({
24
+ className,
25
+ children,
26
+ viewport = true,
27
+ ...props
28
+ }: NavigationMenuProps) {
29
+ const [openItem, setOpenItem] = React.useState<string | null>(null);
30
+
31
+ return (
32
+ <NavigationMenuContext.Provider value={{ openItem, setOpenItem }}>
33
+ <nav
34
+ data-slot="navigation-menu"
35
+ data-viewport={viewport}
36
+ className={cn(
37
+ 'max-w-max group/navigation-menu relative flex flex-1 items-center justify-center',
38
+ className,
39
+ )}
40
+ {...props}
41
+ >
42
+ {children}
43
+ </nav>
44
+ </NavigationMenuContext.Provider>
45
+ );
46
+ }
47
+
48
+ export interface ShadcnNavigationMenuListProps extends React.ComponentProps<'ul'> {}
49
+
50
+ export function ShadcnNavigationMenuList({ className, ...props }: NavigationMenuListProps) {
51
+ return (
52
+ <ul
53
+ data-slot="navigation-menu-list"
54
+ className={cn('gap-0 group flex flex-1 list-none items-center justify-center', className)}
55
+ {...props}
56
+ />
57
+ );
58
+ }
59
+
60
+ const ItemContext = React.createContext<{ id: string; isOpen: boolean }>({
61
+ id: '',
62
+ isOpen: false,
63
+ });
64
+
65
+ export interface ShadcnNavigationMenuItemProps extends React.ComponentProps<'li'> {
66
+ value?: string;
67
+ }
68
+
69
+ export function ShadcnNavigationMenuItem({
70
+ className,
71
+ value,
72
+ children,
73
+ ...props
74
+ }: NavigationMenuItemProps) {
75
+ const generatedId = React.useId();
76
+ const id = value || generatedId;
77
+ const { openItem } = React.useContext(NavigationMenuContext);
78
+ const isOpen = openItem === id;
79
+
80
+ return (
81
+ <ItemContext.Provider value={{ id, isOpen }}>
82
+ <li
83
+ data-slot="navigation-menu-item"
84
+ className={cn('cn-navigation-menu-item relative', className)}
85
+ {...props}
86
+ >
87
+ {children}
88
+ </li>
89
+ </ItemContext.Provider>
90
+ );
91
+ }
92
+
93
+ export interface ShadcnNavigationMenuTriggerProps extends React.ComponentProps<'button'> {}
94
+
95
+ export function ShadcnNavigationMenuTrigger({
96
+ className,
97
+ children,
98
+ onClick,
99
+ ...props
100
+ }: NavigationMenuTriggerProps) {
101
+ const { id, isOpen } = React.useContext(ItemContext);
102
+ const { setOpenItem } = React.useContext(NavigationMenuContext);
103
+
104
+ return (
105
+ <button
106
+ type="button"
107
+ data-slot="navigation-menu-trigger"
108
+ data-state={isOpen ? 'open' : 'closed'}
109
+ aria-expanded={isOpen}
110
+ onClick={(e) => {
111
+ setOpenItem(isOpen ? null : id);
112
+ onClick?.(e);
113
+ }}
114
+ className={cn(navigationMenuTriggerStyle(), 'group', className)}
115
+ {...props}
116
+ >
117
+ {children}
118
+ <ChevronDown
119
+ className="relative top-px ml-1 size-3 transition duration-300 group-data-[state=open]:rotate-180"
120
+ aria-hidden="true"
121
+ />
122
+ </button>
123
+ );
124
+ }
125
+
126
+ export interface ShadcnNavigationMenuContentProps extends React.ComponentProps<'div'> {}
127
+
128
+ export function ShadcnNavigationMenuContent({ className, ...props }: NavigationMenuContentProps) {
129
+ const { isOpen } = React.useContext(ItemContext);
130
+
131
+ if (!isOpen) return null;
132
+
133
+ return (
134
+ <div
135
+ data-slot="navigation-menu-content"
136
+ data-state={isOpen ? 'open' : 'closed'}
137
+ className={cn(
138
+ 'p-1 ease-[cubic-bezier(0.22,1,0.36,1)] rounded-lg bg-popover text-popover-foreground shadow ring-1 ring-foreground/10 duration-300 top-full mt-1.5 overflow-hidden md:absolute md:w-auto z-50 animate-in fade-in-0 zoom-in-95',
139
+ className,
140
+ )}
141
+ {...props}
142
+ />
143
+ );
144
+ }
145
+
146
+ export interface ShadcnNavigationMenuLinkProps extends React.ComponentProps<'a'> {
147
+ active?: boolean;
148
+ }
149
+
150
+ export function ShadcnNavigationMenuLink({ className, active, ...props }: NavigationMenuLinkProps) {
151
+ return (
152
+ <a
153
+ data-slot="navigation-menu-link"
154
+ data-active={active ? '' : undefined}
155
+ className={cn(
156
+ "flex items-center gap-2 rounded-lg p-2 text-sm transition-all outline-none hover:bg-muted focus:bg-muted focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:outline-1 in-data-[slot=navigation-menu-content]:rounded-md data-[active]:bg-muted/50 data-[active]:hover:bg-muted data-[active]:focus:bg-muted [&_svg:not([class*='size-'])]:size-4",
157
+ className,
158
+ )}
159
+ {...props}
160
+ />
161
+ );
162
+ }
163
+
164
+ export interface NavigationMenuIndicatorProps extends React.ComponentProps<'div'> {}
165
+
166
+ export function NavigationMenuIndicator({ className, ...props }: NavigationMenuIndicatorProps) {
167
+ return (
168
+ <div
169
+ data-slot="navigation-menu-indicator"
170
+ className={cn(
171
+ 'top-full z-[1] flex h-1.5 items-end justify-center overflow-hidden',
172
+ className,
173
+ )}
174
+ {...props}
175
+ >
176
+ <div className="rounded-tl-sm bg-border shadow-md relative top-[60%] h-2 w-2 rotate-45" />
177
+ </div>
178
+ );
179
+ }
180
+
181
+ export interface NavigationMenuViewportProps extends React.ComponentProps<'div'> {}
182
+
183
+ export function NavigationMenuViewport({ className, ...props }: NavigationMenuViewportProps) {
184
+ return (
185
+ <div className="absolute start-0 top-full isolate z-50 flex justify-center">
186
+ <div
187
+ data-slot="navigation-menu-viewport"
188
+ className={cn(
189
+ 'rounded-lg bg-popover text-popover-foreground shadow ring-1 ring-foreground/10 duration-100 origin-top-center relative mt-1.5 h-auto w-full overflow-hidden md:w-auto',
190
+ className,
191
+ )}
192
+ {...props}
193
+ />
194
+ </div>
195
+ );
196
+ }
197
+
198
+ export default MinimalistNavigationMenu;
@@ -0,0 +1,152 @@
1
+ import * as React from 'react';
2
+
3
+ import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react';
4
+ import { cn, cva, type VariantProps } from '@surreal-ui/core';
5
+
6
+ export const buttonVariants = cva(
7
+ 'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50',
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: 'bg-primary text-primary-foreground shadow hover:bg-primary/90',
12
+ destructive: 'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
13
+ outline:
14
+ 'border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground',
15
+ secondary: 'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
16
+ ghost: 'hover:bg-accent hover:text-accent-foreground',
17
+ link: 'text-primary underline-offset-4 hover:underline',
18
+ },
19
+ size: {
20
+ default: 'h-9 px-4 py-2',
21
+ sm: 'h-8 rounded-md px-3 text-xs',
22
+ lg: 'h-10 rounded-md px-8',
23
+ icon: 'h-9 w-9',
24
+ },
25
+ },
26
+ defaultVariants: {
27
+ variant: 'default',
28
+ size: 'default',
29
+ },
30
+ },
31
+ );
32
+
33
+ export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
34
+
35
+ export function ShadcnPagination({ className, ...props }: React.ComponentProps<'nav'>) {
36
+ return (
37
+ <nav
38
+ role="navigation"
39
+ aria-label="pagination"
40
+ data-slot="pagination"
41
+ className={cn('cn-pagination mx-auto flex w-full justify-center', className)}
42
+ {...props}
43
+ />
44
+ );
45
+ }
46
+
47
+ export function ShadcnPaginationContent({ className, ...props }: React.ComponentProps<'ul'>) {
48
+ return (
49
+ <ul
50
+ data-slot="pagination-content"
51
+ className={cn('gap-0.5 flex items-center', className)}
52
+ {...props}
53
+ />
54
+ );
55
+ }
56
+
57
+ export function ShadcnPaginationItem({ className, ...props }: React.ComponentProps<'li'>) {
58
+ return <li data-slot="pagination-item" className={className} {...props} />;
59
+ }
60
+
61
+ export interface ShadcnPaginationLinkProps extends React.ComponentProps<'a'> {
62
+ isActive?: boolean;
63
+ size?: ButtonSize;
64
+ }
65
+
66
+ export function ShadcnPaginationLink({
67
+ className,
68
+ isActive = false,
69
+ size = 'icon',
70
+ ...props
71
+ }: PaginationLinkProps) {
72
+ return (
73
+ <a
74
+ aria-current={isActive ? 'page' : undefined}
75
+ data-slot="pagination-link"
76
+ data-active={isActive}
77
+ data-size={size}
78
+ className={cn(
79
+ buttonVariants({ size, variant: isActive ? 'outline' : 'ghost' }),
80
+ 'cn-pagination-link',
81
+ className,
82
+ )}
83
+ {...props}
84
+ />
85
+ );
86
+ }
87
+
88
+ export function ShadcnPaginationPrevious({
89
+ className,
90
+ children,
91
+ ...props
92
+ }: React.ComponentProps<typeof PaginationLink>) {
93
+ return (
94
+ <PaginationLink
95
+ aria-label="Go to previous page"
96
+ size="default"
97
+ className={cn('pl-1.5!', className)}
98
+ {...props}
99
+ >
100
+ {children ?? (
101
+ <>
102
+ <ChevronLeft className="size-4" />
103
+ <span className="cn-pagination-previous-text hidden sm:block">Previous</span>
104
+ </>
105
+ )}
106
+ </PaginationLink>
107
+ );
108
+ }
109
+
110
+ export function ShadcnPaginationNext({
111
+ className,
112
+ children,
113
+ ...props
114
+ }: React.ComponentProps<typeof PaginationLink>) {
115
+ return (
116
+ <PaginationLink
117
+ aria-label="Go to next page"
118
+ size="default"
119
+ className={cn('pr-1.5!', className)}
120
+ {...props}
121
+ >
122
+ {children ?? (
123
+ <>
124
+ <span className="cn-pagination-next-text hidden sm:block">Next</span>
125
+ <ChevronRight className="size-4" />
126
+ </>
127
+ )}
128
+ </PaginationLink>
129
+ );
130
+ }
131
+
132
+ export function PaginationEllipsis({ className, ...props }: React.ComponentProps<'span'>) {
133
+ return (
134
+ <span
135
+ aria-hidden="true"
136
+ data-slot="pagination-ellipsis"
137
+ className={cn(
138
+ "size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4 flex items-center justify-center",
139
+ className,
140
+ )}
141
+ {...props}
142
+ >
143
+ <MoreHorizontal className="size-4" />
144
+ <span className="sr-only">More pages</span>
145
+ </span>
146
+ );
147
+ }
148
+
149
+ export const PaginationPrevButton = PaginationPrevious;
150
+ export const PaginationNextButton = PaginationNext;
151
+
152
+ export default MinimalistPagination;
@@ -0,0 +1,228 @@
1
+ import * as React from 'react';
2
+ import { cn } from '@surreal-ui/core';
3
+
4
+ interface PopoverContextValue {
5
+ open: boolean;
6
+ setOpen: React.Dispatch<React.SetStateAction<boolean>>;
7
+ triggerRef: React.RefObject<HTMLButtonElement | null>;
8
+ }
9
+
10
+ const PopoverContext = React.createContext<PopoverContextValue | null>(null);
11
+
12
+ function usePopover() {
13
+ const context = React.useContext(PopoverContext);
14
+ if (!context) {
15
+ throw new Error('Popover components must be rendered inside a Popover root');
16
+ }
17
+ return context;
18
+ }
19
+
20
+ export interface ShadcnPopoverProps {
21
+ open?: boolean;
22
+ defaultOpen?: boolean;
23
+ onOpenChange?: (open: boolean) => void;
24
+ children?: React.ReactNode;
25
+ }
26
+
27
+ export function ShadcnPopover({
28
+ open: controlledOpen,
29
+ defaultOpen = false,
30
+ onOpenChange,
31
+ children,
32
+ }: PopoverProps) {
33
+ const [uncontrolledOpen, setUncontrolledOpen] = React.useState(defaultOpen);
34
+ const isControlled = controlledOpen !== undefined;
35
+ const open = isControlled ? controlledOpen : uncontrolledOpen;
36
+ const triggerRef = React.useRef<HTMLButtonElement | null>(null);
37
+
38
+ const setOpen = React.useCallback(
39
+ (updater: React.SetStateAction<boolean>) => {
40
+ const nextValue = typeof updater === 'function' ? updater(open) : updater;
41
+ if (!isControlled) {
42
+ setUncontrolledOpen(nextValue);
43
+ }
44
+ onOpenChange?.(nextValue);
45
+ },
46
+ [isControlled, open, onOpenChange],
47
+ );
48
+
49
+ return (
50
+ <PopoverContext.Provider value={{ open, setOpen, triggerRef }}>
51
+ <div data-slot="popover-root" className="relative inline-block">
52
+ {children}
53
+ </div>
54
+ </PopoverContext.Provider>
55
+ );
56
+ }
57
+
58
+ export interface ShadcnPopoverTriggerProps extends React.ComponentProps<'button'> {}
59
+
60
+ export const ShadcnPopoverTrigger = React.forwardRef<HTMLButtonElement, PopoverTriggerProps>(
61
+ ({ className, onClick, ...props }, ref) => {
62
+ const { open, setOpen, triggerRef } = usePopover();
63
+
64
+ const combinedRef = React.useCallback(
65
+ (node: HTMLButtonElement | null) => {
66
+ triggerRef.current = node;
67
+ if (typeof ref === 'function') ref(node);
68
+ else if (ref) (ref as React.MutableRefObject<HTMLButtonElement | null>).current = node;
69
+ },
70
+ [ref, triggerRef],
71
+ );
72
+
73
+ return (
74
+ <button
75
+ ref={combinedRef}
76
+ type="button"
77
+ data-slot="popover-trigger"
78
+ aria-haspopup="dialog"
79
+ aria-expanded={open}
80
+ className={cn('', className)}
81
+ onClick={(e) => {
82
+ onClick?.(e);
83
+ setOpen((prev) => !prev);
84
+ }}
85
+ {...props}
86
+ />
87
+ );
88
+ },
89
+ );
90
+ PopoverTrigger.displayName = 'PopoverTrigger';
91
+
92
+ export interface ShadcnPopoverContentProps extends React.ComponentProps<'div'> {
93
+ sideOffset?: number;
94
+ align?: 'start' | 'center' | 'end';
95
+ side?: 'top' | 'right' | 'bottom' | 'left';
96
+ }
97
+
98
+ export const ShadcnPopoverContent = React.forwardRef<HTMLDivElement, PopoverContentProps>(
99
+ ({ className, side = 'bottom', align = 'center', sideOffset = 4, ...props }, ref) => {
100
+ const { open, setOpen } = usePopover();
101
+ const contentRef = React.useRef<HTMLDivElement | null>(null);
102
+
103
+ React.useEffect(() => {
104
+ if (!open) return;
105
+ const handlePointerDownOutside = (event: MouseEvent) => {
106
+ if (contentRef.current && !contentRef.current.contains(event.target as Node)) {
107
+ setOpen(false);
108
+ }
109
+ };
110
+ const handleKeyDown = (event: KeyboardEvent) => {
111
+ if (event.key === 'Escape') {
112
+ setOpen(false);
113
+ }
114
+ };
115
+ document.addEventListener('mousedown', handlePointerDownOutside);
116
+ document.addEventListener('keydown', handleKeyDown);
117
+ return () => {
118
+ document.removeEventListener('mousedown', handlePointerDownOutside);
119
+ document.removeEventListener('keydown', handleKeyDown);
120
+ };
121
+ }, [open, setOpen]);
122
+
123
+ if (!open) return null;
124
+
125
+ return (
126
+ <div
127
+ ref={(node) => {
128
+ contentRef.current = node;
129
+ if (typeof ref === 'function') ref(node);
130
+ else if (ref) (ref as React.MutableRefObject<HTMLDivElement | null>).current = node;
131
+ }}
132
+ data-slot="popover-content"
133
+ data-side={side}
134
+ data-align={align}
135
+ data-open=""
136
+ className={cn(
137
+ 'z-50 w-72 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 flex flex-col gap-2.5 outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 absolute mt-1',
138
+ className,
139
+ )}
140
+ {...props}
141
+ />
142
+ );
143
+ },
144
+ );
145
+ PopoverContent.displayName = 'PopoverContent';
146
+
147
+ export interface ShadcnPopoverHeaderProps extends React.ComponentProps<'div'> {}
148
+
149
+ export const ShadcnPopoverHeader = React.forwardRef<HTMLDivElement, PopoverHeaderProps>(
150
+ ({ className, ...props }, ref) => (
151
+ <div
152
+ ref={ref}
153
+ data-slot="popover-header"
154
+ className={cn('flex flex-col gap-0.5 text-sm', className)}
155
+ {...props}
156
+ />
157
+ ),
158
+ );
159
+ PopoverHeader.displayName = 'PopoverHeader';
160
+
161
+ export interface ShadcnPopoverTitleProps extends React.ComponentProps<'h4'> {}
162
+
163
+ export const ShadcnPopoverTitle = React.forwardRef<HTMLHeadingElement, PopoverTitleProps>(
164
+ ({ className, ...props }, ref) => (
165
+ <h4
166
+ ref={ref}
167
+ data-slot="popover-title"
168
+ className={cn('font-medium leading-none tracking-tight', className)}
169
+ {...props}
170
+ />
171
+ ),
172
+ );
173
+ PopoverTitle.displayName = 'PopoverTitle';
174
+
175
+ export interface ShadcnPopoverDescriptionProps extends React.ComponentProps<'p'> {}
176
+
177
+ export const ShadcnPopoverDescription = React.forwardRef<HTMLParagraphElement, PopoverDescriptionProps>(
178
+ ({ className, ...props }, ref) => (
179
+ <p
180
+ ref={ref}
181
+ data-slot="popover-description"
182
+ className={cn('text-muted-foreground text-xs', className)}
183
+ {...props}
184
+ />
185
+ ),
186
+ );
187
+ PopoverDescription.displayName = 'PopoverDescription';
188
+
189
+ export interface ShadcnPopoverCloseProps extends React.ComponentProps<'button'> {}
190
+
191
+ export const ShadcnPopoverClose = React.forwardRef<HTMLButtonElement, PopoverCloseProps>(
192
+ ({ className, onClick, ...props }, ref) => {
193
+ const { setOpen } = usePopover();
194
+ return (
195
+ <button
196
+ ref={ref}
197
+ type="button"
198
+ data-slot="popover-close"
199
+ className={cn('', className)}
200
+ onClick={(e) => {
201
+ onClick?.(e);
202
+ setOpen(false);
203
+ }}
204
+ {...props}
205
+ />
206
+ );
207
+ },
208
+ );
209
+ PopoverClose.displayName = 'PopoverClose';
210
+
211
+ export interface ShadcnPopoverPortalProps {
212
+ children?: React.ReactNode;
213
+ }
214
+
215
+ export function ShadcnPopoverPortal({ children }: PopoverPortalProps) {
216
+ return <>{children}</>;
217
+ }
218
+
219
+ export const Root = Popover;
220
+ export const Trigger = PopoverTrigger;
221
+ export const Content = PopoverContent;
222
+ export const Header = PopoverHeader;
223
+ export const Title = PopoverTitle;
224
+ export const Description = PopoverDescription;
225
+ export const Close = PopoverClose;
226
+ export const Portal = PopoverPortal;
227
+
228
+ export default MinimalistPopover;
@@ -0,0 +1,39 @@
1
+ import * as React from 'react';
2
+ import { cn } from '@surreal-ui/core';
3
+
4
+ export interface ShadcnProgressProps extends React.ComponentProps<'div'> {
5
+ value?: number | null;
6
+ max?: number;
7
+ }
8
+
9
+ export const ShadcnProgress = React.forwardRef<HTMLDivElement, ProgressProps>(
10
+ ({ className, value = 0, max = 100, ...props }, ref) => {
11
+ const percentage = 100 - (100 * (value ?? 0)) / (max || 1);
12
+
13
+ return (
14
+ <div
15
+ ref={ref}
16
+ role="progressbar"
17
+ aria-valuemin={0}
18
+ aria-valuemax={max}
19
+ aria-valuenow={value ?? undefined}
20
+ data-slot="progress"
21
+ className={cn(
22
+ 'h-1 rounded-full bg-muted relative flex w-full items-center overflow-x-hidden',
23
+ className,
24
+ )}
25
+ {...props}
26
+ >
27
+ <div
28
+ data-slot="progress-indicator"
29
+ className="bg-primary size-full flex-1 transition-all duration-300"
30
+ style={{ transform: `translateX(-${percentage}%)` }}
31
+ />
32
+ </div>
33
+ );
34
+ },
35
+ );
36
+
37
+ Progress.displayName = 'Progress';
38
+
39
+ export default MinimalistProgress;