@aurelia-mdc-web/floating-label
Version:
Wrapper for Material Components Web Floating Label
56 lines • 2.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MdcFloatingLabel = void 0;
var tslib_1 = require("tslib");
var aurelia_framework_1 = require("aurelia-framework");
var floating_label_1 = require("@material/floating-label");
var base_1 = require("@aurelia-mdc-web/base");
var ponyfill_1 = require("@material/dom/ponyfill");
var MdcFloatingLabel = /** @class */ (function (_super) {
tslib_1.__extends(MdcFloatingLabel, _super);
function MdcFloatingLabel() {
return _super !== null && _super.apply(this, arguments) || this;
}
MdcFloatingLabel.prototype.shake = function (shouldShake) {
var _a;
(_a = this.foundation) === null || _a === void 0 ? void 0 : _a.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.
*/
MdcFloatingLabel.prototype.float = function (shouldFloat) {
var _a;
(_a = this.foundation) === null || _a === void 0 ? void 0 : _a.float(shouldFloat);
};
/**
* Styles the label as required.
* @param isRequired If true, adds an asterisk to the label, indicating that it is required.
*/
MdcFloatingLabel.prototype.setRequired = function (isRequired) {
var _a;
(_a = this.foundation) === null || _a === void 0 ? void 0 : _a.setRequired(isRequired);
};
MdcFloatingLabel.prototype.getWidth = function () {
return this.foundation.getWidth();
};
MdcFloatingLabel.prototype.getDefaultFoundation = function () {
var _this = this;
var adapter = {
addClass: function (className) { return _this.root.classList.add(className); },
removeClass: function (className) { return _this.root.classList.remove(className); },
getWidth: function () { return (0, ponyfill_1.estimateScrollWidth)(_this.root); },
registerInteractionHandler: function (evtType, handler) { return _this.listen(evtType, handler); },
deregisterInteractionHandler: function (evtType, handler) { return _this.unlisten(evtType, handler); },
};
return new floating_label_1.MDCFloatingLabelFoundation(adapter);
};
MdcFloatingLabel = tslib_1.__decorate([
(0, aurelia_framework_1.inject)(Element),
(0, aurelia_framework_1.customElement)('mdc-floating-label'),
(0, aurelia_framework_1.useView)(aurelia_framework_1.PLATFORM.moduleName('./mdc-floating-label.html'))
], MdcFloatingLabel);
return MdcFloatingLabel;
}(base_1.MdcComponent));
exports.MdcFloatingLabel = MdcFloatingLabel;
//# sourceMappingURL=mdc-floating-label.js.map