Files
eewing cf73cd3b4c INIT
2026-02-17 14:10:16 -06:00

37 lines
829 B
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { CalendarPrevButtonProps } from "../types.js";
import { CalendarPrevButtonState } from "../calendar.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
children,
child,
id = createId(uid),
ref = $bindable(null),
// for safari
tabindex = 0,
...restProps
}: CalendarPrevButtonProps = $props();
const prevButtonState = CalendarPrevButtonState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, prevButtonState.props, { tabindex }));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<button {...mergedProps}>
{@render children?.()}
</button>
{/if}