@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,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface ImageProps extends React.ImgHTMLAttributes<HTMLImageElement> {
|
|
5
|
+
src: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
width?: number | string;
|
|
8
|
+
height?: number | string;
|
|
9
|
+
fallback?: React.ReactNode;
|
|
10
|
+
rounded?: boolean;
|
|
11
|
+
border?: boolean;
|
|
12
|
+
shadow?: boolean;
|
|
13
|
+
aspect?: 'square' | 'video' | 'auto';
|
|
14
|
+
objectFit?: 'cover' | 'contain' | 'fill' | 'scale-down';
|
|
15
|
+
onLoadingStateChange?: (state: 'loading' | 'loaded' | 'error') => void;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const Image = React.forwardRef<HTMLImageElement, ImageProps>(
|
|
20
|
+
(
|
|
21
|
+
{
|
|
22
|
+
src,
|
|
23
|
+
alt,
|
|
24
|
+
width,
|
|
25
|
+
height,
|
|
26
|
+
fallback,
|
|
27
|
+
rounded = false,
|
|
28
|
+
border = false,
|
|
29
|
+
shadow = false,
|
|
30
|
+
aspect = 'auto',
|
|
31
|
+
objectFit = 'cover',
|
|
32
|
+
onLoadingStateChange,
|
|
33
|
+
className,
|
|
34
|
+
...props
|
|
35
|
+
},
|
|
36
|
+
ref
|
|
37
|
+
) => {
|
|
38
|
+
const [error, setError] = React.useState(false);
|
|
39
|
+
const [loading, setLoading] = React.useState(true);
|
|
40
|
+
|
|
41
|
+
const aspectClasses = {
|
|
42
|
+
square: 'aspect-square',
|
|
43
|
+
video: 'aspect-video',
|
|
44
|
+
auto: 'auto',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleLoad = () => {
|
|
48
|
+
setLoading(false);
|
|
49
|
+
onLoadingStateChange?.('loaded');
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const handleError = () => {
|
|
53
|
+
setError(true);
|
|
54
|
+
setLoading(false);
|
|
55
|
+
onLoadingStateChange?.('error');
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
if (error && fallback) {
|
|
59
|
+
return <>{fallback}</>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<div
|
|
64
|
+
className={cn(
|
|
65
|
+
'relative bg-gray-100',
|
|
66
|
+
aspectClasses[aspect] !== 'auto' && aspectClasses[aspect],
|
|
67
|
+
{
|
|
68
|
+
'rounded-lg': rounded,
|
|
69
|
+
'border border-gray-200': border,
|
|
70
|
+
'shadow-md': shadow,
|
|
71
|
+
},
|
|
72
|
+
aspect === 'auto' && !height && 'w-full'
|
|
73
|
+
)}
|
|
74
|
+
style={{
|
|
75
|
+
width: typeof width === 'number' ? `${width}px` : width,
|
|
76
|
+
height: typeof height === 'number' ? `${height}px` : height,
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
<img
|
|
80
|
+
ref={ref}
|
|
81
|
+
src={src}
|
|
82
|
+
alt={alt}
|
|
83
|
+
onLoad={handleLoad}
|
|
84
|
+
onError={handleError}
|
|
85
|
+
className={cn(
|
|
86
|
+
'w-full h-full',
|
|
87
|
+
{
|
|
88
|
+
rounded: rounded,
|
|
89
|
+
'animate-pulse': loading,
|
|
90
|
+
},
|
|
91
|
+
className
|
|
92
|
+
)}
|
|
93
|
+
style={{
|
|
94
|
+
objectFit: objectFit,
|
|
95
|
+
}}
|
|
96
|
+
{...props}
|
|
97
|
+
/>
|
|
98
|
+
{loading && (
|
|
99
|
+
<div className="absolute inset-0 bg-gray-200 animate-pulse rounded-lg" />
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
Image.displayName = 'Image';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
helpText?: string;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
13
|
+
(
|
|
14
|
+
{
|
|
15
|
+
label,
|
|
16
|
+
error = false,
|
|
17
|
+
errorMessage,
|
|
18
|
+
helpText,
|
|
19
|
+
fullWidth = false,
|
|
20
|
+
className,
|
|
21
|
+
id,
|
|
22
|
+
disabled,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
25
|
+
ref,
|
|
26
|
+
) => {
|
|
27
|
+
const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={cn(fullWidth && 'w-full')}>
|
|
31
|
+
{label && (
|
|
32
|
+
<label
|
|
33
|
+
htmlFor={inputId}
|
|
34
|
+
className="block text-sm font-medium text-gray-700 mb-1.5"
|
|
35
|
+
>
|
|
36
|
+
{label}
|
|
37
|
+
</label>
|
|
38
|
+
)}
|
|
39
|
+
<input
|
|
40
|
+
ref={ref}
|
|
41
|
+
id={inputId}
|
|
42
|
+
className={cn(
|
|
43
|
+
'w-full px-3 py-2 border rounded-md text-base',
|
|
44
|
+
'focus:outline-none focus:ring-2 focus:ring-offset-1 transition-all duration-200',
|
|
45
|
+
'disabled:bg-gray-100 disabled:text-gray-500 disabled:cursor-not-allowed',
|
|
46
|
+
error
|
|
47
|
+
? 'border-red-500 focus:ring-red-500'
|
|
48
|
+
: 'border-gray-300 focus:ring-blue-500',
|
|
49
|
+
className,
|
|
50
|
+
)}
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
{error && errorMessage && (
|
|
55
|
+
<p className="mt-1 text-sm text-red-600">{errorMessage}</p>
|
|
56
|
+
)}
|
|
57
|
+
{!error && helpText && (
|
|
58
|
+
<p className="mt-1 text-sm text-gray-500">{helpText}</p>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
Input.displayName = 'Input';
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
helpText?: string;
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
13
|
+
(
|
|
14
|
+
{
|
|
15
|
+
label,
|
|
16
|
+
error = false,
|
|
17
|
+
errorMessage,
|
|
18
|
+
helpText,
|
|
19
|
+
fullWidth = false,
|
|
20
|
+
className,
|
|
21
|
+
id,
|
|
22
|
+
disabled,
|
|
23
|
+
...props
|
|
24
|
+
},
|
|
25
|
+
ref,
|
|
26
|
+
) => {
|
|
27
|
+
const inputId = id || `input-${Math.random().toString(36).substr(2, 9)}`;
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className={cn(fullWidth && 'w-full')}>
|
|
31
|
+
{label && (
|
|
32
|
+
<label
|
|
33
|
+
htmlFor={inputId}
|
|
34
|
+
className="block text-sm font-medium text-gray-700 mb-1.5"
|
|
35
|
+
>
|
|
36
|
+
{label}
|
|
37
|
+
</label>
|
|
38
|
+
)}
|
|
39
|
+
<input
|
|
40
|
+
ref={ref}
|
|
41
|
+
id={inputId}
|
|
42
|
+
className={cn(
|
|
43
|
+
'w-full px-3 py-2 border rounded-md text-base',
|
|
44
|
+
'focus:outline-none focus:ring-2 focus:ring-offset-1 transition-all duration-200',
|
|
45
|
+
'disabled:bg-gray-100 disabled:text-gray-500 disabled:cursor-not-allowed',
|
|
46
|
+
error
|
|
47
|
+
? 'border-red-500 focus:ring-red-500'
|
|
48
|
+
: 'border-gray-300 focus:ring-blue-500',
|
|
49
|
+
className,
|
|
50
|
+
)}
|
|
51
|
+
disabled={disabled}
|
|
52
|
+
{...props}
|
|
53
|
+
/>
|
|
54
|
+
{error && errorMessage && (
|
|
55
|
+
<p className="mt-1 text-sm text-red-600">{errorMessage}</p>
|
|
56
|
+
)}
|
|
57
|
+
{!error && helpText && (
|
|
58
|
+
<p className="mt-1 text-sm text-gray-500">{helpText}</p>
|
|
59
|
+
)}
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
},
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
Input.displayName = 'Input';
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
export interface GridProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
children?: React.ReactNode;
|
|
5
|
+
gap?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
6
|
+
autoFit?: boolean;
|
|
7
|
+
minWidth?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const gapClass = {
|
|
11
|
+
xs: 'gap-2',
|
|
12
|
+
sm: 'gap-4',
|
|
13
|
+
md: 'gap-6',
|
|
14
|
+
lg: 'gap-8',
|
|
15
|
+
xl: 'gap-12',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const GridAuto: React.FC<GridProps> = ({
|
|
19
|
+
gap = 'md',
|
|
20
|
+
autoFit = true,
|
|
21
|
+
minWidth = '250px',
|
|
22
|
+
className = '',
|
|
23
|
+
children,
|
|
24
|
+
...props
|
|
25
|
+
}) => {
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
className={`grid ${gapClass[gap]} ${className}`}
|
|
29
|
+
style={{
|
|
30
|
+
gridTemplateColumns: autoFit ? `repeat(auto-fit, minmax(${minWidth}, 1fr))` : undefined,
|
|
31
|
+
}}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const GridResponsive: React.FC<
|
|
40
|
+
GridProps & {
|
|
41
|
+
cols?: { sm?: number; md?: number; lg?: number; xl?: number };
|
|
42
|
+
}
|
|
43
|
+
> = ({
|
|
44
|
+
gap = 'md',
|
|
45
|
+
cols = { sm: 1, md: 2, lg: 3, xl: 4 },
|
|
46
|
+
className = '',
|
|
47
|
+
children,
|
|
48
|
+
...props
|
|
49
|
+
}) => {
|
|
50
|
+
const colClass = `grid-cols-${cols.sm || 1} sm:grid-cols-${cols.md || 2} lg:grid-cols-${cols.lg || 3} xl:grid-cols-${cols.xl || 4}`;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div className={`grid ${gapClass[gap]} ${colClass} ${className}`} {...props}>
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const GridMasonry: React.FC<GridProps> = ({ gap = 'md', className = '', children, ...props }) => {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
className={`grid ${gapClass[gap]} ${className}`}
|
|
63
|
+
style={{ columnCount: 'auto', columnFill: 'balance' }}
|
|
64
|
+
{...props}
|
|
65
|
+
>
|
|
66
|
+
{React.Children.map(children, (child) => (
|
|
67
|
+
<div style={{ breakInside: 'avoid' }}>{child}</div>
|
|
68
|
+
))}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const GridFixedCol: React.FC<
|
|
74
|
+
GridProps & {
|
|
75
|
+
columns: number;
|
|
76
|
+
}
|
|
77
|
+
> = ({ gap = 'md', columns = 3, className = '', children, ...props }) => {
|
|
78
|
+
return (
|
|
79
|
+
<div className={`grid grid-cols-${columns} ${gapClass[gap]} ${className}`} {...props}>
|
|
80
|
+
{children}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const GridDynamic: React.FC<
|
|
86
|
+
GridProps & {
|
|
87
|
+
minColWidth?: string;
|
|
88
|
+
}
|
|
89
|
+
> = ({
|
|
90
|
+
gap = 'md',
|
|
91
|
+
minColWidth = '200px',
|
|
92
|
+
className = '',
|
|
93
|
+
children,
|
|
94
|
+
...props
|
|
95
|
+
}) => {
|
|
96
|
+
return (
|
|
97
|
+
<div
|
|
98
|
+
className={`grid ${gapClass[gap]} ${className}`}
|
|
99
|
+
style={{
|
|
100
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${minColWidth}, 1fr))`,
|
|
101
|
+
}}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
{children}
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const GridNested: React.FC<GridProps> = ({
|
|
110
|
+
gap = 'md',
|
|
111
|
+
className = '',
|
|
112
|
+
children,
|
|
113
|
+
...props
|
|
114
|
+
}) => {
|
|
115
|
+
return (
|
|
116
|
+
<div className={`grid ${gapClass[gap]} ${className}`} {...props}>
|
|
117
|
+
{children}
|
|
118
|
+
</div>
|
|
119
|
+
);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export const GridAligned: React.FC<
|
|
123
|
+
GridProps & {
|
|
124
|
+
align?: 'start' | 'center' | 'end' | 'stretch';
|
|
125
|
+
justify?: 'start' | 'center' | 'end' | 'between';
|
|
126
|
+
}
|
|
127
|
+
> = ({
|
|
128
|
+
gap = 'md',
|
|
129
|
+
align = 'stretch',
|
|
130
|
+
justify = 'start',
|
|
131
|
+
className = '',
|
|
132
|
+
children,
|
|
133
|
+
...props
|
|
134
|
+
}) => {
|
|
135
|
+
const alignClass = {
|
|
136
|
+
start: 'items-start',
|
|
137
|
+
center: 'items-center',
|
|
138
|
+
end: 'items-end',
|
|
139
|
+
stretch: 'items-stretch',
|
|
140
|
+
}[align];
|
|
141
|
+
|
|
142
|
+
const justifyClass = {
|
|
143
|
+
start: 'justify-start',
|
|
144
|
+
center: 'justify-center',
|
|
145
|
+
end: 'justify-end',
|
|
146
|
+
between: 'justify-between',
|
|
147
|
+
}[justify];
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<div className={`grid ${gapClass[gap]} ${alignClass} ${justifyClass} ${className}`} {...props}>
|
|
151
|
+
{children}
|
|
152
|
+
</div>
|
|
153
|
+
);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const Container: React.FC<GridProps & { maxWidth?: 'sm' | 'md' | 'lg' | 'xl' | '2xl' }> = ({
|
|
157
|
+
maxWidth = 'lg',
|
|
158
|
+
className = '',
|
|
159
|
+
children,
|
|
160
|
+
...props
|
|
161
|
+
}) => {
|
|
162
|
+
const maxWidthClass = {
|
|
163
|
+
sm: 'max-w-sm',
|
|
164
|
+
md: 'max-w-md',
|
|
165
|
+
lg: 'max-w-lg',
|
|
166
|
+
xl: 'max-w-xl',
|
|
167
|
+
'2xl': 'max-w-2xl',
|
|
168
|
+
}[maxWidth];
|
|
169
|
+
|
|
170
|
+
return (
|
|
171
|
+
<div className={`mx-auto px-4 ${maxWidthClass} ${className}`} {...props}>
|
|
172
|
+
{children}
|
|
173
|
+
</div>
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export const Flex: React.FC<
|
|
178
|
+
GridProps & {
|
|
179
|
+
direction?: 'row' | 'col';
|
|
180
|
+
wrap?: boolean;
|
|
181
|
+
align?: 'start' | 'center' | 'end' | 'stretch' | 'baseline';
|
|
182
|
+
justify?: 'start' | 'center' | 'end' | 'between' | 'around' | 'evenly';
|
|
183
|
+
}
|
|
184
|
+
> = ({
|
|
185
|
+
direction = 'row',
|
|
186
|
+
wrap = false,
|
|
187
|
+
gap = 'md',
|
|
188
|
+
align = 'stretch',
|
|
189
|
+
justify = 'start',
|
|
190
|
+
className = '',
|
|
191
|
+
children,
|
|
192
|
+
...props
|
|
193
|
+
}) => {
|
|
194
|
+
const directionClass = direction === 'col' ? 'flex-col' : 'flex-row';
|
|
195
|
+
const wrapClass = wrap ? 'flex-wrap' : 'flex-nowrap';
|
|
196
|
+
const alignClass = {
|
|
197
|
+
start: 'items-start',
|
|
198
|
+
center: 'items-center',
|
|
199
|
+
end: 'items-end',
|
|
200
|
+
stretch: 'items-stretch',
|
|
201
|
+
baseline: 'items-baseline',
|
|
202
|
+
}[align];
|
|
203
|
+
|
|
204
|
+
const justifyClass = {
|
|
205
|
+
start: 'justify-start',
|
|
206
|
+
center: 'justify-center',
|
|
207
|
+
end: 'justify-end',
|
|
208
|
+
between: 'justify-between',
|
|
209
|
+
around: 'justify-around',
|
|
210
|
+
evenly: 'justify-evenly',
|
|
211
|
+
}[justify];
|
|
212
|
+
|
|
213
|
+
return (
|
|
214
|
+
<div className={`flex ${directionClass} ${wrapClass} ${gapClass[gap]} ${alignClass} ${justifyClass} ${className}`} {...props}>
|
|
215
|
+
{children}
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export const Stack: React.FC<GridProps & { direction?: 'vertical' | 'horizontal' }> = ({
|
|
221
|
+
direction = 'vertical',
|
|
222
|
+
gap = 'md',
|
|
223
|
+
className = '',
|
|
224
|
+
children,
|
|
225
|
+
...props
|
|
226
|
+
}) => {
|
|
227
|
+
const directionClass = direction === 'vertical' ? 'flex-col' : 'flex-row';
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<div className={`flex ${directionClass} ${gapClass[gap]} ${className}`} {...props}>
|
|
231
|
+
{children}
|
|
232
|
+
</div>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
export const AspectRatio: React.FC<
|
|
237
|
+
GridProps & {
|
|
238
|
+
ratio?: 'square' | '16/9' | '4/3' | '21/9';
|
|
239
|
+
}
|
|
240
|
+
> = ({
|
|
241
|
+
ratio = 'square',
|
|
242
|
+
className = '',
|
|
243
|
+
children,
|
|
244
|
+
...props
|
|
245
|
+
}) => {
|
|
246
|
+
const ratioClass = {
|
|
247
|
+
square: 'aspect-square',
|
|
248
|
+
'16/9': 'aspect-video',
|
|
249
|
+
'4/3': 'aspect-video', // fallback
|
|
250
|
+
'21/9': 'aspect-auto',
|
|
251
|
+
}[ratio];
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<div className={`${ratioClass} overflow-hidden ${className}`} {...props}>
|
|
255
|
+
{children}
|
|
256
|
+
</div>
|
|
257
|
+
);
|
|
258
|
+
};
|