UNPKG

@aurelia-mdc-web/form-field

Version:

Wrapper for Material Components Web Form Field

61 lines 2.95 kB
import { __awaiter, __decorate, __metadata } from "tslib"; import { inject, useView, customElement, PLATFORM } from 'aurelia-framework'; import { cssClasses, MDCFormFieldFoundation } from '@material/form-field'; import { bindable } from 'aurelia-typed-observable-plugin'; import { MdcComponent } from '@aurelia-mdc-web/base'; /** * @selector mdc-form-field */ let MdcFormField = class MdcFormField extends MdcComponent { constructor() { super(...arguments); this.cssClasses = cssClasses; } // eslint-disable-next-line @typescript-eslint/require-await initialise() { return __awaiter(this, void 0, void 0, function* () { let rippleUpgraded = this.root.querySelector('mdc-checkbox'); if (!rippleUpgraded) { rippleUpgraded = this.root.querySelector('mdc-radio'); } this.ripple = rippleUpgraded === null || rippleUpgraded === void 0 ? void 0 : rippleUpgraded.au['mdc-ripple'].viewModel; const input = this.root.querySelector('input, button'); if (input === null || input === void 0 ? void 0 : input.hasAttribute('id')) { this.label = this.root.querySelector('label'); if (this.label) { this.label.setAttribute('for', input.getAttribute('id')); } } }); } getDefaultFoundation() { // DO NOT INLINE this variable. For backward compatibility, foundations take a Partial<MDCFooAdapter>. // To ensure we don't accidentally omit any methods, we need a separate, strongly typed adapter variable. const adapter = { activateInputRipple: () => { var _a; return (_a = this.ripple) === null || _a === void 0 ? void 0 : _a.activate(); }, deactivateInputRipple: () => { var _a; return (_a = this.ripple) === null || _a === void 0 ? void 0 : _a.deactivate(); }, deregisterInteractionHandler: (evtType, handler) => { var _a; return (_a = this.label) === null || _a === void 0 ? void 0 : _a.removeEventListener(evtType, handler); }, registerInteractionHandler: (evtType, handler) => { var _a; return (_a = this.label) === null || _a === void 0 ? void 0 : _a.addEventListener(evtType, handler); }, }; return new MDCFormFieldFoundation(adapter); } }; __decorate([ bindable.booleanAttr, __metadata("design:type", Boolean) ], MdcFormField.prototype, "nowrap", void 0); __decorate([ bindable.booleanAttr, __metadata("design:type", Boolean) ], MdcFormField.prototype, "alignEnd", void 0); __decorate([ bindable.booleanAttr, __metadata("design:type", Boolean) ], MdcFormField.prototype, "spaceBetween", void 0); MdcFormField = __decorate([ inject(Element), useView(PLATFORM.moduleName('./mdc-form-field.html')), customElement(cssClasses.ROOT) ], MdcFormField); export { MdcFormField }; //# sourceMappingURL=mdc-form-field.js.map