This commit is contained in:
Timothy Jaeryang Baek committed 2026-12-02 23:16:31 +04:00
1 parent 69d1a88902
commit 187d2ed3e8
80 files changed
+1125 -1966

No files matched your search

@@ -16,6 +16,12 @@
export let placeholder = '';
export let className = 'w-full';
export let selectedIds: string[] | null = null;
// Opt-in for a full list: no cap, a wider popup, and descriptions beside names.
export let limit: number | null = 8;
export let minWidth = 0;
export let showDescription = false;
export let popupClassName =
'max-w-[min(12rem,calc(100vw-1rem))] max-h-48 rounded-2xl border border-base-200 bg-base-0 p-0.5 shadow-lg dark:border-base-800 dark:bg-base-850';
const i18n: any = getContext('i18n');
@@ -40,7 +46,8 @@
query === '' || id.includes(query) || name.includes(query) || description.includes(query)
);
});
$: optionVoices = selectedIds === null ? matchedVoices.slice(0, 8) : matchedVoices;
$: optionVoices =
selectedIds === null && limit !== null ? matchedVoices.slice(0, limit) : matchedVoices;
$: optionOffset = selectedIds !== null && matchedVoices.length > 0 ? 1 : 0;
$: if (suggestionsOpen && optionVoices.length > 0) {
tick().then(positionPopup);
@@ -59,7 +66,7 @@
if (!inputElement || !popupElement) return;
const rect = inputElement.getBoundingClientRect();
popupElement.style.width = `${rect.width}px`;
popupElement.style.width = `${Math.max(rect.width, minWidth)}px`;
const width = popupElement.offsetWidth;
popupElement.style.top = `${rect.bottom + 4}px`;
@@ -174,7 +181,7 @@
use:portal
bind:this={popupElement}
id={listboxId}
class="fixed max-w-[min(12rem,calc(100vw-1rem))] max-h-48 overflow-y-auto rounded-2xl border border-base-200 bg-base-0 p-0.5 shadow-lg dark:border-base-800 dark:bg-base-850"
class="fixed overflow-y-auto {popupClassName}"
role="listbox"
style="z-index: 9999; top: 0; left: 0;"
>
@@ -220,9 +227,23 @@
selectVoice(voice);
}}
>
<span class="truncate">{voice.id}</span>
{#if voice.name && voice.name !== voice.id}
<span class="truncate text-base-500 dark:text-base-400">{voice.name}</span>
{#if showDescription}
<span
class="flex min-w-0 flex-1 items-baseline gap-1.5"
title={voice.description || undefined}
>
<span class="max-w-full shrink-0 truncate">{voice.name ?? voice.id}</span>
{#if voice.description}
<span class="min-w-0 truncate text-base-500 dark:text-base-400"
>{voice.description}</span
>
{/if}
</span>
{:else}
<span class="truncate">{voice.id}</span>
{#if voice.name && voice.name !== voice.id}
<span class="truncate text-base-500 dark:text-base-400">{voice.name}</span>
{/if}
{/if}
{#if selectedIds !== null && selectedIds.includes(voice.id)}
<svg