-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support markdown and model format
- Loading branch information
Showing
2 changed files
with
73 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
import * as Select from '$lib/components/ui/select' | ||
import { createEventDispatcher } from 'svelte' | ||
type Selected<Value> = { | ||
value: Value | ||
label?: string | ||
} | ||
export let name: string | ||
export let value: any | ||
export let items: Selected<any>[] | ||
export let placeholder: string | ||
$: label = items.find((it) => it.value === value)?.label ?? value | ||
const dispatch = createEventDispatcher<{ | ||
change(value: any): void | ||
}>() | ||
</script> | ||
|
||
<Select.Root | ||
{name} | ||
selected={{ | ||
value, | ||
label, | ||
}} | ||
onSelectedChange={(ev) => dispatch('change', ev?.value)} | ||
> | ||
<Select.Trigger class="w-full"> | ||
{label ?? placeholder} | ||
</Select.Trigger> | ||
<Select.Content class="overflow-y-auto max-h-[20rem]"> | ||
{#each items as it} | ||
<Select.Item value={it.value}>{it.label ?? it.value}</Select.Item> | ||
{/each} | ||
</Select.Content> | ||
</Select.Root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters