feat(multi-select): dispatch "select" event

This commit is contained in:
Eric Liu 2020-10-29 18:39:41 -07:00
commit 2140eebb33
3 changed files with 25 additions and 11 deletions

View file

@ -153,7 +153,7 @@
* @typedef {{ id: MultiSelectItemId; text: MultiSelectItemText; }} MultiSelectItem
*/
import { afterUpdate, setContext } from "svelte";
import { afterUpdate, createEventDispatcher, setContext } from "svelte";
import WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
import { Checkbox } from "../Checkbox";
import {
@ -165,6 +165,8 @@
ListBoxSelection,
} from "../ListBox";
const dispatch = createEventDispatcher();
let multiSelectRef = null;
let fieldRef = null;
let selectionRef = null;
@ -213,6 +215,11 @@
}
prevChecked = checked;
selectedIds = checked.map(({ id }) => id);
dispatch("select", {
selectedIds,
selected: checked,
unselected: unchecked,
});
}
if (!open) {