ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,689 lines (1,658 loc) • 193 kB
JavaScript
import { CommonModule, DOCUMENT } from '@angular/common';
import { Directive, ElementRef, Renderer2, Input, TemplateRef, ViewContainerRef, NgModule, isDevMode, Optional, Inject, Injectable, SkipSelf, RendererFactory2, ɵɵdefineInjectable, ɵɵinject, NgZone, EventEmitter, Type, InjectionToken, Pipe } from '@angular/core';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { __decorate, __metadata } from 'tslib';
import { coerceBooleanProperty, _isNumberValue, coerceCssPixelValue, coerceElement } from '@angular/cdk/coercion';
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
import { CdkConnectedOverlay, ConnectionPositionPair } from '@angular/cdk/overlay';
import { startOfWeek, startOfMonth, setYear, isSameYear, isSameMonth, isSameDay, isSameHour, isSameMinute, isSameSecond, differenceInCalendarYears, differenceInCalendarMonths, differenceInCalendarDays, differenceInHours, differenceInMinutes, differenceInSeconds, isToday, isValid } from 'date-fns';
import addMonths from 'date-fns/add_months';
import addYears from 'date-fns/add_years';
import setDay from 'date-fns/set_day';
import setMonth from 'date-fns/set_month';
import { Subject, BehaviorSubject } from 'rxjs';
import { auditTime, take, filter, mapTo } from 'rxjs/operators';
import { Platform, PlatformModule } from '@angular/cdk/platform';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzClassListAddDirective {
/**
* @param {?} elementRef
* @param {?} renderer
*/
constructor(elementRef, renderer) {
this.elementRef = elementRef;
this.renderer = renderer;
this.classList = [];
}
/**
* @param {?} list
* @return {?}
*/
set nzClassListAdd(list) {
this.classList.forEach((/**
* @param {?} name
* @return {?}
*/
name => {
this.renderer.removeClass(this.elementRef.nativeElement, name);
}));
list.forEach((/**
* @param {?} name
* @return {?}
*/
name => {
this.renderer.addClass(this.elementRef.nativeElement, name);
}));
this.classList = list;
}
}
NzClassListAddDirective.decorators = [
{ type: Directive, args: [{
selector: '[nzClassListAdd]',
exportAs: 'nzClassListAdd'
},] }
];
/** @nocollapse */
NzClassListAddDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: Renderer2 }
];
NzClassListAddDirective.propDecorators = {
nzClassListAdd: [{ type: Input }]
};
if (false) {
/** @type {?} */
NzClassListAddDirective.prototype.classList;
/**
* @type {?}
* @private
*/
NzClassListAddDirective.prototype.elementRef;
/**
* @type {?}
* @private
*/
NzClassListAddDirective.prototype.renderer;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzStringTemplateOutletDirective {
/**
* @param {?} viewContainer
* @param {?} defaultTemplate
*/
constructor(viewContainer, defaultTemplate) {
this.viewContainer = viewContainer;
this.defaultTemplate = defaultTemplate;
// tslint:disable-next-line:no-any
this.inputTemplate = null;
this.inputViewRef = null;
this.defaultViewRef = null;
// tslint:disable-next-line:no-any
this.nzStringTemplateOutletContext = null;
}
/**
* @param {?} value
* @return {?}
*/
set nzStringTemplateOutlet(value) {
if (value instanceof TemplateRef) {
this.isTemplate = true;
this.inputTemplate = value;
}
else {
this.isTemplate = false;
}
}
/**
* @return {?}
*/
recreateView() {
if (!this.isTemplate) {
/** use default template when input is string **/
if (!this.defaultViewRef) {
if (this.defaultTemplate) {
this.defaultViewRef = this.viewContainer.createEmbeddedView(this.defaultTemplate, this.nzStringTemplateOutletContext);
}
}
}
else {
/** use input template when input is templateRef **/
if (!this.inputViewRef) {
if (this.inputTemplate) {
this.inputViewRef = this.viewContainer.createEmbeddedView(this.inputTemplate, this.nzStringTemplateOutletContext);
}
}
}
}
// tslint:disable-next-line:no-any
/**
* @private
* @param {?} value
* @return {?}
*/
getType(value) {
if (value instanceof TemplateRef) {
return 'template';
}
else {
return 'string';
}
}
/**
* @private
* @param {?} changes
* @return {?}
*/
shouldRecreateView(changes) {
const { nzStringTemplateOutletContext, nzStringTemplateOutlet } = changes;
/** @type {?} */
let shouldOutletRecreate = false;
if (nzStringTemplateOutlet) {
if (nzStringTemplateOutlet.firstChange) {
shouldOutletRecreate = true;
}
else {
/** @type {?} */
const previousOutletType = this.getType(nzStringTemplateOutlet.previousValue);
/** @type {?} */
const currentOutletType = this.getType(nzStringTemplateOutlet.currentValue);
shouldOutletRecreate = !(previousOutletType === 'string' && currentOutletType === 'string');
}
}
/** @type {?} */
const shouldContextRecreate = nzStringTemplateOutletContext && this.hasContextShapeChanged(nzStringTemplateOutletContext);
return shouldContextRecreate || shouldOutletRecreate;
}
/**
* @private
* @param {?} ctxChange
* @return {?}
*/
hasContextShapeChanged(ctxChange) {
/** @type {?} */
const prevCtxKeys = Object.keys(ctxChange.previousValue || {});
/** @type {?} */
const currCtxKeys = Object.keys(ctxChange.currentValue || {});
if (prevCtxKeys.length === currCtxKeys.length) {
for (const propName of currCtxKeys) {
if (prevCtxKeys.indexOf(propName) === -1) {
return true;
}
}
return false;
}
else {
return true;
}
}
// tslint:disable-next-line:no-any
/**
* @private
* @param {?} ctx
* @return {?}
*/
updateExistingContext(ctx) {
for (const propName of Object.keys(ctx)) {
// tslint:disable-next-line:no-any
((/** @type {?} */ ((/** @type {?} */ (this.inputViewRef)).context)))[propName] = this.nzStringTemplateOutletContext[propName];
}
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
/** @type {?} */
const recreateView = this.shouldRecreateView(changes);
if (recreateView) {
if (this.viewContainer) {
this.viewContainer.clear();
this.defaultViewRef = null;
this.inputViewRef = null;
}
this.recreateView();
}
else {
if (this.inputViewRef && this.nzStringTemplateOutletContext) {
this.updateExistingContext(this.nzStringTemplateOutletContext);
}
}
}
}
NzStringTemplateOutletDirective.decorators = [
{ type: Directive, args: [{
selector: '[nzStringTemplateOutlet]',
exportAs: 'nzStringTemplateOutlet'
},] }
];
/** @nocollapse */
NzStringTemplateOutletDirective.ctorParameters = () => [
{ type: ViewContainerRef },
{ type: TemplateRef }
];
NzStringTemplateOutletDirective.propDecorators = {
nzStringTemplateOutletContext: [{ type: Input }],
nzStringTemplateOutlet: [{ type: Input }]
};
if (false) {
/**
* @type {?}
* @private
*/
NzStringTemplateOutletDirective.prototype.isTemplate;
/**
* @type {?}
* @private
*/
NzStringTemplateOutletDirective.prototype.inputTemplate;
/**
* @type {?}
* @private
*/
NzStringTemplateOutletDirective.prototype.inputViewRef;
/**
* @type {?}
* @private
*/
NzStringTemplateOutletDirective.prototype.defaultViewRef;
/** @type {?} */
NzStringTemplateOutletDirective.prototype.nzStringTemplateOutletContext;
/**
* @type {?}
* @private
*/
NzStringTemplateOutletDirective.prototype.viewContainer;
/**
* @type {?}
* @private
*/
NzStringTemplateOutletDirective.prototype.defaultTemplate;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzAddOnModule {
}
NzAddOnModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
exports: [NzStringTemplateOutletDirective, NzClassListAddDirective],
declarations: [NzStringTemplateOutletDirective, NzClassListAddDirective]
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
class AnimationDuration {
}
AnimationDuration.SLOW = '0.3s'; // Modal
// Modal
AnimationDuration.BASE = '0.2s';
AnimationDuration.FAST = '0.1s'; // Tooltip
if (false) {
/** @type {?} */
AnimationDuration.SLOW;
/** @type {?} */
AnimationDuration.BASE;
/** @type {?} */
AnimationDuration.FAST;
}
class AnimationCurves {
}
AnimationCurves.EASE_BASE_OUT = 'cubic-bezier(0.7, 0.3, 0.1, 1)';
AnimationCurves.EASE_BASE_IN = 'cubic-bezier(0.9, 0, 0.3, 0.7)';
AnimationCurves.EASE_OUT = 'cubic-bezier(0.215, 0.61, 0.355, 1)';
AnimationCurves.EASE_IN = 'cubic-bezier(0.55, 0.055, 0.675, 0.19)';
AnimationCurves.EASE_IN_OUT = 'cubic-bezier(0.645, 0.045, 0.355, 1)';
AnimationCurves.EASE_OUT_BACK = 'cubic-bezier(0.12, 0.4, 0.29, 1.46)';
AnimationCurves.EASE_IN_BACK = 'cubic-bezier(0.71, -0.46, 0.88, 0.6)';
AnimationCurves.EASE_IN_OUT_BACK = 'cubic-bezier(0.71, -0.46, 0.29, 1.46)';
AnimationCurves.EASE_OUT_CIRC = 'cubic-bezier(0.08, 0.82, 0.17, 1)';
AnimationCurves.EASE_IN_CIRC = 'cubic-bezier(0.6, 0.04, 0.98, 0.34)';
AnimationCurves.EASE_IN_OUT_CIRC = 'cubic-bezier(0.78, 0.14, 0.15, 0.86)';
AnimationCurves.EASE_OUT_QUINT = 'cubic-bezier(0.23, 1, 0.32, 1)';
AnimationCurves.EASE_IN_QUINT = 'cubic-bezier(0.755, 0.05, 0.855, 0.06)';
AnimationCurves.EASE_IN_OUT_QUINT = 'cubic-bezier(0.86, 0, 0.07, 1)';
if (false) {
/** @type {?} */
AnimationCurves.EASE_BASE_OUT;
/** @type {?} */
AnimationCurves.EASE_BASE_IN;
/** @type {?} */
AnimationCurves.EASE_OUT;
/** @type {?} */
AnimationCurves.EASE_IN;
/** @type {?} */
AnimationCurves.EASE_IN_OUT;
/** @type {?} */
AnimationCurves.EASE_OUT_BACK;
/** @type {?} */
AnimationCurves.EASE_IN_BACK;
/** @type {?} */
AnimationCurves.EASE_IN_OUT_BACK;
/** @type {?} */
AnimationCurves.EASE_OUT_CIRC;
/** @type {?} */
AnimationCurves.EASE_IN_CIRC;
/** @type {?} */
AnimationCurves.EASE_IN_OUT_CIRC;
/** @type {?} */
AnimationCurves.EASE_OUT_QUINT;
/** @type {?} */
AnimationCurves.EASE_IN_QUINT;
/** @type {?} */
AnimationCurves.EASE_IN_OUT_QUINT;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const collapseMotion = trigger('collapseMotion', [
state('expanded', style({ height: '*' })),
state('collapsed', style({ height: 0, overflow: 'hidden' })),
state('hidden', style({ height: 0, overflow: 'hidden', borderTopWidth: '0' })),
transition('expanded => collapsed', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('expanded => hidden', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('collapsed => expanded', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`)),
transition('hidden => expanded', animate(`150ms ${AnimationCurves.EASE_IN_OUT}`))
]);
/** @type {?} */
const treeCollapseMotion = trigger('treeCollapseMotion', [
transition(':leave', [
style({ overflow: 'hidden' }),
animate(`150ms ${AnimationCurves.EASE_IN_OUT}`, style({ height: 0 }))
]),
transition(':enter', [
style({ overflow: 'hidden', height: 0 }),
animate(`150ms ${AnimationCurves.EASE_IN_OUT}`, style({ overflow: 'hidden', height: '*' }))
])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const fadeMotion = trigger('fadeMotion', [
transition(':enter', [style({ opacity: 0 }), animate(`${AnimationDuration.BASE}`, style({ opacity: 1 }))]),
transition(':leave', [style({ opacity: 1 }), animate(`${AnimationDuration.BASE}`, style({ opacity: 0 }))])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const helpMotion = trigger('helpMotion', [
transition(':enter', [
style({
opacity: 0,
transform: 'translateY(-5px)'
}),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_OUT}`, style({
opacity: 1,
transform: 'translateY(0)'
}))
]),
transition(':leave', [
style({
opacity: 1,
transform: 'translateY(0)'
}),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_OUT}`, style({
opacity: 0,
transform: 'translateY(-5px)'
}))
])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const moveUpMotion = trigger('moveUpMotion', [
transition('* => enter', [
style({
transformOrigin: '0 0',
transform: 'translateY(-100%)',
opacity: 0
}),
animate(`${AnimationDuration.BASE}`, style({
transformOrigin: '0 0',
transform: 'translateY(0%)',
opacity: 1
}))
]),
transition('* => leave', [
style({
transformOrigin: '0 0',
transform: 'translateY(0%)',
opacity: 1
}),
animate(`${AnimationDuration.BASE}`, style({
transformOrigin: '0 0',
transform: 'translateY(-100%)',
opacity: 0
}))
])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const notificationMotion = trigger('notificationMotion', [
state('enterRight', style({ opacity: 1, transform: 'translateX(0)' })),
transition('* => enterRight', [style({ opacity: 0, transform: 'translateX(5%)' }), animate('100ms linear')]),
state('enterLeft', style({ opacity: 1, transform: 'translateX(0)' })),
transition('* => enterLeft', [style({ opacity: 0, transform: 'translateX(-5%)' }), animate('100ms linear')]),
state('leave', style({
opacity: 0,
transform: 'scaleY(0.8)',
transformOrigin: '0% 0%'
})),
transition('* => leave', [
style({
opacity: 1,
transform: 'scaleY(1)',
transformOrigin: '0% 0%'
}),
animate('100ms linear')
])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const ANIMATION_TRANSITION_IN = `${AnimationDuration.BASE} ${AnimationCurves.EASE_OUT_QUINT}`;
/** @type {?} */
const ANIMATION_TRANSITION_OUT = `${AnimationDuration.BASE} ${AnimationCurves.EASE_IN_QUINT}`;
/** @type {?} */
const slideMotion = trigger('slideMotion', [
state('bottom', style({
opacity: 1,
transform: 'scaleY(1)',
transformOrigin: '0% 0%'
})),
state('top', style({
opacity: 1,
transform: 'scaleY(1)',
transformOrigin: '0% 100%'
})),
transition('void => bottom', [
style({
opacity: 0,
transform: 'scaleY(0.8)',
transformOrigin: '0% 0%'
}),
animate(ANIMATION_TRANSITION_IN)
]),
transition('bottom => void', [
animate(ANIMATION_TRANSITION_OUT, style({
opacity: 0,
transform: 'scaleY(0.8)',
transformOrigin: '0% 0%'
}))
]),
transition('void => top', [
style({
opacity: 0,
transform: 'scaleY(0.8)',
transformOrigin: '0% 100%'
}),
animate(ANIMATION_TRANSITION_IN)
]),
transition('top => void', [
animate(ANIMATION_TRANSITION_OUT, style({
opacity: 0,
transform: 'scaleY(0.8)',
transformOrigin: '0% 100%'
}))
])
]);
/** @type {?} */
const slideAlertMotion = trigger('slideAlertMotion', [
transition(':leave', [
style({ opacity: 1, transform: 'scaleY(1)', transformOrigin: '0% 0%' }),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_OUT_CIRC}`, style({
opacity: 0,
transform: 'scaleY(0)',
transformOrigin: '0% 0%'
}))
])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const zoomMotion = trigger('zoomMotion', [
transition(':enter', [
style({ opacity: 0, transform: 'scale(0.2)' }),
animate(`${AnimationDuration.BASE} ${AnimationCurves.EASE_OUT_CIRC}`, style({
opacity: 1,
transform: 'scale(1)'
}))
]),
transition(':leave', [
style({ opacity: 1, transform: 'scale(1)' }),
animate(`${AnimationDuration.BASE} ${AnimationCurves.EASE_IN_OUT_CIRC}`, style({
opacity: 0,
transform: 'scale(0.2)'
}))
])
]);
/** @type {?} */
const zoomBigMotion = trigger('zoomBigMotion', [
transition('void => active', [
style({ opacity: 0, transform: 'scale(0.8)' }),
animate(`${AnimationDuration.BASE} ${AnimationCurves.EASE_OUT_CIRC}`, style({
opacity: 1,
transform: 'scale(1)'
}))
]),
transition('active => void', [
style({ opacity: 1, transform: 'scale(1)' }),
animate(`${AnimationDuration.BASE} ${AnimationCurves.EASE_IN_OUT_CIRC}`, style({
opacity: 0,
transform: 'scale(0.8)'
}))
])
]);
/** @type {?} */
const zoomBadgeMotion = trigger('zoomBadgeMotion', [
transition(':enter', [
style({ opacity: 0, transform: 'scale(0) translate(50%, -50%)' }),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_OUT_BACK}`, style({
opacity: 1,
transform: 'scale(1) translate(50%, -50%)'
}))
]),
transition(':leave', [
style({ opacity: 1, transform: 'scale(1) translate(50%, -50%)' }),
animate(`${AnimationDuration.SLOW} ${AnimationCurves.EASE_IN_BACK}`, style({
opacity: 0,
transform: 'scale(0) translate(50%, -50%)'
}))
])
]);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/** @type {?} */
const environment = {
isTestMode: false
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const record = {};
/** @type {?} */
const PREFIX = '[NG-ZORRO]:';
/**
* @param {...?} args
* @return {?}
*/
function notRecorded(...args) {
/** @type {?} */
const asRecord = args.reduce((/**
* @param {?} acc
* @param {?} c
* @return {?}
*/
(acc, c) => acc + c.toString()), '');
if (record[asRecord]) {
return false;
}
else {
record[asRecord] = true;
return true;
}
}
/**
* @param {?} consoleFunc
* @param {...?} args
* @return {?}
*/
function consoleCommonBehavior(consoleFunc, ...args) {
if (environment.isTestMode || (isDevMode() && notRecorded(...args))) {
consoleFunc(...args);
}
}
// Warning should only be printed in dev mode and only once.
/** @type {?} */
const warn = (/**
* @param {...?} args
* @return {?}
*/
(...args) => consoleCommonBehavior((/**
* @param {...?} arg
* @return {?}
*/
(...arg) => console.warn(PREFIX, ...arg)), ...args));
/** @type {?} */
const warnDeprecation = (/**
* @param {...?} args
* @return {?}
*/
(...args) => {
if (!environment.isTestMode) {
/** @type {?} */
const stack = new Error().stack;
return consoleCommonBehavior((/**
* @param {...?} arg
* @return {?}
*/
(...arg) => console.warn(PREFIX, 'deprecated:', ...arg, stack)), ...args);
}
else {
return (/**
* @return {?}
*/
() => { });
}
});
// Log should only be printed in dev mode.
/** @type {?} */
const log = (/**
* @param {...?} args
* @return {?}
*/
(...args) => {
if (isDevMode()) {
console.log(PREFIX, ...args);
}
});
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} value
* @return {?}
*/
function toBoolean(value) {
return coerceBooleanProperty(value);
}
/**
* @param {?} value
* @param {?=} fallbackValue
* @return {?}
*/
function toNumber(value, fallbackValue = 0) {
return _isNumberValue(value) ? Number(value) : fallbackValue;
}
/**
* @param {?} value
* @return {?}
*/
function toCssPixel(value) {
return coerceCssPixelValue(value);
}
// tslint:disable no-any
// tslint:disable no-invalid-this
/**
* Get the function-property type's value
* @template T
* @param {?} prop
* @param {...?} args
* @return {?}
*/
function valueFunctionProp(prop, ...args) {
return typeof prop === 'function' ? prop(...args) : prop;
}
/**
* @template T, D
* @param {?} name
* @param {?} fallback
* @return {?}
*/
function propDecoratorFactory(name, fallback) {
/**
* @param {?} target
* @param {?} propName
* @param {?=} originalDescriptor
* @return {?}
*/
function propDecorator(target, propName, originalDescriptor) {
/** @type {?} */
const privatePropName = `$$__${propName}`;
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
warn(`The prop "${privatePropName}" is already exist, it will be overrided by ${name} decorator.`);
}
Object.defineProperty(target, privatePropName, {
configurable: true,
writable: true
});
return {
/**
* @return {?}
*/
get() {
return originalDescriptor && originalDescriptor.get
? originalDescriptor.get.bind(this)()
: this[privatePropName];
},
/**
* @param {?} value
* @return {?}
*/
set(value) {
if (originalDescriptor && originalDescriptor.set) {
originalDescriptor.set.bind(this)(fallback(value));
}
this[privatePropName] = fallback(value);
}
};
}
return propDecorator;
}
/**
* Input decorator that handle a prop to do get/set automatically with toBoolean
*
* Why not using \@InputBoolean alone without \@Input? AOT needs \@Input to be visible
*
* \@howToUse
* ```
* \@Input() \@InputBoolean() visible: boolean = false;
*
* // Act as below:
* // \@Input()
* // get visible() { return this.__visible; }
* // set visible(value) { this.__visible = value; }
* // __visible = false;
* ```
* @return {?}
*/
function InputBoolean() {
return propDecoratorFactory('InputBoolean', toBoolean);
}
/**
* @return {?}
*/
function InputCssPixel() {
return propDecoratorFactory('InputCssPixel', toCssPixel);
}
/**
* @return {?}
*/
function InputNumber() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputNumber', toNumber);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const DISABLED_CLASSNAME = 'nz-animate-disabled';
class NzNoAnimationDirective {
/**
* @param {?} element
* @param {?} renderer
* @param {?} animationType
*/
constructor(element, renderer, animationType) {
this.element = element;
this.renderer = renderer;
this.animationType = animationType;
this.nzNoAnimation = false;
}
/**
* @return {?}
*/
ngOnChanges() {
this.updateClass();
}
/**
* @return {?}
*/
ngAfterViewInit() {
this.updateClass();
}
/**
* @private
* @return {?}
*/
updateClass() {
/** @type {?} */
const element = coerceElement(this.element);
if (!element) {
return;
}
if (this.nzNoAnimation || this.animationType === 'NoopAnimations') {
this.renderer.addClass(element, DISABLED_CLASSNAME);
}
else {
this.renderer.removeClass(element, DISABLED_CLASSNAME);
}
}
}
NzNoAnimationDirective.decorators = [
{ type: Directive, args: [{
selector: '[nzNoAnimation]',
exportAs: 'nzNoAnimation'
},] }
];
/** @nocollapse */
NzNoAnimationDirective.ctorParameters = () => [
{ type: ElementRef },
{ type: Renderer2 },
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
];
NzNoAnimationDirective.propDecorators = {
nzNoAnimation: [{ type: Input }]
};
__decorate([
InputBoolean(),
__metadata("design:type", Boolean)
], NzNoAnimationDirective.prototype, "nzNoAnimation", void 0);
if (false) {
/** @type {?} */
NzNoAnimationDirective.prototype.nzNoAnimation;
/**
* @type {?}
* @private
*/
NzNoAnimationDirective.prototype.element;
/**
* @type {?}
* @private
*/
NzNoAnimationDirective.prototype.renderer;
/**
* @type {?}
* @private
*/
NzNoAnimationDirective.prototype.animationType;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzNoAnimationModule {
}
NzNoAnimationModule.decorators = [
{ type: NgModule, args: [{
declarations: [NzNoAnimationDirective],
exports: [NzNoAnimationDirective],
imports: [CommonModule]
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzConnectedOverlayDirective {
/**
* @param {?} cdkConnectedOverlay
*/
constructor(cdkConnectedOverlay) {
this.cdkConnectedOverlay = cdkConnectedOverlay;
this.cdkConnectedOverlay.backdropClass = 'nz-overlay-transparent-backdrop';
}
}
NzConnectedOverlayDirective.decorators = [
{ type: Directive, args: [{
selector: '[cdkConnectedOverlay][nzConnectedOverlay]',
exportAs: 'nzConnectedOverlay'
},] }
];
/** @nocollapse */
NzConnectedOverlayDirective.ctorParameters = () => [
{ type: CdkConnectedOverlay }
];
if (false) {
/**
* @type {?}
* @private
*/
NzConnectedOverlayDirective.prototype.cdkConnectedOverlay;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
class NzOverlayModule {
}
NzOverlayModule.decorators = [
{ type: NgModule, args: [{
declarations: [NzConnectedOverlayDirective],
exports: [NzConnectedOverlayDirective]
},] }
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
const POSITION_MAP = {
top: new ConnectionPositionPair({ originX: 'center', originY: 'top' }, { overlayX: 'center', overlayY: 'bottom' }),
topCenter: new ConnectionPositionPair({ originX: 'center', originY: 'top' }, { overlayX: 'center', overlayY: 'bottom' }),
topLeft: new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'start', overlayY: 'bottom' }),
topRight: new ConnectionPositionPair({ originX: 'end', originY: 'top' }, { overlayX: 'end', overlayY: 'bottom' }),
right: new ConnectionPositionPair({ originX: 'end', originY: 'center' }, { overlayX: 'start', overlayY: 'center' }),
rightTop: new ConnectionPositionPair({ originX: 'end', originY: 'top' }, { overlayX: 'start', overlayY: 'top' }),
rightBottom: new ConnectionPositionPair({ originX: 'end', originY: 'bottom' }, { overlayX: 'start', overlayY: 'bottom' }),
bottom: new ConnectionPositionPair({ originX: 'center', originY: 'bottom' }, { overlayX: 'center', overlayY: 'top' }),
bottomCenter: new ConnectionPositionPair({ originX: 'center', originY: 'bottom' }, { overlayX: 'center', overlayY: 'top' }),
bottomLeft: new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'top' }),
bottomRight: new ConnectionPositionPair({ originX: 'end', originY: 'bottom' }, { overlayX: 'end', overlayY: 'top' }),
left: new ConnectionPositionPair({ originX: 'start', originY: 'center' }, { overlayX: 'end', overlayY: 'center' }),
leftTop: new ConnectionPositionPair({ originX: 'start', originY: 'top' }, { overlayX: 'end', overlayY: 'top' }),
leftBottom: new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'end', overlayY: 'bottom' })
};
/** @type {?} */
const DEFAULT_TOOLTIP_POSITIONS = [POSITION_MAP.top, POSITION_MAP.right, POSITION_MAP.bottom, POSITION_MAP.left];
/** @type {?} */
const DEFAULT_DROPDOWN_POSITIONS = [
POSITION_MAP.bottomLeft,
POSITION_MAP.bottomRight,
POSITION_MAP.topRight,
POSITION_MAP.topLeft
];
/** @type {?} */
const DEFAULT_SUBMENU_POSITIONS = [POSITION_MAP.rightTop, POSITION_MAP.leftTop];
/** @type {?} */
const DEFAULT_MENTION_TOP_POSITIONS = [
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'start', overlayY: 'bottom' }),
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'end', overlayY: 'bottom' })
];
/** @type {?} */
const DEFAULT_MENTION_BOTTOM_POSITIONS = [
POSITION_MAP.bottomLeft,
new ConnectionPositionPair({ originX: 'start', originY: 'bottom' }, { overlayX: 'end', overlayY: 'top' })
];
/**
* @param {?} position
* @return {?}
*/
function getPlacementName(position) {
/** @type {?} */
const keyList = ['originX', 'originY', 'overlayX', 'overlayY'];
for (const placement in POSITION_MAP) {
// @ts-ignore
if (keyList.every((/**
* @param {?} key
* @return {?}
*/
key => position.connectionPair[key] === POSITION_MAP[placement][key]))) {
return placement;
}
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} rangeValue
* @return {?}
*/
function sortRangeValue(rangeValue) {
if (Array.isArray(rangeValue)) {
const [start, end] = rangeValue;
return start && end && start.isAfterSecond(end) ? [end, start] : [start, end];
}
return rangeValue;
}
/**
* Wrapping kind APIs for date operating and unify
* NOTE: every new API return new CandyDate object without side effects to the former Date object
* NOTE: most APIs are based on local time other than customized locale id (this needs tobe support in future)
* TODO: support format() against to angular's core API
*/
class CandyDate {
// locale: string; // Custom specified locale ID
/**
* @param {?=} date
*/
constructor(date) {
if (date) {
if (date instanceof Date) {
this.nativeDate = date;
}
else if (typeof date === 'string' || typeof date === 'number') {
warn('The string type is not recommended for date-picker, use "Date" type');
this.nativeDate = new Date(date);
}
else {
throw new Error('The input date type is not supported ("Date" is now recommended)');
}
}
else {
this.nativeDate = new Date();
}
}
// getLocale(): string {
// return this.locale;
// }
// setLocale(locale: string): CandyDate {
// this.locale = locale;
// return this;
// }
/**
* @param {?=} options
* @return {?}
*/
calendarStart(options) {
return new CandyDate(startOfWeek(startOfMonth(this.nativeDate), options));
}
// ---------------------------------------------------------------------
// | Native shortcuts
// ---------------------------------------------------------------------
/**
* @return {?}
*/
getYear() {
return this.nativeDate.getFullYear();
}
/**
* @return {?}
*/
getMonth() {
return this.nativeDate.getMonth();
}
/**
* @return {?}
*/
getDay() {
return this.nativeDate.getDay();
}
/**
* @return {?}
*/
getTime() {
return this.nativeDate.getTime();
}
/**
* @return {?}
*/
getDate() {
return this.nativeDate.getDate();
}
/**
* @return {?}
*/
getHours() {
return this.nativeDate.getHours();
}
/**
* @return {?}
*/
getMinutes() {
return this.nativeDate.getMinutes();
}
/**
* @return {?}
*/
getSeconds() {
return this.nativeDate.getSeconds();
}
/**
* @return {?}
*/
getMilliseconds() {
return this.nativeDate.getMilliseconds();
}
// ---------------------------------------------------------------------
// | New implementing APIs
// ---------------------------------------------------------------------
/**
* @return {?}
*/
clone() {
return new CandyDate(new Date(this.nativeDate));
}
/**
* @param {?} hour
* @param {?} minute
* @param {?} second
* @return {?}
*/
setHms(hour, minute, second) {
/** @type {?} */
const date = new Date(this.nativeDate);
date.setHours(hour, minute, second);
return new CandyDate(date);
}
/**
* @param {?} year
* @return {?}
*/
setYear(year) {
return new CandyDate(setYear(this.nativeDate, year));
}
/**
* @param {?} amount
* @return {?}
*/
addYears(amount) {
return new CandyDate(addYears(this.nativeDate, amount));
}
// NOTE: month starts from 0
// NOTE: Don't use the native API for month manipulation as it not restrict the date when it overflows, eg. (new Date('2018-7-31')).setMonth(1) will be date of 2018-3-03 instead of 2018-2-28
/**
* @param {?} month
* @return {?}
*/
setMonth(month) {
return new CandyDate(setMonth(this.nativeDate, month));
}
/**
* @param {?} amount
* @return {?}
*/
addMonths(amount) {
return new CandyDate(addMonths(this.nativeDate, amount));
}
/**
* @param {?} day
* @param {?=} options
* @return {?}
*/
setDay(day, options) {
return new CandyDate(setDay(this.nativeDate, day, options));
}
/**
* @param {?} amount
* @return {?}
*/
setDate(amount) {
/** @type {?} */
const date = new Date(this.nativeDate);
date.setDate(amount);
return new CandyDate(date);
}
/**
* @param {?} amount
* @return {?}
*/
addDays(amount) {
return this.setDate(this.getDate() + amount);
}
/**
* @param {?} date
* @param {?=} grain
* @return {?}
*/
isSame(date, grain = 'day') {
/** @type {?} */
let fn;
switch (grain) {
case 'year':
fn = isSameYear;
break;
case 'month':
fn = isSameMonth;
break;
case 'day':
fn = isSameDay;
break;
case 'hour':
fn = isSameHour;
break;
case 'minute':
fn = isSameMinute;
break;
case 'second':
fn = isSameSecond;
break;
default:
fn = isSameDay;
break;
}
return fn(this.nativeDate, this.toNativeDate(date));
}
/**
* @param {?} date
* @return {?}
*/
isSameYear(date) {
return this.isSame(date, 'year');
}
/**
* @param {?} date
* @return {?}
*/
isSameMonth(date) {
return this.isSame(date, 'month');
}
/**
* @param {?} date
* @return {?}
*/
isSameDay(date) {
return this.isSame(date, 'day');
}
/**
* @param {?} date
* @return {?}
*/
isSameHour(date) {
return this.isSame(date, 'hour');
}
/**
* @param {?} date
* @return {?}
*/
isSameMinute(date) {
return this.isSame(date, 'minute');
}
/**
* @param {?} date
* @return {?}
*/
isSameSecond(date) {
return this.isSame(date, 'second');
}
/**
* @param {?} date
* @param {?=} grain
* @param {?=} isBefore
* @return {?}
*/
compare(date, grain = 'day', isBefore = true) {
if (date === null) {
return false;
}
/** @type {?} */
let fn;
switch (grain) {
case 'year':
fn = differenceInCalendarYears;
break;
case 'month':
fn = differenceInCalendarMonths;
break;
case 'day':
fn = differenceInCalendarDays;
break;
case 'hour':
fn = differenceInHours;
break;
case 'minute':
fn = differenceInMinutes;
break;
case 'second':
fn = differenceInSeconds;
break;
default:
fn = differenceInCalendarDays;
break;
}
return isBefore
? fn(this.nativeDate, this.toNativeDate(date)) < 0
: fn(this.nativeDate, this.toNativeDate(date)) > 0;
}
/**
* @param {?} date
* @return {?}
*/
isBeforeYear(date) {
return this.compare(date, 'year');
}
/**
* @param {?} date
* @return {?}
*/
isBeforeMonth(date) {
return this.compare(date, 'month');
}
/**
* @param {?} date
* @return {?}
*/
isBeforeDay(date) {
return this.compare(date, 'day');
}
/**
* @param {?} date
* @return {?}
*/
isBeforeHour(date) {
return this.compare(date, 'hour');
}
/**
* @param {?} date
* @return {?}
*/
isBeforeMinute(date) {
return this.compare(date, 'minute');
}
/**
* @param {?} date
* @return {?}
*/
isBeforeSecond(date) {
return this.compare(date, 'second');
}
// TODO: isBefore
/**
* @param {?} date
* @return {?}
*/
isAfterYear(date) {
return this.compare(date, 'year', false);
}
/**
* @param {?} date
* @return {?}
*/
isAfterMonth(date) {
return this.compare(date, 'month', false);
}
/**
* @param {?} date
* @return {?}
*/
isAfterDay(date) {
return this.compare(date, 'day', false);
}
/**
* @param {?} date
* @return {?}
*/
isAfterHour(date) {
return this.compare(date, 'hour', false);
}
/**
* @param {?} date
* @return {?}
*/
isAfterMinute(date) {
return this.compare(date, 'minute', false);
}
/**
* @param {?} date
* @return {?}
*/
isAfterSecond(date) {
return this.compare(date, 'second', false);
}
// Equal to today accurate to "day"
/**
* @return {?}
*/
isToday() {
return isToday(this.nativeDate);
}
/**
* @return {?}
*/
isValid() {
return isValid(this.nativeDate);
}
// tslint:disable-next-line: no-any
/**
* @private
* @param {?} date
* @return {?}
*/
toNativeDate(date) {
return date instanceof CandyDate ? date.nativeDate : date;
}
}
if (false) {
/** @type {?} */
CandyDate.prototype.nativeDate;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
/** @type {?} */
const timeUnits = [
['Y', 1000 * 60 * 60 * 24 * 365],
['M', 1000 * 60 * 60 * 24 * 30],
['D', 1000 * 60 * 60 * 24],
['H', 1000 * 60 * 60],
['m', 1000 * 60],
['s', 1000],
['S', 1] // million seconds
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
// tslint:disable:no-any typedef no-invalid-this
/** @type {?} */
const availablePrefixes = ['moz', 'ms', 'webkit'];
/**
* @return {?}
*/
function requestAnimationFramePolyfill() {
/** @type {?} */
let lastTime = 0;
return (/**
* @param {?} callback
* @return {?}
*/
function (callback) {
/** @type {?} */
const currTime = new Date().getTime();
/** @type {?} */
const timeToCall = Math.max(0, 16 - (currTime - lastTime));
/** @type {?} */
const id = setTimeout((/**
* @return {?}
*/
() => {
callback(currTime + timeToCall);
}), timeToCall);
lastTime = currTime + timeToCall;
return id;
});
}
/**
* @return {?}
*/
function getRequestAnimationFrame() {
if (typeof window === 'undefined') {
return (/**
* @return {?}
*/
() => 0);
}
if (window.requestAnimationFrame) {
// https://github.com/vuejs/vue/issues/4465
return window.requestAnimationFrame.bind(window);
}
/** @type {?} */
const prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
key => `${key}RequestAnimationFrame` in window))[0];
return prefix ? ((/** @type {?} */ (window)))[`${prefix}RequestAnimationFrame`] : requestAnimationFramePolyfill();
}
/**
* @param {?} id
* @return {?}
*/
function cancelRequestAnimationFrame(id) {
if (typeof window === 'undefined') {
return null;
}
if (window.cancelAnimationFrame) {
return window.cancelAnimationFrame(id);
}
/** @type {?} */
const prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
key => `${key}CancelAnimationFrame` in window || `${key}CancelRequestAnimationFrame` in window))[0];
return prefix
? (((/** @type {?} */ (window)))[`${prefix}CancelAnimationFrame`] || ((/** @type {?} */ (window)))[`${prefix}CancelRequestAnimationFrame`])
// @ts-ignore
.call(this, id)
: clearTimeout(id);
}
/** @type {?} */
const reqAnimFrame = getRequestAnimationFrame();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} t
* @param {?} b
* @param {?} c
* @param {?} d
* @return {?}
*/
function easeInOutCubic(t, b, c, d) {
/** @type {?} */
const cc = c - b;
/** @type {?} */
let tt = t / (d / 2);
if (tt < 1) {
return (cc / 2) * tt * tt * tt + b;
}
else {
return (cc / 2) * ((tt -= 2) * tt * tt + 2) + b;
}
}
class NzScrollService {
/* tslint:disable-next-line:no-any */
/**
* @param {?} doc
*/
constructor(doc) {
this.doc = doc;
}
/**
* Set the position of the scroll bar of `el`.
* @param {?} el
* @param {?=} topValue
* @return {?}
*/
setScrollTop(el, topValue = 0) {
if (el === window) {
this.doc.body.scrollTop = topValue;
(/** @type {?} */ (this.doc.documentElement)).scrollTop = topValue;
}
else {
((/** @type {?} */ (el))).scrollTop = topValue;
}
}
/**
* Get position of `el` against window.
* @param {?} el
* @return {?}
*/
getOffset(el) {
/** @type {?} */
const ret = {
top: 0,
left: 0
};
if (!el || !el.getClientRects().length) {
return ret;
}
/** @type {?} */
const rect = el.getBoundingClientRect();
if (rect.width || rect.height) {
/** @type {?} */
const doc = (/** @type {?} */ (el.ownerDocument)).documentElement;
ret.top = rect.top - (/** @type {?} */ (doc)).clientTop;
ret.left = rect.left - (/** @type {?} */ (doc)).clientLeft;
}
else {
ret.top = rect.top;
ret.left = rect.left;
}
return ret;
}
/**
* Get the position of the scoll bar of `el`.
* @param {?=} el
* @param {?=} top
* @return {?}
*/
// TODO: remove '| Window' as the fallback already happens here
getScroll(el, top = true) {
/** @type {?} */
const target = el ? el : window;
/** @type {?} */
const prop = top ? 'pageYOffset' : 'pageXOffset';
/** @type {?} */
const method = top ? 'scrollTop' : 'scrollLeft';
/** @type {?} */
const isWindow = target === window;
// @ts-ignore
/** @type {?} */
let ret = isWindow ? target[prop] : target[method];
if (isWindow && typeof ret !== 'numbe