@granto-umbrella/umbrella-components 2.2.6 → 2.2.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@granto-umbrella/umbrella-components",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "description": "Umbrella Components for React",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -40,7 +40,8 @@
40
40
  "react-day-picker": "^9.6.7",
41
41
  "react-dom": "^18.3.1",
42
42
  "react-hook-form": "^7.54.2",
43
- "react-select": "^5.10.0"
43
+ "react-select": "^5.10.0",
44
+ "tailwind-merge": "^3.2.0"
44
45
  },
45
46
  "devDependencies": {
46
47
  "@chromatic-com/storybook": "3.2.3",
@@ -1,31 +1,63 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  import * as React from "react";
3
2
  import { ChevronLeft, ChevronRight } from "lucide-react";
4
- import { DayPicker as RDPDayPicker } from "react-day-picker";
5
- import { StyledDayPicker } from "./Calendar.styles";
3
+ import { DayPicker } from "react-day-picker";
6
4
 
7
- export type CalendarProps = React.ComponentProps<typeof RDPDayPicker>;
5
+ import { cn } from "@/lib/utils";
8
6
 
9
- function Calendar({ className, ...props }: CalendarProps) {
7
+ export type CalendarProps = React.ComponentProps<typeof DayPicker>;
8
+
9
+ function Calendar({
10
+ className,
11
+ classNames,
12
+ showOutsideDays = true,
13
+ ...props
14
+ }: CalendarProps) {
10
15
  return (
11
- <StyledDayPicker
12
- className={className}
13
- showOutsideDays={true}
14
- components={
15
- {
16
- IconPrevious: ({ className, ...props }: { className?: string }) => (
17
- <ChevronLeft className={className} {...props} />
18
- ),
19
- IconNext: ({ className, ...props }: { className?: string }) => (
20
- <ChevronRight className={className} {...props} />
21
- ),
22
- } as unknown as any
23
- }
16
+ <DayPicker
17
+ showOutsideDays={showOutsideDays}
18
+ className={cn("p-3", className)}
19
+ classNames={{
20
+ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
21
+ month: "space-y-4",
22
+ caption: "flex justify-center pt-1 relative items-center",
23
+ caption_label: "text-sm font-medium",
24
+ nav: "space-x-1 flex items-center",
25
+ nav_button: cn(
26
+ "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
27
+ ),
28
+ nav_button_previous: "absolute left-1",
29
+ nav_button_next: "absolute right-1",
30
+ table: "w-full border-collapse space-y-1",
31
+ head_row: "flex",
32
+ head_cell:
33
+ "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
34
+ row: "flex w-full mt-2",
35
+ cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
36
+ day: cn("h-9 w-9 p-0 font-normal aria-selected:opacity-100"),
37
+ day_range_end: "day-range-end",
38
+ day_selected:
39
+ "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
40
+ day_today: "bg-accent text-accent-foreground",
41
+ day_outside:
42
+ "day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
43
+ day_disabled: "text-muted-foreground opacity-50",
44
+ day_range_middle:
45
+ "aria-selected:bg-accent aria-selected:text-accent-foreground",
46
+ day_hidden: "invisible",
47
+ ...classNames,
48
+ }}
49
+ components={{
50
+ IconLeft: ({ className, ...props }) => (
51
+ <ChevronLeft className={cn("h-4 w-4", className)} {...props} />
52
+ ),
53
+ IconRight: ({ className, ...props }) => (
54
+ <ChevronRight className={cn("h-4 w-4", className)} {...props} />
55
+ ),
56
+ }}
24
57
  {...props}
25
58
  />
26
59
  );
27
60
  }
28
-
29
61
  Calendar.displayName = "Calendar";
30
62
 
31
63
  export { Calendar };
@@ -1,19 +1,25 @@
1
1
  import * as React from "react";
2
2
  import * as PopoverPrimitive from "@radix-ui/react-popover";
3
- import { StyledPopoverContent } from "./Popover.styles";
3
+
4
+ import { cn } from "../../../lib/utils";
4
5
 
5
6
  const Popover = PopoverPrimitive.Root;
7
+
6
8
  const PopoverTrigger = PopoverPrimitive.Trigger;
7
9
 
8
10
  const PopoverContent = React.forwardRef<
9
11
  React.ElementRef<typeof PopoverPrimitive.Content>,
10
12
  React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
11
- >(({ align = "center", sideOffset = 4, ...props }, ref) => (
13
+ >(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
12
14
  <PopoverPrimitive.Portal>
13
- <StyledPopoverContent
15
+ <PopoverPrimitive.Content
14
16
  ref={ref}
15
17
  align={align}
16
18
  sideOffset={sideOffset}
19
+ className={cn(
20
+ "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
21
+ className
22
+ )}
17
23
  {...props}
18
24
  />
19
25
  </PopoverPrimitive.Portal>
@@ -1,4 +1,5 @@
1
1
  import * as React from "react";
2
+ import * as LabelPrimitive from "@radix-ui/react-label";
2
3
  import { Slot } from "@radix-ui/react-slot";
3
4
  import {
4
5
  Controller,
@@ -8,14 +9,10 @@ import {
8
9
  FormProvider,
9
10
  useFormContext,
10
11
  } from "react-hook-form";
11
- import {
12
- StyledFormItem,
13
- StyledFormLabel,
14
- StyledFormDescription,
15
- StyledFormMessage,
16
- } from "./Form.styles";
17
12
 
18
- /* Reexporta o FormProvider como Form para facilitar o uso */
13
+ import { cn } from "../../../lib/utils";
14
+ import { Label } from "../../atoms/Label/Label";
15
+
19
16
  const Form = FormProvider;
20
17
 
21
18
  type FormFieldContextValue<
@@ -42,25 +39,6 @@ const FormField = <
42
39
  );
43
40
  };
44
41
 
45
- type FormItemContextValue = { id: string };
46
-
47
- const FormItemContext = React.createContext<FormItemContextValue>(
48
- {} as FormItemContextValue
49
- );
50
-
51
- const FormItem = React.forwardRef<
52
- HTMLDivElement,
53
- React.HTMLAttributes<HTMLDivElement>
54
- >(({ ...props }, ref) => {
55
- const id = React.useId();
56
- return (
57
- <FormItemContext.Provider value={{ id }}>
58
- <StyledFormItem ref={ref} {...props} />
59
- </FormItemContext.Provider>
60
- );
61
- });
62
- FormItem.displayName = "FormItem";
63
-
64
42
  const useFormField = () => {
65
43
  const fieldContext = React.useContext(FormFieldContext);
66
44
  const itemContext = React.useContext(FormItemContext);
@@ -73,6 +51,7 @@ const useFormField = () => {
73
51
  }
74
52
 
75
53
  const { id } = itemContext;
54
+
76
55
  return {
77
56
  id,
78
57
  name: fieldContext.name,
@@ -83,15 +62,41 @@ const useFormField = () => {
83
62
  };
84
63
  };
85
64
 
65
+ type FormItemContextValue = {
66
+ id: string;
67
+ };
68
+
69
+ const FormItemContext = React.createContext<FormItemContextValue>(
70
+ {} as FormItemContextValue
71
+ );
72
+
73
+ const FormItem = React.forwardRef<
74
+ HTMLDivElement,
75
+ React.HTMLAttributes<HTMLDivElement>
76
+ >(({ className, ...props }, ref) => {
77
+ const id = React.useId();
78
+
79
+ return (
80
+ <FormItemContext.Provider value={{ id }}>
81
+ <div ref={ref} className={cn("space-y-2", className)} {...props} />
82
+ </FormItemContext.Provider>
83
+ );
84
+ });
85
+ FormItem.displayName = "FormItem";
86
+
86
87
  const FormLabel = React.forwardRef<
87
- HTMLLabelElement,
88
- React.ComponentPropsWithoutRef<"label">
89
- >(({ children, ...props }, ref) => {
88
+ React.ElementRef<typeof LabelPrimitive.Root>,
89
+ React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
90
+ >(({ className, ...props }, ref) => {
90
91
  const { error, formItemId } = useFormField();
92
+
91
93
  return (
92
- <StyledFormLabel ref={ref} htmlFor={formItemId} error={!!error} {...props}>
93
- {children}
94
- </StyledFormLabel>
94
+ <Label
95
+ ref={ref}
96
+ className={cn(error && "text-destructive", className)}
97
+ htmlFor={formItemId}
98
+ {...props}
99
+ />
95
100
  );
96
101
  });
97
102
  FormLabel.displayName = "FormLabel";
@@ -102,6 +107,7 @@ const FormControl = React.forwardRef<
102
107
  >(({ ...props }, ref) => {
103
108
  const { error, formItemId, formDescriptionId, formMessageId } =
104
109
  useFormField();
110
+
105
111
  return (
106
112
  <Slot
107
113
  ref={ref}
@@ -121,12 +127,16 @@ FormControl.displayName = "FormControl";
121
127
  const FormDescription = React.forwardRef<
122
128
  HTMLParagraphElement,
123
129
  React.HTMLAttributes<HTMLParagraphElement>
124
- >(({ children, ...props }, ref) => {
130
+ >(({ className, ...props }, ref) => {
125
131
  const { formDescriptionId } = useFormField();
132
+
126
133
  return (
127
- <StyledFormDescription ref={ref} id={formDescriptionId} {...props}>
128
- {children}
129
- </StyledFormDescription>
134
+ <p
135
+ ref={ref}
136
+ id={formDescriptionId}
137
+ className={cn("text-sm text-muted-foreground", className)}
138
+ {...props}
139
+ />
130
140
  );
131
141
  });
132
142
  FormDescription.displayName = "FormDescription";
@@ -134,14 +144,23 @@ FormDescription.displayName = "FormDescription";
134
144
  const FormMessage = React.forwardRef<
135
145
  HTMLParagraphElement,
136
146
  React.HTMLAttributes<HTMLParagraphElement>
137
- >(({ children, ...props }, ref) => {
147
+ >(({ className, children, ...props }, ref) => {
138
148
  const { error, formMessageId } = useFormField();
139
149
  const body = error ? String(error?.message) : children;
140
- if (!body) return null;
150
+
151
+ if (!body) {
152
+ return null;
153
+ }
154
+
141
155
  return (
142
- <StyledFormMessage ref={ref} id={formMessageId} {...props}>
156
+ <p
157
+ ref={ref}
158
+ id={formMessageId}
159
+ className={cn("text-sm font-medium text-destructive", className)}
160
+ {...props}
161
+ >
143
162
  {body}
144
- </StyledFormMessage>
163
+ </p>
145
164
  );
146
165
  });
147
166
  FormMessage.displayName = "FormMessage";
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }