UNPKG

ng-zorro-antd

Version:

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

387 lines (376 loc) 15.6 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/cdk/layout'), require('@angular/cdk/platform'), require('ng-zorro-antd/core'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) : typeof define === 'function' && define.amd ? define('ng-zorro-antd/grid', ['exports', '@angular/core', '@angular/cdk/layout', '@angular/cdk/platform', 'ng-zorro-antd/core', 'rxjs', 'rxjs/operators', '@angular/common'], factory) : (global = global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].grid = {}), global.ng.core, global.ng.cdk.layout, global.ng.cdk.platform, global['ng-zorro-antd'].core, global.rxjs, global.rxjs.operators, global.ng.common)); }(this, function (exports, core, layout, platform, core$1, rxjs, operators, common) { 'use strict'; /*! ***************************************************************************** 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. ***************************************************************************** */ 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); }; /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzRowDirective = /** @class */ (function () { function NzRowDirective(elementRef, renderer, nzUpdateHostClassService, mediaMatcher, ngZone, platform) { this.elementRef = elementRef; this.renderer = renderer; this.nzUpdateHostClassService = nzUpdateHostClassService; this.mediaMatcher = mediaMatcher; this.ngZone = ngZone; this.platform = platform; this.nzAlign = 'top'; this.nzJustify = 'start'; this.el = this.elementRef.nativeElement; this.prefixCls = 'ant-row'; this.actualGutter$ = new rxjs.Subject(); this.destroy$ = new rxjs.Subject(); } /** * @return {?} */ NzRowDirective.prototype.calculateGutter = /** * @return {?} */ function () { if (typeof this.nzGutter !== 'object') { return this.nzGutter; } else if (this.breakPoint && this.nzGutter[this.breakPoint]) { return this.nzGutter[this.breakPoint]; } else { return 0; } }; /** * @return {?} */ NzRowDirective.prototype.updateGutter = /** * @return {?} */ function () { /** @type {?} */ var actualGutter = this.calculateGutter(); if (this.actualGutter !== actualGutter) { this.actualGutter = actualGutter; this.actualGutter$.next(this.actualGutter); this.renderer.setStyle(this.el, 'margin-left', "-" + this.actualGutter / 2 + "px"); this.renderer.setStyle(this.el, 'margin-right', "-" + this.actualGutter / 2 + "px"); } }; /** * @return {?} */ NzRowDirective.prototype.watchMedia = /** * @return {?} */ function () { var _this = this; Object.keys(core$1.responsiveMap).map((/** * @param {?} screen * @return {?} */ function (screen) { /** @type {?} */ var castBP = (/** @type {?} */ (screen)); /** @type {?} */ var matchBelow = _this.mediaMatcher.matchMedia(core$1.responsiveMap[castBP]).matches; if (matchBelow) { _this.breakPoint = castBP; } })); this.updateGutter(); }; /** temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289*/ /** * temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289 * @return {?} */ NzRowDirective.prototype.setClassMap = /** * temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289 * @return {?} */ function () { var _a; /** @type {?} */ var classMap = (_a = {}, _a["" + this.prefixCls] = !this.nzType, _a[this.prefixCls + "-" + this.nzType] = this.nzType, _a[this.prefixCls + "-" + this.nzType + "-" + this.nzAlign] = this.nzType && this.nzAlign, _a[this.prefixCls + "-" + this.nzType + "-" + this.nzJustify] = this.nzType && this.nzJustify, _a); this.nzUpdateHostClassService.updateHostClass(this.el, classMap); }; /** * @return {?} */ NzRowDirective.prototype.ngOnInit = /** * @return {?} */ function () { this.setClassMap(); this.watchMedia(); }; /** * @param {?} changes * @return {?} */ NzRowDirective.prototype.ngOnChanges = /** * @param {?} changes * @return {?} */ function (changes) { if (changes.nzType || changes.nzAlign || changes.nzJustify) { this.setClassMap(); } if (changes.nzGutter) { this.updateGutter(); } }; /** * @return {?} */ NzRowDirective.prototype.ngAfterViewInit = /** * @return {?} */ function () { var _this = this; if (this.platform.isBrowser) { this.ngZone.runOutsideAngular((/** * @return {?} */ function () { rxjs.fromEvent(window, 'resize') .pipe(operators.auditTime(16), operators.takeUntil(_this.destroy$)) .subscribe((/** * @return {?} */ function () { return _this.watchMedia(); })); })); } }; /** * @return {?} */ NzRowDirective.prototype.ngOnDestroy = /** * @return {?} */ function () { this.destroy$.next(); this.destroy$.complete(); }; NzRowDirective.decorators = [ { type: core.Directive, args: [{ selector: '[nz-row],nz-row', exportAs: 'nzRow', providers: [core$1.NzUpdateHostClassService] },] } ]; /** @nocollapse */ NzRowDirective.ctorParameters = function () { return [ { type: core.ElementRef }, { type: core.Renderer2 }, { type: core$1.NzUpdateHostClassService }, { type: layout.MediaMatcher }, { type: core.NgZone }, { type: platform.Platform } ]; }; NzRowDirective.propDecorators = { nzType: [{ type: core.Input }], nzAlign: [{ type: core.Input }], nzJustify: [{ type: core.Input }], nzGutter: [{ type: core.Input }] }; return NzRowDirective; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzColDirective = /** @class */ (function () { function NzColDirective(nzUpdateHostClassService, elementRef, nzRowDirective, renderer) { this.nzUpdateHostClassService = nzUpdateHostClassService; this.elementRef = elementRef; this.nzRowDirective = nzRowDirective; this.renderer = renderer; this.el = this.elementRef.nativeElement; this.prefixCls = 'ant-col'; this.destroy$ = new rxjs.Subject(); } /** temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289*/ /** * temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289 * @return {?} */ NzColDirective.prototype.setClassMap = /** * temp solution since no method add classMap to host https://github.com/angular/angular/issues/7289 * @return {?} */ function () { var _a; /** @type {?} */ var classMap = __assign((_a = {}, _a[this.prefixCls + "-" + this.nzSpan] = core$1.isNotNil(this.nzSpan), _a[this.prefixCls + "-order-" + this.nzOrder] = core$1.isNotNil(this.nzOrder), _a[this.prefixCls + "-offset-" + this.nzOffset] = core$1.isNotNil(this.nzOffset), _a[this.prefixCls + "-pull-" + this.nzPull] = core$1.isNotNil(this.nzPull), _a[this.prefixCls + "-push-" + this.nzPush] = core$1.isNotNil(this.nzPush), _a), this.generateClass()); this.nzUpdateHostClassService.updateHostClass(this.el, classMap); }; /** * @return {?} */ NzColDirective.prototype.generateClass = /** * @return {?} */ function () { var _this = this; /** @type {?} */ var listOfSizeInputName = ['nzXs', 'nzSm', 'nzMd', 'nzLg', 'nzXl', 'nzXXl']; /** @type {?} */ var listClassMap = {}; listOfSizeInputName.forEach((/** * @param {?} name * @return {?} */ function (name) { /** @type {?} */ var sizeName = name.replace('nz', '').toLowerCase(); if (core$1.isNotNil(_this[name])) { if (typeof _this[name] === 'number' || typeof _this[name] === 'string') { listClassMap[_this.prefixCls + "-" + sizeName + "-" + _this[name]] = true; } else { /** @type {?} */ var embedded_1 = (/** @type {?} */ (_this[name])); /** @type {?} */ var prefixArray = ['span', 'pull', 'push', 'offset', 'order']; prefixArray.forEach((/** * @param {?} prefix * @return {?} */ function (prefix) { /** @type {?} */ var prefixClass = prefix === 'span' ? '-' : "-" + prefix + "-"; listClassMap[_this.prefixCls + "-" + sizeName + prefixClass + embedded_1[prefix]] = embedded_1 && core$1.isNotNil(embedded_1[prefix]); })); } } })); return listClassMap; }; /** * @return {?} */ NzColDirective.prototype.ngOnChanges = /** * @return {?} */ function () { this.setClassMap(); }; /** * @return {?} */ NzColDirective.prototype.ngAfterViewInit = /** * @return {?} */ function () { var _this = this; if (this.nzRowDirective) { this.nzRowDirective.actualGutter$ .pipe(operators.startWith(this.nzRowDirective.actualGutter), operators.takeUntil(this.destroy$)) .subscribe((/** * @param {?} actualGutter * @return {?} */ function (actualGutter) { _this.renderer.setStyle(_this.el, 'padding-left', actualGutter / 2 + "px"); _this.renderer.setStyle(_this.el, 'padding-right', actualGutter / 2 + "px"); })); } }; /** * @return {?} */ NzColDirective.prototype.ngOnInit = /** * @return {?} */ function () { this.setClassMap(); }; /** * @return {?} */ NzColDirective.prototype.ngOnDestroy = /** * @return {?} */ function () { this.destroy$.next(); this.destroy$.complete(); }; NzColDirective.decorators = [ { type: core.Directive, args: [{ selector: '[nz-col],nz-col', exportAs: 'nzCol', providers: [core$1.NzUpdateHostClassService] },] } ]; /** @nocollapse */ NzColDirective.ctorParameters = function () { return [ { type: core$1.NzUpdateHostClassService }, { type: core.ElementRef }, { type: NzRowDirective, decorators: [{ type: core.Optional }, { type: core.Host }] }, { type: core.Renderer2 } ]; }; NzColDirective.propDecorators = { nzSpan: [{ type: core.Input }], nzOrder: [{ type: core.Input }], nzOffset: [{ type: core.Input }], nzPush: [{ type: core.Input }], nzPull: [{ type: core.Input }], nzXs: [{ type: core.Input }], nzSm: [{ type: core.Input }], nzMd: [{ type: core.Input }], nzLg: [{ type: core.Input }], nzXl: [{ type: core.Input }], nzXXl: [{ type: core.Input }] }; return NzColDirective; }()); /** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ var NzGridModule = /** @class */ (function () { function NzGridModule() { } NzGridModule.decorators = [ { type: core.NgModule, args: [{ declarations: [NzColDirective, NzRowDirective], exports: [NzColDirective, NzRowDirective], imports: [common.CommonModule, layout.LayoutModule, platform.PlatformModule] },] } ]; return NzGridModule; }()); exports.NzColDirective = NzColDirective; exports.NzGridModule = NzGridModule; exports.NzRowDirective = NzRowDirective; Object.defineProperty(exports, '__esModule', { value: true }); })); //# sourceMappingURL=ng-zorro-antd-grid.umd.js.map