@gv-tech/ui-web 2.6.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/package.json +88 -0
- package/src/accordion.tsx +58 -0
- package/src/alert-dialog.tsx +121 -0
- package/src/alert.tsx +49 -0
- package/src/aspect-ratio.tsx +7 -0
- package/src/avatar.tsx +40 -0
- package/src/badge.tsx +34 -0
- package/src/breadcrumb.tsx +105 -0
- package/src/button.tsx +47 -0
- package/src/calendar.tsx +163 -0
- package/src/card.tsx +46 -0
- package/src/carousel.tsx +234 -0
- package/src/chart.tsx +296 -0
- package/src/checkbox.tsx +31 -0
- package/src/collapsible.tsx +15 -0
- package/src/command.tsx +154 -0
- package/src/context-menu.tsx +208 -0
- package/src/dialog.tsx +95 -0
- package/src/drawer.tsx +110 -0
- package/src/dropdown-menu.tsx +212 -0
- package/src/form.tsx +160 -0
- package/src/hooks/use-theme.ts +15 -0
- package/src/hooks/use-toast.ts +189 -0
- package/src/hover-card.tsx +35 -0
- package/src/index.ts +474 -0
- package/src/input.tsx +23 -0
- package/src/label.tsx +21 -0
- package/src/lib/utils.ts +6 -0
- package/src/menubar.tsx +244 -0
- package/src/navigation-menu.tsx +143 -0
- package/src/pagination.tsx +107 -0
- package/src/popover.tsx +45 -0
- package/src/progress.tsx +28 -0
- package/src/radio-group.tsx +41 -0
- package/src/resizable.tsx +59 -0
- package/src/scroll-area.tsx +42 -0
- package/src/search.tsx +87 -0
- package/src/select.tsx +169 -0
- package/src/separator.tsx +24 -0
- package/src/setupTests.ts +114 -0
- package/src/sheet.tsx +136 -0
- package/src/skeleton.tsx +10 -0
- package/src/slider.tsx +27 -0
- package/src/sonner.tsx +32 -0
- package/src/switch.tsx +31 -0
- package/src/table.tsx +104 -0
- package/src/tabs.tsx +62 -0
- package/src/text.tsx +55 -0
- package/src/textarea.tsx +25 -0
- package/src/theme-provider.tsx +15 -0
- package/src/theme-toggle.tsx +92 -0
- package/src/toast.tsx +111 -0
- package/src/toaster.tsx +27 -0
- package/src/toggle-group.tsx +55 -0
- package/src/toggle.tsx +24 -0
- package/src/tooltip.tsx +51 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { ScrollAreaBaseProps, ScrollBarBaseProps } from '@gv-tech/ui-core';
|
|
7
|
+
import { cn } from './lib/utils';
|
|
8
|
+
|
|
9
|
+
const ScrollArea = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & ScrollAreaBaseProps
|
|
12
|
+
>(({ className, children, ...props }, ref) => (
|
|
13
|
+
<ScrollAreaPrimitive.Root ref={ref} className={cn('relative overflow-hidden', className)} {...props}>
|
|
14
|
+
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">{children}</ScrollAreaPrimitive.Viewport>
|
|
15
|
+
<ScrollBar />
|
|
16
|
+
<ScrollAreaPrimitive.Corner />
|
|
17
|
+
</ScrollAreaPrimitive.Root>
|
|
18
|
+
));
|
|
19
|
+
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
20
|
+
|
|
21
|
+
const ScrollBar = React.forwardRef<
|
|
22
|
+
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
|
23
|
+
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> & ScrollBarBaseProps
|
|
24
|
+
>(({ className, orientation = 'vertical', ...props }, ref) => (
|
|
25
|
+
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
|
26
|
+
ref={ref}
|
|
27
|
+
orientation={orientation}
|
|
28
|
+
className={cn(
|
|
29
|
+
'flex touch-none select-none transition-colors',
|
|
30
|
+
orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent p-[1px]',
|
|
31
|
+
orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent p-[1px]',
|
|
32
|
+
className,
|
|
33
|
+
)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
|
37
|
+
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
38
|
+
));
|
|
39
|
+
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
40
|
+
|
|
41
|
+
export { ScrollArea, ScrollBar };
|
|
42
|
+
export type { ScrollAreaBaseProps as ScrollAreaProps, ScrollBarBaseProps as ScrollBarProps };
|
package/src/search.tsx
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { SearchBaseProps, SearchTriggerBaseProps } from '@gv-tech/ui-core';
|
|
4
|
+
import { Search as SearchIcon } from 'lucide-react';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { Button } from './button';
|
|
7
|
+
import { CommandDialog } from './command';
|
|
8
|
+
import { cn } from './lib/utils';
|
|
9
|
+
|
|
10
|
+
export type SearchProps = SearchBaseProps;
|
|
11
|
+
|
|
12
|
+
export function Search({ children, open: customOpen, onOpenChange }: SearchProps) {
|
|
13
|
+
const [open, setOpen] = React.useState(false);
|
|
14
|
+
|
|
15
|
+
// If customOpen is provided (controlled), use it. Otherwise use internal state.
|
|
16
|
+
// Note: customOpen can be undefined, so we check explicit undefined check or just rely on contract.
|
|
17
|
+
const isControlled = customOpen !== undefined;
|
|
18
|
+
const isOpen = isControlled ? (customOpen as boolean) : open;
|
|
19
|
+
|
|
20
|
+
// We need a setter that matches Dispatch<SetStateAction<boolean>> roughly,
|
|
21
|
+
// but handles the controlled callback.
|
|
22
|
+
const setIsOpen = React.useCallback(
|
|
23
|
+
(value: boolean | ((prev: boolean) => boolean)) => {
|
|
24
|
+
let nextValue: boolean;
|
|
25
|
+
if (typeof value === 'function') {
|
|
26
|
+
nextValue = value(isOpen);
|
|
27
|
+
} else {
|
|
28
|
+
nextValue = value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isControlled) {
|
|
32
|
+
onOpenChange?.(nextValue);
|
|
33
|
+
} else {
|
|
34
|
+
setOpen(nextValue);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
[isControlled, isOpen, onOpenChange],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
React.useEffect(() => {
|
|
41
|
+
const down = (e: KeyboardEvent) => {
|
|
42
|
+
if (e.key === 'k' && (e.metaKey || e.ctrlKey)) {
|
|
43
|
+
e.preventDefault();
|
|
44
|
+
setIsOpen((prev) => !prev);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
document.addEventListener('keydown', down);
|
|
49
|
+
return () => document.removeEventListener('keydown', down);
|
|
50
|
+
}, [setIsOpen]);
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<CommandDialog open={isOpen} onOpenChange={setIsOpen}>
|
|
54
|
+
{children}
|
|
55
|
+
</CommandDialog>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SearchTriggerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, SearchTriggerBaseProps {}
|
|
60
|
+
|
|
61
|
+
export const SearchTrigger = React.forwardRef<HTMLButtonElement, SearchTriggerProps>(
|
|
62
|
+
({ className, placeholder = 'Search docs...', variant = 'default', ...props }, ref) => {
|
|
63
|
+
return (
|
|
64
|
+
<Button
|
|
65
|
+
variant="outline"
|
|
66
|
+
className={cn(
|
|
67
|
+
'relative h-9 text-sm text-muted-foreground transition-all transition-colors',
|
|
68
|
+
variant === 'default'
|
|
69
|
+
? 'w-full justify-start pr-12'
|
|
70
|
+
: 'w-9 justify-center px-0 md:w-40 md:justify-start md:px-3 md:pr-12 lg:w-64',
|
|
71
|
+
className,
|
|
72
|
+
)}
|
|
73
|
+
ref={ref}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
<span className="inline-flex items-center gap-2">
|
|
77
|
+
<SearchIcon className="h-4 w-4 shrink-0" />
|
|
78
|
+
<span className={cn('truncate', variant === 'compact' && 'hidden md:inline')}>{placeholder}</span>
|
|
79
|
+
</span>
|
|
80
|
+
<kbd className="pointer-events-none absolute right-1.5 top-1.5 hidden h-6 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium opacity-100 sm:flex">
|
|
81
|
+
<span className="text-xs">⌘</span>K
|
|
82
|
+
</kbd>
|
|
83
|
+
</Button>
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
);
|
|
87
|
+
SearchTrigger.displayName = 'SearchTrigger';
|
package/src/select.tsx
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
4
|
+
import { Check, ChevronDown, ChevronUp } from 'lucide-react';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
SelectBaseProps,
|
|
9
|
+
SelectContentBaseProps,
|
|
10
|
+
SelectGroupBaseProps,
|
|
11
|
+
SelectItemBaseProps,
|
|
12
|
+
SelectLabelBaseProps,
|
|
13
|
+
SelectScrollDownButtonBaseProps,
|
|
14
|
+
SelectScrollUpButtonBaseProps,
|
|
15
|
+
SelectSeparatorBaseProps,
|
|
16
|
+
SelectTriggerBaseProps,
|
|
17
|
+
SelectValueBaseProps,
|
|
18
|
+
} from '@gv-tech/ui-core';
|
|
19
|
+
import { cn } from './lib/utils';
|
|
20
|
+
|
|
21
|
+
const Select = SelectPrimitive.Root;
|
|
22
|
+
|
|
23
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
24
|
+
|
|
25
|
+
const SelectValue = SelectPrimitive.Value;
|
|
26
|
+
|
|
27
|
+
const SelectTrigger = React.forwardRef<
|
|
28
|
+
React.ElementRef<typeof SelectPrimitive.Trigger>,
|
|
29
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger> & SelectTriggerBaseProps
|
|
30
|
+
>(({ className, children, ...props }, ref) => (
|
|
31
|
+
<SelectPrimitive.Trigger
|
|
32
|
+
ref={ref}
|
|
33
|
+
className={cn(
|
|
34
|
+
'flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
<SelectPrimitive.Icon asChild>
|
|
41
|
+
<ChevronDown className="h-4 w-4 opacity-50" />
|
|
42
|
+
</SelectPrimitive.Icon>
|
|
43
|
+
</SelectPrimitive.Trigger>
|
|
44
|
+
));
|
|
45
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
46
|
+
|
|
47
|
+
const SelectScrollUpButton = React.forwardRef<
|
|
48
|
+
React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,
|
|
49
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton> & SelectScrollUpButtonBaseProps
|
|
50
|
+
>(({ className, ...props }, ref) => (
|
|
51
|
+
<SelectPrimitive.ScrollUpButton
|
|
52
|
+
ref={ref}
|
|
53
|
+
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<ChevronUp className="h-4 w-4" />
|
|
57
|
+
</SelectPrimitive.ScrollUpButton>
|
|
58
|
+
));
|
|
59
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
60
|
+
|
|
61
|
+
const SelectScrollDownButton = React.forwardRef<
|
|
62
|
+
React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,
|
|
63
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton> & SelectScrollDownButtonBaseProps
|
|
64
|
+
>(({ className, ...props }, ref) => (
|
|
65
|
+
<SelectPrimitive.ScrollDownButton
|
|
66
|
+
ref={ref}
|
|
67
|
+
className={cn('flex cursor-default items-center justify-center py-1', className)}
|
|
68
|
+
{...props}
|
|
69
|
+
>
|
|
70
|
+
<ChevronDown className="h-4 w-4" />
|
|
71
|
+
</SelectPrimitive.ScrollDownButton>
|
|
72
|
+
));
|
|
73
|
+
SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
|
|
74
|
+
|
|
75
|
+
const SelectContent = React.forwardRef<
|
|
76
|
+
React.ElementRef<typeof SelectPrimitive.Content>,
|
|
77
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & SelectContentBaseProps
|
|
78
|
+
>(({ className, children, position = 'popper', ...props }, ref) => (
|
|
79
|
+
<SelectPrimitive.Portal>
|
|
80
|
+
<SelectPrimitive.Content
|
|
81
|
+
ref={ref}
|
|
82
|
+
className={cn(
|
|
83
|
+
'relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 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 origin-[--radix-select-content-transform-origin]',
|
|
84
|
+
position === 'popper' &&
|
|
85
|
+
'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1',
|
|
86
|
+
className,
|
|
87
|
+
)}
|
|
88
|
+
position={position}
|
|
89
|
+
{...props}
|
|
90
|
+
>
|
|
91
|
+
<SelectScrollUpButton />
|
|
92
|
+
<SelectPrimitive.Viewport
|
|
93
|
+
className={cn(
|
|
94
|
+
'p-1',
|
|
95
|
+
position === 'popper' &&
|
|
96
|
+
'h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]',
|
|
97
|
+
)}
|
|
98
|
+
>
|
|
99
|
+
{children}
|
|
100
|
+
</SelectPrimitive.Viewport>
|
|
101
|
+
<SelectScrollDownButton />
|
|
102
|
+
</SelectPrimitive.Content>
|
|
103
|
+
</SelectPrimitive.Portal>
|
|
104
|
+
));
|
|
105
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
106
|
+
|
|
107
|
+
const SelectLabel = React.forwardRef<
|
|
108
|
+
React.ElementRef<typeof SelectPrimitive.Label>,
|
|
109
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label> & SelectLabelBaseProps
|
|
110
|
+
>(({ className, ...props }, ref) => (
|
|
111
|
+
<SelectPrimitive.Label ref={ref} className={cn('px-2 py-1.5 text-sm font-semibold', className)} {...props} />
|
|
112
|
+
));
|
|
113
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
114
|
+
|
|
115
|
+
const SelectItem = React.forwardRef<
|
|
116
|
+
React.ElementRef<typeof SelectPrimitive.Item>,
|
|
117
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item> & SelectItemBaseProps
|
|
118
|
+
>(({ className, children, ...props }, ref) => (
|
|
119
|
+
<SelectPrimitive.Item
|
|
120
|
+
ref={ref}
|
|
121
|
+
className={cn(
|
|
122
|
+
'relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
123
|
+
className,
|
|
124
|
+
)}
|
|
125
|
+
{...props}
|
|
126
|
+
>
|
|
127
|
+
<span className="absolute right-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
128
|
+
<SelectPrimitive.ItemIndicator>
|
|
129
|
+
<Check className="h-4 w-4" />
|
|
130
|
+
</SelectPrimitive.ItemIndicator>
|
|
131
|
+
</span>
|
|
132
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
133
|
+
</SelectPrimitive.Item>
|
|
134
|
+
));
|
|
135
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
136
|
+
|
|
137
|
+
const SelectSeparator = React.forwardRef<
|
|
138
|
+
React.ElementRef<typeof SelectPrimitive.Separator>,
|
|
139
|
+
React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator> & SelectSeparatorBaseProps
|
|
140
|
+
>(({ className, ...props }, ref) => (
|
|
141
|
+
<SelectPrimitive.Separator ref={ref} className={cn('-mx-1 my-1 h-px bg-muted', className)} {...props} />
|
|
142
|
+
));
|
|
143
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
144
|
+
|
|
145
|
+
export {
|
|
146
|
+
Select,
|
|
147
|
+
SelectContent,
|
|
148
|
+
SelectGroup,
|
|
149
|
+
SelectItem,
|
|
150
|
+
SelectLabel,
|
|
151
|
+
SelectScrollDownButton,
|
|
152
|
+
SelectScrollUpButton,
|
|
153
|
+
SelectSeparator,
|
|
154
|
+
SelectTrigger,
|
|
155
|
+
SelectValue,
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export type {
|
|
159
|
+
SelectContentBaseProps as SelectContentProps,
|
|
160
|
+
SelectGroupBaseProps as SelectGroupProps,
|
|
161
|
+
SelectItemBaseProps as SelectItemProps,
|
|
162
|
+
SelectLabelBaseProps as SelectLabelProps,
|
|
163
|
+
SelectBaseProps as SelectProps,
|
|
164
|
+
SelectScrollDownButtonBaseProps as SelectScrollDownButtonProps,
|
|
165
|
+
SelectScrollUpButtonBaseProps as SelectScrollUpButtonProps,
|
|
166
|
+
SelectSeparatorBaseProps as SelectSeparatorProps,
|
|
167
|
+
SelectTriggerBaseProps as SelectTriggerProps,
|
|
168
|
+
SelectValueBaseProps as SelectValueProps,
|
|
169
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { SeparatorBaseProps } from '@gv-tech/ui-core';
|
|
7
|
+
import { cn } from './lib/utils';
|
|
8
|
+
|
|
9
|
+
const Separator = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> & SeparatorBaseProps
|
|
12
|
+
>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
|
|
13
|
+
<SeparatorPrimitive.Root
|
|
14
|
+
ref={ref}
|
|
15
|
+
decorative={decorative}
|
|
16
|
+
orientation={orientation}
|
|
17
|
+
className={cn('shrink-0 bg-border', orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
));
|
|
21
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
22
|
+
|
|
23
|
+
export { Separator };
|
|
24
|
+
export type { SeparatorBaseProps as SeparatorProps };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { vi } from 'vitest';
|
|
4
|
+
|
|
5
|
+
// ResizeObserver polyfill
|
|
6
|
+
global.ResizeObserver = class ResizeObserver {
|
|
7
|
+
observe() {}
|
|
8
|
+
unobserve() {}
|
|
9
|
+
disconnect() {}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// IntersectionObserver polyfill
|
|
13
|
+
global.IntersectionObserver = class IntersectionObserver {
|
|
14
|
+
readonly root: Element | Document | null = null;
|
|
15
|
+
readonly rootMargin: string = '';
|
|
16
|
+
readonly thresholds: ReadonlyArray<number> = [];
|
|
17
|
+
|
|
18
|
+
constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit) {
|
|
19
|
+
this.root = options?.root ?? null;
|
|
20
|
+
this.rootMargin = options?.rootMargin ?? '';
|
|
21
|
+
this.thresholds = options?.threshold
|
|
22
|
+
? Array.isArray(options.threshold)
|
|
23
|
+
? options.threshold
|
|
24
|
+
: [options.threshold]
|
|
25
|
+
: [];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
observe() {}
|
|
29
|
+
unobserve() {}
|
|
30
|
+
disconnect() {}
|
|
31
|
+
takeRecords(): IntersectionObserverEntry[] {
|
|
32
|
+
return [];
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// matchMedia polyfill
|
|
37
|
+
Object.defineProperty(window, 'matchMedia', {
|
|
38
|
+
writable: true,
|
|
39
|
+
value: vi.fn().mockImplementation((query) => ({
|
|
40
|
+
matches: false,
|
|
41
|
+
media: query,
|
|
42
|
+
onchange: null,
|
|
43
|
+
addListener: vi.fn(), // deprecated
|
|
44
|
+
removeListener: vi.fn(), // deprecated
|
|
45
|
+
addEventListener: vi.fn(),
|
|
46
|
+
removeEventListener: vi.fn(),
|
|
47
|
+
dispatchEvent: vi.fn(),
|
|
48
|
+
})),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// PointerEvent polyfill (simplified)
|
|
52
|
+
if (!global.PointerEvent) {
|
|
53
|
+
class PointerEvent extends MouseEvent {
|
|
54
|
+
public height: number;
|
|
55
|
+
public isPrimary: boolean;
|
|
56
|
+
public pointerId: number;
|
|
57
|
+
public pointerType: string;
|
|
58
|
+
public pressure: number;
|
|
59
|
+
public tangentialPressure: number;
|
|
60
|
+
public tiltX: number;
|
|
61
|
+
public tiltY: number;
|
|
62
|
+
public twist: number;
|
|
63
|
+
public width: number;
|
|
64
|
+
|
|
65
|
+
constructor(type: string, params: PointerEventInit = {}) {
|
|
66
|
+
super(type, params);
|
|
67
|
+
this.pointerId = params.pointerId || 0;
|
|
68
|
+
this.width = params.width || 0;
|
|
69
|
+
this.height = params.height || 0;
|
|
70
|
+
this.pressure = params.pressure || 0;
|
|
71
|
+
this.tangentialPressure = params.tangentialPressure || 0;
|
|
72
|
+
this.tiltX = params.tiltX || 0;
|
|
73
|
+
this.tiltY = params.tiltY || 0;
|
|
74
|
+
this.twist = params.twist || 0;
|
|
75
|
+
this.pointerType = params.pointerType || '';
|
|
76
|
+
this.isPrimary = params.isPrimary || false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
global.PointerEvent = PointerEvent as any;
|
|
80
|
+
window.PointerEvent = PointerEvent as any;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Layout mocks
|
|
84
|
+
Object.defineProperties(HTMLElement.prototype, {
|
|
85
|
+
offsetParent: {
|
|
86
|
+
get() {
|
|
87
|
+
return this.parentNode;
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
offsetLeft: {
|
|
91
|
+
get() {
|
|
92
|
+
return 0;
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
offsetTop: {
|
|
96
|
+
get() {
|
|
97
|
+
return 0;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
offsetHeight: {
|
|
101
|
+
get() {
|
|
102
|
+
return 100;
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
offsetWidth: {
|
|
106
|
+
get() {
|
|
107
|
+
return 100;
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
window.HTMLElement.prototype.scrollIntoView = vi.fn();
|
|
113
|
+
window.HTMLElement.prototype.releasePointerCapture = vi.fn();
|
|
114
|
+
window.HTMLElement.prototype.hasPointerCapture = vi.fn();
|
package/src/sheet.tsx
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
4
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
5
|
+
import { X } from 'lucide-react';
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
SheetBaseProps,
|
|
10
|
+
SheetCloseBaseProps,
|
|
11
|
+
SheetContentBaseProps,
|
|
12
|
+
SheetDescriptionBaseProps,
|
|
13
|
+
SheetFooterBaseProps,
|
|
14
|
+
SheetHeaderBaseProps,
|
|
15
|
+
SheetOverlayBaseProps,
|
|
16
|
+
SheetPortalBaseProps,
|
|
17
|
+
SheetTitleBaseProps,
|
|
18
|
+
SheetTriggerBaseProps,
|
|
19
|
+
} from '@gv-tech/ui-core';
|
|
20
|
+
import { cn } from './lib/utils';
|
|
21
|
+
|
|
22
|
+
const Sheet = SheetPrimitive.Root;
|
|
23
|
+
|
|
24
|
+
const SheetTrigger = SheetPrimitive.Trigger;
|
|
25
|
+
|
|
26
|
+
const SheetClose = SheetPrimitive.Close;
|
|
27
|
+
|
|
28
|
+
const SheetPortal = SheetPrimitive.Portal;
|
|
29
|
+
|
|
30
|
+
const SheetOverlay = React.forwardRef<
|
|
31
|
+
React.ElementRef<typeof SheetPrimitive.Overlay>,
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Overlay> & SheetOverlayBaseProps
|
|
33
|
+
>(({ className, ...props }, ref) => (
|
|
34
|
+
<SheetPrimitive.Overlay
|
|
35
|
+
className={cn(
|
|
36
|
+
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
37
|
+
className,
|
|
38
|
+
)}
|
|
39
|
+
{...props}
|
|
40
|
+
ref={ref}
|
|
41
|
+
/>
|
|
42
|
+
));
|
|
43
|
+
SheetOverlay.displayName = SheetPrimitive.Overlay.displayName;
|
|
44
|
+
|
|
45
|
+
const sheetVariants = cva(
|
|
46
|
+
'fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out',
|
|
47
|
+
{
|
|
48
|
+
variants: {
|
|
49
|
+
side: {
|
|
50
|
+
top: 'inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top',
|
|
51
|
+
bottom:
|
|
52
|
+
'inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom',
|
|
53
|
+
left: 'inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm',
|
|
54
|
+
right:
|
|
55
|
+
'inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
defaultVariants: {
|
|
59
|
+
side: 'right',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
interface SheetContentProps
|
|
65
|
+
extends
|
|
66
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>,
|
|
67
|
+
VariantProps<typeof sheetVariants>,
|
|
68
|
+
Omit<SheetContentBaseProps, 'side'> {}
|
|
69
|
+
|
|
70
|
+
const SheetContent = React.forwardRef<React.ElementRef<typeof SheetPrimitive.Content>, SheetContentProps>(
|
|
71
|
+
({ side = 'right', className, children, ...props }, ref) => (
|
|
72
|
+
<SheetPortal>
|
|
73
|
+
<SheetOverlay />
|
|
74
|
+
<SheetPrimitive.Content ref={ref} className={cn(sheetVariants({ side }), className)} {...props}>
|
|
75
|
+
<SheetPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary">
|
|
76
|
+
<X className="h-4 w-4" />
|
|
77
|
+
<span className="sr-only">Close</span>
|
|
78
|
+
</SheetPrimitive.Close>
|
|
79
|
+
{children}
|
|
80
|
+
</SheetPrimitive.Content>
|
|
81
|
+
</SheetPortal>
|
|
82
|
+
),
|
|
83
|
+
);
|
|
84
|
+
SheetContent.displayName = SheetPrimitive.Content.displayName;
|
|
85
|
+
|
|
86
|
+
const SheetHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement> & SheetHeaderBaseProps) => (
|
|
87
|
+
<div className={cn('flex flex-col space-y-2 text-center sm:text-left', className)} {...props} />
|
|
88
|
+
);
|
|
89
|
+
SheetHeader.displayName = 'SheetHeader';
|
|
90
|
+
|
|
91
|
+
const SheetFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement> & SheetFooterBaseProps) => (
|
|
92
|
+
<div className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className)} {...props} />
|
|
93
|
+
);
|
|
94
|
+
SheetFooter.displayName = 'SheetFooter';
|
|
95
|
+
|
|
96
|
+
const SheetTitle = React.forwardRef<
|
|
97
|
+
React.ElementRef<typeof SheetPrimitive.Title>,
|
|
98
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Title> & SheetTitleBaseProps
|
|
99
|
+
>(({ className, ...props }, ref) => (
|
|
100
|
+
<SheetPrimitive.Title ref={ref} className={cn('text-lg font-semibold text-foreground', className)} {...props} />
|
|
101
|
+
));
|
|
102
|
+
SheetTitle.displayName = SheetPrimitive.Title.displayName;
|
|
103
|
+
|
|
104
|
+
const SheetDescription = React.forwardRef<
|
|
105
|
+
React.ElementRef<typeof SheetPrimitive.Description>,
|
|
106
|
+
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Description> & SheetDescriptionBaseProps
|
|
107
|
+
>(({ className, ...props }, ref) => (
|
|
108
|
+
<SheetPrimitive.Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />
|
|
109
|
+
));
|
|
110
|
+
SheetDescription.displayName = SheetPrimitive.Description.displayName;
|
|
111
|
+
|
|
112
|
+
export {
|
|
113
|
+
Sheet,
|
|
114
|
+
SheetClose,
|
|
115
|
+
SheetContent,
|
|
116
|
+
SheetDescription,
|
|
117
|
+
SheetFooter,
|
|
118
|
+
SheetHeader,
|
|
119
|
+
SheetOverlay,
|
|
120
|
+
SheetPortal,
|
|
121
|
+
SheetTitle,
|
|
122
|
+
SheetTrigger,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type {
|
|
126
|
+
SheetCloseBaseProps as SheetCloseProps,
|
|
127
|
+
SheetContentProps,
|
|
128
|
+
SheetDescriptionBaseProps as SheetDescriptionProps,
|
|
129
|
+
SheetFooterBaseProps as SheetFooterProps,
|
|
130
|
+
SheetHeaderBaseProps as SheetHeaderProps,
|
|
131
|
+
SheetOverlayBaseProps as SheetOverlayProps,
|
|
132
|
+
SheetPortalBaseProps as SheetPortalProps,
|
|
133
|
+
SheetBaseProps as SheetProps,
|
|
134
|
+
SheetTitleBaseProps as SheetTitleProps,
|
|
135
|
+
SheetTriggerBaseProps as SheetTriggerProps,
|
|
136
|
+
};
|
package/src/skeleton.tsx
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SkeletonBaseProps } from '@gv-tech/ui-core';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from './lib/utils';
|
|
4
|
+
|
|
5
|
+
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement> & SkeletonBaseProps) {
|
|
6
|
+
return <div className={cn('animate-pulse rounded-md bg-primary/10', className)} {...props} />;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { Skeleton };
|
|
10
|
+
export type { SkeletonBaseProps as SkeletonProps };
|
package/src/slider.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as SliderPrimitive from '@radix-ui/react-slider';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { SliderBaseProps } from '@gv-tech/ui-core';
|
|
7
|
+
import { cn } from './lib/utils';
|
|
8
|
+
|
|
9
|
+
const Slider = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof SliderPrimitive.Root>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof SliderPrimitive.Root> & SliderBaseProps
|
|
12
|
+
>(({ className, ...props }, ref) => (
|
|
13
|
+
<SliderPrimitive.Root
|
|
14
|
+
ref={ref}
|
|
15
|
+
className={cn('relative flex w-full touch-none select-none items-center', className)}
|
|
16
|
+
{...props}
|
|
17
|
+
>
|
|
18
|
+
<SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20">
|
|
19
|
+
<SliderPrimitive.Range className="absolute h-full bg-primary" />
|
|
20
|
+
</SliderPrimitive.Track>
|
|
21
|
+
<SliderPrimitive.Thumb className="block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50" />
|
|
22
|
+
</SliderPrimitive.Root>
|
|
23
|
+
));
|
|
24
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
25
|
+
|
|
26
|
+
export { Slider };
|
|
27
|
+
export type { SliderBaseProps as SliderProps };
|
package/src/sonner.tsx
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { SonnerBaseProps } from '@gv-tech/ui-core';
|
|
4
|
+
import { useTheme } from 'next-themes';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { Toaster as Sonner } from 'sonner';
|
|
7
|
+
|
|
8
|
+
type ToasterProps = React.ComponentProps<typeof Sonner> & SonnerBaseProps;
|
|
9
|
+
|
|
10
|
+
const Toaster = ({ ...props }: ToasterProps) => {
|
|
11
|
+
const { theme = 'system' } = useTheme();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Sonner
|
|
15
|
+
theme={theme as ToasterProps['theme']}
|
|
16
|
+
className="toaster group"
|
|
17
|
+
toastOptions={{
|
|
18
|
+
classNames: {
|
|
19
|
+
toast:
|
|
20
|
+
'group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg',
|
|
21
|
+
description: 'group-[.toast]:text-muted-foreground',
|
|
22
|
+
actionButton: 'group-[.toast]:bg-primary group-[.toast]:text-primary-foreground',
|
|
23
|
+
cancelButton: 'group-[.toast]:bg-muted group-[.toast]:text-muted-foreground',
|
|
24
|
+
},
|
|
25
|
+
}}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { Toaster };
|
|
32
|
+
export type { ToasterProps };
|
package/src/switch.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
|
|
6
|
+
import { SwitchBaseProps } from '@gv-tech/ui-core';
|
|
7
|
+
import { cn } from './lib/utils';
|
|
8
|
+
|
|
9
|
+
const Switch = React.forwardRef<
|
|
10
|
+
React.ElementRef<typeof SwitchPrimitives.Root>,
|
|
11
|
+
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root> & SwitchBaseProps
|
|
12
|
+
>(({ className, ...props }, ref) => (
|
|
13
|
+
<SwitchPrimitives.Root
|
|
14
|
+
className={cn(
|
|
15
|
+
'peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
|
|
16
|
+
className,
|
|
17
|
+
)}
|
|
18
|
+
{...props}
|
|
19
|
+
ref={ref}
|
|
20
|
+
>
|
|
21
|
+
<SwitchPrimitives.Thumb
|
|
22
|
+
className={cn(
|
|
23
|
+
'pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0',
|
|
24
|
+
)}
|
|
25
|
+
/>
|
|
26
|
+
</SwitchPrimitives.Root>
|
|
27
|
+
));
|
|
28
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
29
|
+
|
|
30
|
+
export { Switch };
|
|
31
|
+
export type { SwitchBaseProps as SwitchProps };
|