ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
304 lines (297 loc) • 9.5 kB
JavaScript
import { __assign, __spread } from 'tslib';
import { Component, ChangeDetectionStrategy, ViewEncapsulation, ChangeDetectorRef, Renderer2, ElementRef, Input, NgModule } from '@angular/core';
import { toCssPixel } from 'ng-zorro-antd/core';
import { CommonModule } from '@angular/common';
/**
* @fileoverview added by tsickle
* Generated from: nz-skeleton.component.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSkeletonComponent = /** @class */ (function () {
function NzSkeletonComponent(cdr, renderer, elementRef) {
this.cdr = cdr;
this.nzActive = false;
this.nzLoading = true;
this.nzTitle = true;
this.nzAvatar = false;
this.nzParagraph = true;
this.rowsList = [];
this.widthList = [];
renderer.addClass(elementRef.nativeElement, 'ant-skeleton');
}
/**
* @param {?=} value
* @return {?}
*/
NzSkeletonComponent.prototype.toCSSUnit = /**
* @param {?=} value
* @return {?}
*/
function (value) {
if (value === void 0) { value = ''; }
return toCssPixel(value);
};
/**
* @private
* @return {?}
*/
NzSkeletonComponent.prototype.getTitleProps = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var hasAvatar = !!this.nzAvatar;
/** @type {?} */
var hasParagraph = !!this.nzParagraph;
/** @type {?} */
var width = '';
if (!hasAvatar && hasParagraph) {
width = '38%';
}
else if (hasAvatar && hasParagraph) {
width = '50%';
}
return __assign({ width: width }, this.getProps(this.nzTitle));
};
/**
* @private
* @return {?}
*/
NzSkeletonComponent.prototype.getAvatarProps = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var shape = !!this.nzTitle && !this.nzParagraph ? 'square' : 'circle';
/** @type {?} */
var size = 'large';
return __assign({ shape: shape, size: size }, this.getProps(this.nzAvatar));
};
/**
* @private
* @return {?}
*/
NzSkeletonComponent.prototype.getParagraphProps = /**
* @private
* @return {?}
*/
function () {
/** @type {?} */
var hasAvatar = !!this.nzAvatar;
/** @type {?} */
var hasTitle = !!this.nzTitle;
/** @type {?} */
var basicProps = {};
// Width
if (!hasAvatar || !hasTitle) {
basicProps.width = '61%';
}
// Rows
if (!hasAvatar && hasTitle) {
basicProps.rows = 3;
}
else {
basicProps.rows = 2;
}
return __assign({}, basicProps, this.getProps(this.nzParagraph));
};
/**
* @private
* @template T
* @param {?} prop
* @return {?}
*/
NzSkeletonComponent.prototype.getProps = /**
* @private
* @template T
* @param {?} prop
* @return {?}
*/
function (prop) {
return prop && typeof prop === 'object' ? prop : {};
};
/**
* @private
* @return {?}
*/
NzSkeletonComponent.prototype.getWidthList = /**
* @private
* @return {?}
*/
function () {
var _a = this.paragraph, width = _a.width, rows = _a.rows;
/** @type {?} */
var widthList = [];
if (width && Array.isArray(width)) {
widthList = width;
}
else if (width && !Array.isArray(width)) {
widthList = [];
widthList[(/** @type {?} */ (rows)) - 1] = width;
}
return widthList;
};
/**
* @private
* @return {?}
*/
NzSkeletonComponent.prototype.updateProps = /**
* @private
* @return {?}
*/
function () {
this.title = this.getTitleProps();
this.avatar = this.getAvatarProps();
this.paragraph = this.getParagraphProps();
this.rowsList = __spread(Array(this.paragraph.rows));
this.widthList = this.getWidthList();
this.cdr.markForCheck();
};
/**
* @return {?}
*/
NzSkeletonComponent.prototype.ngOnInit = /**
* @return {?}
*/
function () {
this.updateProps();
};
/**
* @param {?} changes
* @return {?}
*/
NzSkeletonComponent.prototype.ngOnChanges = /**
* @param {?} changes
* @return {?}
*/
function (changes) {
if (changes.nzTitle || changes.nzAvatar || changes.nzParagraph) {
this.updateProps();
}
};
NzSkeletonComponent.decorators = [
{ type: Component, args: [{
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
selector: 'nz-skeleton',
exportAs: 'nzSkeleton',
template: "<ng-container *ngIf=\"nzLoading\">\n <div class=\"ant-skeleton-header\" *ngIf=\"!!nzAvatar\">\n <span\n class=\"ant-skeleton-avatar\"\n [class.ant-skeleton-avatar-lg]=\"avatar.size === 'large'\"\n [class.ant-skeleton-avatar-sm]=\"avatar.size === 'small'\"\n [class.ant-skeleton-avatar-circle]=\"avatar.shape === 'circle'\"\n [class.ant-skeleton-avatar-square]=\"avatar.shape === 'square'\">\n </span>\n </div>\n <div class=\"ant-skeleton-content\">\n <h3 *ngIf=\"!!nzTitle\" class=\"ant-skeleton-title\" [style.width]=\"toCSSUnit(title.width)\"></h3>\n <ul *ngIf=\"!!nzParagraph\" class=\"ant-skeleton-paragraph\">\n <li *ngFor=\"let row of rowsList; let i=index\" [style.width]=\"toCSSUnit(widthList[i])\">\n </li>\n </ul>\n </div>\n</ng-container>\n<ng-container *ngIf=\"!nzLoading\">\n <ng-content></ng-content>\n</ng-container>",
host: {
'[class.ant-skeleton-with-avatar]': '!!nzAvatar',
'[class.ant-skeleton-active]': 'nzActive'
}
}] }
];
/** @nocollapse */
NzSkeletonComponent.ctorParameters = function () { return [
{ type: ChangeDetectorRef },
{ type: Renderer2 },
{ type: ElementRef }
]; };
NzSkeletonComponent.propDecorators = {
nzActive: [{ type: Input }],
nzLoading: [{ type: Input }],
nzTitle: [{ type: Input }],
nzAvatar: [{ type: Input }],
nzParagraph: [{ type: Input }]
};
return NzSkeletonComponent;
}());
if (false) {
/** @type {?} */
NzSkeletonComponent.prototype.nzActive;
/** @type {?} */
NzSkeletonComponent.prototype.nzLoading;
/** @type {?} */
NzSkeletonComponent.prototype.nzTitle;
/** @type {?} */
NzSkeletonComponent.prototype.nzAvatar;
/** @type {?} */
NzSkeletonComponent.prototype.nzParagraph;
/** @type {?} */
NzSkeletonComponent.prototype.title;
/** @type {?} */
NzSkeletonComponent.prototype.avatar;
/** @type {?} */
NzSkeletonComponent.prototype.paragraph;
/** @type {?} */
NzSkeletonComponent.prototype.rowsList;
/** @type {?} */
NzSkeletonComponent.prototype.widthList;
/**
* @type {?}
* @private
*/
NzSkeletonComponent.prototype.cdr;
}
/**
* @fileoverview added by tsickle
* Generated from: nz-skeleton.module.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
var NzSkeletonModule = /** @class */ (function () {
function NzSkeletonModule() {
}
NzSkeletonModule.decorators = [
{ type: NgModule, args: [{
declarations: [NzSkeletonComponent],
imports: [CommonModule],
exports: [NzSkeletonComponent]
},] }
];
return NzSkeletonModule;
}());
/**
* @fileoverview added by tsickle
* Generated from: nz-skeleton.type.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @license
* Copyright Alibaba.com All Rights Reserved.
*
* 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
*/
/**
* @record
*/
function NzSkeletonAvatar() { }
if (false) {
/** @type {?|undefined} */
NzSkeletonAvatar.prototype.size;
/** @type {?|undefined} */
NzSkeletonAvatar.prototype.shape;
}
/**
* @record
*/
function NzSkeletonTitle() { }
if (false) {
/** @type {?|undefined} */
NzSkeletonTitle.prototype.width;
}
/**
* @record
*/
function NzSkeletonParagraph() { }
if (false) {
/** @type {?|undefined} */
NzSkeletonParagraph.prototype.rows;
/** @type {?|undefined} */
NzSkeletonParagraph.prototype.width;
}
/**
* @fileoverview added by tsickle
* Generated from: public-api.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
/**
* @fileoverview added by tsickle
* Generated from: ng-zorro-antd-skeleton.ts
* @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
*/
export { NzSkeletonComponent, NzSkeletonModule };
//# sourceMappingURL=ng-zorro-antd-skeleton.js.map