action select: add onchange callback

This commit is contained in:
Elijah Duffy
2025-07-07 17:34:38 -07:00
parent 645320d335
commit 45ca099570

View File

@@ -24,6 +24,7 @@
tabbable?: boolean; tabbable?: boolean;
options: ActionSelectOption[]; options: ActionSelectOption[];
class?: ClassValue | null | undefined; class?: ClassValue | null | undefined;
onchange?: (value: ActionSelectOption | undefined) => void;
} }
let { let {
@@ -33,14 +34,18 @@
stateless = false, stateless = false,
tabbable = true, tabbable = true,
options, options,
class: classValue class: classValue,
onchange
}: Props = $props(); }: Props = $props();
const select = new Select<ActionSelectOption>({ const select = new Select<ActionSelectOption>({
value: () => value, value: () => value,
onValueChange: (val) => { onValueChange: (val) => {
val?.onchoose?.(val); val?.onchoose?.(val);
if (!stateless) value = val; if (!stateless) {
value = val;
onchange?.(val);
}
} }
}); });
</script> </script>