@kelvininc/ui-components
Version:
Kelvin UI Components
188 lines (187 loc) • 7.09 kB
JavaScript
import { Host, h } from "@stencil/core";
import { buildDescription } from "./radio-list-item.helper";
export class KvRadioListItem {
constructor() {
/** @inheritdoc */
this.checked = false;
/** @inheritdoc */
this.disabled = false;
this.parsedDescription = buildDescription(this.description);
this.onOptionClick = (ev) => {
ev.stopPropagation();
this.optionClick.emit(this.optionId);
};
}
descriptionWatcher(newValue, old) {
if (newValue === old)
return;
this.parsedDescription = buildDescription(newValue);
}
render() {
return (h(Host, { key: '7ce9aa25a427477080dcf3b6f33a74a3ec4ddbe9' }, h("div", { key: 'abe44a5c569fa607eacfcbb51b80dcd9f462e051', class: {
'radio-list-item-container': true,
'radio-list-item-container--disabled': this.disabled,
'radio-list-item-container--checked': this.checked
}, onClick: this.onOptionClick }, h("slot", { key: '04d4aedbc299fab34295623edbd1af20b0ee4e19', name: "header" }), h("div", { key: '4b2c0cacc8ed406a74438cf5cfde039a52cc190a', class: "content" }, h("kv-radio", { key: 'f0ba306654dba6e357f715f201d159639ce3e649', checked: this.checked, disabled: this.disabled }), h("div", { key: '12b2bed2c789184eb8124a0438ed47ce6546267a', class: "info" }, h("slot", { key: 'f8462beeb86f61d6c7e023aade064dc945fc40d7', name: "label" }, h("div", { key: '4c8f95adc66ace1480732c99cdceb0f2730b7414', class: "label" }, this.label)), this.description && h("div", { key: '919a182a51fd4d8d43829157533f7be40e222193', class: "description" }, this.parsedDescription), h("slot", { key: 'bbfa4b0873e65a85f20b5813f234c99e3533e0c8', name: "additional-info" }))))));
}
static get is() { return "kv-radio-list-item"; }
static get encapsulation() { return "shadow"; }
static get originalStyleUrls() {
return {
"$": ["radio-list-item.scss"]
};
}
static get styleUrls() {
return {
"$": ["radio-list-item.css"]
};
}
static get properties() {
return {
"optionId": {
"type": "any",
"attribute": "option-id",
"mutable": false,
"complexType": {
"original": "string | number",
"resolved": "number | string",
"references": {}
},
"required": true,
"optional": false,
"docs": {
"tags": [{
"name": "inheritdoc",
"text": undefined
}],
"text": "(required) The unique id that serves as a key for this item"
},
"getter": false,
"setter": false,
"reflect": true
},
"label": {
"type": "string",
"attribute": "label",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": true,
"optional": false,
"docs": {
"tags": [{
"name": "inheritdoc",
"text": undefined
}],
"text": "(required) The label to display"
},
"getter": false,
"setter": false,
"reflect": true
},
"description": {
"type": "string",
"attribute": "description",
"mutable": false,
"complexType": {
"original": "string",
"resolved": "string",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [{
"name": "inheritdoc",
"text": undefined
}],
"text": "(optional) The description that can contain links in the [text](url) format"
},
"getter": false,
"setter": false,
"reflect": true
},
"checked": {
"type": "boolean",
"attribute": "checked",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [{
"name": "inheritdoc",
"text": undefined
}],
"text": "(optional) Defines if this option is checked"
},
"getter": false,
"setter": false,
"reflect": true,
"defaultValue": "false"
},
"disabled": {
"type": "boolean",
"attribute": "disabled",
"mutable": false,
"complexType": {
"original": "boolean",
"resolved": "boolean",
"references": {}
},
"required": false,
"optional": true,
"docs": {
"tags": [{
"name": "inheritdoc",
"text": undefined
}],
"text": "(optional) Defines if this option is disabled"
},
"getter": false,
"setter": false,
"reflect": true,
"defaultValue": "false"
}
};
}
static get states() {
return {
"parsedDescription": {}
};
}
static get events() {
return [{
"method": "optionClick",
"name": "optionClick",
"bubbles": true,
"cancelable": true,
"composed": true,
"docs": {
"tags": [{
"name": "inheritdoc",
"text": undefined
}],
"text": "Emits when this option is clicked"
},
"complexType": {
"original": "string | number",
"resolved": "number | string",
"references": {}
}
}];
}
static get watchers() {
return [{
"propName": "description",
"methodName": "descriptionWatcher"
}];
}
}