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

44 lines
1.1 KiB
Svelte

<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import type { TimeRangeFieldInputProps } from "../types.js";
import { TimeRangeFieldInputState } from "../time-range-field.svelte.js";
import { createId } from "../../../internal/create-id.js";
import TimeFieldHiddenInput from "../../time-field/components/time-field-hidden-input.svelte";
const uid = $props.id();
let {
id = createId(uid),
ref = $bindable(null),
name = "",
child,
children,
type,
...restProps
}: TimeRangeFieldInputProps = $props();
const inputState = TimeRangeFieldInputState.create(
{
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
name: boxWith(() => name),
},
type
);
const mergedProps = $derived(mergeProps(restProps, inputState.props, { role: "presentation" }));
</script>
{#if child}
{@render child({ props: mergedProps, segments: inputState.root.segmentContents })}
{:else}
<div {...mergedProps}>
{@render children?.({ segments: inputState.root.segmentContents })}
</div>
{/if}
<TimeFieldHiddenInput />