import ComponentBaseStyles from "../styles/ComponentBaseStyles.wrn" component ButtonGroup { outputs { click(payload: { sourceEvent?: Event; [key: string]: string | number | boolean | null | object }) select(payload: { value: string | number | boolean | null | object; previousValue: string | number | boolean | null | object; item: string | number | boolean | null | object; index: number }) change(payload: { value: string | number | boolean | null | object; previousValue: string | number | boolean | null | object; item: string | number | boolean | null | object; index: number }) } props { items: unknown[] = [] value: string = "" size: string = "md" color: string = "primary" variant: string = "default" orientation: string = "horizontal" responsive: boolean = false attached: boolean = true selectable: boolean = false toolbar: boolean = false disabled: boolean = false ariaLabel: string = "Button group" class: string = "" } state selectedValue = value functions { shared function itemValue(item, index) { return item.value || item.label || String(index) } client function selectItem(item, index) { previousValue = selectedValue nextValue = itemValue(item, index) output.select({ value: nextValue, previousValue: previousValue, item: item, index: index }) if (selectable && previousValue !== nextValue) { selectedValue = nextValue output.change({ value: nextValue, previousValue: previousValue, item: item, index: index }) } } } view {
{#if items} {#each items as item, index} {/each} {/if}