Chore: update TextInput to extend input element #52

Merged
BenjaminPalko merged 1 commit from chore-TextInput-extends-input-element into master 2025-01-16 13:46:31 -05:00
Showing only changes of commit 5fe4ae77e7 - Show all commits

View file

@ -1,26 +1,23 @@
<script lang="ts">
import type { DaisyColor, DaisySize } from '$lib/types';
import type { Snippet } from 'svelte';
import type { HTMLInputTypeAttribute } from 'svelte/elements';
import type { HTMLInputTypeAttribute, SvelteHTMLElements } from 'svelte/elements';
import { fade as fadeTransition } from 'svelte/transition';
type Props = {
bordered?: boolean;
color?: Exclude<DaisyColor, 'neutral'>;
disabled?: boolean;
error?: string | Snippet;
fade?: boolean;
start?: string | Snippet;
end?: string | Snippet;
label?: string | Snippet;
name: string;
placeholder?: string;
size?: DaisySize;
type?: Extract<
HTMLInputTypeAttribute,
'email' | 'password' | 'search' | 'tel' | 'text' | 'url'
>;
};
} & Omit<SvelteHTMLElements['input'], 'type'>;
let {
bordered = false,
@ -35,10 +32,11 @@
placeholder,
size,
type = 'text',
...props
}: Props = $props();
</script>
<label class="form-control w-full">
<label class="form-control w-full" transition:fadeTransition={{ duration: fade ? 200 : 0 }}>
<div class="label">
<span
class="label-text"
@ -65,7 +63,6 @@
</span>
</div>
<div
transition:fadeTransition={{ duration: fade ? 200 : 0 }}
class="input flex w-full items-center gap-2"
class:input-bordered={bordered}
class:input-xs={size === 'xs'}
@ -85,7 +82,7 @@
{:else}
{@render start?.()}
{/if}
<input {disabled} {name} {placeholder} {type} class="grow" />
<input {...props} {disabled} {name} {placeholder} {type} class="grow" />
{#if typeof end === 'string'}
{end}
{:else}