Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/lib/holocene/combobox/combobox-option.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import MenuItem from '$lib/holocene/menu/menu-item.svelte';

interface BaseProps {
label: string;
label?: string;
class?: ClassNameValue;
onclick?: () => void;
leading?: Snippet;
trailing?: Snippet;
children?: Snippet;
}

interface EnabledProps extends BaseProps {
Expand All @@ -30,11 +31,12 @@
active = false,
selected = false,
disabled = false,
label,
label = '',
class: className = '',
onclick,
leading,
trailing,
children,
}: Props = $props();
</script>

Expand All @@ -50,5 +52,9 @@
{leading}
{trailing}
>
{label}
{#if children}
{@render children()}
{:else}
{label}
{/if}
</MenuItem>
25 changes: 19 additions & 6 deletions src/lib/holocene/combobox/combobox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@
class?: string;
optionClass?: string;
action?: Snippet;
optionLabel?: Snippet<[string | T, string]>;
onchange?: (value: string | T) => void;
onclose?: (selected: string | T) => void;
oninput?: (value: string) => void;
Expand Down Expand Up @@ -166,6 +167,7 @@
open = writable(false),
maxMenuHeight = 'max-h-[20rem]',
action,
optionLabel,
chipLimit = 5,
displayChips = true,
selectAllLabel = 'Select All',
Expand Down Expand Up @@ -659,12 +661,23 @@
{/if}

{#each list as option, i (i)}
<ComboboxOption
onclick={() => handleSelectOption(option)}
selected={isSelected(option, value)}
label={getDisplayValue(option)}
class={optionClass}
/>
{#if optionLabel}
<ComboboxOption
onclick={() => handleSelectOption(option)}
selected={isSelected(option, value)}
label={getDisplayValue(option)}
class={optionClass}
>
{@render optionLabel(option, filterValue)}
</ComboboxOption>
{:else}
<ComboboxOption
onclick={() => handleSelectOption(option)}
selected={isSelected(option, value)}
label={getDisplayValue(option)}
class={optionClass}
/>
{/if}
{:else}
{#if !showAddCustom && loading === false}
<ComboboxOption disabled label={noResultsText} />
Expand Down
Loading