Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
25 lines
880 B
Svelte
25 lines
880 B
Svelte
<script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>">
|
|
import * as FormPrimitive from 'formsnap';
|
|
import type { FormPath } from 'sveltekit-superforms';
|
|
import { cn, type WithElementRef, type WithoutChildren } from '$lib/utils.js';
|
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
|
|
let {
|
|
ref = $bindable(null),
|
|
class: className,
|
|
form,
|
|
name,
|
|
children: childrenProp,
|
|
...restProps
|
|
}: FormPrimitive.FieldProps<T, U> &
|
|
WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();
|
|
</script>
|
|
|
|
<FormPrimitive.Field {form} {name}>
|
|
{#snippet children({ constraints, errors, tainted, value })}
|
|
<div bind:this={ref} data-slot="form-item" class={cn('space-y-2', className)} {...restProps}>
|
|
{@render childrenProp?.({ constraints, errors, tainted, value: value as T[U] })}
|
|
</div>
|
|
{/snippet}
|
|
</FormPrimitive.Field>
|