@kayord/ui 0.20.1 → 1.0.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/dist/components/ui/accordion/accordion-content.svelte +2 -5
- package/dist/components/ui/accordion/accordion.svelte +7 -0
- package/dist/components/ui/accordion/accordion.svelte.d.ts +4 -0
- package/dist/components/ui/accordion/index.d.ts +1 -1
- package/dist/components/ui/accordion/index.js +1 -1
- package/dist/components/ui/calendar/calendar-caption.svelte +76 -0
- package/dist/components/ui/calendar/calendar-caption.svelte.d.ts +19 -0
- package/dist/components/ui/calendar/calendar-cell.svelte +1 -1
- package/dist/components/ui/calendar/calendar-day.svelte +13 -8
- package/dist/components/ui/calendar/calendar-grid.svelte +5 -1
- package/dist/components/ui/calendar/calendar-head-cell.svelte +1 -1
- package/dist/components/ui/calendar/calendar-header.svelte +1 -1
- package/dist/components/ui/calendar/calendar-heading.svelte +1 -1
- package/dist/components/ui/calendar/calendar-month-select.svelte +42 -0
- package/dist/components/ui/calendar/calendar-month-select.svelte.d.ts +4 -0
- package/dist/components/ui/calendar/calendar-month.svelte +15 -0
- package/dist/components/ui/calendar/calendar-month.svelte.d.ts +5 -0
- package/dist/components/ui/calendar/calendar-months.svelte +1 -5
- package/dist/components/ui/calendar/calendar-nav.svelte +19 -0
- package/dist/components/ui/calendar/calendar-nav.svelte.d.ts +5 -0
- package/dist/components/ui/calendar/calendar-next-button.svelte +12 -4
- package/dist/components/ui/calendar/calendar-next-button.svelte.d.ts +5 -1
- package/dist/components/ui/calendar/calendar-prev-button.svelte +12 -4
- package/dist/components/ui/calendar/calendar-prev-button.svelte.d.ts +5 -1
- package/dist/components/ui/calendar/calendar-year-select.svelte +41 -0
- package/dist/components/ui/calendar/calendar-year-select.svelte.d.ts +4 -0
- package/dist/components/ui/calendar/calendar.svelte +82 -28
- package/dist/components/ui/calendar/calendar.svelte.d.ts +16 -1
- package/dist/components/ui/calendar/index.d.ts +6 -1
- package/dist/components/ui/calendar/index.js +6 -1
- package/dist/components/ui/carousel/carousel-next.svelte +1 -1
- package/dist/components/ui/carousel/carousel-previous.svelte +1 -1
- package/dist/components/ui/carousel/carousel.svelte +10 -17
- package/dist/components/ui/carousel/context.d.ts +1 -2
- package/dist/components/ui/chart/chart-container.svelte +1 -4
- package/dist/components/ui/collapsible/collapsible.svelte +1 -1
- package/dist/components/ui/collapsible/index.d.ts +3 -15
- package/dist/components/ui/collapsible/index.js +3 -4
- package/dist/components/ui/dialog/dialog-content.svelte +10 -6
- package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
- package/dist/components/ui/drawer/drawer-content.svelte +1 -1
- package/dist/components/ui/drawer/drawer-footer.svelte +1 -1
- package/dist/components/ui/drawer/drawer-header.svelte +1 -1
- package/dist/components/ui/input/input.svelte +1 -1
- package/dist/components/ui/pagination/pagination-link.svelte +1 -1
- package/dist/components/ui/radio-group/radio-group-item.svelte +1 -1
- package/dist/components/ui/range-calendar/index.d.ts +6 -1
- package/dist/components/ui/range-calendar/index.js +6 -1
- package/dist/components/ui/range-calendar/range-calendar-caption.svelte +76 -0
- package/dist/components/ui/range-calendar/range-calendar-caption.svelte.d.ts +19 -0
- package/dist/components/ui/range-calendar/range-calendar-cell.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar-day.svelte +16 -9
- package/dist/components/ui/range-calendar/range-calendar-grid.svelte +5 -1
- package/dist/components/ui/range-calendar/range-calendar-head-cell.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar-header.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar-heading.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar-month-select.svelte +42 -0
- package/dist/components/ui/range-calendar/range-calendar-month-select.svelte.d.ts +4 -0
- package/dist/components/ui/range-calendar/range-calendar-month.svelte +15 -0
- package/dist/components/ui/range-calendar/range-calendar-month.svelte.d.ts +5 -0
- package/dist/components/ui/range-calendar/range-calendar-months.svelte +2 -6
- package/dist/components/ui/range-calendar/range-calendar-months.svelte.d.ts +1 -1
- package/dist/components/ui/range-calendar/range-calendar-nav.svelte +19 -0
- package/dist/components/ui/range-calendar/range-calendar-nav.svelte.d.ts +5 -0
- package/dist/components/ui/range-calendar/range-calendar-next-button.svelte +7 -4
- package/dist/components/ui/range-calendar/range-calendar-next-button.svelte.d.ts +5 -1
- package/dist/components/ui/range-calendar/range-calendar-prev-button.svelte +7 -4
- package/dist/components/ui/range-calendar/range-calendar-prev-button.svelte.d.ts +5 -1
- package/dist/components/ui/range-calendar/range-calendar-year-select.svelte +41 -0
- package/dist/components/ui/range-calendar/range-calendar-year-select.svelte.d.ts +4 -0
- package/dist/components/ui/range-calendar/range-calendar.svelte +83 -28
- package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +17 -1
- package/dist/components/ui/select/index.d.ts +2 -1
- package/dist/components/ui/select/index.js +3 -2
- package/dist/components/ui/select/select-group-heading.svelte +15 -2
- package/dist/components/ui/select/select-group-heading.svelte.d.ts +8 -2
- package/dist/components/ui/select/select-trigger.svelte +1 -1
- package/dist/components/ui/separator/separator.svelte +1 -1
- package/dist/hooks/is-mobile.svelte.d.ts +1 -1
- package/dist/hooks/is-mobile.svelte.js +3 -3
- package/package.json +8 -8
|
@@ -13,13 +13,10 @@
|
|
|
13
13
|
<AccordionPrimitive.Content
|
|
14
14
|
bind:ref
|
|
15
15
|
data-slot="accordion-content"
|
|
16
|
-
class=
|
|
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"
|
|
20
17
|
{...restProps}
|
|
21
18
|
>
|
|
22
|
-
<div class="pt-0 pb-4">
|
|
19
|
+
<div class={cn("pt-0 pb-4", className)}>
|
|
23
20
|
{@render children?.()}
|
|
24
21
|
</div>
|
|
25
22
|
</AccordionPrimitive.Content>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Accordion as AccordionPrimitive } from "bits-ui";
|
|
3
|
+
|
|
4
|
+
let { ref = $bindable(null), value = $bindable(), ...restProps }: AccordionPrimitive.RootProps = $props();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<AccordionPrimitive.Root bind:ref bind:value={value as never} data-slot="accordion" {...restProps} />
|
|
@@ -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}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ComponentProps } from "svelte";
|
|
2
|
+
import type Calendar from "./calendar.svelte";
|
|
3
|
+
import CalendarMonthSelect from "./calendar-month-select.svelte";
|
|
4
|
+
import CalendarYearSelect from "./calendar-year-select.svelte";
|
|
5
|
+
import { type DateValue } from "@internationalized/date";
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
captionLayout: ComponentProps<typeof Calendar>["captionLayout"];
|
|
8
|
+
months: ComponentProps<typeof CalendarMonthSelect>["months"];
|
|
9
|
+
monthFormat: ComponentProps<typeof CalendarMonthSelect>["monthFormat"];
|
|
10
|
+
years: ComponentProps<typeof CalendarYearSelect>["years"];
|
|
11
|
+
yearFormat: ComponentProps<typeof CalendarYearSelect>["yearFormat"];
|
|
12
|
+
month: DateValue;
|
|
13
|
+
placeholder: DateValue | undefined;
|
|
14
|
+
locale: string;
|
|
15
|
+
monthIndex: number;
|
|
16
|
+
};
|
|
17
|
+
declare const CalendarCaption: import("svelte").Component<$$ComponentProps, {}, "placeholder">;
|
|
18
|
+
type CalendarCaption = ReturnType<typeof CalendarCaption>;
|
|
19
|
+
export default CalendarCaption;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<CalendarPrimitive.Cell
|
|
9
9
|
bind:ref
|
|
10
10
|
class={cn(
|
|
11
|
-
"
|
|
11
|
+
"relative size-(--cell-size) 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",
|
|
12
12
|
className
|
|
13
13
|
)}
|
|
14
14
|
{...restProps}
|
|
@@ -10,16 +10,21 @@
|
|
|
10
10
|
bind:ref
|
|
11
11
|
class={cn(
|
|
12
12
|
buttonVariants({ variant: "ghost" }),
|
|
13
|
-
"size-
|
|
14
|
-
"[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground",
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
"flex size-(--cell-size) flex-col items-center justify-center gap-1 p-0 leading-none font-normal whitespace-nowrap select-none",
|
|
14
|
+
"[&[data-today]:not([data-selected])]:bg-accent [&[data-today]:not([data-selected])]:text-accent-foreground [&[data-today][data-disabled]]:text-muted-foreground",
|
|
15
|
+
"data-[selected]:bg-primary dark:data-[selected]:hover:bg-accent/50 data-[selected]:text-primary-foreground",
|
|
16
|
+
// Outside months
|
|
17
|
+
"[&[data-outside-month]:not([data-selected])]:text-muted-foreground [&[data-outside-month]:not([data-selected])]:hover:text-accent-foreground",
|
|
17
18
|
// Disabled
|
|
18
|
-
"data-disabled:text-muted-foreground data-disabled:opacity-50",
|
|
19
|
+
"data-[disabled]:text-muted-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
19
20
|
// Unavailable
|
|
20
|
-
"data-unavailable:text-
|
|
21
|
-
//
|
|
22
|
-
"
|
|
21
|
+
"data-[unavailable]:text-muted-foreground data-[unavailable]:line-through",
|
|
22
|
+
// hover
|
|
23
|
+
"dark:hover:text-accent-foreground",
|
|
24
|
+
// focus
|
|
25
|
+
"focus:border-ring focus:ring-ring/50 focus:relative",
|
|
26
|
+
// inner spans
|
|
27
|
+
"[&>span]:text-xs [&>span]:opacity-70",
|
|
23
28
|
className
|
|
24
29
|
)}
|
|
25
30
|
{...restProps}
|
|
@@ -5,4 +5,8 @@
|
|
|
5
5
|
let { ref = $bindable(null), class: className, ...restProps }: CalendarPrimitive.GridProps = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<CalendarPrimitive.Grid
|
|
8
|
+
<CalendarPrimitive.Grid
|
|
9
|
+
bind:ref
|
|
10
|
+
class={cn("mt-4 flex w-full border-collapse flex-col gap-1", className)}
|
|
11
|
+
{...restProps}
|
|
12
|
+
/>
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
let { ref = $bindable(null), class: className, ...restProps }: CalendarPrimitive.HeadingProps = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<CalendarPrimitive.Heading bind:ref class={cn("text-sm font-medium", className)} {...restProps} />
|
|
8
|
+
<CalendarPrimitive.Heading bind:ref class={cn("px-(--cell-size) text-sm font-medium", className)} {...restProps} />
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn, type WithoutChildrenOrChild } from "../../../utils.js";
|
|
4
|
+
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
value,
|
|
10
|
+
onchange,
|
|
11
|
+
...restProps
|
|
12
|
+
}: WithoutChildrenOrChild<CalendarPrimitive.MonthSelectProps> = $props();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<span
|
|
16
|
+
class={cn(
|
|
17
|
+
"has-focus:border-ring border-input has-focus:ring-ring/50 relative flex rounded-md border shadow-xs has-focus:ring-[3px]",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
>
|
|
21
|
+
<CalendarPrimitive.MonthSelect bind:ref class="absolute inset-0 opacity-0" {...restProps}>
|
|
22
|
+
{#snippet child({ props, monthItems, selectedMonthItem })}
|
|
23
|
+
<select {...props} {value} {onchange}>
|
|
24
|
+
{#each monthItems as monthItem (monthItem.value)}
|
|
25
|
+
<option
|
|
26
|
+
value={monthItem.value}
|
|
27
|
+
selected={value !== undefined ? monthItem.value === value : monthItem.value === selectedMonthItem.value}
|
|
28
|
+
>
|
|
29
|
+
{monthItem.label}
|
|
30
|
+
</option>
|
|
31
|
+
{/each}
|
|
32
|
+
</select>
|
|
33
|
+
<span
|
|
34
|
+
class="[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm font-medium select-none [&>svg]:size-3.5"
|
|
35
|
+
aria-hidden="true"
|
|
36
|
+
>
|
|
37
|
+
{monthItems.find((item) => item.value === value)?.label || selectedMonthItem.label}
|
|
38
|
+
<ChevronDownIcon class="size-4" />
|
|
39
|
+
</span>
|
|
40
|
+
{/snippet}
|
|
41
|
+
</CalendarPrimitive.MonthSelect>
|
|
42
|
+
</span>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
2
|
+
declare const CalendarMonthSelect: import("svelte").Component<Omit<Omit<CalendarPrimitive.MonthSelectProps, "child">, "children">, {}, "ref">;
|
|
3
|
+
type CalendarMonthSelect = ReturnType<typeof CalendarMonthSelect>;
|
|
4
|
+
export default CalendarMonthSelect;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { type WithElementRef, cn } from "../../../utils.js";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div {...restProps} bind:this={ref} class={cn("flex flex-col", className)}>
|
|
14
|
+
{@render children?.()}
|
|
15
|
+
</div>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type WithElementRef } from "../../../utils.js";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
declare const CalendarMonth: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLElement>>, {}, "ref">;
|
|
4
|
+
type CalendarMonth = ReturnType<typeof CalendarMonth>;
|
|
5
|
+
export default CalendarMonth;
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<div
|
|
14
|
-
bind:this={ref}
|
|
15
|
-
class={cn("mt-4 flex flex-col space-y-4 sm:flex-row sm:space-y-0 sm:space-x-4", className)}
|
|
16
|
-
{...restProps}
|
|
17
|
-
>
|
|
13
|
+
<div bind:this={ref} class={cn("relative flex flex-col gap-4 md:flex-row", className)} {...restProps}>
|
|
18
14
|
{@render children?.()}
|
|
19
15
|
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
class: className,
|
|
8
|
+
children,
|
|
9
|
+
...restProps
|
|
10
|
+
}: WithElementRef<HTMLAttributes<HTMLElement>> = $props();
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<nav
|
|
14
|
+
{...restProps}
|
|
15
|
+
bind:this={ref}
|
|
16
|
+
class={cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1", className)}
|
|
17
|
+
>
|
|
18
|
+
{@render children?.()}
|
|
19
|
+
</nav>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type WithElementRef } from "../../../utils.js";
|
|
2
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
declare const CalendarNav: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLElement>>, {}, "ref">;
|
|
4
|
+
type CalendarNav = ReturnType<typeof CalendarNav>;
|
|
5
|
+
export default CalendarNav;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
3
|
import ChevronRightIcon from "@lucide/svelte/icons/chevron-right";
|
|
4
|
-
import { buttonVariants } from "../button/index.js";
|
|
4
|
+
import { buttonVariants, type ButtonVariant } from "../button/index.js";
|
|
5
5
|
import { cn } from "../../../utils.js";
|
|
6
6
|
|
|
7
|
-
let {
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
variant = "ghost",
|
|
12
|
+
...restProps
|
|
13
|
+
}: CalendarPrimitive.NextButtonProps & {
|
|
14
|
+
variant?: ButtonVariant;
|
|
15
|
+
} = $props();
|
|
8
16
|
</script>
|
|
9
17
|
|
|
10
18
|
{#snippet Fallback()}
|
|
@@ -14,8 +22,8 @@
|
|
|
14
22
|
<CalendarPrimitive.NextButton
|
|
15
23
|
bind:ref
|
|
16
24
|
class={cn(
|
|
17
|
-
buttonVariants({ variant
|
|
18
|
-
"size-
|
|
25
|
+
buttonVariants({ variant }),
|
|
26
|
+
"size-(--cell-size) bg-transparent p-0 select-none disabled:opacity-50 rtl:rotate-180",
|
|
19
27
|
className
|
|
20
28
|
)}
|
|
21
29
|
children={children || Fallback}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
2
|
-
|
|
2
|
+
import { type ButtonVariant } from "../button/index.js";
|
|
3
|
+
type $$ComponentProps = CalendarPrimitive.NextButtonProps & {
|
|
4
|
+
variant?: ButtonVariant;
|
|
5
|
+
};
|
|
6
|
+
declare const CalendarNextButton: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
3
7
|
type CalendarNextButton = ReturnType<typeof CalendarNextButton>;
|
|
4
8
|
export default CalendarNextButton;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
3
|
import ChevronLeftIcon from "@lucide/svelte/icons/chevron-left";
|
|
4
|
-
import { buttonVariants } from "../button/index.js";
|
|
4
|
+
import { buttonVariants, type ButtonVariant } from "../button/index.js";
|
|
5
5
|
import { cn } from "../../../utils.js";
|
|
6
6
|
|
|
7
|
-
let {
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
variant = "ghost",
|
|
12
|
+
...restProps
|
|
13
|
+
}: CalendarPrimitive.PrevButtonProps & {
|
|
14
|
+
variant?: ButtonVariant;
|
|
15
|
+
} = $props();
|
|
8
16
|
</script>
|
|
9
17
|
|
|
10
18
|
{#snippet Fallback()}
|
|
@@ -14,8 +22,8 @@
|
|
|
14
22
|
<CalendarPrimitive.PrevButton
|
|
15
23
|
bind:ref
|
|
16
24
|
class={cn(
|
|
17
|
-
buttonVariants({ variant
|
|
18
|
-
"size-
|
|
25
|
+
buttonVariants({ variant }),
|
|
26
|
+
"size-(--cell-size) bg-transparent p-0 select-none disabled:opacity-50 rtl:rotate-180",
|
|
19
27
|
className
|
|
20
28
|
)}
|
|
21
29
|
children={children || Fallback}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
2
|
-
|
|
2
|
+
import { type ButtonVariant } from "../button/index.js";
|
|
3
|
+
type $$ComponentProps = CalendarPrimitive.PrevButtonProps & {
|
|
4
|
+
variant?: ButtonVariant;
|
|
5
|
+
};
|
|
6
|
+
declare const CalendarPrevButton: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
3
7
|
type CalendarPrevButton = ReturnType<typeof CalendarPrevButton>;
|
|
4
8
|
export default CalendarPrevButton;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
|
+
import { cn, type WithoutChildrenOrChild } from "../../../utils.js";
|
|
4
|
+
import ChevronDownIcon from "@lucide/svelte/icons/chevron-down";
|
|
5
|
+
|
|
6
|
+
let {
|
|
7
|
+
ref = $bindable(null),
|
|
8
|
+
class: className,
|
|
9
|
+
value,
|
|
10
|
+
...restProps
|
|
11
|
+
}: WithoutChildrenOrChild<CalendarPrimitive.YearSelectProps> = $props();
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<span
|
|
15
|
+
class={cn(
|
|
16
|
+
"has-focus:border-ring border-input has-focus:ring-ring/50 relative flex rounded-md border shadow-xs has-focus:ring-[3px]",
|
|
17
|
+
className
|
|
18
|
+
)}
|
|
19
|
+
>
|
|
20
|
+
<CalendarPrimitive.YearSelect bind:ref class="absolute inset-0 opacity-0" {...restProps}>
|
|
21
|
+
{#snippet child({ props, yearItems, selectedYearItem })}
|
|
22
|
+
<select {...props} {value}>
|
|
23
|
+
{#each yearItems as yearItem (yearItem.value)}
|
|
24
|
+
<option
|
|
25
|
+
value={yearItem.value}
|
|
26
|
+
selected={value !== undefined ? yearItem.value === value : yearItem.value === selectedYearItem.value}
|
|
27
|
+
>
|
|
28
|
+
{yearItem.label}
|
|
29
|
+
</option>
|
|
30
|
+
{/each}
|
|
31
|
+
</select>
|
|
32
|
+
<span
|
|
33
|
+
class="[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pr-1 pl-2 text-sm font-medium select-none [&>svg]:size-3.5"
|
|
34
|
+
aria-hidden="true"
|
|
35
|
+
>
|
|
36
|
+
{yearItems.find((item) => item.value === value)?.label || selectedYearItem.label}
|
|
37
|
+
<ChevronDownIcon class="size-4" />
|
|
38
|
+
</span>
|
|
39
|
+
{/snippet}
|
|
40
|
+
</CalendarPrimitive.YearSelect>
|
|
41
|
+
</span>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
2
|
+
declare const CalendarYearSelect: import("svelte").Component<Omit<Omit<CalendarPrimitive.YearSelectProps, "child">, "children">, {}, "ref">;
|
|
3
|
+
type CalendarYearSelect = ReturnType<typeof CalendarYearSelect>;
|
|
4
|
+
export default CalendarYearSelect;
|
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
3
3
|
import * as Calendar from "./index.js";
|
|
4
4
|
import { cn, type WithoutChildrenOrChild } from "../../../utils.js";
|
|
5
|
+
import type { ButtonVariant } from "../button/button.svelte";
|
|
6
|
+
import { isEqualMonth, type DateValue } from "@internationalized/date";
|
|
7
|
+
import type { Snippet } from "svelte";
|
|
5
8
|
|
|
6
9
|
let {
|
|
7
10
|
ref = $bindable(null),
|
|
@@ -9,8 +12,31 @@
|
|
|
9
12
|
placeholder = $bindable(),
|
|
10
13
|
class: className,
|
|
11
14
|
weekdayFormat = "short",
|
|
15
|
+
buttonVariant = "ghost",
|
|
16
|
+
captionLayout = "label",
|
|
17
|
+
locale = "en-US",
|
|
18
|
+
months: monthsProp,
|
|
19
|
+
years,
|
|
20
|
+
monthFormat: monthFormatProp,
|
|
21
|
+
yearFormat = "numeric",
|
|
22
|
+
day,
|
|
23
|
+
disableDaysOutsideMonth = false,
|
|
12
24
|
...restProps
|
|
13
|
-
}: WithoutChildrenOrChild<CalendarPrimitive.RootProps>
|
|
25
|
+
}: WithoutChildrenOrChild<CalendarPrimitive.RootProps> & {
|
|
26
|
+
buttonVariant?: ButtonVariant;
|
|
27
|
+
captionLayout?: "dropdown" | "dropdown-months" | "dropdown-years" | "label";
|
|
28
|
+
months?: CalendarPrimitive.MonthSelectProps["months"];
|
|
29
|
+
years?: CalendarPrimitive.YearSelectProps["years"];
|
|
30
|
+
monthFormat?: CalendarPrimitive.MonthSelectProps["monthFormat"];
|
|
31
|
+
yearFormat?: CalendarPrimitive.YearSelectProps["yearFormat"];
|
|
32
|
+
day?: Snippet<[{ day: DateValue; outsideMonth: boolean }]>;
|
|
33
|
+
} = $props();
|
|
34
|
+
|
|
35
|
+
const monthFormat = $derived.by(() => {
|
|
36
|
+
if (monthFormatProp) return monthFormatProp;
|
|
37
|
+
if (captionLayout.startsWith("dropdown")) return "short";
|
|
38
|
+
return "long";
|
|
39
|
+
});
|
|
14
40
|
</script>
|
|
15
41
|
|
|
16
42
|
<!--
|
|
@@ -22,39 +48,67 @@ get along, so we shut typescript up by casting `value` to `never`.
|
|
|
22
48
|
bind:ref
|
|
23
49
|
bind:placeholder
|
|
24
50
|
{weekdayFormat}
|
|
25
|
-
|
|
51
|
+
{disableDaysOutsideMonth}
|
|
52
|
+
class={cn(
|
|
53
|
+
"bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",
|
|
54
|
+
className
|
|
55
|
+
)}
|
|
56
|
+
{locale}
|
|
57
|
+
{monthFormat}
|
|
58
|
+
{yearFormat}
|
|
26
59
|
{...restProps}
|
|
27
60
|
>
|
|
28
61
|
{#snippet children({ months, weekdays })}
|
|
29
|
-
<Calendar.Header>
|
|
30
|
-
<Calendar.PrevButton />
|
|
31
|
-
<Calendar.Heading />
|
|
32
|
-
<Calendar.NextButton />
|
|
33
|
-
</Calendar.Header>
|
|
34
62
|
<Calendar.Months>
|
|
35
|
-
|
|
36
|
-
<Calendar.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
<Calendar.Nav>
|
|
64
|
+
<Calendar.PrevButton variant={buttonVariant} />
|
|
65
|
+
<Calendar.NextButton variant={buttonVariant} />
|
|
66
|
+
</Calendar.Nav>
|
|
67
|
+
{#each months as month, monthIndex (month)}
|
|
68
|
+
<Calendar.Month>
|
|
69
|
+
<Calendar.Header>
|
|
70
|
+
<Calendar.Caption
|
|
71
|
+
{captionLayout}
|
|
72
|
+
months={monthsProp}
|
|
73
|
+
{monthFormat}
|
|
74
|
+
{years}
|
|
75
|
+
{yearFormat}
|
|
76
|
+
month={month.value}
|
|
77
|
+
bind:placeholder
|
|
78
|
+
{locale}
|
|
79
|
+
{monthIndex}
|
|
80
|
+
/>
|
|
81
|
+
</Calendar.Header>
|
|
82
|
+
<Calendar.Grid>
|
|
83
|
+
<Calendar.GridHead>
|
|
84
|
+
<Calendar.GridRow class="select-none">
|
|
85
|
+
{#each weekdays as weekday (weekday)}
|
|
86
|
+
<Calendar.HeadCell>
|
|
87
|
+
{weekday.slice(0, 2)}
|
|
88
|
+
</Calendar.HeadCell>
|
|
53
89
|
{/each}
|
|
54
90
|
</Calendar.GridRow>
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
</Calendar.GridHead>
|
|
92
|
+
<Calendar.GridBody>
|
|
93
|
+
{#each month.weeks as weekDates (weekDates)}
|
|
94
|
+
<Calendar.GridRow class="mt-2 w-full">
|
|
95
|
+
{#each weekDates as date (date)}
|
|
96
|
+
<Calendar.Cell {date} month={month.value}>
|
|
97
|
+
{#if day}
|
|
98
|
+
{@render day({
|
|
99
|
+
day: date,
|
|
100
|
+
outsideMonth: !isEqualMonth(date, month.value),
|
|
101
|
+
})}
|
|
102
|
+
{:else}
|
|
103
|
+
<Calendar.Day />
|
|
104
|
+
{/if}
|
|
105
|
+
</Calendar.Cell>
|
|
106
|
+
{/each}
|
|
107
|
+
</Calendar.GridRow>
|
|
108
|
+
{/each}
|
|
109
|
+
</Calendar.GridBody>
|
|
110
|
+
</Calendar.Grid>
|
|
111
|
+
</Calendar.Month>
|
|
58
112
|
{/each}
|
|
59
113
|
</Calendar.Months>
|
|
60
114
|
{/snippet}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import { Calendar as CalendarPrimitive } from "bits-ui";
|
|
2
2
|
import * as Calendar from "./index.js";
|
|
3
3
|
import { type WithoutChildrenOrChild } from "../../../utils.js";
|
|
4
|
-
|
|
4
|
+
import type { ButtonVariant } from "../button/button.svelte";
|
|
5
|
+
import { type DateValue } from "@internationalized/date";
|
|
6
|
+
import type { Snippet } from "svelte";
|
|
7
|
+
type $$ComponentProps = WithoutChildrenOrChild<CalendarPrimitive.RootProps> & {
|
|
8
|
+
buttonVariant?: ButtonVariant;
|
|
9
|
+
captionLayout?: "dropdown" | "dropdown-months" | "dropdown-years" | "label";
|
|
10
|
+
months?: CalendarPrimitive.MonthSelectProps["months"];
|
|
11
|
+
years?: CalendarPrimitive.YearSelectProps["years"];
|
|
12
|
+
monthFormat?: CalendarPrimitive.MonthSelectProps["monthFormat"];
|
|
13
|
+
yearFormat?: CalendarPrimitive.YearSelectProps["yearFormat"];
|
|
14
|
+
day?: Snippet<[{
|
|
15
|
+
day: DateValue;
|
|
16
|
+
outsideMonth: boolean;
|
|
17
|
+
}]>;
|
|
18
|
+
};
|
|
19
|
+
declare const Calendar: import("svelte").Component<$$ComponentProps, {}, "value" | "placeholder" | "ref">;
|
|
5
20
|
type Calendar = ReturnType<typeof Calendar>;
|
|
6
21
|
export default Calendar;
|
|
@@ -11,4 +11,9 @@ import GridHead from "./calendar-grid-head.svelte";
|
|
|
11
11
|
import HeadCell from "./calendar-head-cell.svelte";
|
|
12
12
|
import NextButton from "./calendar-next-button.svelte";
|
|
13
13
|
import PrevButton from "./calendar-prev-button.svelte";
|
|
14
|
-
|
|
14
|
+
import MonthSelect from "./calendar-month-select.svelte";
|
|
15
|
+
import YearSelect from "./calendar-year-select.svelte";
|
|
16
|
+
import Month from "./calendar-month.svelte";
|
|
17
|
+
import Nav from "./calendar-nav.svelte";
|
|
18
|
+
import Caption from "./calendar-caption.svelte";
|
|
19
|
+
export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, Nav, Month, YearSelect, MonthSelect, Caption, Root as Calendar, };
|