@surreal-ui/react 0.8.1 → 0.9.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 (128) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +955 -7227
  3. package/dist/utils.d.ts +9 -0
  4. package/dist/utils.js +14 -0
  5. package/package.json +21 -4
  6. package/CHANGELOG.md +0 -149
  7. package/src/components/GlassmorphismAlert.tsx +0 -43
  8. package/src/components/GlassmorphismButton.tsx +0 -20
  9. package/src/components/GlassmorphismCard.tsx +0 -43
  10. package/src/components/GlassmorphismEmptyState.tsx +0 -20
  11. package/src/components/GlassmorphismInputGroup.tsx +0 -148
  12. package/src/components/GlassmorphismMenubar.tsx +0 -96
  13. package/src/components/GlassmorphismScrollArea.tsx +0 -67
  14. package/src/components/GlassmorphismTable.tsx +0 -61
  15. package/src/components/GlassmorphismTypography.tsx +0 -31
  16. package/src/components/MinimalistAccordion.tsx +0 -215
  17. package/src/components/MinimalistAlert.tsx +0 -43
  18. package/src/components/MinimalistAlertDialog.tsx +0 -318
  19. package/src/components/MinimalistAspectRatio.tsx +0 -30
  20. package/src/components/MinimalistAvatar.tsx +0 -149
  21. package/src/components/MinimalistBadge.tsx +0 -49
  22. package/src/components/MinimalistBreadcrumb.tsx +0 -109
  23. package/src/components/MinimalistButton.tsx +0 -86
  24. package/src/components/MinimalistButtonGroup.tsx +0 -86
  25. package/src/components/MinimalistCalendar.tsx +0 -355
  26. package/src/components/MinimalistCard.tsx +0 -89
  27. package/src/components/MinimalistCarousel.tsx +0 -266
  28. package/src/components/MinimalistChart.tsx +0 -296
  29. package/src/components/MinimalistCheckbox.tsx +0 -117
  30. package/src/components/MinimalistCodeBlock.tsx +0 -203
  31. package/src/components/MinimalistCollapsible.tsx +0 -134
  32. package/src/components/MinimalistCommand.tsx +0 -344
  33. package/src/components/MinimalistContextMenu.tsx +0 -408
  34. package/src/components/MinimalistDialog.tsx +0 -273
  35. package/src/components/MinimalistDrawer.tsx +0 -220
  36. package/src/components/MinimalistDropdownMenu.tsx +0 -431
  37. package/src/components/MinimalistEmpty.tsx +0 -105
  38. package/src/components/MinimalistEmptyState.tsx +0 -34
  39. package/src/components/MinimalistField.tsx +0 -275
  40. package/src/components/MinimalistForm.tsx +0 -205
  41. package/src/components/MinimalistHoverCard.tsx +0 -48
  42. package/src/components/MinimalistInput.tsx +0 -24
  43. package/src/components/MinimalistInputGroup.tsx +0 -180
  44. package/src/components/MinimalistInputOtp.tsx +0 -189
  45. package/src/components/MinimalistItem.tsx +0 -182
  46. package/src/components/MinimalistKbd.tsx +0 -46
  47. package/src/components/MinimalistLabel.tsx +0 -19
  48. package/src/components/MinimalistMenubar.tsx +0 -491
  49. package/src/components/MinimalistNativeSelect.tsx +0 -77
  50. package/src/components/MinimalistNavigationMenu.tsx +0 -198
  51. package/src/components/MinimalistPagination.tsx +0 -152
  52. package/src/components/MinimalistPopover.tsx +0 -229
  53. package/src/components/MinimalistProgress.tsx +0 -39
  54. package/src/components/MinimalistRadioGroup.tsx +0 -115
  55. package/src/components/MinimalistRangeCalendar.tsx +0 -396
  56. package/src/components/MinimalistResizable.tsx +0 -54
  57. package/src/components/MinimalistScrollArea.tsx +0 -41
  58. package/src/components/MinimalistSelect.tsx +0 -262
  59. package/src/components/MinimalistSeparator.tsx +0 -45
  60. package/src/components/MinimalistSheet.tsx +0 -247
  61. package/src/components/MinimalistSidebar.tsx +0 -638
  62. package/src/components/MinimalistSkeleton.tsx +0 -16
  63. package/src/components/MinimalistSlider.tsx +0 -213
  64. package/src/components/MinimalistSonner.tsx +0 -41
  65. package/src/components/MinimalistSpinner.tsx +0 -39
  66. package/src/components/MinimalistSwitch.tsx +0 -92
  67. package/src/components/MinimalistTable.tsx +0 -65
  68. package/src/components/MinimalistTabs.tsx +0 -171
  69. package/src/components/MinimalistTextarea.tsx +0 -24
  70. package/src/components/MinimalistToggle.tsx +0 -74
  71. package/src/components/MinimalistToggleGroup.tsx +0 -197
  72. package/src/components/MinimalistTooltip.tsx +0 -172
  73. package/src/components/MinimalistTypography.tsx +0 -33
  74. package/src/components/NeubrutalismCard.tsx +0 -84
  75. package/src/components/NeubrutalismItem.tsx +0 -48
  76. package/src/components/ShadcnAccordion.tsx +0 -215
  77. package/src/components/ShadcnAlertDialog.tsx +0 -318
  78. package/src/components/ShadcnAspectRatio.tsx +0 -30
  79. package/src/components/ShadcnAvatar.tsx +0 -149
  80. package/src/components/ShadcnBadge.tsx +0 -49
  81. package/src/components/ShadcnBreadcrumb.tsx +0 -109
  82. package/src/components/ShadcnButton.tsx +0 -86
  83. package/src/components/ShadcnButtonGroup.tsx +0 -86
  84. package/src/components/ShadcnCalendar.tsx +0 -355
  85. package/src/components/ShadcnCarousel.tsx +0 -266
  86. package/src/components/ShadcnChart.tsx +0 -296
  87. package/src/components/ShadcnCheckbox.tsx +0 -117
  88. package/src/components/ShadcnCodeBlock.tsx +0 -203
  89. package/src/components/ShadcnCollapsible.tsx +0 -134
  90. package/src/components/ShadcnCommand.tsx +0 -344
  91. package/src/components/ShadcnContextMenu.tsx +0 -408
  92. package/src/components/ShadcnDialog.tsx +0 -273
  93. package/src/components/ShadcnDrawer.tsx +0 -220
  94. package/src/components/ShadcnDropdownMenu.tsx +0 -431
  95. package/src/components/ShadcnEmpty.tsx +0 -105
  96. package/src/components/ShadcnField.tsx +0 -275
  97. package/src/components/ShadcnForm.tsx +0 -205
  98. package/src/components/ShadcnHoverCard.tsx +0 -48
  99. package/src/components/ShadcnInput.tsx +0 -24
  100. package/src/components/ShadcnInputGroup.tsx +0 -180
  101. package/src/components/ShadcnInputOtp.tsx +0 -189
  102. package/src/components/ShadcnItem.tsx +0 -182
  103. package/src/components/ShadcnKbd.tsx +0 -46
  104. package/src/components/ShadcnLabel.tsx +0 -19
  105. package/src/components/ShadcnMenubar.tsx +0 -491
  106. package/src/components/ShadcnNativeSelect.tsx +0 -77
  107. package/src/components/ShadcnNavigationMenu.tsx +0 -198
  108. package/src/components/ShadcnPagination.tsx +0 -152
  109. package/src/components/ShadcnPopover.tsx +0 -229
  110. package/src/components/ShadcnProgress.tsx +0 -39
  111. package/src/components/ShadcnRadioGroup.tsx +0 -115
  112. package/src/components/ShadcnRangeCalendar.tsx +0 -396
  113. package/src/components/ShadcnSelect.tsx +0 -262
  114. package/src/components/ShadcnSeparator.tsx +0 -45
  115. package/src/components/ShadcnSheet.tsx +0 -247
  116. package/src/components/ShadcnSidebar.tsx +0 -638
  117. package/src/components/ShadcnSkeleton.tsx +0 -16
  118. package/src/components/ShadcnSlider.tsx +0 -213
  119. package/src/components/ShadcnSonner.tsx +0 -41
  120. package/src/components/ShadcnSpinner.tsx +0 -39
  121. package/src/components/ShadcnSwitch.tsx +0 -92
  122. package/src/components/ShadcnTabs.tsx +0 -171
  123. package/src/components/ShadcnTextarea.tsx +0 -24
  124. package/src/components/ShadcnToggle.tsx +0 -74
  125. package/src/components/ShadcnToggleGroup.tsx +0 -197
  126. package/src/components/ShadcnTooltip.tsx +0 -172
  127. package/src/index.ts +0 -124
  128. package/tsconfig.json +0 -10
