UNPKG

ng-zorro-antd-yj

Version:

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

1,605 lines (1,586 loc) 1.35 MB
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 } 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, ContentChild, ContentChildren, NgZone, forwardRef, Host, Pipe, Self, ComponentFactoryResolver, HostListener, Injector, ViewChildren, Version, defineInjectable, inject, LOCALE_ID, 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 {?} */ 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,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; } /** * 设置 `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; } } /** * 获取 `el` 相对于视窗距离 * @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; } /** * 获取 `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 !== 'number') { ret = (/** @type {?} */ (this.doc.documentElement))[method]; } return ret; } /** * 使用动画形式将 `el` 滚动至某位置 * * @param {?} containerEl 容器,默认 `window` * @param {?=} targetTopValue 滚动至目标 `top` 值,默认:0,相当于顶部 * @param {?=} easing 动作算法,默认:`easeInOutCubic` * @param {?=} callback 动画结束后回调 * @return {?} */ scrollTo(containerEl, targetTopValue = 0, easing, callback) { /** @type {?} */ const target = containerEl ? containerEl : window; /** @type {?} */ const scrollTop = this.getScroll(target); /** @type {?} */ const startTime = Date.now(); /** @type {?} */ const frameFunc = (/** * @return {?} */ () => { /** @type {?} */ const timestamp = Date.now(); /** @type {?} */ const 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 = () => [ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] } ]; /** * @param {?} doc * @param {?} scrollService * @return {?} */ function SCROLL_SERVICE_PROVIDER_FACTORY(doc, scrollService) { return scrollService || new NzScrollService(doc); } /** @type {?} */ const 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 {?} */ const keysA = Object.keys(objA); /** @type {?} */ const keysB = Object.keys(objB); if (keysA.length !== keysB.length) { return false; } /** @type {?} */ const bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // tslint:disable-next-line:prefer-for-of for (let idx = 0; idx < keysA.length; idx++) { /** @type {?} */ const 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 {?} */ const nodes = element.childNodes; for (let 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 = 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, ...args) { // tslint:disable-line: no-any return typeof prop === 'function' ? prop(...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 {?} */ const 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, { /** * @return {?} */ get() { return this[privatePropName]; // tslint:disable-line:no-invalid-this }, /** * @param {?} value * @return {?} */ set(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 {?} */ let requestId; /** @type {?} */ const later = (/** * @param {?} args * @return {?} */ (args) => (/** * @return {?} */ () => { requestId = null; fn(...args); })); /** @type {?} */ const throttled = (/** * @param {...?} args * @return {?} */ (...args) => { if (requestId == null) { requestId = reqAnimFrame(later(args)); } }); // tslint:disable-next-line:no-non-null-assertion ((/** @type {?} */ (throttled))).cancel = (/** * @return {?} */ () => cancelRequestAnimationFrame((/** @type {?} */ (requestId)))); return throttled; } /** * @return {?} */ function throttleByAnimationFrameDecorator() { return (/** * @param {?} target * @param {?} key * @param {?} descriptor * @return {?} */ function (target, key, descriptor) { /** @type {?} */ const fn = descriptor.value; /** @type {?} */ let definingProperty = false; return { configurable: true, /** * @return {?} */ get() { if (definingProperty || this === target.prototype || this.hasOwnProperty(key)) { return fn; } /** @type {?} */ const 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 */ class NzAffixComponent { // tslint:disable-next-line:no-any /** * @param {?} _el * @param {?} scrollSrv * @param {?} doc */ constructor(_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; } /** * @param {?} value * @return {?} */ set nzTarget(value) { this.clearEventListeners(); this._target = typeof value === 'string' ? this.doc.querySelector(value) : value || window; this.setTargetEventListeners(); this.updatePosition((/** @type {?} */ ({}))); } /** * @param {?} value * @return {?} */ set nzOffsetTop(value) { if (value === undefined || value === null) { return; } this._offsetTop = toNumber(value, null); this.updatePosition((/** @type {?} */ ({}))); } /** * @return {?} */ get nzOffsetTop() { return this._offsetTop; } /** * @param {?} value * @return {?} */ set nzOffsetBottom(value) { if (typeof value === 'undefined') { return; } this._offsetBottom = toNumber(value, null); this.updatePosition((/** @type {?} */ ({}))); } /** * @return {?} */ ngOnInit() { this.timeout = setTimeout((/** * @return {?} */ () => { this.setTargetEventListeners(); this.updatePosition((/** @type {?} */ ({}))); })); } /** * @return {?} */ ngOnDestroy() { this.clearEventListeners(); clearTimeout(this.timeout); // tslint:disable-next-line:no-any ((/** @type {?} */ (this.updatePosition))).cancel(); } /** * @param {?} element * @param {?} target * @return {?} */ getOffset(element, target) { /** @type {?} */ const elemRect = element.getBoundingClientRect(); /** @type {?} */ const targetRect = this.getTargetRect(target); /** @type {?} */ const scrollTop = this.scrollSrv.getScroll(target, true); /** @type {?} */ const scrollLeft = this.scrollSrv.getScroll(target, false); /** @type {?} */ const docElem = this.doc.body; /** @type {?} */ const clientTop = docElem.clientTop || 0; /** @type {?} */ const 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 {?} */ setTargetEventListeners() { this.clearEventListeners(); this.events.forEach((/** * @param {?} eventName * @return {?} */ (eventName) => { this._target.addEventListener(eventName, this.updatePosition, false); })); } /** * @private * @return {?} */ clearEventListeners() { this.events.forEach((/** * @param {?} eventName * @return {?} */ eventName => { this._target.removeEventListener(eventName, this.updatePosition, false); })); } /** * @private * @param {?} target * @return {?} */ getTargetRect(target) { return target !== window ? ((/** @type {?} */ (target))).getBoundingClientRect() : ((/** @type {?} */ ({ top: 0, left: 0, bottom: 0 }))); } /** * @private * @param {?=} affixStyle * @return {?} */ genStyle(affixStyle) { if (!affixStyle) { return ''; } return Object.keys(affixStyle) .map((/** * @param {?} key * @return {?} */ key => { /** @type {?} */ const val = affixStyle[key]; return `${key}:${typeof val === 'string' ? val : val + 'px'}`; })) .join(';'); } /** * @private * @param {?} e * @param {?=} affixStyle * @return {?} */ setAffixStyle(e, affixStyle) { /** @type {?} */ const originalAffixStyle = this.affixStyle; /** @type {?} */ const isWindow = this._target === window; if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) { return; } if (shallowEqual(originalAffixStyle, affixStyle)) { return; } /** @type {?} */ const fixed = !!affixStyle; /** @type {?} */ const wrapEl = (/** @type {?} */ (this.fixedEl.nativeElement)); wrapEl.style.cssText = this.genStyle(affixStyle); this.affixStyle = affixStyle; /** @type {?} */ const 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 {?} */ setPlaceholderStyle(placeholderStyle) { /** @type {?} */ const originalPlaceholderStyle = this.placeholderStyle; if (shallowEqual(placeholderStyle, originalPlaceholderStyle)) { return; } this.placeholderNode.style.cssText = this.genStyle(placeholderStyle); this.placeholderStyle = placeholderStyle; } /** * @private * @param {?} e * @return {?} */ syncPlaceholderStyle(e) { if (!this.affixStyle) { return; } this.placeholderNode.style.cssText = ''; this.placeholderStyle = undefined; /** @type {?} */ const styleObj = { width: this.placeholderNode.offsetWidth, height: this.fixedEl.nativeElement.offsetHeight }; this.setAffixStyle(e, Object.assign({}, this.affixStyle, styleObj)); this.setPlaceholderStyle(styleObj); } /** * @param {?} e * @return {?} */ updatePosition(e) { /** @type {?} */ const targetNode = this._target; // Backwards support /** @type {?} */ let offsetTop = this.nzOffsetTop; /** @type {?} */ const scrollTop = this.scrollSrv.getScroll(targetNode, true); /** @type {?} */ const elemOffset = this.getOffset(this.placeholderNode, targetNode); /** @type {?} */ const fixedNode = (/** @type {?} */ (this.fixedEl.nativeElement)); /** @type {?} */ const elemSize = { width: fixedNode.offsetWidth, height: fixedNode.offsetHeight }; /** @type {?} */ const 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 {?} */ const targetRect = this.getTargetRect(targetNode); /** @type {?} */ const targetInnerHeight = ((/** @type {?} */ (targetNode))).innerHeight || ((/** @type {?} */ (targetNode))).clientHeight; if (scrollTop >= elemOffset.top - ((/** @type {?} */ (offsetTop))) && offsetMode.top) { /** @type {?} */ const width = elemOffset.width; /** @type {?} */ const top = targetRect.top + ((/** @type {?} */ (offsetTop))); this.setAffixStyle(e, { position: 'fixed', top, left: targetRect.left + elemOffset.left, maxHeight: `calc(100vh - ${top}px)`, width }); this.setPlaceholderStyle({ width, height: elemSize.height }); } else if (scrollTop <= elemOffset.top + elemSize.height + ((/** @type {?} */ (this._offsetBottom))) - targetInnerHeight && offsetMode.bottom) { /** @type {?} */ const targetBottomOffet = targetNode === window ? 0 : window.innerHeight - targetRect.bottom; /** @type {?} */ const width = elemOffset.width; this.setAffixStyle(e, { position: 'fixed', bottom: targetBottomOffet + ((/** @type {?} */ (this._offsetBottom))), left: targetRect.left + elemOffset.left, width }); this.setPlaceholderStyle({ width, height: elemOffset.height }); } else { if (e.type === 'resize' && this.affixStyle && this.affixStyle.position === 'fixed' && this.placeholderNode.offsetWidth) { this.setAffixStyle(e, Object.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: [` nz-affix { display: block; } `] }] } ]; /** @nocollapse */ NzAffixComponent.ctorParameters = () => [ { 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); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzAffixModule { } NzAffixModule.decorators = [ { type: NgModule, args: [{ declarations: [NzAffixComponent], exports: [NzAffixComponent], imports: [CommonModule], providers: [SCROLL_SERVICE_PROVIDER] },] } ]; /** * @fileoverview added by tsickle * @suppress {checkTypes,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]' },] } ]; /** @nocollapse */ NzClassListAddDirective.ctorParameters = () => [ { type: ElementRef }, { type: Renderer2 } ]; NzClassListAddDirective.propDecorators = { nzClassListAdd: [{ type: Input }] }; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ class NzStringTemplateOutletDirective { /** * @param {?} viewContainer * @param {?} defaultTemplate */ constructor(viewContainer, defaultTemplate) { this.viewContainer = viewContainer; this.defaultTemplate = defaultTemplate; this.inputTemplate = null; this.inputViewRef = null; this.defaultViewRef = null; } /** * @param {?} value * @return {?} */ set nzStringTemplateOutlet(value) { if (value instanceof TemplateRef) { this.isTemplate = true; this.inputTemplate = value; } else { this.isTemplate = false; } this.updateView(); } /** * @return {?} */ updateView() { 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 = () => [ { type: ViewContainerRef }, { type: TemplateRef } ]; NzStringTemplateOutletDirective.propDecorators = { nzStringTemplateOutlet: [{ type: Input }] }; /** * @fileoverview added by tsickle * @suppress {checkTypes,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,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** * @param {?} prefix * @return {?} */ function getRegExp(prefix) { /** @type {?} */ const prefixArray = Array.isArray(prefix) ? prefix : [prefix]; /** @type {?} */ let 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 (typeof value !== 'string') { return []; } /** @type {?} */ const regex = getRegExp(prefix); /** @type {?} */ const mentions = value.match(regex); return mentions !== null ? mentions.map((/** * @param {?} e * @return {?} */ e => 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 {?} */ const 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 {?} */ const 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 {?} */ const 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 {?} */ const isBrowser = typeof window !== 'undefined'; // tslint:disable-next-line:no-any /** @type {?} */ const isFirefox = isBrowser && ((/** @type {?} */ (window))).mozInnerScreenX != null; /** @type {?} */ const _parseInt = (/** * @param {?} str * @return {?} */ (str) => 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 {?} */ const debug = (options && options.debug) || false; if (debug) { /** @type {?} */ const 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 {?} */ const div = document.createElement('div'); div.id = 'input-textarea-caret-position-mirror-div'; document.body.appendChild(div); /** @type {?} */ const style$$1 = div.style; // tslint:disable-next-line:no-any /** @type {?} */ const computed = window.getComputedStyle ? window.getComputedStyle(element) : ((/** @type {?} */ (element))).currentStyle; // currentStyle for IE < 9 /** @type {?} */ const 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 {?} */ (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 {?} */ const 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 {?} */ const 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 {?} */ const fontSize = getComputedStyle(element).getPropertyValue('font-size'); /** @type {?} */ const 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 {?} */ 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,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 {?} */ const NZ_ICONS$$1 = new InjectionToken('nz_icons'); /** @type {?} */ const NZ_ICON_DEFAULT_TWOTONE_COLOR$$1 = new InjectionToken('nz_icon_default_twotone_color'); /** @type {?} */ const DEFAULT_TWOTONE_COLOR$$1 = '#1890ff'; /** @type {?} */ const 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. */ class NzIconService$$1 extends IconService { /** * @param {?} rendererFactory * @param {?} sanitizer * @param {?} handler * @param {?} document * @param {?} icons * @param {?} defaultColor */ constructor(rendererFactory, sanitizer, handler, document, icons, defaultColor) { super(rendererFactory, handler, document, sanitizer); 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(...NZ_ICONS_USED_BY_ZORRO$$1, ...(this.icons || [])); /** @type {?} */ let primaryColor = DEFAULT_TWOTONE_COLOR$$1; if (this.defaultColor) { if (this.defaultColor.startsWith('#')) { primaryColor = this.defaultColor; } else { console.warn('[NG-ZORRO]: twotone color must be a hex color!'); } } this.twoToneColor = { primaryColor }; } /** * @param {?} type * @return {?} */ warnAPI(type) { if (type === 'old' && !this.warnedAboutAPI) { console.warn(`<i class="anticon"></i> would be deprecated soon. Please use <i nz-icon type=""></i> API.`); this.warnedAboutAPI = true; } if (type === 'cross' && !this.warnedAboutCross) { console.warn(`'cross' icon is replaced by 'close' icon.`); this.warnedAboutCross = true; } if (type === 'vertical' && !this.warnedAboutVertical) { console.warn(`'verticle' is misspelled, would be corrected in the next major version.`); this.warnedAboutVertical = true; } } /** * @param {?} svg * @return {?} */ normalizeSvgElement(svg) { if (!svg.getAttribute('viewBox')) { this._renderer.setAttribute(svg, 'viewBox', '0 0 1024 1024'); } if (!svg.getAttribute('width') || !svg.getAttribute('height')) { this._renderer.setAttribute(svg, 'width', '1em'); this._renderer.setAttribute(svg, 'height', '1em'); } if (!svg.getAttribute('fill')) { this._renderer.setAttribute(svg, 'fill', 'currentColor'); } } /** * @param {?} opt * @return {?} */ fetchFromIconfont(opt) { const { scriptUrl } = opt; if (this.document && !this.iconfontCache.has(scriptUrl)) { /** @type {?} */ const script = this._renderer.createElement('script'); this._renderer.setAttribute(script, 'src', scriptUrl); this._renderer.setAttribute(script, 'data-namespace', scriptUrl.replace(/^(https?|http):/g, '')); this._renderer.appendChild(this.document.body, script); this.iconfontCache.add(scriptUrl); } } /** * @param {?} type * @return {?} */ createIconfontIcon(type) { return this._createSVGElementFromString(`<svg><use xlink:href="${type}"></svg>`); } } NzIconService$$1.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ NzIconService$$1.ctorParameters = () => [ { type: RendererFactory2 }, { type: DomSanitizer }, { type: HttpBackend, decorators: [{ type: Optional }] }, { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] }, { type: Array, decorators: [{ type: Optional }, { type: Inject, args: [NZ_ICONS$$1,] }] }, { type: String, decorators: [{ type: Optional }, { type: Inject, args: [NZ_ICON_DEFAULT_TWOTONE_COLOR$$1,] }] } ]; /** @nocollapse */ NzIconService$$1.ngInjectableDef = defineInjectable({ factory: function NzIconService_Factory() { return new NzIconService$$1(inject(RendererFactory2), inject(DomSanitizer), inject(HttpBackend, 8), inject(DOCUMENT, 8), inject(NZ_ICONS$$1, 8), inject(NZ_ICON_DEFAULT_TWOTONE_COLOR$$1, 8)); }, token: NzIconService$$1, providedIn: "root" }); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ /** @type {?} */ const iconTypeRE = /^anticon\-\w/; /** @type {?} */ const getIconTypeClass = (/** * @param {?} className * @return {?} */ (className) => { if (!className) { return undefined; } else { /** @type {?} */ const classArr = className.split(/\s/); /** @type {?} */ const index = classArr.findIndex((/** * @param {?} cls * @return {?} */ cls => cls !== 'anticon' && cls !== 'anticon-spin' && !!cls.match(iconTypeRE))); return index === -1 ? undefined : { name: classArr[index], index }; } }); /** @type {?} */ const normalizeType = (/** * @param {?} rawType * @return {?} */ (rawType) => { /** @type {?} */ const ret = { type: rawType, crossError: false, verticalError: false }; ret.type = rawType ? rawType.replace('anticon-', '') : ''; if (ret.type.includes('verticle')) { ret.type = 'up'; ret.verticalError = true; } if (ret.type.startsWith('cross')) { ret.type = 'close'; ret.crossError = true; } return ret; }); /** * This directive extends IconDirective to provide: * * - IconFont support * - spinning * - old API compatibility * * \@break-changes * * - old API compatibility, icon class names would not be supported. * - properties that not started with `nz`. */ class NzIconDirective extends IconDirective { /** * @param {?} iconService * @param {?} elementRef