@granto-umbrella/umbrella-components 2.2.6 → 2.2.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@granto-umbrella/umbrella-components",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
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,68 @@
|
|
|
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
|
|
5
|
-
import { StyledDayPicker } from "./Calendar.styles";
|
|
3
|
+
import { DayPicker } from "react-day-picker";
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
import { buttonVariants } from "@/components/ui/button";
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
export type CalendarProps = React.ComponentProps<typeof DayPicker>;
|
|
9
|
+
|
|
10
|
+
function Calendar({
|
|
11
|
+
className,
|
|
12
|
+
classNames,
|
|
13
|
+
showOutsideDays = true,
|
|
14
|
+
...props
|
|
15
|
+
}: CalendarProps) {
|
|
10
16
|
return (
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
),
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
<DayPicker
|
|
18
|
+
showOutsideDays={showOutsideDays}
|
|
19
|
+
className={cn("p-3", className)}
|
|
20
|
+
classNames={{
|
|
21
|
+
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
|
|
22
|
+
month: "space-y-4",
|
|
23
|
+
caption: "flex justify-center pt-1 relative items-center",
|
|
24
|
+
caption_label: "text-sm font-medium",
|
|
25
|
+
nav: "space-x-1 flex items-center",
|
|
26
|
+
nav_button: cn(
|
|
27
|
+
buttonVariants({ variant: "outline" }),
|
|
28
|
+
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
|
|
29
|
+
),
|
|
30
|
+
nav_button_previous: "absolute left-1",
|
|
31
|
+
nav_button_next: "absolute right-1",
|
|
32
|
+
table: "w-full border-collapse space-y-1",
|
|
33
|
+
head_row: "flex",
|
|
34
|
+
head_cell:
|
|
35
|
+
"text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
|
|
36
|
+
row: "flex w-full mt-2",
|
|
37
|
+
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",
|
|
38
|
+
day: cn(
|
|
39
|
+
buttonVariants({ variant: "ghost" }),
|
|
40
|
+
"h-9 w-9 p-0 font-normal aria-selected:opacity-100"
|
|
41
|
+
),
|
|
42
|
+
day_range_end: "day-range-end",
|
|
43
|
+
day_selected:
|
|
44
|
+
"bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
|
|
45
|
+
day_today: "bg-accent text-accent-foreground",
|
|
46
|
+
day_outside:
|
|
47
|
+
"day-outside text-muted-foreground aria-selected:bg-accent/50 aria-selected:text-muted-foreground",
|
|
48
|
+
day_disabled: "text-muted-foreground opacity-50",
|
|
49
|
+
day_range_middle:
|
|
50
|
+
"aria-selected:bg-accent aria-selected:text-accent-foreground",
|
|
51
|
+
day_hidden: "invisible",
|
|
52
|
+
...classNames,
|
|
53
|
+
}}
|
|
54
|
+
components={{
|
|
55
|
+
IconLeft: ({ className, ...props }) => (
|
|
56
|
+
<ChevronLeft className={cn("h-4 w-4", className)} {...props} />
|
|
57
|
+
),
|
|
58
|
+
IconRight: ({ className, ...props }) => (
|
|
59
|
+
<ChevronRight className={cn("h-4 w-4", className)} {...props} />
|
|
60
|
+
),
|
|
61
|
+
}}
|
|
24
62
|
{...props}
|
|
25
63
|
/>
|
|
26
64
|
);
|
|
27
65
|
}
|
|
28
|
-
|
|
29
66
|
Calendar.displayName = "Calendar";
|
|
30
67
|
|
|
31
68
|
export { Calendar };
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
3
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
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
|
-
|
|
88
|
-
React.ComponentPropsWithoutRef<
|
|
89
|
-
>(({
|
|
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
|
-
<
|
|
93
|
-
{
|
|
94
|
-
|
|
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
|
-
>(({
|
|
130
|
+
>(({ className, ...props }, ref) => {
|
|
125
131
|
const { formDescriptionId } = useFormField();
|
|
132
|
+
|
|
126
133
|
return (
|
|
127
|
-
<
|
|
128
|
-
{
|
|
129
|
-
|
|
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
|
-
|
|
150
|
+
|
|
151
|
+
if (!body) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
141
155
|
return (
|
|
142
|
-
<
|
|
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
|
-
</
|
|
163
|
+
</p>
|
|
145
164
|
);
|
|
146
165
|
});
|
|
147
166
|
FormMessage.displayName = "FormMessage";
|