Skip to content

Commit 15a8d80

Browse files
committed
Update shadcn ui to 1.0.2
1 parent 32831b8 commit 15a8d80

49 files changed

Lines changed: 718 additions & 132 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

components.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://next.shadcn-svelte.com/schema.json",
2+
"$schema": "https://shadcn-svelte.com/schema.json",
33
"tailwind": {
44
"css": "src\\app.css",
55
"baseColor": "neutral"
@@ -12,5 +12,5 @@
1212
"lib": "$lib"
1313
},
1414
"typescript": true,
15-
"registry": "https://next.shadcn-svelte.com/registry"
15+
"registry": "https://shadcn-svelte.com/registry"
1616
}

src/lib/components/ui/accordion/accordion-content.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@
1313
<AccordionPrimitive.Content
1414
bind:ref
1515
data-slot="accordion-content"
16-
class={cn(
17-
"data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm",
18-
className
19-
)}
16+
class="data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down overflow-hidden text-sm"
2017
{...restProps}
2118
>
22-
<div class="pb-4 pt-0">
19+
<div class={cn("pb-4 pt-0", className)}>
2320
{@render children?.()}
2421
</div>
2522
</AccordionPrimitive.Content>
File renamed without changes.

src/lib/components/ui/accordion/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Root from "./accordion-root.svelte";
1+
import Root from "./accordion.svelte";
22
import Content from "./accordion-content.svelte";
33
import Item from "./accordion-item.svelte";
44
import Trigger from "./accordion-trigger.svelte";
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<script lang="ts">
2+
import type { ComponentProps } from "svelte";
3+
import type Calendar from "./calendar.svelte";
4+
import CalendarMonthSelect from "./calendar-month-select.svelte";
5+
import CalendarYearSelect from "./calendar-year-select.svelte";
6+
import { DateFormatter, getLocalTimeZone, type DateValue } from "@internationalized/date";
7+
8+
let {
9+
captionLayout,
10+
months,
11+
monthFormat,
12+
years,
13+
yearFormat,
14+
month,
15+
locale,
16+
placeholder = $bindable(),
17+
monthIndex = 0,
18+
}: {
19+
captionLayout: ComponentProps<typeof Calendar>["captionLayout"];
20+
months: ComponentProps<typeof CalendarMonthSelect>["months"];
21+
monthFormat: ComponentProps<typeof CalendarMonthSelect>["monthFormat"];
22+
years: ComponentProps<typeof CalendarYearSelect>["years"];
23+
yearFormat: ComponentProps<typeof CalendarYearSelect>["yearFormat"];
24+
month: DateValue;
25+
placeholder: DateValue | undefined;
26+
locale: string;
27+
monthIndex: number;
28+
} = $props();
29+
30+
function formatYear(date: DateValue) {
31+
const dateObj = date.toDate(getLocalTimeZone());
32+
if (typeof yearFormat === "function") return yearFormat(dateObj.getFullYear());
33+
return new DateFormatter(locale, { year: yearFormat }).format(dateObj);
34+
}
35+
36+
function formatMonth(date: DateValue) {
37+
const dateObj = date.toDate(getLocalTimeZone());
38+
if (typeof monthFormat === "function") return monthFormat(dateObj.getMonth() + 1);
39+
return new DateFormatter(locale, { month: monthFormat }).format(dateObj);
40+
}
41+
</script>
42+
43+
{#snippet MonthSelect()}
44+
<CalendarMonthSelect
45+
{months}
46+
{monthFormat}
47+
value={month.month}
48+
onchange={(e) => {
49+
if (!placeholder) return;
50+
const v = Number.parseInt(e.currentTarget.value);
51+
const newPlaceholder = placeholder.set({ month: v });
52+
placeholder = newPlaceholder.subtract({ months: monthIndex });
53+
}}
54+
/>
55+
{/snippet}
56+
57+
{#snippet YearSelect()}
58+
<CalendarYearSelect {years} {yearFormat} value={month.year} />
59+
{/snippet}
60+
61+
{#if captionLayout === "dropdown"}
62+
{@render MonthSelect()}
63+
{@render YearSelect()}
64+
{:else if captionLayout === "dropdown-months"}
65+
{@render MonthSelect()}
66+
{#if placeholder}
67+
{formatYear(placeholder)}
68+
{/if}
69+
{:else if captionLayout === "dropdown-years"}
70+
{#if placeholder}
71+
{formatMonth(placeholder)}
72+
{/if}
73+
{@render YearSelect()}
74+
{:else}
75+
{formatMonth(month)} {formatYear(month)}
76+
{/if}

src/lib/components/ui/calendar/calendar-cell.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<CalendarPrimitive.Cell
1313
bind:ref
1414
class={cn(
15-
"[&:has([data-selected])]:bg-accent [&:has([data-selected][data-outside-month])]:bg-accent/50 relative size-8 p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([data-selected])]:rounded-md",
15+
"size-(--cell-size) relative p-0 text-center text-sm focus-within:z-20 [&:first-child[data-selected]_[data-bits-day]]:rounded-l-md [&:last-child[data-selected]_[data-bits-day]]:rounded-r-md",
1616
className
1717
)}
1818
{...restProps}

src/lib/components/ui/calendar/calendar-day.svelte

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@
1414
bind:ref
1515
class={cn(
1616
buttonVariants({ variant: "ghost" }),
17-
"size-8 select-none p-0 font-normal",
18-
"[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground",
19-
// Selected
20-
"data-selected:bg-primary data-selected:text-primary-foreground data-selected:hover:bg-primary data-selected:hover:text-primary-foreground data-selected:focus:bg-primary data-selected:focus:text-primary-foreground data-selected:opacity-100 dark:data-selected:hover:bg-primary dark:data-selected:focus:bg-primary",
17+
"size-(--cell-size) flex select-none flex-col items-center justify-center gap-1 whitespace-nowrap p-0 font-normal leading-none",
18+
"[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground [&[data-today][data-disabled]]:text-muted-foreground",
19+
"data-selected:bg-primary dark:data-selected:hover:bg-accent/50 data-selected:text-primary-foreground",
20+
// Outside months
21+
"[&[data-outside-month]:not([data-selected])]:text-muted-foreground [&[data-outside-month]:not([data-selected])]:hover:text-accent-foreground",
2122
// Disabled
22-
"data-disabled:text-muted-foreground data-disabled:opacity-50",
23+
"data-disabled:text-muted-foreground data-disabled:pointer-events-none data-disabled:opacity-50",
2324
// Unavailable
24-
"data-unavailable:text-destructive-foreground data-unavailable:line-through",
25-
// Outside months
26-
"data-outside-month:text-muted-foreground [&[data-outside-month][data-selected]]:bg-accent/50 [&[data-outside-month][data-selected]]:text-muted-foreground data-outside-month:pointer-events-none data-outside-month:opacity-50 [&[data-outside-month][data-selected]]:opacity-30",
25+
"data-unavailable:text-muted-foreground data-unavailable:line-through",
26+
// hover
27+
"dark:hover:text-accent-foreground",
28+
// focus
29+
"focus:border-ring focus:ring-ring/50 focus:relative",
30+
// inner spans
31+
"[&>span]:text-xs [&>span]:opacity-70",
2732
className
2833
)}
2934
{...restProps}

src/lib/components/ui/calendar/calendar-grid.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111

1212
<CalendarPrimitive.Grid
1313
bind:ref
14-
class={cn("w-full border-collapse space-y-1", className)}
14+
class={cn("mt-4 flex w-full border-collapse flex-col gap-1", className)}
1515
{...restProps}
1616
/>

src/lib/components/ui/calendar/calendar-head-cell.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
<CalendarPrimitive.HeadCell
1313
bind:ref
14-
class={cn("text-muted-foreground w-8 rounded-md text-[0.8rem] font-normal", className)}
14+
class={cn(
15+
"text-muted-foreground w-(--cell-size) rounded-md text-[0.8rem] font-normal",
16+
className
17+
)}
1518
{...restProps}
1619
/>

src/lib/components/ui/calendar/calendar-header.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
<CalendarPrimitive.Header
1313
bind:ref
14-
class={cn("relative flex w-full items-center justify-between pt-1", className)}
14+
class={cn(
15+
"h-(--cell-size) flex w-full items-center justify-center gap-1.5 text-sm font-medium",
16+
className
17+
)}
1518
{...restProps}
1619
/>

0 commit comments

Comments
 (0)