Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { ComponentParamHandle } from '$lib/client/ecs';
import { Input } from '$lib/components/ui/input';
import { TristateSwitch } from '$lib/components/ui/tristate-switch';
import { Select, SelectContent, SelectItem, SelectTrigger } from '$lib/components/ui/select';

interface Props {
handle: ComponentParamHandle;
Expand All @@ -23,7 +24,32 @@
<div class="text-neutral-200 text-sm">{$param.name}</div>

{#if $param.type === 'string'}
<Input type="text" bind:value onchange={handleChange} />
{#if $param.enum}
<Select type="single" bind:value>
<SelectTrigger class="w-full">{value}</SelectTrigger>
<SelectContent>
{#if Array.isArray($param.enum)}
{#if !!$param.enum.length}
{#each $param.enum as opt (opt)}
<SelectItem value={opt}>{opt}</SelectItem>
{/each}
{:else}
<div class="px-4 py-2 text-muted-foreground italic">No options</div>
{/if}
{:else}
{#if Object.keys($param.enum).length === 0}
{#each Object.entries($param.enum) as [displayOpt, realOpt] (displayOpt)}
<SelectItem value={realOpt}>{displayOpt}</SelectItem>
{/each}
{:else}
<div class="px-4 py-2 text-muted-foreground italic">No options</div>
{/if}
{/if}
</SelectContent>
</Select>
{:else}
<Input type="text" bind:value onchange={handleChange} />
{/if}
{:else if $param.type === 'number'}
<Input type="number" bind:value onchange={handleChange} />
{:else if $param.type === 'boolean'}
Expand Down
4 changes: 1 addition & 3 deletions src/lib/components/ui/select/select-content.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
>
<SelectScrollUpButton />
<SelectPrimitive.Viewport
class={cn(
'h-(--bits-select-anchor-height) w-full min-w-(--bits-select-anchor-width) scroll-my-1',
)}
class={cn('h-auto max-h-80 w-full min-w-(--bits-select-anchor-width)')}
>
{@render children?.()}
</SelectPrimitive.Viewport>
Expand Down
Loading