UNPKG

ng-zorro-antd

Version:

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

2 lines 11.1 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("ng-zorro-antd/core"),require("@angular/common"),require("ng-zorro-antd/icon"),require("@angular/cdk/platform"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ng-zorro-antd/input",["exports","@angular/core","ng-zorro-antd/core","@angular/common","ng-zorro-antd/icon","@angular/cdk/platform","rxjs","rxjs/operators"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].input={}),e.ng.core,e["ng-zorro-antd"].core,e.ng.common,e["ng-zorro-antd"].icon,e.ng.cdk.platform,e.rxjs,e.rxjs.operators)}(this,function(e,t,n,i,r,o,a,s){"use strict";function p(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function u(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var c=function(){function e(e,t){this.nzSize="default",this.disabled=!1,e.addClass(t.nativeElement,"ant-input")}return e.decorators=[{type:t.Directive,args:[{selector:"[nz-input]",exportAs:"nzInput",host:{"[class.ant-input-disabled]":"disabled","[class.ant-input-lg]":"nzSize === 'large'","[class.ant-input-sm]":"nzSize === 'small'"}}]}],e.ctorParameters=function(){return[{type:t.Renderer2},{type:t.ElementRef}]},e.propDecorators={nzSize:[{type:t.Input}],disabled:[{type:t.Input}]},p([n.InputBoolean(),u("design:type",Object)],e.prototype,"disabled",void 0),e}();var l=function(){function e(){this._size="default",this.nzSearch=!1,this.nzCompact=!1}return Object.defineProperty(e.prototype,"nzSize",{get:function(){return this._size},set:function(e){this._size=e,this.updateChildrenInputSize()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLarge",{get:function(){return"large"===this.nzSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSmall",{get:function(){return"small"===this.nzSize},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAffix",{get:function(){return!!(this.nzSuffix||this.nzPrefix||this.nzPrefixIcon||this.nzSuffixIcon)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAddOn",{get:function(){return!!(this.nzAddOnAfter||this.nzAddOnBefore||this.nzAddOnAfterIcon||this.nzAddOnBeforeIcon)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAffixWrapper",{get:function(){return this.isAffix&&!this.isAddOn},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isGroup",{get:function(){return!this.isAffix&&!this.isAddOn},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLargeGroup",{get:function(){return this.isGroup&&this.isLarge},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLargeGroupWrapper",{get:function(){return this.isAddOn&&this.isLarge},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLargeAffix",{get:function(){return this.isAffixWrapper&&this.isLarge},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLargeSearch",{get:function(){return this.nzSearch&&this.isLarge},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSmallGroup",{get:function(){return this.isGroup&&this.isSmall},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSmallAffix",{get:function(){return this.isAffixWrapper&&this.isSmall},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSmallGroupWrapper",{get:function(){return this.isAddOn&&this.isSmall},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSmallSearch",{get:function(){return this.nzSearch&&this.isSmall},enumerable:!0,configurable:!0}),e.prototype.updateChildrenInputSize=function(){var e=this;this.listOfNzInputDirective&&this.listOfNzInputDirective.forEach(function(t){return t.nzSize=e.nzSize})},e.prototype.ngAfterContentInit=function(){this.updateChildrenInputSize()},e.decorators=[{type:t.Component,args:[{selector:"nz-input-group",exportAs:"nzInputGroup",preserveWhitespaces:!1,encapsulation:t.ViewEncapsulation.None,changeDetection:t.ChangeDetectionStrategy.OnPush,template:'<span class="ant-input-wrapper ant-input-group" *ngIf="isAddOn">\n <span class="ant-input-group-addon" *ngIf="nzAddOnBefore || nzAddOnBeforeIcon">\n <i nz-icon [nzType]="nzAddOnBeforeIcon" *ngIf="nzAddOnBeforeIcon"></i>\n <ng-container *nzStringTemplateOutlet="nzAddOnBefore">{{ nzAddOnBefore }}</ng-container>\n </span>\n <ng-container *ngIf="!isAffix">\n <ng-template *ngTemplateOutlet="contentTemplate"></ng-template>\n </ng-container>\n <span class="ant-input-affix-wrapper" [class.ant-input-affix-wrapper-sm]="isSmall" [class.ant-input-affix-wrapper-lg]="isLarge" *ngIf="isAffix">\n <ng-template *ngTemplateOutlet="affixTemplate"></ng-template>\n </span>\n <span class="ant-input-group-addon" *ngIf="nzAddOnAfter || nzAddOnAfterIcon">\n <i nz-icon [nzType]="nzAddOnAfterIcon" *ngIf="nzAddOnAfterIcon"></i>\n <ng-container *nzStringTemplateOutlet="nzAddOnAfter">{{ nzAddOnAfter }}</ng-container>\n </span>\n</span>\n<ng-container *ngIf="isAffix && !isAddOn">\n <ng-template *ngTemplateOutlet="affixTemplate"></ng-template>\n</ng-container>\n<ng-template #affixTemplate>\n <span class="ant-input-prefix" *ngIf="nzPrefix || nzPrefixIcon">\n \x3c!-- TODO: should have a class to set its color, cc: antd--\x3e\n <i nz-icon [nzType]="nzPrefixIcon" *ngIf="nzPrefixIcon" style="color: rgba(0, 0, 0, 0.25)"></i>\n <ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>\n </span>\n <ng-template *ngTemplateOutlet="contentTemplate"></ng-template>\n <span class="ant-input-suffix" *ngIf="nzSuffix || nzSuffixIcon">\n <i nz-icon [nzType]="nzSuffixIcon" *ngIf="nzSuffixIcon"></i>\n <ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>\n </span>\n</ng-template>\n<ng-container *ngIf="isGroup">\n <ng-template *ngTemplateOutlet="contentTemplate"></ng-template>\n</ng-container>\n<ng-template #contentTemplate>\n <ng-content></ng-content>\n</ng-template>\n',host:{"[class.ant-input-group-compact]":"nzCompact","[class.ant-input-search-enter-button]":"nzSearch","[class.ant-input-search]":"nzSearch","[class.ant-input-search-sm]":"isSmallSearch","[class.ant-input-affix-wrapper]":"isAffixWrapper","[class.ant-input-group-wrapper]":"isAddOn","[class.ant-input-group]":"isGroup","[class.ant-input-group-lg]":"isLargeGroup","[class.ant-input-group-wrapper-lg]":"isLargeGroupWrapper","[class.ant-input-affix-wrapper-lg]":"isLargeAffix","[class.ant-input-search-lg]":"isLargeSearch","[class.ant-input-group-sm]":"isSmallGroup","[class.ant-input-affix-wrapper-sm]":"isSmallAffix","[class.ant-input-group-wrapper-sm]":"isSmallGroupWrapper"}}]}],e.propDecorators={listOfNzInputDirective:[{type:t.ContentChildren,args:[c]}],nzAddOnBeforeIcon:[{type:t.Input}],nzAddOnAfterIcon:[{type:t.Input}],nzPrefixIcon:[{type:t.Input}],nzSuffixIcon:[{type:t.Input}],nzAddOnBefore:[{type:t.Input}],nzAddOnAfter:[{type:t.Input}],nzPrefix:[{type:t.Input}],nzSuffix:[{type:t.Input}],nzSearch:[{type:t.Input}],nzCompact:[{type:t.Input}],nzSize:[{type:t.Input}]},p([n.InputBoolean(),u("design:type",Object)],e.prototype,"nzSearch",void 0),p([n.InputBoolean(),u("design:type",Object)],e.prototype,"nzCompact",void 0),e}();function f(e){return!("string"==typeof e||"boolean"==typeof e||!e.maxRows&&!e.minRows)}var g=function(){function e(e,t,n,i){this.elementRef=e,this.ngZone=t,this.platform=n,this.nzDomEventService=i,this.autosize=!1,this.el=this.elementRef.nativeElement,this.destroy$=new a.Subject,this.inputGap=10}return Object.defineProperty(e.prototype,"nzAutosize",{get:function(){return this.autosize},set:function(e){"string"==typeof e?this.autosize=!0:f(e)&&(this.autosize=e,this.minRows=e.minRows,this.maxRows=e.maxRows,this.setMaxHeight(),this.setMinHeight())},enumerable:!0,configurable:!0}),e.prototype.resizeToFitContent=function(e){var t=this;if(void 0===e&&(e=!1),this.cacheTextareaLineHeight(),this.cachedLineHeight){var n=this.el,i=n.value;if(e||this.minRows!==this.previousMinRows||i!==this.previousValue){var r=n.placeholder;n.classList.add("cdk-textarea-autosize-measuring"),n.placeholder="";var o=Math.round((n.scrollHeight-this.inputGap)/this.cachedLineHeight)*this.cachedLineHeight+this.inputGap;n.style.height=o+"px",n.classList.remove("cdk-textarea-autosize-measuring"),n.placeholder=r,"undefined"!=typeof requestAnimationFrame&&this.ngZone.runOutsideAngular(function(){return requestAnimationFrame(function(){var e=n.selectionStart,i=n.selectionEnd;t.destroy$.isStopped||document.activeElement!==n||n.setSelectionRange(e,i)})}),this.previousValue=i,this.previousMinRows=this.minRows}}},e.prototype.cacheTextareaLineHeight=function(){if(!(this.cachedLineHeight>=0)&&this.el.parentNode){var e=this.el.cloneNode(!1);e.rows=1,e.style.position="absolute",e.style.visibility="hidden",e.style.border="none",e.style.padding="0",e.style.height="",e.style.minHeight="",e.style.maxHeight="",e.style.overflow="hidden",this.el.parentNode.appendChild(e),this.cachedLineHeight=e.clientHeight-this.inputGap-1,this.el.parentNode.removeChild(e),this.setMinHeight(),this.setMaxHeight()}},e.prototype.setMinHeight=function(){var e=this.minRows&&this.cachedLineHeight?this.minRows*this.cachedLineHeight+this.inputGap+"px":null;e&&(this.el.style.minHeight=e)},e.prototype.setMaxHeight=function(){var e=this.maxRows&&this.cachedLineHeight?this.maxRows*this.cachedLineHeight+this.inputGap+"px":null;e&&(this.el.style.maxHeight=e)},e.prototype.noopInputHandler=function(){},e.prototype.ngAfterViewInit=function(){var e=this;this.nzAutosize&&this.platform.isBrowser&&(this.resizeToFitContent(),this.nzDomEventService.registerResizeListener().pipe(s.takeUntil(this.destroy$),s.finalize(function(){return e.nzDomEventService.unregisterResizeListener()})).subscribe(function(){return e.resizeToFitContent(!0)}))},e.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},e.prototype.ngDoCheck=function(){this.nzAutosize&&this.platform.isBrowser&&this.resizeToFitContent()},e.decorators=[{type:t.Directive,args:[{selector:"textarea[nzAutosize]",exportAs:"nzAutosize",host:{rows:"1","(input)":"noopInputHandler()"}}]}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:t.NgZone},{type:o.Platform},{type:n.NzDomEventService}]},e.propDecorators={nzAutosize:[{type:t.Input}]},e}();var d=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[c,l,g],exports:[c,l,g],imports:[i.CommonModule,r.NzIconModule,o.PlatformModule,n.NzAddOnModule]}]}],e}();e.NzAutosizeDirective=g,e.NzInputDirective=c,e.NzInputGroupComponent=l,e.NzInputModule=d,e.isAutoSizeType=f,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-input.umd.min.js.map