UNPKG

primeng-extensions

Version:

[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![npm](https://img.shields.io/npm/dt/primeng-extensions.svg)]() [![Dependency Status][daviddm-image]][daviddm-url] ![Crates.io](https://img.shields.io/github/license/mashape

159 lines 8.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var common_1 = require("@angular/common"); var forms_1 = require("@angular/forms"); var button_1 = require("primeng/button"); var i0 = require("@angular/core"); var i1 = require("@angular/common"); var i2 = require("primeng/button"); var _c0 = function (a2, a3) { return { styleClass: true, "ui-minusplus ui-widget ui-widget-content ui-corner-all": true, "ui-minusplus-vertical": a2, "ui-state-disabled": a3 }; }; var _c1 = ["*"]; exports.MINUSPLUSINPUT_VALUE_ACCESSOR = { provide: forms_1.NG_VALUE_ACCESSOR, useExisting: core_1.forwardRef(function () { return MinusPlusInputComponent; }), multi: true }; var MinusPlusInputComponent = /** @class */ (function () { function MinusPlusInputComponent(cd) { this.cd = cd; this.min = 0; this.max = 10; this.step = 1; this.vertical = false; this.disabled = false; this.decrementLabel = '-'; this.incrementLabel = '+'; this.styleClass = null; this.onInputChange = new core_1.EventEmitter(); this.value = 0; this.inputValue = 0; this.onModelChange = function () { }; this.onModelTouched = function () { }; } MinusPlusInputComponent.prototype.writeValue = function (value) { this.inputValue = value; this.cd.detectChanges(); }; MinusPlusInputComponent.prototype.isIncrement = function () { return (this.inputValue + this.step) <= this.max; }; MinusPlusInputComponent.prototype.isDecrement = function () { return (this.inputValue - this.step) >= this.min; }; MinusPlusInputComponent.prototype.getButtonClass = function (status) { var buttonClass = ''; if (status) { if (!this.isDecrement()) buttonClass += ' ui-state-disabled'; } else { if (!this.isIncrement()) buttonClass += ' ui-state-disabled'; } return buttonClass; }; MinusPlusInputComponent.prototype.increment = function () { if (this.isIncrement()) { this.inputValue = this.inputValue + this.step; this.onModelChange(this.inputValue); this.onModelTouched(); this.onInputChange.emit(this.inputValue); } }; MinusPlusInputComponent.prototype.decrement = function () { if (this.isDecrement()) { this.inputValue = this.inputValue - this.step; this.onModelChange(this.inputValue); this.onModelTouched(); this.onInputChange.emit(this.inputValue); } }; MinusPlusInputComponent.prototype.ngOnDestroy = function () { }; MinusPlusInputComponent.prototype.ngOnInit = function () { this.inputValue = this.value; if (this.step < 1) { this.step = 1; } }; MinusPlusInputComponent.prototype.registerOnChange = function (fn) { this.onModelChange = fn; }; MinusPlusInputComponent.prototype.registerOnTouched = function (fn) { this.onModelTouched = fn; }; MinusPlusInputComponent.ɵfac = function MinusPlusInputComponent_Factory(t) { return new (t || MinusPlusInputComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); }; MinusPlusInputComponent.ɵcmp = i0.ɵɵdefineComponent({ type: MinusPlusInputComponent, selectors: [["pe-minusplusinput"]], inputs: { min: "min", max: "max", step: "step", vertical: "vertical", disabled: "disabled", decrementLabel: "decrementLabel", incrementLabel: "incrementLabel", styleClass: "styleClass" }, outputs: { onInputChange: "onInputChange" }, features: [i0.ɵɵProvidersFeature([exports.MINUSPLUSINPUT_VALUE_ACCESSOR])], ngContentSelectors: _c1, decls: 6, vars: 9, consts: [[3, "ngClass"], ["pButton", "", 3, "ngClass", "label", "click"], [1, "ui-minusplus-value"]], template: function MinusPlusInputComponent_Template(rf, ctx) { if (rf & 1) { i0.ɵɵprojectionDef(); i0.ɵɵelementStart(0, "div", 0); i0.ɵɵelementStart(1, "button", 1); i0.ɵɵlistener("click", function MinusPlusInputComponent_Template_button_click_1_listener() { return ctx.decrement(); }); i0.ɵɵelementEnd(); i0.ɵɵelementStart(2, "div", 2); i0.ɵɵprojection(3); i0.ɵɵtext(4); i0.ɵɵelementEnd(); i0.ɵɵelementStart(5, "button", 1); i0.ɵɵlistener("click", function MinusPlusInputComponent_Template_button_click_5_listener() { return ctx.increment(); }); i0.ɵɵelementEnd(); i0.ɵɵelementEnd(); } if (rf & 2) { i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction2(6, _c0, ctx.vertical, ctx.disabled)); i0.ɵɵadvance(1); i0.ɵɵproperty("ngClass", ctx.getButtonClass(true))("label", ctx.decrementLabel); i0.ɵɵadvance(3); i0.ɵɵtextInterpolate1(" ", ctx.inputValue, " "); i0.ɵɵadvance(1); i0.ɵɵproperty("ngClass", ctx.getButtonClass(false))("label", ctx.incrementLabel); } }, directives: [i1.NgClass, i2.ButtonDirective], encapsulation: 2 }); return MinusPlusInputComponent; }()); exports.MinusPlusInputComponent = MinusPlusInputComponent; /*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MinusPlusInputComponent, [{ type: core_1.Component, args: [{ selector: 'pe-minusplusinput', template: "\n <div\n [ngClass]=\"{styleClass: true,'ui-minusplus ui-widget ui-widget-content ui-corner-all': true,'ui-minusplus-vertical': vertical, 'ui-state-disabled': disabled}\">\n <button pButton [ngClass]=\"getButtonClass(true)\" (click)=\"decrement()\" [label]=\"decrementLabel\">\n </button>\n <div class=\"ui-minusplus-value\">\n <ng-content></ng-content>\n {{ inputValue }}\n </div>\n <button pButton [ngClass]=\"getButtonClass(false)\" (click)=\"increment()\" [label]=\"incrementLabel\">\n </button>\n </div>", encapsulation: core_1.ViewEncapsulation.None, providers: [exports.MINUSPLUSINPUT_VALUE_ACCESSOR] }] }], function () { return [{ type: i0.ChangeDetectorRef }]; }, { min: [{ type: core_1.Input }], max: [{ type: core_1.Input }], step: [{ type: core_1.Input }], vertical: [{ type: core_1.Input }], disabled: [{ type: core_1.Input }], decrementLabel: [{ type: core_1.Input }], incrementLabel: [{ type: core_1.Input }], styleClass: [{ type: core_1.Input }], onInputChange: [{ type: core_1.Output }] }); })(); var MinusPlusInputModule = /** @class */ (function () { function MinusPlusInputModule() { } MinusPlusInputModule.ɵmod = i0.ɵɵdefineNgModule({ type: MinusPlusInputModule }); MinusPlusInputModule.ɵinj = i0.ɵɵdefineInjector({ factory: function MinusPlusInputModule_Factory(t) { return new (t || MinusPlusInputModule)(); }, imports: [[common_1.CommonModule, button_1.ButtonModule]] }); return MinusPlusInputModule; }()); exports.MinusPlusInputModule = MinusPlusInputModule; (function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(MinusPlusInputModule, { declarations: [MinusPlusInputComponent], imports: [common_1.CommonModule, button_1.ButtonModule], exports: [MinusPlusInputComponent] }); })(); /*@__PURE__*/ (function () { i0.ɵsetClassMetadata(MinusPlusInputModule, [{ type: core_1.NgModule, args: [{ imports: [common_1.CommonModule, button_1.ButtonModule], exports: [MinusPlusInputComponent], declarations: [MinusPlusInputComponent] }] }], null, null); })(); //# sourceMappingURL=minusplusinput.js.map