eai-frontend-components 2.0.5 → 2.0.7
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/dist/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- 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 -363
- 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,65 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import * as FormComponents from '../../form';
|
|
3
|
-
import { InputFile } 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
|
-
className?: string;
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
required?: boolean;
|
|
18
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const FormInputFile: React.FC<Props> = ({
|
|
22
|
-
control,
|
|
23
|
-
name,
|
|
24
|
-
label,
|
|
25
|
-
subLabel,
|
|
26
|
-
helpText,
|
|
27
|
-
placeholder,
|
|
28
|
-
className,
|
|
29
|
-
disabled,
|
|
30
|
-
required,
|
|
31
|
-
onChange,
|
|
32
|
-
}) => {
|
|
33
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
34
|
-
const [value, setValue] = useState('');
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<FormField
|
|
38
|
-
control={control}
|
|
39
|
-
name={name}
|
|
40
|
-
render={({ field, formState }) => (
|
|
41
|
-
<FormItem className={className}>
|
|
42
|
-
<div className='flex items-center space-x-1.5'>
|
|
43
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
44
|
-
{helpText && formHelpText(helpText)}
|
|
45
|
-
</div>
|
|
46
|
-
<FormControl>
|
|
47
|
-
<InputFile
|
|
48
|
-
value={value}
|
|
49
|
-
placeholder={placeholder}
|
|
50
|
-
disabled={disabled || formState.isSubmitting}
|
|
51
|
-
onChange={(e) => {
|
|
52
|
-
if (onChange) {
|
|
53
|
-
onChange(e);
|
|
54
|
-
}
|
|
55
|
-
setValue(e.target.value);
|
|
56
|
-
field.onChange(e.target.files);
|
|
57
|
-
}}
|
|
58
|
-
/>
|
|
59
|
-
</FormControl>
|
|
60
|
-
{formMessage(FormMessage)}
|
|
61
|
-
</FormItem>
|
|
62
|
-
)}
|
|
63
|
-
/>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CircleHelp } from 'lucide-react';
|
|
2
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../tooltip';
|
|
3
|
-
|
|
4
|
-
const formHelpText = (helpText: JSX.Element) => {
|
|
5
|
-
return (
|
|
6
|
-
<TooltipProvider>
|
|
7
|
-
<Tooltip>
|
|
8
|
-
<TooltipTrigger className='pb-2'>
|
|
9
|
-
<CircleHelp size={16} className='text-muted' />
|
|
10
|
-
</TooltipTrigger>
|
|
11
|
-
<TooltipContent className='text-white bg-background-primary' align='start'>
|
|
12
|
-
{helpText}
|
|
13
|
-
</TooltipContent>
|
|
14
|
-
</Tooltip>
|
|
15
|
-
</TooltipProvider>
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { formHelpText };
|
|
20
|
-
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import * as LabelPrimitive from '@radix-ui/react-label';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { cn } from '../../../../lib/utils';
|
|
4
|
-
|
|
5
|
-
type FormLabelComponent = React.ForwardRefExoticComponent<React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> & React.RefAttributes<React.ElementRef<typeof LabelPrimitive.Root>>>;
|
|
6
|
-
|
|
7
|
-
const formLabel = (FormLabel: FormLabelComponent, label: string) => {
|
|
8
|
-
return <FormLabel className='text-default font-medium text-sm h-5'>{label}</FormLabel>;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const formLabelAndSubLabel = (FormLabel: FormLabelComponent, label: string, subLabel?: string, required?: boolean | undefined, className?: string) => {
|
|
12
|
-
return (
|
|
13
|
-
<div className={cn('flex flex-col pb-2', className)}>
|
|
14
|
-
<div className='flex gap-1'>
|
|
15
|
-
{formLabel(FormLabel, label)}
|
|
16
|
-
{required && <FormLabel className='text-red-600 font-medium text-sm'>*</FormLabel>}
|
|
17
|
-
</div>
|
|
18
|
-
{subLabel && <FormLabel className='text-default font-normal pt-1'>{subLabel}</FormLabel>}
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export { formLabel, formLabelAndSubLabel };
|
|
24
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
type FormMessageComponent = React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
4
|
-
|
|
5
|
-
const formMessage = (FormMessage: FormMessageComponent) => {
|
|
6
|
-
return <FormMessage className='text-red-600 mt-1' />;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export { formMessage };
|
|
10
|
-
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as FormComponents from '../../form';
|
|
2
|
-
import { InputText } from '../../input';
|
|
3
|
-
import { formMessage } from './form-message';
|
|
4
|
-
|
|
5
|
-
interface Props {
|
|
6
|
-
control: any;
|
|
7
|
-
name: string;
|
|
8
|
-
className?: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const FormInputGhost: React.FC<Props> = ({ control, name, className }) => {
|
|
12
|
-
const { FormField, FormItem, FormControl, FormMessage } = FormComponents;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<FormField
|
|
16
|
-
control={control}
|
|
17
|
-
name={name}
|
|
18
|
-
render={({ field }) => (
|
|
19
|
-
<FormItem className={className}>
|
|
20
|
-
<FormControl>
|
|
21
|
-
<InputText {...field} className='hidden' />
|
|
22
|
-
</FormControl>
|
|
23
|
-
{formMessage(FormMessage)}
|
|
24
|
-
</FormItem>
|
|
25
|
-
)}
|
|
26
|
-
/>
|
|
27
|
-
);
|
|
28
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as FormComponents from '../../form';
|
|
2
|
-
import { Input } from '../../input';
|
|
3
|
-
import { formHelpText } from './form-help-text';
|
|
4
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
5
|
-
import { formMessage } from './form-message';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
control: any;
|
|
9
|
-
type?: string;
|
|
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
|
-
onChange?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
20
|
-
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const FormInput: React.FC<Props> = ({
|
|
24
|
-
control,
|
|
25
|
-
type,
|
|
26
|
-
name,
|
|
27
|
-
label,
|
|
28
|
-
subLabel,
|
|
29
|
-
helpText,
|
|
30
|
-
placeholder,
|
|
31
|
-
maxLength,
|
|
32
|
-
className,
|
|
33
|
-
disabled,
|
|
34
|
-
required,
|
|
35
|
-
onKeyUp,
|
|
36
|
-
}) => {
|
|
37
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<FormField
|
|
41
|
-
control={control}
|
|
42
|
-
name={name}
|
|
43
|
-
render={({ field, formState }) => (
|
|
44
|
-
<FormItem className={className}>
|
|
45
|
-
<div className='flex items-center space-x-1.5'>
|
|
46
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
47
|
-
{helpText && formHelpText(helpText)}
|
|
48
|
-
</div>
|
|
49
|
-
<FormControl>
|
|
50
|
-
<Input
|
|
51
|
-
{...field}
|
|
52
|
-
className={className}
|
|
53
|
-
maxLength={maxLength}
|
|
54
|
-
placeholder={placeholder}
|
|
55
|
-
disabled={disabled || formState.isSubmitting}
|
|
56
|
-
type={type}
|
|
57
|
-
onKeyUp={(e) => {
|
|
58
|
-
if (onKeyUp) {
|
|
59
|
-
onKeyUp(e);
|
|
60
|
-
}
|
|
61
|
-
}}
|
|
62
|
-
/>
|
|
63
|
-
</FormControl>
|
|
64
|
-
{formMessage(FormMessage)}
|
|
65
|
-
</FormItem>
|
|
66
|
-
)}
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import * as FormComponents from '../../form';
|
|
2
|
-
import { MaskInput } from '../../input';
|
|
3
|
-
import { formHelpText } from './form-help-text';
|
|
4
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
5
|
-
import { formMessage } from './form-message';
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
control: any;
|
|
9
|
-
name: string;
|
|
10
|
-
label: string;
|
|
11
|
-
subLabel?: string;
|
|
12
|
-
helpText?: JSX.Element;
|
|
13
|
-
placeholder?: string;
|
|
14
|
-
mask: string;
|
|
15
|
-
maskPlaceholder?: string | null;
|
|
16
|
-
className?: string;
|
|
17
|
-
disabled?: boolean;
|
|
18
|
-
required?: boolean;
|
|
19
|
-
inputRef?: React.Ref<HTMLInputElement>;
|
|
20
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
21
|
-
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const FormInputMask: React.FC<Props> = ({
|
|
25
|
-
control,
|
|
26
|
-
name,
|
|
27
|
-
label,
|
|
28
|
-
subLabel,
|
|
29
|
-
helpText,
|
|
30
|
-
placeholder,
|
|
31
|
-
mask,
|
|
32
|
-
maskPlaceholder,
|
|
33
|
-
className,
|
|
34
|
-
disabled,
|
|
35
|
-
required,
|
|
36
|
-
inputRef,
|
|
37
|
-
onChange,
|
|
38
|
-
onKeyUp,
|
|
39
|
-
}) => {
|
|
40
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<FormField
|
|
44
|
-
control={control}
|
|
45
|
-
name={name}
|
|
46
|
-
render={({ field, formState }) => (
|
|
47
|
-
<FormItem className={className}>
|
|
48
|
-
<div className='flex items-center space-x-1.5'>
|
|
49
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
50
|
-
{helpText && formHelpText(helpText)}
|
|
51
|
-
</div>
|
|
52
|
-
<FormControl>
|
|
53
|
-
<MaskInput
|
|
54
|
-
{...field}
|
|
55
|
-
mask={mask}
|
|
56
|
-
maskPlaceholder={maskPlaceholder}
|
|
57
|
-
placeholder={placeholder}
|
|
58
|
-
disabled={disabled || formState.isSubmitting}
|
|
59
|
-
onChange={(e) => {
|
|
60
|
-
field.onChange(e);
|
|
61
|
-
if (onChange) {
|
|
62
|
-
onChange(e);
|
|
63
|
-
}
|
|
64
|
-
}}
|
|
65
|
-
onKeyUp={(e) => {
|
|
66
|
-
if (onKeyUp) {
|
|
67
|
-
onKeyUp(e);
|
|
68
|
-
}
|
|
69
|
-
}}
|
|
70
|
-
ref={inputRef}
|
|
71
|
-
/>
|
|
72
|
-
</FormControl>
|
|
73
|
-
{formMessage(FormMessage)}
|
|
74
|
-
</FormItem>
|
|
75
|
-
)}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
};
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { type VariantProps, cva } from 'class-variance-authority';
|
|
2
|
-
import { CheckIcon, ChevronDown, X } from 'lucide-react';
|
|
3
|
-
import * as React from 'react';
|
|
4
|
-
import { ControllerRenderProps, FieldValues } from 'react-hook-form';
|
|
5
|
-
import { cn } from '../../../../lib/utils';
|
|
6
|
-
import { Badge } from '../../badge';
|
|
7
|
-
import { Button } from '../../button';
|
|
8
|
-
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '../../command';
|
|
9
|
-
import * as FormComponents from '../../form';
|
|
10
|
-
import { Popover, PopoverContent, PopoverTrigger } from '../../popover';
|
|
11
|
-
import { formHelpText } from './form-help-text';
|
|
12
|
-
import { formLabelAndSubLabel } from './form-label';
|
|
13
|
-
import { formMessage } from './form-message';
|
|
14
|
-
|
|
15
|
-
const multiSelectVariants = cva('m-1 rounded-[6px]', {
|
|
16
|
-
variants: {
|
|
17
|
-
variant: {
|
|
18
|
-
default: 'text-foreground bg-background-secondary dark:bg-popover hover:bg-background-secondary',
|
|
19
|
-
secondary: 'border-foreground/10 bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
20
|
-
destructive: 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
|
|
21
|
-
inverted: 'inverted',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
defaultVariants: {
|
|
25
|
-
variant: 'default',
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export interface MultiSelectOption {
|
|
30
|
-
value: string;
|
|
31
|
-
label: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface MultiSelectProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof multiSelectVariants> {
|
|
35
|
-
control: any;
|
|
36
|
-
name: string;
|
|
37
|
-
label?: string;
|
|
38
|
-
subLabel?: string;
|
|
39
|
-
helpText?: JSX.Element;
|
|
40
|
-
options: MultiSelectOption[];
|
|
41
|
-
placeholder?: string;
|
|
42
|
-
maxCount?: number;
|
|
43
|
-
modalPopover?: boolean;
|
|
44
|
-
asChild?: boolean;
|
|
45
|
-
className?: string;
|
|
46
|
-
required?: boolean;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const MultiSelect = React.forwardRef<HTMLButtonElement, MultiSelectProps>(
|
|
50
|
-
(
|
|
51
|
-
{
|
|
52
|
-
control,
|
|
53
|
-
name,
|
|
54
|
-
label,
|
|
55
|
-
subLabel,
|
|
56
|
-
helpText,
|
|
57
|
-
options,
|
|
58
|
-
variant,
|
|
59
|
-
placeholder,
|
|
60
|
-
maxCount = 2,
|
|
61
|
-
modalPopover = false,
|
|
62
|
-
asChild = false,
|
|
63
|
-
className,
|
|
64
|
-
required,
|
|
65
|
-
...props
|
|
66
|
-
},
|
|
67
|
-
ref,
|
|
68
|
-
) => {
|
|
69
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
70
|
-
const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);
|
|
71
|
-
const DEFAULT_PLACEHOLDER_FILTER = 'Digite para buscar...';
|
|
72
|
-
const DEFAULT_PLACEHOLDER = 'Selecione';
|
|
73
|
-
|
|
74
|
-
const toggleOption = (option: MultiSelectOption, field: ControllerRenderProps<FieldValues, string>) => {
|
|
75
|
-
const prevValue = field.value || [];
|
|
76
|
-
|
|
77
|
-
const newValue = prevValue?.some((item: MultiSelectOption) => item.value === option.value)
|
|
78
|
-
? prevValue.filter((item: MultiSelectOption) => item.value !== option.value)
|
|
79
|
-
: [...prevValue, option];
|
|
80
|
-
|
|
81
|
-
field.onChange(newValue);
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const handleClear = (field: ControllerRenderProps<FieldValues, string>) => {
|
|
85
|
-
field.onChange([]);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const handleTogglePopover = () => {
|
|
89
|
-
setIsPopoverOpen((prev) => !prev);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const toggleAll = (field: ControllerRenderProps<FieldValues, string>) => {
|
|
93
|
-
if (field.value?.length === options.length) {
|
|
94
|
-
handleClear(field);
|
|
95
|
-
} else {
|
|
96
|
-
const allValues = options.map((option) => option);
|
|
97
|
-
field.onChange(allValues);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<FormField
|
|
103
|
-
control={control}
|
|
104
|
-
name={name}
|
|
105
|
-
render={({ field }) => (
|
|
106
|
-
<FormItem>
|
|
107
|
-
<div className='flex items-center space-x-1.5'>
|
|
108
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
109
|
-
{helpText && formHelpText(helpText)}
|
|
110
|
-
</div>
|
|
111
|
-
<Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen} modal={modalPopover}>
|
|
112
|
-
<PopoverTrigger asChild>
|
|
113
|
-
<Button
|
|
114
|
-
ref={ref}
|
|
115
|
-
{...props}
|
|
116
|
-
onClick={handleTogglePopover}
|
|
117
|
-
className={cn(
|
|
118
|
-
'flex w-full p-1 rounded-md border min-h-10 h-auto items-center justify-between bg-background hover:bg-background [&_svg]:size-3.5',
|
|
119
|
-
className,
|
|
120
|
-
)}
|
|
121
|
-
>
|
|
122
|
-
{field.value?.length > 0 ? (
|
|
123
|
-
<div className='flex justify-between items-center w-full'>
|
|
124
|
-
<div className='flex items-center'>
|
|
125
|
-
<div className={`grid grid-cols-${maxCount}`}>
|
|
126
|
-
{field.value.slice(0, maxCount).map((option: MultiSelectOption) => {
|
|
127
|
-
return (
|
|
128
|
-
<Badge
|
|
129
|
-
key={`msoptlbl-${option.value}`}
|
|
130
|
-
className={cn(multiSelectVariants({ variant }))}
|
|
131
|
-
onClick={(event) => {
|
|
132
|
-
event.stopPropagation();
|
|
133
|
-
toggleOption(option, field);
|
|
134
|
-
}}
|
|
135
|
-
>
|
|
136
|
-
<div className='truncate'>{option?.label}</div>
|
|
137
|
-
<X className='ml-2 cursor-pointer text-zinc-500' />
|
|
138
|
-
</Badge>
|
|
139
|
-
);
|
|
140
|
-
})}
|
|
141
|
-
</div>
|
|
142
|
-
{field.value?.length > maxCount && (
|
|
143
|
-
<Badge variant={'surface'}
|
|
144
|
-
>
|
|
145
|
-
{`+${field.value?.length - maxCount}`}
|
|
146
|
-
</Badge>
|
|
147
|
-
)}
|
|
148
|
-
</div>
|
|
149
|
-
<div className='flex items-center justify-between'>
|
|
150
|
-
<ChevronDown className='h-4 mx-2 cursor-pointer text-muted-foreground' />
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
) : (
|
|
154
|
-
<div className='flex items-center justify-between w-full mx-auto'>
|
|
155
|
-
<span className='text-sm text-muted-foreground mx-3'>{placeholder ?? DEFAULT_PLACEHOLDER}</span>
|
|
156
|
-
<ChevronDown className='h-4 cursor-pointer text-muted-foreground mx-2' />
|
|
157
|
-
</div>
|
|
158
|
-
)}
|
|
159
|
-
</Button>
|
|
160
|
-
</PopoverTrigger>
|
|
161
|
-
<PopoverContent className={cn('w-auto p-0', 'w-[--radix-popover-trigger-width]')} align='start' onEscapeKeyDown={() => setIsPopoverOpen(false)}>
|
|
162
|
-
<Command>
|
|
163
|
-
<CommandInput placeholder={DEFAULT_PLACEHOLDER_FILTER} />
|
|
164
|
-
<CommandList>
|
|
165
|
-
<CommandEmpty>Nenhum resultado encontrado</CommandEmpty>
|
|
166
|
-
<CommandGroup>
|
|
167
|
-
<CommandItem key='all' onSelect={() => toggleAll(field)} className='cursor-pointer'>
|
|
168
|
-
<div
|
|
169
|
-
className={cn(
|
|
170
|
-
'mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary',
|
|
171
|
-
field.value?.length === options.length
|
|
172
|
-
? 'bg-primary text-primary-foreground'
|
|
173
|
-
: 'opacity-50 [&_svg]:invisible',
|
|
174
|
-
)}
|
|
175
|
-
>
|
|
176
|
-
<CheckIcon className='h-4 w-4' />
|
|
177
|
-
</div>
|
|
178
|
-
<span>(Selecionar Todos)</span>
|
|
179
|
-
</CommandItem>
|
|
180
|
-
{options.map((option) => {
|
|
181
|
-
const isSelected = field.value?.some((item: MultiSelectOption) => item.value === option.value);
|
|
182
|
-
return (
|
|
183
|
-
<CommandItem key={`msopt-${option.value}`} onSelect={() => toggleOption(option, field)} className='cursor-pointer'>
|
|
184
|
-
<div
|
|
185
|
-
className={cn(
|
|
186
|
-
'mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary',
|
|
187
|
-
isSelected ? 'bg-primary text-primary-foreground' : 'opacity-50 [&_svg]:invisible',
|
|
188
|
-
)}
|
|
189
|
-
>
|
|
190
|
-
<CheckIcon className='h-4 w-4' />
|
|
191
|
-
</div>
|
|
192
|
-
<span>{option.label}</span>
|
|
193
|
-
</CommandItem>
|
|
194
|
-
);
|
|
195
|
-
})}
|
|
196
|
-
</CommandGroup>
|
|
197
|
-
</CommandList>
|
|
198
|
-
</Command>
|
|
199
|
-
</PopoverContent>
|
|
200
|
-
</Popover>
|
|
201
|
-
{formMessage(FormMessage)}
|
|
202
|
-
</FormItem>
|
|
203
|
-
)}
|
|
204
|
-
/>
|
|
205
|
-
);
|
|
206
|
-
},
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
MultiSelect.displayName = 'MultiSelect';
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Eye, EyeOff } from 'lucide-react';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import * as FormComponents from '../../form';
|
|
4
|
-
import { InputText } 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
|
-
maxLength?: number;
|
|
17
|
-
className?: string;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
required?: boolean;
|
|
20
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const FormInputPassWord: React.FC<Props> = ({
|
|
24
|
-
control,
|
|
25
|
-
name,
|
|
26
|
-
label,
|
|
27
|
-
subLabel,
|
|
28
|
-
helpText,
|
|
29
|
-
placeholder,
|
|
30
|
-
maxLength,
|
|
31
|
-
className,
|
|
32
|
-
disabled,
|
|
33
|
-
required,
|
|
34
|
-
}) => {
|
|
35
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
36
|
-
const [showPassword, setShowPassword] = useState(true);
|
|
37
|
-
const togglePasswordVisibility = () => setShowPassword((prev) => !prev);
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<FormField
|
|
41
|
-
control={control}
|
|
42
|
-
name={name}
|
|
43
|
-
render={({ field, formState }) => (
|
|
44
|
-
<FormItem className={className}>
|
|
45
|
-
<div className='flex items-center space-x-1.5'>
|
|
46
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
47
|
-
{helpText && formHelpText(helpText)}
|
|
48
|
-
</div>
|
|
49
|
-
<FormControl>
|
|
50
|
-
<div className='relative w-full'>
|
|
51
|
-
<InputText
|
|
52
|
-
{...field}
|
|
53
|
-
type={showPassword ? 'password' : 'text'}
|
|
54
|
-
name={name}
|
|
55
|
-
maxLength={maxLength}
|
|
56
|
-
className={className}
|
|
57
|
-
placeholder={placeholder}
|
|
58
|
-
disabled={disabled || formState.isSubmitting}
|
|
59
|
-
/>
|
|
60
|
-
<button type='button' onClick={togglePasswordVisibility} className='absolute inset-y-0 right-2 flex items-center'>
|
|
61
|
-
{showPassword ? <EyeOff className='w-5 h-5 text-slate-500' /> : <Eye className='w-5 h-5 text-slate-500' />}
|
|
62
|
-
</button>
|
|
63
|
-
</div>
|
|
64
|
-
</FormControl>
|
|
65
|
-
{formMessage(FormMessage)}
|
|
66
|
-
</FormItem>
|
|
67
|
-
)}
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { ControllerRenderProps, FieldValues, FormState } from 'react-hook-form';
|
|
2
|
-
import * as FormComponents from '../../form';
|
|
3
|
-
import { MaskInputDecimal } 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
|
-
className?: string;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
required?: boolean;
|
|
17
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const FormInputPercent: React.FC<Props> = ({ control, name, label, subLabel, helpText, className, disabled, required, onChange }) => {
|
|
21
|
-
const { FormField, FormItem, FormLabel, FormControl, FormMessage } = FormComponents;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<FormField
|
|
25
|
-
control={control}
|
|
26
|
-
name={name}
|
|
27
|
-
render={({ field, formState }: { field: ControllerRenderProps<FieldValues, string>; formState: FormState<FieldValues> }) => (
|
|
28
|
-
<FormItem className={className}>
|
|
29
|
-
<div className='flex items-center space-x-1.5'>
|
|
30
|
-
{label && formLabelAndSubLabel(FormLabel, label, subLabel, required)}
|
|
31
|
-
{helpText && formHelpText(helpText)}
|
|
32
|
-
</div>
|
|
33
|
-
<FormControl>
|
|
34
|
-
<MaskInputDecimal
|
|
35
|
-
{...field}
|
|
36
|
-
symbol='%'
|
|
37
|
-
className={`${className}`}
|
|
38
|
-
disabled={disabled || formState.isSubmitting}
|
|
39
|
-
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
40
|
-
field.onChange(e);
|
|
41
|
-
if (onChange) {
|
|
42
|
-
onChange(e);
|
|
43
|
-
}
|
|
44
|
-
}}
|
|
45
|
-
/>
|
|
46
|
-
</FormControl>
|
|
47
|
-
{formMessage(FormMessage)}
|
|
48
|
-
</FormItem>
|
|
49
|
-
)}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
};
|