@assecosolutions/fox-button-group
Advanced tools
Comparing version 1.0.0-beta.3 to 1.0.0-beta.4
33
index.js
import { css, LitElement, html as html$2 } from 'lit'; | ||
import { property, state, queryAssignedElements } from 'lit/decorators.js'; | ||
import { FoxButton } from '@assecosolutions/fox-button'; | ||
@@ -1707,3 +1706,5 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
firstUpdated() { | ||
this.addEventListener('click', this.handleButtonClick); | ||
this.buttons.forEach((button, index) => { | ||
button.addEventListener('click', () => this.handleButtonClick(button, index)); | ||
}); | ||
} | ||
@@ -1733,19 +1734,13 @@ updated() { | ||
} | ||
handleButtonClick(event) { | ||
const clickedButton = event.target; | ||
if (!(clickedButton instanceof FoxButton)) { | ||
console.warn('Clicked element is not a FoxButton'); | ||
} else { | ||
const index = Array.from(this.buttons).indexOf(clickedButton); | ||
const value = clickedButton.getAttribute('value'); | ||
if (index >= 0) { | ||
this.multiselect ? this.toggleButton(index) : this.selectButton(index); | ||
this.dispatchEvent(new CustomEvent('button-pressed', { | ||
detail: { | ||
index, | ||
value, | ||
clickedButton | ||
} | ||
})); | ||
} | ||
handleButtonClick(button, index) { | ||
const value = button.getAttribute('value'); | ||
if (index >= 0) { | ||
this.multiselect ? this.toggleButton(index) : this.selectButton(index); | ||
this.dispatchEvent(new CustomEvent('button-pressed', { | ||
detail: { | ||
index, | ||
value, | ||
button | ||
} | ||
})); | ||
} | ||
@@ -1752,0 +1747,0 @@ } |
{ | ||
"name": "@assecosolutions/fox-button-group", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0-beta.4", | ||
"public": true, | ||
@@ -20,4 +20,4 @@ "publishConfig": { | ||
"dependencies": { | ||
"@assecosolutions/fox-button": "~1.11.8-beta.3", | ||
"@assecosolutions/fox-common-utils": "~1.11.7-beta.3" | ||
"@assecosolutions/fox-button": "~1.11.8-beta.4", | ||
"@assecosolutions/fox-common-utils": "~1.11.7-beta.4" | ||
}, | ||
@@ -24,0 +24,0 @@ "peerDependencies": { |
@@ -31,3 +31,3 @@ import { LitElement } from 'lit'; | ||
private selectButton; | ||
handleButtonClick(event: Event): void; | ||
handleButtonClick(button: FoxButton, index: number): void; | ||
} |
65060
1523