mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
feat(multi-select): dispatch "select" event
This commit is contained in:
parent
a016bf897c
commit
2140eebb33
3 changed files with 25 additions and 11 deletions
|
@ -2756,7 +2756,7 @@ No slots.
|
||||||
|
|
||||||
### Dispatched events
|
### Dispatched events
|
||||||
|
|
||||||
No dispatched events.
|
- `on:select`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -8054,8 +8054,8 @@
|
||||||
[
|
[
|
||||||
"clear",
|
"clear",
|
||||||
{
|
{
|
||||||
"start": 8393,
|
"start": 8577,
|
||||||
"end": 8401,
|
"end": 8585,
|
||||||
"type": "EventHandler",
|
"type": "EventHandler",
|
||||||
"name": "clear",
|
"name": "clear",
|
||||||
"modifiers": [],
|
"modifiers": [],
|
||||||
|
@ -8065,8 +8065,8 @@
|
||||||
[
|
[
|
||||||
"keydown",
|
"keydown",
|
||||||
{
|
{
|
||||||
"start": 9289,
|
"start": 9473,
|
||||||
"end": 9299,
|
"end": 9483,
|
||||||
"type": "EventHandler",
|
"type": "EventHandler",
|
||||||
"name": "keydown",
|
"name": "keydown",
|
||||||
"modifiers": [],
|
"modifiers": [],
|
||||||
|
@ -8076,8 +8076,8 @@
|
||||||
[
|
[
|
||||||
"focus",
|
"focus",
|
||||||
{
|
{
|
||||||
"start": 9791,
|
"start": 9975,
|
||||||
"end": 9799,
|
"end": 9983,
|
||||||
"type": "EventHandler",
|
"type": "EventHandler",
|
||||||
"name": "focus",
|
"name": "focus",
|
||||||
"modifiers": [],
|
"modifiers": [],
|
||||||
|
@ -8087,8 +8087,8 @@
|
||||||
[
|
[
|
||||||
"blur",
|
"blur",
|
||||||
{
|
{
|
||||||
"start": 9810,
|
"start": 9994,
|
||||||
"end": 9817,
|
"end": 10001,
|
||||||
"type": "EventHandler",
|
"type": "EventHandler",
|
||||||
"name": "blur",
|
"name": "blur",
|
||||||
"modifiers": [],
|
"modifiers": [],
|
||||||
|
@ -8096,7 +8096,14 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"dispatched_events": []
|
"dispatched_events": [
|
||||||
|
[
|
||||||
|
"select",
|
||||||
|
{
|
||||||
|
"detail": "{\n selectedIds,\n selected: checked,\n unselected: unchecked,\n }"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"NotificationActionButton": {
|
"NotificationActionButton": {
|
||||||
"moduleName": "NotificationActionButton",
|
"moduleName": "NotificationActionButton",
|
||||||
|
|
|
@ -153,7 +153,7 @@
|
||||||
* @typedef {{ id: MultiSelectItemId; text: MultiSelectItemText; }} MultiSelectItem
|
* @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 WarningFilled16 from "carbon-icons-svelte/lib/WarningFilled16";
|
||||||
import { Checkbox } from "../Checkbox";
|
import { Checkbox } from "../Checkbox";
|
||||||
import {
|
import {
|
||||||
|
@ -165,6 +165,8 @@
|
||||||
ListBoxSelection,
|
ListBoxSelection,
|
||||||
} from "../ListBox";
|
} from "../ListBox";
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
|
||||||
let multiSelectRef = null;
|
let multiSelectRef = null;
|
||||||
let fieldRef = null;
|
let fieldRef = null;
|
||||||
let selectionRef = null;
|
let selectionRef = null;
|
||||||
|
@ -213,6 +215,11 @@
|
||||||
}
|
}
|
||||||
prevChecked = checked;
|
prevChecked = checked;
|
||||||
selectedIds = checked.map(({ id }) => id);
|
selectedIds = checked.map(({ id }) => id);
|
||||||
|
dispatch("select", {
|
||||||
|
selectedIds,
|
||||||
|
selected: checked,
|
||||||
|
unselected: unchecked,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!open) {
|
if (!open) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue