{#each items as item} {@const isSelect = selected === item.id} { if (!isSelect) select(item.id) else if (allowDeselected) select(false) }} /> {/each}