ng-zorro-antd-yj
Version:
An enterprise-class UI components based on Ant Design and Angular
1,578 lines (1,560 loc) • 1.61 MB
JavaScript
import { IconService, IconDirective } from '@ant-design/icons-angular';
import { BarsOutline, CalendarOutline, CaretDownFill, CaretDownOutline, CaretUpFill, CaretUpOutline, CheckCircleFill, CheckCircleOutline, CheckOutline, ClockCircleOutline, CloseCircleFill, CloseCircleOutline, CloseOutline, DoubleLeftOutline, DoubleRightOutline, DownOutline, EllipsisOutline, ExclamationCircleFill, ExclamationCircleOutline, EyeOutline, FileFill, FileOutline, FilterFill, InfoCircleFill, InfoCircleOutline, LeftOutline, LoadingOutline, PaperClipOutline, QuestionCircleOutline, RightOutline, SearchOutline, StarFill, UploadOutline, UpOutline } from '@ant-design/icons-angular/icons';
import { ActivatedRoute, PRIMARY_OUTLET, Router } from '@angular/router';
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
import fnsFormat from 'date-fns/format';
import fnsGetISOWeek from 'date-fns/get_iso_week';
import fnsParse from 'date-fns/parse';
import { coerceBooleanProperty, coerceCssPixelValue, _isNumberValue, coerceElement } from '@angular/cdk/coercion';
import addDays from 'date-fns/add_days';
import differenceInCalendarDays from 'date-fns/difference_in_calendar_days';
import differenceInCalendarMonths from 'date-fns/difference_in_calendar_months';
import differenceInCalendarWeeks from 'date-fns/difference_in_calendar_weeks';
import isSameDay from 'date-fns/is_same_day';
import isSameMonth from 'date-fns/is_same_month';
import isSameYear from 'date-fns/is_same_year';
import isThisMonth from 'date-fns/is_this_month';
import isThisYear from 'date-fns/is_this_year';
import setYear from 'date-fns/set_year';
import startOfMonth from 'date-fns/start_of_month';
import startOfWeek from 'date-fns/start_of_week';
import startOfYear from 'date-fns/start_of_year';
import { DomSanitizer } from '@angular/platform-browser';
import addMonths from 'date-fns/add_months';
import addYears from 'date-fns/add_years';
import endOfMonth from 'date-fns/end_of_month';
import setDay from 'date-fns/set_day';
import setMonth from 'date-fns/set_month';
import { MediaMatcher, LayoutModule } from '@angular/cdk/layout';
import { Platform, PlatformModule } from '@angular/cdk/platform';
import { FocusMonitor, FocusTrapFactory } from '@angular/cdk/a11y';
import { CdkVirtualScrollViewport, ScrollingModule } from '@angular/cdk/scrolling';
import { ObserversModule } from '@angular/cdk/observers';
import { Directionality } from '@angular/cdk/bidi';
import { NG_VALUE_ACCESSOR, FormsModule, NgControl, FormControl, FormControlName } from '@angular/forms';
import { DOWN_ARROW, ENTER, ESCAPE, TAB, UP_ARROW, BACKSPACE, SPACE, LEFT_ARROW, RIGHT_ARROW } from '@angular/cdk/keycodes';
import { HttpBackend, HttpRequest, HttpHeaders, HttpEventType, HttpResponse, HttpClient } from '@angular/common/http';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { __decorate, __metadata, __spread, __assign, __extends, __read, __values } from 'tslib';
import { DOCUMENT, CommonModule, DatePipe, getLocaleNumberSymbol, NumberSymbol } from '@angular/common';
import { ConnectionPositionPair, Overlay, OverlayConfig, OverlayModule, CdkConnectedOverlay, CdkOverlayOrigin, OverlayRef } from '@angular/cdk/overlay';
import { TemplatePortal, ComponentPortal, PortalInjector, PortalModule, CdkPortalOutlet } from '@angular/cdk/portal';
import { fromEvent, defer, merge, Subscription, Subject, BehaviorSubject, combineLatest, ReplaySubject, EMPTY, interval, of, Observable } from 'rxjs';
import { distinctUntilChanged, throttleTime, filter, switchMap, take, delay, distinct, map, takeUntil, startWith, share, skip, tap, flatMap, debounceTime, auditTime, mapTo, pluck } from 'rxjs/operators';
import { Inject, Injectable, Optional, SkipSelf, TemplateRef, Type, ChangeDetectionStrategy, Component, ElementRef, EventEmitter, Input, Output, ViewChild, ViewEncapsulation, NgModule, Directive, Renderer2, ViewContainerRef, InjectionToken, RendererFactory2, ChangeDetectorRef, ContentChildren, NgZone, Pipe, Self, ContentChild, Host, HostListener, forwardRef, ViewChildren, ComponentFactoryResolver, Version, defineInjectable, inject, LOCALE_ID, Injector, HostBinding, ApplicationRef, INJECTOR } from '@angular/core';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// tslint:disable:no-any typedef no-invalid-this
/** @type {?} */
var availablePrefixes = ['moz', 'ms', 'webkit'];
/**
* @return {?}
*/
function requestAnimationFramePolyfill() {
/** @type {?} */
var lastTime = 0;
return (/**
* @param {?} callback
* @return {?}
*/
function (callback) {
/** @type {?} */
var currTime = new Date().getTime();
/** @type {?} */
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
/** @type {?} */
var id = setTimeout((/**
* @return {?}
*/
function () {
callback(currTime + timeToCall);
}), timeToCall);
lastTime = currTime + timeToCall;
return id;
});
}
/**
* @return {?}
*/
function getRequestAnimationFrame() {
if (typeof window === 'undefined') {
return (/**
* @return {?}
*/
function () { return 0; });
}
if (window.requestAnimationFrame) {
// https://github.com/vuejs/vue/issues/4465
return window.requestAnimationFrame.bind(window);
}
/** @type {?} */
var prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
function (key) { return 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 {?} */
var prefix = availablePrefixes.filter((/**
* @param {?} key
* @return {?}
*/
function (key) { return 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 {?} */
var reqAnimFrame = getRequestAnimationFrame();
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} t
* @param {?} b
* @param {?} c
* @param {?} d
* @return {?}
*/
function easeInOutCubic(t, b, c, d) {
/** @type {?} */
var cc = c - b;
/** @type {?} */
var tt = t / (d / 2);
if (tt < 1) {
return (cc / 2) * tt * tt * tt + b;
}
else {
return (cc / 2) * ((tt -= 2) * tt * tt + 2) + b;
}
}
var NzScrollService = /** @class */ (function () {
/* tslint:disable-next-line:no-any */
function NzScrollService(doc) {
this.doc = doc;
}
/** 设置 `el` 滚动条位置 */
/**
* 设置 `el` 滚动条位置
* @param {?} el
* @param {?=} topValue
* @return {?}
*/
NzScrollService.prototype.setScrollTop = /**
* 设置 `el` 滚动条位置
* @param {?} el
* @param {?=} topValue
* @return {?}
*/
function (el, topValue) {
if (topValue === void 0) { topValue = 0; }
if (el === window) {
this.doc.body.scrollTop = topValue;
(/** @type {?} */ (this.doc.documentElement)).scrollTop = topValue;
}
else {
((/** @type {?} */ (el))).scrollTop = topValue;
}
};
/** 获取 `el` 相对于视窗距离 */
/**
* 获取 `el` 相对于视窗距离
* @param {?} el
* @return {?}
*/
NzScrollService.prototype.getOffset = /**
* 获取 `el` 相对于视窗距离
* @param {?} el
* @return {?}
*/
function (el) {
/** @type {?} */
var ret = {
top: 0,
left: 0
};
if (!el || !el.getClientRects().length) {
return ret;
}
/** @type {?} */
var rect = el.getBoundingClientRect();
if (rect.width || rect.height) {
/** @type {?} */
var 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;
};
/** 获取 `el` 滚动条位置 */
// TODO: remove '| Window' as the fallback already happens here
/**
* 获取 `el` 滚动条位置
* @param {?=} el
* @param {?=} top
* @return {?}
*/
// TODO: remove '| Window' as the fallback already happens here
NzScrollService.prototype.getScroll = /**
* 获取 `el` 滚动条位置
* @param {?=} el
* @param {?=} top
* @return {?}
*/
// TODO: remove '| Window' as the fallback already happens here
function (el, top) {
if (top === void 0) { top = true; }
/** @type {?} */
var target = el ? el : window;
/** @type {?} */
var prop = top ? 'pageYOffset' : 'pageXOffset';
/** @type {?} */
var method = top ? 'scrollTop' : 'scrollLeft';
/** @type {?} */
var isWindow = target === window;
// @ts-ignore
/** @type {?} */
var ret = isWindow ? target[prop] : target[method];
if (isWindow && typeof ret !== 'number') {
ret = (/** @type {?} */ (this.doc.documentElement))[method];
}
return ret;
};
/**
* 使用动画形式将 `el` 滚动至某位置
*
* @param containerEl 容器,默认 `window`
* @param targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部
* @param easing 动作算法,默认:`easeInOutCubic`
* @param callback 动画结束后回调
*/
/**
* 使用动画形式将 `el` 滚动至某位置
*
* @param {?} containerEl 容器,默认 `window`
* @param {?=} targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部
* @param {?=} easing 动作算法,默认:`easeInOutCubic`
* @param {?=} callback 动画结束后回调
* @return {?}
*/
NzScrollService.prototype.scrollTo = /**
* 使用动画形式将 `el` 滚动至某位置
*
* @param {?} containerEl 容器,默认 `window`
* @param {?=} targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部
* @param {?=} easing 动作算法,默认:`easeInOutCubic`
* @param {?=} callback 动画结束后回调
* @return {?}
*/
function (containerEl, targetTopValue, easing, callback) {
var _this = this;
if (targetTopValue === void 0) { targetTopValue = 0; }
/** @type {?} */
var target = containerEl ? containerEl : window;
/** @type {?} */
var scrollTop = this.getScroll(target);
/** @type {?} */
var startTime = Date.now();
/** @type {?} */
var frameFunc = (/**
* @return {?}
*/
function () {
/** @type {?} */
var timestamp = Date.now();
/** @type {?} */
var time = timestamp - startTime;
_this.setScrollTop(target, (easing || easeInOutCubic)(time, scrollTop, targetTopValue, 450));
if (time < 450) {
reqAnimFrame(frameFunc);
}
else {
if (callback) {
callback();
}
}
});
reqAnimFrame(frameFunc);
};
NzScrollService.decorators = [
{ type: Injectable }
];
/** @nocollapse */
NzScrollService.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
]; };
return NzScrollService;
}());
/**
* @param {?} doc
* @param {?} scrollService
* @return {?}
*/
function SCROLL_SERVICE_PROVIDER_FACTORY(doc, scrollService) {
return scrollService || new NzScrollService(doc);
}
/** @type {?} */
var SCROLL_SERVICE_PROVIDER = {
provide: NzScrollService,
useFactory: SCROLL_SERVICE_PROVIDER_FACTORY,
deps: [DOCUMENT, [new Optional(), new SkipSelf(), NzScrollService]]
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// tslint:disable-next-line:no-any
/**
* @param {?} value
* @return {?}
*/
function isNotNil(value) {
return typeof value !== 'undefined' && value !== null;
}
// tslint:disable-next-line:no-any
/**
* @param {?} value
* @return {?}
*/
function isNil(value) {
return typeof value === 'undefined' || value === null;
}
/**
* Examine if two objects are shallowly equaled.
* @param {?=} objA
* @param {?=} objB
* @return {?}
*/
function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
}
if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
return false;
}
/** @type {?} */
var keysA = Object.keys(objA);
/** @type {?} */
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
/** @type {?} */
var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB);
// tslint:disable-next-line:prefer-for-of
for (var idx = 0; idx < keysA.length; idx++) {
/** @type {?} */
var key = keysA[idx];
if (!bHasOwnProperty(key)) {
return false;
}
if (objA[key] !== objB[key]) {
return false;
}
}
return true;
}
/**
* @param {?} value
* @return {?}
*/
function isInteger(value) {
return typeof value === 'number' && isFinite(value) && Math.floor(value) === value;
}
/**
* @param {?} element
* @return {?}
*/
function isEmpty(element) {
/** @type {?} */
var nodes = element.childNodes;
for (var i = 0; i < nodes.length; i++) {
if (filterNotEmptyNode(nodes.item(i))) {
return false;
}
}
return true;
}
/**
* @param {?} node
* @return {?}
*/
function filterNotEmptyNode(node) {
if (node) {
if (node.nodeType === 1 && ((/** @type {?} */ (node))).outerHTML.toString().trim().length !== 0) {
// ELEMENT_NODE
return node;
}
else if (node.nodeType === 3 && (/** @type {?} */ (node.textContent)).toString().trim().length !== 0) {
// TEXT_NODE
return node;
}
return null;
}
return null;
}
/**
* @param {?} value
* @return {?}
*/
function isNonEmptyString(value) {
// tslint:disable-line:no-any
return typeof value === 'string' && value !== '';
}
/**
* @param {?} value
* @return {?}
*/
function isTemplateRef(value) {
// tslint:disable-line:no-any
return value instanceof TemplateRef;
}
/**
* @param {?} value
* @return {?}
*/
function isComponent(value) {
// tslint:disable-line:no-any
return value instanceof Type;
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,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) {
if (fallbackValue === void 0) { fallbackValue = 0; }
return _isNumberValue(value) ? Number(value) : fallbackValue;
}
/**
* @param {?} value
* @return {?}
*/
function toCssPixel(value) {
return coerceCssPixelValue(value);
}
// Get the function-property type's value
/**
* @template T
* @param {?} prop
* @param {...?} args
* @return {?}
*/
function valueFunctionProp(prop) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
// tslint:disable-line: no-any
return typeof prop === 'function' ? prop.apply(void 0, __spread(args)) : prop;
}
// tslint:disable-next-line: no-any
/**
* @template T, D
* @param {?} name
* @param {?} fallback
* @return {?}
*/
function propDecoratorFactory(name, fallback) {
// tslint:disable-next-line: no-any
/**
* @param {?} target
* @param {?} propName
* @return {?}
*/
function propDecorator(target, propName) {
/** @type {?} */
var privatePropName = "$$__" + propName;
if (Object.prototype.hasOwnProperty.call(target, privatePropName)) {
console.warn("The prop \"" + privatePropName + "\" is already exist, it will be overrided by " + name + " decorator.");
}
Object.defineProperty(target, privatePropName, {
configurable: true,
writable: true
});
Object.defineProperty(target, propName, {
get: /**
* @return {?}
*/
function () {
return this[privatePropName]; // tslint:disable-line:no-invalid-this
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this[privatePropName] = fallback(value); // tslint:disable-line:no-invalid-this
}
});
}
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.__visibile; }
* // set visible(value) { this.__visible = value; }
* // __visible = false;
* ```
* @return {?}
*/
function InputBoolean() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputBoolean', toBoolean);
}
/**
* @return {?}
*/
function InputCssPixel() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputCssPixel', toCssPixel);
}
/**
* @return {?}
*/
function InputNumber() {
// tslint:disable-line: no-any
return propDecoratorFactory('InputNumber', toNumber);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} fn
* @return {?}
*/
function throttleByAnimationFrame(fn) {
/** @type {?} */
var requestId;
/** @type {?} */
var later = (/**
* @param {?} args
* @return {?}
*/
function (args) { return (/**
* @return {?}
*/
function () {
requestId = null;
fn.apply(void 0, __spread(args));
}); });
/** @type {?} */
var throttled = (/**
* @param {...?} args
* @return {?}
*/
function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (requestId == null) {
requestId = reqAnimFrame(later(args));
}
});
// tslint:disable-next-line:no-non-null-assertion
((/** @type {?} */ (throttled))).cancel = (/**
* @return {?}
*/
function () { return cancelRequestAnimationFrame((/** @type {?} */ (requestId))); });
return throttled;
}
/**
* @return {?}
*/
function throttleByAnimationFrameDecorator() {
return (/**
* @param {?} target
* @param {?} key
* @param {?} descriptor
* @return {?}
*/
function (target, key, descriptor) {
/** @type {?} */
var fn = descriptor.value;
/** @type {?} */
var definingProperty = false;
return {
configurable: true,
get: /**
* @return {?}
*/
function () {
if (definingProperty || this === target.prototype || this.hasOwnProperty(key)) {
return fn;
}
/** @type {?} */
var boundFn = throttleByAnimationFrame(fn.bind(this));
definingProperty = true;
Object.defineProperty(this, key, {
value: boundFn,
configurable: true,
writable: true
});
definingProperty = false;
return boundFn;
}
};
});
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzAffixComponent = /** @class */ (function () {
// tslint:disable-next-line:no-any
function NzAffixComponent(_el, scrollSrv, doc) {
this.scrollSrv = scrollSrv;
this.doc = doc;
this.nzChange = new EventEmitter();
this.events = ['resize', 'scroll', 'touchstart', 'touchmove', 'touchend', 'pageshow', 'load'];
this._target = window;
this.placeholderNode = _el.nativeElement;
}
Object.defineProperty(NzAffixComponent.prototype, "nzTarget", {
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
this.clearEventListeners();
this._target = typeof value === 'string' ? this.doc.querySelector(value) : value || window;
this.setTargetEventListeners();
this.updatePosition((/** @type {?} */ ({})));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzAffixComponent.prototype, "nzOffsetTop", {
get: /**
* @return {?}
*/
function () {
return this._offsetTop;
},
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value === undefined || value === null) {
return;
}
this._offsetTop = toNumber(value, null);
this.updatePosition((/** @type {?} */ ({})));
},
enumerable: true,
configurable: true
});
Object.defineProperty(NzAffixComponent.prototype, "nzOffsetBottom", {
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (typeof value === 'undefined') {
return;
}
this._offsetBottom = toNumber(value, null);
this.updatePosition((/** @type {?} */ ({})));
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NzAffixComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
var _this = this;
this.timeout = setTimeout((/**
* @return {?}
*/
function () {
_this.setTargetEventListeners();
_this.updatePosition((/** @type {?} */ ({})));
}));
};
/**
* @return {?}
*/
NzAffixComponent.prototype.ngOnDestroy = /**
* @return {?}
*/
function () {
this.clearEventListeners();
clearTimeout(this.timeout);
// tslint:disable-next-line:no-any
((/** @type {?} */ (this.updatePosition))).cancel();
};
/**
* @param {?} element
* @param {?} target
* @return {?}
*/
NzAffixComponent.prototype.getOffset = /**
* @param {?} element
* @param {?} target
* @return {?}
*/
function (element, target) {
/** @type {?} */
var elemRect = element.getBoundingClientRect();
/** @type {?} */
var targetRect = this.getTargetRect(target);
/** @type {?} */
var scrollTop = this.scrollSrv.getScroll(target, true);
/** @type {?} */
var scrollLeft = this.scrollSrv.getScroll(target, false);
/** @type {?} */
var docElem = this.doc.body;
/** @type {?} */
var clientTop = docElem.clientTop || 0;
/** @type {?} */
var clientLeft = docElem.clientLeft || 0;
return {
top: elemRect.top - targetRect.top + scrollTop - clientTop,
left: elemRect.left - targetRect.left + scrollLeft - clientLeft,
width: elemRect.width,
height: elemRect.height
};
};
/**
* @private
* @return {?}
*/
NzAffixComponent.prototype.setTargetEventListeners = /**
* @private
* @return {?}
*/
function () {
var _this = this;
this.clearEventListeners();
this.events.forEach((/**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
_this._target.addEventListener(eventName, _this.updatePosition, false);
}));
};
/**
* @private
* @return {?}
*/
NzAffixComponent.prototype.clearEventListeners = /**
* @private
* @return {?}
*/
function () {
var _this = this;
this.events.forEach((/**
* @param {?} eventName
* @return {?}
*/
function (eventName) {
_this._target.removeEventListener(eventName, _this.updatePosition, false);
}));
};
/**
* @private
* @param {?} target
* @return {?}
*/
NzAffixComponent.prototype.getTargetRect = /**
* @private
* @param {?} target
* @return {?}
*/
function (target) {
return target !== window
? ((/** @type {?} */ (target))).getBoundingClientRect()
: ((/** @type {?} */ ({ top: 0, left: 0, bottom: 0 })));
};
/**
* @private
* @param {?=} affixStyle
* @return {?}
*/
NzAffixComponent.prototype.genStyle = /**
* @private
* @param {?=} affixStyle
* @return {?}
*/
function (affixStyle) {
if (!affixStyle) {
return '';
}
return Object.keys(affixStyle)
.map((/**
* @param {?} key
* @return {?}
*/
function (key) {
/** @type {?} */
var val = affixStyle[key];
return key + ":" + (typeof val === 'string' ? val : val + 'px');
}))
.join(';');
};
/**
* @private
* @param {?} e
* @param {?=} affixStyle
* @return {?}
*/
NzAffixComponent.prototype.setAffixStyle = /**
* @private
* @param {?} e
* @param {?=} affixStyle
* @return {?}
*/
function (e, affixStyle) {
/** @type {?} */
var originalAffixStyle = this.affixStyle;
/** @type {?} */
var isWindow = this._target === window;
if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) {
return;
}
if (shallowEqual(originalAffixStyle, affixStyle)) {
return;
}
/** @type {?} */
var fixed = !!affixStyle;
/** @type {?} */
var wrapEl = (/** @type {?} */ (this.fixedEl.nativeElement));
wrapEl.style.cssText = this.genStyle(affixStyle);
this.affixStyle = affixStyle;
/** @type {?} */
var cls = 'ant-affix';
if (fixed) {
wrapEl.classList.add(cls);
}
else {
wrapEl.classList.remove(cls);
}
if ((affixStyle && !originalAffixStyle) || (!affixStyle && originalAffixStyle)) {
this.nzChange.emit(fixed);
}
};
/**
* @private
* @param {?=} placeholderStyle
* @return {?}
*/
NzAffixComponent.prototype.setPlaceholderStyle = /**
* @private
* @param {?=} placeholderStyle
* @return {?}
*/
function (placeholderStyle) {
/** @type {?} */
var originalPlaceholderStyle = this.placeholderStyle;
if (shallowEqual(placeholderStyle, originalPlaceholderStyle)) {
return;
}
this.placeholderNode.style.cssText = this.genStyle(placeholderStyle);
this.placeholderStyle = placeholderStyle;
};
/**
* @private
* @param {?} e
* @return {?}
*/
NzAffixComponent.prototype.syncPlaceholderStyle = /**
* @private
* @param {?} e
* @return {?}
*/
function (e) {
if (!this.affixStyle) {
return;
}
this.placeholderNode.style.cssText = '';
this.placeholderStyle = undefined;
/** @type {?} */
var styleObj = { width: this.placeholderNode.offsetWidth, height: this.fixedEl.nativeElement.offsetHeight };
this.setAffixStyle(e, __assign({}, this.affixStyle, styleObj));
this.setPlaceholderStyle(styleObj);
};
/**
* @param {?} e
* @return {?}
*/
NzAffixComponent.prototype.updatePosition = /**
* @param {?} e
* @return {?}
*/
function (e) {
/** @type {?} */
var targetNode = this._target;
// Backwards support
/** @type {?} */
var offsetTop = this.nzOffsetTop;
/** @type {?} */
var scrollTop = this.scrollSrv.getScroll(targetNode, true);
/** @type {?} */
var elemOffset = this.getOffset(this.placeholderNode, targetNode);
/** @type {?} */
var fixedNode = (/** @type {?} */ (this.fixedEl.nativeElement));
/** @type {?} */
var elemSize = {
width: fixedNode.offsetWidth,
height: fixedNode.offsetHeight
};
/** @type {?} */
var offsetMode = {
top: false,
bottom: false
};
// Default to `offsetTop=0`.
if (typeof offsetTop !== 'number' && typeof this._offsetBottom !== 'number') {
offsetMode.top = true;
offsetTop = 0;
}
else {
offsetMode.top = typeof offsetTop === 'number';
offsetMode.bottom = typeof this._offsetBottom === 'number';
}
/** @type {?} */
var targetRect = this.getTargetRect(targetNode);
/** @type {?} */
var targetInnerHeight = ((/** @type {?} */ (targetNode))).innerHeight || ((/** @type {?} */ (targetNode))).clientHeight;
if (scrollTop >= elemOffset.top - ((/** @type {?} */ (offsetTop))) && offsetMode.top) {
/** @type {?} */
var width = elemOffset.width;
/** @type {?} */
var top_1 = targetRect.top + ((/** @type {?} */ (offsetTop)));
this.setAffixStyle(e, {
position: 'fixed',
top: top_1,
left: targetRect.left + elemOffset.left,
maxHeight: "calc(100vh - " + top_1 + "px)",
width: width
});
this.setPlaceholderStyle({
width: width,
height: elemSize.height
});
}
else if (scrollTop <= elemOffset.top + elemSize.height + ((/** @type {?} */ (this._offsetBottom))) - targetInnerHeight &&
offsetMode.bottom) {
/** @type {?} */
var targetBottomOffet = targetNode === window ? 0 : window.innerHeight - targetRect.bottom;
/** @type {?} */
var width = elemOffset.width;
this.setAffixStyle(e, {
position: 'fixed',
bottom: targetBottomOffet + ((/** @type {?} */ (this._offsetBottom))),
left: targetRect.left + elemOffset.left,
width: width
});
this.setPlaceholderStyle({
width: width,
height: elemOffset.height
});
}
else {
if (e.type === 'resize' &&
this.affixStyle &&
this.affixStyle.position === 'fixed' &&
this.placeholderNode.offsetWidth) {
this.setAffixStyle(e, __assign({}, this.affixStyle, { width: this.placeholderNode.offsetWidth }));
}
else {
this.setAffixStyle(e);
}
this.setPlaceholderStyle();
}
if (e.type === 'resize') {
this.syncPlaceholderStyle(e);
}
};
NzAffixComponent.decorators = [
{ type: Component, args: [{
selector: 'nz-affix',
template: "<div #fixedEl>\n <ng-content></ng-content>\n</div>",
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
styles: ["\n nz-affix {\n display: block;\n }\n "]
}] }
];
/** @nocollapse */
NzAffixComponent.ctorParameters = function () { return [
{ type: ElementRef },
{ type: NzScrollService },
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
]; };
NzAffixComponent.propDecorators = {
nzTarget: [{ type: Input }],
nzOffsetTop: [{ type: Input }],
nzOffsetBottom: [{ type: Input }],
nzChange: [{ type: Output }],
fixedEl: [{ type: ViewChild, args: ['fixedEl',] }]
};
__decorate([
throttleByAnimationFrameDecorator(),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Event]),
__metadata("design:returntype", void 0)
], NzAffixComponent.prototype, "updatePosition", null);
return NzAffixComponent;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzAffixModule = /** @class */ (function () {
function NzAffixModule() {
}
NzAffixModule.decorators = [
{ type: NgModule, args: [{
declarations: [NzAffixComponent],
exports: [NzAffixComponent],
imports: [CommonModule],
providers: [SCROLL_SERVICE_PROVIDER]
},] }
];
return NzAffixModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzClassListAddDirective = /** @class */ (function () {
function NzClassListAddDirective(elementRef, renderer) {
this.elementRef = elementRef;
this.renderer = renderer;
this.classList = [];
}
Object.defineProperty(NzClassListAddDirective.prototype, "nzClassListAdd", {
set: /**
* @param {?} list
* @return {?}
*/
function (list) {
var _this = this;
this.classList.forEach((/**
* @param {?} name
* @return {?}
*/
function (name) {
_this.renderer.removeClass(_this.elementRef.nativeElement, name);
}));
list.forEach((/**
* @param {?} name
* @return {?}
*/
function (name) {
_this.renderer.addClass(_this.elementRef.nativeElement, name);
}));
this.classList = list;
},
enumerable: true,
configurable: true
});
NzClassListAddDirective.decorators = [
{ type: Directive, args: [{
selector: '[nzClassListAdd]'
},] }
];
/** @nocollapse */
NzClassListAddDirective.ctorParameters = function () { return [
{ type: ElementRef },
{ type: Renderer2 }
]; };
NzClassListAddDirective.propDecorators = {
nzClassListAdd: [{ type: Input }]
};
return NzClassListAddDirective;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzStringTemplateOutletDirective = /** @class */ (function () {
function NzStringTemplateOutletDirective(viewContainer, defaultTemplate) {
this.viewContainer = viewContainer;
this.defaultTemplate = defaultTemplate;
this.inputTemplate = null;
this.inputViewRef = null;
this.defaultViewRef = null;
}
Object.defineProperty(NzStringTemplateOutletDirective.prototype, "nzStringTemplateOutlet", {
set: /**
* @param {?} value
* @return {?}
*/
function (value) {
if (value instanceof TemplateRef) {
this.isTemplate = true;
this.inputTemplate = value;
}
else {
this.isTemplate = false;
}
this.updateView();
},
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
NzStringTemplateOutletDirective.prototype.updateView = /**
* @return {?}
*/
function () {
if (!this.isTemplate) {
/** use default template when input is string **/
if (!this.defaultViewRef) {
this.viewContainer.clear();
this.inputViewRef = null;
if (this.defaultTemplate) {
this.defaultViewRef = this.viewContainer.createEmbeddedView(this.defaultTemplate);
}
}
}
else {
/** use input template when input is templateRef **/
if (!this.inputViewRef) {
this.viewContainer.clear();
this.defaultViewRef = null;
if (this.inputTemplate) {
this.inputViewRef = this.viewContainer.createEmbeddedView(this.inputTemplate);
}
}
}
};
NzStringTemplateOutletDirective.decorators = [
{ type: Directive, args: [{
selector: '[nzStringTemplateOutlet]'
},] }
];
/** @nocollapse */
NzStringTemplateOutletDirective.ctorParameters = function () { return [
{ type: ViewContainerRef },
{ type: TemplateRef }
]; };
NzStringTemplateOutletDirective.propDecorators = {
nzStringTemplateOutlet: [{ type: Input }]
};
return NzStringTemplateOutletDirective;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzAddOnModule = /** @class */ (function () {
function NzAddOnModule() {
}
NzAddOnModule.decorators = [
{ type: NgModule, args: [{
imports: [CommonModule],
exports: [NzStringTemplateOutletDirective, NzClassListAddDirective],
declarations: [NzStringTemplateOutletDirective, NzClassListAddDirective]
},] }
];
return NzAddOnModule;
}());
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @param {?} prefix
* @return {?}
*/
function getRegExp(prefix) {
/** @type {?} */
var prefixArray = Array.isArray(prefix) ? prefix : [prefix];
/** @type {?} */
var prefixToken = prefixArray.join('').replace(/(\$|\^)/g, '\\$1');
if (prefixArray.length > 1) {
prefixToken = "[" + prefixToken + "]";
}
return new RegExp("(\\s|^)(" + prefixToken + ")[^\\s]*", 'g');
}
/**
* @param {?} value
* @param {?=} prefix
* @return {?}
*/
function getMentions(value, prefix) {
if (prefix === void 0) { prefix = '@'; }
if (typeof value !== 'string') {
return [];
}
/** @type {?} */
var regex = getRegExp(prefix);
/** @type {?} */
var mentions = value.match(regex);
return mentions !== null ? mentions.map((/**
* @param {?} e
* @return {?}
*/
function (e) { return e.trim(); })) : [];
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* Much like lodash.
* @param {?} toPad
* @param {?} length
* @param {?} element
* @return {?}
*/
function padStart(toPad, length, element) {
if (toPad.length > length) {
return toPad;
}
/** @type {?} */
var joined = "" + getRepeatedElement(length, element) + toPad;
return joined.slice(joined.length - length, joined.length);
}
/**
* @param {?} toPad
* @param {?} length
* @param {?} element
* @return {?}
*/
function padEnd(toPad, length, element) {
/** @type {?} */
var joined = "" + toPad + getRepeatedElement(length, element);
return joined.slice(0, length);
}
/**
* @param {?} length
* @param {?} element
* @return {?}
*/
function getRepeatedElement(length, element) {
return Array(length)
.fill(element)
.join('');
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
// from https://github.com/component/textarea-caret-position
// We'll copy the properties below into the mirror div.
// Note that some browsers, such as Firefox, do not concatenate properties
// into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),
// so we have to list every single property explicitly.
/** @type {?} */
var properties = [
'direction',
'boxSizing',
'width',
'height',
'overflowX',
'overflowY',
'borderTopWidth',
'borderRightWidth',
'borderBottomWidth',
'borderLeftWidth',
'borderStyle',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
// https://developer.mozilla.org/en-US/docs/Web/CSS/font
'fontStyle',
'fontVariant',
'fontWeight',
'fontStretch',
'fontSize',
'fontSizeAdjust',
'lineHeight',
'fontFamily',
'textAlign',
'textTransform',
'textIndent',
'textDecoration',
'letterSpacing',
'wordSpacing',
'tabSize',
'MozTabSize'
];
/** @type {?} */
var isBrowser = typeof window !== 'undefined';
// tslint:disable-next-line:no-any
/** @type {?} */
var isFirefox = isBrowser && ((/** @type {?} */ (window))).mozInnerScreenX != null;
/** @type {?} */
var _parseInt = (/**
* @param {?} str
* @return {?}
*/
function (str) { return parseInt(str, 10); });
/**
* @param {?} element
* @param {?} position
* @param {?=} options
* @return {?}
*/
function getCaretCoordinates(element, position, options) {
if (!isBrowser) {
throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');
}
/** @type {?} */
var debug = (options && options.debug) || false;
if (debug) {
/** @type {?} */
var el = document.querySelector('#input-textarea-caret-position-mirror-div');
if (el) {
(/** @type {?} */ (el.parentNode)).removeChild(el);
}
}
// The mirror div will replicate the textarea's style
/** @type {?} */
var div = document.createElement('div');
div.id = 'input-textarea-caret-position-mirror-div';
document.body.appendChild(div);
/** @type {?} */
var style$$1 = div.style;
// tslint:disable-next-line:no-any
/** @type {?} */
var computed = window.getComputedStyle ? window.getComputedStyle(element) : ((/** @type {?} */ (element))).currentStyle;
// currentStyle for IE < 9
/** @type {?} */
var isInput = element.nodeName === 'INPUT';
// Default textarea styles
style$$1.whiteSpace = 'pre-wrap';
if (!isInput) {
style$$1.wordWrap = 'break-word'; // only for textarea-s
}
// Position off-screen
style$$1.position = 'absolute'; // required to return coordinates properly
if (!debug) {
style$$1.visibility = 'hidden';
} // not 'display: none' because we want rendering
// Transfer the element's properties to the div
properties.forEach((/**
* @param {?} prop
* @return {?}
*/
function (prop) {
if (isInput && prop === 'lineHeight') {
// Special case for <input>s because text is rendered centered and line height may be != height
style$$1.lineHeight = computed.height;
}
else {
// @ts-ignore
style$$1[prop] = computed[prop];
}
}));
if (isFirefox) {
// Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275
if (element.scrollHeight > _parseInt(computed.height)) {
style$$1.overflowY = 'scroll';
}
}
else {
style$$1.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'
}
div.textContent = element.value.substring(0, position);
// The second special handling for input type="text" vs textarea:
// spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
if (isInput) {
div.textContent = div.textContent.replace(/\s/g, '\u00a0');
}
/** @type {?} */
var span = document.createElement('span');
// Wrapping must be replicated *exactly*, including when a long word gets
// onto the next line, with whitespace at the end of the line before (#7).
// The *only* reliable way to do that is to copy the *entire* rest of the
// textarea's content into the <span> created at the caret position.
// For inputs, just '.' would be enough, but no need to bother.
span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all
div.appendChild(span);
/** @type {?} */
var coordinates = {
top: span.offsetTop + _parseInt(computed.borderTopWidth),
left: span.offsetLeft + _parseInt(computed.borderLeftWidth),
height: _parseInt(computed.lineHeight)
};
if (debug) {
span.style.backgroundColor = '#eee';
createDebugEle(element, coordinates);
}
else {
document.body.removeChild(div);
}
return coordinates;
}
/**
* @param {?} element
* @param {?} coordinates
* @return {?}
*/
function createDebugEle(element, coordinates) {
/** @type {?} */
var fontSize = getComputedStyle(element).getPropertyValue('font-size');
/** @type {?} */
var rect = ((/** @type {?} */ (document.querySelector('#DEBUG')))) || document.createElement('div');
document.body.appendChild(rect);
rect.id = 'DEBUG';
rect.style.position = 'absolute';
rect.style.backgroundColor = 'red';
rect.style.height = fontSize;
rect.style.width = '1px';
rect.style.top = element.getBoundingClientRect().top -
element.scrollTop +
window.pageYOffset +
coordinates.top + "px";
rect.style.left = element.getBoundingClientRect().left -
element.scrollLeft +
window.pageXOffset +
coordinates.left + "px";
console.log(rect.style.top);
console.log(rect.style.left);
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var 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,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/** @type {?} */
var NZ_ICONS$$1 = new InjectionToken('nz_icons');
/** @type {?} */
var NZ_ICON_DEFAULT_TWOTONE_COLOR$$1 = new InjectionToken('nz_icon_default_twotone_color');
/** @type {?} */
var DEFAULT_TWOTONE_COLOR$$1 = '#1890ff';
/** @type {?} */
var NZ_ICONS_USED_BY_ZORRO$$1 = [
BarsOutline,
CalendarOutline,
CaretUpFill,
CaretUpOutline,
CaretDownFill,
CaretDownOutline,
CheckCircleFill,
CheckCircleOutline,
CheckOutline,
ClockCircleOutline,
CloseCircleOutline,
CloseCircleFill,
CloseOutline,
DoubleLeftOutline,
DoubleRightOutline,
DownOutline,
EllipsisOutline,
ExclamationCircleFill,
ExclamationCircleOutline,
EyeOutline,
FileFill,
FileOutline,
FilterFill,
InfoCircleFill,
InfoCircleOutline,
LeftOutline,
LoadingOutline,
PaperClipOutline,
QuestionCircleOutline,
RightOutline,
StarFill,
SearchOutline,
StarFill,
UploadOutline,
UpOutline
];
/**
* It should be a global singleton, otherwise registered icons could not be found.
*/
var NzIconService$$1 = /** @class */ (function (_super) {
__extends(NzIconService$$1, _super);
function NzIconService$$1(rendererFactory, sanitizer, handler, document, icons, defaultColor) {
var _this = _super.call(this, rendererFactory, handler, document, sanitizer) || this;
_this.rendererFactory = rendererFactory;
_this.sanitizer = sanitizer;
_this.handler = handler;
_this.document = document;
_this.icons = icons;
_this.defaultColor = defaultColor;
_this.iconfontCache = new Set();
_this.warnedAboutAPI = false;
_this.warnedAboutCross = false;
_this.warnedAboutVertical = false;
_this.addIcon.apply(_this, __spread(NZ_ICONS_USED_BY_ZORRO$$1, (_this.icons || [])));
/** @type {?} */
var primaryColor = DEFAULT_TWOTONE_COLOR$$1;
if (_this.defaultColor) {
if (_this.defaultColor.startsWith('#')) {
primaryColor = _this.defaultColor;
}
else {
console.warn