Files
base/node_modules/bits-ui/dist/bits/slider/components/slider-tick-label.svelte
T
eewing ec317eb17c
CI / build (push) Has been skipped
CI / deploy (push) Successful in 1m11s
INIT
2026-02-18 15:17:47 -06:00

51 lines
1.1 KiB
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { SliderTickLabelProps } from "../types.js";
import { SliderRootContext, SliderTickLabelState } from "../slider.svelte.js";
import { createId } from "../../../internal/create-id.js";
const uid = $props.id();
let {
children,
child,
ref = $bindable(null),
id = createId(uid),
index,
position: positionProp,
...restProps
}: SliderTickLabelProps = $props();
const root = SliderRootContext.get();
const position = $derived.by(() => {
if (positionProp !== undefined) return positionProp;
switch (root.direction) {
case "lr":
case "rl":
return "top";
case "tb":
case "bt":
return "left";
}
});
const tickLabelState = SliderTickLabelState.create({
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
index: boxWith(() => index),
position: boxWith(() => position),
});
const mergedProps = $derived(mergeProps(restProps, tickLabelState.props));
</script>
{#if child}
{@render child({ props: mergedProps })}
{:else}
<span {...mergedProps}>{@render children?.()}</span>
{/if}