mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
Use custom logic
This commit is contained in:
parent
ede294d553
commit
1aa22d2522
2 changed files with 12 additions and 2 deletions
|
@ -656,4 +656,4 @@
|
|||
"path": "carbon-components-svelte/src/UnorderedList/UnorderedList.svelte"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -57,6 +57,16 @@
|
|||
const dispatch = createEventDispatcher();
|
||||
|
||||
$: dispatch("check", checked);
|
||||
$: checked = group.indexOf(value) >= 0;
|
||||
|
||||
const updateGroup = () => {
|
||||
if (checked) {
|
||||
group = [...group, value];
|
||||
} else {
|
||||
group.splice(group.indexOf(value), 1);
|
||||
group = group;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||
|
@ -80,7 +90,6 @@
|
|||
>
|
||||
<input
|
||||
bind:this="{ref}"
|
||||
bind:group
|
||||
type="checkbox"
|
||||
value="{value}"
|
||||
checked="{checked}"
|
||||
|
@ -94,6 +103,7 @@
|
|||
on:change="{() => {
|
||||
checked = !checked;
|
||||
}}"
|
||||
on:change="{updateGroup}"
|
||||
on:blur
|
||||
/>
|
||||
<label for="{id}" title="{title}" class:bx--checkbox-label="{true}">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue