UNPKG

@lxlib/seed

Version:

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.

16 lines (14 loc) 4.97 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core"),require("@lxlib/util"),require("ng-zorro-antd/icon")):"function"==typeof define&&define.amd?define("@lxlib/seed/error-collect",["exports","@angular/common","@angular/core","@lxlib/util","ng-zorro-antd/icon"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.seed=e.lxlib.seed||{},e.lxlib.seed["error-collect"]={}),e.ng.common,e.ng.core,e.lxlib.util,e["ng-zorro-antd/icon"])}(this,(function(e,t,r,o,n){"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. ***************************************************************************** */var i=function(){return(i=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function l(e,t,r,o){var n,i=arguments.length,l=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,r):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,r,o);else for(var c=e.length-1;c>=0;c--)(n=e[c])&&(l=(i<3?n(l):i>3?n(t,r,l):n(t,r))||l);return i>3&&l&&Object.defineProperty(t,r,l),l}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var o,n,i=r.call(e),l=[];try{for(;(void 0===t||t-- >0)&&!(o=i.next()).done;)l.push(o.value)}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return l}function s(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}var u=function(){function e(){this.freq=500,this.offsetTop=145}return e.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],e.ɵprov=r.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}();var f=function(){function e(e,t,r,o){this.el=t,this.cdr=r,this.doc=o,this.$time=null,this._hiden=!0,this.count=0,Object.assign(this,i(i({},new u),e))}return Object.defineProperty(e.prototype,"errEls",{get:function(){return this.formEl.querySelectorAll(".ant-form-item-has-error")},enumerable:!0,configurable:!0}),e.prototype.update=function(){var e=this.errEls.length;e!==this.count&&(this.count=e,this._hiden=0===e,this.cdr.markForCheck())},e.prototype._click=function(){if(0===this.count)return!1;var e=this.errEls;return(this.findParent(e[0],"[nz-form-control]")||e[0]).scrollIntoView(!0),this.doc.documentElement.scrollTop-=this.offsetTop,!0},e.prototype.install=function(){var e=this;this.uninstall(),this.$time=setInterval((function(){return e.update()}),this.freq),this.update()},e.prototype.uninstall=function(){clearInterval(this.$time)},e.prototype.findParent=function(e,t){for(var r=null;e;){if(e.querySelector(t)){r=e;break}e=e.parentElement}return r},e.prototype.ngOnInit=function(){if(this.formEl=this.findParent(this.el.nativeElement,"form"),null===this.formEl)throw new Error("No found form element");this.install()},e.prototype.ngOnDestroy=function(){this.uninstall()},e.decorators=[{type:r.Component,args:[{selector:"error-collect, [error-collect]",exportAs:"errorCollect",template:'\n <i nz-icon nzType="exclamation-circle"></i>\n <span class="pl-sm">{{ count }}</span>\n ',host:{"[class.error-collect]":"true","[class.d-none]":"_hiden","(click)":"_click()"},preserveWhitespaces:!1,changeDetection:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None}]}],e.ctorParameters=function(){return[{type:u},{type:r.ElementRef},{type:r.ChangeDetectorRef},{type:void 0,decorators:[{type:r.Inject,args:[t.DOCUMENT]}]}]},e.propDecorators={freq:[{type:r.Input}],offsetTop:[{type:r.Input}]},l([o.InputNumber(),c("design:type",Number)],e.prototype,"freq",void 0),l([o.InputNumber(),c("design:type",Number)],e.prototype,"offsetTop",void 0),e}();var p=[f],d=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{imports:[t.CommonModule,o.LxlibUtilModule,n.NzIconModule],declarations:s(p),exports:s(p)}]}],e}();e.ErrorCollectComponent=f,e.ErrorCollectConfig=u,e.ErrorCollectModule=d,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=errorCollect.umd.min.js.map