UNPKG

ng-zorro-antd

Version:

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

16 lines (14 loc) 12.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/a11y"),require("@angular/core"),require("ng-zorro-antd/core/util"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/platform"),require("@angular/common"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/icon"),require("ng-zorro-antd/core/services")):"function"==typeof define&&define.amd?define("ng-zorro-antd/input",["exports","@angular/cdk/a11y","@angular/core","ng-zorro-antd/core/util","rxjs","rxjs/operators","@angular/cdk/platform","@angular/common","ng-zorro-antd/core/outlet","ng-zorro-antd/icon","ng-zorro-antd/core/services"],e):e(((t=t||self)["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"].input={}),t.ng.cdk.a11y,t.ng.core,t["ng-zorro-antd"].core.util,t.rxjs,t.rxjs.operators,t.ng.cdk.platform,t.ng.common,t["ng-zorro-antd"].core.outlet,t["ng-zorro-antd"].icon,t["ng-zorro-antd"].core.services)}(this,(function(t,e,n,i,r,o,s,a,p,u,c){"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 l(t,e,n,i){var r,o=arguments.length,s=o<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--)(r=t[a])&&(s=(o<3?r(s):o>3?r(e,n,s):r(e,n))||s);return o>3&&s&&Object.defineProperty(e,n,s),s}function f(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function d(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return s}var h=function(){function t(t,e){this.nzSize="default",this.disabled=!1,this.disabled$=new r.Subject,t.addClass(e.nativeElement,"ant-input")}return t.prototype.ngOnChanges=function(t){t.disabled&&this.disabled$.next(this.disabled)},t.decorators=[{type:n.Directive,args:[{selector:"input[nz-input],textarea[nz-input]",exportAs:"nzInput",host:{"[class.ant-input-disabled]":"disabled","[class.ant-input-lg]":"nzSize === 'large'","[class.ant-input-sm]":"nzSize === 'small'"}}]}],t.ctorParameters=function(){return[{type:n.Renderer2},{type:n.ElementRef}]},t.propDecorators={nzSize:[{type:n.Input}],disabled:[{type:n.Input}]},l([i.InputBoolean(),f("design:type",Object)],t.prototype,"disabled",void 0),t}();var g=function(){function t(t){this.elementRef=t}return t.decorators=[{type:n.Directive,args:[{selector:"nz-input-group[nzSuffix], nz-input-group[nzPrefix]"}]}],t.ctorParameters=function(){return[{type:n.ElementRef}]},t}();var m=function(){function t(t,e,n){this.focusMonitor=t,this.elementRef=e,this.cdr=n,this.nzSearch=!1,this.nzCompact=!1,this.isLarge=!1,this.isSmall=!1,this.isAffix=!1,this.isAddOn=!1,this.focused=!1,this.disabled=!1,this.destroy$=new r.Subject}return t.prototype.updateChildrenInputSize=function(){var t=this;this.listOfNzInputDirective&&this.listOfNzInputDirective.forEach((function(e){return e.nzSize=t.nzSize}))},t.prototype.ngOnInit=function(){var t=this;this.focusMonitor.monitor(this.elementRef,!0).pipe(o.takeUntil(this.destroy$)).subscribe((function(e){t.focused=!!e,t.cdr.markForCheck()}))},t.prototype.ngAfterContentInit=function(){var t=this;this.updateChildrenInputSize();var e=this.listOfNzInputDirective.changes.pipe(o.startWith(this.listOfNzInputDirective));e.pipe(o.switchMap((function(t){return r.merge.apply(void 0,function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(d(arguments[e]));return t}([e],t.map((function(t){return t.disabled$}))))})),o.flatMap((function(){return e})),o.map((function(t){return t.some((function(t){return t.disabled}))})),o.takeUntil(this.destroy$)).subscribe((function(e){t.disabled=e,t.cdr.markForCheck()}))},t.prototype.ngOnChanges=function(t){var e=t.nzSize,n=t.nzSuffix,i=t.nzPrefix,r=t.nzPrefixIcon,o=t.nzSuffixIcon,s=t.nzAddOnAfter,a=t.nzAddOnBefore,p=t.nzAddOnAfterIcon,u=t.nzAddOnBeforeIcon;e&&(this.updateChildrenInputSize(),this.isLarge="large"===this.nzSize,this.isSmall="small"===this.nzSize),(n||i||r||o)&&(this.isAffix=!!(this.nzSuffix||this.nzPrefix||this.nzPrefixIcon||this.nzSuffixIcon)),(s||a||p||u)&&(this.isAddOn=!!(this.nzAddOnAfter||this.nzAddOnBefore||this.nzAddOnAfterIcon||this.nzAddOnBeforeIcon))},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.decorators=[{type:n.Component,args:[{selector:"nz-input-group",exportAs:"nzInputGroup",preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,template:'\n <span class="ant-input-wrapper ant-input-group" *ngIf="isAddOn; else noAddOnTemplate">\n <span\n *ngIf="nzAddOnBefore || nzAddOnBeforeIcon"\n nz-input-group-slot\n type="addon"\n [icon]="nzAddOnBeforeIcon"\n [template]="nzAddOnBefore"\n >\n </span>\n <span\n *ngIf="isAffix; else contentTemplate"\n class="ant-input-affix-wrapper"\n [class.ant-input-affix-wrapper-sm]="isSmall"\n [class.ant-input-affix-wrapper-lg]="isLarge"\n >\n <ng-template [ngTemplateOutlet]="affixTemplate"></ng-template>\n </span>\n <span\n *ngIf="nzAddOnAfter || nzAddOnAfterIcon"\n nz-input-group-slot\n type="addon"\n [icon]="nzAddOnAfterIcon"\n [template]="nzAddOnAfter"\n ></span>\n </span>\n <ng-template #noAddOnTemplate>\n <ng-template [ngIf]="isAffix" [ngIfElse]="contentTemplate">\n <ng-template [ngTemplateOutlet]="affixTemplate"></ng-template>\n </ng-template>\n </ng-template>\n <ng-template #affixTemplate>\n <span *ngIf="nzPrefix || nzPrefixIcon" nz-input-group-slot type="prefix" [icon]="nzPrefixIcon" [template]="nzPrefix"></span>\n <ng-template [ngTemplateOutlet]="contentTemplate"></ng-template>\n <span *ngIf="nzSuffix || nzSuffixIcon" nz-input-group-slot type="suffix" [icon]="nzSuffixIcon" [template]="nzSuffix"></span>\n </ng-template>\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]":"nzSearch && isSmall","[class.ant-input-search-large]":"nzSearch && isLarge","[class.ant-input-group-wrapper]":"isAddOn","[class.ant-input-group-wrapper-lg]":"isAddOn && isLarge","[class.ant-input-group-wrapper-sm]":"isAddOn && isSmall","[class.ant-input-affix-wrapper]":"isAffix && !isAddOn","[class.ant-input-affix-wrapper-focused]":"isAffix && focused","[class.ant-input-affix-wrapper-disabled]":"isAffix && disabled","[class.ant-input-affix-wrapper-lg]":"isAffix && !isAddOn && isLarge","[class.ant-input-affix-wrapper-sm]":"isAffix && !isAddOn && isSmall","[class.ant-input-group]":"!isAffix && !isAddOn","[class.ant-input-group-lg]":"!isAffix && !isAddOn && isLarge","[class.ant-input-group-sm]":"!isAffix && !isAddOn && isSmall"}}]}],t.ctorParameters=function(){return[{type:e.FocusMonitor},{type:n.ElementRef},{type:n.ChangeDetectorRef}]},t.propDecorators={listOfNzInputDirective:[{type:n.ContentChildren,args:[h]}],nzAddOnBeforeIcon:[{type:n.Input}],nzAddOnAfterIcon:[{type:n.Input}],nzPrefixIcon:[{type:n.Input}],nzSuffixIcon:[{type:n.Input}],nzAddOnBefore:[{type:n.Input}],nzAddOnAfter:[{type:n.Input}],nzPrefix:[{type:n.Input}],nzSuffix:[{type:n.Input}],nzSize:[{type:n.Input}],nzSearch:[{type:n.Input}],nzCompact:[{type:n.Input}]},l([i.InputBoolean(),f("design:type",Object)],t.prototype,"nzSearch",void 0),l([i.InputBoolean(),f("design:type",Object)],t.prototype,"nzCompact",void 0),t}();var z=function(){function t(t,e,n,i){this.elementRef=t,this.ngZone=e,this.platform=n,this.resizeService=i,this.autosize=!1,this.el=this.elementRef.nativeElement,this.maxHeight=null,this.minHeight=null,this.destroy$=new r.Subject,this.inputGap=10}return Object.defineProperty(t.prototype,"nzAutosize",{set:function(t){var e;"string"==typeof t?this.autosize=!0:"string"!=typeof(e=t)&&"boolean"!=typeof e&&(e.maxRows||e.minRows)&&(this.autosize=t,this.minRows=t.minRows,this.maxRows=t.maxRows,this.maxHeight=this.setMaxHeight(),this.minHeight=this.setMinHeight())},enumerable:!0,configurable:!0}),t.prototype.resizeToFitContent=function(t){var e=this;if(void 0===t&&(t=!1),this.cacheTextareaLineHeight(),this.cachedLineHeight){var n=this.el,i=n.value;if(t||this.minRows!==this.previousMinRows||i!==this.previousValue){var r=n.placeholder;n.classList.add("nz-textarea-autosize-measuring"),n.placeholder="";var o=Math.round((n.scrollHeight-this.inputGap)/this.cachedLineHeight)*this.cachedLineHeight+this.inputGap;null!==this.maxHeight&&o>this.maxHeight&&(o=this.maxHeight),null!==this.minHeight&&o<this.minHeight&&(o=this.minHeight),n.style.height=o+"px",n.classList.remove("nz-textarea-autosize-measuring"),n.placeholder=r,"undefined"!=typeof requestAnimationFrame&&this.ngZone.runOutsideAngular((function(){return requestAnimationFrame((function(){var t=n.selectionStart,i=n.selectionEnd;e.destroy$.isStopped||document.activeElement!==n||n.setSelectionRange(t,i)}))})),this.previousValue=i,this.previousMinRows=this.minRows}}},t.prototype.cacheTextareaLineHeight=function(){if(!(this.cachedLineHeight>=0)&&this.el.parentNode){var t=this.el.cloneNode(!1);t.rows=1,t.style.position="absolute",t.style.visibility="hidden",t.style.border="none",t.style.padding="0",t.style.height="",t.style.minHeight="",t.style.maxHeight="",t.style.overflow="hidden",this.el.parentNode.appendChild(t),this.cachedLineHeight=t.clientHeight-this.inputGap,this.el.parentNode.removeChild(t),this.maxHeight=this.setMaxHeight(),this.minHeight=this.setMinHeight()}},t.prototype.setMinHeight=function(){var t=this.minRows&&this.cachedLineHeight?this.minRows*this.cachedLineHeight+this.inputGap:null;return null!==t&&(this.el.style.minHeight=t+"px"),t},t.prototype.setMaxHeight=function(){var t=this.maxRows&&this.cachedLineHeight?this.maxRows*this.cachedLineHeight+this.inputGap:null;return null!==t&&(this.el.style.maxHeight=t+"px"),t},t.prototype.noopInputHandler=function(){},t.prototype.ngAfterViewInit=function(){var t=this;this.autosize&&this.platform.isBrowser&&(this.resizeToFitContent(),this.resizeService.subscribe().pipe(o.takeUntil(this.destroy$)).subscribe((function(){return t.resizeToFitContent(!0)})))},t.prototype.ngOnDestroy=function(){this.destroy$.next(),this.destroy$.complete()},t.prototype.ngDoCheck=function(){this.autosize&&this.platform.isBrowser&&this.resizeToFitContent()},t.decorators=[{type:n.Directive,args:[{selector:"textarea[nzAutosize]",exportAs:"nzAutosize",host:{rows:"1","(input)":"noopInputHandler()"}}]}],t.ctorParameters=function(){return[{type:n.ElementRef},{type:n.NgZone},{type:s.Platform},{type:c.NzResizeService}]},t.propDecorators={nzAutosize:[{type:n.Input}]},t}();var y=function(){function t(){this.icon=null,this.type=null,this.template=null}return t.decorators=[{type:n.Component,args:[{selector:"[nz-input-group-slot]",preserveWhitespaces:!1,encapsulation:n.ViewEncapsulation.None,changeDetection:n.ChangeDetectionStrategy.OnPush,template:'\n <i nz-icon [nzType]="icon" *ngIf="icon"></i>\n <ng-container *nzStringTemplateOutlet="template">{{ template }}</ng-container>\n ',host:{"[class.ant-input-group-addon]":"type === 'addon'","[class.ant-input-prefix]":"type === 'prefix'","[class.ant-input-suffix]":"type === 'suffix'"}}]}],t.propDecorators={icon:[{type:n.Input}],type:[{type:n.Input}],template:[{type:n.Input}]},t}();var x=function(){function t(){}return t.decorators=[{type:n.NgModule,args:[{declarations:[h,m,z,y,g],exports:[h,m,z,g],imports:[a.CommonModule,u.NzIconModule,s.PlatformModule,p.NzOutletModule]}]}],t}();t.NzAutosizeDirective=z,t.NzInputDirective=h,t.NzInputGroupComponent=m,t.NzInputGroupSlotComponent=y,t.NzInputGroupWhitSuffixOrPrefixDirective=g,t.NzInputModule=x,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-input.umd.min.js.map