Skip to content

Commit 217c6e6

Browse files
chore: re-pull coss-ui components (calcom#28032)
1 parent b1eb5a2 commit 217c6e6

39 files changed

Lines changed: 438 additions & 152 deletions

apps/web/modules/settings/billing/components/ActiveUserBreakdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function ActiveUserBreakdownContent({ data, teamId }: { data: BreakdownData; tea
155155
</PanelCard>
156156

157157
<Sheet open={!!selectedUser} onOpenChange={(open) => !open && setSelectedUser(null)}>
158-
<SheetContent side="right" inset>
158+
<SheetContent side="right" variant="inset">
159159
<SheetHeader>
160160
<SheetTitle>{selectedUser?.name || selectedUser?.email}</SheetTitle>
161161
<SheetDescription>

packages/coss-ui/src/components/alert-dialog.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function AlertDialogPopup({
6666
>
6767
<AlertDialogPrimitive.Popup
6868
className={cn(
69-
"-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover not-dark:bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg/5 transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/6%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
69+
"-translate-y-[calc(1.25rem*var(--nested-dialogs))] relative row-start-2 flex max-h-full min-h-0 w-full min-w-0 max-w-lg scale-[calc(1-0.1*var(--nested-dialogs))] flex-col rounded-2xl border bg-popover not-dark:bg-clip-padding text-popover-foreground opacity-[calc(1-0.1*var(--nested-dialogs))] shadow-lg/5 transition-[scale,opacity,translate] duration-200 ease-in-out will-change-transform before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-2xl)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] data-nested:data-ending-style:translate-y-8 data-nested:data-starting-style:translate-y-8 data-nested-dialog-open:origin-top data-ending-style:scale-98 data-starting-style:scale-98 data-ending-style:opacity-0 data-starting-style:opacity-0 dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
7070
bottomStickOnMobile &&
7171
"max-sm:max-w-none max-sm:rounded-none max-sm:border-x-0 max-sm:border-t max-sm:border-b-0 max-sm:opacity-[calc(1-min(var(--nested-dialogs),1))] max-sm:data-ending-style:translate-y-4 max-sm:data-starting-style:translate-y-4 max-sm:before:hidden max-sm:before:rounded-none",
7272
className,
@@ -86,7 +86,7 @@ function AlertDialogHeader({
8686
return (
8787
<div
8888
className={cn(
89-
"flex flex-col gap-2 p-6 not-has-[+[data-slot=alert-dialog-footer]]:pb-4 text-center max-sm:pb-4 sm:text-left",
89+
"flex flex-col gap-2 p-6 text-center max-sm:pb-4 sm:text-left",
9090
className,
9191
)}
9292
data-slot="alert-dialog-header"
@@ -107,7 +107,7 @@ function AlertDialogFooter({
107107
className={cn(
108108
"flex flex-col-reverse gap-2 px-6 sm:flex-row sm:justify-end sm:rounded-b-[calc(var(--radius-2xl)-1px)]",
109109
variant === "default" && "border-t bg-muted/72 py-4",
110-
variant === "bare" && "pt-4 pb-6",
110+
variant === "bare" && "pb-6",
111111
className,
112112
)}
113113
data-slot="alert-dialog-footer"

packages/coss-ui/src/components/autocomplete.tsx

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ function AutocompleteInput({
1515
showClear = false,
1616
startAddon,
1717
size,
18+
triggerProps,
19+
clearProps,
1820
...props
1921
}: Omit<AutocompletePrimitive.Input.Props, "size"> & {
2022
showTrigger?: boolean;
2123
showClear?: boolean;
2224
startAddon?: React.ReactNode;
2325
size?: "sm" | "default" | "lg" | number;
2426
ref?: React.Ref<HTMLInputElement>;
27+
triggerProps?: AutocompletePrimitive.Trigger.Props;
28+
clearProps?: AutocompletePrimitive.Clear.Props;
2529
}) {
2630
const sizeValue = (size ?? "default") as "sm" | "default" | "lg" | number;
2731

2832
return (
29-
<div className="relative not-has-[>*.w-full]:w-fit w-full has-disabled:opacity-64">
33+
<div className="relative not-has-[>*.w-full]:w-fit w-full text-foreground has-disabled:opacity-64">
3034
{startAddon && (
3135
<div
3236
aria-hidden="true"
@@ -55,8 +59,11 @@ function AutocompleteInput({
5559
"-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-colors pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=autocomplete-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
5660
sizeValue === "sm" ? "end-0" : "end-0.5",
5761
)}
62+
{...triggerProps}
5863
>
59-
<ChevronsUpDownIcon />
64+
<AutocompletePrimitive.Icon data-slot="autocomplete-icon">
65+
<ChevronsUpDownIcon />
66+
</AutocompletePrimitive.Icon>
6067
</AutocompleteTrigger>
6168
)}
6269
{showClear && (
@@ -65,6 +72,7 @@ function AutocompleteInput({
6572
"-translate-y-1/2 absolute top-1/2 inline-flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-transparent opacity-80 outline-none transition-colors pointer-coarse:after:absolute pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 hover:opacity-100 has-[+[data-slot=autocomplete-clear]]:hidden sm:size-7 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
6673
sizeValue === "sm" ? "end-0" : "end-0.5",
6774
)}
75+
{...clearProps}
6876
>
6977
<XIcon />
7078
</AutocompleteClear>
@@ -76,26 +84,38 @@ function AutocompleteInput({
7684
function AutocompletePopup({
7785
className,
7886
children,
87+
side = "bottom",
7988
sideOffset = 4,
89+
alignOffset,
90+
align = "start",
91+
anchor,
8092
...props
8193
}: AutocompletePrimitive.Popup.Props & {
82-
sideOffset?: number;
94+
align?: AutocompletePrimitive.Positioner.Props["align"];
95+
sideOffset?: AutocompletePrimitive.Positioner.Props["sideOffset"];
96+
alignOffset?: AutocompletePrimitive.Positioner.Props["alignOffset"];
97+
side?: AutocompletePrimitive.Positioner.Props["side"];
98+
anchor?: AutocompletePrimitive.Positioner.Props["anchor"];
8399
}) {
84100
return (
85101
<AutocompletePrimitive.Portal>
86102
<AutocompletePrimitive.Positioner
103+
align={align}
104+
alignOffset={alignOffset}
105+
anchor={anchor}
87106
className="z-50 select-none"
88107
data-slot="autocomplete-positioner"
108+
side={side}
89109
sideOffset={sideOffset}
90110
>
91111
<span
92112
className={cn(
93-
"relative flex max-h-full origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/6%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
113+
"relative flex max-h-full min-w-(--anchor-width) max-w-(--available-width) origin-(--transform-origin) rounded-lg border bg-popover not-dark:bg-clip-padding shadow-lg/5 transition-[scale,opacity] before:pointer-events-none before:absolute before:inset-0 before:rounded-[calc(var(--radius-lg)-1px)] before:shadow-[0_1px_--theme(--color-black/4%)] dark:before:shadow-[0_-1px_--theme(--color-white/6%)]",
94114
className,
95115
)}
96116
>
97117
<AutocompletePrimitive.Popup
98-
className="flex max-h-[min(var(--available-height),23rem)] w-(--anchor-width) max-w-(--available-width) flex-col"
118+
className="flex max-h-[min(var(--available-height),23rem)] flex-1 flex-col text-foreground"
99119
data-slot="autocomplete-popup"
100120
{...props}
101121
>
@@ -268,14 +288,17 @@ function AutocompleteCollection({
268288

269289
function AutocompleteTrigger({
270290
className,
291+
children,
271292
...props
272293
}: AutocompletePrimitive.Trigger.Props) {
273294
return (
274295
<AutocompletePrimitive.Trigger
275296
className={className}
276297
data-slot="autocomplete-trigger"
277298
{...props}
278-
/>
299+
>
300+
{children}
301+
</AutocompletePrimitive.Trigger>
279302
);
280303
}
281304

packages/coss-ui/src/components/badge.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { cva, type VariantProps } from "class-variance-authority";
77
import { cn } from "@coss/ui/lib/utils";
88

99
const badgeVariants = cva(
10-
"relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button,a&]:cursor-pointer [button,a&]:pointer-coarse:after:absolute [button,a&]:pointer-coarse:after:size-full [button,a&]:pointer-coarse:after:min-h-11 [button,a&]:pointer-coarse:after:min-w-11",
10+
"relative inline-flex shrink-0 items-center justify-center gap-1 whitespace-nowrap rounded-sm border border-transparent font-medium outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-3.5 sm:[&_svg:not([class*='size-'])]:size-3 [&_svg]:pointer-events-none [&_svg]:shrink-0 [button&,a&]:cursor-pointer [button&,a&]:pointer-coarse:after:absolute [button&,a&]:pointer-coarse:after:size-full [button&,a&]:pointer-coarse:after:min-h-11 [button&,a&]:pointer-coarse:after:min-w-11",
1111
{
1212
defaultVariants: {
1313
size: "default",
@@ -18,20 +18,20 @@ const badgeVariants = cva(
1818
default:
1919
"h-5.5 min-w-5.5 px-[calc(--spacing(1)-1px)] text-sm sm:h-4.5 sm:min-w-4.5 sm:text-xs",
2020
lg: "h-6.5 min-w-6.5 px-[calc(--spacing(1.5)-1px)] text-base sm:h-5.5 sm:min-w-5.5 sm:text-sm",
21-
sm: "h-5 min-w-5 rounded-[calc(var(--radius-sm)-2px)] px-[calc(--spacing(1)-1px)] text-xs sm:h-4 sm:min-w-4 sm:text-[.625rem]",
21+
sm: "h-5 min-w-5 rounded-[.25rem] px-[calc(--spacing(1)-1px)] text-xs sm:h-4 sm:min-w-4 sm:text-[.625rem]",
2222
},
2323
variant: {
2424
default:
25-
"bg-primary text-primary-foreground [button,a&]:hover:bg-primary/90",
25+
"bg-primary text-primary-foreground [button&,a&]:hover:bg-primary/90",
2626
destructive:
27-
"bg-destructive text-white [button,a&]:hover:bg-destructive/90",
27+
"bg-destructive text-white [button&,a&]:hover:bg-destructive/90",
2828
error:
2929
"bg-destructive/8 text-destructive-foreground dark:bg-destructive/16",
3030
info: "bg-info/8 text-info-foreground dark:bg-info/16",
3131
outline:
32-
"border-input bg-background dark:bg-input/32 [button,a&]:hover:bg-accent/50 dark:[button,a&]:hover:bg-input/48",
32+
"border-input bg-background text-foreground dark:bg-input/32 [button&,a&]:hover:bg-accent/50 dark:[button&,a&]:hover:bg-input/48",
3333
secondary:
34-
"bg-secondary text-secondary-foreground [button,a&]:hover:bg-secondary/90",
34+
"bg-secondary text-secondary-foreground [button&,a&]:hover:bg-secondary/90",
3535
success: "bg-success/8 text-success-foreground dark:bg-success/16",
3636
warning: "bg-warning/8 text-warning-foreground dark:bg-warning/16",
3737
},

packages/coss-ui/src/components/button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ const buttonVariants = cva(
3535
destructive:
3636
"not-disabled:inset-shadow-[0_1px_--theme(--color-white/16%)] border-destructive bg-destructive text-white shadow-destructive/24 shadow-xs [:active,[data-pressed]]:inset-shadow-[0_1px_--theme(--color-black/8%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-destructive/90",
3737
"destructive-outline":
38-
"border-input bg-transparent not-dark:bg-clip-padding text-destructive-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/6%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:border-destructive/32 [:hover,[data-pressed]]:bg-destructive/4",
38+
"border-input bg-popover not-dark:bg-clip-padding text-destructive-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:border-destructive/32 [:hover,[data-pressed]]:bg-destructive/4",
3939
ghost:
40-
"border-transparent data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent",
40+
"border-transparent text-foreground data-pressed:bg-accent [:hover,[data-pressed]]:bg-accent",
4141
link: "border-transparent underline-offset-4 [:hover,[data-pressed]]:underline",
4242
outline:
43-
"border-input bg-background not-dark:bg-clip-padding shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/6%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64",
43+
"border-input bg-popover not-dark:bg-clip-padding text-foreground shadow-xs/5 not-disabled:not-active:not-data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:bg-input/32 dark:not-disabled:before:shadow-[0_-1px_--theme(--color-white/2%)] dark:not-disabled:not-active:not-data-pressed:before:shadow-[0_-1px_--theme(--color-white/6%)] [:disabled,:active,[data-pressed]]:shadow-none [:hover,[data-pressed]]:bg-accent/50 dark:[:hover,[data-pressed]]:bg-input/64",
4444
secondary:
4545
"border-transparent bg-secondary text-secondary-foreground [:active,[data-pressed]]:bg-secondary/80 [:hover,[data-pressed]]:bg-secondary/90",
4646
},
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
"use client";
2+
3+
import {
4+
ChevronLeftIcon,
5+
ChevronRightIcon,
6+
ChevronsUpDownIcon,
7+
} from "lucide-react";
8+
import type * as React from "react";
9+
import { DayPicker } from "react-day-picker";
10+
11+
import { cn } from "@coss/ui/lib/utils";
12+
13+
const buttonClassNames =
14+
"relative flex size-(--cell-size) text-base sm:text-sm items-center justify-center rounded-lg text-foreground not-in-data-selected:hover:bg-accent disabled:pointer-events-none disabled:opacity-64 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0";
15+
16+
function Calendar({
17+
className,
18+
classNames,
19+
showOutsideDays = true,
20+
components: userComponents,
21+
mode = "single",
22+
...props
23+
}: React.ComponentProps<typeof DayPicker>) {
24+
const defaultClassNames = {
25+
button_next: buttonClassNames,
26+
button_previous: buttonClassNames,
27+
caption_label:
28+
"text-base sm:text-sm font-medium flex items-center gap-2 h-full",
29+
day: "size-(--cell-size) text-sm py-px",
30+
day_button: cn(
31+
buttonClassNames,
32+
"in-[[data-selected]:not(.range-middle)]:transition-[color,background-color,border-radius,box-shadow] in-data-disabled:pointer-events-none focus-visible:z-1 in-data-selected:bg-primary in-data-selected:text-primary-foreground in-data-disabled:text-muted-foreground/70 in-data-disabled:line-through in-data-outside:text-muted-foreground/70 in-data-selected:in-data-outside:text-primary-foreground outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px] in-[.range-start:not(.range-end)]:rounded-e-none in-[.range-end:not(.range-start)]:rounded-s-none in-[.range-middle]:rounded-none in-[.range-middle]:in-data-selected:bg-accent in-[.range-middle]:in-data-selected:text-foreground",
33+
),
34+
dropdown: "absolute bg-popover inset-0 opacity-0",
35+
dropdown_root:
36+
"relative has-focus:border-ring has-focus:ring-ring/50 has-focus:ring-[3px] border border-input shadow-xs/5 rounded-lg px-[calc(--spacing(3)-1px)] h-9 sm:h-8 [&_svg:not([class*='opacity-'])]:opacity-80 [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:-me-1",
37+
dropdowns:
38+
"w-full flex items-center text-base sm:text-sm justify-center h-(--cell-size) gap-1.5 *:[span]:font-medium",
39+
hidden: "invisible",
40+
month: "w-full",
41+
month_caption:
42+
"relative mx-(--cell-size) px-1 mb-1 flex h-(--cell-size) items-center justify-center z-2",
43+
months: "relative flex flex-col sm:flex-row gap-2",
44+
nav: "absolute top-0 flex w-full justify-between z-1",
45+
outside:
46+
"text-muted-foreground data-selected:bg-accent/50 data-selected:text-muted-foreground",
47+
range_end: "range-end",
48+
range_middle: "range-middle",
49+
range_start: "range-start",
50+
today:
51+
"*:after:pointer-events-none *:after:absolute *:after:bottom-1 *:after:start-1/2 *:after:z-1 *:after:size-[3px] *:after:-translate-x-1/2 *:after:rounded-full *:after:bg-primary [&[data-selected]:not(.range-middle)>*]:after:bg-background [&[data-disabled]>*]:after:bg-foreground/30 *:after:transition-colors",
52+
week_number:
53+
"size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/70",
54+
weekday:
55+
"size-(--cell-size) p-0 text-xs font-medium text-muted-foreground/70",
56+
};
57+
const mergedClassNames: typeof defaultClassNames = Object.keys(
58+
defaultClassNames,
59+
).reduce(
60+
(acc, key) => {
61+
const userClass = classNames?.[key as keyof typeof classNames];
62+
const baseClass =
63+
defaultClassNames[key as keyof typeof defaultClassNames];
64+
65+
acc[key as keyof typeof defaultClassNames] = userClass
66+
? cn(baseClass, userClass)
67+
: baseClass;
68+
69+
return acc;
70+
},
71+
{ ...defaultClassNames } as typeof defaultClassNames,
72+
);
73+
74+
const defaultComponents = {
75+
Chevron: ({
76+
className,
77+
orientation,
78+
...props
79+
}: {
80+
className?: string;
81+
orientation?: "left" | "right" | "up" | "down";
82+
}) => {
83+
if (orientation === "left") {
84+
return (
85+
<ChevronLeftIcon
86+
className={cn(className, "rtl:rotate-180")}
87+
{...props}
88+
aria-hidden="true"
89+
/>
90+
);
91+
}
92+
93+
if (orientation === "right") {
94+
return (
95+
<ChevronRightIcon
96+
className={cn(className, "rtl:rotate-180")}
97+
{...props}
98+
aria-hidden="true"
99+
/>
100+
);
101+
}
102+
103+
return (
104+
<ChevronsUpDownIcon
105+
className={className}
106+
{...props}
107+
aria-hidden="true"
108+
/>
109+
);
110+
},
111+
};
112+
113+
const mergedComponents = {
114+
...defaultComponents,
115+
...userComponents,
116+
};
117+
118+
const dayPickerProps = {
119+
className: cn(
120+
"w-fit [--cell-size:--spacing(10)] sm:[--cell-size:--spacing(9)]",
121+
className,
122+
),
123+
classNames: mergedClassNames,
124+
components: mergedComponents,
125+
"data-slot": "calendar",
126+
formatters: {
127+
formatMonthDropdown: (date: Date) =>
128+
date.toLocaleString("default", { month: "short" }),
129+
} as React.ComponentProps<typeof DayPicker>["formatters"],
130+
mode,
131+
showOutsideDays,
132+
...props,
133+
};
134+
135+
return (
136+
<DayPicker
137+
{...(dayPickerProps as React.ComponentProps<typeof DayPicker>)}
138+
/>
139+
);
140+
}
141+
142+
export { Calendar };

0 commit comments

Comments
 (0)