action select: add onchange callback
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user