UNPKG

@asi-ngtools/lib

Version:

This project is a little components library, simple to use, which will help you to simplify your project.

1,551 lines (1,537 loc) 364 kB
import { RouterModule } from '@angular/router'; import { cloneDeep } from 'lodash'; import { HttpClient } from '@angular/common/http'; import { DomSanitizer } from '@angular/platform-browser'; import { trigger, style, animate, transition } from '@angular/animations'; import { __spread, __extends, __values, __assign } from 'tslib'; import { CommonModule, isPlatformBrowser, DOCUMENT } from '@angular/common'; import { TranslateModule, TranslateService } from '@ngx-translate/core'; import { FormsModule, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormControl, FormGroupDirective, FormGroupName, Validators } from '@angular/forms'; import moment from 'moment'; import { isObservable, of, from, Subject, Observable, throwError } from 'rxjs'; import { debounceTime, switchMap, tap, map, catchError, first } from 'rxjs/operators'; import { Directive, TemplateRef, Component, Input, EventEmitter, Output, NgModule, Renderer2, ElementRef, forwardRef, Inject, PLATFORM_ID, Injector, ContentChild, ViewChild, HostListener, Injectable, ComponentFactoryResolver, ViewContainerRef, NgZone, HostBinding, ContentChildren, ApplicationRef, Renderer, ChangeDetectorRef, IterableDiffers, ViewChildren, Pipe } from '@angular/core'; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiComponentTemplate = /** @class */ (function () { function AsiComponentTemplate() { } AsiComponentTemplate.decorators = [ { type: 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 = /** @class */ (function () { function AsiComponentTemplateOptionDef(template) { this.template = template; } AsiComponentTemplateOptionDef.decorators = [ { type: Directive, args: [{ selector: '[asiOptionDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateOptionDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateOptionDef; }()); var AsiComponentTemplateTagDef = /** @class */ (function () { function AsiComponentTemplateTagDef(template) { this.template = template; } AsiComponentTemplateTagDef.decorators = [ { type: Directive, args: [{ selector: '[asiTagDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateTagDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateTagDef; }()); var AsiComponentTemplateSelectedDef = /** @class */ (function () { function AsiComponentTemplateSelectedDef(template) { this.template = template; } AsiComponentTemplateSelectedDef.decorators = [ { type: Directive, args: [{ selector: '[asiSelectedDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateSelectedDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateSelectedDef; }()); var AsiComponentTemplateEmptyDef = /** @class */ (function () { function AsiComponentTemplateEmptyDef(template) { this.template = template; } AsiComponentTemplateEmptyDef.decorators = [ { type: Directive, args: [{ selector: '[asiEmptyDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateEmptyDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateEmptyDef; }()); var AsiComponentTemplateClearDef = /** @class */ (function () { function AsiComponentTemplateClearDef(template) { this.template = template; } AsiComponentTemplateClearDef.decorators = [ { type: Directive, args: [{ selector: '[asiClearDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateClearDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateClearDef; }()); var AsiComponentTemplateTableHeaderDef = /** @class */ (function () { function AsiComponentTemplateTableHeaderDef(template) { this.template = template; } AsiComponentTemplateTableHeaderDef.decorators = [ { type: Directive, args: [{ selector: '[asiTableHeaderDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateTableHeaderDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateTableHeaderDef; }()); var AsiComponentTemplateTabHeaderDef = /** @class */ (function () { function AsiComponentTemplateTabHeaderDef(template) { this.template = template; } AsiComponentTemplateTabHeaderDef.decorators = [ { type: Directive, args: [{ selector: '[asiTabHeaderDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateTabHeaderDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateTabHeaderDef; }()); var AsiComponentTemplateNavHeaderDef = /** @class */ (function () { function AsiComponentTemplateNavHeaderDef(template) { this.template = template; } AsiComponentTemplateNavHeaderDef.decorators = [ { type: Directive, args: [{ selector: '[asiNavHeaderDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateNavHeaderDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateNavHeaderDef; }()); var AsiComponentTemplateCollapseHeaderDef = /** @class */ (function () { function AsiComponentTemplateCollapseHeaderDef(template) { this.template = template; } AsiComponentTemplateCollapseHeaderDef.decorators = [ { type: Directive, args: [{ selector: '[asiCollapseHeaderDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateCollapseHeaderDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateCollapseHeaderDef; }()); var AsiComponentTemplateCellDef = /** @class */ (function () { function AsiComponentTemplateCellDef(template) { this.template = template; } AsiComponentTemplateCellDef.decorators = [ { type: Directive, args: [{ selector: '[asiCellDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateCellDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateCellDef; }()); var AsiComponentTemplateColumnDef = /** @class */ (function () { function AsiComponentTemplateColumnDef(template) { this.template = template; } AsiComponentTemplateColumnDef.decorators = [ { type: Directive, args: [{ selector: '[asiColumnDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateColumnDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateColumnDef; }()); var AsiComponentTemplateTreeNodeDef = /** @class */ (function () { function AsiComponentTemplateTreeNodeDef(template) { this.template = template; } AsiComponentTemplateTreeNodeDef.decorators = [ { type: Directive, args: [{ selector: '[asiTreeNodeDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateTreeNodeDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateTreeNodeDef; }()); var AsiComponentTemplateTreeLeafDef = /** @class */ (function () { function AsiComponentTemplateTreeLeafDef(template) { this.template = template; } AsiComponentTemplateTreeLeafDef.decorators = [ { type: Directive, args: [{ selector: '[asiTreeLeafDef]', },] } ]; /** @nocollapse */ AsiComponentTemplateTreeLeafDef.ctorParameters = function () { return [ { type: TemplateRef } ]; }; return AsiComponentTemplateTreeLeafDef; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var DefaultControlValueAccessor = /** @class */ (function () { function DefaultControlValueAccessor() { /** * is enabled/disabled */ this.disabled = false; /** * Event emitted when component value changed */ this.onValueChange = new 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: Input, args: ['value',] }], disabled: [{ type: Input }], onValueChange: [{ type: Output }] }; return DefaultControlValueAccessor; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiNgToolsBaseModule = /** @class */ (function () { function AsiNgToolsBaseModule() { } /** * @return {?} */ AsiNgToolsBaseModule.forRoot = /** * @return {?} */ function () { return { ngModule: AsiNgToolsBaseModule, providers: [TranslateService] }; }; AsiNgToolsBaseModule.decorators = [ { type: NgModule, args: [{ declarations: [ AsiComponentTemplateTabHeaderDef, AsiComponentTemplateTableHeaderDef, AsiComponentTemplateOptionDef, AsiComponentTemplateEmptyDef, AsiComponentTemplateClearDef, AsiComponentTemplateSelectedDef, AsiComponentTemplateColumnDef, AsiComponentTemplateCellDef, AsiComponentTemplateTagDef, AsiComponentTemplateTreeNodeDef, AsiComponentTemplateTreeLeafDef, AsiComponentTemplateNavHeaderDef, AsiComponentTemplateCollapseHeaderDef, AsiComponentTemplate ], imports: [TranslateModule, FormsModule, ReactiveFormsModule, CommonModule, RouterModule], exports: [TranslateModule, FormsModule, ReactiveFormsModule, CommonModule, RouterModule, AsiComponentTemplateTabHeaderDef, AsiComponentTemplateTableHeaderDef, AsiComponentTemplateOptionDef, AsiComponentTemplateEmptyDef, AsiComponentTemplateClearDef, AsiComponentTemplateSelectedDef, AsiComponentTemplateTagDef, AsiComponentTemplateColumnDef, AsiComponentTemplateCellDef, AsiComponentTemplateTreeNodeDef, AsiComponentTemplateTreeLeafDef, AsiComponentTemplateCollapseHeaderDef, AsiComponentTemplate], entryComponents: [], providers: [TranslateService] },] } ]; return AsiNgToolsBaseModule; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiButtonComponent = /** @class */ (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: 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: Renderer2 }, { type: ElementRef } ]; }; AsiButtonComponent.propDecorators = { id: [{ type: Input }], name: [{ type: Input }], type: [{ type: Input }], design: [{ type: Input }], size: [{ type: Input }], disabled: [{ type: Input }] }; return AsiButtonComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiLinkButtonComponent = /** @class */ (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: 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: Renderer2 }, { type: ElementRef } ]; }; AsiLinkButtonComponent.propDecorators = { design: [{ type: Input }], href: [{ type: Input }], target: [{ type: Input }], disabled: [{ type: Input }] }; return AsiLinkButtonComponent; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiButtonModule = /** @class */ (function () { function AsiButtonModule() { } /** * @return {?} */ AsiButtonModule.forRoot = /** * @return {?} */ function () { return { ngModule: AsiButtonModule, providers: [] }; }; AsiButtonModule.decorators = [ { type: NgModule, args: [{ declarations: [AsiButtonComponent, AsiLinkButtonComponent], imports: [AsiNgToolsBaseModule.forRoot()], exports: [AsiNgToolsBaseModule, AsiButtonComponent, AsiLinkButtonComponent], entryComponents: [], providers: [] },] } ]; return AsiButtonModule; }()); /** * @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$1(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$1(object) { return 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 (isObservable(obs)) { return obs; } else if (obs instanceof Promise) { return from(obs); } else { return of(/** @type {?} */ (obs)); } } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiDmyPickerComponent = /** @class */ (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 (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: 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: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return AsiDmyPickerComponent; }), multi: true } ] }] } ]; /** @nocollapse */ AsiDmyPickerComponent.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }, { type: Injector }, { type: Renderer2 }, { type: ElementRef } ]; }; AsiDmyPickerComponent.propDecorators = { label: [{ type: Input }], labelPosition: [{ type: Input }], dayHidden: [{ type: Input }] }; return AsiDmyPickerComponent; }(DefaultControlValueAccessor)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiCheckboxComponent = /** @class */ (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: 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: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return AsiCheckboxComponent; }), multi: true } ] }] } ]; /** @nocollapse */ AsiCheckboxComponent.ctorParameters = function () { return [ { type: Renderer2 }, { type: ElementRef } ]; }; AsiCheckboxComponent.propDecorators = { label: [{ type: Input }], labelPosition: [{ type: Input }], type: [{ type: Input }] }; return AsiCheckboxComponent; }(DefaultControlValueAccessor)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiCheckBoxModule = /** @class */ (function () { function AsiCheckBoxModule() { } /** * @return {?} */ AsiCheckBoxModule.forRoot = /** * @return {?} */ function () { return { ngModule: AsiCheckBoxModule, providers: [] }; }; AsiCheckBoxModule.decorators = [ { type: 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 = /** @class */ (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]; } else { return possibleValue === data.value; } } return false; }) != null; } }); } else { this.selectDatas.forEach(function (data) { if (data != null) { data.selected = false; } }); } this.updateAllChecked(); } this.manageHasValue(); }; /** * @param {?} value * @return {?} */ AsiSelectComponent.prototype.onModelChange = /** * @param {?} value * @return {?} */ function (value) { this.value = value; this.manageHasValue(); }; /** * @return {?} */ AsiSelectComponent.prototype.manageHasValue = /** * @return {?} */ function () { if (this.value != null) { this.renderer.addClass(this.elementRef.nativeElement, 'has-value'); } else { this.renderer.removeClass(this.elementRef.nativeElement, 'has-value'); } }; AsiSelectComponent.decorators = [ { type: Component, args: [{ selector: 'asi-select', host: { 'class': 'asi-component asi-select' }, template: "<label class=\"input-label\" *ngIf=\"label != null\">{{label | translate}}</label>\r\n\r\n<div class=\"asi-select-container\" aria-labelledby=\"select\">\r\n <div class=\"asi-select-header asi-focus-error\" (keyup.esc)=\"toggleSelect()\">\r\n <asi-checkbox *ngIf=\"multiple\" [disabled]=\"disabled\" [ngModel]=\"allChecked\" (onValueChange)=\"checkAll($event)\">\r\n </asi-checkbox>\r\n <button type=\"button\" class=\"item-container\" [disabled]=\"disabled\" (click)=\"toggleSelect()\">\r\n <span>\r\n <div class=\"item\">\r\n <ng-template *ngIf=\"value != null\" [ngTemplateOutlet]=\"selectedDef.template\"\r\n [ngTemplateOutletContext]=\"{$implicit : value}\"></ng-template>\r\n <ng-template *ngIf=\"value == null\" [ngTemplateOutlet]=\"emptyDef?.template\"\r\n [ngTemplateOutletContext]=\"{$implicit : value}\"></ng-template>\r\n </div>\r\n <div class=\"drop-icon-container\">\r\n <span class=\"drop-icon\" [innerHtml]=\"'&#9660;'\"></span>\r\n </div>\r\n </span>\r\n </button>\r\n </div>\r\n\r\n <asi-dropdown [open]=\"open\" (onClose)=\"onDropdownClose()\" dropDownClass=\"asi-select-dropdown\">\r\n <div class=\"drop-down-select\">\r\n <div class=\"drop-down-panel\">\r\n <button type=\"button\" class=\"drop-down-item\" [ngClass]=\"{'empty' : data == null , 'selected' : data?.selected}\"\r\n (keyup.esc)=\"toggleSelect()\" (click)=\"selectValue($event, data)\" *ngFor=\"let data of selectDatas\">\r\n <span class=\"option\">\r\n <asi-checkbox *ngIf=\"multiple && data != null\" [ngModel]=\"data.selected\"\r\n (click)=\"selectValue($event, data)\"></asi-checkbox>\r\n <div class=\"item\" aria-labelledby=\"item\">\r\n <ng-template *ngIf=\"data != null\" [ngTemplateOutlet]=\"optionDef.template\"\r\n [ngTemplateOutletContext]=\"{$implicit : data.value}\"></ng-template>\r\n </div>\r\n </span>\r\n </button>\r\n </div>\r\n </div>\r\n </asi-dropdown>\r\n</div>\r\n", providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(function () { return AsiSelectComponent; }), multi: true } ] }] } ]; /** @nocollapse */ AsiSelectComponent.ctorParameters = function () { return [ { type: Renderer2 }, { type: ElementRef } ]; }; AsiSelectComponent.propDecorators = { label: [{ type: Input }], labelPosition: [{ type: Input }], data: [{ type: Input }], multiple: [{ type: Input }], trackBy: [{ type: Input }], withEmptyValue: [{ type: Input }], optionDef: [{ type: ContentChild, args: [AsiComponentTemplateOptionDef,] }], emptyDef: [{ type: ContentChild, args: [AsiComponentTemplateEmptyDef,] }], selectedDef: [{ type: ContentChild, args: [AsiComponentTemplateSelectedDef,] }] }; return AsiSelectComponent; }(DefaultControlValueAccessor)); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ var AsiDropdownContainer = /** @class */ (function () { function AsiDropdownContainer(document, renderer, elementRef) { this.document = document; this.renderer = renderer; this.elementRef = elementRef; this.calculWidth = true; this.subjectContainer = new Subject(); } /** * @param {?} event * @return {?} */ AsiDropdownContainer.prototype.documentClick = /** * @param {?} event * @return {?} */ function (event) { var _this = this; if (!this.drop.nativeElement.contains(event.target)) { this.asiDropDownService.canClose(this.index, this.canClose).subscribe(function (close) { if (close) { setTimeout(function () { _this.close(); }); } }); } }; /** * @return {?} */ AsiDropdownContainer.prototype.close = /** * @return {?} */ function () { this.subjectContainer.next(this); this.subjectContainer.complete(); }; // Close event when click outside /** * @return {?} */ AsiDropdownContainer.prototype.onClose = /** * @return {?} */ function () { return this.subjectContainer.asObservable(); }; /** * Move the container under htmlElement * @param relativeTo The parent HTMLElement of the dropdown */ /** * Move the container under htmlElement * @param {?} relativeTo The parent HTMLElement of the dropdown * @return {?} */ AsiDropdownContainer.prototype.forElement = /** * Move the container under htmlElement * @param {?} relativeTo The parent HTMLElement of the dropdown * @return {?} */ function (relativeTo) { this.referenceElement = relativeTo; /** @type {?} */ var rectRelativeTo = relativeTo.getBoundingClientRect(); /** @type {?} */ var bodyComputedStyle = getComputedStyle(this.document.body); /** @type {?} */ var bodyMarginTop = parseInt(bodyComputedStyle.marginTop.slice(0, -2), 10); /** @type {?} */ var parentComputedStyle = getComputedStyle(this.elementRef.nativeElement); /** @type {?} */ var parentMarginTop = parseInt(parentComputedStyle.marginTop.slice(0, -2), 10); /** @type {?} */ var parentMarginLeft = parseInt(parentComputedStyle.marginLeft.slice(0, -2), 10); /** @type {?} */ var rectElement = this.elementRef.nativeElement.getBoundingClientRect(); /** @type {?} */ var screenVerticalPosition = rectRelativeTo.top - bodyMarginTop; if (screenVerticalPosition > this.document.body.clientHeight / 2) { /** @type {?} */ var bodyVerticalPosition = rectElement.bottom - rectRelativeTo.top + parentMarginTop; this.drop.nativeElement.style.bottom = bodyVerticalPosition + 'px'; this.drop.nativeElement.style.marginBottom = '2px'; } else { /** @type {?} */ var bodyVerticalPosition = -rectElement.top + rectRelativeTo.top - parentMarginTop + relativeTo.offsetHeight; this.drop.nativeElement.style.top = bodyVerticalPosition + 'px'; this.drop.nativeElement.style.marginTop = '2px'; } this.drop.nativeElement.style.left = rectRelativeTo.left - rectElement.left - parentMarginLeft + 'px'; this.drop.nativeElement.style.width = relativeTo.offsetWidth + 'px'; }; /** * @param asiDrownDown The content to display in the container */ /** * @param {?} asiDrownDown The content to display in the container * @return {?} */ AsiDropdownContainer.prototype.show = /** * @param {?} asiDrownDown The content to display in the container * @return {?} */ function (asiDrownDown) { var _this = this; setTimeout(function () { _this.template = asiDrownDown.contentTemplate; /** @type {?} */ var visibility = _this.drop.nativeElement.style.visibility; _this.drop.nativeElement.style.visibility = 'hidden'; if (asiDrownDown.dropDownClass) { _this.renderer.addClass(_this.elementRef.nativeElement, asiDrownDown.dropDownClass); } setTimeout(function () { /** @type {?} */ var dropContainer = _this.drop.nativeElement.getBoundingClientRect(); if (dropContainer.right > _this.document.documentElement.clientWidth) { _this.drop.nativeElement.style.left = (_this.drop.nativeElement.offsetLeft - dropContainer.right + _this.document.documentElement.clientWidth) + 'px'; } /** @type {?} */ var dropRight = _this.drop.nativeElement.offsetLeft + _this.drop.nativeElement.offsetWidth; if (dropRight > _this.document.documentElement.clientWidth) { _this.drop.nativeElement.style.left = _this.drop.nativeElement.offsetLeft + _this.document.documentElement.scrollLeft - (dropRight - _this.document.documentElement.clientWidth) + 'px'; } _this.drop.nativeElement.style.visibility = visibility; });