UNPKG

@aurelia-mdc-web/list

Version:

Wrapper for Material Components Web List

91 lines 3.5 kB
import { __decorate, __metadata } from "tslib"; import { inject, useView, customElement, processContent } from 'aurelia-framework'; import { PLATFORM } from 'aurelia-pal'; import { bindable } from 'aurelia-typed-observable-plugin'; var listItemId = 0; var ENTER = 13; var SPACE = 32; var LIST_ITEM_ACTION = 'mdclistitem:action'; /** * @selector mdc-deprecated-list-item */ var MdcDeprecatedListItem = /** @class */ (function () { function MdcDeprecatedListItem(root) { this.root = root; this.id = ++listItemId; } MdcDeprecatedListItem.processContent = function (_viewCompiler, _resources, element) { var graphic = element.querySelector('mdc-checkbox:not([mdc-deprecated-list-item-meta]),[mdc-deprecated-list-item-graphic]'); if (graphic) { element.removeChild(graphic); } var meta = element.querySelector('[mdc-deprecated-list-item-meta]'); if (meta) { element.removeChild(meta); } var itemText = document.createElement('span'); itemText.classList.add('mdc-deprecated-list-item__text'); var children = [].slice.call(element.childNodes); for (var i = 0; i < children.length; ++i) { itemText.appendChild(children[i]); } if (graphic) { element.appendChild(graphic); } element.appendChild(itemText); if (meta) { element.appendChild(meta); } return true; }; MdcDeprecatedListItem.prototype.hrefChanged = function () { if (this.href) { this.root.setAttribute('href', this.href); } else { this.root.removeAttribute('href'); } }; MdcDeprecatedListItem.prototype.onKeydown = function (evt) { if ((evt.keyCode === ENTER || evt.keyCode === SPACE) && !this.disabled) { this.root.dispatchEvent(new CustomEvent(LIST_ITEM_ACTION, { detail: { item: this, data: this.value }, bubbles: true })); } return true; }; MdcDeprecatedListItem.prototype.onClick = function () { if (!this.disabled) { this.root.dispatchEvent(new CustomEvent(LIST_ITEM_ACTION, { detail: { item: this, data: this.value }, bubbles: true })); } return true; }; __decorate([ bindable.booleanAttr, __metadata("design:type", Boolean) ], MdcDeprecatedListItem.prototype, "disabled", void 0); __decorate([ bindable.booleanAttr, __metadata("design:type", Boolean) ], MdcDeprecatedListItem.prototype, "activated", void 0); __decorate([ bindable.none, __metadata("design:type", Object) ], MdcDeprecatedListItem.prototype, "value", void 0); __decorate([ bindable.booleanAttr, __metadata("design:type", Boolean) ], MdcDeprecatedListItem.prototype, "disableRipple", void 0); __decorate([ bindable.none, __metadata("design:type", String) ], MdcDeprecatedListItem.prototype, "href", void 0); MdcDeprecatedListItem = __decorate([ inject(Element), useView(PLATFORM.moduleName('./mdc-deprecated-list-item.html')), customElement('mdc-deprecated-list-item'), processContent(MdcDeprecatedListItem.processContent), __metadata("design:paramtypes", [HTMLElement]) ], MdcDeprecatedListItem); return MdcDeprecatedListItem; }()); export { MdcDeprecatedListItem }; //# sourceMappingURL=mdc-deprecated-list-item.js.map