@thangnqdev/ui 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +196 -0
- package/dist/Label-DWOlgSNW.d.cts +14 -0
- package/dist/Label-DWOlgSNW.d.ts +14 -0
- package/dist/bento/index.cjs +140 -0
- package/dist/bento/index.cjs.map +1 -0
- package/dist/bento/index.d.cts +4 -0
- package/dist/bento/index.d.ts +4 -0
- package/dist/bento/index.js +4 -0
- package/dist/bento/index.js.map +1 -0
- package/dist/bento/styles.css +46 -0
- package/dist/buttons/index.cjs +365 -0
- package/dist/buttons/index.cjs.map +1 -0
- package/dist/buttons/index.d.cts +4 -0
- package/dist/buttons/index.d.ts +4 -0
- package/dist/buttons/index.js +5 -0
- package/dist/buttons/index.js.map +1 -0
- package/dist/buttons/styles.css +6 -0
- package/dist/chunk-2OXZK6IP.js +514 -0
- package/dist/chunk-2OXZK6IP.js.map +1 -0
- package/dist/chunk-4S6L5V7X.js +15 -0
- package/dist/chunk-4S6L5V7X.js.map +1 -0
- package/dist/chunk-5FZ6ZFII.js +728 -0
- package/dist/chunk-5FZ6ZFII.js.map +1 -0
- package/dist/chunk-66VWUJEI.js +86 -0
- package/dist/chunk-66VWUJEI.js.map +1 -0
- package/dist/chunk-A7P3O5Z5.js +163 -0
- package/dist/chunk-A7P3O5Z5.js.map +1 -0
- package/dist/chunk-ATYGDTMK.js +257 -0
- package/dist/chunk-ATYGDTMK.js.map +1 -0
- package/dist/chunk-C4SUXMI3.js +138 -0
- package/dist/chunk-C4SUXMI3.js.map +1 -0
- package/dist/chunk-EU2LPUYP.js +25 -0
- package/dist/chunk-EU2LPUYP.js.map +1 -0
- package/dist/chunk-F5Q7BTMH.js +1991 -0
- package/dist/chunk-F5Q7BTMH.js.map +1 -0
- package/dist/chunk-GXI2H5XA.js +46 -0
- package/dist/chunk-GXI2H5XA.js.map +1 -0
- package/dist/chunk-H3LCNPMC.js +101 -0
- package/dist/chunk-H3LCNPMC.js.map +1 -0
- package/dist/chunk-IABPUCAQ.js +19 -0
- package/dist/chunk-IABPUCAQ.js.map +1 -0
- package/dist/chunk-KJRBRTQE.js +101 -0
- package/dist/chunk-KJRBRTQE.js.map +1 -0
- package/dist/chunk-LBUBXUYQ.js +40 -0
- package/dist/chunk-LBUBXUYQ.js.map +1 -0
- package/dist/chunk-LWFRUJRU.js +537 -0
- package/dist/chunk-LWFRUJRU.js.map +1 -0
- package/dist/chunk-NFVONJUK.js +882 -0
- package/dist/chunk-NFVONJUK.js.map +1 -0
- package/dist/chunk-PF4ZHGVW.js +284 -0
- package/dist/chunk-PF4ZHGVW.js.map +1 -0
- package/dist/chunk-WAFHC4DQ.js +366 -0
- package/dist/chunk-WAFHC4DQ.js.map +1 -0
- package/dist/chunk-X76KBH4Y.js +71 -0
- package/dist/chunk-X76KBH4Y.js.map +1 -0
- package/dist/core/index.cjs +103 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +3 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/styles.css +128 -0
- package/dist/data-display/index.cjs +1023 -0
- package/dist/data-display/index.cjs.map +1 -0
- package/dist/data-display/index.d.cts +4 -0
- package/dist/data-display/index.d.ts +4 -0
- package/dist/data-display/index.js +6 -0
- package/dist/data-display/index.js.map +1 -0
- package/dist/data-display/styles.css +4 -0
- package/dist/feedback/index.cjs +368 -0
- package/dist/feedback/index.cjs.map +1 -0
- package/dist/feedback/index.d.cts +4 -0
- package/dist/feedback/index.d.ts +4 -0
- package/dist/feedback/index.js +4 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/feedback/styles.css +4 -0
- package/dist/forms/index.cjs +2287 -0
- package/dist/forms/index.cjs.map +1 -0
- package/dist/forms/index.d.cts +5 -0
- package/dist/forms/index.d.ts +5 -0
- package/dist/forms/index.js +10 -0
- package/dist/forms/index.js.map +1 -0
- package/dist/forms/styles.css +6 -0
- package/dist/glass/index.cjs +165 -0
- package/dist/glass/index.cjs.map +1 -0
- package/dist/glass/index.d.cts +4 -0
- package/dist/glass/index.d.ts +4 -0
- package/dist/glass/index.js +4 -0
- package/dist/glass/index.js.map +1 -0
- package/dist/glass/styles.css +81 -0
- package/dist/index-BTvkbCIj.d.cts +146 -0
- package/dist/index-BTvkbCIj.d.ts +146 -0
- package/dist/index-BkRqGNG1.d.cts +201 -0
- package/dist/index-BkRqGNG1.d.ts +201 -0
- package/dist/index-BlPcGeW-.d.cts +45 -0
- package/dist/index-BlPcGeW-.d.ts +45 -0
- package/dist/index-BzOCqvC6.d.cts +32 -0
- package/dist/index-BzOCqvC6.d.ts +32 -0
- package/dist/index-CCeWYAvn.d.cts +83 -0
- package/dist/index-COQ7uwt9.d.cts +44 -0
- package/dist/index-COQ7uwt9.d.ts +44 -0
- package/dist/index-CenuF_P2.d.cts +221 -0
- package/dist/index-CenuF_P2.d.ts +221 -0
- package/dist/index-Cle6QzQl.d.ts +371 -0
- package/dist/index-D6fE7w-b.d.cts +90 -0
- package/dist/index-D6fE7w-b.d.ts +90 -0
- package/dist/index-DR8cfJUG.d.ts +83 -0
- package/dist/index-DzcWh1Hs.d.cts +131 -0
- package/dist/index-DzcWh1Hs.d.ts +131 -0
- package/dist/index-TyK-Ldpy.d.cts +371 -0
- package/dist/index-ugj5s6a3.d.cts +95 -0
- package/dist/index-ugj5s6a3.d.ts +95 -0
- package/dist/index.cjs +6400 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/layout/index.cjs +516 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.d.cts +4 -0
- package/dist/layout/index.d.ts +4 -0
- package/dist/layout/index.js +4 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/styles.css +8 -0
- package/dist/navigation/index.cjs +673 -0
- package/dist/navigation/index.cjs.map +1 -0
- package/dist/navigation/index.d.cts +2 -0
- package/dist/navigation/index.d.ts +2 -0
- package/dist/navigation/index.js +8 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/styles.css +4 -0
- package/dist/overlays/index.cjs +954 -0
- package/dist/overlays/index.cjs.map +1 -0
- package/dist/overlays/index.d.cts +4 -0
- package/dist/overlays/index.d.ts +4 -0
- package/dist/overlays/index.js +9 -0
- package/dist/overlays/index.js.map +1 -0
- package/dist/overlays/styles.css +8 -0
- package/dist/styles.css +333 -0
- package/dist/typography/index.cjs +311 -0
- package/dist/typography/index.cjs.map +1 -0
- package/dist/typography/index.d.cts +5 -0
- package/dist/typography/index.d.ts +5 -0
- package/dist/typography/index.js +6 -0
- package/dist/typography/index.js.map +1 -0
- package/dist/typography/styles.css +5 -0
- package/llms.txt +113 -0
- package/package.json +116 -0
- package/src/bento/BentoCard.tsx +140 -0
- package/src/bento/BentoGrid.tsx +50 -0
- package/src/bento/index.ts +2 -0
- package/src/bento/tokens.css +46 -0
- package/src/buttons/Button.tsx +104 -0
- package/src/buttons/ButtonGroup.tsx +43 -0
- package/src/buttons/IconButton.tsx +79 -0
- package/src/buttons/SplitButton.tsx +86 -0
- package/src/buttons/ToggleButton.tsx +157 -0
- package/src/buttons/index.ts +5 -0
- package/src/buttons/tokens.css +6 -0
- package/src/core/ThemeProvider.tsx +123 -0
- package/src/core/index.ts +2 -0
- package/src/core/tokens.css +128 -0
- package/src/data-display/Accordion.tsx +147 -0
- package/src/data-display/Avatar.tsx +134 -0
- package/src/data-display/Card.tsx +112 -0
- package/src/data-display/Carousel.tsx +130 -0
- package/src/data-display/Chip.tsx +74 -0
- package/src/data-display/DataTablePro.tsx +356 -0
- package/src/data-display/StatCard.tsx +60 -0
- package/src/data-display/Table.tsx +74 -0
- package/src/data-display/Timeline.tsx +62 -0
- package/src/data-display/TreeView.tsx +140 -0
- package/src/data-display/index.ts +10 -0
- package/src/data-display/tokens.css +4 -0
- package/src/feedback/Alert.tsx +80 -0
- package/src/feedback/EmptyState.tsx +45 -0
- package/src/feedback/ProgressBar.tsx +174 -0
- package/src/feedback/Skeleton.tsx +66 -0
- package/src/feedback/Spinner.tsx +65 -0
- package/src/feedback/index.ts +5 -0
- package/src/feedback/tokens.css +4 -0
- package/src/forms/Checkbox.tsx +69 -0
- package/src/forms/CheckboxGroup.tsx +29 -0
- package/src/forms/Combobox.tsx +368 -0
- package/src/forms/DatePicker.tsx +480 -0
- package/src/forms/FileUpload.tsx +222 -0
- package/src/forms/FormField.tsx +115 -0
- package/src/forms/Input.tsx +151 -0
- package/src/forms/MaskedInput.tsx +97 -0
- package/src/forms/NumberInput.tsx +248 -0
- package/src/forms/PasswordInput.tsx +35 -0
- package/src/forms/PinInput.tsx +125 -0
- package/src/forms/Radio.tsx +142 -0
- package/src/forms/RangeSlider.tsx +111 -0
- package/src/forms/SearchInput.tsx +34 -0
- package/src/forms/Select.tsx +103 -0
- package/src/forms/Slider.tsx +85 -0
- package/src/forms/Switch.tsx +95 -0
- package/src/forms/Textarea.tsx +114 -0
- package/src/forms/index.ts +18 -0
- package/src/forms/tokens.css +6 -0
- package/src/glass/GlassBadge.tsx +61 -0
- package/src/glass/GlassButton.tsx +59 -0
- package/src/glass/GlassCard.tsx +71 -0
- package/src/glass/index.ts +3 -0
- package/src/glass/tokens.css +81 -0
- package/src/index.ts +26 -0
- package/src/layout/AspectRatio.tsx +39 -0
- package/src/layout/Container.tsx +53 -0
- package/src/layout/Divider.tsx +61 -0
- package/src/layout/Flex.tsx +79 -0
- package/src/layout/Grid.tsx +124 -0
- package/src/layout/PageLayout.tsx +59 -0
- package/src/layout/ScrollArea.tsx +43 -0
- package/src/layout/Section.tsx +47 -0
- package/src/layout/Spacer.tsx +30 -0
- package/src/layout/Stack.tsx +88 -0
- package/src/layout/index.ts +10 -0
- package/src/layout/tokens.css +8 -0
- package/src/navigation/Breadcrumb.tsx +73 -0
- package/src/navigation/CommandPalette.tsx +142 -0
- package/src/navigation/DropdownMenu.tsx +160 -0
- package/src/navigation/Pagination.tsx +114 -0
- package/src/navigation/Stepper.tsx +93 -0
- package/src/navigation/Tabs.tsx +133 -0
- package/src/navigation/index.ts +6 -0
- package/src/navigation/tokens.css +4 -0
- package/src/overlays/AlertDialog.tsx +54 -0
- package/src/overlays/BottomSheet.tsx +123 -0
- package/src/overlays/ContextMenu.tsx +119 -0
- package/src/overlays/Drawer.tsx +145 -0
- package/src/overlays/FocusTrap.tsx +49 -0
- package/src/overlays/HoverCard.tsx +72 -0
- package/src/overlays/Modal.tsx +219 -0
- package/src/overlays/Popover.tsx +126 -0
- package/src/overlays/Portal.tsx +23 -0
- package/src/overlays/Toast.tsx +137 -0
- package/src/overlays/Tooltip.tsx +100 -0
- package/src/overlays/index.ts +11 -0
- package/src/overlays/tokens.css +8 -0
- package/src/styles/tokens.css +2 -0
- package/src/typography/Blockquote.tsx +32 -0
- package/src/typography/Code.tsx +89 -0
- package/src/typography/Heading.tsx +56 -0
- package/src/typography/Kbd.tsx +25 -0
- package/src/typography/Label.tsx +47 -0
- package/src/typography/Link.tsx +56 -0
- package/src/typography/Text.tsx +62 -0
- package/src/typography/index.ts +7 -0
- package/src/typography/tokens.css +5 -0
- package/src/utils/cn.ts +6 -0
- package/ui-contract.json +62 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useState, useRef, forwardRef } from 'react';
|
|
2
|
+
import { cn } from '../utils/cn';
|
|
3
|
+
import { Portal } from './Portal';
|
|
4
|
+
|
|
5
|
+
export interface HoverCardProps {
|
|
6
|
+
trigger: React.ReactNode;
|
|
7
|
+
content: React.ReactNode;
|
|
8
|
+
openDelay?: number;
|
|
9
|
+
closeDelay?: number;
|
|
10
|
+
className?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const HoverCard = forwardRef<HTMLDivElement, HoverCardProps>(
|
|
14
|
+
({ trigger, content, openDelay = 200, closeDelay = 250, className }, ref) => {
|
|
15
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
16
|
+
const [coords, setCoords] = useState<{ top: number; left: number }>({ top: 0, left: 0 });
|
|
17
|
+
const triggerRef = useRef<HTMLDivElement | null>(null);
|
|
18
|
+
const openTimerRef = useRef<any>(null);
|
|
19
|
+
const closeTimerRef = useRef<any>(null);
|
|
20
|
+
|
|
21
|
+
const handleMouseEnter = () => {
|
|
22
|
+
clearTimeout(closeTimerRef.current);
|
|
23
|
+
openTimerRef.current = setTimeout(() => {
|
|
24
|
+
if (triggerRef.current) {
|
|
25
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
26
|
+
setCoords({
|
|
27
|
+
top: rect.bottom + window.scrollY + 8,
|
|
28
|
+
left: Math.max(16, Math.min(window.innerWidth - 320, rect.left + window.scrollX)),
|
|
29
|
+
});
|
|
30
|
+
setIsOpen(true);
|
|
31
|
+
}
|
|
32
|
+
}, openDelay);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const handleMouseLeave = () => {
|
|
36
|
+
clearTimeout(openTimerRef.current);
|
|
37
|
+
closeTimerRef.current = setTimeout(() => {
|
|
38
|
+
setIsOpen(false);
|
|
39
|
+
}, closeDelay);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
ref={ref}
|
|
45
|
+
className="inline-block relative"
|
|
46
|
+
onMouseEnter={handleMouseEnter}
|
|
47
|
+
onMouseLeave={handleMouseLeave}
|
|
48
|
+
>
|
|
49
|
+
<div ref={triggerRef} className="inline-block">
|
|
50
|
+
{trigger}
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
{isOpen && (
|
|
54
|
+
<Portal>
|
|
55
|
+
<div
|
|
56
|
+
style={{ top: `${coords.top}px`, left: `${coords.left}px` }}
|
|
57
|
+
onMouseEnter={() => clearTimeout(closeTimerRef.current)}
|
|
58
|
+
onMouseLeave={handleMouseLeave}
|
|
59
|
+
className={cn(
|
|
60
|
+
'fixed z-50 w-72 p-4 rounded-2xl bg-[var(--ui-bg-surface)] backdrop-blur-3xl border border-[var(--ui-border-default)] shadow-2xl animate-in fade-in zoom-in-95 duration-200',
|
|
61
|
+
className
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
{content}
|
|
65
|
+
</div>
|
|
66
|
+
</Portal>
|
|
67
|
+
)}
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
HoverCard.displayName = 'HoverCard';
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React, { forwardRef, createContext, useContext, useEffect } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { X } from 'lucide-react';
|
|
4
|
+
import { Portal } from './Portal';
|
|
5
|
+
import { FocusTrap } from './FocusTrap';
|
|
6
|
+
import { cn } from '../utils/cn';
|
|
7
|
+
|
|
8
|
+
interface ModalContextType {
|
|
9
|
+
isOpen: boolean;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
closeOnOverlayClick?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const ModalContext = createContext<ModalContextType | null>(null);
|
|
15
|
+
|
|
16
|
+
export function useModal() {
|
|
17
|
+
const context = useContext(ModalContext);
|
|
18
|
+
if (!context) {
|
|
19
|
+
throw new Error('Modal compound components must be used within a <Modal />');
|
|
20
|
+
}
|
|
21
|
+
return context;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ModalProps {
|
|
25
|
+
isOpen: boolean;
|
|
26
|
+
onClose: () => void;
|
|
27
|
+
children: React.ReactNode;
|
|
28
|
+
closeOnEsc?: boolean;
|
|
29
|
+
closeOnOverlayClick?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function Modal({
|
|
33
|
+
isOpen,
|
|
34
|
+
onClose,
|
|
35
|
+
children,
|
|
36
|
+
closeOnEsc = true,
|
|
37
|
+
closeOnOverlayClick = true,
|
|
38
|
+
}: ModalProps) {
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!isOpen) return;
|
|
41
|
+
|
|
42
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
43
|
+
if (closeOnEsc && e.key === 'Escape') {
|
|
44
|
+
onClose();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const originalOverflow = document.body.style.overflow;
|
|
49
|
+
document.body.style.overflow = 'hidden';
|
|
50
|
+
|
|
51
|
+
window.addEventListener('keydown', handleKeyDown);
|
|
52
|
+
return () => {
|
|
53
|
+
window.removeEventListener('keydown', handleKeyDown);
|
|
54
|
+
document.body.style.overflow = originalOverflow;
|
|
55
|
+
};
|
|
56
|
+
}, [isOpen, closeOnEsc, onClose]);
|
|
57
|
+
|
|
58
|
+
if (!isOpen) return null;
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<Portal>
|
|
62
|
+
<ModalContext.Provider value={{ isOpen, onClose, closeOnOverlayClick }}>
|
|
63
|
+
<FocusTrap active={isOpen}>
|
|
64
|
+
<div
|
|
65
|
+
className="fixed inset-0 z-50 flex items-center justify-center p-4 sm:p-6"
|
|
66
|
+
role="dialog"
|
|
67
|
+
aria-modal="true"
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
</div>
|
|
71
|
+
</FocusTrap>
|
|
72
|
+
</ModalContext.Provider>
|
|
73
|
+
</Portal>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ModalOverlayProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
78
|
+
|
|
79
|
+
export const ModalOverlay = forwardRef<HTMLDivElement, ModalOverlayProps>(
|
|
80
|
+
({ className, onClick, ...props }, ref) => {
|
|
81
|
+
const { onClose, closeOnOverlayClick } = useModal();
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div
|
|
85
|
+
ref={ref}
|
|
86
|
+
aria-hidden="true"
|
|
87
|
+
onClick={(e) => {
|
|
88
|
+
onClick?.(e);
|
|
89
|
+
if (closeOnOverlayClick) onClose();
|
|
90
|
+
}}
|
|
91
|
+
className={cn(
|
|
92
|
+
'fixed inset-0 bg-[var(--ui-bg-overlay)] backdrop-blur-sm transition-opacity animate-in fade-in duration-200',
|
|
93
|
+
className
|
|
94
|
+
)}
|
|
95
|
+
{...props}
|
|
96
|
+
/>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
ModalOverlay.displayName = 'ModalOverlay';
|
|
101
|
+
|
|
102
|
+
export const modalContentVariants = cva(
|
|
103
|
+
'relative w-full max-w-lg rounded-[var(--ui-radius-xl)] bg-[var(--ui-bg-surface)] border border-[var(--ui-border-default)] p-6 text-[var(--ui-text-primary)] shadow-2xl transition-all animate-in zoom-in-95 duration-200 z-10',
|
|
104
|
+
{
|
|
105
|
+
variants: {
|
|
106
|
+
size: {
|
|
107
|
+
sm: 'max-w-sm',
|
|
108
|
+
md: 'max-w-md',
|
|
109
|
+
lg: 'max-w-lg',
|
|
110
|
+
xl: 'max-w-xl',
|
|
111
|
+
'2xl': 'max-w-2xl',
|
|
112
|
+
full: 'max-w-[calc(100vw-2rem)] h-[calc(100vh-2rem)]',
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
defaultVariants: {
|
|
116
|
+
size: 'md',
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
export interface ModalContentProps
|
|
122
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
123
|
+
VariantProps<typeof modalContentVariants> {}
|
|
124
|
+
|
|
125
|
+
export const ModalContent = forwardRef<HTMLDivElement, ModalContentProps>(
|
|
126
|
+
({ className, size, children, ...props }, ref) => {
|
|
127
|
+
return (
|
|
128
|
+
<div
|
|
129
|
+
ref={ref}
|
|
130
|
+
className={cn(modalContentVariants({ size }), className)}
|
|
131
|
+
{...props}
|
|
132
|
+
>
|
|
133
|
+
{children}
|
|
134
|
+
</div>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
ModalContent.displayName = 'ModalContent';
|
|
139
|
+
|
|
140
|
+
export const ModalHeader = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
141
|
+
({ className, children, ...props }, ref) => {
|
|
142
|
+
return (
|
|
143
|
+
<div ref={ref} className={cn('flex flex-col space-y-1.5 mb-4', className)} {...props}>
|
|
144
|
+
{children}
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
);
|
|
149
|
+
ModalHeader.displayName = 'ModalHeader';
|
|
150
|
+
|
|
151
|
+
export const ModalTitle = forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
152
|
+
({ className, children, ...props }, ref) => {
|
|
153
|
+
return (
|
|
154
|
+
<h2 ref={ref} className={cn('text-lg sm:text-xl font-bold tracking-tight text-[var(--ui-text-primary)]', className)} {...props}>
|
|
155
|
+
{children}
|
|
156
|
+
</h2>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
ModalTitle.displayName = 'ModalTitle';
|
|
161
|
+
|
|
162
|
+
export const ModalDescription = forwardRef<HTMLParagraphElement, React.HTMLAttributes<HTMLParagraphElement>>(
|
|
163
|
+
({ className, children, ...props }, ref) => {
|
|
164
|
+
return (
|
|
165
|
+
<p ref={ref} className={cn('text-sm text-[var(--ui-text-muted)]', className)} {...props}>
|
|
166
|
+
{children}
|
|
167
|
+
</p>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
ModalDescription.displayName = 'ModalDescription';
|
|
172
|
+
|
|
173
|
+
export const ModalBody = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
174
|
+
({ className, children, ...props }, ref) => {
|
|
175
|
+
return (
|
|
176
|
+
<div ref={ref} className={cn('py-2', className)} {...props}>
|
|
177
|
+
{children}
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
ModalBody.displayName = 'ModalBody';
|
|
183
|
+
|
|
184
|
+
export const ModalFooter = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
|
|
185
|
+
({ className, children, ...props }, ref) => {
|
|
186
|
+
return (
|
|
187
|
+
<div ref={ref} className={cn('flex items-center justify-end gap-3 mt-6 pt-4 border-t border-[var(--ui-border-subtle)]', className)} {...props}>
|
|
188
|
+
{children}
|
|
189
|
+
</div>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
);
|
|
193
|
+
ModalFooter.displayName = 'ModalFooter';
|
|
194
|
+
|
|
195
|
+
export const ModalCloseButton = forwardRef<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>(
|
|
196
|
+
({ className, onClick, ...props }, ref) => {
|
|
197
|
+
const { onClose } = useModal();
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<button
|
|
201
|
+
ref={ref}
|
|
202
|
+
type="button"
|
|
203
|
+
onClick={(e) => {
|
|
204
|
+
onClick?.(e);
|
|
205
|
+
onClose();
|
|
206
|
+
}}
|
|
207
|
+
aria-label="Close dialog"
|
|
208
|
+
className={cn(
|
|
209
|
+
'absolute top-4 right-4 p-1.5 rounded-full text-[var(--ui-text-muted)] hover:text-[var(--ui-text-primary)] hover:bg-[var(--ui-bg-tertiary)] transition-colors',
|
|
210
|
+
className
|
|
211
|
+
)}
|
|
212
|
+
{...props}
|
|
213
|
+
>
|
|
214
|
+
<X className="w-4 h-4" />
|
|
215
|
+
</button>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
ModalCloseButton.displayName = 'ModalCloseButton';
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
+
import { Portal } from './Portal';
|
|
3
|
+
import { cn } from '../utils/cn';
|
|
4
|
+
|
|
5
|
+
export interface PopoverProps {
|
|
6
|
+
trigger: React.ReactNode;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
isOpen?: boolean;
|
|
9
|
+
onClose?: () => void;
|
|
10
|
+
placement?: 'top' | 'bottom' | 'left' | 'right';
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Popover = ({
|
|
15
|
+
trigger,
|
|
16
|
+
children,
|
|
17
|
+
isOpen: controlledIsOpen,
|
|
18
|
+
onClose,
|
|
19
|
+
placement = 'bottom',
|
|
20
|
+
className,
|
|
21
|
+
}: PopoverProps) => {
|
|
22
|
+
const [internalIsOpen, setInternalIsOpen] = useState(false);
|
|
23
|
+
const isOpen = controlledIsOpen !== undefined ? controlledIsOpen : internalIsOpen;
|
|
24
|
+
|
|
25
|
+
const [coords, setCoords] = useState<{ top: number; left: number }>({ top: 0, left: 0 });
|
|
26
|
+
const triggerRef = useRef<HTMLDivElement | null>(null);
|
|
27
|
+
const popoverRef = useRef<HTMLDivElement | null>(null);
|
|
28
|
+
|
|
29
|
+
const calculatePosition = () => {
|
|
30
|
+
if (triggerRef.current) {
|
|
31
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
32
|
+
let top = 0;
|
|
33
|
+
let left = 0;
|
|
34
|
+
|
|
35
|
+
if (placement === 'bottom') {
|
|
36
|
+
top = rect.bottom + window.scrollY + 8;
|
|
37
|
+
left = rect.left + window.scrollX;
|
|
38
|
+
} else if (placement === 'top') {
|
|
39
|
+
top = rect.top + window.scrollY - 8;
|
|
40
|
+
left = rect.left + window.scrollX;
|
|
41
|
+
} else if (placement === 'right') {
|
|
42
|
+
top = rect.top + window.scrollY;
|
|
43
|
+
left = rect.right + window.scrollX + 8;
|
|
44
|
+
} else if (placement === 'left') {
|
|
45
|
+
top = rect.top + window.scrollY;
|
|
46
|
+
left = rect.left + window.scrollX - 8;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setCoords({ top, left });
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleToggle = () => {
|
|
54
|
+
if (!isOpen) {
|
|
55
|
+
calculatePosition();
|
|
56
|
+
}
|
|
57
|
+
if (controlledIsOpen !== undefined) {
|
|
58
|
+
if (isOpen) onClose?.();
|
|
59
|
+
} else {
|
|
60
|
+
setInternalIsOpen(!internalIsOpen);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (isOpen) {
|
|
66
|
+
calculatePosition();
|
|
67
|
+
}
|
|
68
|
+
}, [isOpen]);
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const handleOutside = (e: MouseEvent) => {
|
|
72
|
+
if (
|
|
73
|
+
popoverRef.current &&
|
|
74
|
+
!popoverRef.current.contains(e.target as Node) &&
|
|
75
|
+
triggerRef.current &&
|
|
76
|
+
!triggerRef.current.contains(e.target as Node)
|
|
77
|
+
) {
|
|
78
|
+
if (controlledIsOpen !== undefined) {
|
|
79
|
+
onClose?.();
|
|
80
|
+
} else {
|
|
81
|
+
setInternalIsOpen(false);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (isOpen) {
|
|
87
|
+
document.addEventListener('mousedown', handleOutside);
|
|
88
|
+
window.addEventListener('resize', calculatePosition);
|
|
89
|
+
window.addEventListener('scroll', calculatePosition);
|
|
90
|
+
}
|
|
91
|
+
return () => {
|
|
92
|
+
document.removeEventListener('mousedown', handleOutside);
|
|
93
|
+
window.removeEventListener('resize', calculatePosition);
|
|
94
|
+
window.removeEventListener('scroll', calculatePosition);
|
|
95
|
+
};
|
|
96
|
+
}, [isOpen, controlledIsOpen, onClose]);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<>
|
|
100
|
+
<div ref={triggerRef} onClick={handleToggle} className="w-full inline-block cursor-pointer">
|
|
101
|
+
{trigger}
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{isOpen && (
|
|
105
|
+
<Portal>
|
|
106
|
+
<div
|
|
107
|
+
ref={popoverRef}
|
|
108
|
+
style={{
|
|
109
|
+
top: `${coords.top}px`,
|
|
110
|
+
left: `${coords.left}px`,
|
|
111
|
+
position: 'absolute',
|
|
112
|
+
}}
|
|
113
|
+
className={cn(
|
|
114
|
+
'z-50 min-w-[12rem] rounded-[var(--ui-radius-lg)] bg-[var(--ui-bg-surface)] border border-[var(--ui-border-default)] p-4 text-[var(--ui-text-primary)] shadow-xl animate-in fade-in zoom-in-95',
|
|
115
|
+
placement === 'top' && '-translate-y-full',
|
|
116
|
+
placement === 'left' && '-translate-x-full',
|
|
117
|
+
className
|
|
118
|
+
)}
|
|
119
|
+
>
|
|
120
|
+
{children}
|
|
121
|
+
</div>
|
|
122
|
+
</Portal>
|
|
123
|
+
)}
|
|
124
|
+
</>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
|
|
4
|
+
export interface PortalProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
container?: Element | null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function Portal({ children, container }: PortalProps) {
|
|
10
|
+
const [mounted, setMounted] = useState(false);
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setMounted(true);
|
|
14
|
+
return () => setMounted(false);
|
|
15
|
+
}, []);
|
|
16
|
+
|
|
17
|
+
if (!mounted) return null;
|
|
18
|
+
|
|
19
|
+
const target = container || (typeof document !== 'undefined' ? document.body : null);
|
|
20
|
+
if (!target) return null;
|
|
21
|
+
|
|
22
|
+
return createPortal(children, target);
|
|
23
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import React, { createContext, useContext, useState, useCallback } from 'react';
|
|
2
|
+
import { cva } from 'class-variance-authority';
|
|
3
|
+
import { CheckCircle2, AlertTriangle, AlertCircle, Info, X } from 'lucide-react';
|
|
4
|
+
import { Portal } from './Portal';
|
|
5
|
+
import { cn } from '../utils/cn';
|
|
6
|
+
|
|
7
|
+
export type ToastType = 'info' | 'success' | 'warning' | 'error';
|
|
8
|
+
|
|
9
|
+
export interface ToastOptions {
|
|
10
|
+
id?: string;
|
|
11
|
+
title: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
type?: ToastType;
|
|
14
|
+
duration?: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ToastItem extends ToastOptions {
|
|
18
|
+
id: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface ToastContextType {
|
|
22
|
+
toast: (options: ToastOptions) => string;
|
|
23
|
+
dismiss: (id: string) => void;
|
|
24
|
+
toasts: ToastItem[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ToastContext = createContext<ToastContextType | null>(null);
|
|
28
|
+
|
|
29
|
+
export function useToast() {
|
|
30
|
+
const context = useContext(ToastContext);
|
|
31
|
+
if (!context) {
|
|
32
|
+
throw new Error('useToast must be used within a ToasterProvider');
|
|
33
|
+
}
|
|
34
|
+
return context;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const toastVariants = cva(
|
|
38
|
+
'pointer-events-auto flex w-full max-w-md items-start gap-3 rounded-[var(--ui-radius-lg)] border p-4 shadow-lg transition-all animate-in slide-in-from-bottom-5 duration-300',
|
|
39
|
+
{
|
|
40
|
+
variants: {
|
|
41
|
+
type: {
|
|
42
|
+
info: 'bg-[var(--ui-bg-surface)] border-[var(--ui-info)]/30 text-[var(--ui-text-primary)]',
|
|
43
|
+
success: 'bg-[var(--ui-bg-surface)] border-[var(--ui-success)]/30 text-[var(--ui-text-primary)]',
|
|
44
|
+
warning: 'bg-[var(--ui-bg-surface)] border-[var(--ui-warning)]/30 text-[var(--ui-text-primary)]',
|
|
45
|
+
error: 'bg-[var(--ui-bg-surface)] border-[var(--ui-error)]/30 text-[var(--ui-text-primary)]',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
defaultVariants: {
|
|
49
|
+
type: 'info',
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const toastIcons: Record<ToastType, React.ReactNode> = {
|
|
55
|
+
info: <Info className="w-5 h-5 text-[var(--ui-info)] flex-shrink-0" />,
|
|
56
|
+
success: <CheckCircle2 className="w-5 h-5 text-[var(--ui-success)] flex-shrink-0" />,
|
|
57
|
+
warning: <AlertTriangle className="w-5 h-5 text-[var(--ui-warning)] flex-shrink-0" />,
|
|
58
|
+
error: <AlertCircle className="w-5 h-5 text-[var(--ui-error)] flex-shrink-0" />,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export interface ToasterProviderProps {
|
|
62
|
+
children: React.ReactNode;
|
|
63
|
+
position?: 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function ToasterProvider({ children, position = 'bottom-right' }: ToasterProviderProps) {
|
|
67
|
+
const [toasts, setToasts] = useState<ToastItem[]>([]);
|
|
68
|
+
|
|
69
|
+
const dismiss = useCallback((id: string) => {
|
|
70
|
+
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
71
|
+
}, []);
|
|
72
|
+
|
|
73
|
+
const toast = useCallback(
|
|
74
|
+
({ id = Math.random().toString(36).slice(2, 9), title, description, type = 'info', duration = 4000 }: ToastOptions) => {
|
|
75
|
+
const item: ToastItem = { id, title, description, type, duration };
|
|
76
|
+
|
|
77
|
+
setToasts((prev) => [...prev, item]);
|
|
78
|
+
|
|
79
|
+
if (duration > 0) {
|
|
80
|
+
setTimeout(() => {
|
|
81
|
+
dismiss(id);
|
|
82
|
+
}, duration);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return id;
|
|
86
|
+
},
|
|
87
|
+
[dismiss]
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
const getPositionClasses = () => {
|
|
91
|
+
switch (position) {
|
|
92
|
+
case 'top-left':
|
|
93
|
+
return 'top-4 left-4 items-start';
|
|
94
|
+
case 'top-center':
|
|
95
|
+
return 'top-4 left-1/2 -translate-x-1/2 items-center';
|
|
96
|
+
case 'top-right':
|
|
97
|
+
return 'top-4 right-4 items-end';
|
|
98
|
+
case 'bottom-left':
|
|
99
|
+
return 'bottom-4 left-4 items-start';
|
|
100
|
+
case 'bottom-center':
|
|
101
|
+
return 'bottom-4 left-1/2 -translate-x-1/2 items-center';
|
|
102
|
+
case 'bottom-right':
|
|
103
|
+
default:
|
|
104
|
+
return 'bottom-4 right-4 items-end';
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<ToastContext.Provider value={{ toast, dismiss, toasts }}>
|
|
110
|
+
{children}
|
|
111
|
+
<Portal>
|
|
112
|
+
<div
|
|
113
|
+
aria-live="polite"
|
|
114
|
+
className={cn('fixed z-[100] flex flex-col gap-2 pointer-events-none p-4 w-full max-w-sm sm:max-w-md', getPositionClasses())}
|
|
115
|
+
>
|
|
116
|
+
{toasts.map((t) => (
|
|
117
|
+
<div key={t.id} className={cn(toastVariants({ type: t.type }))}>
|
|
118
|
+
{toastIcons[t.type || 'info']}
|
|
119
|
+
<div className="flex-1 space-y-1">
|
|
120
|
+
<h4 className="text-sm font-semibold text-[var(--ui-text-primary)]">{t.title}</h4>
|
|
121
|
+
{t.description && <p className="text-xs text-[var(--ui-text-muted)]">{t.description}</p>}
|
|
122
|
+
</div>
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
onClick={() => dismiss(t.id)}
|
|
126
|
+
aria-label="Dismiss toast"
|
|
127
|
+
className="p-1 rounded text-[var(--ui-text-muted)] hover:text-[var(--ui-text-primary)] hover:bg-[var(--ui-bg-tertiary)] transition-colors"
|
|
128
|
+
>
|
|
129
|
+
<X className="w-3.5 h-3.5" />
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
))}
|
|
133
|
+
</div>
|
|
134
|
+
</Portal>
|
|
135
|
+
</ToastContext.Provider>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import React, { useState, useRef } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
import { Portal } from './Portal';
|
|
4
|
+
import { cn } from '../utils/cn';
|
|
5
|
+
|
|
6
|
+
export const tooltipVariants = cva(
|
|
7
|
+
'z-50 overflow-hidden rounded-[var(--ui-radius-sm)] bg-[var(--ui-bg-primary)] border border-[var(--ui-border-default)] px-2.5 py-1 text-xs font-medium text-[var(--ui-text-primary)] shadow-md animate-in fade-in zoom-in-95 pointer-events-none select-none',
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
placement: {
|
|
11
|
+
top: '-translate-x-1/2 -translate-y-full mb-1.5',
|
|
12
|
+
bottom: '-translate-x-1/2 mt-1.5',
|
|
13
|
+
left: '-translate-x-full -translate-y-1/2 mr-1.5',
|
|
14
|
+
right: 'translate-y-[-50%] ml-1.5',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
placement: 'top',
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export interface TooltipProps extends VariantProps<typeof tooltipVariants> {
|
|
24
|
+
content: React.ReactNode;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
delayDuration?: number;
|
|
27
|
+
className?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function Tooltip({
|
|
31
|
+
content,
|
|
32
|
+
children,
|
|
33
|
+
placement = 'top',
|
|
34
|
+
delayDuration = 200,
|
|
35
|
+
className,
|
|
36
|
+
}: TooltipProps) {
|
|
37
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
38
|
+
const [coords, setCoords] = useState<{ top: number; left: number }>({ top: 0, left: 0 });
|
|
39
|
+
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
40
|
+
const triggerRef = useRef<HTMLDivElement | null>(null);
|
|
41
|
+
|
|
42
|
+
const handleMouseEnter = () => {
|
|
43
|
+
timeoutRef.current = setTimeout(() => {
|
|
44
|
+
if (triggerRef.current) {
|
|
45
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
46
|
+
let top = 0;
|
|
47
|
+
let left = 0;
|
|
48
|
+
|
|
49
|
+
if (placement === 'top') {
|
|
50
|
+
top = rect.top + window.scrollY;
|
|
51
|
+
left = rect.left + rect.width / 2 + window.scrollX;
|
|
52
|
+
} else if (placement === 'bottom') {
|
|
53
|
+
top = rect.bottom + window.scrollY;
|
|
54
|
+
left = rect.left + rect.width / 2 + window.scrollX;
|
|
55
|
+
} else if (placement === 'left') {
|
|
56
|
+
top = rect.top + rect.height / 2 + window.scrollY;
|
|
57
|
+
left = rect.left + window.scrollX;
|
|
58
|
+
} else if (placement === 'right') {
|
|
59
|
+
top = rect.top + rect.height / 2 + window.scrollY;
|
|
60
|
+
left = rect.right + window.scrollX;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
setCoords({ top, left });
|
|
64
|
+
setIsVisible(true);
|
|
65
|
+
}
|
|
66
|
+
}, delayDuration);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const handleMouseLeave = () => {
|
|
70
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
71
|
+
setIsVisible(false);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<div
|
|
77
|
+
ref={triggerRef}
|
|
78
|
+
onMouseEnter={handleMouseEnter}
|
|
79
|
+
onMouseLeave={handleMouseLeave}
|
|
80
|
+
onFocus={handleMouseEnter}
|
|
81
|
+
onBlur={handleMouseLeave}
|
|
82
|
+
className="inline-flex cursor-pointer"
|
|
83
|
+
>
|
|
84
|
+
{children}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
{isVisible && (
|
|
88
|
+
<Portal>
|
|
89
|
+
<div
|
|
90
|
+
style={{ top: `${coords.top}px`, left: `${coords.left}px`, position: 'absolute' }}
|
|
91
|
+
role="tooltip"
|
|
92
|
+
className={cn(tooltipVariants({ placement }), className)}
|
|
93
|
+
>
|
|
94
|
+
{content}
|
|
95
|
+
</div>
|
|
96
|
+
</Portal>
|
|
97
|
+
)}
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './Portal';
|
|
2
|
+
export * from './FocusTrap';
|
|
3
|
+
export * from './Modal';
|
|
4
|
+
export * from './AlertDialog';
|
|
5
|
+
export * from './Drawer';
|
|
6
|
+
export * from './Tooltip';
|
|
7
|
+
export * from './Popover';
|
|
8
|
+
export * from './Toast';
|
|
9
|
+
export * from './BottomSheet';
|
|
10
|
+
export * from './ContextMenu';
|
|
11
|
+
export * from './HoverCard';
|