@neocomplexx/ngx-neo-directives
Version:
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 7.0.5.
2,323 lines • 87.3 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/forms'), require('@ng-bootstrap/ng-bootstrap')) :
typeof define === 'function' && define.amd ? define('@neocomplexx/ngx-neo-directives', ['exports', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/forms', '@ng-bootstrap/ng-bootstrap'], factory) :
(global = global || self, factory((global.neocomplexx = global.neocomplexx || {}, global.neocomplexx['ngx-neo-directives'] = {}), global.ng.core, global.rxjs, global.rxjs.operators, global.ng.forms, global.ngBootstrap));
}(this, (function (exports, core, rxjs, operators, forms, ngBootstrap) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __createBinding(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}
function __exportStar(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/onReturn.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var OnReturnDirective = /** @class */ (function () {
function OnReturnDirective(_el) {
this._el = _el;
this.setEnabled = true;
this.el = this._el;
}
/**
* @param {?} e
* @return {?}
*/
OnReturnDirective.prototype.onKeyDown = /**
* @param {?} e
* @return {?}
*/
function (e) {
if ((e.which === 13 || e.keyCode === 13)) {
e.preventDefault();
OnReturnDirective.setNextFocus(this.onReturn, this.setEnabled);
return;
}
};
// tslint:disable-next-line:member-ordering
// tslint:disable-next-line:member-ordering
/**
* @param {?} onReturn
* @param {?=} setEnabled
* @return {?}
*/
OnReturnDirective.setNextFocus =
// tslint:disable-next-line:member-ordering
/**
* @param {?} onReturn
* @param {?=} setEnabled
* @return {?}
*/
function (onReturn, setEnabled) {
if (setEnabled === void 0) { setEnabled = true; }
if (onReturn instanceof Array) {
/** @type {?} */
var termine = false;
/** @type {?} */
var i = 0;
while (!termine && i < onReturn.length) {
/** @type {?} */
var element = onReturn[i];
if (element) {
if (element instanceof HTMLInputElement ||
element instanceof HTMLButtonElement ||
element instanceof HTMLSelectElement ||
element instanceof HTMLSelectElement) {
if (!element.disabled) {
element.focus();
termine = true;
}
}
else {
if (element && element.nativeElement instanceof HTMLInputElement ||
element.nativeElement instanceof HTMLButtonElement ||
element.nativeElement instanceof HTMLSelectElement) {
if (!element.nativeElement.disabled) {
element.nativeElement.focus();
termine = true;
}
}
else {
/** @type {?} */
var input = element['ctrInput'];
if (input) {
input = input['nativeElement'];
if (input && input instanceof HTMLInputElement) {
if (!input.disabled) {
input.focus();
termine = true;
}
}
}
else {
element = document.getElementById(element);
if (element) {
if (element.disabled && setEnabled) {
element.disabled = false;
}
if (!element.disabled) {
element.focus();
termine = true;
}
}
}
}
}
}
i++;
}
}
else if (onReturn) {
/** @type {?} */
var element = onReturn;
if (element instanceof HTMLInputElement || element instanceof HTMLButtonElement || element instanceof HTMLSelectElement) {
if (element.disabled) {
element.disabled = false;
}
element.focus();
}
else {
/** @type {?} */
var input = element['ctrInput'];
if (input) {
input = input['nativeElement'];
if (input && input instanceof HTMLInputElement) {
if (input.disabled) {
input.disabled = false;
}
input.focus();
}
}
else {
element = document.getElementById(onReturn);
if (element) {
if (element.disabled && setEnabled) {
element.disabled = false;
}
element.focus();
}
}
}
}
};
OnReturnDirective.decorators = [
{ type: core.Directive, args: [{
// tslint:disable-next-line:directive-selector
selector: '[onReturn]'
},] }
];
/** @nocollapse */
OnReturnDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
OnReturnDirective.propDecorators = {
onReturn: [{ type: core.Input }],
setEnabled: [{ type: core.Input }],
onKeyDown: [{ type: core.HostListener, args: ['keydown', ['$event'],] }]
};
return OnReturnDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
OnReturnDirective.prototype.el;
/** @type {?} */
OnReturnDirective.prototype.onReturn;
/** @type {?} */
OnReturnDirective.prototype.setEnabled;
/**
* @type {?}
* @private
*/
OnReturnDirective.prototype._el;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/ngx-command/command.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var COMMAND_CONFIG = new core.InjectionToken('COMMAND_CONFIG');
/** @type {?} */
var COMMAND_DEFAULT_CONFIG = {
executingCssClass: 'executing',
};
/*
export function provideConfig(config: CommandOptions): any {
return Object.assign({}, COMMAND_DEFAULT_CONFIG, config);
} */
/**
*
* ### Example with options
* ```html
* <button [command]='saveCmd' [commandOptions]='{executingCssClass: 'in-progress'}'>Save</button>
* ```
*/
var CommandDirective = /** @class */ (function () {
function CommandDirective(renderer, element) {
this.renderer = renderer;
this.element = element;
this.stopPropagation = false;
// @HostBinding('disabled') isDisabled: boolean;
this.setEnabled = true;
this.config = COMMAND_DEFAULT_CONFIG;
this.ownDisabledState = false;
this.commandDisabledChanged = false;
}
/**
* @return {?}
*/
CommandDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
// console.log('[commandDirective::init]');
this.commandOptions = Object.assign({}, this.config, this.commandOptions);
if (!this.command) {
throw new Error('[commandDirective] command should be defined!');
}
else {
this.command.verifyCommandExecutionPipe();
this.command.setNextFocus(this.commandNextFocus);
this.command.setEnabledValue(this.setEnabled);
}
// if (this.element.nativeElement.localName === 'button') {
// let thisAux = this; // Set up a new observer
// var observer = new MutationObserver(function(mutations) {
// mutations.forEach(function(mutation) {
// // Check the modified attributeName is "disabled"
// if(!thisAux.commandDisabledChanged) {
// if (mutation.attributeName === "disabled") {
// thisAux.ownDisabledState = thisAux.element.nativeElement.disabled;
// }
// } else {
// thisAux.commandDisabledChanged = false;
// }
// });
// });
// // Configure to only listen to attribute changes
// var config = { attributes: true };
// // Start observing myElem
// observer.observe(this.element.nativeElement, config);
// }
this.canExecute$$ = this.command.canExecute$.pipe(operators.tap((/**
* @param {?} x
* @return {?}
*/
function (x) {
if (_this.element.nativeElement.localName === 'button') {
_this.commandDisabledChanged = true;
if (_this.commandValue == _this.command.executingParam) {
_this.element.nativeElement.disabled = !x;
// } else {
// this.element.nativeElement.disabled = !(!this.ownDisabledState && x);
}
}
}))).subscribe();
this.isExecuting$$ = this.command.isExecuting$.pipe(operators.tap((/**
* @param {?} x
* @return {?}
*/
function (x) {
// console.log('[commandDirective::isExecuting$]', x);
x ? _this.renderer.addClass(_this.element.nativeElement, _this.commandOptions.executingCssClass) : _this.renderer.removeClass(_this.element.nativeElement, _this.commandOptions.executingCssClass);
}))).subscribe();
if (this.isMobileOperatingSystem()) {
this.element.nativeElement.addEventListener('touchstart', (/**
* @param {?} event
* @return {?}
*/
function (event) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
event.preventDefault();
event.stopPropagation();
if (this.element.nativeElement.localName === 'input') {
return [2 /*return*/];
}
this.executeCommand();
return [2 /*return*/];
});
}); }));
this.element.nativeElement.addEventListener('focusin', (/**
* @param {?} event
* @return {?}
*/
function (event) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
event.preventDefault();
event.stopPropagation();
this.executeCommand();
return [2 /*return*/];
});
}); }));
}
else {
this.element.nativeElement.addEventListener('keydown', (/**
* @param {?} event
* @return {?}
*/
function (event) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
if ((event.which === 13 || event.keyCode === 13)) {
event.preventDefault();
event.stopPropagation();
this.executeCommand();
}
return [2 /*return*/];
});
}); }));
this.element.nativeElement.addEventListener('click', (/**
* @param {?} event
* @return {?}
*/
function (event) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
if (this.element.nativeElement.localName === 'input') {
return [2 /*return*/];
}
event.preventDefault();
if (this.stopPropagation) {
event.stopPropagation();
}
this.executeCommand();
return [2 /*return*/];
});
}); }));
}
};
/**
* @return {?}
*/
CommandDirective.prototype.executeCommand = /**
* @return {?}
*/
function () {
if (!this.element.nativeElement.disabled)
this.command.canExecute = true;
this.command.verifyCommandExecutionPipe();
this.command.execute(this.commandValue);
};
/**
* @return {?}
*/
CommandDirective.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this.command) {
this.command.destroy();
}
if (this.canExecute$$) {
this.canExecute$$.unsubscribe();
}
if (this.isExecuting$$) {
this.isExecuting$$.unsubscribe();
}
};
/**
* @private
* @return {?}
*/
CommandDirective.prototype.isMobileOperatingSystem = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var isMobile = false;
/** @type {?} */
var userAgent = navigator.userAgent || navigator.vendor;
// Windows Phone must come first because its UA also contains "Android"
if (/windows phone/i.test(userAgent)) {
isMobile = true; // "Windows Phone";
}
else if (/android/i.test(userAgent)) {
isMobile = true; // "Android";
}
else if (/iPad|iPhone|iPod/.test(userAgent)) {
// iOS detection from: http://stackoverflow.com/a/9039885/177710
isMobile = true; // "iOS";
}
isMobile = false;
return isMobile; // "unknown";
};
CommandDirective.decorators = [
{ type: core.Directive, args: [{
// tslint:disable-next-line:directive-selector
selector: '[command]'
},] }
];
/** @nocollapse */
CommandDirective.ctorParameters = function () { return [
{ type: core.Renderer2 },
{ type: core.ElementRef }
]; };
CommandDirective.propDecorators = {
command: [{ type: core.Input }],
commandOptions: [{ type: core.Input }],
commandCanExecute: [{ type: core.Input }],
commandValue: [{ type: core.Input }],
stopPropagation: [{ type: core.Input }],
commandNextFocus: [{ type: core.Input }],
setEnabled: [{ type: core.Input }]
};
return CommandDirective;
}());
if (false) {
/** @type {?} */
CommandDirective.prototype.command;
/** @type {?} */
CommandDirective.prototype.commandOptions;
/** @type {?} */
CommandDirective.prototype.commandCanExecute;
/** @type {?} */
CommandDirective.prototype.commandValue;
/** @type {?} */
CommandDirective.prototype.stopPropagation;
/** @type {?} */
CommandDirective.prototype.commandNextFocus;
/** @type {?} */
CommandDirective.prototype.setEnabled;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.canExecute$$;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.isExecuting$$;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.config;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.ownDisabledState;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.commandDisabledChanged;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.renderer;
/**
* @type {?}
* @private
*/
CommandDirective.prototype.element;
}
/**
* @record
*/
function CommandOptions() { }
if (false) {
/**
* Css Class which gets added/removed on the Command element's host while Command isExecuting$.
*
* @type {?}
*/
CommandOptions.prototype.executingCssClass;
}
/**
* @record
*/
function ICommand() { }
if (false) {
/** @type {?} */
ICommand.prototype.executingParam;
/**
* Determines whether the command is currently executing.
* @type {?}
*/
ICommand.prototype.isExecuting;
/** @type {?|undefined} */
ICommand.prototype.isExecuting$;
/**
* Determines whether the command can execute or not.
* @type {?}
*/
ICommand.prototype.canExecute;
/** @type {?|undefined} */
ICommand.prototype.canExecute$;
/**
* Execute function to invoke.
* @param {?=} value
* @return {?}
*/
ICommand.prototype.execute = function (value) { };
/**
* Execute function to invoke and return a result in Promise.
* @param {?=} value
* @return {?}
*/
ICommand.prototype.executeWithResult = function (value) { };
/**
* Disposes all resources held by subscriptions.
* @return {?}
*/
ICommand.prototype.destroy = function () { };
/**
* @return {?}
*/
ICommand.prototype.verifyCommandExecutionPipe = function () { };
/**
* @param {?} element
* @return {?}
*/
ICommand.prototype.setNextFocus = function (element) { };
/**
* @param {?} enable
* @return {?}
*/
ICommand.prototype.setEnabledValue = function (enable) { };
}
/**
* Command object used to encapsulate information which is needed to perform an action.
*/
var /**
* Command object used to encapsulate information which is needed to perform an action.
*/
Command = /** @class */ (function () {
/**
* Creates an instance of Command.
*/
function Command(executeParam, canExecute$, isAsync, delay) {
var _this = this;
this.executeParam = executeParam;
this.isAsync = isAsync;
this.delay = delay;
this.isExecuting = false;
this.isExecuting$ = new rxjs.BehaviorSubject(false);
this.canExecute = true;
this.executionPipe$ = new rxjs.Subject();
this.setEnabled = true;
if (canExecute$) {
this.canExecute$ = rxjs.combineLatest(this.isExecuting$, canExecute$, (/**
* @param {?} isExecuting
* @param {?} canExecuteResult
* @return {?}
*/
function (isExecuting, canExecuteResult) {
// console.log('[command::combineLatest$] update!', { isExecuting, canExecuteResult });
_this.isExecuting = isExecuting;
_this.canExecute = !isExecuting && canExecuteResult;
return _this.canExecute;
}));
this.canExecute$$ = this.canExecute$.subscribe();
}
else {
this.canExecute$ = this.isExecuting$.pipe(operators.map((/**
* @param {?} x
* @return {?}
*/
function (x) {
/** @type {?} */
var canExecute = !x;
_this.canExecute = canExecute;
return canExecute;
})));
this.isExecuting$$ = this.isExecuting$.pipe(operators.tap((/**
* @param {?} x
* @return {?}
*/
function (x) { return _this.isExecuting = x; })))
.subscribe();
}
this.buildExecutionPipe(executeParam, isAsync, delay);
}
/**
* @return {?}
*/
Command.prototype.verifyCommandExecutionPipe = /**
* @return {?}
*/
function () {
if (this.executionPipe$.observers.length === 0) {
this.buildExecutionPipe(this.executeParam, this.isAsync, this.delay);
}
};
/**
* @param {?=} value
* @return {?}
*/
Command.prototype.execute = /**
* @param {?=} value
* @return {?}
*/
function (value) {
this.executingParam = value;
this.executionPipe$.next(value);
};
/**
* @param {?=} value
* @return {?}
*/
Command.prototype.executeWithResult = /**
* @param {?=} value
* @return {?}
*/
function (value) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
this.executingParam = value;
this.executionPipe$.next(value);
return [4 /*yield*/, this.result];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
};
/**
* @return {?}
*/
Command.prototype.destroy = /**
* @return {?}
*/
function () {
if (this.executionPipe$$) {
this.executionPipe$$.unsubscribe();
}
if (this.canExecute$$) {
this.canExecute$$.unsubscribe();
}
if (this.isExecuting$$) {
this.isExecuting$$.unsubscribe();
}
if (this.isExecuting$) {
this.isExecuting$.complete();
}
if (this.asyncAction != null) {
this.asyncAction = null;
this.resultAsyncAction = null;
}
};
/**
* @private
* @param {?} executeParm
* @param {?=} isAsync
* @param {?=} delay
* @return {?}
*/
Command.prototype.buildExecutionPipe = /**
* @private
* @param {?} executeParm
* @param {?=} isAsync
* @param {?=} delay
* @return {?}
*/
function (executeParm, isAsync, delay) {
var _this = this;
/** @type {?} */
var pipe$ = this.executionPipe$.pipe(operators.filter((/**
* @return {?}
*/
function () { return _this.canExecute; })), operators.tap((/**
* @return {?}
*/
function () {
_this.isExecuting$.next(true);
if (isAsync && _this.asyncAction != null) {
_this.resultAsyncAction = _this.asyncAction(undefined);
}
})));
pipe$ = isAsync
? pipe$.pipe(operators.switchMap((/**
* @param {?} value
* @return {?}
*/
function (value) {
if (delay && delay > 0) {
if (_this.delaySubscribe) {
_this.delaySubscribe.unsubscribe();
}
/** @type {?} */
var delayTimer = rxjs.timer(delay);
_this.delaySubscribe = delayTimer.subscribe((/**
* @param {?} t
* @return {?}
*/
function (t) { executeParm(value); }));
return Promise.resolve(null);
}
else {
/** @type {?} */
var result = executeParm(value);
return Promise.resolve(result);
}
})))
: pipe$.pipe(operators.tap((/**
* @param {?} value
* @return {?}
*/
function (value) { executeParm(value); })));
pipe$ = pipe$.pipe(operators.tap((/**
* @return {?}
*/
function () {
// console.log('[command::excutionPipe$] do#2 - set idle');
_this.isExecuting$.next(false);
_this.executingParam = undefined;
if (isAsync && _this.asyncAction != null) {
_this.resultAsyncAction = _this.asyncAction(_this.resultAsyncAction);
}
OnReturnDirective.setNextFocus(_this.elementNextFocus, _this.setEnabled);
}), (/**
* @param {?} e
* @return {?}
*/
function (e) {
console.log('[command::excutionPipe$] do#2 error - set idle' + e.toString());
_this.isExecuting$.next(false);
_this.executingParam = undefined;
if (isAsync && _this.asyncAction != null) {
_this.resultAsyncAction = _this.asyncAction(_this.resultAsyncAction);
}
_this.buildExecutionPipe(executeParm, isAsync, delay);
})));
this.executionPipe$$ = pipe$.subscribe();
};
/**
* @param {?} element
* @return {?}
*/
Command.prototype.setNextFocus = /**
* @param {?} element
* @return {?}
*/
function (element) {
this.elementNextFocus = element;
};
/**
* @param {?} enabled
* @return {?}
*/
Command.prototype.setEnabledValue = /**
* @param {?} enabled
* @return {?}
*/
function (enabled) {
this.setEnabled = enabled;
};
return Command;
}());
if (false) {
/** @type {?} */
Command.prototype.isExecuting;
/** @type {?} */
Command.prototype.isExecuting$;
/** @type {?} */
Command.prototype.canExecute;
/** @type {?} */
Command.prototype.canExecute$;
/**
* @type {?}
* @private
*/
Command.prototype.executionPipe$;
/**
* @type {?}
* @private
*/
Command.prototype.isExecuting$$;
/**
* @type {?}
* @private
*/
Command.prototype.canExecute$$;
/**
* @type {?}
* @private
*/
Command.prototype.executionPipe$$;
/**
* @type {?}
* @private
*/
Command.prototype.elementNextFocus;
/** @type {?} */
Command.prototype.result;
/** @type {?} */
Command.prototype.asyncAction;
/** @type {?} */
Command.prototype.resultAsyncAction;
/** @type {?} */
Command.prototype.executingParam;
/**
* @type {?}
* @private
*/
Command.prototype.delaySubscribe;
/**
* @type {?}
* @private
*/
Command.prototype.setEnabled;
/**
* @type {?}
* @private
*/
Command.prototype.executeParam;
/**
* @type {?}
* @private
*/
Command.prototype.isAsync;
/**
* @type {?}
* @private
*/
Command.prototype.delay;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/strings.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var StringsDirective = /** @class */ (function () {
function StringsDirective(_el) {
this._el = _el;
this.el = this._el;
}
/**
* @param {?} e
* @return {?}
*/
StringsDirective.prototype.onKeyDown = /**
* @param {?} e
* @return {?}
*/
function (e) {
if (e.key === 'Delete' || e.key === 'Tab' || e.key === 'Backspace' || e.key === 'ArrowLeft' ||
e.altKey || e.ctrlKey || e.key === 'Home' || e.key === 'End' || e.key === 'PageDown' || e.key === 'PageUp' ||
e.key === 'ArrowRight' || e.key === 'Control' || e.key === 'Alt' || e.key === 'Shift') {
return;
}
/** @type {?} */
var element = this._el.nativeElement.value;
if (element && element.length >= this.maxLength) {
e.preventDefault();
}
};
StringsDirective.decorators = [
{ type: core.Directive, args: [{
// tslint:disable-next-line:directive-selector
selector: '[maxLength]'
},] }
];
/** @nocollapse */
StringsDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
StringsDirective.propDecorators = {
maxLength: [{ type: core.Input }],
onKeyDown: [{ type: core.HostListener, args: ['keydown', ['$event'],] }]
};
return StringsDirective;
}());
if (false) {
/**
* @type {?}
* @private
*/
StringsDirective.prototype.el;
/** @type {?} */
StringsDirective.prototype.maxLength;
/**
* @type {?}
* @private
*/
StringsDirective.prototype._el;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/neo-numbers.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NeoNumbersDirective = /** @class */ (function () {
function NeoNumbersDirective(el, renderer, model) {
this.el = el;
this.renderer = renderer;
this.model = model;
this.allowNullValue = false;
}
/**
* @return {?}
*/
NeoNumbersDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if ((/** @type {?} */ (this.allowNullValue)) === "")
this.allowNullValue = true;
this.regex = new RegExp('^\\d+$');
this.el.nativeElement.type = "number";
};
/**
* @param {?} e
* @return {?}
*/
NeoNumbersDirective.prototype.blockPaste = /**
* @param {?} e
* @return {?}
*/
function (e) {
var _this = this;
/** @type {?} */
var clipboardData = e.clipboardData || window['clipboardData'];
/** @type {?} */
var pastedData = clipboardData.getData('text/plain').split(",").join(".");
/** @type {?} */
var posPoint = pastedData.lastIndexOf('.');
if (posPoint > -1) {
pastedData = pastedData.substring(0, posPoint).split(".").join("");
}
/** @type {?} */
var onlyNumbers = Array.from(pastedData).map((/**
* @param {?} x
* @return {?}
*/
function (x) { return _this.isOnlyNumber(x); })).reduce((/**
* @param {?} prev
* @param {?} el
* @return {?}
*/
function (prev, el) { return prev && el; }), true);
/** @type {?} */
var isCorrect = this.regex.test(pastedData);
if (isCorrect && this.el.nativeElement.max && pastedData.length > this.el.nativeElement.max.length)
pastedData = pastedData.substr(0, this.el.nativeElement.max.length);
setTimeout((/**
* @return {?}
*/
function () {
if (onlyNumbers && isCorrect) {
_this.el.nativeElement.value = pastedData;
}
else {
_this.el.nativeElement.value = '0';
}
}), 10);
};
/**
* @return {?}
*/
NeoNumbersDirective.prototype.onfocus = /**
* @return {?}
*/
function () {
if (this.el.nativeElement.value == "0") {
this.el.nativeElement.value = null;
}
};
/**
* @return {?}
*/
NeoNumbersDirective.prototype.onBlur = /**
* @return {?}
*/
function () {
/** @type {?} */
var current = this.el.nativeElement.value;
if (current == "") {
if (this.allowNullValue) {
this.el.nativeElement.value = null;
this.model.control.setValue(null);
}
else {
this.el.nativeElement.value = "0";
this.model.control.setValue(0);
}
}
else {
this.el.nativeElement.type = "text";
this.el.nativeElement.type = "number";
if (this.el.nativeElement.max && this.el.nativeElement.valueAsNumber > +this.el.nativeElement.max) {
this.el.nativeElement.value = this.el.nativeElement.max;
this.model.control.setValue(this.el.nativeElement.valueAsNumber);
}
}
};
/**
* @param {?} event
* @return {?}
*/
NeoNumbersDirective.prototype.onKeyUp = /**
* @param {?} event
* @return {?}
*/
function (event) {
console.log(event);
/** @type {?} */
var current = this.el.nativeElement.value;
current = current.split("-").join("");
/** @type {?} */
var posPoint = current.indexOf('.');
if (posPoint > -1) {
current = current.substring(0, posPoint);
this.el.nativeElement.value = current;
}
if (this.isSpecial(event) || current == "") {
if (event.keyCode == 8 || current != "") {
this.prev = current;
}
return;
}
if (!this.isOnlyNumber(event)) {
event.preventDefault();
event.stopPropagation();
return false;
}
if (this.el.nativeElement.max && this.el.nativeElement.valueAsNumber > +this.el.nativeElement.max) {
this.el.nativeElement.value = current.substring(0, current.length - 1);
}
};
/**
* @param {?} event
* @return {?}
*/
NeoNumbersDirective.prototype.onKeyDown = /**
* @param {?} event
* @return {?}
*/
function (event) {
if (this.isSpecial(event)) {
return;
}
if (!this.isOnlyNumber(event)) {
event.preventDefault();
event.stopPropagation();
return false;
}
/** @type {?} */
var current = this.el.nativeElement.value;
this.prev = current;
};
/**
* @private
* @param {?} e
* @return {?}
*/
NeoNumbersDirective.prototype.isSpecial = /**
* @private
* @param {?} e
* @return {?}
*/
function (e) {
return e.key === 'Delete' || (e.key === 'Tab' || e.keyCode == 9) || (e.key === 'Backspace' || e.keyCode == 8) || e.key === 'ArrowLeft' ||
e.altKey || e.ctrlKey || e.key === 'Home' || e.key === 'End' || e.key === 'PageDown' || e.key === 'PageUp' ||
e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'ArrowRight' || e.key === 'Control' || e.key === 'Alt' || e.key === 'Shift' ||
(((/** @type {?} */ (e))).keyIdentifier == 'Down' || ((/** @type {?} */ (e))).keyIdentifier == 'Up' || ((/** @type {?} */ (e))).keyIdentifier == 'Left' || ((/** @type {?} */ (e))).keyIdentifier == 'Right');
};
/**
* @private
* @param {?} e
* @return {?}
*/
NeoNumbersDirective.prototype.isOnlyNumber = /**
* @private
* @param {?} e
* @return {?}
*/
function (e) {
if (e instanceof KeyboardEvent) {
return ((e.key >= '0' && e.key <= '9') || (e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105));
}
else {
return (e >= '0' && e <= '9');
}
};
NeoNumbersDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[isNumber]'
},] }
];
/** @nocollapse */
NeoNumbersDirective.ctorParameters = function () { return [
{ type: core.ElementRef },
{ type: core.Renderer2 },
{ type: forms.NgModel }
]; };
NeoNumbersDirective.propDecorators = {
isNumber: [{ type: core.Input }],
allowNullValue: [{ type: core.Input, args: ['allowNullValue',] }],
blockPaste: [{ type: core.HostListener, args: ['paste', ['$event'],] }],
onfocus: [{ type: core.HostListener, args: ['focus',] }],
onBlur: [{ type: core.HostListener, args: ['blur',] }],
onKeyUp: [{ type: core.HostListener, args: ['keyup', ['$event'],] }],
onKeyDown: [{ type: core.HostListener, args: ['keydown', ['$event'],] }]
};
return NeoNumbersDirective;
}());
if (false) {
/** @type {?} */
NeoNumbersDirective.prototype.isNumber;
/** @type {?} */
NeoNumbersDirective.prototype.allowNullValue;
/**
* @type {?}
* @private
*/
NeoNumbersDirective.prototype.prev;
/**
* @type {?}
* @private
*/
NeoNumbersDirective.prototype.regex;
/**
* @type {?}
* @private
*/
NeoNumbersDirective.prototype.el;
/**
* @type {?}
* @private
*/
NeoNumbersDirective.prototype.renderer;
/**
* @type {?}
* @private
*/
NeoNumbersDirective.prototype.model;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/ngb-tabset.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @author jcangelosi
*/
var NgbTabSetDirective = /** @class */ (function () {
function NgbTabSetDirective(_el) {
this._el = _el;
this.el = this._el;
this.onTabChanging = false;
}
/**
* @return {?}
*/
NgbTabSetDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
if (this.tabSelectedId) {
this.tabSelectedIdSubscribe = this.tabSelectedId.subscribe((/**
* @param {?} tabSelectedId
* @return {?}
*/
function (tabSelectedId) {
if (tabSelectedId.length > 0) {
/** @type {?} */
var tabs = (/** @type {?} */ (_this.el));
// const previousValue = this.tabSelectedId.value;
if (tabs.activeId !== tabSelectedId) {
tabs.select(tabSelectedId);
}
}
}));
}
};
/**
* @return {?}
*/
NgbTabSetDirective.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
if (this.tabSelectedIdSubscribe) {
this.tabSelectedIdSubscribe.unsubscribe();
}
};
/**
* @param {?} $event
* @return {?}
*/
NgbTabSetDirective.prototype.onTabChange = /**
* @param {?} $event
* @return {?}
*/
function ($event) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (this.onTabChanging) {
return [2 /*return*/];
}
this.onTabChanging = true;
if (!this.tabChangeController) return [3 /*break*/, 2];
$event.preventDefault();
return [4 /*yield*/, this.tabChangeController.canChangeTab()];
case 1:
if (_a.sent()) {
this.cambiarTab($event, true);
}
return [3 /*break*/, 3];
case 2:
this.cambiarTab($event);
_a.label = 3;
case 3:
this.onTabChanging = false;
return [2 /*return*/];
}
});
});
};
/**
* @private
* @param {?} $event
* @param {?=} force
* @return {?}
*/
NgbTabSetDirective.prototype.cambiarTab = /**
* @private
* @param {?} $event
* @param {?=} force
* @return {?}
*/
function ($event, force) {
if (force === void 0) { force = false; }
/** @type {?} */
var tabSelecting = $event.nextId;
if (force || this.tabSelectedId.value !== tabSelecting) {
this.tabSelectedId.next(tabSelecting);
}
};
NgbTabSetDirective.decorators = [
{ type: core.Directive, args: [{
// tslint:disable-next-line:directive-selector
selector: '[tabSelectedId], [tabChangeController]',
},] }
];
/** @nocollapse */
NgbTabSetDirective.ctorParameters = function () { return [
{ type: ngBootstrap.NgbTabset }
]; };
NgbTabSetDirective.propDecorators = {
tabSelectedId: [{ type: core.Input }],
tabChangeController: [{ type: core.Input }],
onTabChange: [{ type: core.HostListener, args: ['tabChange', ['$event'],] }]
};
return NgbTabSetDirective;
}());
if (false) {
/**
* @type {?}
* @protected
*/
NgbTabSetDirective.prototype.el;
/**
* @type {?}
* @protected
*/
NgbTabSetDirective.prototype.tabSelectedIdSubscribe;
/** @type {?} */
NgbTabSetDirective.prototype.tabSelectedId;
/** @type {?} */
NgbTabSetDirective.prototype.tabChangeController;
/**
* @type {?}
* @protected
*/
NgbTabSetDirective.prototype.onTabChanging;
/**
* @type {?}
* @protected
*/
NgbTabSetDirective.prototype._el;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/neo-autofocus.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NeoAutofocusDirective = /** @class */ (function () {
function NeoAutofocusDirective(el) {
this.el = el;
}
/**
* @return {?}
*/
NeoAutofocusDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
};
/**
* @return {?}
*/
NeoAutofocusDirective.prototype.ngAfterViewInit = /**
* @return {?}
*/
function () {
var _this = this;
this.subscription = rxjs.timer(100).subscribe((/**
* @return {?}
*/
function () {
if (_this.neoAutofocus) {
_this.setFocus();
}
_this.subscription.unsubscribe();
}));
};
/**
* @private
* @return {?}
*/
NeoAutofocusDirective.prototype.setFocus = /**
* @private
* @return {?}
*/
function () {
if (this.el) {
if (this.el instanceof HTMLInputElement ||
this.el instanceof HTMLButtonElement ||
this.el instanceof HTMLSelectElement ||
this.el instanceof HTMLSelectElement) {
if (!this.el.disabled) {
this.el.focus();
}
}
else {
if (this.el && this.el.nativeElement instanceof HTMLInputElement ||
this.el.nativeElement instanceof HTMLButtonElement ||
this.el.nativeElement instanceof HTMLSelectElement) {
if (!this.el.nativeElement.disabled) {
this.el.nativeElement.focus();
}
}
else {
/** @type {?} */
var input = this.el['ctrInput'];
if (input) {
input = input['nativeElement'];
if (input && input instanceof HTMLInputElement) {
if (!input.disabled) {
input.focus();
}
}
}
}
}
}
};
NeoAutofocusDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[neoAutofocus]'
},] }
];
/** @nocollapse */
NeoAutofocusDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NeoAutofocusDirective.propDecorators = {
neoAutofocus: [{ type: core.Input, args: ['neoAutofocus',] }]
};
return NeoAutofocusDirective;
}());
if (false) {
/** @type {?} */
NeoAutofocusDirective.prototype.neoAutofocus;
/**
* @type {?}
* @private
*/
NeoAutofocusDirective.prototype.subscription;
/**
* @type {?}
* @private
*/
NeoAutofocusDirective.prototype.el;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/neo-changecommand.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NeoChangeCommandDirective = /** @class */ (function () {
function NeoChangeCommandDirective(element) {
this.element = element;
}
/**
* @param {?} event
* @return {?}
*/
NeoChangeCommandDirective.prototype.onInputChange = /**
* @param {?} event
* @return {?}
*/
function (event) {
/** @type {?} */
var value = this.element.nativeElement.value;
if (!this._lastValue || this._lastValue !== value) {
this._lastValue = value;
this.changeCommand.execute(value);
}
};
NeoChangeCommandDirective.decorators = [
{ type: core.Directive, args: [{
// tslint:disable-next-line:directive-selector
selector: '[changeCommand]'
},] }
];
/** @nocollapse */
NeoChangeCommandDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NeoChangeCommandDirective.propDecorators = {
changeCommand: [{ type: core.Input }],
onInputChange: [{ type: core.HostListener, args: ['keyup', ['$event'],] }]
};
return NeoChangeCommandDirective;
}());
if (false) {
/** @type {?} */
NeoChangeCommandDirective.prototype.changeCommand;
/**
* @type {?}
* @private
*/
NeoChangeCommandDirective.prototype._lastValue;
/**
* @type {?}
* @private
*/
NeoChangeCommandDirective.prototype.element;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/neo-decimalNumbers.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NeoDecimalNumbersDirective = /** @class */ (function () {
function NeoDecimalNumbersDirective(el, renderer, model) {
this.el = el;
this.renderer = renderer;
this.model = model;
this.decimals = 2;
this.allowNullValue = false;
this.haveDecimalPoint = false;
}
/**
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.ngOnInit = /**
* @return {?}
*/
function () {
if ((/** @type {?} */ (this.decimals)) == "")
this.decimals = 2;
if ((/** @type {?} */ (this.allowNullValue)) === "")
this.allowNullValue = true;
this.el.nativeElement.type = "number";
this.regex = new RegExp('^[0-9]+(\\.[0-9]{0,' + this.decimals + '})?$');
};
/**
* @param {?} e
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.blockPaste = /**
* @param {?} e
* @return {?}
*/
function (e) {
var _this = this;
/** @type {?} */
var clipboardData = e.clipboardData || window['clipboardData'];
/** @type {?} */
var pastedData = clipboardData.getData('text/plain').split(",").join(".");
/** @type {?} */
var posPoint = pastedData.lastIndexOf('.');
if (posPoint > -1) {
pastedData = pastedData.substring(0, posPoint).split(".").join("") + pastedData.substring(posPoint);
posPoint = pastedData.lastIndexOf('.');
if (posPoint + this.decimals < pastedData.length) {
pastedData = pastedData.substring(0, posPoint + this.decimals + 1);
}
}
/** @type {?} */
var onlyNumbers = Array.from(pastedData).map((/**
* @param {?} x
* @return {?}
*/
function (x) { return _this.isNumber(x); })).reduce((/**
* @param {?} prev
* @param {?} el
* @return {?}
*/
function (prev, el) { return prev && el; }), true);
/** @type {?} */
var a = this.regex.test(pastedData);
setTimeout((/**
* @return {?}
*/
function () {
if (onlyNumbers && a) {
_this.el.nativeElement.value = pastedData;
}
else {
_this.el.nativeElement.value = '0';
}
}), 10);
};
/**
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.onfocus = /**
* @return {?}
*/
function () {
if (this.el.nativeElement.value == "0") {
this.el.nativeElement.value = null;
}
};
/**
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.onBlur = /**
* @return {?}
*/
function () {
/** @type {?} */
var current = this.el.nativeElement.value;
if (current == "") {
if (this.allowNullValue) {
this.el.nativeElement.value = null;
this.model.control.setValue(null);
}
else {
this.el.nativeElement.value = "0";
this.model.control.setValue(0);
}
}
else {
this.el.nativeElement.type = "text";
this.el.nativeElement.type = "number";
if (this.el.nativeElement.max && this.el.nativeElement.valueAsNumber > +this.el.nativeElement.max) {
this.el.nativeElement.value = this.el.nativeElement.max;
this.model.control.setValue(this.el.nativeElement.valueAsNumber);
}
}
};
/**
* @param {?} event
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.onKeyUp = /**
* @param {?} event
* @return {?}
*/
function (event) {
/** @type {?} */
var current = this.el.nativeElement.value;
current = current.split("-").join("");
/** @type {?} */
var posPoint = current.indexOf('.');
if (posPoint > -1) {
this.el.nativeElement.value = current.substring(0, posPoint + 1) + current.substring(posPoint).split(".").join("");
}
if (this.haveDecimalPoint && current == "" && this.prev > "") {
this.haveDecimalPoint = false;
this.el.nativeElement.value = this.prev + (this.prev.endsWith(".0") ? "" : ".0");
this.el.nativeElement.type = "text";
this.el.nativeElement.selectionStart = this.el.nativeElement.value.length - 1;
this.el.nativeElement.selectionEnd = this.el.nativeElement.value.length;
this.el.nativeElement.type = "number";
return;
}
if (this.isSpecial(event) || current == "") {
if (event.keyCode == 8 || current != "") {
this.prev = current;
/** @type {?} */
var dotIndex = current.toString().indexOf('.');
if (dotIndex >= 0)
this.haveDecimalPoint = false;
}
return;
}
if (!this.isNumber(event)) {
event.preventDefault();
event.stopPropagation();
return false;
}
if (current) {
current = current.toString();
/** @type {?} */
var dotIndex = current.indexOf('.');
if ((dotIndex >= 0) && ((current.length - 1) - dotIndex > this.decimals)) {
this.renderer.setProperty(this.el.nativeElement, 'value', current.slice(0, dotIndex + this.decimals + 1));
}
}
else {
this.renderer.setProperty(this.el.nativeElement, 'value', this.prev);
}
};
/**
* @param {?} event
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.onKeyDown = /**
* @param {?} event
* @return {?}
*/
function (event) {
if (this.isSpecial(event)) {
return;
}
if (!this.isNumber(event)) {
event.preventDefault();
event.stopPropagation();
return false;
}
/** @type {?} */
var current = this.el.nativeElement.value;
if (this.isDecimalPoint(event)) {
this.haveDecimalPoint = true;
if (!current.endsWith(".0")) {
this.el.nativeElement.value = current + ".0";
this.el.nativeElement.type = "text";
this.el.nativeElement.selectionStart = this.el.nativeElement.value.length - 1;
this.el.nativeElement.selectionEnd = this.el.nativeElement.value.length;
this.el.nativeElement.type = "number";
}
}
this.prev = current;
};
/**
* @private
* @param {?} e
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.isSpecial = /**
* @private
* @param {?} e
* @return {?}
*/
function (e) {
return e.key === 'Delete' || (e.key === 'Tab' || e.keyCode == 9) || (e.key === 'Backspace' || e.keyCode == 8) || e.key === 'ArrowLeft' ||
e.altKey || e.ctrlKey || e.key === 'Home' || e.key === 'End' || e.key === 'PageDown' || e.key === 'PageUp' ||
e.key === 'ArrowDown' || e.key === 'ArrowUp' || e.key === 'ArrowRight' || e.key === 'Control' || e.key === 'Alt' || e.key === 'Shift' ||
(((/** @type {?} */ (e))).keyIdentifier == 'Down' || ((/** @type {?} */ (e))).keyIdentifier == 'Up');
};
/**
* @private
* @param {?} e
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.isNumber = /**
* @private
* @param {?} e
* @return {?}
*/
function (e) {
if (e instanceof KeyboardEvent) {
return ((e.key >= '0' && e.key <= '9') || ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) ||
(e.key === '.' || e.key === ',') || (e.keyCode === 188 || e.keyCode === 190 || e.keyCode === 229));
}
else {
return ((e >= '0' && e <= '9') || (e === '.' || e === ','));
}
};
/**
* @private
* @param {?} e
* @return {?}
*/
NeoDecimalNumbersDirective.prototype.isDecimalPoint = /**
* @private
* @param {?} e
* @return {?}
*/
function (e) {
return (e.key === '.' || e.key === ',') || (e.keyCode === 188 || e.keyCode === 190 || e.keyCode === 229);
};
NeoDecimalNumbersDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[isDecimal]',
},] }
];
/** @nocollapse */
NeoDecimalNumbersDirective.ctorParameters = function () { return [
{ type: core.ElementRef },
{ type: core.Renderer2 },
{ type: forms.NgModel }
]; };
NeoDecimalNumbersDirective.propDecorators = {
decimals: [{ type: core.Input, args: ['isDecimal',] }],
allowNullValue: [{ type: core.Input, args: ['allowNullValue',] }],
blockPaste: [{ type: core.HostListener, args: ['paste', ['$event'],] }],
onfocus: [{ type: core.HostListener, args: ['focus',] }],
onBlur: [{ type: core.HostListener, args: ['blur',] }],
onKeyUp: [{ type: core.HostListener, args: ['keyup', ['$event'],] }],
onKeyDown: [{ type: core.HostListener, args: ['keydown', ['$event'],] }]
};
return NeoDecimalNumbersDirective;
}());
if (false) {
/** @type {?} */
NeoDecimalNumbersDirective.prototype.decimals;
/** @type {?} */
NeoDecimalNumbersDirective.prototype.allowNullValue;
/**
* @type {?}
* @private
*/
NeoDecimalNumbersDirective.prototype.prev;
/**
* @type {?}
* @private
*/
NeoDecimalNumbersDirective.prototype.regex;
/**
* @type {?}
* @private
*/
NeoDecimalNumbersDirective.prototype.haveDecimalPoint;
/**
* @type {?}
* @private
*/
NeoDecimalNumbersDirective.prototype.el;
/**
* @type {?}
* @private
*/
NeoDecimalNumbersDirective.prototype.renderer;
/**
* @type {?}
* @private
*/
NeoDecimalNumbersDirective.prototype.model;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/composite-input/commandKey.function.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* Boolean function that check if the keyboard event is not a normal key but a command like key
* Will return boolean if the key is Alt, Shift , Control, Delete, Tab, Backspace, Arrows, Home, End, PageUp and PageDown.
*
* @export
* @param {?} e
* @return {?}
*/
function isCommandKey(e) {
return e.key === 'Delete' || e.key === 'Tab' || e.key === 'Backspace' || e.key === 'ArrowLeft' || e.key === 'Left' ||
e.altKey || e.ctrlKey || e.key === 'Home' || e.key === 'End' || e.key === 'PageDown' || e.key === 'PageUp' ||
e.key === 'ArrowRight' || e.key === 'Right' || e.key === 'Control' || e.key === 'Alt' || e.key === 'Shift';
}
/**
* @fileoverview added by tsickle
* Generated from: lib/composite-input/composite-input.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NeoCompositeInputDirective = /** @class */ (function () {
function NeoCompositeInputDirective(el) {
this.el = el;
// Next input to move from the current input
this.previousInput = null;
// Previous input to move from the current input
this.nextInput = null;
}
/**
* @param {?} e
* @return {?}
*/
NeoCompositeInputDirective.prototype.onKeyDown = /**
* @param {?} e
* @return {?}
*/
function (e) {
// If the element is selected and the user presses backspace we must clear the input
if (e.key === 'Backspace' && this.elementIsSelected()) {
return true;
}
// We must move to the previous input if the user presses backspace and he is in the first position of the input
// or if he presses the left key
if (((e.key === 'Backspace') && (this.el.nativeElement.selectionStart === 0) || ((e.key === 'ArrowLeft') || (e.key === 'Left')))) {
if ((this.previousInput) && (this.previousInput instanceof HTMLInputElement) && (!this.previousInput.disabled)) {
this.previousInput.focus();
return false;
}
}
// If he presses the right arrow it must move to the next input
if (e.key === 'ArrowRight' || e.key === 'Right') {
if ((this.nextInput) && (this.nextInput instanceof HTMLInputElement) && (!this.nextInput.disabled)) {
this.nextInput.focus();
return false;
}
}
};
/**
*
* Method called on keyup to check if the pressed key is allow, if it is not it stops the event.
* If the element reached its maximum length on key pressed it must jump to the next input
* @param e
*/
/**
*
* Method called on keyup to check if the pressed key is allow, if it is not it stops the event.
* If the element reached its maximum length on key pressed it must jump to the next input
* @param {?} e
* @return {?}
*/
NeoCompositeInputDirective.prototype.onKeyUp = /**
*
* Method called on keyup to check if the pressed key is allow, if it is not it stops the event.
* If the element reached its maximum length on key pressed it must jump to the next input
* @param {?} e
* @return {?}
*/
function (e) {
if (isCommandKey(e)) {
return;
}
/** @type {?} */
var value = this.el.nativeElement.value;
if (this.nextInput && (value.length >= this.el.nativeElement.maxLength)) {
this.nextInput.focus();
}
};
/**
* On focus we select the entire value of the input
*/
/**
* On focus we select the entire value of the input
* @return {?}
*/
NeoCompositeInputDirective.prototype.onFocus = /**
* On focus we select the entire value of the input
* @return {?}
*/
function () {
this.el.nativeElement.select();
};
/**
* Method to check if the element is selected
*
*/
/**
* Method to check if the element is selected
*
* @private
* @return {?}
*/
NeoCompositeInputDirective.prototype.elementIsSelected = /**
* Method to check if the element is selected
*
* @private
* @return {?}
*/
function () {
return this.el.nativeElement.selectionStart === 0 && this.el.nativeElement.selectionEnd !== 0;
};
NeoCompositeInputDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[compositeInput]'
},] }
];
/** @nocollapse */
NeoCompositeInputDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NeoCompositeInputDirective.propDecorators = {
previousInput: [{ type: core.Input }],
nextInput: [{ type: core.Input }],
onKeyDown: [{ type: core.HostListener, args: ['keydown', ['$event'],] }],
onKeyUp: [{ type: core.HostListener, args: ['keyup', ['$event'],] }],
onFocus: [{ type: core.HostListener, args: ['focus', [],] }]
};
return NeoCompositeInputDirective;
}());
if (false) {
/** @type {?} */
NeoCompositeInputDirective.prototype.previousInput;
/** @type {?} */
NeoCompositeInputDirective.prototype.nextInput;
/**
* @type {?}
* @private
*/
NeoCompositeInputDirective.prototype.el;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/neo-matchheight.directive.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NeoMatchHeightDirective = /** @class */ (function () {
function NeoMatchHeightDirective(el) {
this.el = el;
}
/**
* @return {?}
*/
NeoMatchHeightDirective.prototype.onResize = /**
* @return {?}
*/
function () {
this.matchHeight(this.el.nativeElement, this.matchHeightClassName);
};
/**
* @return {?}
*/
NeoMatchHeightDirective.prototype.ngAfterViewChecked = /**
* @return {?}
*/
function () {
this.matchHeight(this.el.nativeElement, this.matchHeightClassName);
};
/**
* @param {?} parent
* @param {?} className
* @return {?}
*/
NeoMatchHeightDirective.prototype.matchHeight = /**
* @param {?} parent
* @param {?} className
* @return {?}
*/
function (parent, className) {
if (!parent) {
return;
}
// step 1: find all the child elements with the selected class name
/** @type {?} */
var children = parent.getElementsByClassName(className);
if (!children) {
return;
}
// step 1b: reset all children height
Array.from(children).forEach((/**
* @param {?} x
* @return {?}
*/
function (x) {
x.style.height = 'initial';
}));
// step 2a: get all the child elements heights
/** @type {?} */
var itemHeights = Array.from(children)
.map((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.getBoundingClientRect().height; }));
// step 2b: find out the tallest
/** @type {?} */
var maxHeight = itemHeights.reduce((/**
* @param {?} prev
* @param {?} curr
* @return {?}
*/
function (prev, curr) {
return curr > prev ? curr : prev;
}), 0);
// step 3: update all the child elements to the tallest height
Array.from(children)
.forEach((/**
* @param {?} x
* @return {?}
*/
function (x) { return x.style.height = maxHeight + "px"; }));
};
NeoMatchHeightDirective.decorators = [
{ type: core.Directive, args: [{
selector: '[neoMatchHeight]'
},] }
];
/** @nocollapse */
NeoMatchHeightDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NeoMatchHeightDirective.propDecorators = {
matchHeightClassName: [{ type: core.Input, args: ['neoMatchHeight',] }],
onResize: [{ type: core.HostListener, args: ['window:resize',] }]
};
return NeoMatchHeightDirective;
}());
if (false) {
/** @type {?} */
NeoMatchHeightDirective.prototype.matchHeightClassName;
/**
* @type {?}
* @private
*/
NeoMatchHeightDirective.prototype.el;
}
/**
* @fileoverview added by tsickle
* Generated from: lib/ngx-neo-directives.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NgxNeoDirectivesModule = /** @class */ (function () {
function NgxNeoDirectivesModule() {
}
/**
* @param {?=} options
* @return {?}
*/
NgxNeoDirectivesModule.forRoot = /**
* @param {?=} options
* @return {?}
*/
function (options) {
if (options === void 0) { options = { executingCssClass: 'executing' }; }
return {
ngModule: NgxNeoDirectivesModule,
providers: [
{ provide: COMMAND_CONFIG, useValue: options },
]
};
};
NgxNeoDirectivesModule.decorators = [
{ type: core.NgModule, args: [{
imports: [],
declarations: [
CommandDirective,
OnReturnDirective,
StringsDirective,
NeoNumbersDirective,
NgbTabSetDirective,
NeoAutofocusDirective,
NeoChangeCommandDirective,
NeoDecimalNumbersDirective,
NeoCompositeInputDirective,
NeoMatchHeightDirective,
],
exports: [
CommandDirective,
OnReturnDirective,
StringsDirective,
NeoNumbersDirective,
NgbTabSetDirective,
NeoAutofocusDirective,
NeoChangeCommandDirective,
NeoDecimalNumbersDirective,
NeoCompositeInputDirective,
NeoMatchHeightDirective
]
},] }
];
return NgxNeoDirectivesModule;
}());
/**
* @fileoverview added by tsickle
* Generated from: lib/models.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @record
*/
function ITabChangeController() { }
if (false) {
/**
* @return {?}
*/
ITabChangeController.prototype.canChangeTab = function () { };
}
exports.COMMAND_CONFIG = COMMAND_CONFIG;
exports.COMMAND_DEFAULT_CONFIG = COMMAND_DEFAULT_CONFIG;
exports.Command = Command;
exports.CommandDirective = CommandDirective;
exports.NeoAutofocusDirective = NeoAutofocusDirective;
exports.NeoChangeCommandDirective = NeoChangeCommandDirective;
exports.NeoCompositeInputDirective = NeoCompositeInputDirective;
exports.NeoDecimalNumbersDirective = NeoDecimalNumbersDirective;
exports.NeoMatchHeightDirective = NeoMatchHeightDirective;
exports.NeoNumbersDirective = NeoNumbersDirective;
exports.NgbTabSetDirective = NgbTabSetDirective;
exports.NgxNeoDirectivesModule = NgxNeoDirectivesModule;
exports.OnReturnDirective = OnReturnDirective;
exports.StringsDirective = StringsDirective;
exports.isCommandKey = isCommandKey;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=neocomplexx-ngx-neo-directives.umd.js.map