Refactor select component to enhance value binding and event handling
Publish telemt-api gateway Docker image / test (push) Successful in 25s
Publish telemt-api gateway Docker image / build-and-push (push) Successful in 2m19s

- Updated the alias filter select component to bind the selected value directly, simplifying the value change logic.
- Enhanced the select component to support an optional `onValueChange` callback, improving flexibility in handling value changes.
This commit is contained in:
Denozordec
2026-03-31 22:02:12 +07:00
parent 4eb53c91c9
commit e1f16799ba
2 changed files with 14 additions and 9 deletions
@@ -25,13 +25,7 @@
<label class="text-xs text-muted-foreground">
{label}
<Select.Root
type="single"
value={value}
onValueChange={(next) => {
value = (next as string) || "all";
}}
>
<Select.Root type="single" bind:value>
<Select.Trigger class="mt-1 w-[220px]">
{selectedLabel}
</Select.Trigger>
+13 -2
View File
@@ -4,8 +4,19 @@
let {
open = $bindable(false),
value = $bindable(),
onValueChange,
...restProps
}: SelectPrimitive.RootProps = $props();
}: SelectPrimitive.RootProps & {
onValueChange?: (next: string | string[]) => void;
} = $props();
</script>
<SelectPrimitive.Root bind:open bind:value={value as never} {...restProps} />
<SelectPrimitive.Root
bind:open
bind:value={value as never}
onValueChange={(next: unknown) => {
value = next as typeof value;
onValueChange?.(next as string | string[]);
}}
{...restProps}
/>