UNPKG

ng-zorro-antd-yj

Version:

An enterprise-class UI components based on Ant Design and Angular

1,264 lines (1,251 loc) 1.87 MB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@ant-design/icons-angular'), require('@ant-design/icons-angular/icons'), require('@angular/router'), require('@angular/platform-browser/animations'), require('date-fns/format'), require('date-fns/get_iso_week'), require('date-fns/parse'), require('@angular/cdk/coercion'), require('date-fns/add_days'), require('date-fns/difference_in_calendar_days'), require('date-fns/difference_in_calendar_months'), require('date-fns/difference_in_calendar_weeks'), require('date-fns/is_same_day'), require('date-fns/is_same_month'), require('date-fns/is_same_year'), require('date-fns/is_this_month'), require('date-fns/is_this_year'), require('date-fns/set_year'), require('date-fns/start_of_month'), require('date-fns/start_of_week'), require('date-fns/start_of_year'), require('@angular/platform-browser'), require('date-fns/add_months'), require('date-fns/add_years'), require('date-fns/end_of_month'), require('date-fns/set_day'), require('date-fns/set_month'), require('@angular/cdk/layout'), require('@angular/cdk/platform'), require('@angular/cdk/a11y'), require('@angular/cdk/scrolling'), require('@angular/cdk/observers'), require('@angular/cdk/bidi'), require('@angular/forms'), require('@angular/cdk/keycodes'), require('@angular/common/http'), require('@angular/animations'), require('@angular/common'), require('@angular/cdk/overlay'), require('@angular/cdk/portal'), require('rxjs'), require('rxjs/operators'), require('@angular/core')) : typeof define === 'function' && define.amd ? define('ng-zorro-antd-yj', ['exports', '@ant-design/icons-angular', '@ant-design/icons-angular/icons', '@angular/router', '@angular/platform-browser/animations', 'date-fns/format', 'date-fns/get_iso_week', 'date-fns/parse', '@angular/cdk/coercion', 'date-fns/add_days', 'date-fns/difference_in_calendar_days', 'date-fns/difference_in_calendar_months', 'date-fns/difference_in_calendar_weeks', 'date-fns/is_same_day', 'date-fns/is_same_month', 'date-fns/is_same_year', 'date-fns/is_this_month', 'date-fns/is_this_year', 'date-fns/set_year', 'date-fns/start_of_month', 'date-fns/start_of_week', 'date-fns/start_of_year', '@angular/platform-browser', 'date-fns/add_months', 'date-fns/add_years', 'date-fns/end_of_month', 'date-fns/set_day', 'date-fns/set_month', '@angular/cdk/layout', '@angular/cdk/platform', '@angular/cdk/a11y', '@angular/cdk/scrolling', '@angular/cdk/observers', '@angular/cdk/bidi', '@angular/forms', '@angular/cdk/keycodes', '@angular/common/http', '@angular/animations', '@angular/common', '@angular/cdk/overlay', '@angular/cdk/portal', 'rxjs', 'rxjs/operators', '@angular/core'], factory) : (factory((global['ng-zorro-antd-yj'] = {}),global.iconsAngular,global.icons,global.ng.router,global.ng.platformBrowser.animations,global.fnsFormat,global.fnsGetISOWeek,global.fnsParse,global.ng.cdk.coercion,global.addDays,global.differenceInCalendarDays,global.differenceInCalendarMonths,global.differenceInCalendarWeeks,global.isSameDay,global.isSameMonth,global.isSameYear,global.isThisMonth,global.isThisYear,global.setYear,global.startOfMonth,global.startOfWeek,global.startOfYear,global.ng.platformBrowser,global.addMonths,global.addYears,global.endOfMonth,global.setDay,global.setMonth,global.ng.cdk.layout,global.ng.cdk.platform,global.ng.cdk.a11y,global.ng.cdk.scrolling,global.ng.cdk.observers,global.ng.cdk.bidi,global.ng.forms,global.ng.cdk.keycodes,global.ng.common.http,global.ng.animations,global.ng.common,global.ng.cdk.overlay,global.ng.cdk.portal,global.rxjs,global.rxjs.operators,global.ng.core)); }(this, (function (exports,iconsAngular,icons,router,animations,fnsFormat,fnsGetISOWeek,fnsParse,coercion,addDays,differenceInCalendarDays,differenceInCalendarMonths,differenceInCalendarWeeks,isSameDay,isSameMonth,isSameYear,isThisMonth,isThisYear,setYear,startOfMonth,startOfWeek,startOfYear,i2,addMonths,addYears,endOfMonth,setDay,setMonth,layout,platform,a11y,scrolling,observers,bidi,forms,keycodes,i3,animations$1,i2$1,i2$2,portal,rxjs,operators,i0) { 'use strict'; fnsFormat = fnsFormat && fnsFormat.hasOwnProperty('default') ? fnsFormat['default'] : fnsFormat; fnsGetISOWeek = fnsGetISOWeek && fnsGetISOWeek.hasOwnProperty('default') ? fnsGetISOWeek['default'] : fnsGetISOWeek; fnsParse = fnsParse && fnsParse.hasOwnProperty('default') ? fnsParse['default'] : fnsParse; addDays = addDays && addDays.hasOwnProperty('default') ? addDays['default'] : addDays; differenceInCalendarDays = differenceInCalendarDays && differenceInCalendarDays.hasOwnProperty('default') ? differenceInCalendarDays['default'] : differenceInCalendarDays; differenceInCalendarMonths = differenceInCalendarMonths && differenceInCalendarMonths.hasOwnProperty('default') ? differenceInCalendarMonths['default'] : differenceInCalendarMonths; differenceInCalendarWeeks = differenceInCalendarWeeks && differenceInCalendarWeeks.hasOwnProperty('default') ? differenceInCalendarWeeks['default'] : differenceInCalendarWeeks; isSameDay = isSameDay && isSameDay.hasOwnProperty('default') ? isSameDay['default'] : isSameDay; isSameMonth = isSameMonth && isSameMonth.hasOwnProperty('default') ? isSameMonth['default'] : isSameMonth; isSameYear = isSameYear && isSameYear.hasOwnProperty('default') ? isSameYear['default'] : isSameYear; isThisMonth = isThisMonth && isThisMonth.hasOwnProperty('default') ? isThisMonth['default'] : isThisMonth; isThisYear = isThisYear && isThisYear.hasOwnProperty('default') ? isThisYear['default'] : isThisYear; setYear = setYear && setYear.hasOwnProperty('default') ? setYear['default'] : setYear; startOfMonth = startOfMonth && startOfMonth.hasOwnProperty('default') ? startOfMonth['default'] : startOfMonth; startOfWeek = startOfWeek && startOfWeek.hasOwnProperty('default') ? startOfWeek['default'] : startOfWeek; startOfYear = startOfYear && startOfYear.hasOwnProperty('default') ? startOfYear['default'] : startOfYear; addMonths = addMonths && addMonths.hasOwnProperty('default') ? addMonths['default'] : addMonths; addYears = addYears && addYears.hasOwnProperty('default') ? addYears['default'] : addYears; endOfMonth = endOfMonth && endOfMonth.hasOwnProperty('default') ? endOfMonth['default'] : endOfMonth; setDay = setDay && setDay.hasOwnProperty('default') ? setDay['default'] : setDay; setMonth = setMonth && setMonth.hasOwnProperty('default') ? setMonth['default'] : setMonth; /** * @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: i0.Injectable } ]; /** @nocollapse */ NzScrollService.ctorParameters = function () { return [ { type: undefined, decorators: [{ type: i0.Inject, args: [i2$1.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: [i2$1.DOCUMENT, [new i0.Optional(), new i0.SkipSelf(), NzScrollService]] }; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __values(o) { var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; if (m) return m.call(o); return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,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 i0.TemplateRef; } /** * @param {?} value * @return {?} */ function isComponent(value) { // tslint:disable-line:no-any return value instanceof i0.Type; } /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} value * @return {?} */ function toBoolean(value) { return coercion.coerceBooleanProperty(value); } /** * @param {?} value * @param {?=} fallbackValue * @return {?} */ function toNumber(value, fallbackValue) { if (fallbackValue === void 0) { fallbackValue = 0; } return coercion._isNumberValue(value) ? Number(value) : fallbackValue; } /** * @param {?} value * @return {?} */ function toCssPixel(value) { return coercion.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 i0.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: i0.Component, args: [{ selector: 'nz-affix', template: "<div #fixedEl>\n <ng-content></ng-content>\n</div>", changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None, styles: ["\n nz-affix {\n display: block;\n }\n "] }] } ]; /** @nocollapse */ NzAffixComponent.ctorParameters = function () { return [ { type: i0.ElementRef }, { type: NzScrollService }, { type: undefined, decorators: [{ type: i0.Inject, args: [i2$1.DOCUMENT,] }] } ]; }; NzAffixComponent.propDecorators = { nzTarget: [{ type: i0.Input }], nzOffsetTop: [{ type: i0.Input }], nzOffsetBottom: [{ type: i0.Input }], nzChange: [{ type: i0.Output }], fixedEl: [{ type: i0.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: i0.NgModule, args: [{ declarations: [NzAffixComponent], exports: [NzAffixComponent], imports: [i2$1.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: i0.Directive, args: [{ selector: '[nzClassListAdd]' },] } ]; /** @nocollapse */ NzClassListAddDirective.ctorParameters = function () { return [ { type: i0.ElementRef }, { type: i0.Renderer2 } ]; }; NzClassListAddDirective.propDecorators = { nzClassListAdd: [{ type: i0.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 i0.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: i0.Directive, args: [{ selector: '[nzStringTemplateOutlet]' },] } ]; /** @nocollapse */ NzStringTemplateOutletDirective.ctorParameters = function () { return [ { type: i0.ViewContainerRef }, { type: i0.TemplateRef } ]; }; Nz