ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 15.2 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/clipboard"),require("@angular/cdk/platform"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/core/trans-button"),require("ng-zorro-antd/i18n"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/input"),require("ng-zorro-antd/tooltip"),require("rxjs"),require("rxjs/operators"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/polyfill"),require("ng-zorro-antd/core/services"),require("ng-zorro-antd/core/util")):"function"==typeof define&&define.amd?define("ng-zorro-antd/typography",["exports","@angular/cdk/clipboard","@angular/cdk/platform","@angular/common","@angular/core","ng-zorro-antd/core/trans-button","ng-zorro-antd/i18n","ng-zorro-antd/icon","ng-zorro-antd/input","ng-zorro-antd/tooltip","rxjs","rxjs/operators","ng-zorro-antd/core/config","ng-zorro-antd/core/polyfill","ng-zorro-antd/core/services","ng-zorro-antd/core/util"],e):e(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].typography={}),t.ng.cdk.clipboard,t.ng.cdk.platform,t.ng.common,t.ng.core,t["ng-zorro-antd"].core["trans-button"],t["ng-zorro-antd"].i18n,t["ng-zorro-antd"].icon,t["ng-zorro-antd"].input,t["ng-zorro-antd"].tooltip,t.rxjs,t.rxjs.operators,t["ng-zorro-antd"].core.config,t["ng-zorro-antd"].core.polyfill,t["ng-zorro-antd"].core.services,t["ng-zorro-antd"].core.util)}(this,(function(t,e,n,i,o,r,s,a,p,l,c,d,h,u,y,g){"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.
***************************************************************************** */function f(t,e,n,i){var o,r=arguments.length,s=r<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,n,s):o(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}function z(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var x=function(){function t(t,e,n,i){this.host=t,this.cdr=e,this.clipboard=n,this.i18n=i,this.copied=!1,this.locale={},this.nativeElement=this.host.nativeElement,this.destroy$=new c.Subject,this.textCopy=new o.EventEmitter}return t.prototype.ngOnInit=function(){var t=this;this.i18n.localeChange.pipe(d.takeUntil(this.destroy$)).subscribe((function(){t.locale=t.i18n.getLocaleData("Text"),t.cdr.markForCheck()}))},t.prototype.ngOnDestroy=function(){clearTimeout(this.copyId),this.destroy$.next(),this.destroy$.complete()},t.prototype.onClick=function(){if(!this.copied){this.copied=!0,this.cdr.detectChanges();var t=this.text;this.textCopy.emit(t),this.clipboard.copy(t),this.onCopied()}},t.prototype.onCopied=function(){var t=this;clearTimeout(this.copyId),this.copyId=setTimeout((function(){t.copied=!1,t.cdr.detectChanges()}),3e3)},t.decorators=[{type:o.Component,args:[{selector:"nz-text-copy",exportAs:"nzTextCopy",template:'\n <button\n nz-tooltip\n nz-trans-button\n [nzTooltipTitle]="copied ? locale?.copied : locale?.copy"\n class="ant-typography-copy"\n [class.ant-typography-copy-success]="copied"\n (click)="onClick()"\n >\n <i nz-icon [nzType]="copied ? \'check\' : \'copy\'"></i>\n </button>\n ',changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.ViewEncapsulation.None,preserveWhitespaces:!1}]}],t.ctorParameters=function(){return[{type:o.ElementRef},{type:o.ChangeDetectorRef},{type:e.Clipboard},{type:s.NzI18nService}]},t.propDecorators={text:[{type:o.Input}],textCopy:[{type:o.Output}]},t}();var E=function(){function t(t,e,n){this.host=t,this.cdr=e,this.i18n=n,this.editing=!1,this.locale={},this.destroy$=new c.Subject,this.startEditing=new o.EventEmitter,this.endEditing=new o.EventEmitter,this.nativeElement=this.host.nativeElement}return t.prototype.ngOnInit=function(){var t=this;this.i18n.localeChange.pipe(d.takeUntil(this.destroy$)).subscribe((function(){t.locale=t.i18n.getLocaleData("Text"),t.cdr.markForCheck()}))},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.prototype.onClick=function(){this.beforeText=this.text,this.currentText=this.beforeText,this.editing=!0,this.startEditing.emit(),this.focusAndSetValue()},t.prototype.confirm=function(){this.editing=!1,this.endEditing.emit(this.currentText)},t.prototype.onInput=function(t){var e=t.target;this.currentText=e.value},t.prototype.onEnter=function(t){t.stopPropagation(),t.preventDefault(),this.confirm()},t.prototype.onCancel=function(){this.currentText=this.beforeText,this.confirm()},t.prototype.focusAndSetValue=function(){var t=this;setTimeout((function(){var e;(null===(e=t.textarea)||void 0===e?void 0:e.nativeElement)&&(t.textarea.nativeElement.focus(),t.textarea.nativeElement.value=t.currentText,t.autosizeDirective.resizeToFitContent())}))},t.decorators=[{type:o.Component,args:[{selector:"nz-text-edit",exportAs:"nzTextEdit",template:'\n <button *ngIf="!editing" [nzTooltipTitle]="locale?.edit" nz-tooltip nz-trans-button class="ant-typography-edit" (click)="onClick()">\n <i nz-icon nzType="edit"></i>\n </button>\n <ng-container *ngIf="editing">\n <textarea\n #textarea\n nz-input\n nzAutosize\n (input)="onInput($event)"\n (blur)="confirm()"\n (keydown.esc)="onCancel()"\n (keydown.enter)="onEnter($event)"\n >\n </textarea>\n <button nz-trans-button class="ant-typography-edit-content-confirm" (click)="confirm()">\n <i nz-icon nzType="enter"></i>\n </button>\n </ng-container>\n ',changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.ViewEncapsulation.None,preserveWhitespaces:!1}]}],t.ctorParameters=function(){return[{type:o.ElementRef},{type:o.ChangeDetectorRef},{type:s.NzI18nService}]},t.propDecorators={text:[{type:o.Input}],startEditing:[{type:o.Output}],endEditing:[{type:o.Output}],textarea:[{type:o.ViewChild,args:["textarea",{static:!1}]}],autosizeDirective:[{type:o.ViewChild,args:[p.NzAutosizeDirective,{static:!1}]}]},t}();var m=function(){function t(t,e,n,i,r,s,a,p,l){this.nzConfigService=t,this.host=e,this.cdr=n,this.viewContainerRef=i,this.renderer=r,this.platform=s,this.i18n=a,this.resizeService=l,this.nzCopyable=!1,this.nzEditable=!1,this.nzDisabled=!1,this.nzExpandable=!1,this.nzEllipsis=!1,this.nzContentChange=new o.EventEmitter,this.nzCopy=new o.EventEmitter,this.nzExpandChange=new o.EventEmitter,this.locale={},this.expandableBtnElementCache=null,this.editing=!1,this.cssEllipsis=!1,this.isEllipsis=!0,this.expanded=!1,this.ellipsisStr="...",this.viewInit=!1,this.rfaId=-1,this.destroy$=new c.Subject,this.windowResizeSubscription=c.Subscription.EMPTY,this.document=p}return Object.defineProperty(t.prototype,"canCssEllipsis",{get:function(){return this.nzEllipsis&&this.cssEllipsis&&!this.expanded},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"copyText",{get:function(){return"string"==typeof this.nzCopyText?this.nzCopyText:this.nzContent},enumerable:!0,configurable:!0}),t.prototype.onTextCopy=function(t){this.nzCopy.emit(t)},t.prototype.onStartEditing=function(){this.editing=!0},t.prototype.onEndEditing=function(t){this.editing=!1,this.nzContentChange.emit(t),this.nzContent===t&&this.renderOnNextFrame()},t.prototype.onExpand=function(){this.isEllipsis=!1,this.expanded=!0,this.nzExpandChange.emit()},t.prototype.canUseCSSEllipsis=function(){return!(this.nzEditable||this.nzCopyable||this.nzExpandable||this.nzSuffix)&&(1===this.nzEllipsisRows?g.isStyleSupport("textOverflow"):g.isStyleSupport("webkitLineClamp"))},t.prototype.renderOnNextFrame=function(){var t=this;u.cancelRequestAnimationFrame(this.rfaId),!this.viewInit||!this.nzEllipsis||this.nzEllipsisRows<0||this.expanded||!this.platform.isBrowser||(this.rfaId=u.reqAnimFrame((function(){t.syncEllipsis()})))},t.prototype.getOriginContentViewRef=function(){var t=this,e=this.viewContainerRef.createEmbeddedView(this.contentTemplate,{content:this.nzContent});return e.detectChanges(),{viewRef:e,removeView:function(){t.viewContainerRef.remove(t.viewContainerRef.indexOf(e))}}},t.prototype.syncEllipsis=function(){var t=this;if(!this.cssEllipsis){var e=this.getOriginContentViewRef(),n=e.viewRef,i=e.removeView,o=[this.textCopyRef,this.textEditRef].filter((function(t){return t&&t.nativeElement})).map((function(t){return t.nativeElement})),r=this.getExpandableBtnElement();r&&o.push(r);var s=g.measure(this.host.nativeElement,this.nzEllipsisRows,n.rootNodes,o,this.ellipsisStr,this.nzSuffix),a=s.contentNodes,p=s.text,l=s.ellipsis;i(),this.ellipsisText=p,this.isEllipsis=l;for(var c=this.ellipsisContainer.nativeElement;c.firstChild;)this.renderer.removeChild(c,c.firstChild);a.forEach((function(e){t.renderer.appendChild(c,e.cloneNode(!0))})),this.cdr.markForCheck()}},t.prototype.getExpandableBtnElement=function(){if(this.nzExpandable){var t=this.locale?this.locale.expand:"",e=this.expandableBtnElementCache;if(!e||e.innerText===t){var n=this.document.createElement("a");n.className="ant-typography-expand",n.innerText=t,this.expandableBtnElementCache=n}return this.expandableBtnElementCache}return this.expandableBtnElementCache=null,null},t.prototype.renderAndSubscribeWindowResize=function(){var t=this;this.platform.isBrowser&&(this.windowResizeSubscription.unsubscribe(),this.cssEllipsis=this.canUseCSSEllipsis(),this.renderOnNextFrame(),this.windowResizeSubscription=this.resizeService.subscribe().pipe(d.takeUntil(this.destroy$)).subscribe((function(){return t.renderOnNextFrame()})))},t.prototype.ngOnInit=function(){var t=this;this.i18n.localeChange.pipe(d.takeUntil(this.destroy$)).subscribe((function(){t.locale=t.i18n.getLocaleData("Text"),t.cdr.markForCheck()}))},t.prototype.ngAfterViewInit=function(){this.viewInit=!0,this.renderAndSubscribeWindowResize()},t.prototype.ngOnChanges=function(t){var e=t.nzCopyable,n=t.nzEditable,i=t.nzExpandable,o=t.nzEllipsis,r=t.nzContent,s=t.nzEllipsisRows,a=t.nzSuffix;(e||n||i||o||r||s||a)&&this.nzEllipsis&&(this.expanded?this.windowResizeSubscription.unsubscribe():this.renderAndSubscribeWindowResize())},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete(),this.expandableBtnElementCache=null,this.windowResizeSubscription.unsubscribe()},t.decorators=[{type:o.Component,args:[{selector:"\n nz-typography,\n [nz-typography],\n p[nz-paragraph],\n span[nz-text],\n h1[nz-title], h2[nz-title], h3[nz-title], h4[nz-title]\n ",exportAs:"nzTypography",template:'\n <ng-template #contentTemplate let-content="content">\n <ng-content *ngIf="!content"></ng-content>\n {{ content }}\n </ng-template>\n\n <ng-container *ngIf="!editing">\n <ng-container *ngIf="expanded || (!nzExpandable && !nzSuffix && nzEllipsisRows === 1) || canCssEllipsis">\n <ng-template [ngTemplateOutlet]="contentTemplate" [ngTemplateOutletContext]="{ content: nzContent }"></ng-template>\n </ng-container>\n <ng-container *ngIf="(nzEllipsis && !expanded && (nzEllipsisRows > 1 || nzExpandable)) || nzSuffix">\n <span #ellipsisContainer *ngIf="!expanded"></span>\n <ng-container *ngIf="isEllipsis">{{ ellipsisStr }}</ng-container>\n <ng-container *ngIf="nzSuffix">{{ nzSuffix }}</ng-container>\n <a #expandable *ngIf="nzExpandable && isEllipsis" class="ant-typography-expand" (click)="onExpand()">{{ locale?.expand }}</a>\n </ng-container>\n </ng-container>\n\n <nz-text-edit *ngIf="nzEditable" [text]="nzContent" (endEditing)="onEndEditing($event)" (startEditing)="onStartEditing()">\n </nz-text-edit>\n\n <nz-text-copy *ngIf="nzCopyable && !editing" [text]="copyText" (textCopy)="onTextCopy($event)"></nz-text-copy>\n ',changeDetection:o.ChangeDetectionStrategy.OnPush,encapsulation:o.ViewEncapsulation.None,preserveWhitespaces:!1,host:{"[class.ant-typography]":"!editing","[class.ant-typography-edit-content]":"editing","[class.ant-typography-secondary]":'nzType === "secondary"',"[class.ant-typography-warning]":'nzType === "warning"',"[class.ant-typography-danger]":'nzType === "danger"',"[class.ant-typography-disabled]":"nzDisabled","[class.ant-typography-ellipsis]":"nzEllipsis && !expanded","[class.ant-typography-ellipsis-single-line]":"canCssEllipsis && nzEllipsisRows === 1","[class.ant-typography-ellipsis-multiple-line]":"canCssEllipsis && nzEllipsisRows > 1","[style.-webkit-line-clamp]":"(canCssEllipsis && nzEllipsisRows > 1) ? nzEllipsisRows : null"}}]}],t.ctorParameters=function(){return[{type:h.NzConfigService},{type:o.ElementRef},{type:o.ChangeDetectorRef},{type:o.ViewContainerRef},{type:o.Renderer2},{type:n.Platform},{type:s.NzI18nService},{type:void 0,decorators:[{type:o.Inject,args:[i.DOCUMENT]}]},{type:y.NzResizeService}]},t.propDecorators={nzCopyable:[{type:o.Input}],nzEditable:[{type:o.Input}],nzDisabled:[{type:o.Input}],nzExpandable:[{type:o.Input}],nzEllipsis:[{type:o.Input}],nzContent:[{type:o.Input}],nzEllipsisRows:[{type:o.Input}],nzType:[{type:o.Input}],nzCopyText:[{type:o.Input}],nzSuffix:[{type:o.Input}],nzContentChange:[{type:o.Output}],nzCopy:[{type:o.Output}],nzExpandChange:[{type:o.Output}],textEditRef:[{type:o.ViewChild,args:[E,{static:!1}]}],textCopyRef:[{type:o.ViewChild,args:[x,{static:!1}]}],ellipsisContainer:[{type:o.ViewChild,args:["ellipsisContainer",{static:!1}]}],expandableBtn:[{type:o.ViewChild,args:["expandable",{static:!1}]}],contentTemplate:[{type:o.ViewChild,args:["contentTemplate",{static:!1}]}]},f([g.InputBoolean(),z("design:type",Object)],t.prototype,"nzCopyable",void 0),f([g.InputBoolean(),z("design:type",Object)],t.prototype,"nzEditable",void 0),f([g.InputBoolean(),z("design:type",Object)],t.prototype,"nzDisabled",void 0),f([g.InputBoolean(),z("design:type",Object)],t.prototype,"nzExpandable",void 0),f([g.InputBoolean(),z("design:type",Object)],t.prototype,"nzEllipsis",void 0),f([h.WithConfig("typography",1),g.InputNumber(),z("design:type",Number)],t.prototype,"nzEllipsisRows",void 0),t}();var C=function(){function t(){}return t.decorators=[{type:o.NgModule,args:[{imports:[i.CommonModule,a.NzIconModule,l.NzToolTipModule,p.NzInputModule,s.NzI18nModule,r.NzTransButtonModule,e.ClipboardModule],exports:[m,x,E,n.PlatformModule],declarations:[m,x,E]}]}],t}();t.NzTextCopyComponent=x,t.NzTextEditComponent=E,t.NzTypographyComponent=m,t.NzTypographyModule=C,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-typography.umd.min.js.map