@open-elements/ui 0.1.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/LICENSE +201 -0
- package/README.md +37 -0
- package/dist/brand.css +48 -0
- package/dist/components/alert-dialog.d.ts +19 -0
- package/dist/components/alert-dialog.d.ts.map +1 -0
- package/dist/components/alert-dialog.js +66 -0
- package/dist/components/alert-dialog.js.map +1 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +37 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/button.d.ts +11 -0
- package/dist/components/button.d.ts.map +1 -0
- package/dist/components/button.js +48 -0
- package/dist/components/button.js.map +1 -0
- package/dist/components/calendar.d.ts +9 -0
- package/dist/components/calendar.d.ts.map +1 -0
- package/dist/components/calendar.js +58 -0
- package/dist/components/calendar.js.map +1 -0
- package/dist/components/card.d.ts +10 -0
- package/dist/components/card.d.ts.map +1 -0
- package/dist/components/card.js +43 -0
- package/dist/components/card.js.map +1 -0
- package/dist/components/combobox.d.ts +25 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +85 -0
- package/dist/components/combobox.js.map +1 -0
- package/dist/components/dialog.d.ts +18 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +59 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/health-status.d.ts +12 -0
- package/dist/components/health-status.d.ts.map +1 -0
- package/dist/components/health-status.js +8 -0
- package/dist/components/health-status.js.map +1 -0
- package/dist/components/input-group.d.ts +17 -0
- package/dist/components/input-group.d.ts.map +1 -0
- package/dist/components/input-group.js +82 -0
- package/dist/components/input-group.js.map +1 -0
- package/dist/components/input.d.ts +4 -0
- package/dist/components/input.d.ts.map +1 -0
- package/dist/components/input.js +19 -0
- package/dist/components/input.js.map +1 -0
- package/dist/components/label.d.ts +5 -0
- package/dist/components/label.d.ts.map +1 -0
- package/dist/components/label.js +21 -0
- package/dist/components/label.js.map +1 -0
- package/dist/components/language-switch.d.ts +2 -0
- package/dist/components/language-switch.d.ts.map +1 -0
- package/dist/components/language-switch.js +13 -0
- package/dist/components/language-switch.js.map +1 -0
- package/dist/components/popover.d.ts +11 -0
- package/dist/components/popover.d.ts.map +1 -0
- package/dist/components/popover.js +45 -0
- package/dist/components/popover.js.map +1 -0
- package/dist/components/select.d.ts +16 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +60 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/separator.d.ts +5 -0
- package/dist/components/separator.d.ts.map +1 -0
- package/dist/components/separator.js +21 -0
- package/dist/components/separator.js.map +1 -0
- package/dist/components/sheet.d.ts +15 -0
- package/dist/components/sheet.d.ts.map +1 -0
- package/dist/components/sheet.js +62 -0
- package/dist/components/sheet.js.map +1 -0
- package/dist/components/sidebar.d.ts +53 -0
- package/dist/components/sidebar.d.ts.map +1 -0
- package/dist/components/sidebar.js +44 -0
- package/dist/components/sidebar.js.map +1 -0
- package/dist/components/skeleton.d.ts +3 -0
- package/dist/components/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton.js +19 -0
- package/dist/components/skeleton.js.map +1 -0
- package/dist/components/table.d.ts +11 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +48 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tag-chips.d.ts +8 -0
- package/dist/components/tag-chips.d.ts.map +1 -0
- package/dist/components/tag-chips.js +22 -0
- package/dist/components/tag-chips.js.map +1 -0
- package/dist/components/tag-form.d.ts +29 -0
- package/dist/components/tag-form.d.ts.map +1 -0
- package/dist/components/tag-form.js +84 -0
- package/dist/components/tag-form.js.map +1 -0
- package/dist/components/tag-multi-select.d.ts +4 -0
- package/dist/components/tag-multi-select.d.ts.map +1 -0
- package/dist/components/tag-multi-select.js +30 -0
- package/dist/components/tag-multi-select.js.map +1 -0
- package/dist/components/textarea.d.ts +4 -0
- package/dist/components/textarea.d.ts.map +1 -0
- package/dist/components/textarea.js +19 -0
- package/dist/components/textarea.js.map +1 -0
- package/dist/components/tooltip.d.ts +8 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +26 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/i18n/de.d.ts +7 -0
- package/dist/i18n/de.d.ts.map +1 -0
- package/dist/i18n/de.js +7 -0
- package/dist/i18n/de.js.map +1 -0
- package/dist/i18n/en.d.ts +7 -0
- package/dist/i18n/en.d.ts.map +1 -0
- package/dist/i18n/en.js +7 -0
- package/dist/i18n/en.js.map +1 -0
- package/dist/i18n/language-context.d.ts +14 -0
- package/dist/i18n/language-context.d.ts.map +1 -0
- package/dist/i18n/language-context.js +77 -0
- package/dist/i18n/language-context.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +77 -0
- package/src/components/__tests__/button.test.tsx +41 -0
- package/src/components/__tests__/input.test.tsx +28 -0
- package/src/components/__tests__/tag-multi-select.test.tsx +131 -0
- package/src/components/__tests__/textarea.test.tsx +22 -0
- package/src/components/alert-dialog.tsx +179 -0
- package/src/components/badge.tsx +46 -0
- package/src/components/button.tsx +62 -0
- package/src/components/calendar.tsx +180 -0
- package/src/components/card.tsx +75 -0
- package/src/components/combobox.tsx +277 -0
- package/src/components/dialog.tsx +144 -0
- package/src/components/health-status.tsx +37 -0
- package/src/components/input-group.tsx +158 -0
- package/src/components/input.tsx +21 -0
- package/src/components/label.tsx +21 -0
- package/src/components/language-switch.tsx +36 -0
- package/src/components/popover.tsx +74 -0
- package/src/components/select.tsx +175 -0
- package/src/components/separator.tsx +28 -0
- package/src/components/sheet.tsx +134 -0
- package/src/components/sidebar.tsx +290 -0
- package/src/components/skeleton.tsx +13 -0
- package/src/components/table.tsx +92 -0
- package/src/components/tag-chips.tsx +47 -0
- package/src/components/tag-form.tsx +200 -0
- package/src/components/tag-multi-select.tsx +84 -0
- package/src/components/textarea.tsx +18 -0
- package/src/components/tooltip.tsx +32 -0
- package/src/i18n/de.ts +6 -0
- package/src/i18n/en.ts +6 -0
- package/src/i18n/language-context.tsx +104 -0
- package/src/index.ts +156 -0
- package/src/lib/__tests__/utils.test.ts +29 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/brand.css +48 -0
- package/src/test/setup.ts +1 -0
- package/src/types/index.ts +29 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
5
|
+
import { DayPicker, getDefaultClassNames, type DayButton } from "react-day-picker";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../lib/utils";
|
|
8
|
+
import { Button, buttonVariants } from "./button";
|
|
9
|
+
|
|
10
|
+
function Calendar({
|
|
11
|
+
className,
|
|
12
|
+
classNames,
|
|
13
|
+
showOutsideDays = true,
|
|
14
|
+
captionLayout = "label",
|
|
15
|
+
buttonVariant = "ghost",
|
|
16
|
+
formatters,
|
|
17
|
+
components,
|
|
18
|
+
...props
|
|
19
|
+
}: React.ComponentProps<typeof DayPicker> & {
|
|
20
|
+
buttonVariant?: React.ComponentProps<typeof Button>["variant"];
|
|
21
|
+
}) {
|
|
22
|
+
const defaultClassNames = getDefaultClassNames();
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<DayPicker
|
|
26
|
+
showOutsideDays={showOutsideDays}
|
|
27
|
+
className={cn(
|
|
28
|
+
"group/calendar bg-background p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
29
|
+
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
|
|
30
|
+
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
|
|
31
|
+
className,
|
|
32
|
+
)}
|
|
33
|
+
captionLayout={captionLayout}
|
|
34
|
+
formatters={{
|
|
35
|
+
formatMonthDropdown: (date) => date.toLocaleString("default", { month: "short" }),
|
|
36
|
+
...formatters,
|
|
37
|
+
}}
|
|
38
|
+
classNames={{
|
|
39
|
+
root: cn("w-fit", defaultClassNames.root),
|
|
40
|
+
months: cn("relative flex flex-col gap-4 md:flex-row", defaultClassNames.months),
|
|
41
|
+
month: cn("flex w-full flex-col gap-4", defaultClassNames.month),
|
|
42
|
+
nav: cn(
|
|
43
|
+
"absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",
|
|
44
|
+
defaultClassNames.nav,
|
|
45
|
+
),
|
|
46
|
+
button_previous: cn(
|
|
47
|
+
buttonVariants({ variant: buttonVariant }),
|
|
48
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
49
|
+
defaultClassNames.button_previous,
|
|
50
|
+
),
|
|
51
|
+
button_next: cn(
|
|
52
|
+
buttonVariants({ variant: buttonVariant }),
|
|
53
|
+
"size-(--cell-size) p-0 select-none aria-disabled:opacity-50",
|
|
54
|
+
defaultClassNames.button_next,
|
|
55
|
+
),
|
|
56
|
+
month_caption: cn(
|
|
57
|
+
"flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)",
|
|
58
|
+
defaultClassNames.month_caption,
|
|
59
|
+
),
|
|
60
|
+
dropdowns: cn(
|
|
61
|
+
"flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium",
|
|
62
|
+
defaultClassNames.dropdowns,
|
|
63
|
+
),
|
|
64
|
+
dropdown_root: cn(
|
|
65
|
+
"relative rounded-md border border-input shadow-xs has-focus:border-ring has-focus:ring-[3px] has-focus:ring-ring/50",
|
|
66
|
+
defaultClassNames.dropdown_root,
|
|
67
|
+
),
|
|
68
|
+
dropdown: cn("absolute inset-0 bg-popover opacity-0", defaultClassNames.dropdown),
|
|
69
|
+
caption_label: cn(
|
|
70
|
+
"font-medium select-none",
|
|
71
|
+
captionLayout === "label"
|
|
72
|
+
? "text-sm"
|
|
73
|
+
: "flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground",
|
|
74
|
+
defaultClassNames.caption_label,
|
|
75
|
+
),
|
|
76
|
+
table: "w-full border-collapse",
|
|
77
|
+
weekdays: cn("flex", defaultClassNames.weekdays),
|
|
78
|
+
weekday: cn(
|
|
79
|
+
"flex-1 rounded-md text-[0.8rem] font-normal text-muted-foreground select-none",
|
|
80
|
+
defaultClassNames.weekday,
|
|
81
|
+
),
|
|
82
|
+
week: cn("mt-2 flex w-full", defaultClassNames.week),
|
|
83
|
+
week_number_header: cn("w-(--cell-size) select-none", defaultClassNames.week_number_header),
|
|
84
|
+
week_number: cn(
|
|
85
|
+
"text-[0.8rem] text-muted-foreground select-none",
|
|
86
|
+
defaultClassNames.week_number,
|
|
87
|
+
),
|
|
88
|
+
day: cn(
|
|
89
|
+
"group/day relative aspect-square h-full w-full p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-md",
|
|
90
|
+
props.showWeekNumber
|
|
91
|
+
? "[&:nth-child(2)[data-selected=true]_button]:rounded-l-md"
|
|
92
|
+
: "[&:first-child[data-selected=true]_button]:rounded-l-md",
|
|
93
|
+
defaultClassNames.day,
|
|
94
|
+
),
|
|
95
|
+
range_start: cn("rounded-l-md bg-accent", defaultClassNames.range_start),
|
|
96
|
+
range_middle: cn("rounded-none", defaultClassNames.range_middle),
|
|
97
|
+
range_end: cn("rounded-r-md bg-accent", defaultClassNames.range_end),
|
|
98
|
+
today: cn(
|
|
99
|
+
"rounded-md bg-accent text-accent-foreground data-[selected=true]:rounded-none",
|
|
100
|
+
defaultClassNames.today,
|
|
101
|
+
),
|
|
102
|
+
outside: cn(
|
|
103
|
+
"text-muted-foreground aria-selected:text-muted-foreground",
|
|
104
|
+
defaultClassNames.outside,
|
|
105
|
+
),
|
|
106
|
+
disabled: cn("text-muted-foreground opacity-50", defaultClassNames.disabled),
|
|
107
|
+
hidden: cn("invisible", defaultClassNames.hidden),
|
|
108
|
+
...classNames,
|
|
109
|
+
}}
|
|
110
|
+
components={{
|
|
111
|
+
Root: ({ className, rootRef, ...props }) => {
|
|
112
|
+
return <div data-slot="calendar" ref={rootRef} className={cn(className)} {...props} />;
|
|
113
|
+
},
|
|
114
|
+
Chevron: ({ className, orientation, ...props }) => {
|
|
115
|
+
if (orientation === "left") {
|
|
116
|
+
return <ChevronLeftIcon className={cn("size-4", className)} {...props} />;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (orientation === "right") {
|
|
120
|
+
return <ChevronRightIcon className={cn("size-4", className)} {...props} />;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return <ChevronDownIcon className={cn("size-4", className)} {...props} />;
|
|
124
|
+
},
|
|
125
|
+
DayButton: CalendarDayButton,
|
|
126
|
+
WeekNumber: ({ children, ...props }) => {
|
|
127
|
+
return (
|
|
128
|
+
<td {...props}>
|
|
129
|
+
<div className="flex size-(--cell-size) items-center justify-center text-center">
|
|
130
|
+
{children}
|
|
131
|
+
</div>
|
|
132
|
+
</td>
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
...components,
|
|
136
|
+
}}
|
|
137
|
+
{...props}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function CalendarDayButton({
|
|
143
|
+
className,
|
|
144
|
+
day,
|
|
145
|
+
modifiers,
|
|
146
|
+
...props
|
|
147
|
+
}: React.ComponentProps<typeof DayButton>) {
|
|
148
|
+
const defaultClassNames = getDefaultClassNames();
|
|
149
|
+
|
|
150
|
+
const ref = React.useRef<HTMLButtonElement>(null);
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
if (modifiers.focused) ref.current?.focus();
|
|
153
|
+
}, [modifiers.focused]);
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<Button
|
|
157
|
+
ref={ref}
|
|
158
|
+
variant="ghost"
|
|
159
|
+
size="icon"
|
|
160
|
+
data-day={day.date.toLocaleDateString()}
|
|
161
|
+
data-selected-single={
|
|
162
|
+
modifiers.selected &&
|
|
163
|
+
!modifiers.range_start &&
|
|
164
|
+
!modifiers.range_end &&
|
|
165
|
+
!modifiers.range_middle
|
|
166
|
+
}
|
|
167
|
+
data-range-start={modifiers.range_start}
|
|
168
|
+
data-range-end={modifiers.range_end}
|
|
169
|
+
data-range-middle={modifiers.range_middle}
|
|
170
|
+
className={cn(
|
|
171
|
+
"flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-accent-foreground [&>span]:text-xs [&>span]:opacity-70",
|
|
172
|
+
defaultClassNames.day,
|
|
173
|
+
className,
|
|
174
|
+
)}
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { Calendar, CalendarDayButton };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../lib/utils";
|
|
4
|
+
|
|
5
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="card"
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
data-slot="card-header"
|
|
22
|
+
className={cn(
|
|
23
|
+
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-2 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
{...props}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
|
|
32
|
+
return (
|
|
33
|
+
<div
|
|
34
|
+
data-slot="card-title"
|
|
35
|
+
className={cn("leading-none font-semibold", className)}
|
|
36
|
+
{...props}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
data-slot="card-description"
|
|
45
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
46
|
+
{...props}
|
|
47
|
+
/>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function CardAction({ className, ...props }: React.ComponentProps<"div">) {
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
data-slot="card-action"
|
|
55
|
+
className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
62
|
+
return <div data-slot="card-content" className={cn("px-6", className)} {...props} />;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
66
|
+
return (
|
|
67
|
+
<div
|
|
68
|
+
data-slot="card-footer"
|
|
69
|
+
className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Combobox as ComboboxPrimitive } from "@base-ui/react";
|
|
5
|
+
import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../lib/utils";
|
|
8
|
+
import { Button } from "./button";
|
|
9
|
+
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "./input-group";
|
|
10
|
+
|
|
11
|
+
const Combobox = ComboboxPrimitive.Root;
|
|
12
|
+
|
|
13
|
+
function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
|
|
14
|
+
return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function ComboboxTrigger({ className, children, ...props }: ComboboxPrimitive.Trigger.Props) {
|
|
18
|
+
return (
|
|
19
|
+
<ComboboxPrimitive.Trigger
|
|
20
|
+
data-slot="combobox-trigger"
|
|
21
|
+
className={cn("[&_svg:not([class*='size-'])]:size-4", className)}
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
<ChevronDownIcon
|
|
26
|
+
data-slot="combobox-trigger-icon"
|
|
27
|
+
className="pointer-events-none size-4 text-muted-foreground"
|
|
28
|
+
/>
|
|
29
|
+
</ComboboxPrimitive.Trigger>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
|
|
34
|
+
return (
|
|
35
|
+
<ComboboxPrimitive.Clear
|
|
36
|
+
data-slot="combobox-clear"
|
|
37
|
+
render={<InputGroupButton variant="ghost" size="icon-xs" />}
|
|
38
|
+
className={cn(className)}
|
|
39
|
+
{...props}
|
|
40
|
+
>
|
|
41
|
+
<XIcon className="pointer-events-none" />
|
|
42
|
+
</ComboboxPrimitive.Clear>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function ComboboxInput({
|
|
47
|
+
className,
|
|
48
|
+
children,
|
|
49
|
+
disabled = false,
|
|
50
|
+
showTrigger = true,
|
|
51
|
+
showClear = false,
|
|
52
|
+
...props
|
|
53
|
+
}: ComboboxPrimitive.Input.Props & {
|
|
54
|
+
showTrigger?: boolean;
|
|
55
|
+
showClear?: boolean;
|
|
56
|
+
}) {
|
|
57
|
+
return (
|
|
58
|
+
<InputGroup className={cn("w-auto", className)}>
|
|
59
|
+
<ComboboxPrimitive.Input render={<InputGroupInput disabled={disabled} />} {...props} />
|
|
60
|
+
<InputGroupAddon align="inline-end">
|
|
61
|
+
{showTrigger && (
|
|
62
|
+
<InputGroupButton
|
|
63
|
+
size="icon-xs"
|
|
64
|
+
variant="ghost"
|
|
65
|
+
asChild
|
|
66
|
+
data-slot="input-group-button"
|
|
67
|
+
className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
|
|
68
|
+
disabled={disabled}
|
|
69
|
+
>
|
|
70
|
+
<ComboboxTrigger />
|
|
71
|
+
</InputGroupButton>
|
|
72
|
+
)}
|
|
73
|
+
{showClear && <ComboboxClear disabled={disabled} />}
|
|
74
|
+
</InputGroupAddon>
|
|
75
|
+
{children}
|
|
76
|
+
</InputGroup>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function ComboboxContent({
|
|
81
|
+
className,
|
|
82
|
+
side = "bottom",
|
|
83
|
+
sideOffset = 6,
|
|
84
|
+
align = "start",
|
|
85
|
+
alignOffset = 0,
|
|
86
|
+
anchor,
|
|
87
|
+
...props
|
|
88
|
+
}: ComboboxPrimitive.Popup.Props &
|
|
89
|
+
Pick<
|
|
90
|
+
ComboboxPrimitive.Positioner.Props,
|
|
91
|
+
"side" | "align" | "sideOffset" | "alignOffset" | "anchor"
|
|
92
|
+
>) {
|
|
93
|
+
return (
|
|
94
|
+
<ComboboxPrimitive.Portal>
|
|
95
|
+
<ComboboxPrimitive.Positioner
|
|
96
|
+
side={side}
|
|
97
|
+
sideOffset={sideOffset}
|
|
98
|
+
align={align}
|
|
99
|
+
alignOffset={alignOffset}
|
|
100
|
+
anchor={anchor}
|
|
101
|
+
className="isolate z-50"
|
|
102
|
+
>
|
|
103
|
+
<ComboboxPrimitive.Popup
|
|
104
|
+
data-slot="combobox-content"
|
|
105
|
+
data-chips={!!anchor}
|
|
106
|
+
className={cn(
|
|
107
|
+
"group/combobox-content relative max-h-96 w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) 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 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
108
|
+
className,
|
|
109
|
+
)}
|
|
110
|
+
{...props}
|
|
111
|
+
/>
|
|
112
|
+
</ComboboxPrimitive.Positioner>
|
|
113
|
+
</ComboboxPrimitive.Portal>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
|
|
118
|
+
return (
|
|
119
|
+
<ComboboxPrimitive.List
|
|
120
|
+
data-slot="combobox-list"
|
|
121
|
+
className={cn(
|
|
122
|
+
"max-h-[min(calc(--spacing(96)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto p-1 data-empty:p-0",
|
|
123
|
+
className,
|
|
124
|
+
)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function ComboboxItem({ className, children, ...props }: ComboboxPrimitive.Item.Props) {
|
|
131
|
+
return (
|
|
132
|
+
<ComboboxPrimitive.Item
|
|
133
|
+
data-slot="combobox-item"
|
|
134
|
+
className={cn(
|
|
135
|
+
"relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
136
|
+
className,
|
|
137
|
+
)}
|
|
138
|
+
{...props}
|
|
139
|
+
>
|
|
140
|
+
{children}
|
|
141
|
+
<ComboboxPrimitive.ItemIndicator
|
|
142
|
+
data-slot="combobox-item-indicator"
|
|
143
|
+
render={
|
|
144
|
+
<span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
<CheckIcon className="pointer-events-none size-4 pointer-coarse:size-5" />
|
|
148
|
+
</ComboboxPrimitive.ItemIndicator>
|
|
149
|
+
</ComboboxPrimitive.Item>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
|
|
154
|
+
return (
|
|
155
|
+
<ComboboxPrimitive.Group data-slot="combobox-group" className={cn(className)} {...props} />
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function ComboboxLabel({ className, ...props }: ComboboxPrimitive.GroupLabel.Props) {
|
|
160
|
+
return (
|
|
161
|
+
<ComboboxPrimitive.GroupLabel
|
|
162
|
+
data-slot="combobox-label"
|
|
163
|
+
className={cn(
|
|
164
|
+
"px-2 py-1.5 text-xs text-muted-foreground pointer-coarse:px-3 pointer-coarse:py-2 pointer-coarse:text-sm",
|
|
165
|
+
className,
|
|
166
|
+
)}
|
|
167
|
+
{...props}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
|
|
173
|
+
return <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
|
|
177
|
+
return (
|
|
178
|
+
<ComboboxPrimitive.Empty
|
|
179
|
+
data-slot="combobox-empty"
|
|
180
|
+
className={cn(
|
|
181
|
+
"hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex",
|
|
182
|
+
className,
|
|
183
|
+
)}
|
|
184
|
+
{...props}
|
|
185
|
+
/>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props) {
|
|
190
|
+
return (
|
|
191
|
+
<ComboboxPrimitive.Separator
|
|
192
|
+
data-slot="combobox-separator"
|
|
193
|
+
className={cn("-mx-1 my-1 h-px bg-border", className)}
|
|
194
|
+
{...props}
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function ComboboxChips({
|
|
200
|
+
className,
|
|
201
|
+
...props
|
|
202
|
+
}: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props) {
|
|
203
|
+
return (
|
|
204
|
+
<ComboboxPrimitive.Chips
|
|
205
|
+
data-slot="combobox-chips"
|
|
206
|
+
className={cn(
|
|
207
|
+
"flex min-h-9 flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1.5 text-sm shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-[3px] has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1.5 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40",
|
|
208
|
+
className,
|
|
209
|
+
)}
|
|
210
|
+
{...props}
|
|
211
|
+
/>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function ComboboxChip({
|
|
216
|
+
className,
|
|
217
|
+
children,
|
|
218
|
+
showRemove = true,
|
|
219
|
+
...props
|
|
220
|
+
}: ComboboxPrimitive.Chip.Props & {
|
|
221
|
+
showRemove?: boolean;
|
|
222
|
+
}) {
|
|
223
|
+
return (
|
|
224
|
+
<ComboboxPrimitive.Chip
|
|
225
|
+
data-slot="combobox-chip"
|
|
226
|
+
className={cn(
|
|
227
|
+
"flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
|
|
228
|
+
className,
|
|
229
|
+
)}
|
|
230
|
+
{...props}
|
|
231
|
+
>
|
|
232
|
+
{children}
|
|
233
|
+
{showRemove && (
|
|
234
|
+
<ComboboxPrimitive.ChipRemove
|
|
235
|
+
render={<Button variant="ghost" size="icon-xs" />}
|
|
236
|
+
className="-ml-1 opacity-50 hover:opacity-100"
|
|
237
|
+
data-slot="combobox-chip-remove"
|
|
238
|
+
>
|
|
239
|
+
<XIcon className="pointer-events-none" />
|
|
240
|
+
</ComboboxPrimitive.ChipRemove>
|
|
241
|
+
)}
|
|
242
|
+
</ComboboxPrimitive.Chip>
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
function ComboboxChipsInput({ className, children, ...props }: ComboboxPrimitive.Input.Props) {
|
|
247
|
+
return (
|
|
248
|
+
<ComboboxPrimitive.Input
|
|
249
|
+
data-slot="combobox-chip-input"
|
|
250
|
+
className={cn("min-w-16 flex-1 outline-none", className)}
|
|
251
|
+
{...props}
|
|
252
|
+
/>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function useComboboxAnchor() {
|
|
257
|
+
return React.useRef<HTMLDivElement | null>(null);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export {
|
|
261
|
+
Combobox,
|
|
262
|
+
ComboboxInput,
|
|
263
|
+
ComboboxContent,
|
|
264
|
+
ComboboxList,
|
|
265
|
+
ComboboxItem,
|
|
266
|
+
ComboboxGroup,
|
|
267
|
+
ComboboxLabel,
|
|
268
|
+
ComboboxCollection,
|
|
269
|
+
ComboboxEmpty,
|
|
270
|
+
ComboboxSeparator,
|
|
271
|
+
ComboboxChips,
|
|
272
|
+
ComboboxChip,
|
|
273
|
+
ComboboxChipsInput,
|
|
274
|
+
ComboboxTrigger,
|
|
275
|
+
ComboboxValue,
|
|
276
|
+
useComboboxAnchor,
|
|
277
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
5
|
+
import { Dialog as DialogPrimitive } from "radix-ui";
|
|
6
|
+
|
|
7
|
+
import { cn } from "../lib/utils";
|
|
8
|
+
import { Button } from "./button";
|
|
9
|
+
|
|
10
|
+
function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>) {
|
|
11
|
+
return <DialogPrimitive.Root data-slot="dialog" {...props} />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
|
|
15
|
+
return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
|
|
19
|
+
return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {
|
|
23
|
+
return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function DialogOverlay({
|
|
27
|
+
className,
|
|
28
|
+
...props
|
|
29
|
+
}: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
|
|
30
|
+
return (
|
|
31
|
+
<DialogPrimitive.Overlay
|
|
32
|
+
data-slot="dialog-overlay"
|
|
33
|
+
className={cn(
|
|
34
|
+
"fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
|
|
35
|
+
className,
|
|
36
|
+
)}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function DialogContent({
|
|
43
|
+
className,
|
|
44
|
+
children,
|
|
45
|
+
showCloseButton = true,
|
|
46
|
+
...props
|
|
47
|
+
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
|
|
48
|
+
showCloseButton?: boolean;
|
|
49
|
+
}) {
|
|
50
|
+
return (
|
|
51
|
+
<DialogPortal data-slot="dialog-portal">
|
|
52
|
+
<DialogOverlay />
|
|
53
|
+
<DialogPrimitive.Content
|
|
54
|
+
data-slot="dialog-content"
|
|
55
|
+
className={cn(
|
|
56
|
+
"fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
|
|
57
|
+
className,
|
|
58
|
+
)}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
{children}
|
|
62
|
+
{showCloseButton && (
|
|
63
|
+
<DialogPrimitive.Close
|
|
64
|
+
data-slot="dialog-close"
|
|
65
|
+
className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
66
|
+
>
|
|
67
|
+
<XIcon />
|
|
68
|
+
<span className="sr-only">Close</span>
|
|
69
|
+
</DialogPrimitive.Close>
|
|
70
|
+
)}
|
|
71
|
+
</DialogPrimitive.Content>
|
|
72
|
+
</DialogPortal>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
data-slot="dialog-header"
|
|
80
|
+
className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function DialogFooter({
|
|
87
|
+
className,
|
|
88
|
+
showCloseButton = false,
|
|
89
|
+
children,
|
|
90
|
+
...props
|
|
91
|
+
}: React.ComponentProps<"div"> & {
|
|
92
|
+
showCloseButton?: boolean;
|
|
93
|
+
}) {
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
data-slot="dialog-footer"
|
|
97
|
+
className={cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className)}
|
|
98
|
+
{...props}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
{showCloseButton && (
|
|
102
|
+
<DialogPrimitive.Close asChild>
|
|
103
|
+
<Button variant="outline">Close</Button>
|
|
104
|
+
</DialogPrimitive.Close>
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>) {
|
|
111
|
+
return (
|
|
112
|
+
<DialogPrimitive.Title
|
|
113
|
+
data-slot="dialog-title"
|
|
114
|
+
className={cn("text-lg leading-none font-semibold", className)}
|
|
115
|
+
{...props}
|
|
116
|
+
/>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function DialogDescription({
|
|
121
|
+
className,
|
|
122
|
+
...props
|
|
123
|
+
}: React.ComponentProps<typeof DialogPrimitive.Description>) {
|
|
124
|
+
return (
|
|
125
|
+
<DialogPrimitive.Description
|
|
126
|
+
data-slot="dialog-description"
|
|
127
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
128
|
+
{...props}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
Dialog,
|
|
135
|
+
DialogClose,
|
|
136
|
+
DialogContent,
|
|
137
|
+
DialogDescription,
|
|
138
|
+
DialogFooter,
|
|
139
|
+
DialogHeader,
|
|
140
|
+
DialogOverlay,
|
|
141
|
+
DialogPortal,
|
|
142
|
+
DialogTitle,
|
|
143
|
+
DialogTrigger,
|
|
144
|
+
};
|