You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
804 B
33 lines
804 B
<script lang="ts">
|
|
import { readableActive, writableActive } from '$libs/reactive';
|
|
import { mergeProps } from '../../../props';
|
|
import { createId } from '../../../id';
|
|
import { EditableHiddenInputProvider } from '../editable-provider.svelte';
|
|
import type { EditableHiddenInputProps } from '../types';
|
|
|
|
const uid = $props.id();
|
|
|
|
let {
|
|
ref = $bindable(null),
|
|
id = createId(uid, 'editable-hidden-input'),
|
|
child,
|
|
...restProps
|
|
}: EditableHiddenInputProps = $props();
|
|
|
|
const state = EditableHiddenInputProvider.create({
|
|
id: readableActive(() => id),
|
|
ref: writableActive(
|
|
() => ref,
|
|
(v) => (ref = v)
|
|
)
|
|
});
|
|
|
|
const mergedProps = $derived(mergeProps(restProps, state.props));
|
|
</script>
|
|
|
|
{#if child}
|
|
{@render child({ props: mergedProps })}
|
|
{:else}
|
|
<input {...mergedProps} />
|
|
{/if}
|