@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,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
value: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
variant?: 'primary' | 'success' | 'warning' | 'danger';
|
|
9
|
+
animated?: boolean;
|
|
10
|
+
showLabel?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sizeStyles = {
|
|
14
|
+
sm: 'h-1',
|
|
15
|
+
md: 'h-2',
|
|
16
|
+
lg: 'h-3',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const variantStyles = {
|
|
20
|
+
primary: 'bg-blue-600',
|
|
21
|
+
success: 'bg-green-600',
|
|
22
|
+
warning: 'bg-yellow-600',
|
|
23
|
+
danger: 'bg-red-600',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
|
|
27
|
+
(
|
|
28
|
+
{
|
|
29
|
+
value,
|
|
30
|
+
max = 100,
|
|
31
|
+
size = 'md',
|
|
32
|
+
variant = 'primary',
|
|
33
|
+
animated = false,
|
|
34
|
+
showLabel = false,
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
},
|
|
38
|
+
ref,
|
|
39
|
+
) => {
|
|
40
|
+
const percentage = Math.min((value / max) * 100, 100);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div ref={ref} className={cn('', className)} {...props}>
|
|
44
|
+
<div className={cn('w-full bg-gray-200 rounded-full overflow-hidden', sizeStyles[size])}>
|
|
45
|
+
<div
|
|
46
|
+
className={cn(
|
|
47
|
+
'h-full transition-all duration-300',
|
|
48
|
+
variantStyles[variant],
|
|
49
|
+
animated && 'animate-pulse',
|
|
50
|
+
)}
|
|
51
|
+
style={{ width: `${percentage}%` }}
|
|
52
|
+
role="progressbar"
|
|
53
|
+
aria-valuenow={value}
|
|
54
|
+
aria-valuemin={0}
|
|
55
|
+
aria-valuemax={max}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
{showLabel && (
|
|
59
|
+
<p className="mt-2 text-sm text-gray-600">
|
|
60
|
+
{Math.round(percentage)}%
|
|
61
|
+
</p>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
Progress.displayName = 'Progress';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
value: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
variant?: 'primary' | 'success' | 'warning' | 'danger';
|
|
9
|
+
animated?: boolean;
|
|
10
|
+
showLabel?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sizeStyles = {
|
|
14
|
+
sm: 'h-1',
|
|
15
|
+
md: 'h-2',
|
|
16
|
+
lg: 'h-3',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const variantStyles = {
|
|
20
|
+
primary: 'bg-blue-600',
|
|
21
|
+
success: 'bg-green-600',
|
|
22
|
+
warning: 'bg-yellow-600',
|
|
23
|
+
danger: 'bg-red-600',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
|
|
27
|
+
(
|
|
28
|
+
{
|
|
29
|
+
value,
|
|
30
|
+
max = 100,
|
|
31
|
+
size = 'md',
|
|
32
|
+
variant = 'primary',
|
|
33
|
+
animated = false,
|
|
34
|
+
showLabel = false,
|
|
35
|
+
className,
|
|
36
|
+
...props
|
|
37
|
+
},
|
|
38
|
+
ref,
|
|
39
|
+
) => {
|
|
40
|
+
const percentage = Math.min((value / max) * 100, 100);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div ref={ref} className={cn('', className)} {...props}>
|
|
44
|
+
<div className={cn('w-full bg-gray-200 rounded-full overflow-hidden', sizeStyles[size])}>
|
|
45
|
+
<div
|
|
46
|
+
className={cn(
|
|
47
|
+
'h-full transition-all duration-300',
|
|
48
|
+
variantStyles[variant],
|
|
49
|
+
animated && 'animate-pulse',
|
|
50
|
+
)}
|
|
51
|
+
style={{ width: `${percentage}%` }}
|
|
52
|
+
role="progressbar"
|
|
53
|
+
aria-valuenow={value}
|
|
54
|
+
aria-valuemin={0}
|
|
55
|
+
aria-valuemax={max}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
{showLabel && (
|
|
59
|
+
<p className="mt-2 text-sm text-gray-600">
|
|
60
|
+
{Math.round(percentage)}%
|
|
61
|
+
</p>
|
|
62
|
+
)}
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
Progress.displayName = 'Progress';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface RadioProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Radio = React.forwardRef<HTMLInputElement, RadioProps>(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
label,
|
|
14
|
+
error = false,
|
|
15
|
+
errorMessage,
|
|
16
|
+
id,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
},
|
|
20
|
+
ref,
|
|
21
|
+
) => {
|
|
22
|
+
const inputId = id || `radio-${Math.random().toString(36).substr(2, 9)}`;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex flex-col gap-1">
|
|
26
|
+
<label className="flex items-center gap-2 cursor-pointer">
|
|
27
|
+
<input
|
|
28
|
+
ref={ref}
|
|
29
|
+
id={inputId}
|
|
30
|
+
type="radio"
|
|
31
|
+
className={cn(
|
|
32
|
+
'w-4 h-4 rounded-full border border-gray-300 text-blue-600',
|
|
33
|
+
'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1',
|
|
34
|
+
'disabled:opacity-50 disabled:cursor-not-allowed',
|
|
35
|
+
error && 'border-red-500',
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
{label && <span className="text-sm text-gray-700">{label}</span>}
|
|
41
|
+
</label>
|
|
42
|
+
{error && errorMessage && (
|
|
43
|
+
<p className="text-sm text-red-600">{errorMessage}</p>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
Radio.displayName = 'Radio';
|
|
51
|
+
|
|
52
|
+
export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
53
|
+
options: Array<{ value: string; label: string }>;
|
|
54
|
+
value?: string;
|
|
55
|
+
onChange?: (value: string) => void;
|
|
56
|
+
error?: boolean;
|
|
57
|
+
errorMessage?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
options,
|
|
64
|
+
value,
|
|
65
|
+
onChange,
|
|
66
|
+
error = false,
|
|
67
|
+
errorMessage,
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
},
|
|
71
|
+
ref,
|
|
72
|
+
) => {
|
|
73
|
+
return (
|
|
74
|
+
<div ref={ref} className={cn('flex flex-col gap-2', className)} {...props}>
|
|
75
|
+
{options.map((option) => (
|
|
76
|
+
<Radio
|
|
77
|
+
key={option.value}
|
|
78
|
+
label={option.label}
|
|
79
|
+
value={option.value}
|
|
80
|
+
checked={value === option.value}
|
|
81
|
+
onChange={(e) => onChange?.(e.target.value)}
|
|
82
|
+
error={error}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
{error && errorMessage && (
|
|
86
|
+
<p className="text-sm text-red-600">{errorMessage}</p>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface RadioProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Radio = React.forwardRef<HTMLInputElement, RadioProps>(
|
|
11
|
+
(
|
|
12
|
+
{
|
|
13
|
+
label,
|
|
14
|
+
error = false,
|
|
15
|
+
errorMessage,
|
|
16
|
+
id,
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
},
|
|
20
|
+
ref,
|
|
21
|
+
) => {
|
|
22
|
+
const inputId = id || `radio-${Math.random().toString(36).substr(2, 9)}`;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="flex flex-col gap-1">
|
|
26
|
+
<label className="flex items-center gap-2 cursor-pointer">
|
|
27
|
+
<input
|
|
28
|
+
ref={ref}
|
|
29
|
+
id={inputId}
|
|
30
|
+
type="radio"
|
|
31
|
+
className={cn(
|
|
32
|
+
'w-4 h-4 rounded-full border border-gray-300 text-blue-600',
|
|
33
|
+
'focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1',
|
|
34
|
+
'disabled:opacity-50 disabled:cursor-not-allowed',
|
|
35
|
+
error && 'border-red-500',
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
{...props}
|
|
39
|
+
/>
|
|
40
|
+
{label && <span className="text-sm text-gray-700">{label}</span>}
|
|
41
|
+
</label>
|
|
42
|
+
{error && errorMessage && (
|
|
43
|
+
<p className="text-sm text-red-600">{errorMessage}</p>
|
|
44
|
+
)}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
Radio.displayName = 'Radio';
|
|
51
|
+
|
|
52
|
+
export interface RadioGroupProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
53
|
+
options: Array<{ value: string; label: string }>;
|
|
54
|
+
value?: string;
|
|
55
|
+
onChange?: (value: string) => void;
|
|
56
|
+
error?: boolean;
|
|
57
|
+
errorMessage?: string;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export const RadioGroup = React.forwardRef<HTMLDivElement, RadioGroupProps>(
|
|
61
|
+
(
|
|
62
|
+
{
|
|
63
|
+
options,
|
|
64
|
+
value,
|
|
65
|
+
onChange,
|
|
66
|
+
error = false,
|
|
67
|
+
errorMessage,
|
|
68
|
+
className,
|
|
69
|
+
...props
|
|
70
|
+
},
|
|
71
|
+
ref,
|
|
72
|
+
) => {
|
|
73
|
+
return (
|
|
74
|
+
<div ref={ref} className={cn('flex flex-col gap-2', className)} {...props}>
|
|
75
|
+
{options.map((option) => (
|
|
76
|
+
<Radio
|
|
77
|
+
key={option.value}
|
|
78
|
+
label={option.label}
|
|
79
|
+
value={option.value}
|
|
80
|
+
checked={value === option.value}
|
|
81
|
+
onChange={(e) => onChange?.(e.target.value)}
|
|
82
|
+
error={error}
|
|
83
|
+
/>
|
|
84
|
+
))}
|
|
85
|
+
{error && errorMessage && (
|
|
86
|
+
<p className="text-sm text-red-600">{errorMessage}</p>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
RadioGroup.displayName = 'RadioGroup';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
value?: number;
|
|
6
|
+
onChange?: (value: number) => void;
|
|
7
|
+
max?: number;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
color?: 'primary' | 'warning' | 'danger';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sizeStyles = {
|
|
14
|
+
sm: 'w-4 h-4',
|
|
15
|
+
md: 'w-5 h-5',
|
|
16
|
+
lg: 'w-6 h-6',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const colorStyles = {
|
|
20
|
+
primary: 'text-blue-600',
|
|
21
|
+
warning: 'text-yellow-500',
|
|
22
|
+
danger: 'text-red-600',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
26
|
+
(
|
|
27
|
+
{
|
|
28
|
+
value = 0,
|
|
29
|
+
onChange,
|
|
30
|
+
max = 5,
|
|
31
|
+
size = 'md',
|
|
32
|
+
readonly = false,
|
|
33
|
+
color = 'warning',
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
},
|
|
37
|
+
ref,
|
|
38
|
+
) => {
|
|
39
|
+
const [hoverValue, setHoverValue] = React.useState(0);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn('flex gap-1', className)}
|
|
45
|
+
role="radiogroup"
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{Array.from({ length: max }).map((_, index) => {
|
|
49
|
+
const starValue = index + 1;
|
|
50
|
+
const displayValue = hoverValue || value;
|
|
51
|
+
const isFilled = starValue <= displayValue;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<button
|
|
55
|
+
key={index}
|
|
56
|
+
className={cn(
|
|
57
|
+
sizeStyles[size],
|
|
58
|
+
readonly && 'cursor-default',
|
|
59
|
+
!readonly && 'cursor-pointer hover:scale-110 transition-transform',
|
|
60
|
+
colorStyles[color],
|
|
61
|
+
)}
|
|
62
|
+
onClick={() => !readonly && onChange?.(starValue)}
|
|
63
|
+
onMouseEnter={() => !readonly && setHoverValue(starValue)}
|
|
64
|
+
onMouseLeave={() => setHoverValue(0)}
|
|
65
|
+
aria-label={`Rate ${starValue}`}
|
|
66
|
+
disabled={readonly}
|
|
67
|
+
>
|
|
68
|
+
<svg
|
|
69
|
+
className={cn('w-full h-full', isFilled ? 'fill-current' : 'fill-none stroke-current stroke-2')}
|
|
70
|
+
viewBox="0 0 20 20"
|
|
71
|
+
>
|
|
72
|
+
<path d="M10 1.27l2.756 5.58h6.147l-4.97 3.613 1.897 5.835-4.83-3.512-4.83 3.512 1.897-5.835-4.97-3.613h6.147z" />
|
|
73
|
+
</svg>
|
|
74
|
+
</button>
|
|
75
|
+
);
|
|
76
|
+
})}
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
Rating.displayName = 'Rating';
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
5
|
+
value?: number;
|
|
6
|
+
onChange?: (value: number) => void;
|
|
7
|
+
max?: number;
|
|
8
|
+
size?: 'sm' | 'md' | 'lg';
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
color?: 'primary' | 'warning' | 'danger';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const sizeStyles = {
|
|
14
|
+
sm: 'w-4 h-4',
|
|
15
|
+
md: 'w-5 h-5',
|
|
16
|
+
lg: 'w-6 h-6',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const colorStyles = {
|
|
20
|
+
primary: 'text-blue-600',
|
|
21
|
+
warning: 'text-yellow-500',
|
|
22
|
+
danger: 'text-red-600',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
26
|
+
(
|
|
27
|
+
{
|
|
28
|
+
value = 0,
|
|
29
|
+
onChange,
|
|
30
|
+
max = 5,
|
|
31
|
+
size = 'md',
|
|
32
|
+
readonly = false,
|
|
33
|
+
color = 'warning',
|
|
34
|
+
className,
|
|
35
|
+
...props
|
|
36
|
+
},
|
|
37
|
+
ref,
|
|
38
|
+
) => {
|
|
39
|
+
const [hoverValue, setHoverValue] = React.useState(0);
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
ref={ref}
|
|
44
|
+
className={cn('flex gap-1', className)}
|
|
45
|
+
role="radiogroup"
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{Array.from({ length: max }).map((_, index) => {
|
|
49
|
+
const starValue = index + 1;
|
|
50
|
+
const displayValue = hoverValue || value;
|
|
51
|
+
const isFilled = starValue <= displayValue;
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<button
|
|
55
|
+
key={index}
|
|
56
|
+
className={cn(
|
|
57
|
+
sizeStyles[size],
|
|
58
|
+
readonly && 'cursor-default',
|
|
59
|
+
!readonly && 'cursor-pointer hover:scale-110 transition-transform',
|
|
60
|
+
colorStyles[color],
|
|
61
|
+
)}
|
|
62
|
+
onClick={() => !readonly && onChange?.(starValue)}
|
|
63
|
+
onMouseEnter={() => !readonly && setHoverValue(starValue)}
|
|
64
|
+
onMouseLeave={() => setHoverValue(0)}
|
|
65
|
+
aria-label={`Rate ${starValue}`}
|
|
66
|
+
disabled={readonly}
|
|
67
|
+
>
|
|
68
|
+
<svg
|
|
69
|
+
className={cn('w-full h-full', isFilled ? 'fill-current' : 'fill-none stroke-current stroke-2')}
|
|
70
|
+
viewBox="0 0 20 20"
|
|
71
|
+
>
|
|
72
|
+
<path d="M10 1.27l2.756 5.58h6.147l-4.97 3.613 1.897 5.835-4.83-3.512-4.83 3.512 1.897-5.835-4.97-3.613h6.147z" />
|
|
73
|
+
</svg>
|
|
74
|
+
</button>
|
|
75
|
+
);
|
|
76
|
+
})}
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
Rating.displayName = 'Rating';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
helpText?: string;
|
|
9
|
+
options: Array<{ value: string; label: string }>;
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
14
|
+
(
|
|
15
|
+
{
|
|
16
|
+
label,
|
|
17
|
+
error = false,
|
|
18
|
+
errorMessage,
|
|
19
|
+
helpText,
|
|
20
|
+
options,
|
|
21
|
+
fullWidth = false,
|
|
22
|
+
id,
|
|
23
|
+
className,
|
|
24
|
+
disabled,
|
|
25
|
+
...props
|
|
26
|
+
},
|
|
27
|
+
ref,
|
|
28
|
+
) => {
|
|
29
|
+
const selectId = id || `select-${Math.random().toString(36).substr(2, 9)}`;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className={cn(fullWidth && 'w-full')}>
|
|
33
|
+
{label && (
|
|
34
|
+
<label
|
|
35
|
+
htmlFor={selectId}
|
|
36
|
+
className="block text-sm font-medium text-gray-700 mb-1.5"
|
|
37
|
+
>
|
|
38
|
+
{label}
|
|
39
|
+
</label>
|
|
40
|
+
)}
|
|
41
|
+
<select
|
|
42
|
+
ref={ref}
|
|
43
|
+
id={selectId}
|
|
44
|
+
className={cn(
|
|
45
|
+
'w-full px-3 py-2 border rounded-md text-base appearance-none',
|
|
46
|
+
'focus:outline-none focus:ring-2 focus:ring-offset-1 transition-all duration-200',
|
|
47
|
+
'disabled:bg-gray-100 disabled:text-gray-500 disabled:cursor-not-allowed',
|
|
48
|
+
error
|
|
49
|
+
? 'border-red-500 focus:ring-red-500'
|
|
50
|
+
: 'border-gray-300 focus:ring-blue-500',
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<option value="">Select an option</option>
|
|
57
|
+
{options.map((option) => (
|
|
58
|
+
<option key={option.value} value={option.value}>
|
|
59
|
+
{option.label}
|
|
60
|
+
</option>
|
|
61
|
+
))}
|
|
62
|
+
</select>
|
|
63
|
+
{error && errorMessage && (
|
|
64
|
+
<p className="mt-1 text-sm text-red-600">{errorMessage}</p>
|
|
65
|
+
)}
|
|
66
|
+
{!error && helpText && (
|
|
67
|
+
<p className="mt-1 text-sm text-gray-500">{helpText}</p>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
Select.displayName = 'Select';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cn } from '../utilities/classNames';
|
|
3
|
+
|
|
4
|
+
export interface SelectProps extends React.SelectHTMLAttributes<HTMLSelectElement> {
|
|
5
|
+
label?: string;
|
|
6
|
+
error?: boolean;
|
|
7
|
+
errorMessage?: string;
|
|
8
|
+
helpText?: string;
|
|
9
|
+
options: Array<{ value: string; label: string }>;
|
|
10
|
+
fullWidth?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
|
|
14
|
+
(
|
|
15
|
+
{
|
|
16
|
+
label,
|
|
17
|
+
error = false,
|
|
18
|
+
errorMessage,
|
|
19
|
+
helpText,
|
|
20
|
+
options,
|
|
21
|
+
fullWidth = false,
|
|
22
|
+
id,
|
|
23
|
+
className,
|
|
24
|
+
disabled,
|
|
25
|
+
...props
|
|
26
|
+
},
|
|
27
|
+
ref,
|
|
28
|
+
) => {
|
|
29
|
+
const selectId = id || `select-${Math.random().toString(36).substr(2, 9)}`;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div className={cn(fullWidth && 'w-full')}>
|
|
33
|
+
{label && (
|
|
34
|
+
<label
|
|
35
|
+
htmlFor={selectId}
|
|
36
|
+
className="block text-sm font-medium text-gray-700 mb-1.5"
|
|
37
|
+
>
|
|
38
|
+
{label}
|
|
39
|
+
</label>
|
|
40
|
+
)}
|
|
41
|
+
<select
|
|
42
|
+
ref={ref}
|
|
43
|
+
id={selectId}
|
|
44
|
+
className={cn(
|
|
45
|
+
'w-full px-3 py-2 border rounded-md text-base appearance-none',
|
|
46
|
+
'focus:outline-none focus:ring-2 focus:ring-offset-1 transition-all duration-200',
|
|
47
|
+
'disabled:bg-gray-100 disabled:text-gray-500 disabled:cursor-not-allowed',
|
|
48
|
+
error
|
|
49
|
+
? 'border-red-500 focus:ring-red-500'
|
|
50
|
+
: 'border-gray-300 focus:ring-blue-500',
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<option value="">Select an option</option>
|
|
57
|
+
{options.map((option) => (
|
|
58
|
+
<option key={option.value} value={option.value}>
|
|
59
|
+
{option.label}
|
|
60
|
+
</option>
|
|
61
|
+
))}
|
|
62
|
+
</select>
|
|
63
|
+
{error && errorMessage && (
|
|
64
|
+
<p className="mt-1 text-sm text-red-600">{errorMessage}</p>
|
|
65
|
+
)}
|
|
66
|
+
{!error && helpText && (
|
|
67
|
+
<p className="mt-1 text-sm text-gray-500">{helpText}</p>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
},
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
Select.displayName = 'Select';
|