eai-frontend-components 2.0.4 → 2.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/ui/accordion.tsx +0 -48
- package/src/components/ui/alert-dialog.tsx +0 -138
- package/src/components/ui/alert.tsx +0 -36
- package/src/components/ui/avatar.tsx +0 -48
- package/src/components/ui/badge.tsx +0 -35
- package/src/components/ui/breadcrumb.tsx +0 -115
- package/src/components/ui/button.tsx +0 -43
- package/src/components/ui/calendar.tsx +0 -142
- package/src/components/ui/card.tsx +0 -35
- package/src/components/ui/carousel.tsx +0 -257
- package/src/components/ui/chart.tsx +0 -364
- package/src/components/ui/checkbox.tsx +0 -26
- package/src/components/ui/collapsible.tsx +0 -9
- package/src/components/ui/command.tsx +0 -145
- package/src/components/ui/context-menu.tsx +0 -198
- package/src/components/ui/custom/date-picker.tsx +0 -97
- package/src/components/ui/custom/form/checkbox.tsx +0 -53
- package/src/components/ui/custom/form/color.tsx +0 -140
- package/src/components/ui/custom/form/combobox.tsx +0 -259
- package/src/components/ui/custom/form/cpf-cnpj.tsx +0 -85
- package/src/components/ui/custom/form/currency.tsx +0 -51
- package/src/components/ui/custom/form/date-range.tsx +0 -110
- package/src/components/ui/custom/form/date.tsx +0 -109
- package/src/components/ui/custom/form/decimal.tsx +0 -50
- package/src/components/ui/custom/form/file.tsx +0 -65
- package/src/components/ui/custom/form/form-help-text.tsx +0 -20
- package/src/components/ui/custom/form/form-label.tsx +0 -24
- package/src/components/ui/custom/form/form-message.tsx +0 -10
- package/src/components/ui/custom/form/ghost.tsx +0 -28
- package/src/components/ui/custom/form/input.tsx +0 -69
- package/src/components/ui/custom/form/mask.tsx +0 -78
- package/src/components/ui/custom/form/multi-select.tsx +0 -209
- package/src/components/ui/custom/form/password.tsx +0 -70
- package/src/components/ui/custom/form/percent.tsx +0 -52
- package/src/components/ui/custom/form/phone.tsx +0 -79
- package/src/components/ui/custom/form/radio-group.tsx +0 -94
- package/src/components/ui/custom/form/select.tsx +0 -62
- package/src/components/ui/custom/form/step-new-form.tsx +0 -49
- package/src/components/ui/custom/form/switch.tsx +0 -51
- package/src/components/ui/custom/form/text.tsx +0 -71
- package/src/components/ui/custom/form/textarea.tsx +0 -71
- package/src/components/ui/custom/form/utils.ts +0 -100
- package/src/components/ui/custom/header.tsx +0 -128
- package/src/components/ui/custom/label.tsx +0 -79
- package/src/components/ui/custom/not-found.tsx +0 -30
- package/src/components/ui/custom/sidebar/module-switcher.tsx +0 -58
- package/src/components/ui/custom/sidebar/nav-footer.tsx +0 -35
- package/src/components/ui/custom/sidebar/nav-main.tsx +0 -64
- package/src/components/ui/custom/sidebar/nav-submenu-collapsible.tsx +0 -60
- package/src/components/ui/custom/sidebar/nav-submenu-dropdown.tsx +0 -56
- package/src/components/ui/custom/sidebar/nav-user.tsx +0 -77
- package/src/components/ui/custom/sidebar/sidebar-button.tsx +0 -30
- package/src/components/ui/custom/sidebar/sidebar-item-two-lines.tsx +0 -25
- package/src/components/ui/custom/sidebar/sidebar-item.tsx +0 -19
- package/src/components/ui/custom/sidebar/types/sidebar.ts +0 -31
- package/src/components/ui/custom/table/data-table-export.tsx +0 -126
- package/src/components/ui/custom/table/data-table-footer.tsx +0 -148
- package/src/components/ui/custom/table/data-table-header.tsx +0 -58
- package/src/components/ui/custom/table/data-table-rows.tsx +0 -94
- package/src/components/ui/custom/table/data-table.tsx +0 -285
- package/src/components/ui/custom/table/types/data-table.ts +0 -31
- package/src/components/ui/custom/theme-provider.tsx +0 -121
- package/src/components/ui/dateRangePicker.tsx +0 -63
- package/src/components/ui/dialog.tsx +0 -84
- package/src/components/ui/drawer.tsx +0 -116
- package/src/components/ui/dropdown-menu.tsx +0 -173
- package/src/components/ui/form.tsx +0 -114
- package/src/components/ui/hover-card.tsx +0 -27
- package/src/components/ui/input.tsx +0 -265
- package/src/components/ui/label.tsx +0 -15
- package/src/components/ui/masks.ts +0 -35
- package/src/components/ui/pagination.tsx +0 -78
- package/src/components/ui/popover.tsx +0 -32
- package/src/components/ui/progress.tsx +0 -22
- package/src/components/ui/radio-group.tsx +0 -36
- package/src/components/ui/scroll-area.tsx +0 -46
- package/src/components/ui/select.tsx +0 -130
- package/src/components/ui/separator.tsx +0 -29
- package/src/components/ui/sheet.tsx +0 -90
- package/src/components/ui/sidebar.tsx +0 -598
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/slider.tsx +0 -18
- package/src/components/ui/switch.tsx +0 -26
- package/src/components/ui/table.tsx +0 -53
- package/src/components/ui/tabs.tsx +0 -47
- package/src/components/ui/textarea.tsx +0 -27
- package/src/components/ui/toast.tsx +0 -88
- package/src/components/ui/toaster.tsx +0 -49
- package/src/components/ui/tooltip.tsx +0 -31
- package/src/components/ui/use-calendar.tsx +0 -61
- package/src/components/ui/use-toast.ts +0 -186
- package/src/hooks/use-mobile.tsx +0 -19
- package/src/index.ts +0 -299
- package/src/lib/help/date-utils.ts +0 -41
- package/src/lib/help/format.ts +0 -171
- package/src/lib/help/theme.ts +0 -346
- package/src/lib/help/uuid.ts +0 -4
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -59
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
import { ControllerRenderProps, FieldValues, FormState } from 'react-hook-form';
|
|
3
|
-
import * as FormComponents from '../../form';
|
|
4
|
-
import { MaskInputFone } from '../../input';
|
|
5
|
-
import { formHelpText } from './form-help-text';
|
|
6
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
7
|
-
import { formMessage } from './form-message';
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
control: any;
|
|
11
|
-
name: string;
|
|
12
|
-
label: string;
|
|
13
|
-
subLabel?: string;
|
|
14
|
-
helpText?: JSX.Element;
|
|
15
|
-
placeholder?: string;
|
|
16
|
-
className?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
required?: boolean;
|
|
19
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
20
|
-
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const masks = ['(99) 9999-99999', '(99) 9 9999-9999'];
|
|
24
|
-
|
|
25
|
-
export const FormInputPhone: React.FC<Props> = ({
|
|
26
|
-
control,
|
|
27
|
-
name,
|
|
28
|
-
label,
|
|
29
|
-
subLabel,
|
|
30
|
-
helpText,
|
|
31
|
-
placeholder,
|
|
32
|
-
className,
|
|
33
|
-
disabled,
|
|
34
|
-
required,
|
|
35
|
-
onChange,
|
|
36
|
-
onKeyUp,
|
|
37
|
-
}) => {
|
|
38
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
39
|
-
const [mask, setMask] = useState(masks[0]);
|
|
40
|
-
|
|
41
|
-
const getMask = (val: string) => (val.replace(/\D/g, '').length > 10 ? masks[1] : masks[0]);
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<FormField
|
|
45
|
-
control={control}
|
|
46
|
-
name={name}
|
|
47
|
-
render={({ field, formState }: { field: ControllerRenderProps<FieldValues, string>; formState: FormState<FieldValues> }) => {
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
setMask(getMask(field.value || ''));
|
|
50
|
-
}, [field.value]);
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<FormItem className={className}>
|
|
54
|
-
<div className='flex items-center space-x-1.5'>
|
|
55
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
56
|
-
{helpText && formHelpText(helpText)}
|
|
57
|
-
</div>
|
|
58
|
-
<FormControl>
|
|
59
|
-
<MaskInputFone
|
|
60
|
-
{...field}
|
|
61
|
-
className={className}
|
|
62
|
-
placeholder={placeholder ?? '(00) 0 0000-0000'}
|
|
63
|
-
disabled={disabled || formState.isSubmitting}
|
|
64
|
-
mask={mask}
|
|
65
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
66
|
-
onChange?.(e);
|
|
67
|
-
field.onChange(e);
|
|
68
|
-
setMask(getMask(e.target.value));
|
|
69
|
-
}}
|
|
70
|
-
onKeyUp={(e: React.KeyboardEvent<HTMLInputElement>) => onKeyUp?.(e)}
|
|
71
|
-
/>
|
|
72
|
-
</FormControl>
|
|
73
|
-
{formMessage(FormMessage)}
|
|
74
|
-
</FormItem>
|
|
75
|
-
);
|
|
76
|
-
}}
|
|
77
|
-
/>
|
|
78
|
-
);
|
|
79
|
-
};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ControllerRenderProps, FieldValues, FormState } from 'react-hook-form';
|
|
2
|
-
import { cn } from '../../../../lib/utils';
|
|
3
|
-
import * as FormComponents from '../../form';
|
|
4
|
-
import { Label } from '../../label';
|
|
5
|
-
import { RadioGroup, RadioGroupItem } from '../../radio-group';
|
|
6
|
-
import { formHelpText } from './form-help-text';
|
|
7
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
8
|
-
import { formMessage } from './form-message';
|
|
9
|
-
|
|
10
|
-
export interface RadioOption {
|
|
11
|
-
value: string;
|
|
12
|
-
label: string;
|
|
13
|
-
description?: string;
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface Props {
|
|
17
|
-
control: any;
|
|
18
|
-
name: string;
|
|
19
|
-
value?: string;
|
|
20
|
-
label?: string;
|
|
21
|
-
subLabel?: string;
|
|
22
|
-
helpText?: JSX.Element;
|
|
23
|
-
className?: string;
|
|
24
|
-
classNameOptions?: string;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
required?: boolean;
|
|
27
|
-
options?: RadioOption[];
|
|
28
|
-
onChange?: (value: string) => void;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const FormRadioGroup: React.FC<Props> = ({
|
|
32
|
-
control,
|
|
33
|
-
name,
|
|
34
|
-
value,
|
|
35
|
-
label,
|
|
36
|
-
subLabel,
|
|
37
|
-
helpText,
|
|
38
|
-
className,
|
|
39
|
-
classNameOptions,
|
|
40
|
-
disabled,
|
|
41
|
-
required,
|
|
42
|
-
options,
|
|
43
|
-
onChange,
|
|
44
|
-
}) => {
|
|
45
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
46
|
-
return (
|
|
47
|
-
<FormField
|
|
48
|
-
control={control}
|
|
49
|
-
name={name}
|
|
50
|
-
key={value}
|
|
51
|
-
render={({ field, formState }: { field: ControllerRenderProps<FieldValues, string>; formState: FormState<FieldValues> }) => (
|
|
52
|
-
<FormItem>
|
|
53
|
-
<div className={cn('flex items-center space-x-1.5 mb-2', className)}>
|
|
54
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
55
|
-
{helpText && formHelpText(helpText)}
|
|
56
|
-
</div>
|
|
57
|
-
<FormControl>
|
|
58
|
-
<RadioGroup
|
|
59
|
-
onValueChange={(value: string) => {
|
|
60
|
-
field?.onChange?.(value);
|
|
61
|
-
onChange?.(value);
|
|
62
|
-
}}
|
|
63
|
-
defaultValue={field.value}
|
|
64
|
-
disabled={disabled || formState.isSubmitting}
|
|
65
|
-
className={`${className}`}
|
|
66
|
-
>
|
|
67
|
-
<div className={cn('flex flex-grow gap-6', classNameOptions)}>
|
|
68
|
-
{options?.map((option, index) => (
|
|
69
|
-
<div className='flex flex-col' key={`radio-${name}-${index}`}>
|
|
70
|
-
<div className='flex items-center space-x-2' key={`radio-${name}-${index}`}>
|
|
71
|
-
<RadioGroupItem
|
|
72
|
-
value={option.value}
|
|
73
|
-
id={`r${option.value}`}
|
|
74
|
-
checked={field.value === option.value}
|
|
75
|
-
disabled={option.disabled}
|
|
76
|
-
/>
|
|
77
|
-
<Label htmlFor={`r${option.value}`} className={option.disabled ? 'opacity-50' : ''}>
|
|
78
|
-
{option.label}
|
|
79
|
-
</Label>
|
|
80
|
-
</div>
|
|
81
|
-
{option.description && (
|
|
82
|
-
<div className={cn('pl-6 text-zinc-500', { 'opacity-50': option.disabled })}>{option.description}</div>
|
|
83
|
-
)}
|
|
84
|
-
</div>
|
|
85
|
-
))}
|
|
86
|
-
</div>
|
|
87
|
-
</RadioGroup>
|
|
88
|
-
</FormControl>
|
|
89
|
-
{formMessage(FormMessage)}
|
|
90
|
-
</FormItem>
|
|
91
|
-
)}
|
|
92
|
-
/>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { Select } from '@radix-ui/react-select';
|
|
2
|
-
import { cn } from '../../../../lib/utils';
|
|
3
|
-
import * as FormComponents from '../../form';
|
|
4
|
-
import { SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue } from '../../select';
|
|
5
|
-
import { formHelpText } from './form-help-text';
|
|
6
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
7
|
-
import { formMessage } from './form-message';
|
|
8
|
-
|
|
9
|
-
export interface SelectOption {
|
|
10
|
-
value: string;
|
|
11
|
-
label: string;
|
|
12
|
-
default?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
control: any;
|
|
17
|
-
name: string;
|
|
18
|
-
label: string;
|
|
19
|
-
subLabel?: string;
|
|
20
|
-
helpText?: JSX.Element;
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
className?: string;
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
required?: boolean;
|
|
25
|
-
options: SelectOption[];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const FormSelect: React.FC<Props> = ({ control, name, label, subLabel, helpText, placeholder, className, disabled, required, options }) => {
|
|
29
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<FormField
|
|
33
|
-
control={control}
|
|
34
|
-
name={name}
|
|
35
|
-
render={({ field, formState }) => (
|
|
36
|
-
<FormItem className={className}>
|
|
37
|
-
<div className='flex items-center space-x-1.5'>
|
|
38
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
39
|
-
{helpText && formHelpText(helpText)}
|
|
40
|
-
</div>
|
|
41
|
-
<FormControl>
|
|
42
|
-
<Select onValueChange={field.onChange} defaultValue={field.value} disabled={disabled}>
|
|
43
|
-
<SelectTrigger className={cn('', formState.errors[name] ? 'border-red-600' : '', className)}>
|
|
44
|
-
<SelectValue className='text-slate-400' placeholder={placeholder} />
|
|
45
|
-
</SelectTrigger>
|
|
46
|
-
<SelectContent className='bg-white cursor-pointer'>
|
|
47
|
-
<SelectGroup>
|
|
48
|
-
{options.map((option) => (
|
|
49
|
-
<SelectItem key={option.value} value={option.value}>
|
|
50
|
-
{option.label}
|
|
51
|
-
</SelectItem>
|
|
52
|
-
))}
|
|
53
|
-
</SelectGroup>
|
|
54
|
-
</SelectContent>
|
|
55
|
-
</Select>
|
|
56
|
-
</FormControl>
|
|
57
|
-
{formMessage(FormMessage)}
|
|
58
|
-
</FormItem>
|
|
59
|
-
)}
|
|
60
|
-
/>
|
|
61
|
-
);
|
|
62
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Check } from 'lucide-react';
|
|
2
|
-
import { Separator } from '../../separator';
|
|
3
|
-
|
|
4
|
-
interface PropsStepNewForm {
|
|
5
|
-
steps: { id: string; label: string }[];
|
|
6
|
-
currentIndex: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const StepNewForm = ({ steps, currentIndex }: PropsStepNewForm) => {
|
|
10
|
-
const getStepIcon = (index: number) => {
|
|
11
|
-
if (index < currentIndex) {
|
|
12
|
-
return (
|
|
13
|
-
<div className='flex w-6 h-6 rounded-md items-center justify-center bg-background-secondary border'>
|
|
14
|
-
<Check size={16} className='stroke-2 stroke-primary' />
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<div
|
|
21
|
-
className={`flex w-6 h-6 rounded-md items-center justify-center border ${
|
|
22
|
-
index === currentIndex ? 'bg-background-primary text-white' : 'bg-white text-black'
|
|
23
|
-
}`}
|
|
24
|
-
>
|
|
25
|
-
{index + 1}
|
|
26
|
-
</div>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className='flex flex-row gap-x-3 my-2.5'>
|
|
32
|
-
{steps.map((step, index, array) => (
|
|
33
|
-
<div className='flex items-center text-sm font-medium gap-x-3' key={step.id}>
|
|
34
|
-
<div className='flex items-center text-sm font-medium gap-x-3'>
|
|
35
|
-
{getStepIcon(index)}
|
|
36
|
-
{step.label}
|
|
37
|
-
</div>
|
|
38
|
-
{index + 1 < array.length && (
|
|
39
|
-
<div className='w-10'>
|
|
40
|
-
<Separator />
|
|
41
|
-
</div>
|
|
42
|
-
)}
|
|
43
|
-
</div>
|
|
44
|
-
))}
|
|
45
|
-
</div>
|
|
46
|
-
);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default StepNewForm;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ControllerRenderProps, FieldValues } from 'react-hook-form';
|
|
2
|
-
import { cn } from '../../../../lib/utils';
|
|
3
|
-
import * as FormComponents from '../../form';
|
|
4
|
-
import { Switch } from '../../switch';
|
|
5
|
-
import { formHelpText } from './form-help-text';
|
|
6
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
7
|
-
import { formMessage } from './form-message';
|
|
8
|
-
|
|
9
|
-
interface Props {
|
|
10
|
-
control: any;
|
|
11
|
-
name: string;
|
|
12
|
-
label: string;
|
|
13
|
-
subLabel?: string;
|
|
14
|
-
helpText?: JSX.Element;
|
|
15
|
-
className?: string;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
onCheckedChange?: (checked: boolean) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const FormInputSwitch: React.FC<Props> = ({ control, name, label, subLabel, helpText, className, disabled, onCheckedChange }) => {
|
|
21
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<FormField
|
|
25
|
-
control={control}
|
|
26
|
-
name={name}
|
|
27
|
-
render={({ field }: { field: ControllerRenderProps<FieldValues, string> }) => (
|
|
28
|
-
<FormItem className={cn('flex items-top gap-x-2', className)}>
|
|
29
|
-
<FormControl>
|
|
30
|
-
<Switch
|
|
31
|
-
{...field}
|
|
32
|
-
checked={field.value}
|
|
33
|
-
onCheckedChange={(checked: boolean) => {
|
|
34
|
-
field.onChange(checked);
|
|
35
|
-
if (onCheckedChange) {
|
|
36
|
-
onCheckedChange(checked);
|
|
37
|
-
}
|
|
38
|
-
}}
|
|
39
|
-
disabled={disabled}
|
|
40
|
-
/>
|
|
41
|
-
</FormControl>
|
|
42
|
-
<div className='flex h-full items-center space-x-1.5'>
|
|
43
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, false, 'pb-0')}
|
|
44
|
-
{helpText && formHelpText(helpText)}
|
|
45
|
-
</div>
|
|
46
|
-
{formMessage(FormMessage)}
|
|
47
|
-
</FormItem>
|
|
48
|
-
)}
|
|
49
|
-
/>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ControllerRenderProps, FieldValues, FormState } from 'react-hook-form';
|
|
2
|
-
import * as FormComponents from '../../form';
|
|
3
|
-
import { InputText } from '../../input';
|
|
4
|
-
import { formHelpText } from './form-help-text';
|
|
5
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
6
|
-
import { formMessage } from './form-message';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
control: any;
|
|
10
|
-
name: string;
|
|
11
|
-
label: string;
|
|
12
|
-
subLabel?: string;
|
|
13
|
-
helpText?: JSX.Element;
|
|
14
|
-
placeholder?: string;
|
|
15
|
-
maxLength?: number;
|
|
16
|
-
className?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
required?: boolean;
|
|
19
|
-
inputRef?: React.Ref<HTMLInputElement>;
|
|
20
|
-
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
21
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const FormInputText: React.FC<Props> = ({
|
|
25
|
-
control,
|
|
26
|
-
name,
|
|
27
|
-
label,
|
|
28
|
-
subLabel,
|
|
29
|
-
helpText,
|
|
30
|
-
placeholder,
|
|
31
|
-
maxLength,
|
|
32
|
-
className,
|
|
33
|
-
disabled,
|
|
34
|
-
required,
|
|
35
|
-
inputRef,
|
|
36
|
-
onKeyUp,
|
|
37
|
-
onChange,
|
|
38
|
-
}) => {
|
|
39
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<FormField
|
|
43
|
-
control={control}
|
|
44
|
-
name={name}
|
|
45
|
-
render={({ field, formState }: { field: ControllerRenderProps<FieldValues, string>; formState: FormState<FieldValues> }) => (
|
|
46
|
-
<FormItem className={className}>
|
|
47
|
-
<div className='flex items-center space-x-1.5'>
|
|
48
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
49
|
-
{helpText && formHelpText(helpText)}
|
|
50
|
-
</div>
|
|
51
|
-
<FormControl>
|
|
52
|
-
<InputText
|
|
53
|
-
{...field}
|
|
54
|
-
maxLength={maxLength}
|
|
55
|
-
placeholder={placeholder}
|
|
56
|
-
disabled={disabled || formState.isSubmitting}
|
|
57
|
-
value={field.value || ''}
|
|
58
|
-
onKeyUp={(e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
59
|
-
if (onKeyUp) {
|
|
60
|
-
onKeyUp(e);
|
|
61
|
-
}
|
|
62
|
-
}}
|
|
63
|
-
ref={inputRef}
|
|
64
|
-
/>
|
|
65
|
-
</FormControl>
|
|
66
|
-
{formMessage(FormMessage)}
|
|
67
|
-
</FormItem>
|
|
68
|
-
)}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { ControllerRenderProps, FieldValues, FormState } from 'react-hook-form';
|
|
2
|
-
import * as FormComponents from '../../form';
|
|
3
|
-
import { Textarea } from '../../textarea';
|
|
4
|
-
import { formHelpText } from './form-help-text';
|
|
5
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
6
|
-
import { formMessage } from './form-message';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
control: any;
|
|
10
|
-
name: string;
|
|
11
|
-
label: string;
|
|
12
|
-
subLabel?: string;
|
|
13
|
-
helpText?: JSX.Element;
|
|
14
|
-
placeholder?: string;
|
|
15
|
-
className?: string;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
required?: boolean;
|
|
18
|
-
onChange?: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
19
|
-
onKeyUp?: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export const FormTextarea: React.FC<Props> = ({
|
|
23
|
-
control,
|
|
24
|
-
name,
|
|
25
|
-
label,
|
|
26
|
-
subLabel,
|
|
27
|
-
helpText,
|
|
28
|
-
placeholder,
|
|
29
|
-
className,
|
|
30
|
-
disabled,
|
|
31
|
-
required,
|
|
32
|
-
onChange,
|
|
33
|
-
onKeyUp,
|
|
34
|
-
}) => {
|
|
35
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<FormField
|
|
39
|
-
control={control}
|
|
40
|
-
name={name}
|
|
41
|
-
render={({ field, formState }: { field: ControllerRenderProps<FieldValues, string>; formState: FormState<FieldValues> }) => (
|
|
42
|
-
<FormItem className={className}>
|
|
43
|
-
<div className='flex items-center space-x-1.5'>
|
|
44
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
45
|
-
{helpText && formHelpText(helpText)}
|
|
46
|
-
</div>
|
|
47
|
-
<FormControl>
|
|
48
|
-
<Textarea
|
|
49
|
-
{...field}
|
|
50
|
-
className='resize-none outline-none focus:outline-none'
|
|
51
|
-
placeholder={placeholder}
|
|
52
|
-
disabled={disabled || formState.isSubmitting}
|
|
53
|
-
onChange={(e: React.ChangeEvent<HTMLTextAreaElement>) => {
|
|
54
|
-
field.onChange(e);
|
|
55
|
-
if (onChange) {
|
|
56
|
-
onChange(e);
|
|
57
|
-
}
|
|
58
|
-
}}
|
|
59
|
-
onKeyUp={(e: React.KeyboardEvent<HTMLTextAreaElement>) => {
|
|
60
|
-
if (onKeyUp) {
|
|
61
|
-
onKeyUp(e);
|
|
62
|
-
}
|
|
63
|
-
}}
|
|
64
|
-
/>
|
|
65
|
-
</FormControl>
|
|
66
|
-
{formMessage(FormMessage)}
|
|
67
|
-
</FormItem>
|
|
68
|
-
)}
|
|
69
|
-
/>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
export type RGB = { r: number; g: number; b: number };
|
|
2
|
-
type HSL = { h: number; s: number; l: number };
|
|
3
|
-
|
|
4
|
-
export const rgbToHex = ({ r, g, b }: RGB): string => {
|
|
5
|
-
const toHex = (n: number) => Math.max(0, Math.min(255, n)).toString(16).padStart(2, '0').toUpperCase();
|
|
6
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const hexToRgb = (hex: string): RGB | null => {
|
|
10
|
-
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
11
|
-
return result
|
|
12
|
-
? {
|
|
13
|
-
r: Number.parseInt(result[1], 16),
|
|
14
|
-
g: Number.parseInt(result[2], 16),
|
|
15
|
-
b: Number.parseInt(result[3], 16),
|
|
16
|
-
}
|
|
17
|
-
: null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const rgbToHsl = ({ r, g, b }: RGB): HSL => {
|
|
21
|
-
r /= 255;
|
|
22
|
-
g /= 255;
|
|
23
|
-
b /= 255;
|
|
24
|
-
|
|
25
|
-
const max = Math.max(r, g, b);
|
|
26
|
-
const min = Math.min(r, g, b);
|
|
27
|
-
let h = 0;
|
|
28
|
-
let s = 0;
|
|
29
|
-
const l = (max + min) / 2;
|
|
30
|
-
|
|
31
|
-
if (max !== min) {
|
|
32
|
-
const d = max - min;
|
|
33
|
-
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
34
|
-
|
|
35
|
-
switch (max) {
|
|
36
|
-
case r:
|
|
37
|
-
h = (g - b) / d + (g < b ? 6 : 0);
|
|
38
|
-
break;
|
|
39
|
-
case g:
|
|
40
|
-
h = (b - r) / d + 2;
|
|
41
|
-
break;
|
|
42
|
-
case b:
|
|
43
|
-
h = (r - g) / d + 4;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
h /= 6;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return {
|
|
51
|
-
h: Math.round(h * 360),
|
|
52
|
-
s: Math.round(s * 100),
|
|
53
|
-
l: Math.round(l * 100),
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const hue2rgb = (p: number, q: number, t: number) => {
|
|
58
|
-
let tempT = t;
|
|
59
|
-
if (tempT < 0) tempT += 1;
|
|
60
|
-
if (tempT > 1) tempT -= 1;
|
|
61
|
-
if (tempT < 1 / 6) return p + (q - p) * 6 * tempT;
|
|
62
|
-
if (tempT < 1 / 2) return q;
|
|
63
|
-
if (tempT < 2 / 3) return p + (q - p) * (2 / 3 - tempT) * 6;
|
|
64
|
-
return p;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const hslToRgb = ({ h, s, l }: HSL): RGB => {
|
|
68
|
-
h /= 360;
|
|
69
|
-
s /= 100;
|
|
70
|
-
l /= 100;
|
|
71
|
-
|
|
72
|
-
let r: number;
|
|
73
|
-
let g: number;
|
|
74
|
-
let b: number;
|
|
75
|
-
|
|
76
|
-
if (s === 0) {
|
|
77
|
-
r = g = b = l;
|
|
78
|
-
} else {
|
|
79
|
-
const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
80
|
-
const p = 2 * l - q;
|
|
81
|
-
|
|
82
|
-
r = hue2rgb(p, q, h + 1 / 3);
|
|
83
|
-
g = hue2rgb(p, q, h);
|
|
84
|
-
b = hue2rgb(p, q, h - 1 / 3);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
r: Math.round(r * 255),
|
|
89
|
-
g: Math.round(g * 255),
|
|
90
|
-
b: Math.round(b * 255),
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const formatRgba = (rgb: RGB, a = 1): string => {
|
|
95
|
-
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${a})`;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const formatHsla = (hsl: HSL, a = 1): string => {
|
|
99
|
-
return `hsla(${hsl.h}, ${hsl.s}%, ${hsl.l}%, ${a})`;
|
|
100
|
-
};
|