From 39ca78e8374d98acc17690acb7843632aeaedcce Mon Sep 17 00:00:00 2001 From: Elijah Duffy Date: Tue, 8 Jul 2025 12:21:58 -0700 Subject: [PATCH] action select: patch weird focus issue, add value helper field --- src/lib/ActionSelect.svelte | 109 +++++++++++++++++++++++++----------- src/lib/Button.svelte | 3 + src/routes/+page.svelte | 16 +++--- 3 files changed, 88 insertions(+), 40 deletions(-) diff --git a/src/lib/ActionSelect.svelte b/src/lib/ActionSelect.svelte index d762563..3d0221f 100644 --- a/src/lib/ActionSelect.svelte +++ b/src/lib/ActionSelect.svelte @@ -1,9 +1,11 @@ @@ -58,15 +86,16 @@ {/if} -
+
{#each options as option} - +
{/each}
-{#snippet title(opt: ActionSelectOption)} - {#if typeof opt.title === 'string'} - {opt.title} +{#snippet optionLabel(opt: ActionSelectOption)} + {#if typeof opt.label === 'string'} + {opt.label} {:else} - {@render opt.title(opt)} + {@render opt.label(opt)} {/if} {/snippet} -{#snippet icon(opt: ActionSelectOption)} +{#snippet optionIcon(opt: ActionSelectOption)} {#if opt.icon && typeof opt.icon === 'object'} {:else if opt.icon} {@render opt.icon(opt)} {/if} {/snippet} + + diff --git a/src/lib/Button.svelte b/src/lib/Button.svelte index be35bd6..7f4c0dc 100644 --- a/src/lib/Button.svelte +++ b/src/lib/Button.svelte @@ -8,6 +8,7 @@ animate?: boolean; loading?: boolean; class?: ClassValue | null | undefined; + ref?: HTMLButtonElement | null; children: Snippet; onclick?: MouseEventHandler; } @@ -17,6 +18,7 @@ animate = true, loading, class: classValue, + ref = $bindable(null), children, onclick, ...others @@ -70,6 +72,7 @@