@ng-arthur/core
Version:
@ng-arthur/core for Angular 8+ Components
2 lines • 20 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@ngx-translate/core"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("nprogress"),require("qrcode"),require("@angular/common/http"),require("@ng-arthur/common"),require("deepmerge"),require("@angular/platform-browser"),require("@angular/router")):"function"==typeof define&&define.amd?define("@ng-arthur/core",["exports","@angular/core","@ngx-translate/core","rxjs","rxjs/operators","@angular/common","nprogress","qrcode","@angular/common/http","@ng-arthur/common","deepmerge","@angular/platform-browser","@angular/router"],t):t(((e=e||self)["ng-arthur"]=e["ng-arthur"]||{},e["ng-arthur"].core={}),e.ng.core,e["@ngx-translate/core"],e.rxjs,e.rxjs.operators,e.ng.common,e.nprogress,e.qrcode,e.ng.common.http,e["@ng-arthur/common"],e.deepmerge,e.ng.platformBrowser,e.ng.router)}(this,function(e,t,r,n,o,i,a,s,p,u,c,l,f){"use strict";s=s&&s.hasOwnProperty("default")?s["default"]:s,c=c&&c.hasOwnProperty("default")?c["default"]:c;var d=function(e,t){return(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)};function g(e,t){function r(){this.constructor=e}d(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function h(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,a),a}function y(e,t){return function(r,n){t(r,n,e)}}function m(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function v(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(s){o={error:s}}finally{try{n&&!n.done&&(r=i["return"])&&r.call(i)}finally{if(o)throw o.error}}return a}function b(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(v(arguments[t]));return e}var I=function(){function e(e){this.translate=e}return Object.defineProperty(e.prototype,"naI18n",{set:function(e){this.translate.translate=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"naI18nParams",{set:function(e){this.translate.translateParams=e},enumerable:!0,configurable:!0}),h([t.Input(),m("design:type",String),m("design:paramtypes",[String])],e.prototype,"naI18n",null),h([t.Input(),m("design:type",Object),m("design:paramtypes",[Object])],e.prototype,"naI18nParams",null),e=h([t.Directive({selector:"[naI18n]"}),m("design:paramtypes",[r.TranslateDirective])],e)}(),j=function(){function e(e){this.translate=e}return e.prototype.transform=function(e,t){return this.translate.transform(e,t)},e=h([t.Injectable(),t.Pipe({name:"naI18N",pure:!1}),m("design:paramtypes",[r.TranslatePipe])],e)}(),S=function(){function e(){}return e=h([t.NgModule({imports:[r.TranslateModule],exports:[r.TranslateModule,j,I],declarations:[j,I]})],e)}(),w=function(){function e(e){this.translate=e,this.change$=new n.BehaviorSubject(new Object),(null==e.getLangs()||e.getLangs().length<=0)&&e.addLangs([this.translate.getBrowserLang()]),null==this.translate.getDefaultLang()&&this.translate.setDefaultLang(this.translate.getBrowserLang())}return Object.defineProperty(e.prototype,"change",{get:function(){return this.change$.asObservable().pipe(o.filter(function(e){return null!=e}))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentLang",{get:function(){return this.translate.currentLang},enumerable:!0,configurable:!0}),e.prototype.get=function(e,t){return this.translate.get(e,t)},e.prototype.stream=function(e,t){return this.translate.stream(e,t)},e.prototype.instant=function(e,t){return this.translate.instant(e,t)},e.prototype.use=function(e){return this.change$.next(e),this.translate.use(e)},e.prototype.setDefaultLang=function(e){this.translate.setDefaultLang(e)},e.prototype.getDefaultLang=function(){return this.translate.defaultLang},e.prototype.getLangs=function(){return this.translate.langs},e.prototype.addLangs=function(e){this.translate.addLangs(e)},e.prototype.set=function(e,t,r){void 0===r&&(r=this.translate.currentLang),this.translate.set(e,t,r)},e.prototype.reloadLang=function(e){return this.translate.reloadLang(e)},e.prototype.resetLang=function(e){this.translate.resetLang(e)},e.prototype.getBrowserLang=function(){return this.translate.getBrowserLang()},e.prototype.getBrowserCultureLang=function(){return this.translate.getBrowserCultureLang()},e=h([t.Injectable(),m("design:paramtypes",[r.TranslateService])],e)}(),N=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return g(n,e),n.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new n(t.ɵɵinject(r.TranslateService))},token:n,providedIn:"root"}),n=h([t.Injectable({providedIn:"root"})],n)}(w),O=function(){function e(e){this.i18nSrv=e,this._change$=new n.BehaviorSubject([]),this.data=[]}return Object.defineProperty(e.prototype,"change",{get:function(){return this._change$.pipe(o.share())},enumerable:!0,configurable:!0}),e.prototype.getPathByUrl=function(e){return null},e.prototype.ngOnDestroy=function(){this._change$&&this._change$.unsubscribe(),this.i18n$&&this.i18n$.unsubscribe()},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(N))},token:e,providedIn:"root"}),e=h([t.Injectable({providedIn:"root"}),m("design:paramtypes",[N])],e)}(),T=function(){function e(){}return e.prototype.success=function(e,t){throw new Error("请导入NaMessageService实现类, 错误信息: "+e)},e.prototype.error=function(e,t){throw new Error("请导入NaMessageService实现类, 错误信息: "+e)},e.prototype.info=function(e,t){throw new Error("请导入NaMessageService实现类, 错误信息: "+e)},e.prototype.warning=function(e,t){throw new Error("请导入NaMessageService实现类, 错误信息: "+e)},e.prototype.loading=function(e,t){throw new Error("请导入NaMessageService实现类, 错误信息: "+e)},e.prototype.hide=function(){},e=h([t.Injectable()],e)}(),x=function(){function e(){}return e=h([t.NgModule({imports:[i.CommonModule],providers:[T]})],e)}();var E=function(){function e(){this.progressEmitter=new t.EventEmitter}return e.prototype.start=function(){this.progressEmitter.emit(!0)},e.prototype.done=function(){this.progressEmitter.emit(!1)},e=h([t.Injectable(),m("design:paramtypes",[])],e)}(),_=function(){function e(e){this.progressBarService=e,this.options={parent:"#container",showSpinner:!1},a.configure(this.options),this.progressEmitter$=this.progressBarService.progressEmitter.subscribe(function(e){e?a.start():a.done()})}return Object.defineProperty(e.prototype,"progress",{set:function(e){this.progressBarService.progressEmitter.emit(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnDestroy=function(){this.progressEmitter$&&this.progressEmitter$.unsubscribe()},e.prototype.ngAfterViewInit=function(){},e.prototype.ngAfterContentInit=function(){},e.prototype.ngOnChanges=function(e){},h([t.Input(),m("design:type",Object)],e.prototype,"options",void 0),h([t.Input(),m("design:type",Boolean),m("design:paramtypes",[Boolean])],e.prototype,"progress",null),e=h([t.Component({selector:"na-progress-bar",template:'<div id="container" style="height: 100%;">\n <ng-content></ng-content>\n</div>\n',encapsulation:t.ViewEncapsulation.None,styles:["#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:2px solid transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:.4s linear infinite nprogress-spinner;animation:.4s linear infinite nprogress-spinner}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@keyframes nprogress-spinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}"]}),m("design:paramtypes",[E])],e)}(),M=function(){function e(){}return e=h([t.NgModule({imports:[i.CommonModule],exports:[_],declarations:[_],providers:[E]})],e)}(),C=function(){function e(e,r){this.el=e,this._doc=r,this.urlChange=new t.EventEmitter,this.level="M",this.margin=0,this.type="image/jpeg",this.size=256,this.colorDark="#000000",this.colorLight="#ffffff",this.isValidQrCodeText=function(e){return!(void 0===e)}}return e.prototype.ngOnInit=function(){var e=this;s.toDataURL(this._doc.getElementById("canvas"),this.data,{version:this.version,errorCorrectionLevel:this.level,margin:this.margin,width:this.size,color:{dark:this.colorDark,light:this.colorLight},type:this.type,rendererOpts:{quality:.3}}).then(function(t){e.urlChange.emit(t)})["catch"](function(e){console.error(e)})},e.prototype.ngOnChanges=function(e){var t=e.data;t&&this.isValidQrCodeText(t.currentValue)},h([t.Input(),m("design:type",Number)],e.prototype,"version",void 0),h([t.Input(),m("design:type",String)],e.prototype,"data",void 0),h([t.Input(),m("design:type",String)],e.prototype,"url",void 0),h([t.Output(),m("design:type",Object)],e.prototype,"urlChange",void 0),h([t.Input(),m("design:type",String)],e.prototype,"level",void 0),h([t.Input(),m("design:type",Object)],e.prototype,"margin",void 0),h([t.Input(),m("design:type",String)],e.prototype,"type",void 0),h([t.Input(),m("design:type",Object)],e.prototype,"size",void 0),h([t.Input(),m("design:type",Object)],e.prototype,"colorDark",void 0),h([t.Input(),m("design:type",Object)],e.prototype,"colorLight",void 0),e=h([t.Component({selector:"na-qrcode",template:'<canvas id="canvas"></canvas>\n',changeDetection:t.ChangeDetectionStrategy.OnPush,styles:[""]}),y(1,t.Inject(i.DOCUMENT)),m("design:paramtypes",[t.ElementRef,Object])],e)}(),L=function(){function e(){}return e.prototype.create=function(e,t){return s.create(e,t)},e.prototype.toCanvas=function(e,t,r){return r?s.toCanvas(r,e,t):s.toCanvas(e,t)},e.prototype.toDataURL=function(e,t,r){return r?s.toDataURL(r,e,t):s.toDataURL(e,t)},e.prototype.toString=function(e,t){return s.toString(e,t)},e.prototype.toFile=function(e,t,r){return s.toFile(e,t,r)},e.prototype.toFileStream=function(e,t,r){return s.toFileStream(e,t,r)},e=h([t.Injectable(),m("design:paramtypes",[])],e)}(),D=function(){function e(){}return e=h([t.NgModule({imports:[],exports:[C],providers:[L],declarations:[C]})],e)}(),R=function(){function e(){}return e.prototype.ngOnInit=function(){},e=h([t.Component({selector:"na-settings",template:"<p>\n settings works!\n</p>\n",styles:[""]}),m("design:paramtypes",[])],e)}(),P=function(){function e(){}return e=h([t.NgModule({imports:[i.CommonModule],declarations:[R]})],e)}(),k=function(){function e(){}return e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e=h([t.Injectable({providedIn:"root"}),m("design:paramtypes",[])],e)}(),B=new t.InjectionToken("NA_STARTUP_CONFIG"),A=function(){function e(e){this.client=e,this._startupConfig={},this.initialized=!1,this.cache=new Map}return e.prototype.load=function(e){var t=this,r=e.prefix+e.suffix;return this.client.get(r).pipe(o.switchMap(function(r){var i=Object.assign({},r),a=i.profiles;if(a&&a.active){var s=e.prefix+"-"+a.active+e.suffix;return t.client.get(s,{params:{}}).pipe(o.map(function(e){return u.NaUtils.mergeJSON(i,e),i}))}return n.of(i)}),o.tap(function(e){t._startupConfig=e,t.initialized=!0}),o.catchError(function(e){return console.error("the profiles does not exist or error. please check the profiles active.",e),n.throwError(e)})).toPromise()},e.prototype.get=function(e){if(!this.initialized)throw new Error("未加载完毕!");return this.getValue(this._startupConfig,e)},e.prototype.getValue=function(e,t){if(this.cache.has(t))return this.cache.get(t);var r=t.split(".");t="";do{t+=r.shift(),!u.NaUtils.isDefined(e)||!u.NaUtils.isDefined(e[t])||"object"!=typeof e[t]&&r.length?r.length?t+=".":e=undefined:(e=e[t],t="")}while(r.length);return this.cache.set(t,e),e},e=h([t.Injectable(),m("design:paramtypes",[p.HttpClient])],e)}();function q(e,t){if(e)throw new Error(t+" has already been loaded. Import "+t+" modules in the AppModule only.")}var U=new t.InjectionToken("NA_TRANSLATE_RESOURCES"),$=function(){function e(e,t,r){this.http=e,this.resources=t,this.injector=r}return e.prototype.getTranslation=function(e){var t=this,r=[];this.injector.get(U,[]).forEach(function(t){r.push(t.getTranslation(e).pipe(o.catchError(function(e){return console.error("获取翻译资源失败!",e),n.of({})})))});var i=this.resources.map(function(r){return t.http.get(r.prefix+e+r.suffix).pipe(o.catchError(function(e){return console.error("获取翻译资源失败!",e),n.of({})}))});return r.push.apply(r,b(i)),n.forkJoin(r).pipe(o.map(function(e){var t=[];return e.forEach(function(e){e&&t.push(e)}),c.all(t)}))},e}(),F=new t.InjectionToken("NA_DEFAULT_RESOURCES");function V(e,t,r){return new $(e,t,r)}var z=function(){function e(){}var n;return n=e,e.forRoot=function(e){return void 0===e&&(e=[]),{ngModule:n,providers:b([{provide:F,useValue:e}],r.TranslateModule.forRoot({loader:{provide:r.TranslateLoader,useFactory:V,deps:[p.HttpClient,F,t.Injector]},isolate:!0,useDefaultLang:!0}).providers)}},e=n=h([t.NgModule({imports:[r.TranslateModule],exports:[r.TranslateModule],providers:[w]})],e)}(),J=function(){function e(e){q(e,"NaStartupModule")}var r;return r=e,e.forRoot=function(e){return{ngModule:r,providers:[{provide:B,useValue:e},A,{provide:t.APP_INITIALIZER,useFactory:Q,deps:[A,B],multi:!0}]}},e=r=h([t.NgModule({imports:[z]}),y(0,t.Optional()),y(0,t.SkipSelf()),m("design:paramtypes",[e])],e)}();function Q(e,t){return function(){return e.load(t)}}var G=function(){function e(e){this.meta=e}return e.prototype.addTag=function(e,t){return this.meta.addTag(e,t)},e.prototype.addTags=function(e,t){return this.meta.addTags(e,t)},e.prototype.getTag=function(e){return this.meta.getTag(e)},e.prototype.getTags=function(e){return this.meta.getTags(e)},e.prototype.updateTag=function(e,t){return this.meta.updateTag(e,t)},e.prototype.removeTag=function(e){this.meta.removeTag(e)},e.prototype.removeTagElement=function(e){this.meta.removeTagElement(e)},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(l.Meta))},token:e,providedIn:"root"}),e=h([t.Injectable({providedIn:"root"}),m("design:paramtypes",[l.Meta])],e)}(),H=function(){function e(e,t,r){this.injector=e,this.title=t,this.doc=r,this._prefix="",this._suffix="",this._separator=" - ",this._reverse=!1,this._default="Not Page Name"}return Object.defineProperty(e.prototype,"separator",{set:function(e){this._separator=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"prefix",{set:function(e){this._prefix=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"suffix",{set:function(e){this._suffix=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reverse",{set:function(e){this._reverse=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"default",{set:function(e){this._default=e},enumerable:!0,configurable:!0}),e.prototype.getByElement=function(){var e=this.doc.querySelector(".content__title h1")||this.doc.querySelector("pro-header h1.title");return e?e.firstChild.textContent.trim():""},e.prototype.getByRoute=function(){for(var e=this.injector.get(f.ActivatedRoute);e.firstChild;)e=e.firstChild;return(e.snapshot&&e.snapshot.data||{}).title},e.prototype.getByMenu=function(){return null},e.prototype.setTitle=function(e){e||(e=this.getByRoute()||this.getByMenu()||this.getByElement()||this._default),e&&!Array.isArray(e)&&(e=[e]);var t=[];this._prefix&&t.push(this._prefix),t.push.apply(t,b(e)),this._suffix&&t.push(this._suffix),this._reverse&&(t=t.reverse()),this.title.setTitle(t.join(this._separator))},e.prototype.ngOnDestroy=function(){this.i18n$&&this.i18n$.unsubscribe()},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e(t.ɵɵinject(t.INJECTOR),t.ɵɵinject(l.Title),t.ɵɵinject(i.DOCUMENT))},token:e,providedIn:"root"}),e=h([t.Injectable({providedIn:"root"}),y(2,t.Inject(i.DOCUMENT)),m("design:paramtypes",[t.Injector,l.Title,Object])],e)}(),W=(new t.InjectionToken("Browser Storage",{providedIn:"root",factory:function(){return localStorage}}),function(){function e(){}return e.prototype.set=function(e,t,r){var n=new Object;n.data=t,null!=r&&(n.expires=(new Date).getTime()+1e3*r),this.storage.setItem(e,JSON.stringify(n))},e.prototype.get=function(e){return this.getValidData(e)},e.prototype.remove=function(e){this.storage.removeItem(e)},e.prototype.getValidData=function(e){var t=this.storage.getItem(e);try{var r=JSON.parse(t);if(r){if(null==r.expires||r.expires>=(new Date).getTime())return r.data;this.remove(e)}return null}catch(n){return t}},e}());function Z(){return localStorage}var K=new t.InjectionToken("Browser LocalStorage",{providedIn:"root",factory:Z}),X=function(e){function r(t){var r=e.call(this)||this;return r.storage=t,r.storage=t,r}return g(r,e),r=h([t.Injectable(),y(0,t.Inject(K)),m("design:paramtypes",[Object])],r)}(W);function Y(){return sessionStorage}var ee=new t.InjectionToken("Browser SessionStorage",{providedIn:"root",factory:Y}),te=function(e){function r(t){var r=e.call(this)||this;return r.storage=t,r.storage=t,r}return g(r,e),r=h([t.Injectable(),y(0,t.Inject(ee)),m("design:paramtypes",[Object])],r)}(W),re=function(){function e(){this.preloadedModules=[]}return e.prototype.preload=function(e,t){return e.data&&e.data.preload?(this.preloadedModules.push(e.path),t()):n.of(null)},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e=h([t.Injectable({providedIn:"root"})],e)}(),ne=function(){function e(e){q(e,"NaCoreModule")}return e=h([t.NgModule({exports:[x],providers:[X,te,re]}),y(0,t.Optional()),y(0,t.SkipSelf()),m("design:paramtypes",[e])],e)}();e.BROWSER_LOCALSTORAGE=K,e.BROWSER_SESSIONSTORAGE=ee,e.DeleteEmptyFields=function(e,t,r,n){return console.log(e,t,r,n),function(e,t){console.log(e,t)}},e.MultiTranslateHttpLoader=$,e.NA_DEFAULT_RESOURCES=F,e.NA_STARTUP_CONFIG=B,e.NA_TRANSLATE_RESOURCES=U,e.NaCoreModule=ne,e.NaI18NDirective=I,e.NaI18NModule=S,e.NaI18NPipe=j,e.NaI18NService=N,e.NaLocalStorageService=X,e.NaMenuService=O,e.NaMessageModule=x,e.NaMessageService=T,e.NaMetaService=G,e.NaQRCodeComponent=C,e.NaQRCodeModule=D,e.NaQRCodeService=L,e.NaSelectivePreloadStrategy=re,e.NaSessionStorageService=te,e.NaSettingsComponent=R,e.NaSettingsModule=P,e.NaSettingsService=k,e.NaStartupModule=J,e.NaStartupService=A,e.NaStartupServiceFactory=Q,e.NaTitleService=H,e.NaTranslateModule=z,e.NaTranslateService=w,e.ProgressBarComponent=_,e.ProgressBarModule=M,e.ProgressBarService=E,e._localStorage=Z,e._sessionStorage=Y,e.createTranslateLoader=V,e.preloaderFinished=function(){var e=document.querySelector("body"),t=document.querySelector(".preloader");e.style.overflow="hidden",window.appBootstrap=function(){setTimeout(function(){t&&(t.addEventListener("transitionend",function(){t.className="preloader-hidden"}),t.className+=" preloader-hidden-add preloader-hidden-add-active"),e.style.overflow=""},100)}},e.throwIfAlreadyLoaded=q,e.ɵa=W,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=ng-arthur-core.umd.min.js.map