mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
chore: add more prop annotations
This commit is contained in:
parent
8c1ffd4cb0
commit
773b18d314
75 changed files with 877 additions and 137 deletions
|
@ -1,5 +1,14 @@
|
|||
<script>
|
||||
/**
|
||||
* Set the selected index of the switch item
|
||||
* @type {number} [selectedIndex=0]
|
||||
*/
|
||||
export let selectedIndex = 0;
|
||||
|
||||
/**
|
||||
* Set to `true` to enable the light variant
|
||||
* @type {boolean} [light=false]
|
||||
*/
|
||||
export let light = false;
|
||||
|
||||
import { afterUpdate, createEventDispatcher, setContext } from "svelte";
|
||||
|
@ -24,10 +33,10 @@
|
|||
|
||||
switches = [...switches, { id, text, selected }];
|
||||
},
|
||||
update: id => {
|
||||
update: (id) => {
|
||||
selectedIndex = switches.map(({ id }) => id).indexOf(id);
|
||||
},
|
||||
change: direction => {
|
||||
change: (direction) => {
|
||||
let index = currentIndex + direction;
|
||||
|
||||
if (index < 0) {
|
||||
|
@ -37,7 +46,7 @@
|
|||
}
|
||||
|
||||
selectedIndex = index;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
afterUpdate(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue