update FramelessButton, PhoneInput, TextInput

- FramelessButton: use cursor-pointer
- PhoneInput: add setCountryByIP with geo lookup
- TextInput: add $bindable ref property
This commit is contained in:
Elijah Duffy
2025-05-06 10:59:42 -07:00
parent be7ef6bdfd
commit 8c27737404
3 changed files with 26 additions and 7 deletions

View File

@@ -10,7 +10,8 @@
placeholder,
type,
validate: validateOpts,
invalidMessage
invalidMessage = 'Field is required',
ref = $bindable<HTMLInputElement | null>(null)
}: {
name: string;
label?: string;
@@ -19,6 +20,7 @@
type?: HTMLInputElement['type'];
validate?: ValidatorOptions;
invalidMessage?: string;
ref?: HTMLInputElement | null;
} = $props();
let valid: boolean = $state(true);
@@ -34,15 +36,18 @@
{name}
{type}
bind:value
bind:ref
validate={validateOpts}
onvalidate={(e) => {
valid = e.detail.valid;
}}
/>
<div class={['opacity-0 transition-opacity', !valid && 'opacity-100']}>
<Label for={name} error>
{invalidMessage !== undefined && invalidMessage != '' ? invalidMessage : 'Field is required'}
</Label>
</div>
{#if validateOpts}
<div class={['opacity-0 transition-opacity', !valid && 'opacity-100']}>
<Label for={name} error>
{invalidMessage}
</Label>
</div>
{/if}
</div>