UNPKG

@aurelia-mdc-web/floating-label

Version:

Wrapper for Material Components Web Floating Label

44 lines 1.78 kB
import { __decorate } from "tslib"; import { inject, customElement, useView, PLATFORM } from 'aurelia-framework'; import { MDCFloatingLabelFoundation } from '@material/floating-label'; import { MdcComponent } from '@aurelia-mdc-web/base'; import { estimateScrollWidth } from '@material/dom/ponyfill'; let MdcFloatingLabel = class MdcFloatingLabel extends MdcComponent { shake(shouldShake) { this.foundation?.shake(shouldShake); } /** * Styles the label to float/dock. * @param shouldFloat If true, floats the label by adding a CSS class; otherwise, docks it by removing the class. */ float(shouldFloat) { this.foundation?.float(shouldFloat); } /** * Styles the label as required. * @param isRequired If true, adds an asterisk to the label, indicating that it is required. */ setRequired(isRequired) { this.foundation?.setRequired(isRequired); } getWidth() { return this.foundation.getWidth(); } getDefaultFoundation() { const adapter = { addClass: (className) => this.root.classList.add(className), removeClass: (className) => this.root.classList.remove(className), getWidth: () => estimateScrollWidth(this.root), registerInteractionHandler: (evtType, handler) => this.listen(evtType, handler), deregisterInteractionHandler: (evtType, handler) => this.unlisten(evtType, handler), }; return new MDCFloatingLabelFoundation(adapter); } }; MdcFloatingLabel = __decorate([ inject(Element), customElement('mdc-floating-label'), useView(PLATFORM.moduleName('./mdc-floating-label.html')) ], MdcFloatingLabel); export { MdcFloatingLabel }; //# sourceMappingURL=mdc-floating-label.js.map