Files
eewing ec317eb17c
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m11s
INIT
2026-02-18 15:17:47 -06:00

41 lines
1.3 KiB
Svelte

<script lang="ts">
import { boxWith } from "svelte-toolbelt";
import type { ScrollAreaScrollbarProps } from "../types.js";
import { ScrollAreaScrollbarState } from "../scroll-area.svelte.js";
import ScrollAreaScrollbarAuto from "./scroll-area-scrollbar-auto.svelte";
import ScrollAreaScrollbarScroll from "./scroll-area-scrollbar-scroll.svelte";
import ScrollAreaScrollbarHover from "./scroll-area-scrollbar-hover.svelte";
import ScrollAreaScrollbarVisible from "./scroll-area-scrollbar-visible.svelte";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
ref = $bindable(null),
id = createId(uid),
orientation,
...restProps
}: ScrollAreaScrollbarProps = $props();
const scrollbarState = ScrollAreaScrollbarState.create({
orientation: boxWith(() => orientation),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
});
const type = $derived(scrollbarState.root.opts.type.current);
</script>
{#if type === "hover"}
<ScrollAreaScrollbarHover {...restProps} {id} />
{:else if type === "scroll"}
<ScrollAreaScrollbarScroll {...restProps} {id} />
{:else if type === "auto"}
<ScrollAreaScrollbarAuto {...restProps} {id} />
{:else if type === "always"}
<ScrollAreaScrollbarVisible {...restProps} {id} />
{/if}