@asi-ngtools/lib
Version:
This project is a little components library, simple to use, which will help you to simplify your project.
1,445 lines (1,428 loc) • 434 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/router'), require('lodash'), require('@angular/common/http'), require('@angular/platform-browser'), require('@angular/animations'), require('@angular/common'), require('@ngx-translate/core'), require('@angular/forms'), require('moment'), require('rxjs'), require('rxjs/operators'), require('@angular/core')) :
typeof define === 'function' && define.amd ? define('@asi-ngtools/lib', ['exports', '@angular/router', 'lodash', '@angular/common/http', '@angular/platform-browser', '@angular/animations', '@angular/common', '@ngx-translate/core', '@angular/forms', 'moment', 'rxjs', 'rxjs/operators', '@angular/core'], factory) :
(factory((global['asi-ngtools'] = global['asi-ngtools'] || {}, global['asi-ngtools'].lib = {}),global.ng.router,global.lodash,global.ng.common.http,global.ng.platformBrowser,global.ng.animations,global.ng.common,global.core,global.ng.forms,global.moment,global.rxjs,global.rxjs.operators,global.ng.core));
}(this, (function (exports,router,lodash,http,platformBrowser,animations,common,core,forms,moment,rxjs,operators,core$1) { 'use strict';
moment = moment && moment.hasOwnProperty('default') ? moment['default'] : moment;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiComponentTemplate = (function () {
function AsiComponentTemplate() {
}
AsiComponentTemplate.decorators = [
{ type: core$1.Component, args: [{
selector: 'asi-option, asi-tag, asi-selected, asi-empty, asi-header, asi-cell, asi-tree-node, asi-tree-leaf, asi-clear',
template: '<ng-content></ng-content>'
}] }
];
/** @nocollapse */
AsiComponentTemplate.ctorParameters = function () { return []; };
return AsiComponentTemplate;
}());
var AsiComponentTemplateOptionDef = (function () {
function AsiComponentTemplateOptionDef(template) {
this.template = template;
}
AsiComponentTemplateOptionDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiOptionDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateOptionDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateOptionDef;
}());
var AsiComponentTemplateTagDef = (function () {
function AsiComponentTemplateTagDef(template) {
this.template = template;
}
AsiComponentTemplateTagDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiTagDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateTagDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateTagDef;
}());
var AsiComponentTemplateSelectedDef = (function () {
function AsiComponentTemplateSelectedDef(template) {
this.template = template;
}
AsiComponentTemplateSelectedDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiSelectedDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateSelectedDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateSelectedDef;
}());
var AsiComponentTemplateEmptyDef = (function () {
function AsiComponentTemplateEmptyDef(template) {
this.template = template;
}
AsiComponentTemplateEmptyDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiEmptyDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateEmptyDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateEmptyDef;
}());
var AsiComponentTemplateClearDef = (function () {
function AsiComponentTemplateClearDef(template) {
this.template = template;
}
AsiComponentTemplateClearDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiClearDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateClearDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateClearDef;
}());
var AsiComponentTemplateTableHeaderDef = (function () {
function AsiComponentTemplateTableHeaderDef(template) {
this.template = template;
}
AsiComponentTemplateTableHeaderDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiTableHeaderDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateTableHeaderDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateTableHeaderDef;
}());
var AsiComponentTemplateTabHeaderDef = (function () {
function AsiComponentTemplateTabHeaderDef(template) {
this.template = template;
}
AsiComponentTemplateTabHeaderDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiTabHeaderDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateTabHeaderDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateTabHeaderDef;
}());
var AsiComponentTemplateNavHeaderDef = (function () {
function AsiComponentTemplateNavHeaderDef(template) {
this.template = template;
}
AsiComponentTemplateNavHeaderDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiNavHeaderDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateNavHeaderDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateNavHeaderDef;
}());
var AsiComponentTemplateCollapseHeaderDef = (function () {
function AsiComponentTemplateCollapseHeaderDef(template) {
this.template = template;
}
AsiComponentTemplateCollapseHeaderDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiCollapseHeaderDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateCollapseHeaderDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateCollapseHeaderDef;
}());
var AsiComponentTemplateCellDef = (function () {
function AsiComponentTemplateCellDef(template) {
this.template = template;
}
AsiComponentTemplateCellDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiCellDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateCellDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateCellDef;
}());
var AsiComponentTemplateColumnDef = (function () {
function AsiComponentTemplateColumnDef(template) {
this.template = template;
}
AsiComponentTemplateColumnDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiColumnDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateColumnDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateColumnDef;
}());
var AsiComponentTemplateTreeNodeDef = (function () {
function AsiComponentTemplateTreeNodeDef(template) {
this.template = template;
}
AsiComponentTemplateTreeNodeDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiTreeNodeDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateTreeNodeDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateTreeNodeDef;
}());
var AsiComponentTemplateTreeLeafDef = (function () {
function AsiComponentTemplateTreeLeafDef(template) {
this.template = template;
}
AsiComponentTemplateTreeLeafDef.decorators = [
{ type: core$1.Directive, args: [{
selector: '[asiTreeLeafDef]',
},] }
];
/** @nocollapse */
AsiComponentTemplateTreeLeafDef.ctorParameters = function () {
return [
{ type: core$1.TemplateRef }
];
};
return AsiComponentTemplateTreeLeafDef;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var DefaultControlValueAccessor = (function () {
function DefaultControlValueAccessor() {
/**
* is enabled/disabled
*/
this.disabled = false;
/**
* Event emitted when component value changed
*/
this.onValueChange = new core$1.EventEmitter();
this.onChange = function () { };
this.onTouched = function () { };
}
Object.defineProperty(DefaultControlValueAccessor.prototype, "value", {
get: /**
* @return {?}
*/ function () {
return this._value;
},
set: /**
* @param {?} val
* @return {?}
*/ function (val) {
this._value = val;
this.onTouched();
this.onChange(val);
this.onValueChange.emit(this.value);
},
enumerable: true,
configurable: true
});
/**
* @param {?} fn
* @return {?}
*/
DefaultControlValueAccessor.prototype.registerOnChange = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this.onChange = fn;
};
/**
* @param {?} fn
* @return {?}
*/
DefaultControlValueAccessor.prototype.registerOnTouched = /**
* @param {?} fn
* @return {?}
*/
function (fn) {
this.onTouched = fn;
};
/**
* @param {?} value
* @return {?}
*/
DefaultControlValueAccessor.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
this._value = value;
};
/**
* @param {?} disabled
* @return {?}
*/
DefaultControlValueAccessor.prototype.setDisabledState = /**
* @param {?} disabled
* @return {?}
*/
function (disabled) {
this.disabled = disabled;
};
DefaultControlValueAccessor.propDecorators = {
_value: [{ type: core$1.Input, args: ['value',] }],
disabled: [{ type: core$1.Input }],
onValueChange: [{ type: core$1.Output }]
};
return DefaultControlValueAccessor;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiNgToolsBaseModule = (function () {
function AsiNgToolsBaseModule() {
}
/**
* @return {?}
*/
AsiNgToolsBaseModule.forRoot = /**
* @return {?}
*/
function () {
return {
ngModule: AsiNgToolsBaseModule,
providers: [core.TranslateService]
};
};
AsiNgToolsBaseModule.decorators = [
{ type: core$1.NgModule, args: [{
declarations: [
AsiComponentTemplateTabHeaderDef,
AsiComponentTemplateTableHeaderDef,
AsiComponentTemplateOptionDef,
AsiComponentTemplateEmptyDef,
AsiComponentTemplateClearDef,
AsiComponentTemplateSelectedDef,
AsiComponentTemplateColumnDef,
AsiComponentTemplateCellDef,
AsiComponentTemplateTagDef,
AsiComponentTemplateTreeNodeDef,
AsiComponentTemplateTreeLeafDef,
AsiComponentTemplateNavHeaderDef,
AsiComponentTemplateCollapseHeaderDef,
AsiComponentTemplate
],
imports: [core.TranslateModule,
forms.FormsModule,
forms.ReactiveFormsModule,
common.CommonModule,
router.RouterModule],
exports: [core.TranslateModule,
forms.FormsModule,
forms.ReactiveFormsModule,
common.CommonModule,
router.RouterModule,
AsiComponentTemplateTabHeaderDef,
AsiComponentTemplateTableHeaderDef,
AsiComponentTemplateOptionDef,
AsiComponentTemplateEmptyDef,
AsiComponentTemplateClearDef,
AsiComponentTemplateSelectedDef,
AsiComponentTemplateTagDef,
AsiComponentTemplateColumnDef,
AsiComponentTemplateCellDef,
AsiComponentTemplateTreeNodeDef,
AsiComponentTemplateTreeLeafDef,
AsiComponentTemplateCollapseHeaderDef,
AsiComponentTemplate],
entryComponents: [],
providers: [core.TranslateService]
},] }
];
return AsiNgToolsBaseModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiButtonComponent = (function () {
function AsiButtonComponent(renderer, elementRef) {
this.renderer = renderer;
this.elementRef = elementRef;
/**
* html type
*/
this.type = 'button';
/**
* button design
*/
this.design = 'flat';
/**
* button size
*/
this.size = 'standard';
/**
* ensable/disable the button
*/
this.disabled = false;
}
/**
* @return {?}
*/
AsiButtonComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.renderer.addClass(this.elementRef.nativeElement, "button-" + this.design);
this.renderer.addClass(this.elementRef.nativeElement, "button-" + this.size);
};
/**
* @return {?}
*/
AsiButtonComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
if (this.disabled) {
this.renderer.addClass(this.elementRef.nativeElement, 'disabled');
}
else {
this.renderer.removeClass(this.elementRef.nativeElement, 'disabled');
}
};
AsiButtonComponent.decorators = [
{ type: core$1.Component, args: [{
selector: 'asi-button',
host: { 'class': 'asi-component asi-button' },
template: "<button [attr.id]=\"id\" [attr.name]=\"name\" [attr.type]=\"type\" [disabled]=\"disabled\" [attr.disabled]=\"disabled ? 'disabled' : null\">\n <ng-content></ng-content>\n</button>\n"
}] }
];
/** @nocollapse */
AsiButtonComponent.ctorParameters = function () {
return [
{ type: core$1.Renderer2 },
{ type: core$1.ElementRef }
];
};
AsiButtonComponent.propDecorators = {
id: [{ type: core$1.Input }],
name: [{ type: core$1.Input }],
type: [{ type: core$1.Input }],
design: [{ type: core$1.Input }],
size: [{ type: core$1.Input }],
disabled: [{ type: core$1.Input }]
};
return AsiButtonComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiLinkButtonComponent = (function () {
function AsiLinkButtonComponent(renderer, elementRef) {
this.renderer = renderer;
this.elementRef = elementRef;
this.design = 'flat';
this.href = '';
this.target = '_self';
this.disabled = false;
}
/**
* @return {?}
*/
AsiLinkButtonComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.renderer.addClass(this.elementRef.nativeElement, "link-button-" + this.design);
};
/**
* @return {?}
*/
AsiLinkButtonComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
if (this.disabled) {
this.renderer.addClass(this.elementRef.nativeElement, 'disabled');
}
else {
this.renderer.removeClass(this.elementRef.nativeElement, 'disabled');
}
};
AsiLinkButtonComponent.decorators = [
{ type: core$1.Component, args: [{
selector: 'asi-link-button',
host: { 'class': 'asi-component asi-link-button' },
template: "<a [attr.href]=\"href\" [attr.target]=\"target\">\r\n <ng-content></ng-content>\r\n</a>\r\n"
}] }
];
/** @nocollapse */
AsiLinkButtonComponent.ctorParameters = function () {
return [
{ type: core$1.Renderer2 },
{ type: core$1.ElementRef }
];
};
AsiLinkButtonComponent.propDecorators = {
design: [{ type: core$1.Input }],
href: [{ type: core$1.Input }],
target: [{ type: core$1.Input }],
disabled: [{ type: core$1.Input }]
};
return AsiLinkButtonComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiButtonModule = (function () {
function AsiButtonModule() {
}
/**
* @return {?}
*/
AsiButtonModule.forRoot = /**
* @return {?}
*/
function () {
return {
ngModule: AsiButtonModule,
providers: []
};
};
AsiButtonModule.decorators = [
{ type: core$1.NgModule, args: [{
declarations: [AsiButtonComponent, AsiLinkButtonComponent],
imports: [AsiNgToolsBaseModule.forRoot()],
exports: [AsiNgToolsBaseModule, AsiButtonComponent, AsiLinkButtonComponent],
entryComponents: [],
providers: []
},] }
];
return AsiButtonModule;
}());
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* 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 __values(o) {
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
if (m)
return m.call(o);
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
}
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;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
/** @type {?} */
var months_fr = [
{ num: 1, libelle: 'Janvier' },
{ num: 2, libelle: 'Février' },
{ num: 3, libelle: 'Mars' },
{ num: 4, libelle: 'Avril' },
{ num: 5, libelle: 'Mai' },
{ num: 6, libelle: 'Juin' },
{ num: 7, libelle: 'Juillet' },
{ num: 8, libelle: 'Août' },
{ num: 9, libelle: 'Septembre' },
{ num: 10, libelle: 'Octobre' },
{ num: 11, libelle: 'Novembre' },
{ num: 12, libelle: 'Décembre' },
];
/** @type {?} */
var months_en = [
{ num: 1, libelle: 'January' },
{ num: 2, libelle: 'February' },
{ num: 3, libelle: 'March' },
{ num: 4, libelle: 'April' },
{ num: 5, libelle: 'May' },
{ num: 6, libelle: 'June' },
{ num: 7, libelle: 'July' },
{ num: 8, libelle: 'August' },
{ num: 9, libelle: 'September' },
{ num: 10, libelle: 'October' },
{ num: 11, libelle: 'November' },
{ num: 12, libelle: 'Decemder' }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
/**
* @param {?} array
* @param {?} mapper
* @return {?}
*/
function map(array, mapper) {
if (array) {
return array.map(mapper);
}
return array;
}
/**
* @param {?} array
* @param {?} iteratee
* @return {?}
*/
function filter(array, iteratee) {
if (array) {
return array.filter(iteratee);
}
return array;
}
/**
* @param {?} array
* @return {?}
*/
function isArray(array) {
return Array.isArray(array);
}
/**
* @param {?} howManyTimes
* @param {?} iteratee
* @return {?}
*/
function times(howManyTimes, iteratee) {
/** @type {?} */
var res = [];
/** @type {?} */
var index = -1;
while (++index < howManyTimes) {
res.push(iteratee(index));
}
return res;
}
/**
* @param {?} array
* @param {?} iteratee
* @return {?}
*/
function forEach(array, iteratee) {
if (array) {
array.forEach(iteratee);
}
}
/**
* @param {?} array
* @param {?} iteratee
* @return {?}
*/
function remove(array, iteratee) {
/** @type {?} */
var deletedItems = [];
if (array) {
/** @type {?} */
var index = array.length;
while (index--) {
/** @type {?} */
var item = array[index];
if (iteratee(item, index)) {
array.splice(index, 1);
deletedItems.push(item);
}
}
}
return deletedItems;
}
/**
* @param {?} array
* @param {?} index
* @return {?}
*/
function removeAtIndex(array, index) {
if (array) {
array.splice(index, 1);
}
}
/**
* @param {?} object
* @param {?} path
* @param {?=} defaultVal
* @return {?}
*/
function get(object, path, defaultVal) {
/** @type {?} */
var _path = Array.isArray(path)
? path
: path.split('.').filter(function (index) { return index.length; });
if (!_path.length) {
return object === undefined ? defaultVal : object;
}
return get(object[_path.shift()], _path, defaultVal);
}
/**
* @param {?} array
* @param {?} finder
* @return {?}
*/
function find(array, finder) {
if (array) {
return array.find(finder);
}
return undefined;
}
/**
* @param {?} value
* @param {?} maxLength
* @return {?}
*/
function truncate(value, maxLength) {
if (value) {
return value.substring(0, maxLength);
}
return value;
}
/**
* @param {?} items
* @param {?} what
* @return {?}
*/
function indexOf(items, what) {
if (items) {
return items.indexOf(what);
}
return -1;
}
/**
* @param {...?} arrays
* @return {?}
*/
function concat() {
var arrays = [];
for (var _i = 0; _i < arguments.length; _i++) {
arrays[_i] = arguments[_i];
}
/** @type {?} */
var newArray = [];
arrays.forEach(function (array) {
newArray = newArray.concat(array);
});
return newArray;
}
/**
* @param {?} str
* @param {?} reg
* @param {?} newVal
* @return {?}
*/
function replace(str, reg, newVal) {
if (str) {
return str.replace(reg, newVal);
}
return str;
}
/**
* @param {?} array
* @param {?} key
* @param {?} asc
* @return {?}
*/
function orderByWithoutCase(array, key, asc) {
/** @type {?} */
var order = asc === 'asc' ? -1 : 1;
array.sort(function (a, b) {
if (!a[key] && !b[key]) {
return 0;
}
else if (a[key] && !b[key]) {
return -1;
}
else if (!a[key] && b[key]) {
return 1;
}
/** @type {?} */
var value1 = a[key].toLowerCase();
/** @type {?} */
var value2 = b[key].toLowerCase();
if (value1 < value2) {
return order;
}
else if (value1 > value2) {
return -order;
}
return 0;
});
return array;
}
/**
* @param {?} object
* @return {?}
*/
function cloneDeep(object) {
return lodash.cloneDeep(object);
}
/**
* @param {?} item
* @return {?}
*/
function isEmpty(item) {
return item == null || item.length === 0;
}
/**
* @param {?} items
* @param {?} separator
* @return {?}
*/
function join(items, separator) {
if (items) {
return items.join(separator);
}
return items;
}
/**
* @template T
* @param {?} obs
* @return {?}
*/
function observe(obs) {
if (rxjs.isObservable(obs)) {
return obs;
}
else if (obs instanceof Promise) {
return rxjs.from(obs);
}
else {
return rxjs.of(/** @type {?} */ (obs));
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiDmyPickerComponent = (function (_super) {
__extends(AsiDmyPickerComponent, _super);
function AsiDmyPickerComponent(platformId, injector, renderer, elementRef) {
var _this = _super.call(this) || this;
_this.platformId = platformId;
_this.injector = injector;
_this.renderer = renderer;
_this.elementRef = elementRef;
/**
* Label position
*/
_this.labelPosition = 'top';
/**
* hide day list
*/
_this.dayHidden = false;
_this.days = [];
_this.months = [];
_this.years = [];
return _this;
}
/**
* @return {?}
*/
AsiDmyPickerComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.renderer.addClass(this.elementRef.nativeElement, 'label-' + this.labelPosition);
if (this.isFr()) {
this.months = months_fr;
this.dayLabel = 'Jour';
this.monthLabel = 'Mois';
this.yearLabel = 'Annee';
}
else {
this.months = months_en;
this.dayLabel = 'Day';
this.monthLabel = 'Month';
this.yearLabel = 'Year';
}
this.initDays();
this.initYears();
};
/**
* @return {?}
*/
AsiDmyPickerComponent.prototype.isFr = /**
* @return {?}
*/
function () {
if (common.isPlatformBrowser(this.platformId)) {
return navigator.language === 'fr' || navigator.language === 'fr-FR';
}
else {
/** @type {?} */
var request = this.injector.get('request');
if (request && request.asiNgtools) {
/** @type {?} */
var language = request.asiNgtools.language;
if (language) {
return language.substring(0, 2) === 'fr';
}
}
return false;
}
};
/**
* @return {?}
*/
AsiDmyPickerComponent.prototype.initDays = /**
* @return {?}
*/
function () {
var _this = this;
times(31, function (time) {
_this.days.push(time + 1);
});
};
/**
* @return {?}
*/
AsiDmyPickerComponent.prototype.initYears = /**
* @return {?}
*/
function () {
/** @type {?} */
var results = new Array();
/** @type {?} */
var currentYear = new Date().getFullYear();
for (var year = currentYear; year >= 1900; year--) {
results.push(year);
}
this.years = results;
};
/**
* @param {?} month
* @return {?}
*/
AsiDmyPickerComponent.prototype.onMonthChange = /**
* @param {?} month
* @return {?}
*/
function (month) {
this.value = { day: this.day, month: month != null ? month.num : null, year: this.year };
};
/**
* @param {?} year
* @return {?}
*/
AsiDmyPickerComponent.prototype.onYearChange = /**
* @param {?} year
* @return {?}
*/
function (year) {
this.value = { day: this.day, month: this.month != null ? this.month.num : null, year: year };
};
/**
* @param {?} day
* @return {?}
*/
AsiDmyPickerComponent.prototype.onDayChange = /**
* @param {?} day
* @return {?}
*/
function (day) {
this.value = { day: day, month: this.month != null ? this.month.num : null, year: this.year };
};
// Controle value accessor
/**
* @param {?} value
* @return {?}
*/
AsiDmyPickerComponent.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value != null) {
this.day = value.day;
this.month = this.getMontFromNum(value.month);
this.year = value.year;
}
else {
this.day = null;
this.month = null;
this.year = null;
}
this._value = { day: this.day, month: this.month, year: this.year };
};
/**
* @param {?} monthNum
* @return {?}
*/
AsiDmyPickerComponent.prototype.getMontFromNum = /**
* @param {?} monthNum
* @return {?}
*/
function (monthNum) {
if (monthNum == null) {
return null;
}
return find(this.months, function (month) {
return month.num === monthNum;
});
};
AsiDmyPickerComponent.decorators = [
{ type: core$1.Component, args: [{
selector: 'asi-dmypicker',
host: { 'class': 'asi-component asi-dmypicker' },
template: "<label class=\"input-label\" [translate]=\"label\"></label>\r\n<div class=\"asi-dmypicker-container\">\r\n <asi-select class=\"asi-dmy-days\" [disabled]=\"disabled\" [withEmptyValue]=\"true\" [hidden]=\"dayHidden\" [data]=\"days\" [(ngModel)]=\"day\"\r\n (ngModelChange)=\"onDayChange($event)\">\r\n <asi-empty *asiEmptyDef>{{dayLabel}}</asi-empty>\r\n <asi-selected *asiSelectedDef=\"let data\">{{data}}</asi-selected>\r\n <asi-option *asiOptionDef=\"let data\">{{data}}</asi-option>\r\n </asi-select>\r\n <asi-select class=\"asi-dmy-months\" [disabled]=\"disabled\" [withEmptyValue]=\"true\" [data]=\"months\" [(ngModel)]=\"month\" (ngModelChange)=\"onMonthChange($event)\">\r\n <asi-empty *asiEmptyDef>{{monthLabel}}</asi-empty>\r\n <asi-selected *asiSelectedDef=\"let data\">{{data.num + \" - \" + data.libelle}}</asi-selected>\r\n <asi-option *asiOptionDef=\"let data\">{{data.num + \" - \" + data.libelle}}</asi-option>\r\n </asi-select>\r\n <asi-select class=\"asi-dmy-years\" [disabled]=\"disabled\" [withEmptyValue]=\"true\" [data]=\"years\" [(ngModel)]=\"year\" (ngModelChange)=\"onYearChange($event)\">\r\n <asi-empty *asiEmptyDef>{{yearLabel}}</asi-empty>\r\n <asi-selected *asiSelectedDef=\"let data\">{{data}}</asi-selected>\r\n <asi-option *asiOptionDef=\"let data\">{{data}}</asi-option>\r\n </asi-select>\r\n</div>",
providers: [
{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core$1.forwardRef(function () { return AsiDmyPickerComponent; }),
multi: true
}
]
}] }
];
/** @nocollapse */
AsiDmyPickerComponent.ctorParameters = function () {
return [
{ type: undefined, decorators: [{ type: core$1.Inject, args: [core$1.PLATFORM_ID,] }] },
{ type: core$1.Injector },
{ type: core$1.Renderer2 },
{ type: core$1.ElementRef }
];
};
AsiDmyPickerComponent.propDecorators = {
label: [{ type: core$1.Input }],
labelPosition: [{ type: core$1.Input }],
dayHidden: [{ type: core$1.Input }]
};
return AsiDmyPickerComponent;
}(DefaultControlValueAccessor));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiCheckboxComponent = (function (_super) {
__extends(AsiCheckboxComponent, _super);
function AsiCheckboxComponent(renderer, elementRef) {
var _this = _super.call(this) || this;
_this.renderer = renderer;
_this.elementRef = elementRef;
/**
* Label position
*/
_this.labelPosition = 'top';
/**
* design : checkbox (square) or radio (round)
*/
_this.type = 'checkbox';
return _this;
}
/**
* @return {?}
*/
AsiCheckboxComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.renderer.addClass(this.elementRef.nativeElement, 'label-' + this.labelPosition);
};
/**
* @return {?}
*/
AsiCheckboxComponent.prototype.toggleCheck = /**
* @return {?}
*/
function () {
this.value = !this.value;
};
AsiCheckboxComponent.decorators = [
{ type: core$1.Component, args: [{
selector: 'asi-checkbox',
host: { 'class': 'asi-component asi-checkbox' },
template: "<label class=\"input-label\" *ngIf=\"label != null\">{{label | translate}}</label>\r\n\r\n<button type=\"button\" [disabled]=\"disabled\" (click)=\"toggleCheck()\" class=\"checkbox asi-focus-error\" [ngClass]=\"{ 'checked': value, 'radio' : type == 'radio' }\">\r\n <div><span class=\"checkbox-button\"></span></div>\r\n</button>",
providers: [
{
provide: forms.NG_VALUE_ACCESSOR,
useExisting: core$1.forwardRef(function () { return AsiCheckboxComponent; }),
multi: true
}
]
}] }
];
/** @nocollapse */
AsiCheckboxComponent.ctorParameters = function () {
return [
{ type: core$1.Renderer2 },
{ type: core$1.ElementRef }
];
};
AsiCheckboxComponent.propDecorators = {
label: [{ type: core$1.Input }],
labelPosition: [{ type: core$1.Input }],
type: [{ type: core$1.Input }]
};
return AsiCheckboxComponent;
}(DefaultControlValueAccessor));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiCheckBoxModule = (function () {
function AsiCheckBoxModule() {
}
/**
* @return {?}
*/
AsiCheckBoxModule.forRoot = /**
* @return {?}
*/
function () {
return {
ngModule: AsiCheckBoxModule,
providers: []
};
};
AsiCheckBoxModule.decorators = [
{ type: core$1.NgModule, args: [{
declarations: [AsiCheckboxComponent],
imports: [AsiNgToolsBaseModule.forRoot()],
exports: [AsiNgToolsBaseModule, AsiCheckboxComponent],
entryComponents: [],
providers: []
},] }
];
return AsiCheckBoxModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,uselessCode} checked by tsc
*/
var AsiSelectComponent = (function (_super) {
__extends(AsiSelectComponent, _super);
function AsiSelectComponent(renderer, elementRef) {
var _this = _super.call(this) || this;
_this.renderer = renderer;
_this.elementRef = elementRef;
/**
* Label position
*/
_this.labelPosition = 'top';
/**
* Multi selection
*/
_this.multiple = false;
/**
* Add an empty value (template must be define)
*/
_this.withEmptyValue = false;
_this.open = false;
_this.allChecked = false;
return _this;
}
/**
* @return {?}
*/
AsiSelectComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.renderer.addClass(this.elementRef.nativeElement, 'label-' + this.labelPosition);
if (this.multiple) {
this.renderer.addClass(this.elementRef.nativeElement, 'multiple');
}
};
/**
* @return {?}
*/
AsiSelectComponent.prototype.onDropdownClose = /**
* @return {?}
*/
function () {
this.open = false;
};
/**
* @return {?}
*/
AsiSelectComponent.prototype.isOpened = /**
* @return {?}
*/
function () {
return this.open;
};
/**
* @return {?}
*/
AsiSelectComponent.prototype.ngOnChanges = /**
* @return {?}
*/
function () {
this.initData();
};
/**
* @return {?}
*/
AsiSelectComponent.prototype.initData = /**
* @return {?}
*/
function () {
var _this = this;
this.selectDatas = [];
this.data = this.data || [];
if (this.withEmptyValue) {
this.selectDatas.push(null);
}
this.data.forEach(function (data) {
/** @type {?} */
var proxyData = {
selected: false,
value: data
};
_this.selectDatas.push(proxyData);
});
};
/**
* @param {?} value
* @return {?}
*/
AsiSelectComponent.prototype.checkAll = /**
* @param {?} value
* @return {?}
*/
function (value) {
var _this = this;
this.allChecked = value;
this.selectDatas.forEach(function (data) {
if (data != null && (value !== data.selected)) {
_this.internalSelectValue(null, data);
}
});
this.onModelChange(this._value);
};
/**
* @return {?}
*/
AsiSelectComponent.prototype.updateAllChecked = /**
* @return {?}
*/
function () {
this.allChecked = find(this.selectDatas, function (data) {
return data != null ? !data.selected : false;
}) == null;
};
/**
* @param {?} event
* @param {?} data
* @return {?}
*/
AsiSelectComponent.prototype.selectValue = /**
* @param {?} event
* @param {?} data
* @return {?}
*/
function (event, data) {
this.internalSelectValue(event, data);
this.onModelChange(this._value);
};
/**
* @param {?} event
* @param {?} data
* @return {?}
*/
AsiSelectComponent.prototype.internalSelectValue = /**
* @param {?} event
* @param {?} data
* @return {?}
*/
function (event, data) {
var _this = this;
if (data == null) {
this.onModelChange(null);
this.open = false;
return;
}
/** @type {?} */
var realValue = data.value;
if (this.multiple) {
if (event != null) {
event.stopPropagation();
}
if (this._value == null) {
this._value = [];
}
/** @type {?} */
var removed = remove(this._value, function (value) {
if (value != null) {
if (_this.trackBy != null) {
return value[_this.trackBy] === realValue[_this.trackBy];
}
else {
return value === realValue;
}
}
return false;
});
if (isEmpty(removed)) {
this.value.push(realValue);
data.selected = true;
}
else {
data.selected = false;
}
if (isEmpty(this._value)) {
this._value = null;
}
if (event != null) {
this.updateAllChecked();
}
}
else {
this.open = false;
this._value = realValue;
}
};
/**
* @return {?}
*/
AsiSelectComponent.prototype.toggleSelect = /**
* @return {?}
*/
function () {
this.open = !this.open;
};
/**
* @param {?} value
* @return {?}
*/
AsiSelectComponent.prototype.writeValue = /**
* @param {?} value
* @return {?}
*/
function (value) {
var _this = this;
if (isNaN(value) && isEmpty(value)) {
this._value = null;
}
else {
this._value = value;
}
if (this.multiple) {
if (this._value != null) {
this.selectDatas.forEach(function (data) {
if (data != null) {
data.selected = find(_this.value, function (possibleValue) {
if (possibleValue != null) {
if (_this.trackBy != null) {
return possibleValue[_this.trackBy] === data.value[_this.trackBy];
}