ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
1,025 lines (1,011 loc) • 128 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/bidi'), require('@angular/cdk/platform'), require('@angular/cdk/scrolling'), require('@angular/common'), require('@angular/core'), require('@angular/forms'), require('ng-zorro-antd/button'), require('ng-zorro-antd/checkbox'), require('ng-zorro-antd/core/outlet'), require('ng-zorro-antd/core/resize-observers'), require('ng-zorro-antd/dropdown'), require('ng-zorro-antd/empty'), require('ng-zorro-antd/i18n'), require('ng-zorro-antd/icon'), require('ng-zorro-antd/menu'), require('ng-zorro-antd/pagination'), require('ng-zorro-antd/radio'), require('ng-zorro-antd/spin'), require('ng-zorro-antd/core/util'), require('rxjs'), require('rxjs/operators'), require('ng-zorro-antd/core/services'), require('ng-zorro-antd/core/config')) :
typeof define === 'function' && define.amd ? define('ng-zorro-antd/table', ['exports', '@angular/cdk/bidi', '@angular/cdk/platform', '@angular/cdk/scrolling', '@angular/common', '@angular/core', '@angular/forms', 'ng-zorro-antd/button', 'ng-zorro-antd/checkbox', 'ng-zorro-antd/core/outlet', 'ng-zorro-antd/core/resize-observers', 'ng-zorro-antd/dropdown', 'ng-zorro-antd/empty', 'ng-zorro-antd/i18n', 'ng-zorro-antd/icon', 'ng-zorro-antd/menu', 'ng-zorro-antd/pagination', 'ng-zorro-antd/radio', 'ng-zorro-antd/spin', 'ng-zorro-antd/core/util', 'rxjs', 'rxjs/operators', 'ng-zorro-antd/core/services', 'ng-zorro-antd/core/config'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ng-zorro-antd'] = global['ng-zorro-antd'] || {}, global['ng-zorro-antd'].table = {}), global.ng.cdk.bidi, global.ng.cdk.platform, global.ng.cdk.scrolling, global.ng.common, global.ng.core, global.ng.forms, global['ng-zorro-antd'].button, global['ng-zorro-antd'].checkbox, global['ng-zorro-antd'].core.outlet, global['ng-zorro-antd'].core['resize-observers'], global['ng-zorro-antd'].dropdown, global['ng-zorro-antd'].empty, global['ng-zorro-antd'].i18n, global['ng-zorro-antd'].icon, global['ng-zorro-antd'].menu, global['ng-zorro-antd'].pagination, global['ng-zorro-antd'].radio, global['ng-zorro-antd'].spin, global['ng-zorro-antd'].core.util, global.rxjs, global.rxjs.operators, global['ng-zorro-antd'].core.services, global['ng-zorro-antd'].core.config));
}(this, (function (exports, bidi, platform, scrolling, common, core, forms, button, checkbox, outlet, resizeObservers, dropdown, empty, i18n, icon, menu, pagination, radio, spin, util, rxjs, operators, services, config) { 'use strict';
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzFilterTriggerComponent = /** @class */ (function () {
function NzFilterTriggerComponent(cdr, elementRef) {
this.cdr = cdr;
this.elementRef = elementRef;
this.nzActive = false;
this.nzVisible = false;
this.nzHasBackdrop = false;
this.nzVisibleChange = new core.EventEmitter();
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-table-filter-trigger-container');
}
NzFilterTriggerComponent.prototype.onVisibleChange = function (visible) {
this.nzVisible = visible;
this.nzVisibleChange.next(visible);
};
NzFilterTriggerComponent.prototype.onFilterClick = function ($event) {
$event.stopPropagation();
};
NzFilterTriggerComponent.prototype.hide = function () {
this.nzVisible = false;
this.cdr.markForCheck();
};
NzFilterTriggerComponent.prototype.show = function () {
this.nzVisible = true;
this.cdr.markForCheck();
};
return NzFilterTriggerComponent;
}());
NzFilterTriggerComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-filter-trigger',
exportAs: "nzFilterTrigger",
changeDetection: core.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
encapsulation: core.ViewEncapsulation.None,
template: "\n <span\n nz-dropdown\n class=\"ant-table-filter-trigger\"\n nzTrigger=\"click\"\n nzPlacement=\"bottomRight\"\n [nzHasBackdrop]=\"nzHasBackdrop\"\n [nzClickHide]=\"false\"\n [nzDropdownMenu]=\"nzDropdownMenu\"\n [class.active]=\"nzActive\"\n [class.ant-table-filter-open]=\"nzVisible\"\n [nzVisible]=\"nzVisible\"\n (nzVisibleChange)=\"onVisibleChange($event)\"\n (click)=\"onFilterClick($event)\"\n >\n <ng-content></ng-content>\n </span>\n ",
host: {
'[class.ant-table-filter-trigger-container-open]': 'nzVisible'
}
},] }
];
NzFilterTriggerComponent.ctorParameters = function () { return [
{ type: core.ChangeDetectorRef },
{ type: core.ElementRef }
]; };
NzFilterTriggerComponent.propDecorators = {
nzActive: [{ type: core.Input }],
nzDropdownMenu: [{ type: core.Input }],
nzVisible: [{ type: core.Input }],
nzHasBackdrop: [{ type: core.Input }],
nzVisibleChange: [{ type: core.Output }]
};
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzTableFilterComponent = /** @class */ (function () {
function NzTableFilterComponent(cdr, i18n, elementRef) {
this.cdr = cdr;
this.i18n = i18n;
this.elementRef = elementRef;
this.contentTemplate = null;
this.customFilter = false;
this.extraTemplate = null;
this.filterMultiple = true;
this.listOfFilter = [];
this.filterChange = new core.EventEmitter();
this.destroy$ = new rxjs.Subject();
this.isChecked = false;
this.isVisible = false;
this.listOfParsedFilter = [];
this.listOfChecked = [];
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-table-filter-column');
}
NzTableFilterComponent.prototype.trackByValue = function (_, item) {
return item.value;
};
NzTableFilterComponent.prototype.check = function (filter) {
if (this.filterMultiple) {
this.listOfParsedFilter = this.listOfParsedFilter.map(function (item) {
if (item === filter) {
return Object.assign(Object.assign({}, item), { checked: !filter.checked });
}
else {
return item;
}
});
filter.checked = !filter.checked;
}
else {
this.listOfParsedFilter = this.listOfParsedFilter.map(function (item) {
return Object.assign(Object.assign({}, item), { checked: item === filter });
});
}
this.isChecked = this.getCheckedStatus(this.listOfParsedFilter);
};
NzTableFilterComponent.prototype.confirm = function () {
this.isVisible = false;
this.emitFilterData();
};
NzTableFilterComponent.prototype.reset = function () {
this.isVisible = false;
this.listOfParsedFilter = this.parseListOfFilter(this.listOfFilter, true);
this.isChecked = this.getCheckedStatus(this.listOfParsedFilter);
this.emitFilterData();
};
NzTableFilterComponent.prototype.onVisibleChange = function (value) {
this.isVisible = value;
if (!value) {
this.emitFilterData();
}
else {
this.listOfChecked = this.listOfParsedFilter.filter(function (item) { return item.checked; }).map(function (item) { return item.value; });
}
};
NzTableFilterComponent.prototype.emitFilterData = function () {
var listOfChecked = this.listOfParsedFilter.filter(function (item) { return item.checked; }).map(function (item) { return item.value; });
if (!util.arraysEqual(this.listOfChecked, listOfChecked)) {
if (this.filterMultiple) {
this.filterChange.emit(listOfChecked);
}
else {
this.filterChange.emit(listOfChecked.length > 0 ? listOfChecked[0] : null);
}
}
};
NzTableFilterComponent.prototype.parseListOfFilter = function (listOfFilter, reset) {
return listOfFilter.map(function (item) {
var checked = reset ? false : !!item.byDefault;
return { text: item.text, value: item.value, checked: checked };
});
};
NzTableFilterComponent.prototype.getCheckedStatus = function (listOfParsedFilter) {
return listOfParsedFilter.some(function (item) { return item.checked; });
};
NzTableFilterComponent.prototype.ngOnInit = function () {
var _this = this;
this.i18n.localeChange.pipe(operators.takeUntil(this.destroy$)).subscribe(function () {
_this.locale = _this.i18n.getLocaleData('Table');
_this.cdr.markForCheck();
});
};
NzTableFilterComponent.prototype.ngOnChanges = function (changes) {
var listOfFilter = changes.listOfFilter;
if (listOfFilter && this.listOfFilter && this.listOfFilter.length) {
this.listOfParsedFilter = this.parseListOfFilter(this.listOfFilter);
this.isChecked = this.getCheckedStatus(this.listOfParsedFilter);
}
};
NzTableFilterComponent.prototype.ngOnDestroy = function () {
this.destroy$.next();
this.destroy$.complete();
};
return NzTableFilterComponent;
}());
NzTableFilterComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-table-filter',
preserveWhitespaces: false,
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
template: "\n <span class=\"ant-table-filter-column-title\">\n <ng-template [ngTemplateOutlet]=\"contentTemplate\"></ng-template>\n </span>\n <ng-container *ngIf=\"!customFilter; else extraTemplate\">\n <nz-filter-trigger\n [nzVisible]=\"isVisible\"\n [nzActive]=\"isChecked\"\n [nzDropdownMenu]=\"filterMenu\"\n (nzVisibleChange)=\"onVisibleChange($event)\"\n >\n <i nz-icon nzType=\"filter\" nzTheme=\"fill\"></i>\n </nz-filter-trigger>\n <nz-dropdown-menu #filterMenu=\"nzDropdownMenu\">\n <div class=\"ant-table-filter-dropdown\">\n <ul nz-menu>\n <li nz-menu-item [nzSelected]=\"f.checked\" *ngFor=\"let f of listOfParsedFilter; trackBy: trackByValue\" (click)=\"check(f)\">\n <label nz-radio *ngIf=\"!filterMultiple\" [ngModel]=\"f.checked\" (ngModelChange)=\"check(f)\"></label>\n <label nz-checkbox *ngIf=\"filterMultiple\" [ngModel]=\"f.checked\" (ngModelChange)=\"check(f)\"></label>\n <span>{{ f.text }}</span>\n </li>\n </ul>\n <div class=\"ant-table-filter-dropdown-btns\">\n <button nz-button nzType=\"link\" nzSize=\"small\" (click)=\"reset()\" [disabled]=\"!isChecked\">{{ locale.filterReset }}</button>\n <button nz-button nzType=\"primary\" nzSize=\"small\" (click)=\"confirm()\">{{ locale.filterConfirm }}</button>\n </div>\n </div>\n </nz-dropdown-menu>\n </ng-container>\n "
},] }
];
NzTableFilterComponent.ctorParameters = function () { return [
{ type: core.ChangeDetectorRef },
{ type: i18n.NzI18nService },
{ type: core.ElementRef }
]; };
NzTableFilterComponent.propDecorators = {
contentTemplate: [{ type: core.Input }],
customFilter: [{ type: core.Input }],
extraTemplate: [{ type: core.Input }],
filterMultiple: [{ type: core.Input }],
listOfFilter: [{ type: core.Input }],
filterChange: [{ type: core.Output }]
};
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzRowExpandButtonDirective = /** @class */ (function () {
function NzRowExpandButtonDirective(elementRef) {
this.elementRef = elementRef;
this.expand = false;
this.spaceMode = false;
this.expandChange = new core.EventEmitter();
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-table-row-expand-icon');
}
NzRowExpandButtonDirective.prototype.onHostClick = function () {
if (!this.spaceMode) {
this.expand = !this.expand;
this.expandChange.next(this.expand);
}
};
return NzRowExpandButtonDirective;
}());
NzRowExpandButtonDirective.decorators = [
{ type: core.Directive, args: [{
selector: 'button[nz-row-expand-button]',
host: {
'[type]': "'button'",
'[class.ant-table-row-expand-icon-expanded]': "!spaceMode && expand === true",
'[class.ant-table-row-expand-icon-collapsed]': "!spaceMode && expand === false",
'[class.ant-table-row-expand-icon-spaced]': 'spaceMode',
'(click)': 'onHostClick()'
}
},] }
];
NzRowExpandButtonDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NzRowExpandButtonDirective.propDecorators = {
expand: [{ type: core.Input }],
spaceMode: [{ type: core.Input }],
expandChange: [{ type: core.Output }]
};
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzRowIndentDirective = /** @class */ (function () {
function NzRowIndentDirective(elementRef) {
this.elementRef = elementRef;
this.indentSize = 0;
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-table-row-indent');
}
return NzRowIndentDirective;
}());
NzRowIndentDirective.decorators = [
{ type: core.Directive, args: [{
selector: 'nz-row-indent',
host: {
'[style.padding-left.px]': 'indentSize'
}
},] }
];
NzRowIndentDirective.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NzRowIndentDirective.propDecorators = {
indentSize: [{ type: core.Input }]
};
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzTableSelectionComponent = /** @class */ (function () {
function NzTableSelectionComponent(elementRef) {
this.elementRef = elementRef;
this.listOfSelections = [];
this.checked = false;
this.disabled = false;
this.indeterminate = false;
this.showCheckbox = false;
this.showRowSelection = false;
this.checkedChange = new core.EventEmitter();
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-table-selection');
}
NzTableSelectionComponent.prototype.onCheckedChange = function (checked) {
this.checked = checked;
this.checkedChange.emit(checked);
};
return NzTableSelectionComponent;
}());
NzTableSelectionComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-table-selection',
preserveWhitespaces: false,
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
template: "\n <label\n *ngIf=\"showCheckbox\"\n nz-checkbox\n [class.ant-table-selection-select-all-custom]=\"showRowSelection\"\n [ngModel]=\"checked\"\n [nzDisabled]=\"disabled\"\n [nzIndeterminate]=\"indeterminate\"\n (ngModelChange)=\"onCheckedChange($event)\"\n ></label>\n <div class=\"ant-table-selection-extra\" *ngIf=\"showRowSelection\">\n <span nz-dropdown class=\"ant-table-selection-down\" nzPlacement=\"bottomLeft\" [nzDropdownMenu]=\"selectionMenu\">\n <i nz-icon nzType=\"down\"></i>\n </span>\n <nz-dropdown-menu #selectionMenu=\"nzDropdownMenu\">\n <ul nz-menu class=\"ant-table-selection-menu\">\n <li nz-menu-item *ngFor=\"let selection of listOfSelections\" (click)=\"selection.onSelect()\">\n {{ selection.text }}\n </li>\n </ul>\n </nz-dropdown-menu>\n </div>\n "
},] }
];
NzTableSelectionComponent.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NzTableSelectionComponent.propDecorators = {
listOfSelections: [{ type: core.Input }],
checked: [{ type: core.Input }],
disabled: [{ type: core.Input }],
indeterminate: [{ type: core.Input }],
showCheckbox: [{ type: core.Input }],
showRowSelection: [{ type: core.Input }],
checkedChange: [{ type: core.Output }]
};
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzTableSortersComponent = /** @class */ (function () {
function NzTableSortersComponent(elementRef) {
this.elementRef = elementRef;
this.sortDirections = ['ascend', 'descend', null];
this.sortOrder = null;
this.contentTemplate = null;
this.isUp = false;
this.isDown = false;
// TODO: move to host after View Engine deprecation
this.elementRef.nativeElement.classList.add('ant-table-column-sorters');
}
NzTableSortersComponent.prototype.ngOnChanges = function (changes) {
var sortDirections = changes.sortDirections;
if (sortDirections) {
this.isUp = this.sortDirections.indexOf('ascend') !== -1;
this.isDown = this.sortDirections.indexOf('descend') !== -1;
}
};
return NzTableSortersComponent;
}());
NzTableSortersComponent.decorators = [
{ type: core.Component, args: [{
selector: 'nz-table-sorters',
preserveWhitespaces: false,
changeDetection: core.ChangeDetectionStrategy.OnPush,
encapsulation: core.ViewEncapsulation.None,
template: "\n <span><ng-template [ngTemplateOutlet]=\"contentTemplate\"></ng-template></span>\n <span class=\"ant-table-column-sorter\" [class.ant-table-column-sorter-full]=\"isDown && isUp\">\n <span class=\"ant-table-column-sorter-inner\">\n <i nz-icon nzType=\"caret-up\" *ngIf=\"isUp\" class=\"ant-table-column-sorter-up\" [class.active]=\"sortOrder == 'ascend'\"></i>\n <i nz-icon nzType=\"caret-down\" *ngIf=\"isDown\" class=\"ant-table-column-sorter-down\" [class.active]=\"sortOrder == 'descend'\"></i>\n </span>\n </span>\n "
},] }
];
NzTableSortersComponent.ctorParameters = function () { return [
{ type: core.ElementRef }
]; };
NzTableSortersComponent.propDecorators = {
sortDirections: [{ type: core.Input }],
sortOrder: [{ type: core.Input }],
contentTemplate: [{ type: core.Input }]
};
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzCellFixedDirective = /** @class */ (function () {
function NzCellFixedDirective(renderer, elementRef) {
this.renderer = renderer;
this.elementRef = elementRef;
this.nzRight = false;
this.nzLeft = false;
this.colspan = null;
this.colSpan = null;
this.changes$ = new rxjs.Subject();
this.isAutoLeft = false;
this.isAutoRight = false;
this.isFixedLeft = false;
this.isFixedRight = false;
this.isFixed = false;
}
NzCellFixedDirective.prototype.setAutoLeftWidth = function (autoLeft) {
this.renderer.setStyle(this.elementRef.nativeElement, 'left', autoLeft);
};
NzCellFixedDirective.prototype.setAutoRightWidth = function (autoRight) {
this.renderer.setStyle(this.elementRef.nativeElement, 'right', autoRight);
};
NzCellFixedDirective.prototype.setIsFirstRight = function (isFirstRight) {
this.setFixClass(isFirstRight, 'ant-table-cell-fix-right-first');
};
NzCellFixedDirective.prototype.setIsLastLeft = function (isLastLeft) {
this.setFixClass(isLastLeft, 'ant-table-cell-fix-left-last');
};
NzCellFixedDirective.prototype.setFixClass = function (flag, className) {
// the setFixClass function may call many times, so remove it first.
this.renderer.removeClass(this.elementRef.nativeElement, className);
if (flag) {
this.renderer.addClass(this.elementRef.nativeElement, className);
}
};
NzCellFixedDirective.prototype.ngOnChanges = function () {
this.setIsFirstRight(false);
this.setIsLastLeft(false);
this.isAutoLeft = this.nzLeft === '' || this.nzLeft === true;
this.isAutoRight = this.nzRight === '' || this.nzRight === true;
this.isFixedLeft = this.nzLeft !== false;
this.isFixedRight = this.nzRight !== false;
this.isFixed = this.isFixedLeft || this.isFixedRight;
var validatePx = function (value) {
if (typeof value === 'string' && value !== '') {
return value;
}
else {
return null;
}
};
this.setAutoLeftWidth(validatePx(this.nzLeft));
this.setAutoRightWidth(validatePx(this.nzRight));
this.changes$.next();
};
return NzCellFixedDirective;
}());
NzCellFixedDirective.decorators = [
{ type: core.Directive, args: [{
selector: 'td[nzRight],th[nzRight],td[nzLeft],th[nzLeft]',
host: {
'[class.ant-table-cell-fix-right]': "isFixedRight",
'[class.ant-table-cell-fix-left]': "isFixedLeft",
'[style.position]': "isFixed? 'sticky' : null"
}
},] }
];
NzCellFixedDirective.ctorParameters = function () { return [
{ type: core.Renderer2 },
{ type: core.ElementRef }
]; };
NzCellFixedDirective.propDecorators = {
nzRight: [{ type: core.Input }],
nzLeft: [{ type: core.Input }],
colspan: [{ type: core.Input }],
colSpan: [{ type: core.Input }]
};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* 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 (Object.prototype.hasOwnProperty.call(b, p))
d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
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 __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
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 __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); };
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try {
step(generator.next(value));
}
catch (e) {
reject(e);
} }
function rejected(value) { try {
step(generator["throw"](value));
}
catch (e) {
reject(e);
} }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function () { if (t[0] & 1)
throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
}
catch (e) {
op = [6, e];
y = 0;
}
finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
}
var __createBinding = Object.create ? (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
}) : (function (o, m, k, k2) {
if (k2 === undefined)
k2 = k;
o[k2] = m[k];
});
function __exportStar(m, o) {
for (var p in m)
if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
__createBinding(o, m, p);
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function () {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
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;
}
/** @deprecated */
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
/** @deprecated */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
function __spreadArray(to, from) {
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
to[j] = from[i];
return to;
}
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n])
i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try {
step(g[n](v));
}
catch (e) {
settle(q[0][3], e);
} }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length)
resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
}
else {
cooked.raw = raw;
}
return cooked;
}
;
var __setModuleDefault = Object.create ? (function (o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function (o, v) {
o["default"] = v;
};
function __importStar(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null)
for (var k in mod)
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
__createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
var NzTableStyleService = /** @class */ (function () {
function NzTableStyleService() {
this.theadTemplate$ = new rxjs.ReplaySubject(1);
this.hasFixLeft$ = new rxjs.ReplaySubject(1);
this.hasFixRight$ = new rxjs.ReplaySubject(1);
this.hostWidth$ = new rxjs.ReplaySubject(1);
this.columnCount$ = new rxjs.ReplaySubject(1);
this.showEmpty$ = new rxjs.ReplaySubject(1);
this.noResult$ = new rxjs.ReplaySubject(1);
this.listOfThWidthConfigPx$ = new rxjs.BehaviorSubject([]);
this.tableWidthConfigPx$ = new rxjs.BehaviorSubject([]);
this.manualWidthConfigPx$ = rxjs.combineLatest([this.tableWidthConfigPx$, this.listOfThWidthConfigPx$]).pipe(operators.map(function (_a) {
var _b = __read(_a, 2), widthConfig = _b[0], listOfWidth = _b[1];
return (widthConfig.length ? widthConfig : listOfWidth);
}));
this.listOfAutoWidthPx$ = new rxjs.ReplaySubject(1);
this.listOfListOfThWidthPx$ = rxjs.merge(
/** init with manual width **/
this.manualWidthConfigPx$, rxjs.combineLatest([this.listOfAutoWidthPx$, this.manualWidthConfigPx$]).pipe(operators.map(function (_a) {
var _b = __read(_a, 2), autoWidth = _b[0], manualWidth = _b[1];
/** use autoWidth until column length match **/
if (autoWidth.length === manualWidth.length) {
return autoWidth.map(function (width, index) {
if (width === '0px') {
return manualWidth[index] || null;
}
else {
return manualWidth[index] || width;
}
});
}
else {
return manualWidth;
}
})));
this.listOfMeasureColumn$ = new rxjs.ReplaySubject(1);
this.listOfListOfThWidth$ = this.listOfAutoWidthPx$.pipe(operators.map(function (list) { return list.map(function (width) { return parseInt(width, 10); }); }));
this.enableAutoMeasure$ = new rxjs.ReplaySubject(1);
}
NzTableStyleService.prototype.setTheadTemplate = function (template) {
this.theadTemplate$.next(template);
};
NzTableStyleService.prototype.setHasFixLeft = function (hasFixLeft) {
this.hasFixLeft$.next(hasFixLeft);
};
NzTableStyleService.prototype.setHasFixRight = function (hasFixRight) {
this.hasFixRight$.next(hasFixRight);
};
NzTableStyleService.prototype.setTableWidthConfig = function (widthConfig) {
this.tableWidthConfigPx$.next(widthConfig);
};
NzTableStyleService.prototype.setListOfTh = function (listOfTh) {
var columnCount = 0;
listOfTh.forEach(function (th) {
columnCount += (th.colspan && +th.colspan) || (th.colSpan && +th.colSpan) || 1;
});
var listOfThPx = listOfTh.map(function (item) { return item.nzWidth; });
this.columnCount$.next(columnCount);
this.listOfThWidthConfigPx$.next(listOfThPx);
};
NzTableStyleService.prototype.setListOfMeasureColumn = function (listOfTh) {
var listOfKeys = [];
listOfTh.forEach(function (th) {
var length = (th.colspan && +th.colspan) || (th.colSpan && +th.colSpan) || 1;
for (var i = 0; i < length; i++) {
listOfKeys.push("measure_key_" + i);
}
});
this.listOfMeasureColumn$.next(listOfKeys);
};
NzTableStyleService.prototype.setListOfAutoWidth = function (listOfAutoWidth) {
this.listOfAutoWidthPx$.next(listOfAutoWidth.map(function (width) { return width + "px"; }));
};
NzTableStyleService.prototype.setShowEmpty = function (showEmpty) {
this.showEmpty$.next(showEmpty);
};
NzTableStyleService.prototype.setNoResult = function (noResult) {
this.noResult$.next(noResult);
};
NzTableStyleService.prototype.setScroll = function (scrollX, scrollY) {
var enableAutoMeasure = !!(scrollX || scrollY);
if (!enableAutoMeasure) {
this.setListOfAutoWidth([]);
}
this.enableAutoMeasure$.next(enableAutoMeasure);
};
return NzTableStyleService;
}());
NzTableStyleService.decorators = [
{ type: core.Injectable }
];
NzTableStyleService.ctorParameters = function () { return []; };
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzTableCellDirective = /** @class */ (function () {
function NzTableCellDirective(nzTableStyleService) {
this.isInsideTable = false;
this.isInsideTable = !!nzTableStyleService;
}
return NzTableCellDirective;
}());
NzTableCellDirective.decorators = [
{ type: core.Directive, args: [{
selector: 'th:not(.nz-disable-th):not([mat-cell]), td:not(.nz-disable-td):not([mat-cell])',
host: {
'[class.ant-table-cell]': 'isInsideTable'
}
},] }
];
NzTableCellDirective.ctorParameters = function () { return [
{ type: NzTableStyleService, decorators: [{ type: core.Optional }] }
]; };
/**
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
*/
var NzTdAddOnComponent = /** @class */ (function () {
function NzTdAddOnComponent() {
this.nzChecked = false;
this.nzDisabled = false;
this.nzIndeterminate = false;
this.nzIndentSize = 0;
this.nzShowExpand = false;
this.nzShowCheckbox = false;
this.nzExpand = false;
this.nzCheckedChange = new core.EventEmitter();
this.nzExpandChange = new core.EventEmitter();
this.isNzShowExpandChanged = false;
this.isNzShowCheckboxChanged = false;
}
NzTdAddOnComponent.prototype.onCheckedChange = function (checked) {
this.nzChecked = checked;
this.nzCheckedChange.emit(checked);
};
NzTdAddOnComponent.prototype.onExpandChange = function (expand) {
this.nzExpand = expand;
this.nzExpandChange.emit(expand);
};
NzTdAddOnComponent.prototype.ngOnChanges = function (changes) {
var isFirstChange = function (value) { return value && value.firstChange && value.currentValue !== undefined; };
var nzExpand = changes.nzExpand, nzChecked = changes.nzChecked, nzShowExpand = changes.nzShowExpand, nzShowCheckbox = changes.nzShowCheckbox;
if (nzShowExpand) {
this.isNzShowExpandChanged = true;
}
if (nzShowCheckbox) {
this.isNzShowCheckboxChanged = true;
}
if (isFirstChange(nzExpand) && !this.isNzShowExpandChanged) {
this.nzShowExpand = true;
}
if (isFirstChange(nzChecked) && !this.isNzShowCheckboxChanged) {
this.nzShowCheckbox = true;
}
};
return NzTdAddOnComponent;
}());
NzTdAddOnComponent.decorators = [
{ type: core.Component, args: [{
selector: 'td[nzChecked], td[nzDisabled], td[nzIndeterminate], td[nzIndentSize], td[nzExpand], td[nzShowExpand], td[nzShowCheckbox]',
changeDetection: core.ChangeDetectionStrategy.OnPush,
preserveWhitespaces: false,
encapsulation: core.ViewEncapsulation.None,
template: "\n <ng-container *ngIf=\"nzShowExpand || nzIndentSize > 0\">\n <nz-row-indent [indentSize]=\"nzIndentSize\"></nz-row-indent>\n <button nz-row-expand-button [expand]=\"nzExpand\" (expandChange)=\"onExpandChange($event)\" [spaceMode]=\"!nzShowExpand\"></button>\n </ng-container>\n <label\n nz-checkbox\n *ngIf=\"nzShowCheckbox\"\n [nzDisabled]=\"nzDisabled\"\n [ngModel]=\"nzChecked\"\n [nzIndeterminate]=\"nzIndeterminate\"\n (ngModelChange)=\"onCheckedChange($event)\"\n >\n </label>\n <ng-content></ng-content>\n ",
host: {
'[class.ant-table-cell-with-append]': "nzShowExpand || nzIndentSize > 0",
'[class.ant-table-selection-column]': "nzShowCheckbox"
}
},] }
];
NzTdAddOnComponent.propDecorators = {
nzChecked: [{ type: core.Input }],
nzDisabled: [{ type: core.Input }],
nzIndeterminate: [{ type: core.Input }],
nzIndentSize: [{ type: core.Input }],
nzShowExpand: [{ type: core.Input }],
nzShowCheckbox: [{ type: core.Input }],
nzExpand: [{ type: core.Input }],
nzCheckedChange: [{ type: core.Output }],
nzExpandChange: [{ type: core.Output }]
};
__decorate([
util.InputBoolean(),
__metadata("design:type", Object)
], NzTdAddOnComponent.prototype, "nzShowExpand", void 0);
__decorate([
util.InputBoolean(),
__metadata("design:type", Object)
], NzTdAddOnComponent.prototype, "nzShowCheckbox", void 0);
__decorate([
util.InputBoolean(),
__metadata("design:type", Object)
], NzTdAddOnComponent.prototype, "nzExpand", void 0);
var NzThAddOnComponent = /** @class */ (function () {
function NzThAddOnComponent(cdr) {
this.cdr = cdr;
this.manualClickOrder$ = new rxjs.Subject();
this.calcOperatorChange$ = new rxjs.Subject();
this.nzFilterValue = null;
this.sortOrder = null;
this.sortDirections = ['ascend', 'descend', null];
this.sortOrderChange$ = new rxjs.Subject();
this.destroy$ = new rxjs.Subject();
this.isNzShowSortChanged = false;
this.isNzShowFilterChanged = false;
this.nzFilterMultiple = true;
this.nzSortOrder = null;
this.nzSortPriority = false;
this.nzSortDirections = ['ascend', 'descend', null];
this.nzFilters = [];
this.nzSortFn = null;
this.nzFilterFn = null;
this.nzShowSort = false;
this.nzShowFilter = false;
this.nzCustomFilter = false;
this.nzCheckedChange = new core.EventEmitter();
this.nzSortOrderChange = new core.EventEmitter();
this.nzFilterChange = new core.EventEmitter();
}
NzThAddOnComponent.prototype.getNextSortDirection = function (sortDirections, current) {
var index = sortDirections.indexOf(current);
if (index === sortDirections.length - 1) {
return sortDirections[0];
}
else {
return sortDirections[index + 1];
}
};
NzThAddOnComponent.prototype.emitNextSortValue = function () {
if (this.nzShowSort) {
var nextOrder = this.getNextSortDirection(this.sortDirections, this.sortOrder);
this.setSortOrder(nextOrder);
this.manualClickOrder$.next(this);
}
};
NzThAddOnComponent.prototype.setSortOrder = function (order) {
this.sortOrderChange$.next(order);
};
NzThAddOnComponent.prototype.clearSortOrder = function () {
if (this.sortOrder !== null) {
this.setSortOrder(null);
}
};
NzThAddOnComponent.prototype.onFilterValueChange = function (value) {
this.nzFilterChange.emit(value);
this.nzFilterValue = value;
this.updateCalcOperator();
};
NzThAddOnComponent.prototype.updateCalcOperator = function () {
this.calcOperatorChange$.next();
};
NzThAddOnComponent.prototype.ngOnInit = function () {
var _this = this;
this.sortOrderChange$.pipe(operators.takeUntil(this.destroy$)).subscribe(function (order) {
if (_this.sortOrder !== order) {
_this.sortOrder = order;
_this.nzSortOrderChange.emit(order);
}
_this.updateCalcOperator();
_this.cdr.markForCheck();
});
};
NzThAddOnComponent.prototype.ngOnChanges = function (changes) {
var nzSortDirections = changes.nzSortDirections, nzFilters = changes.nzFilters, nzSortOrder = changes.nzSortOrder, nzSortFn = changes.nzSortFn, nzFilterFn = changes.nzFilterFn, nzSortPriority = changes.nzSortPriority, nzFilterMultiple = changes.nzFilterMultiple, nzShowSort = changes.nzShowSort, nzShowFilter = changes.nzShowFilter;
if (nzSortDirections) {
if (this.nzSortDirections && this.nzSortDirections.length) {
this.sortDirections = this.nzSortDirections;
}
}
if (nzSortOrder) {
this.sortOrder = this.nzSortOrder;
this.setSortOrder(this.nzSortOrder);
}
if (nzShowSort) {
this.isNzShowSortChanged = true;
}
if (nzShowFilter) {
this.isNzShowFilterChanged = true;
}
var isFirstChange = function (value) { return value && value.firstChange && value.currentValue !== undefined; };
if ((isFirstChange(nzSortOrder) || isFirstChange(nzSortFn)) && !this.isNzShowSortChanged) {
this.nzShowSort = true;
}
if (isFirstChange(nzFilters) && !this.i