@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
|
@@ -11,6 +11,11 @@ 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,
|
|
15
20
|
//
|
|
16
21
|
Root as Calendar, };
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
data-slot="carousel-next"
|
|
21
21
|
{variant}
|
|
22
22
|
{size}
|
|
23
|
+
aria-disabled={!emblaCtx.canScrollNext}
|
|
23
24
|
class={cn(
|
|
24
25
|
"absolute size-8 rounded-full",
|
|
25
26
|
emblaCtx.orientation === "horizontal"
|
|
@@ -27,7 +28,6 @@
|
|
|
27
28
|
: "-bottom-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
28
29
|
className
|
|
29
30
|
)}
|
|
30
|
-
disabled={!emblaCtx.canScrollNext}
|
|
31
31
|
onclick={emblaCtx.scrollNext}
|
|
32
32
|
onkeydown={emblaCtx.handleKeyDown}
|
|
33
33
|
bind:ref
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
data-slot="carousel-previous"
|
|
21
21
|
{variant}
|
|
22
22
|
{size}
|
|
23
|
+
disabled={!emblaCtx.canScrollPrev}
|
|
23
24
|
class={cn(
|
|
24
25
|
"absolute size-8 rounded-full",
|
|
25
26
|
emblaCtx.orientation === "horizontal"
|
|
@@ -27,7 +28,6 @@
|
|
|
27
28
|
: "-top-12 left-1/2 -translate-x-1/2 rotate-90",
|
|
28
29
|
className
|
|
29
30
|
)}
|
|
30
|
-
disabled={!emblaCtx.canScrollPrev}
|
|
31
31
|
onclick={emblaCtx.scrollPrev}
|
|
32
32
|
onkeydown={emblaCtx.handleKeyDown}
|
|
33
33
|
{...restProps}
|
|
@@ -34,28 +34,22 @@
|
|
|
34
34
|
function scrollPrev() {
|
|
35
35
|
carouselState.api?.scrollPrev();
|
|
36
36
|
}
|
|
37
|
+
|
|
37
38
|
function scrollNext() {
|
|
38
39
|
carouselState.api?.scrollNext();
|
|
39
40
|
}
|
|
41
|
+
|
|
40
42
|
function scrollTo(index: number, jump?: boolean) {
|
|
41
43
|
carouselState.api?.scrollTo(index, jump);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
function onSelect(
|
|
45
|
-
if (!api) return;
|
|
46
|
-
carouselState.
|
|
47
|
-
carouselState.canScrollNext = api.canScrollNext();
|
|
48
|
-
carouselState.
|
|
46
|
+
function onSelect() {
|
|
47
|
+
if (!carouselState.api) return;
|
|
48
|
+
carouselState.selectedIndex = carouselState.api.selectedScrollSnap();
|
|
49
|
+
carouselState.canScrollNext = carouselState.api.canScrollNext();
|
|
50
|
+
carouselState.canScrollPrev = carouselState.api.canScrollPrev();
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
$effect(() => {
|
|
52
|
-
if (carouselState.api) {
|
|
53
|
-
onSelect(carouselState.api);
|
|
54
|
-
carouselState.api.on("select", onSelect);
|
|
55
|
-
carouselState.api.on("reInit", onSelect);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
53
|
function handleKeyDown(e: KeyboardEvent) {
|
|
60
54
|
if (e.key === "ArrowLeft") {
|
|
61
55
|
e.preventDefault();
|
|
@@ -66,14 +60,13 @@
|
|
|
66
60
|
}
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
$effect(() => {
|
|
70
|
-
setApi(carouselState.api);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
63
|
function onInit(event: CustomEvent<CarouselAPI>) {
|
|
74
64
|
carouselState.api = event.detail;
|
|
65
|
+
setApi(carouselState.api);
|
|
75
66
|
|
|
76
67
|
carouselState.scrollSnaps = carouselState.api.scrollSnapList();
|
|
68
|
+
carouselState.api.on("select", onSelect);
|
|
69
|
+
onSelect();
|
|
77
70
|
}
|
|
78
71
|
|
|
79
72
|
$effect(() => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { WithElementRef } from "../../../utils.js";
|
|
2
|
-
import type { EmblaCarouselSvelteType } from "embla-carousel-svelte";
|
|
3
|
-
import type emblaCarouselSvelte from "embla-carousel-svelte";
|
|
2
|
+
import type { EmblaCarouselSvelteType, default as emblaCarouselSvelte } from "embla-carousel-svelte";
|
|
4
3
|
import type { HTMLAttributes } from "svelte/elements";
|
|
5
4
|
export type CarouselAPI = NonNullable<NonNullable<EmblaCarouselSvelteType["$$_attributes"]>["on:emblaInit"]> extends (evt: CustomEvent<infer CarouselAPI>) => void ? CarouselAPI : never;
|
|
6
5
|
type EmblaCarouselConfig = NonNullable<Parameters<typeof emblaCarouselSvelte>[1]>;
|
|
@@ -42,12 +42,9 @@
|
|
|
42
42
|
// by default, layerchart shows a line intersecting the point when hovering, this hides that
|
|
43
43
|
"[&_.lc-highlight-line]:stroke-0",
|
|
44
44
|
|
|
45
|
-
// prevent text from being cut off
|
|
46
|
-
"[&_.lc-text-svg]:overflow-visible",
|
|
47
|
-
|
|
48
45
|
// by default, when you hover a point on a stacked series chart, it will drop the opacity
|
|
49
46
|
// of the other series, this overrides that
|
|
50
|
-
"[&_.lc-area-path]:opacity-100 [&_.lc-highlight-line]:opacity-100 [&_.lc-highlight-point]:opacity-100 [&_.lc-spline-path]:opacity-100 [&_.lc-text]:text-xs",
|
|
47
|
+
"[&_.lc-area-path]:opacity-100 [&_.lc-highlight-line]:opacity-100 [&_.lc-highlight-point]:opacity-100 [&_.lc-spline-path]:opacity-100 [&_.lc-text]:text-xs [&_.lc-text-svg]:overflow-visible",
|
|
51
48
|
|
|
52
49
|
// We don't want the little tick lines between the axis labels and the chart, so we remove
|
|
53
50
|
// the stroke. The alternative is to manually disable `tickMarks` on the x/y axis of every
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
let { ref = $bindable(null), open = $bindable(false), ...restProps }: CollapsiblePrimitive.RootProps = $props();
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
|
-
<CollapsiblePrimitive.Root bind:ref data-slot="collapsible" {...restProps} />
|
|
7
|
+
<CollapsiblePrimitive.Root bind:ref bind:open data-slot="collapsible" {...restProps} />
|
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
declare const Content: import("svelte").Component<Omit<{
|
|
5
|
-
forceMount?: boolean;
|
|
6
|
-
}, "child" | "children"> & {
|
|
7
|
-
child?: import("svelte").Snippet<[import("bits-ui").CollapsibleContentSnippetProps & {
|
|
8
|
-
props: Record<string, unknown>;
|
|
9
|
-
}]> | undefined;
|
|
10
|
-
children?: import("svelte").Snippet;
|
|
11
|
-
style?: import("bits-ui").StyleProperties | string | null | undefined;
|
|
12
|
-
ref?: HTMLElement | null | undefined;
|
|
13
|
-
} & import("bits-ui").Without<import("bits-ui").BitsPrimitiveDivAttributes, import("bits-ui").CollapsibleContentPropsWithoutHTML> & {
|
|
14
|
-
forceMount?: boolean;
|
|
15
|
-
}, {}, "ref">;
|
|
1
|
+
import Root from "./collapsible.svelte";
|
|
2
|
+
import Trigger from "./collapsible-trigger.svelte";
|
|
3
|
+
import Content from "./collapsible-content.svelte";
|
|
16
4
|
export { Root, Content, Trigger, Root as Collapsible, Content as CollapsibleContent, Trigger as CollapsibleTrigger, };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Content = CollapsiblePrimitive.Content;
|
|
1
|
+
import Root from "./collapsible.svelte";
|
|
2
|
+
import Trigger from "./collapsible-trigger.svelte";
|
|
3
|
+
import Content from "./collapsible-content.svelte";
|
|
5
4
|
export { Root, Content, Trigger,
|
|
6
5
|
//
|
|
7
6
|
Root as Collapsible, Content as CollapsibleContent, Trigger as CollapsibleTrigger, };
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
class: className,
|
|
11
11
|
portalProps,
|
|
12
12
|
children,
|
|
13
|
+
showCloseButton = true,
|
|
13
14
|
...restProps
|
|
14
15
|
}: WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
15
16
|
portalProps?: DialogPrimitive.PortalProps;
|
|
16
17
|
children: Snippet;
|
|
18
|
+
showCloseButton?: boolean;
|
|
17
19
|
} = $props();
|
|
18
20
|
</script>
|
|
19
21
|
|
|
@@ -29,11 +31,13 @@
|
|
|
29
31
|
{...restProps}
|
|
30
32
|
>
|
|
31
33
|
{@render children?.()}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
{#if showCloseButton}
|
|
35
|
+
<DialogPrimitive.Close
|
|
36
|
+
class="ring-offset-background focus:ring-ring absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
|
|
37
|
+
>
|
|
38
|
+
<XIcon />
|
|
39
|
+
<span class="sr-only">Close</span>
|
|
40
|
+
</DialogPrimitive.Close>
|
|
41
|
+
{/if}
|
|
38
42
|
</DialogPrimitive.Content>
|
|
39
43
|
</Dialog.Portal>
|
|
@@ -4,6 +4,7 @@ import { type WithoutChildrenOrChild } from "../../../utils.js";
|
|
|
4
4
|
type $$ComponentProps = WithoutChildrenOrChild<DialogPrimitive.ContentProps> & {
|
|
5
5
|
portalProps?: DialogPrimitive.PortalProps;
|
|
6
6
|
children: Snippet;
|
|
7
|
+
showCloseButton?: boolean;
|
|
7
8
|
};
|
|
8
9
|
declare const DialogContent: import("svelte").Component<$$ComponentProps, {}, "ref">;
|
|
9
10
|
type DialogContent = ReturnType<typeof DialogContent>;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
bind:ref
|
|
21
21
|
data-slot="drawer-content"
|
|
22
22
|
class={cn(
|
|
23
|
-
"group/drawer-content bg-background fixed z-50 flex h-auto flex-col
|
|
23
|
+
"group/drawer-content bg-background fixed z-50 flex h-auto flex-col",
|
|
24
24
|
"data-[vaul-drawer-direction=top]:inset-x-0 data-[vaul-drawer-direction=top]:top-0 data-[vaul-drawer-direction=top]:mb-24 data-[vaul-drawer-direction=top]:max-h-[80vh] data-[vaul-drawer-direction=top]:rounded-b-lg data-[vaul-drawer-direction=top]:border-b",
|
|
25
25
|
"data-[vaul-drawer-direction=bottom]:inset-x-0 data-[vaul-drawer-direction=bottom]:bottom-0 data-[vaul-drawer-direction=bottom]:mt-24 data-[vaul-drawer-direction=bottom]:max-h-[80vh] data-[vaul-drawer-direction=bottom]:rounded-t-lg data-[vaul-drawer-direction=bottom]:border-t",
|
|
26
26
|
"data-[vaul-drawer-direction=right]:inset-y-0 data-[vaul-drawer-direction=right]:right-0 data-[vaul-drawer-direction=right]:w-3/4 data-[vaul-drawer-direction=right]:border-l data-[vaul-drawer-direction=right]:sm:max-w-sm",
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<div bind:this={ref} data-slot="drawer-footer" class={cn("mt-auto flex flex-col gap-2", className)} {...restProps}>
|
|
13
|
+
<div bind:this={ref} data-slot="drawer-footer" class={cn("mt-auto flex flex-col gap-2 p-4", className)} {...restProps}>
|
|
14
14
|
{@render children?.()}
|
|
15
15
|
</div>
|
|
@@ -10,6 +10,6 @@
|
|
|
10
10
|
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
|
-
<div bind:this={ref} data-slot="drawer-header" class={cn("flex flex-col gap-1.5", className)} {...restProps}>
|
|
13
|
+
<div bind:this={ref} data-slot="drawer-header" class={cn("flex flex-col gap-1.5 p-4", className)} {...restProps}>
|
|
14
14
|
{@render children?.()}
|
|
15
15
|
</div>
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
bind:this={ref}
|
|
24
24
|
data-slot="input"
|
|
25
25
|
class={cn(
|
|
26
|
-
"selection:bg-primary dark:bg-input/30 selection:text-primary-foreground border-input ring-offset-background placeholder:text-muted-foreground flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3
|
|
26
|
+
"selection:bg-primary dark:bg-input/30 selection:text-primary-foreground border-input ring-offset-background placeholder:text-muted-foreground flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 pt-1.5 text-sm font-medium shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
27
27
|
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
28
28
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
29
29
|
className
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
{#snippet children({ checked })}
|
|
23
23
|
<div data-slot="radio-group-indicator" class="relative flex items-center justify-center">
|
|
24
24
|
{#if checked}
|
|
25
|
-
<CircleIcon class="fill-primary
|
|
25
|
+
<CircleIcon class="fill-primary absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2" />
|
|
26
26
|
{/if}
|
|
27
27
|
</div>
|
|
28
28
|
{/snippet}
|
|
@@ -10,6 +10,11 @@ import Heading from "./range-calendar-heading.svelte";
|
|
|
10
10
|
import HeadCell from "./range-calendar-head-cell.svelte";
|
|
11
11
|
import NextButton from "./range-calendar-next-button.svelte";
|
|
12
12
|
import PrevButton from "./range-calendar-prev-button.svelte";
|
|
13
|
+
import MonthSelect from "./range-calendar-month-select.svelte";
|
|
14
|
+
import YearSelect from "./range-calendar-year-select.svelte";
|
|
15
|
+
import Caption from "./range-calendar-caption.svelte";
|
|
16
|
+
import Nav from "./range-calendar-nav.svelte";
|
|
17
|
+
import Month from "./range-calendar-month.svelte";
|
|
13
18
|
declare const GridHead: import("svelte").Component<RangeCalendarPrimitive.GridHeadProps, {}, "ref">;
|
|
14
19
|
declare const GridBody: import("svelte").Component<RangeCalendarPrimitive.GridBodyProps, {}, "ref">;
|
|
15
|
-
export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, Root as RangeCalendar, };
|
|
20
|
+
export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, MonthSelect, YearSelect, Caption, Nav, Month, Root as RangeCalendar, };
|
|
@@ -10,8 +10,13 @@ import Heading from "./range-calendar-heading.svelte";
|
|
|
10
10
|
import HeadCell from "./range-calendar-head-cell.svelte";
|
|
11
11
|
import NextButton from "./range-calendar-next-button.svelte";
|
|
12
12
|
import PrevButton from "./range-calendar-prev-button.svelte";
|
|
13
|
+
import MonthSelect from "./range-calendar-month-select.svelte";
|
|
14
|
+
import YearSelect from "./range-calendar-year-select.svelte";
|
|
15
|
+
import Caption from "./range-calendar-caption.svelte";
|
|
16
|
+
import Nav from "./range-calendar-nav.svelte";
|
|
17
|
+
import Month from "./range-calendar-month.svelte";
|
|
13
18
|
const GridHead = RangeCalendarPrimitive.GridHead;
|
|
14
19
|
const GridBody = RangeCalendarPrimitive.GridBody;
|
|
15
|
-
export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton,
|
|
20
|
+
export { Day, Cell, Grid, Header, Months, GridRow, Heading, GridBody, GridHead, HeadCell, NextButton, PrevButton, MonthSelect, YearSelect, Caption, Nav, Month,
|
|
16
21
|
//
|
|
17
22
|
Root as RangeCalendar, };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ComponentProps } from "svelte";
|
|
3
|
+
import type RangeCalendar from "./range-calendar.svelte";
|
|
4
|
+
import RangeCalendarMonthSelect from "./range-calendar-month-select.svelte";
|
|
5
|
+
import RangeCalendarYearSelect from "./range-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 RangeCalendar>["captionLayout"];
|
|
20
|
+
months: ComponentProps<typeof RangeCalendarMonthSelect>["months"];
|
|
21
|
+
monthFormat: ComponentProps<typeof RangeCalendarMonthSelect>["monthFormat"];
|
|
22
|
+
years: ComponentProps<typeof RangeCalendarYearSelect>["years"];
|
|
23
|
+
yearFormat: ComponentProps<typeof RangeCalendarYearSelect>["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
|
+
<RangeCalendarMonthSelect
|
|
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
|
+
<RangeCalendarYearSelect {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 RangeCalendar from "./range-calendar.svelte";
|
|
3
|
+
import RangeCalendarMonthSelect from "./range-calendar-month-select.svelte";
|
|
4
|
+
import RangeCalendarYearSelect from "./range-calendar-year-select.svelte";
|
|
5
|
+
import { type DateValue } from "@internationalized/date";
|
|
6
|
+
type $$ComponentProps = {
|
|
7
|
+
captionLayout: ComponentProps<typeof RangeCalendar>["captionLayout"];
|
|
8
|
+
months: ComponentProps<typeof RangeCalendarMonthSelect>["months"];
|
|
9
|
+
monthFormat: ComponentProps<typeof RangeCalendarMonthSelect>["monthFormat"];
|
|
10
|
+
years: ComponentProps<typeof RangeCalendarYearSelect>["years"];
|
|
11
|
+
yearFormat: ComponentProps<typeof RangeCalendarYearSelect>["yearFormat"];
|
|
12
|
+
month: DateValue;
|
|
13
|
+
placeholder: DateValue | undefined;
|
|
14
|
+
locale: string;
|
|
15
|
+
monthIndex: number;
|
|
16
|
+
};
|
|
17
|
+
declare const RangeCalendarCaption: import("svelte").Component<$$ComponentProps, {}, "placeholder">;
|
|
18
|
+
type RangeCalendarCaption = ReturnType<typeof RangeCalendarCaption>;
|
|
19
|
+
export default RangeCalendarCaption;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<RangeCalendarPrimitive.Cell
|
|
9
9
|
bind:ref
|
|
10
10
|
class={cn(
|
|
11
|
-
"[&:has([data-
|
|
11
|
+
"dark:[&:has([data-range-start])]:hover:bg-accent dark:[&:has([data-range-end])]:hover:bg-accent [&:has([data-range-middle])]:bg-accent dark:[&:has([data-range-middle])]:hover:bg-accent/50 [&:has([data-selected])]:bg-accent relative size-(--cell-size) p-0 text-center text-sm focus-within:z-20 data-[range-middle]:rounded-r-md [&:first-child[data-selected]_[data-bits-day]]:rounded-l-md [&:has([data-range-end])]:rounded-r-md [&:has([data-range-middle])]:rounded-none first:[&:has([data-range-middle])]:rounded-l-md last:[&:has([data-range-middle])]:rounded-r-md [&:has([data-range-start])]:rounded-l-md [&:last-child[data-selected]_[data-bits-day]]:rounded-r-md",
|
|
12
12
|
className
|
|
13
13
|
)}
|
|
14
14
|
{...restProps}
|
|
@@ -10,18 +10,25 @@
|
|
|
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
|
-
"data-[
|
|
17
|
-
//
|
|
18
|
-
"data-[
|
|
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 data-[range-middle]:rounded-none",
|
|
15
|
+
// range Start
|
|
16
|
+
"data-[range-start]:bg-primary dark:data-[range-start]:hover:bg-accent data-[range-start]:text-primary-foreground",
|
|
17
|
+
// range End
|
|
18
|
+
"data-[range-end]:bg-primary dark:data-[range-end]:hover:bg-accent data-[range-end]:text-primary-foreground",
|
|
19
19
|
// Outside months
|
|
20
|
-
"
|
|
20
|
+
"[&[data-outside-month]:not([data-selected])]:text-muted-foreground [&[data-outside-month]:not([data-selected])]:hover:text-accent-foreground",
|
|
21
21
|
// Disabled
|
|
22
|
-
"data-[disabled]:text-muted-foreground data-[disabled]:opacity-50",
|
|
22
|
+
"data-[disabled]:text-muted-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
23
23
|
// Unavailable
|
|
24
|
-
"data-[unavailable]:
|
|
24
|
+
"data-[unavailable]:line-through",
|
|
25
|
+
"dark:data-[range-middle]:hover:bg-accent/0",
|
|
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",
|
|
25
32
|
className
|
|
26
33
|
)}
|
|
27
34
|
{...restProps}
|
|
@@ -5,4 +5,8 @@
|
|
|
5
5
|
let { ref = $bindable(null), class: className, ...restProps }: RangeCalendarPrimitive.GridProps = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<RangeCalendarPrimitive.Grid
|
|
8
|
+
<RangeCalendarPrimitive.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 }: RangeCalendarPrimitive.HeadingProps = $props();
|
|
6
6
|
</script>
|
|
7
7
|
|
|
8
|
-
<RangeCalendarPrimitive.Heading bind:ref class={cn("text-sm font-medium", className)} {...restProps} />
|
|
8
|
+
<RangeCalendarPrimitive.Heading bind:ref class={cn("px-(--cell-size) text-sm font-medium", className)} {...restProps} />
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { RangeCalendar as RangeCalendarPrimitive } 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<RangeCalendarPrimitive.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
|
+
<RangeCalendarPrimitive.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
|
+
</RangeCalendarPrimitive.MonthSelect>
|
|
42
|
+
</span>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RangeCalendar as RangeCalendarPrimitive } from "bits-ui";
|
|
2
|
+
declare const RangeCalendarMonthSelect: import("svelte").Component<Omit<Omit<RangeCalendarPrimitive.MonthSelectProps, "child">, "children">, {}, "ref">;
|
|
3
|
+
type RangeCalendarMonthSelect = ReturnType<typeof RangeCalendarMonthSelect>;
|
|
4
|
+
export default RangeCalendarMonthSelect;
|
|
@@ -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 RangeCalendarMonth: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLElement>>, {}, "ref">;
|
|
4
|
+
type RangeCalendarMonth = ReturnType<typeof RangeCalendarMonth>;
|
|
5
|
+
export default RangeCalendarMonth;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { cn, type WithElementRef } from "../../../utils.js";
|
|
3
2
|
import type { HTMLAttributes } from "svelte/elements";
|
|
3
|
+
import { cn, type WithElementRef } from "../../../utils.js";
|
|
4
4
|
|
|
5
5
|
let {
|
|
6
6
|
ref = $bindable(null),
|
|
@@ -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>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type WithElementRef } from "../../../utils.js";
|
|
2
1
|
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
import { type WithElementRef } from "../../../utils.js";
|
|
3
3
|
declare const RangeCalendarMonths: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLDivElement>>, {}, "ref">;
|
|
4
4
|
type RangeCalendarMonths = ReturnType<typeof RangeCalendarMonths>;
|
|
5
5
|
export default RangeCalendarMonths;
|
|
@@ -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 RangeCalendarNav: import("svelte").Component<WithElementRef<HTMLAttributes<HTMLElement>>, {}, "ref">;
|
|
4
|
+
type RangeCalendarNav = ReturnType<typeof RangeCalendarNav>;
|
|
5
|
+
export default RangeCalendarNav;
|