@3mo/checkbox-group
Advanced tools
Comparing version
@@ -6,2 +6,4 @@ import { Checkbox } from '@3mo/checkbox'; | ||
* | ||
* @ssr true | ||
* | ||
* @attr direction | ||
@@ -14,6 +16,7 @@ */ | ||
private set childrenSelected(value); | ||
protected changed: () => CheckboxSelection; | ||
protected handleChanged(): void; | ||
static get styles(): import("@a11d/lit").CSSResult; | ||
protected get template(): import("lit-html").HTMLTemplateResult; | ||
private readonly handleSlotChange; | ||
private updateValue; | ||
} | ||
@@ -20,0 +23,0 @@ declare global { |
@@ -7,2 +7,4 @@ import { __decorate } from "tslib"; | ||
* | ||
* @ssr true | ||
* | ||
* @attr direction | ||
@@ -14,14 +16,13 @@ */ | ||
this.direction = 'vertical'; | ||
this.changed = () => this.childrenSelected = this.selected; | ||
this.handleSlotChange = () => { | ||
const updateValue = () => { | ||
const selected = this.childrenSelected; | ||
if (selected !== this.selected) { | ||
this.selected = selected; | ||
this.change.dispatch(selected); | ||
} | ||
}; | ||
updateValue(); | ||
this.checkboxes.forEach(checkbox => checkbox.change.subscribe(updateValue)); | ||
this.updateValue(); | ||
this.checkboxes.forEach(checkbox => checkbox.change.subscribe(this.updateValue)); | ||
}; | ||
this.updateValue = () => { | ||
const childrenSelected = this.childrenSelected; | ||
if (childrenSelected !== this.selected) { | ||
this.selected = childrenSelected; | ||
this.change.dispatch(childrenSelected); | ||
} | ||
}; | ||
} | ||
@@ -53,2 +54,7 @@ get checkboxes() { | ||
} | ||
handleChanged() { | ||
// Whenever "selected" changes, wether by user interaction or by the children changing | ||
// we need to update the childrenSelected state. | ||
this.childrenSelected = this.selected; | ||
} | ||
static get styles() { | ||
@@ -83,3 +89,3 @@ return css ` | ||
eventListener('change') | ||
], CheckboxGroup.prototype, "changed", void 0); | ||
], CheckboxGroup.prototype, "handleChanged", null); | ||
CheckboxGroup = __decorate([ | ||
@@ -86,0 +92,0 @@ component('mo-checkbox-group') |
{ | ||
"name": "@3mo/checkbox-group", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "A checkbox-group web-component based on Material Web Components.", | ||
@@ -5,0 +5,0 @@ "repository": { |
# CheckboxGroup | ||
A checkbox-group web-component based on Material Web Components. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
79544
1.84%115
8.49%