Static Site
This commit is contained in:
134
Static/package/dist/collection/components/switch/switch.js
vendored
Normal file
134
Static/package/dist/collection/components/switch/switch.js
vendored
Normal file
@ -0,0 +1,134 @@
|
||||
import { h } from "@stencil/core";
|
||||
export class Switch {
|
||||
constructor() {
|
||||
this.value = false;
|
||||
this.name = '';
|
||||
this.disabled = false;
|
||||
this.internalValue = false;
|
||||
}
|
||||
componentWillLoad() {
|
||||
this.internalValue = this.value;
|
||||
}
|
||||
valueChanged(newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
this.internalValue = newValue;
|
||||
}
|
||||
}
|
||||
toggle() {
|
||||
if (this.disabled)
|
||||
return;
|
||||
this.internalValue = !this.internalValue;
|
||||
this.ifxChange.emit(this.internalValue);
|
||||
}
|
||||
handleKeyDown(event) {
|
||||
if (this.disabled)
|
||||
return;
|
||||
// If the pressed key is either 'Enter' or 'Space'
|
||||
if (event.key === 'Enter' || event.key === ' ') {
|
||||
this.toggle();
|
||||
}
|
||||
}
|
||||
render() {
|
||||
return (h("div", { class: `container ${this.internalValue ? 'checked' : ''} ${this.disabled ? 'disabled' : ''}`, role: "switch", tabindex: "0", "aria-checked": this.internalValue ? 'true' : 'false', "aria-label": this.name, onClick: () => this.toggle(), onKeyDown: (event) => this.handleKeyDown(event) }, h("div", { class: "switch_checkbox-wrapper" }, h("input", { type: "checkbox", hidden: true, name: this.name, disabled: this.disabled, value: `${this.internalValue}` }), h("div", { class: `switch ${this.internalValue ? 'checked' : ''} ${this.disabled ? 'disabled' : ''}` })), h("div", { class: `switch_label-wrapper ${this.disabled ? 'disabled' : ''}` }, h("label", { htmlFor: "switch" }, h("slot", null)))));
|
||||
}
|
||||
static get is() { return "ifx-switch"; }
|
||||
static get encapsulation() { return "shadow"; }
|
||||
static get originalStyleUrls() {
|
||||
return {
|
||||
"$": ["switch.scss"]
|
||||
};
|
||||
}
|
||||
static get styleUrls() {
|
||||
return {
|
||||
"$": ["switch.css"]
|
||||
};
|
||||
}
|
||||
static get properties() {
|
||||
return {
|
||||
"value": {
|
||||
"type": "boolean",
|
||||
"mutable": false,
|
||||
"complexType": {
|
||||
"original": "boolean",
|
||||
"resolved": "boolean",
|
||||
"references": {}
|
||||
},
|
||||
"required": false,
|
||||
"optional": false,
|
||||
"docs": {
|
||||
"tags": [],
|
||||
"text": ""
|
||||
},
|
||||
"attribute": "value",
|
||||
"reflect": false,
|
||||
"defaultValue": "false"
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
"mutable": false,
|
||||
"complexType": {
|
||||
"original": "string",
|
||||
"resolved": "string",
|
||||
"references": {}
|
||||
},
|
||||
"required": false,
|
||||
"optional": false,
|
||||
"docs": {
|
||||
"tags": [],
|
||||
"text": ""
|
||||
},
|
||||
"attribute": "name",
|
||||
"reflect": false,
|
||||
"defaultValue": "''"
|
||||
},
|
||||
"disabled": {
|
||||
"type": "boolean",
|
||||
"mutable": false,
|
||||
"complexType": {
|
||||
"original": "boolean",
|
||||
"resolved": "boolean",
|
||||
"references": {}
|
||||
},
|
||||
"required": false,
|
||||
"optional": false,
|
||||
"docs": {
|
||||
"tags": [],
|
||||
"text": ""
|
||||
},
|
||||
"attribute": "disabled",
|
||||
"reflect": false,
|
||||
"defaultValue": "false"
|
||||
}
|
||||
};
|
||||
}
|
||||
static get states() {
|
||||
return {
|
||||
"internalValue": {}
|
||||
};
|
||||
}
|
||||
static get events() {
|
||||
return [{
|
||||
"method": "ifxChange",
|
||||
"name": "ifxChange",
|
||||
"bubbles": true,
|
||||
"cancelable": true,
|
||||
"composed": true,
|
||||
"docs": {
|
||||
"tags": [],
|
||||
"text": ""
|
||||
},
|
||||
"complexType": {
|
||||
"original": "boolean",
|
||||
"resolved": "boolean",
|
||||
"references": {}
|
||||
}
|
||||
}];
|
||||
}
|
||||
static get watchers() {
|
||||
return [{
|
||||
"propName": "value",
|
||||
"methodName": "valueChanged"
|
||||
}];
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=switch.js.map
|
Reference in New Issue
Block a user