@vtx-ui/react 0.0.1-beta.1
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/LICENSE +21 -0
- package/README.md +228 -0
- package/dist/components/Accordion/Accordion.d.ts +31 -0
- package/dist/components/Accordion/Accordion.examples.d.ts +3 -0
- package/dist/components/Accordion/AccordionItem.d.ts +5 -0
- package/dist/components/Accordion/index.d.ts +4 -0
- package/dist/components/Accordion/types.d.ts +98 -0
- package/dist/components/Alert/Alert.d.ts +119 -0
- package/dist/components/Alert/index.d.ts +3 -0
- package/dist/components/Avatar/Avatar.d.ts +63 -0
- package/dist/components/Avatar/index.d.ts +3 -0
- package/dist/components/Badge/Badge.d.ts +81 -0
- package/dist/components/Badge/index.d.ts +3 -0
- package/dist/components/Button/Button.d.ts +117 -0
- package/dist/components/Button/index.d.ts +3 -0
- package/dist/components/Card/Card.d.ts +120 -0
- package/dist/components/Card/index.d.ts +3 -0
- package/dist/components/Checkbox/Checkbox.d.ts +114 -0
- package/dist/components/Checkbox/index.d.ts +3 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +121 -0
- package/dist/components/CheckboxGroup/index.d.ts +3 -0
- package/dist/components/Chip/Chip.d.ts +91 -0
- package/dist/components/Chip/index.d.ts +3 -0
- package/dist/components/Divider/Divider.d.ts +118 -0
- package/dist/components/Divider/index.d.ts +3 -0
- package/dist/components/Flex/Flex.d.ts +66 -0
- package/dist/components/Flex/index.d.ts +3 -0
- package/dist/components/Grid/Grid.d.ts +156 -0
- package/dist/components/Grid/index.d.ts +3 -0
- package/dist/components/Header/Header.d.ts +138 -0
- package/dist/components/Header/index.d.ts +3 -0
- package/dist/components/Input/Input.d.ts +129 -0
- package/dist/components/Input/index.d.ts +3 -0
- package/dist/components/Menu/Menu.d.ts +114 -0
- package/dist/components/Menu/index.d.ts +4 -0
- package/dist/components/Modal/Modal.d.ts +201 -0
- package/dist/components/Modal/index.d.ts +3 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +190 -0
- package/dist/components/MultiSelect/index.d.ts +3 -0
- package/dist/components/Radio/Radio.d.ts +105 -0
- package/dist/components/Radio/index.d.ts +3 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +134 -0
- package/dist/components/RadioGroup/index.d.ts +3 -0
- package/dist/components/Select/Select.d.ts +169 -0
- package/dist/components/Select/index.d.ts +3 -0
- package/dist/components/SideMenu/SideMenu.d.ts +118 -0
- package/dist/components/SideMenu/index.d.ts +4 -0
- package/dist/components/Table/Table.d.ts +211 -0
- package/dist/components/Table/index.d.ts +3 -0
- package/dist/components/Text/Text.d.ts +160 -0
- package/dist/components/Text/index.d.ts +3 -0
- package/dist/components/Toast/Toast.d.ts +56 -0
- package/dist/components/Toast/ToastContainer.d.ts +6 -0
- package/dist/components/Toast/index.d.ts +5 -0
- package/dist/components/Toast/types.d.ts +148 -0
- package/dist/components/Toast/useToast.d.ts +34 -0
- package/dist/components/Tooltip/Tooltip.d.ts +108 -0
- package/dist/components/Tooltip/index.d.ts +3 -0
- package/dist/hooks/index.d.ts +85 -0
- package/dist/hooks/useTheme.d.ts +268 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +55 -0
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/theme/ThemeProvider.d.ts +39 -0
- package/dist/theme/cssVariables.d.ts +9 -0
- package/dist/theme/index.d.ts +6 -0
- package/dist/theme/tokens.d.ts +258 -0
- package/dist/types/components/Accordion/Accordion.d.ts +31 -0
- package/dist/types/components/Accordion/Accordion.examples.d.ts +3 -0
- package/dist/types/components/Accordion/AccordionItem.d.ts +5 -0
- package/dist/types/components/Accordion/index.d.ts +4 -0
- package/dist/types/components/Accordion/types.d.ts +98 -0
- package/dist/types/components/Alert/Alert.d.ts +119 -0
- package/dist/types/components/Alert/index.d.ts +3 -0
- package/dist/types/components/Avatar/Avatar.d.ts +63 -0
- package/dist/types/components/Avatar/index.d.ts +3 -0
- package/dist/types/components/Badge/Badge.d.ts +81 -0
- package/dist/types/components/Badge/index.d.ts +3 -0
- package/dist/types/components/Button/Button.d.ts +117 -0
- package/dist/types/components/Button/index.d.ts +3 -0
- package/dist/types/components/Card/Card.d.ts +120 -0
- package/dist/types/components/Card/index.d.ts +3 -0
- package/dist/types/components/Checkbox/Checkbox.d.ts +114 -0
- package/dist/types/components/Checkbox/index.d.ts +3 -0
- package/dist/types/components/CheckboxGroup/CheckboxGroup.d.ts +121 -0
- package/dist/types/components/CheckboxGroup/index.d.ts +3 -0
- package/dist/types/components/Chip/Chip.d.ts +91 -0
- package/dist/types/components/Chip/index.d.ts +3 -0
- package/dist/types/components/Divider/Divider.d.ts +118 -0
- package/dist/types/components/Divider/index.d.ts +3 -0
- package/dist/types/components/Flex/Flex.d.ts +66 -0
- package/dist/types/components/Flex/index.d.ts +3 -0
- package/dist/types/components/Grid/Grid.d.ts +156 -0
- package/dist/types/components/Grid/index.d.ts +3 -0
- package/dist/types/components/Header/Header.d.ts +138 -0
- package/dist/types/components/Header/index.d.ts +3 -0
- package/dist/types/components/Input/Input.d.ts +129 -0
- package/dist/types/components/Input/index.d.ts +3 -0
- package/dist/types/components/Menu/Menu.d.ts +114 -0
- package/dist/types/components/Menu/index.d.ts +4 -0
- package/dist/types/components/Modal/Modal.d.ts +201 -0
- package/dist/types/components/Modal/index.d.ts +3 -0
- package/dist/types/components/MultiSelect/MultiSelect.d.ts +190 -0
- package/dist/types/components/MultiSelect/index.d.ts +3 -0
- package/dist/types/components/Radio/Radio.d.ts +105 -0
- package/dist/types/components/Radio/index.d.ts +3 -0
- package/dist/types/components/RadioGroup/RadioGroup.d.ts +134 -0
- package/dist/types/components/RadioGroup/index.d.ts +3 -0
- package/dist/types/components/Select/Select.d.ts +169 -0
- package/dist/types/components/Select/index.d.ts +3 -0
- package/dist/types/components/SideMenu/SideMenu.d.ts +118 -0
- package/dist/types/components/SideMenu/index.d.ts +4 -0
- package/dist/types/components/Table/Table.d.ts +211 -0
- package/dist/types/components/Table/index.d.ts +3 -0
- package/dist/types/components/Text/Text.d.ts +160 -0
- package/dist/types/components/Text/index.d.ts +3 -0
- package/dist/types/components/Toast/Toast.d.ts +56 -0
- package/dist/types/components/Toast/ToastContainer.d.ts +6 -0
- package/dist/types/components/Toast/index.d.ts +5 -0
- package/dist/types/components/Toast/types.d.ts +148 -0
- package/dist/types/components/Toast/useToast.d.ts +34 -0
- package/dist/types/components/Tooltip/Tooltip.d.ts +108 -0
- package/dist/types/components/Tooltip/index.d.ts +3 -0
- package/dist/types/hooks/index.d.ts +85 -0
- package/dist/types/hooks/useTheme.d.ts +268 -0
- package/dist/types/index.d.ts +55 -0
- package/dist/types/theme/ThemeProvider.d.ts +39 -0
- package/dist/types/theme/cssVariables.d.ts +9 -0
- package/dist/types/theme/index.d.ts +6 -0
- package/dist/types/theme/tokens.d.ts +258 -0
- package/package.json +59 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ToastProps } from './types';
|
|
3
|
+
import './Toast.css';
|
|
4
|
+
/**
|
|
5
|
+
* Toast component - Displays brief notifications to users
|
|
6
|
+
*
|
|
7
|
+
* A comprehensive toast notification component with auto-dismiss, progress bar,
|
|
8
|
+
* pause on hover, and various visual variants for different message types.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* Basic success toast
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Toast variant="success">
|
|
14
|
+
* Your changes have been saved successfully!
|
|
15
|
+
* </Toast>
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* Toast with action button
|
|
20
|
+
* ```tsx
|
|
21
|
+
* <Toast
|
|
22
|
+
* variant="warning"
|
|
23
|
+
* action={<Button size="sm">Undo</Button>}
|
|
24
|
+
* autoClose={false}
|
|
25
|
+
* >
|
|
26
|
+
* Item moved to trash
|
|
27
|
+
* </Toast>
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* Custom toast with icon
|
|
32
|
+
* ```tsx
|
|
33
|
+
* <Toast
|
|
34
|
+
* variant="info"
|
|
35
|
+
* icon={<CustomIcon />}
|
|
36
|
+
* progressBar={false}
|
|
37
|
+
* >
|
|
38
|
+
* Update available for download
|
|
39
|
+
* </Toast>
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* Toast with custom auto-close duration
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <Toast
|
|
46
|
+
* variant="error"
|
|
47
|
+
* autoClose={10000}
|
|
48
|
+
* pauseOnHover={false}
|
|
49
|
+
* >
|
|
50
|
+
* Failed to connect to server
|
|
51
|
+
* </Toast>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare const Toast: React.ForwardRefExoticComponent<ToastProps & React.RefAttributes<HTMLDivElement>>;
|
|
55
|
+
declare const _default: React.FC<ToastProps & React.RefAttributes<HTMLDivElement>>;
|
|
56
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ToastContainerProps } from './types';
|
|
3
|
+
import './ToastContainer.css';
|
|
4
|
+
export declare const ToastContainer: React.FC<ToastContainerProps>;
|
|
5
|
+
declare const _default: React.FC<ToastContainerProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as Toast } from './Toast';
|
|
2
|
+
export { Toast as ToastComponent } from './Toast';
|
|
3
|
+
export { ToastContainer } from './ToastContainer';
|
|
4
|
+
export { useToast, toast } from './useToast';
|
|
5
|
+
export type { ToastProps, ToastVariant, ToastPosition, ToastOptions, ToastInstance } from './types';
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type ToastVariant = 'success' | 'error' | 'warning' | 'info' | 'default' | 'primary';
|
|
3
|
+
export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
4
|
+
export interface ToastOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Auto close duration in milliseconds
|
|
7
|
+
* Set to false to disable auto close
|
|
8
|
+
* @default 5000
|
|
9
|
+
*/
|
|
10
|
+
autoClose?: number | false;
|
|
11
|
+
/**
|
|
12
|
+
* Show close button
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
closeButton?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Show progress bar
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
progressBar?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Pause on hover
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
pauseOnHover?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Pause on focus loss
|
|
28
|
+
* @default true
|
|
29
|
+
*/
|
|
30
|
+
pauseOnFocusLoss?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Toast variant/type
|
|
33
|
+
* @default 'default'
|
|
34
|
+
*/
|
|
35
|
+
variant?: ToastVariant;
|
|
36
|
+
/**
|
|
37
|
+
* Custom icon or false to hide icon
|
|
38
|
+
*/
|
|
39
|
+
icon?: ReactNode | false;
|
|
40
|
+
/**
|
|
41
|
+
* Custom action button
|
|
42
|
+
*/
|
|
43
|
+
action?: {
|
|
44
|
+
label: string;
|
|
45
|
+
onClick: () => void;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Custom className
|
|
49
|
+
*/
|
|
50
|
+
className?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Custom styles
|
|
53
|
+
*/
|
|
54
|
+
style?: React.CSSProperties;
|
|
55
|
+
/**
|
|
56
|
+
* Toast ID for updates/dismissal
|
|
57
|
+
*/
|
|
58
|
+
toastId?: string | number;
|
|
59
|
+
/**
|
|
60
|
+
* Callback when toast is closed
|
|
61
|
+
*/
|
|
62
|
+
onClose?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Callback when toast is opened
|
|
65
|
+
*/
|
|
66
|
+
onOpen?: () => void;
|
|
67
|
+
/**
|
|
68
|
+
* Rich content with title and description
|
|
69
|
+
*/
|
|
70
|
+
title?: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Animation duration in milliseconds
|
|
74
|
+
* @default 300
|
|
75
|
+
*/
|
|
76
|
+
animationDuration?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface ToastProps extends ToastOptions {
|
|
79
|
+
/**
|
|
80
|
+
* Toast content
|
|
81
|
+
*/
|
|
82
|
+
children: ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Whether toast is visible
|
|
85
|
+
*/
|
|
86
|
+
isVisible: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Function to close the toast
|
|
89
|
+
*/
|
|
90
|
+
onDismiss: () => void;
|
|
91
|
+
/**
|
|
92
|
+
* Unique toast ID
|
|
93
|
+
*/
|
|
94
|
+
id: string | number;
|
|
95
|
+
/**
|
|
96
|
+
* Creation timestamp
|
|
97
|
+
*/
|
|
98
|
+
createdAt: number;
|
|
99
|
+
}
|
|
100
|
+
export interface ToastContainerProps {
|
|
101
|
+
/**
|
|
102
|
+
* Children components to render alongside the toast container
|
|
103
|
+
*/
|
|
104
|
+
children?: ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* Container position
|
|
107
|
+
* @default 'top-right'
|
|
108
|
+
*/
|
|
109
|
+
position?: ToastPosition;
|
|
110
|
+
/**
|
|
111
|
+
* Maximum number of toasts to show
|
|
112
|
+
* @default 5
|
|
113
|
+
*/
|
|
114
|
+
limit?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Gap between toasts in pixels
|
|
117
|
+
* @default 12
|
|
118
|
+
*/
|
|
119
|
+
gap?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Container margin from viewport edge
|
|
122
|
+
* @default 16
|
|
123
|
+
*/
|
|
124
|
+
margin?: number;
|
|
125
|
+
/**
|
|
126
|
+
* Custom className for container
|
|
127
|
+
*/
|
|
128
|
+
className?: string;
|
|
129
|
+
/**
|
|
130
|
+
* Custom styles for container
|
|
131
|
+
*/
|
|
132
|
+
style?: React.CSSProperties;
|
|
133
|
+
/**
|
|
134
|
+
* Enable stacked layout for mobile
|
|
135
|
+
* @default true
|
|
136
|
+
*/
|
|
137
|
+
stacked?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Custom theme
|
|
140
|
+
*/
|
|
141
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
142
|
+
}
|
|
143
|
+
export interface ToastInstance extends ToastOptions {
|
|
144
|
+
id: string | number;
|
|
145
|
+
content: ReactNode;
|
|
146
|
+
createdAt: number;
|
|
147
|
+
isVisible: boolean;
|
|
148
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { ToastInstance, ToastOptions } from './types';
|
|
3
|
+
interface ToastContextValue {
|
|
4
|
+
toasts: ToastInstance[];
|
|
5
|
+
addToast: (content: ReactNode, options?: ToastOptions) => string | number;
|
|
6
|
+
removeToast: (id: string | number) => void;
|
|
7
|
+
clearAllToasts: () => void;
|
|
8
|
+
updateToast: (id: string | number, options: Partial<ToastOptions>) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const useToast: () => ToastContextValue;
|
|
11
|
+
interface ToastProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare const ToastProvider: React.FC<ToastProviderProps>;
|
|
15
|
+
declare class ToastManager {
|
|
16
|
+
private static instance;
|
|
17
|
+
private addToastFn;
|
|
18
|
+
private removeToastFn;
|
|
19
|
+
private clearAllToastsFn;
|
|
20
|
+
private updateToastFn;
|
|
21
|
+
static getInstance(): ToastManager;
|
|
22
|
+
setMethods(addToast: (content: ReactNode, options?: ToastOptions) => string | number, removeToast: (id: string | number) => void, clearAllToasts: () => void, updateToast: (id: string | number, options: Partial<ToastOptions>) => void): void;
|
|
23
|
+
show(content: ReactNode, options?: ToastOptions): string | number;
|
|
24
|
+
success(content: ReactNode, options?: Omit<ToastOptions, 'variant'>): string | number;
|
|
25
|
+
error(content: ReactNode, options?: Omit<ToastOptions, 'variant'>): string | number;
|
|
26
|
+
warning(content: ReactNode, options?: Omit<ToastOptions, 'variant'>): string | number;
|
|
27
|
+
info(content: ReactNode, options?: Omit<ToastOptions, 'variant'>): string | number;
|
|
28
|
+
primary(content: ReactNode, options?: Omit<ToastOptions, 'variant'>): string | number;
|
|
29
|
+
dismiss(id: string | number): void;
|
|
30
|
+
dismissAll(): void;
|
|
31
|
+
update(id: string | number, options: Partial<ToastOptions>): void;
|
|
32
|
+
}
|
|
33
|
+
export declare const toast: ToastManager;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import './Tooltip.css';
|
|
3
|
+
export interface TooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'content'> {
|
|
4
|
+
/**
|
|
5
|
+
* Content to display in the tooltip
|
|
6
|
+
* Can be text, JSX, or any React node
|
|
7
|
+
*/
|
|
8
|
+
content: React.ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* Placement of the tooltip relative to the trigger element
|
|
11
|
+
* @default 'top'
|
|
12
|
+
*/
|
|
13
|
+
placement?: 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end';
|
|
14
|
+
/**
|
|
15
|
+
* Delay before showing tooltip in milliseconds
|
|
16
|
+
* @default 200
|
|
17
|
+
*/
|
|
18
|
+
delay?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Delay before hiding tooltip in milliseconds
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
hideDelay?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Element that triggers the tooltip
|
|
26
|
+
*/
|
|
27
|
+
children: React.ReactElement<any>;
|
|
28
|
+
/**
|
|
29
|
+
* If true, tooltip is always visible
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
open?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* If true, tooltip is disabled and won't show
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* If true, shows an arrow pointing to the trigger element
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
arrow?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Maximum width of the tooltip
|
|
45
|
+
* @default '300px'
|
|
46
|
+
*/
|
|
47
|
+
maxWidth?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Tooltip variant for different visual styles
|
|
50
|
+
* @default 'dark'
|
|
51
|
+
*/
|
|
52
|
+
variant?: 'dark' | 'light' | 'error' | 'warning' | 'success' | 'info';
|
|
53
|
+
/**
|
|
54
|
+
* If true, shows a close button to manually dismiss the tooltip
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
dismissible?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Callback fired when tooltip is shown
|
|
60
|
+
*/
|
|
61
|
+
onShow?: () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Callback fired when tooltip is hidden
|
|
64
|
+
*/
|
|
65
|
+
onHide?: () => void;
|
|
66
|
+
/**
|
|
67
|
+
* Callback fired when dismiss button is clicked
|
|
68
|
+
*/
|
|
69
|
+
onDismiss?: () => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Tooltip component - Displays helpful information on hover or focus
|
|
73
|
+
*
|
|
74
|
+
* A feature-rich tooltip component with multiple placement options, variants,
|
|
75
|
+
* customizable delays, and arrow indicators.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* Basic usage
|
|
79
|
+
* ```tsx
|
|
80
|
+
* <Tooltip content="Click to save changes" placement="top">
|
|
81
|
+
* <Button>Save</Button>
|
|
82
|
+
* </Tooltip>
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* With arrow and variant
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <Tooltip
|
|
89
|
+
* content="This action cannot be undone"
|
|
90
|
+
* placement="right"
|
|
91
|
+
* variant="warning"
|
|
92
|
+
* arrow
|
|
93
|
+
* >
|
|
94
|
+
* <Button variant="danger">Delete</Button>
|
|
95
|
+
* </Tooltip>
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* Always visible
|
|
100
|
+
* ```tsx
|
|
101
|
+
* <Tooltip content="Important information" open>
|
|
102
|
+
* <span>Hover target</span>
|
|
103
|
+
* </Tooltip>
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export declare const Tooltip: React.ForwardRefExoticComponent<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
107
|
+
declare const _default: React.FC<TooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
108
|
+
export default _default;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to handle click events outside of a specified element
|
|
4
|
+
*
|
|
5
|
+
* @param ref - Reference to the element to detect clicks outside of
|
|
6
|
+
* @param handler - Callback function to execute when clicking outside
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* function Dropdown() {
|
|
11
|
+
* const ref = useRef<HTMLDivElement>(null);
|
|
12
|
+
* const [isOpen, setIsOpen] = useState(false);
|
|
13
|
+
*
|
|
14
|
+
* useClickOutside(ref, () => setIsOpen(false));
|
|
15
|
+
*
|
|
16
|
+
* return <div ref={ref}>Dropdown content</div>;
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const useClickOutside: <T extends HTMLElement = HTMLElement>(ref: RefObject<T>, handler: (event: MouseEvent | TouchEvent) => void) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Hook to manage focus trap within a component (useful for modals, dialogs)
|
|
23
|
+
*
|
|
24
|
+
* @param ref - Reference to the container element
|
|
25
|
+
* @param isActive - Whether the focus trap is active
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* function Modal({ isOpen }) {
|
|
30
|
+
* const ref = useRef<HTMLDivElement>(null);
|
|
31
|
+
* useFocusTrap(ref, isOpen);
|
|
32
|
+
* return <div ref={ref}>Modal content</div>;
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare const useFocusTrap: <T extends HTMLElement = HTMLElement>(ref: RefObject<T>, isActive: boolean) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Hook to handle escape key press
|
|
39
|
+
*
|
|
40
|
+
* @param handler - Callback function to execute when escape is pressed
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```tsx
|
|
44
|
+
* function Modal({ onClose }) {
|
|
45
|
+
* useEscapeKey(onClose);
|
|
46
|
+
* return <div>Modal content</div>;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare const useEscapeKey: (handler: () => void) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Hook to manage body scroll lock (useful for modals)
|
|
53
|
+
*
|
|
54
|
+
* @param isLocked - Whether to lock the body scroll
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```tsx
|
|
58
|
+
* function Modal({ isOpen }) {
|
|
59
|
+
* useBodyScrollLock(isOpen);
|
|
60
|
+
* return <div>Modal content</div>;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare const useBodyScrollLock: (isLocked: boolean) => void;
|
|
65
|
+
export declare const useId: (prefix?: string) => string;
|
|
66
|
+
/**
|
|
67
|
+
* Hook to debounce a value
|
|
68
|
+
*
|
|
69
|
+
* @param value - Value to debounce
|
|
70
|
+
* @param delay - Delay in milliseconds
|
|
71
|
+
* @returns Debounced value
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```tsx
|
|
75
|
+
* function SearchInput() {
|
|
76
|
+
* const [search, setSearch] = useState('');
|
|
77
|
+
* const debouncedSearch = useDebounce(search, 300);
|
|
78
|
+
*
|
|
79
|
+
* useEffect(() => {
|
|
80
|
+
* // API call with debouncedSearch
|
|
81
|
+
* }, [debouncedSearch]);
|
|
82
|
+
* }
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export declare const useDebounce: <T>(value: T, delay: number) => T;
|