@@ -1,198 +0,0 @@
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 ShadcnNavigationMenu;
@@ -1,152 +0,0 @@
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 ShadcnPagination;
@@ -1,229 +0,0 @@
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<
178
- HTMLParagraphElement,
179
- PopoverDescriptionProps
180
- >(({ className, ...props }, ref) => (
181
- <p
182
- ref={ref}
183
- data-slot="popover-description"
184
- className={cn('text-muted-foreground text-xs', className)}
185
- {...props}
186
- />
187
- ));
188
- PopoverDescription.displayName = 'PopoverDescription';
189
-
190
- export interface ShadcnPopoverCloseProps extends React.ComponentProps<'button'> {}
191
-
192
- export const ShadcnPopoverClose = React.forwardRef<HTMLButtonElement, PopoverCloseProps>(
193
- ({ className, onClick, ...props }, ref) => {
194
- const { setOpen } = usePopover();
195
- return (
196
- <button
197
- ref={ref}
198
- type="button"
199
- data-slot="popover-close"
200
- className={cn('', className)}
201
- onClick={(e) => {
202
- onClick?.(e);
203
- setOpen(false);
204
- }}
205
- {...props}
206
- />
207
- );
208
- }
209
- );
210
- PopoverClose.displayName = 'PopoverClose';
211
-
212
- export interface ShadcnPopoverPortalProps {
213
- children?: React.ReactNode;
214
- }
215
-
216
- export function ShadcnPopoverPortal({ children }: PopoverPortalProps) {
217
- return <>{children}</>;
218
- }
219
-
220
- export const Root = Popover;
221
- export const Trigger = PopoverTrigger;
222
- export const Content = PopoverContent;
223
- export const Header = PopoverHeader;
224
- export const Title = PopoverTitle;
225
- export const Description = PopoverDescription;
226
- export const Close = PopoverClose;
227
- export const Portal = PopoverPortal;
228
-
229
- export default ShadcnPopover;
@@ -1,39 +0,0 @@
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 ShadcnProgress;