This commit is contained in:
Generated
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
<script lang="ts">
|
||||
import { boxWith, mergeProps } from "svelte-toolbelt";
|
||||
import { IsMounted } from "runed";
|
||||
import type { ScrollAreaThumbProps } from "../types.js";
|
||||
import { ScrollAreaThumbImplState } from "../scroll-area.svelte.js";
|
||||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
id,
|
||||
child,
|
||||
children,
|
||||
present,
|
||||
...restProps
|
||||
}: Omit<ScrollAreaThumbProps, "forceMount" | "id"> & {
|
||||
id: string;
|
||||
present: boolean;
|
||||
} = $props();
|
||||
|
||||
const isMounted = new IsMounted();
|
||||
|
||||
const thumbState = ScrollAreaThumbImplState.create({
|
||||
id: boxWith(() => id),
|
||||
ref: boxWith(
|
||||
() => ref,
|
||||
(v) => (ref = v)
|
||||
),
|
||||
mounted: boxWith(() => isMounted.current),
|
||||
});
|
||||
|
||||
const mergedProps = $derived(
|
||||
mergeProps(restProps, thumbState.props, {
|
||||
style: {
|
||||
hidden: !present,
|
||||
},
|
||||
})
|
||||
);
|
||||
</script>
|
||||
|
||||
{#if child}
|
||||
{@render child({ props: mergedProps })}
|
||||
{:else}
|
||||
<div {...mergedProps}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
{/if}
|
||||
Reference in New Issue
Block a user