@lp-labs/ui-components 0.0.0-stage → 1.0.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/CHANGELOG.md +41 -0
- package/LICENSE +21 -0
- package/README.md +256 -2
- package/dist/cjs/components/Accordion.d.ts +78 -0
- package/dist/cjs/components/Accordion.js +78 -0
- package/dist/cjs/components/AdvancedComponents.d.ts +353 -0
- package/dist/cjs/components/AdvancedComponents.js +353 -0
- package/dist/cjs/components/Alert.d.ts +102 -0
- package/dist/cjs/components/Alert.js +102 -0
- package/dist/cjs/components/Avatar.d.ts +89 -0
- package/dist/cjs/components/Avatar.js +89 -0
- package/dist/cjs/components/Badge.d.ts +57 -0
- package/dist/cjs/components/Badge.js +57 -0
- package/dist/cjs/components/Breadcrumb.d.ts +50 -0
- package/dist/cjs/components/Breadcrumb.js +50 -0
- package/dist/cjs/components/Button.d.ts +77 -0
- package/dist/cjs/components/Button.js +77 -0
- package/dist/cjs/components/ButtonVariants.d.ts +261 -0
- package/dist/cjs/components/ButtonVariants.js +261 -0
- package/dist/cjs/components/Card.d.ts +56 -0
- package/dist/cjs/components/Card.js +56 -0
- package/dist/cjs/components/CardVariants.d.ts +267 -0
- package/dist/cjs/components/CardVariants.js +267 -0
- package/dist/cjs/components/Checkbox.d.ts +50 -0
- package/dist/cjs/components/Checkbox.js +50 -0
- package/dist/cjs/components/Chip.d.ts +104 -0
- package/dist/cjs/components/Chip.js +104 -0
- package/dist/cjs/components/DataDisplayComponents.d.ts +275 -0
- package/dist/cjs/components/DataDisplayComponents.js +275 -0
- package/dist/cjs/components/Divider.d.ts +77 -0
- package/dist/cjs/components/Divider.js +77 -0
- package/dist/cjs/components/Drawer.d.ts +142 -0
- package/dist/cjs/components/Drawer.js +142 -0
- package/dist/cjs/components/Dropdown.d.ts +139 -0
- package/dist/cjs/components/Dropdown.js +139 -0
- package/dist/cjs/components/Form.d.ts +41 -0
- package/dist/cjs/components/Form.js +41 -0
- package/dist/cjs/components/FormGroup.d.ts +58 -0
- package/dist/cjs/components/FormGroup.js +58 -0
- package/dist/cjs/components/FormInputVariants.d.ts +298 -0
- package/dist/cjs/components/FormInputVariants.js +298 -0
- package/dist/cjs/components/Image.d.ts +106 -0
- package/dist/cjs/components/Image.js +106 -0
- package/dist/cjs/components/Input.d.ts +65 -0
- package/dist/cjs/components/Input.js +65 -0
- package/dist/cjs/components/LayoutComponents.d.ts +258 -0
- package/dist/cjs/components/LayoutComponents.js +258 -0
- package/dist/cjs/components/Link.d.ts +71 -0
- package/dist/cjs/components/Link.js +71 -0
- package/dist/cjs/components/LoadingFeedbackComponents.d.ts +230 -0
- package/dist/cjs/components/LoadingFeedbackComponents.js +230 -0
- package/dist/cjs/components/Menu.d.ts +167 -0
- package/dist/cjs/components/Menu.js +167 -0
- package/dist/cjs/components/Modal.d.ts +145 -0
- package/dist/cjs/components/Modal.js +145 -0
- package/dist/cjs/components/ModalTypes.d.ts +288 -0
- package/dist/cjs/components/ModalTypes.js +288 -0
- package/dist/cjs/components/Navbar.d.ts +181 -0
- package/dist/cjs/components/Navbar.js +181 -0
- package/dist/cjs/components/NavigationComponents.d.ts +276 -0
- package/dist/cjs/components/NavigationComponents.js +276 -0
- package/dist/cjs/components/Pagination.d.ts +94 -0
- package/dist/cjs/components/Pagination.js +94 -0
- package/dist/cjs/components/Popover.d.ts +108 -0
- package/dist/cjs/components/Popover.js +108 -0
- package/dist/cjs/components/Progress.d.ts +68 -0
- package/dist/cjs/components/Progress.js +68 -0
- package/dist/cjs/components/Radio.d.ts +93 -0
- package/dist/cjs/components/Radio.js +93 -0
- package/dist/cjs/components/Rating.d.ts +82 -0
- package/dist/cjs/components/Rating.js +82 -0
- package/dist/cjs/components/Select.d.ts +74 -0
- package/dist/cjs/components/Select.js +74 -0
- package/dist/cjs/components/Sidebar.d.ts +174 -0
- package/dist/cjs/components/Sidebar.js +174 -0
- package/dist/cjs/components/Skeleton.d.ts +57 -0
- package/dist/cjs/components/Skeleton.js +57 -0
- package/dist/cjs/components/Slider.d.ts +64 -0
- package/dist/cjs/components/Slider.js +64 -0
- package/dist/cjs/components/Spinner.d.ts +70 -0
- package/dist/cjs/components/Spinner.js +70 -0
- package/dist/cjs/components/Stack.d.ts +75 -0
- package/dist/cjs/components/Stack.js +75 -0
- package/dist/cjs/components/Stepper.d.ts +150 -0
- package/dist/cjs/components/Stepper.js +150 -0
- package/dist/cjs/components/Table.d.ts +173 -0
- package/dist/cjs/components/Table.js +173 -0
- package/dist/cjs/components/Tabs.d.ts +104 -0
- package/dist/cjs/components/Tabs.js +104 -0
- package/dist/cjs/components/Tag.d.ts +74 -0
- package/dist/cjs/components/Tag.js +74 -0
- package/dist/cjs/components/Textarea.d.ts +75 -0
- package/dist/cjs/components/Textarea.js +75 -0
- package/dist/cjs/components/Timeline.d.ts +124 -0
- package/dist/cjs/components/Timeline.js +124 -0
- package/dist/cjs/components/Toast.d.ts +155 -0
- package/dist/cjs/components/Toast.js +155 -0
- package/dist/cjs/components/Toggle.d.ts +75 -0
- package/dist/cjs/components/Toggle.js +75 -0
- package/dist/cjs/components/Tooltip.d.ts +80 -0
- package/dist/cjs/components/Tooltip.js +80 -0
- package/dist/cjs/components/TypographyComponents.d.ts +265 -0
- package/dist/cjs/components/TypographyComponents.js +265 -0
- package/dist/cjs/components/UtilityComponents.d.ts +345 -0
- package/dist/cjs/components/UtilityComponents.js +345 -0
- package/dist/cjs/components/Video.d.ts +82 -0
- package/dist/cjs/components/Video.js +82 -0
- package/dist/cjs/components/index.d.ts +311 -0
- package/dist/cjs/components/index.js +311 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/styles/main.css +493 -0
- package/dist/cjs/theme/ThemeProvider.d.ts +185 -0
- package/dist/cjs/theme/ThemeProvider.js +185 -0
- package/dist/cjs/theme/index.d.ts +2 -0
- package/dist/cjs/theme/index.js +2 -0
- package/dist/cjs/utilities/classNames.d.ts +200 -0
- package/dist/cjs/utilities/classNames.js +200 -0
- package/dist/cjs/utilities/index.d.ts +3 -0
- package/dist/cjs/utilities/index.js +3 -0
- package/dist/cjs/utilities/styles.d.ts +94 -0
- package/dist/cjs/utilities/styles.js +94 -0
- package/dist/esm/components/Accordion.d.ts +78 -0
- package/dist/esm/components/Accordion.js +78 -0
- package/dist/esm/components/AdvancedComponents.d.ts +353 -0
- package/dist/esm/components/AdvancedComponents.js +353 -0
- package/dist/esm/components/Alert.d.ts +102 -0
- package/dist/esm/components/Alert.js +102 -0
- package/dist/esm/components/Avatar.d.ts +89 -0
- package/dist/esm/components/Avatar.js +89 -0
- package/dist/esm/components/Badge.d.ts +57 -0
- package/dist/esm/components/Badge.js +57 -0
- package/dist/esm/components/Breadcrumb.d.ts +50 -0
- package/dist/esm/components/Breadcrumb.js +50 -0
- package/dist/esm/components/Button.d.ts +77 -0
- package/dist/esm/components/Button.js +77 -0
- package/dist/esm/components/ButtonVariants.d.ts +261 -0
- package/dist/esm/components/ButtonVariants.js +261 -0
- package/dist/esm/components/Card.d.ts +56 -0
- package/dist/esm/components/Card.js +56 -0
- package/dist/esm/components/CardVariants.d.ts +267 -0
- package/dist/esm/components/CardVariants.js +267 -0
- package/dist/esm/components/Checkbox.d.ts +50 -0
- package/dist/esm/components/Checkbox.js +50 -0
- package/dist/esm/components/Chip.d.ts +104 -0
- package/dist/esm/components/Chip.js +104 -0
- package/dist/esm/components/DataDisplayComponents.d.ts +275 -0
- package/dist/esm/components/DataDisplayComponents.js +275 -0
- package/dist/esm/components/Divider.d.ts +77 -0
- package/dist/esm/components/Divider.js +77 -0
- package/dist/esm/components/Drawer.d.ts +142 -0
- package/dist/esm/components/Drawer.js +142 -0
- package/dist/esm/components/Dropdown.d.ts +139 -0
- package/dist/esm/components/Dropdown.js +139 -0
- package/dist/esm/components/Form.d.ts +41 -0
- package/dist/esm/components/Form.js +41 -0
- package/dist/esm/components/FormGroup.d.ts +58 -0
- package/dist/esm/components/FormGroup.js +58 -0
- package/dist/esm/components/FormInputVariants.d.ts +298 -0
- package/dist/esm/components/FormInputVariants.js +298 -0
- package/dist/esm/components/Image.d.ts +106 -0
- package/dist/esm/components/Image.js +106 -0
- package/dist/esm/components/Input.d.ts +65 -0
- package/dist/esm/components/Input.js +65 -0
- package/dist/esm/components/LayoutComponents.d.ts +258 -0
- package/dist/esm/components/LayoutComponents.js +258 -0
- package/dist/esm/components/Link.d.ts +71 -0
- package/dist/esm/components/Link.js +71 -0
- package/dist/esm/components/LoadingFeedbackComponents.d.ts +230 -0
- package/dist/esm/components/LoadingFeedbackComponents.js +230 -0
- package/dist/esm/components/Menu.d.ts +167 -0
- package/dist/esm/components/Menu.js +167 -0
- package/dist/esm/components/Modal.d.ts +145 -0
- package/dist/esm/components/Modal.js +145 -0
- package/dist/esm/components/ModalTypes.d.ts +288 -0
- package/dist/esm/components/ModalTypes.js +288 -0
- package/dist/esm/components/Navbar.d.ts +181 -0
- package/dist/esm/components/Navbar.js +181 -0
- package/dist/esm/components/NavigationComponents.d.ts +276 -0
- package/dist/esm/components/NavigationComponents.js +276 -0
- package/dist/esm/components/Pagination.d.ts +94 -0
- package/dist/esm/components/Pagination.js +94 -0
- package/dist/esm/components/Popover.d.ts +108 -0
- package/dist/esm/components/Popover.js +108 -0
- package/dist/esm/components/Progress.d.ts +68 -0
- package/dist/esm/components/Progress.js +68 -0
- package/dist/esm/components/Radio.d.ts +93 -0
- package/dist/esm/components/Radio.js +93 -0
- package/dist/esm/components/Rating.d.ts +82 -0
- package/dist/esm/components/Rating.js +82 -0
- package/dist/esm/components/Select.d.ts +74 -0
- package/dist/esm/components/Select.js +74 -0
- package/dist/esm/components/Sidebar.d.ts +174 -0
- package/dist/esm/components/Sidebar.js +174 -0
- package/dist/esm/components/Skeleton.d.ts +57 -0
- package/dist/esm/components/Skeleton.js +57 -0
- package/dist/esm/components/Slider.d.ts +64 -0
- package/dist/esm/components/Slider.js +64 -0
- package/dist/esm/components/Spinner.d.ts +70 -0
- package/dist/esm/components/Spinner.js +70 -0
- package/dist/esm/components/Stack.d.ts +75 -0
- package/dist/esm/components/Stack.js +75 -0
- package/dist/esm/components/Stepper.d.ts +150 -0
- package/dist/esm/components/Stepper.js +150 -0
- package/dist/esm/components/Table.d.ts +173 -0
- package/dist/esm/components/Table.js +173 -0
- package/dist/esm/components/Tabs.d.ts +104 -0
- package/dist/esm/components/Tabs.js +104 -0
- package/dist/esm/components/Tag.d.ts +74 -0
- package/dist/esm/components/Tag.js +74 -0
- package/dist/esm/components/Textarea.d.ts +75 -0
- package/dist/esm/components/Textarea.js +75 -0
- package/dist/esm/components/Timeline.d.ts +124 -0
- package/dist/esm/components/Timeline.js +124 -0
- package/dist/esm/components/Toast.d.ts +155 -0
- package/dist/esm/components/Toast.js +155 -0
- package/dist/esm/components/Toggle.d.ts +75 -0
- package/dist/esm/components/Toggle.js +75 -0
- package/dist/esm/components/Tooltip.d.ts +80 -0
- package/dist/esm/components/Tooltip.js +80 -0
- package/dist/esm/components/TypographyComponents.d.ts +265 -0
- package/dist/esm/components/TypographyComponents.js +265 -0
- package/dist/esm/components/UtilityComponents.d.ts +345 -0
- package/dist/esm/components/UtilityComponents.js +345 -0
- package/dist/esm/components/Video.d.ts +82 -0
- package/dist/esm/components/Video.js +82 -0
- package/dist/esm/components/index.d.ts +311 -0
- package/dist/esm/components/index.js +311 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/styles/main.css +493 -0
- package/dist/esm/theme/ThemeProvider.d.ts +185 -0
- package/dist/esm/theme/ThemeProvider.js +185 -0
- package/dist/esm/theme/index.d.ts +2 -0
- package/dist/esm/theme/index.js +2 -0
- package/dist/esm/utilities/classNames.d.ts +200 -0
- package/dist/esm/utilities/classNames.js +200 -0
- package/dist/esm/utilities/index.d.ts +3 -0
- package/dist/esm/utilities/index.js +3 -0
- package/dist/esm/utilities/styles.d.ts +94 -0
- package/dist/esm/utilities/styles.js +94 -0
- package/dist/styles/main.css +493 -0
- package/package.json +124 -6
- package/src/styles/main.css +493 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface UtilityComponentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const Tooltip: React.FC<
|
|
8
|
+
UtilityComponentProps & {
|
|
9
|
+
content: string;
|
|
10
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
11
|
+
}
|
|
12
|
+
> = ({
|
|
13
|
+
content,
|
|
14
|
+
position = 'top',
|
|
15
|
+
className = '',
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
const [visible, setVisible] = React.useState(false);
|
|
20
|
+
|
|
21
|
+
const positionClass = {
|
|
22
|
+
top: 'bottom-full mb-2',
|
|
23
|
+
bottom: 'top-full mt-2',
|
|
24
|
+
left: 'right-full mr-2',
|
|
25
|
+
right: 'left-full ml-2',
|
|
26
|
+
}[position];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className="relative inline-block"
|
|
31
|
+
onMouseEnter={() => setVisible(true)}
|
|
32
|
+
onMouseLeave={() => setVisible(false)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
{visible && (
|
|
37
|
+
<div
|
|
38
|
+
className={`absolute ${positionClass} bg-gray-900 text-white text-sm px-2 py-1 rounded whitespace-nowrap z-50`}
|
|
39
|
+
>
|
|
40
|
+
{content}
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Popover: React.FC<
|
|
48
|
+
UtilityComponentProps & {
|
|
49
|
+
trigger: React.ReactNode;
|
|
50
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
51
|
+
}
|
|
52
|
+
> = ({
|
|
53
|
+
trigger,
|
|
54
|
+
position = 'bottom',
|
|
55
|
+
className = '',
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}) => {
|
|
59
|
+
const [open, setOpen] = React.useState(false);
|
|
60
|
+
|
|
61
|
+
const positionClass = {
|
|
62
|
+
top: 'bottom-full mb-2',
|
|
63
|
+
bottom: 'top-full mt-2',
|
|
64
|
+
left: 'right-full mr-2',
|
|
65
|
+
right: 'left-full ml-2',
|
|
66
|
+
}[position];
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className="relative inline-block" {...props}>
|
|
70
|
+
<button onClick={() => setOpen(!open)} className="cursor-pointer">
|
|
71
|
+
{trigger}
|
|
72
|
+
</button>
|
|
73
|
+
{open && (
|
|
74
|
+
<div className={`absolute ${positionClass} bg-white border border-gray-200 rounded-lg shadow-lg p-4 z-50 min-w-max`}>
|
|
75
|
+
{children}
|
|
76
|
+
</div>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const ContextMenu: React.FC<
|
|
83
|
+
UtilityComponentProps & {
|
|
84
|
+
items: Array<{ label: string; onClick: () => void; icon?: React.ReactNode }>;
|
|
85
|
+
}
|
|
86
|
+
> = ({
|
|
87
|
+
items,
|
|
88
|
+
className = '',
|
|
89
|
+
children,
|
|
90
|
+
...props
|
|
91
|
+
}) => {
|
|
92
|
+
const [position, setPosition] = React.useState<{ x: number; y: number } | null>(null);
|
|
93
|
+
|
|
94
|
+
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
setPosition({ x: e.clientX, y: e.clientY });
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleClose = () => setPosition(null);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div onContextMenu={handleContextMenu} className={className} {...props}>
|
|
103
|
+
{children}
|
|
104
|
+
{position && (
|
|
105
|
+
<>
|
|
106
|
+
<div className="fixed inset-0 z-40" onClick={handleClose}></div>
|
|
107
|
+
<div
|
|
108
|
+
className="fixed bg-white border border-gray-200 rounded-lg shadow-lg z-50"
|
|
109
|
+
style={{ top: position.y, left: position.x }}
|
|
110
|
+
>
|
|
111
|
+
{items.map((item, idx) => (
|
|
112
|
+
<button
|
|
113
|
+
key={idx}
|
|
114
|
+
onClick={() => {
|
|
115
|
+
item.onClick();
|
|
116
|
+
handleClose();
|
|
117
|
+
}}
|
|
118
|
+
className="w-full text-left px-4 py-2 hover:bg-gray-100 flex items-center gap-2 text-sm"
|
|
119
|
+
>
|
|
120
|
+
{item.icon}
|
|
121
|
+
{item.label}
|
|
122
|
+
</button>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
</>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const Notification: React.FC<
|
|
132
|
+
UtilityComponentProps & {
|
|
133
|
+
type?: 'info' | 'success' | 'warning' | 'error';
|
|
134
|
+
title?: string;
|
|
135
|
+
onClose?: () => void;
|
|
136
|
+
}
|
|
137
|
+
> = ({
|
|
138
|
+
type = 'info',
|
|
139
|
+
title,
|
|
140
|
+
onClose,
|
|
141
|
+
className = '',
|
|
142
|
+
children,
|
|
143
|
+
...props
|
|
144
|
+
}) => {
|
|
145
|
+
const bgClass = {
|
|
146
|
+
info: 'bg-blue-50 border-blue-200',
|
|
147
|
+
success: 'bg-green-50 border-green-200',
|
|
148
|
+
warning: 'bg-yellow-50 border-yellow-200',
|
|
149
|
+
error: 'bg-red-50 border-red-200',
|
|
150
|
+
}[type];
|
|
151
|
+
|
|
152
|
+
const iconClass = {
|
|
153
|
+
info: '🔵',
|
|
154
|
+
success: '✅',
|
|
155
|
+
warning: '⚠️',
|
|
156
|
+
error: '❌',
|
|
157
|
+
}[type];
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div className={`border-l-4 ${bgClass} p-4 rounded-md flex gap-3 ${className}`} {...props}>
|
|
161
|
+
<span className="text-xl">{iconClass}</span>
|
|
162
|
+
<div className="flex-1">
|
|
163
|
+
{title && <h4 className="font-semibold">{title}</h4>}
|
|
164
|
+
<p>{children}</p>
|
|
165
|
+
</div>
|
|
166
|
+
{onClose && (
|
|
167
|
+
<button onClick={onClose} className="text-gray-500 hover:text-gray-700">
|
|
168
|
+
✕
|
|
169
|
+
</button>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const Badge: React.FC<
|
|
176
|
+
UtilityComponentProps & {
|
|
177
|
+
variant?: 'solid' | 'outline' | 'dot';
|
|
178
|
+
color?: 'blue' | 'green' | 'red' | 'yellow' | 'gray';
|
|
179
|
+
count?: number | string;
|
|
180
|
+
}
|
|
181
|
+
> = ({
|
|
182
|
+
variant = 'solid',
|
|
183
|
+
color = 'blue',
|
|
184
|
+
count,
|
|
185
|
+
className = '',
|
|
186
|
+
children,
|
|
187
|
+
...props
|
|
188
|
+
}) => {
|
|
189
|
+
const colorClass = {
|
|
190
|
+
blue: 'bg-blue-600 text-white',
|
|
191
|
+
green: 'bg-green-600 text-white',
|
|
192
|
+
red: 'bg-red-600 text-white',
|
|
193
|
+
yellow: 'bg-yellow-600 text-white',
|
|
194
|
+
gray: 'bg-gray-600 text-white',
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const variantClass = {
|
|
198
|
+
solid: colorClass[color],
|
|
199
|
+
outline: `border-2 border-${color}-600 text-${color}-600`,
|
|
200
|
+
dot: `w-3 h-3 bg-${color}-600 rounded-full`,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div className="relative inline-block" {...props}>
|
|
205
|
+
{children}
|
|
206
|
+
{count && (
|
|
207
|
+
<span className={`absolute -top-2 -right-2 px-2 py-1 rounded-full text-xs font-semibold ${variantClass[variant]} ${className}`}>
|
|
208
|
+
{count}
|
|
209
|
+
</span>
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const Pill: React.FC<UtilityComponentProps & { onRemove?: () => void; color?: string }> = ({
|
|
216
|
+
onRemove,
|
|
217
|
+
color = 'blue',
|
|
218
|
+
className = '',
|
|
219
|
+
children,
|
|
220
|
+
...props
|
|
221
|
+
}) => {
|
|
222
|
+
return (
|
|
223
|
+
<div
|
|
224
|
+
className={`inline-flex items-center gap-2 px-3 py-1 bg-${color}-100 text-${color}-700 rounded-full text-sm ${className}`}
|
|
225
|
+
{...props}
|
|
226
|
+
>
|
|
227
|
+
{children}
|
|
228
|
+
{onRemove && (
|
|
229
|
+
<button onClick={onRemove} className="ml-1 hover:text-${color}-900">
|
|
230
|
+
✕
|
|
231
|
+
</button>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const Tag: React.FC<
|
|
238
|
+
UtilityComponentProps & {
|
|
239
|
+
variant?: 'solid' | 'outline';
|
|
240
|
+
color?: 'blue' | 'green' | 'red' | 'yellow' | 'purple';
|
|
241
|
+
}
|
|
242
|
+
> = ({
|
|
243
|
+
variant = 'solid',
|
|
244
|
+
color = 'blue',
|
|
245
|
+
className = '',
|
|
246
|
+
children,
|
|
247
|
+
...props
|
|
248
|
+
}) => {
|
|
249
|
+
const variantClass =
|
|
250
|
+
variant === 'solid'
|
|
251
|
+
? `bg-${color}-600 text-white`
|
|
252
|
+
: `border border-${color}-600 text-${color}-600`;
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<span className={`inline-block px-3 py-1 rounded text-sm font-medium ${variantClass} ${className}`} {...props}>
|
|
256
|
+
{children}
|
|
257
|
+
</span>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const Chip: React.FC<
|
|
262
|
+
UtilityComponentProps & {
|
|
263
|
+
onDelete?: () => void;
|
|
264
|
+
deletable?: boolean;
|
|
265
|
+
}
|
|
266
|
+
> = ({
|
|
267
|
+
onDelete,
|
|
268
|
+
deletable = true,
|
|
269
|
+
className = '',
|
|
270
|
+
children,
|
|
271
|
+
...props
|
|
272
|
+
}) => {
|
|
273
|
+
return (
|
|
274
|
+
<div
|
|
275
|
+
className={`inline-flex items-center gap-2 px-3 py-1.5 bg-gray-200 text-gray-800 rounded-full text-sm ${className}`}
|
|
276
|
+
{...props}
|
|
277
|
+
>
|
|
278
|
+
{children}
|
|
279
|
+
{deletable && onDelete && (
|
|
280
|
+
<button onClick={onDelete} className="hover:text-gray-900 font-bold">
|
|
281
|
+
×
|
|
282
|
+
</button>
|
|
283
|
+
)}
|
|
284
|
+
</div>
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export const Counter: React.FC<
|
|
289
|
+
UtilityComponentProps & {
|
|
290
|
+
value: number;
|
|
291
|
+
onChange?: (value: number) => void;
|
|
292
|
+
min?: number;
|
|
293
|
+
max?: number;
|
|
294
|
+
}
|
|
295
|
+
> = ({
|
|
296
|
+
value,
|
|
297
|
+
onChange,
|
|
298
|
+
min = 0,
|
|
299
|
+
max = Infinity,
|
|
300
|
+
className = '',
|
|
301
|
+
...props
|
|
302
|
+
}) => {
|
|
303
|
+
return (
|
|
304
|
+
<div className={`flex items-center gap-2 border border-gray-300 rounded-lg p-1 w-fit ${className}`} {...props}>
|
|
305
|
+
<button
|
|
306
|
+
onClick={() => onChange?.(Math.max(value - 1, min))}
|
|
307
|
+
className="px-2 py-1 hover:bg-gray-100"
|
|
308
|
+
>
|
|
309
|
+
−
|
|
310
|
+
</button>
|
|
311
|
+
<span className="px-4">{value}</span>
|
|
312
|
+
<button
|
|
313
|
+
onClick={() => onChange?.(Math.min(value + 1, max))}
|
|
314
|
+
className="px-2 py-1 hover:bg-gray-100"
|
|
315
|
+
>
|
|
316
|
+
+
|
|
317
|
+
</button>
|
|
318
|
+
</div>
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export const Flag: React.FC<
|
|
323
|
+
UtilityComponentProps & {
|
|
324
|
+
text?: string;
|
|
325
|
+
color?: 'red' | 'yellow' | 'blue' | 'green';
|
|
326
|
+
}
|
|
327
|
+
> = ({
|
|
328
|
+
text,
|
|
329
|
+
color = 'red',
|
|
330
|
+
className = '',
|
|
331
|
+
...props
|
|
332
|
+
}) => {
|
|
333
|
+
const bgClass = {
|
|
334
|
+
red: 'bg-red-500',
|
|
335
|
+
yellow: 'bg-yellow-500',
|
|
336
|
+
blue: 'bg-blue-500',
|
|
337
|
+
green: 'bg-green-500',
|
|
338
|
+
}[color];
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<div className={`${bgClass} text-white text-xs font-semibold px-2 py-1 rounded inline-block ${className}`} {...props}>
|
|
342
|
+
{text}
|
|
343
|
+
</div>
|
|
344
|
+
);
|
|
345
|
+
};
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface UtilityComponentProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const Tooltip: React.FC<
|
|
8
|
+
UtilityComponentProps & {
|
|
9
|
+
content: string;
|
|
10
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
11
|
+
}
|
|
12
|
+
> = ({
|
|
13
|
+
content,
|
|
14
|
+
position = 'top',
|
|
15
|
+
className = '',
|
|
16
|
+
children,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
const [visible, setVisible] = React.useState(false);
|
|
20
|
+
|
|
21
|
+
const positionClass = {
|
|
22
|
+
top: 'bottom-full mb-2',
|
|
23
|
+
bottom: 'top-full mt-2',
|
|
24
|
+
left: 'right-full mr-2',
|
|
25
|
+
right: 'left-full ml-2',
|
|
26
|
+
}[position];
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<div
|
|
30
|
+
className="relative inline-block"
|
|
31
|
+
onMouseEnter={() => setVisible(true)}
|
|
32
|
+
onMouseLeave={() => setVisible(false)}
|
|
33
|
+
{...props}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
{visible && (
|
|
37
|
+
<div
|
|
38
|
+
className={`absolute ${positionClass} bg-gray-900 text-white text-sm px-2 py-1 rounded whitespace-nowrap z-50`}
|
|
39
|
+
>
|
|
40
|
+
{content}
|
|
41
|
+
</div>
|
|
42
|
+
)}
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Popover: React.FC<
|
|
48
|
+
UtilityComponentProps & {
|
|
49
|
+
trigger: React.ReactNode;
|
|
50
|
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
|
51
|
+
}
|
|
52
|
+
> = ({
|
|
53
|
+
trigger,
|
|
54
|
+
position = 'bottom',
|
|
55
|
+
className = '',
|
|
56
|
+
children,
|
|
57
|
+
...props
|
|
58
|
+
}) => {
|
|
59
|
+
const [open, setOpen] = React.useState(false);
|
|
60
|
+
|
|
61
|
+
const positionClass = {
|
|
62
|
+
top: 'bottom-full mb-2',
|
|
63
|
+
bottom: 'top-full mt-2',
|
|
64
|
+
left: 'right-full mr-2',
|
|
65
|
+
right: 'left-full ml-2',
|
|
66
|
+
}[position];
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className="relative inline-block" {...props}>
|
|
70
|
+
<button onClick={() => setOpen(!open)} className="cursor-pointer">
|
|
71
|
+
{trigger}
|
|
72
|
+
</button>
|
|
73
|
+
{open && (
|
|
74
|
+
<div className={`absolute ${positionClass} bg-white border border-gray-200 rounded-lg shadow-lg p-4 z-50 min-w-max`}>
|
|
75
|
+
{children}
|
|
76
|
+
</div>
|
|
77
|
+
)}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const ContextMenu: React.FC<
|
|
83
|
+
UtilityComponentProps & {
|
|
84
|
+
items: Array<{ label: string; onClick: () => void; icon?: React.ReactNode }>;
|
|
85
|
+
}
|
|
86
|
+
> = ({
|
|
87
|
+
items,
|
|
88
|
+
className = '',
|
|
89
|
+
children,
|
|
90
|
+
...props
|
|
91
|
+
}) => {
|
|
92
|
+
const [position, setPosition] = React.useState<{ x: number; y: number } | null>(null);
|
|
93
|
+
|
|
94
|
+
const handleContextMenu = (e: React.MouseEvent<HTMLDivElement>) => {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
setPosition({ x: e.clientX, y: e.clientY });
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const handleClose = () => setPosition(null);
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div onContextMenu={handleContextMenu} className={className} {...props}>
|
|
103
|
+
{children}
|
|
104
|
+
{position && (
|
|
105
|
+
<>
|
|
106
|
+
<div className="fixed inset-0 z-40" onClick={handleClose}></div>
|
|
107
|
+
<div
|
|
108
|
+
className="fixed bg-white border border-gray-200 rounded-lg shadow-lg z-50"
|
|
109
|
+
style={{ top: position.y, left: position.x }}
|
|
110
|
+
>
|
|
111
|
+
{items.map((item, idx) => (
|
|
112
|
+
<button
|
|
113
|
+
key={idx}
|
|
114
|
+
onClick={() => {
|
|
115
|
+
item.onClick();
|
|
116
|
+
handleClose();
|
|
117
|
+
}}
|
|
118
|
+
className="w-full text-left px-4 py-2 hover:bg-gray-100 flex items-center gap-2 text-sm"
|
|
119
|
+
>
|
|
120
|
+
{item.icon}
|
|
121
|
+
{item.label}
|
|
122
|
+
</button>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
</>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export const Notification: React.FC<
|
|
132
|
+
UtilityComponentProps & {
|
|
133
|
+
type?: 'info' | 'success' | 'warning' | 'error';
|
|
134
|
+
title?: string;
|
|
135
|
+
onClose?: () => void;
|
|
136
|
+
}
|
|
137
|
+
> = ({
|
|
138
|
+
type = 'info',
|
|
139
|
+
title,
|
|
140
|
+
onClose,
|
|
141
|
+
className = '',
|
|
142
|
+
children,
|
|
143
|
+
...props
|
|
144
|
+
}) => {
|
|
145
|
+
const bgClass = {
|
|
146
|
+
info: 'bg-blue-50 border-blue-200',
|
|
147
|
+
success: 'bg-green-50 border-green-200',
|
|
148
|
+
warning: 'bg-yellow-50 border-yellow-200',
|
|
149
|
+
error: 'bg-red-50 border-red-200',
|
|
150
|
+
}[type];
|
|
151
|
+
|
|
152
|
+
const iconClass = {
|
|
153
|
+
info: '🔵',
|
|
154
|
+
success: '✅',
|
|
155
|
+
warning: '⚠️',
|
|
156
|
+
error: '❌',
|
|
157
|
+
}[type];
|
|
158
|
+
|
|
159
|
+
return (
|
|
160
|
+
<div className={`border-l-4 ${bgClass} p-4 rounded-md flex gap-3 ${className}`} {...props}>
|
|
161
|
+
<span className="text-xl">{iconClass}</span>
|
|
162
|
+
<div className="flex-1">
|
|
163
|
+
{title && <h4 className="font-semibold">{title}</h4>}
|
|
164
|
+
<p>{children}</p>
|
|
165
|
+
</div>
|
|
166
|
+
{onClose && (
|
|
167
|
+
<button onClick={onClose} className="text-gray-500 hover:text-gray-700">
|
|
168
|
+
✕
|
|
169
|
+
</button>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const Badge: React.FC<
|
|
176
|
+
UtilityComponentProps & {
|
|
177
|
+
variant?: 'solid' | 'outline' | 'dot';
|
|
178
|
+
color?: 'blue' | 'green' | 'red' | 'yellow' | 'gray';
|
|
179
|
+
count?: number | string;
|
|
180
|
+
}
|
|
181
|
+
> = ({
|
|
182
|
+
variant = 'solid',
|
|
183
|
+
color = 'blue',
|
|
184
|
+
count,
|
|
185
|
+
className = '',
|
|
186
|
+
children,
|
|
187
|
+
...props
|
|
188
|
+
}) => {
|
|
189
|
+
const colorClass = {
|
|
190
|
+
blue: 'bg-blue-600 text-white',
|
|
191
|
+
green: 'bg-green-600 text-white',
|
|
192
|
+
red: 'bg-red-600 text-white',
|
|
193
|
+
yellow: 'bg-yellow-600 text-white',
|
|
194
|
+
gray: 'bg-gray-600 text-white',
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const variantClass = {
|
|
198
|
+
solid: colorClass[color],
|
|
199
|
+
outline: `border-2 border-${color}-600 text-${color}-600`,
|
|
200
|
+
dot: `w-3 h-3 bg-${color}-600 rounded-full`,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
return (
|
|
204
|
+
<div className="relative inline-block" {...props}>
|
|
205
|
+
{children}
|
|
206
|
+
{count && (
|
|
207
|
+
<span className={`absolute -top-2 -right-2 px-2 py-1 rounded-full text-xs font-semibold ${variantClass[variant]} ${className}`}>
|
|
208
|
+
{count}
|
|
209
|
+
</span>
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const Pill: React.FC<UtilityComponentProps & { onRemove?: () => void; color?: string }> = ({
|
|
216
|
+
onRemove,
|
|
217
|
+
color = 'blue',
|
|
218
|
+
className = '',
|
|
219
|
+
children,
|
|
220
|
+
...props
|
|
221
|
+
}) => {
|
|
222
|
+
return (
|
|
223
|
+
<div
|
|
224
|
+
className={`inline-flex items-center gap-2 px-3 py-1 bg-${color}-100 text-${color}-700 rounded-full text-sm ${className}`}
|
|
225
|
+
{...props}
|
|
226
|
+
>
|
|
227
|
+
{children}
|
|
228
|
+
{onRemove && (
|
|
229
|
+
<button onClick={onRemove} className="ml-1 hover:text-${color}-900">
|
|
230
|
+
✕
|
|
231
|
+
</button>
|
|
232
|
+
)}
|
|
233
|
+
</div>
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const Tag: React.FC<
|
|
238
|
+
UtilityComponentProps & {
|
|
239
|
+
variant?: 'solid' | 'outline';
|
|
240
|
+
color?: 'blue' | 'green' | 'red' | 'yellow' | 'purple';
|
|
241
|
+
}
|
|
242
|
+
> = ({
|
|
243
|
+
variant = 'solid',
|
|
244
|
+
color = 'blue',
|
|
245
|
+
className = '',
|
|
246
|
+
children,
|
|
247
|
+
...props
|
|
248
|
+
}) => {
|
|
249
|
+
const variantClass =
|
|
250
|
+
variant === 'solid'
|
|
251
|
+
? `bg-${color}-600 text-white`
|
|
252
|
+
: `border border-${color}-600 text-${color}-600`;
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<span className={`inline-block px-3 py-1 rounded text-sm font-medium ${variantClass} ${className}`} {...props}>
|
|
256
|
+
{children}
|
|
257
|
+
</span>
|
|
258
|
+
);
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const Chip: React.FC<
|
|
262
|
+
UtilityComponentProps & {
|
|
263
|
+
onDelete?: () => void;
|
|
264
|
+
deletable?: boolean;
|
|
265
|
+
}
|
|
266
|
+
> = ({
|
|
267
|
+
onDelete,
|
|
268
|
+
deletable = true,
|
|
269
|
+
className = '',
|
|
270
|
+
children,
|
|
271
|
+
...props
|
|
272
|
+
}) => {
|
|
273
|
+
return (
|
|
274
|
+
<div
|
|
275
|
+
className={`inline-flex items-center gap-2 px-3 py-1.5 bg-gray-200 text-gray-800 rounded-full text-sm ${className}`}
|
|
276
|
+
{...props}
|
|
277
|
+
>
|
|
278
|
+
{children}
|
|
279
|
+
{deletable && onDelete && (
|
|
280
|
+
<button onClick={onDelete} className="hover:text-gray-900 font-bold">
|
|
281
|
+
×
|
|
282
|
+
</button>
|
|
283
|
+
)}
|
|
284
|
+
</div>
|
|
285
|
+
);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
export const Counter: React.FC<
|
|
289
|
+
UtilityComponentProps & {
|
|
290
|
+
value: number;
|
|
291
|
+
onChange?: (value: number) => void;
|
|
292
|
+
min?: number;
|
|
293
|
+
max?: number;
|
|
294
|
+
}
|
|
295
|
+
> = ({
|
|
296
|
+
value,
|
|
297
|
+
onChange,
|
|
298
|
+
min = 0,
|
|
299
|
+
max = Infinity,
|
|
300
|
+
className = '',
|
|
301
|
+
...props
|
|
302
|
+
}) => {
|
|
303
|
+
return (
|
|
304
|
+
<div className={`flex items-center gap-2 border border-gray-300 rounded-lg p-1 w-fit ${className}`} {...props}>
|
|
305
|
+
<button
|
|
306
|
+
onClick={() => onChange?.(Math.max(value - 1, min))}
|
|
307
|
+
className="px-2 py-1 hover:bg-gray-100"
|
|
308
|
+
>
|
|
309
|
+
−
|
|
310
|
+
</button>
|
|
311
|
+
<span className="px-4">{value}</span>
|
|
312
|
+
<button
|
|
313
|
+
onClick={() => onChange?.(Math.min(value + 1, max))}
|
|
314
|
+
className="px-2 py-1 hover:bg-gray-100"
|
|
315
|
+
>
|
|
316
|
+
+
|
|
317
|
+
</button>
|
|
318
|
+
</div>
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export const Flag: React.FC<
|
|
323
|
+
UtilityComponentProps & {
|
|
324
|
+
text?: string;
|
|
325
|
+
color?: 'red' | 'yellow' | 'blue' | 'green';
|
|
326
|
+
}
|
|
327
|
+
> = ({
|
|
328
|
+
text,
|
|
329
|
+
color = 'red',
|
|
330
|
+
className = '',
|
|
331
|
+
...props
|
|
332
|
+
}) => {
|
|
333
|
+
const bgClass = {
|
|
334
|
+
red: 'bg-red-500',
|
|
335
|
+
yellow: 'bg-yellow-500',
|
|
336
|
+
blue: 'bg-blue-500',
|
|
337
|
+
green: 'bg-green-500',
|
|
338
|
+
}[color];
|
|
339
|
+
|
|
340
|
+
return (
|
|
341
|
+
<div className={`${bgClass} text-white text-xs font-semibold px-2 py-1 rounded inline-block ${className}`} {...props}>
|
|
342
|
+
{text}
|
|
343
|
+
</div>
|
|
344
|
+
);
|
|
345
|
+
};
|