UNPKG

@aurelia-mdc-web/list

Version:

Wrapper for Material Components Web List

92 lines 4.36 kB
define(["require", "exports", "tslib", "aurelia-framework", "aurelia-pal", "aurelia-typed-observable-plugin"], function (require, exports, tslib_1, aurelia_framework_1, aurelia_pal_1, aurelia_typed_observable_plugin_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MdcDeprecatedListItem = void 0; 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; }; tslib_1.__decorate([ aurelia_typed_observable_plugin_1.bindable.booleanAttr, tslib_1.__metadata("design:type", Boolean) ], MdcDeprecatedListItem.prototype, "disabled", void 0); tslib_1.__decorate([ aurelia_typed_observable_plugin_1.bindable.booleanAttr, tslib_1.__metadata("design:type", Boolean) ], MdcDeprecatedListItem.prototype, "activated", void 0); tslib_1.__decorate([ aurelia_typed_observable_plugin_1.bindable.none, tslib_1.__metadata("design:type", Object) ], MdcDeprecatedListItem.prototype, "value", void 0); tslib_1.__decorate([ aurelia_typed_observable_plugin_1.bindable.booleanAttr, tslib_1.__metadata("design:type", Boolean) ], MdcDeprecatedListItem.prototype, "disableRipple", void 0); tslib_1.__decorate([ aurelia_typed_observable_plugin_1.bindable.none, tslib_1.__metadata("design:type", String) ], MdcDeprecatedListItem.prototype, "href", void 0); MdcDeprecatedListItem = tslib_1.__decorate([ (0, aurelia_framework_1.inject)(Element), (0, aurelia_framework_1.useView)(aurelia_pal_1.PLATFORM.moduleName('./mdc-deprecated-list-item.html')), (0, aurelia_framework_1.customElement)('mdc-deprecated-list-item'), (0, aurelia_framework_1.processContent)(MdcDeprecatedListItem.processContent), tslib_1.__metadata("design:paramtypes", [HTMLElement]) ], MdcDeprecatedListItem); return MdcDeprecatedListItem; }()); exports.MdcDeprecatedListItem = MdcDeprecatedListItem; }); //# sourceMappingURL=mdc-deprecated-list-item.js.map