UNPKG

@ngx-easy-i18n-js/bootstrap

Version:
1 lines 11.2 kB
{"version":3,"file":"ngx-easy-i18n-js-bootstrap.mjs","sources":["../../../projects/bootstrap/src/lib/easy-i18n-bootstrap.component.ts","../../../projects/bootstrap/src/lib/easy-i18n-bootstrap.component.html","../../../projects/bootstrap/src/public-api.ts","../../../projects/bootstrap/src/ngx-easy-i18n-js-bootstrap.ts"],"sourcesContent":["import { Component, ComponentRef, Inject, InjectionToken, Injector, OnDestroy, OnInit, ViewChild } from '@angular/core';\r\nimport { Observable } from 'rxjs';\r\nimport { CdkPortalOutlet, ComponentPortal, PortalModule } from '@angular/cdk/portal';\r\nimport { tap } from 'rxjs/operators';\r\nimport { ComponentType } from '@angular/cdk/overlay';\r\nimport { EasyI18nService, LocaleStatus } from '@ngx-easy-i18n-js/core';\r\nimport { CommonModule } from '@angular/common';\r\n\r\nexport const BOOTSTRAP = new InjectionToken<ComponentType<any>>('BOOTSTRAP');\r\nexport const LOADING_COMPONENT = new InjectionToken<ComponentType<any>>('LOADING_COMPONENT');\r\n\r\n@Component({\n selector: 'ngx-easy-i18n',\n templateUrl: './easy-i18n-bootstrap.component.html',\n standalone: false\n})\r\nexport class EasyI18nBootstrapComponent implements OnInit, OnDestroy {\r\n\r\n @ViewChild(CdkPortalOutlet, { static: true })\r\n portalOutlet?: CdkPortalOutlet;\r\n\r\n localeStatus$?: Observable<LocaleStatus>;\r\n\r\n loadingPortal?: ComponentPortal<any> | null;\r\n\r\n private containerRef?: ComponentRef<any> | null;\r\n\r\n constructor(\r\n private injector: Injector,\r\n @Inject(BOOTSTRAP) private bootstrap: ComponentType<any>,\r\n @Inject(LOADING_COMPONENT) private loadingComponent: ComponentType<any>,\r\n private easyI18nService: EasyI18nService\r\n ) {\r\n }\r\n\r\n ngOnInit(): void {\r\n const injector = Injector.create({\r\n providers: [],\r\n parent: this.injector\r\n });\r\n this.loadingPortal = this.loadingComponent != null ?\r\n new ComponentPortal<any>(this.loadingComponent, undefined, injector) : null;\r\n\r\n const bootstrapPortal = new ComponentPortal<any>(this.bootstrap, undefined, injector);\r\n\r\n this.localeStatus$ = this.easyI18nService.localeStatus$.pipe(\r\n tap(res => {\r\n if (res === 'ready') {\r\n if (this.containerRef != null) {\r\n this.portalOutlet?.detach();\r\n this.containerRef = null;\r\n }\r\n this.containerRef = this.portalOutlet?.attachComponentPortal(bootstrapPortal);\r\n }\r\n })\r\n );\r\n }\r\n\r\n ngOnDestroy(): void {\r\n this.portalOutlet?.dispose();\r\n }\r\n}","<ng-template cdkPortalOutlet></ng-template>\n<ng-container *ngIf=\"localeStatus$ | async as localeStatus\">\n <div *ngIf=\"localeStatus === 'loading'\"\n style=\"pointer-events: all; position: absolute; top: 0; left: 0; bottom: 0; right: 0; z-index: 10000;\">\n <ng-container *ngIf=\"loadingPortal; else defaultLoadingTemplate\">\n <ng-template [cdkPortalOutlet]=\"loadingPortal\"></ng-template>\n </ng-container>\n <ng-template #defaultLoadingTemplate>\n <div style=\"display: grid; height: 100vh; place-content: center; background-color: #FFFFFF77\">\n <div style=\"font-weight: 300; font-size: 3.5rem; line-height: 1.2;\">Loading languages...</div>\n <div style=\"text-align: center;\">\n <svg xmlns=\"http://www.w3.org/2000/svg\"\n style=\"margin: auto; background: rgba(0, 0, 0, 0); display: block; shape-rendering: auto;\" width=\"100px\"\n height=\"100px\" viewBox=\"0 0 100 100\" preserveAspectRatio=\"xMidYMid\">\n <rect x=\"19\" y=\"19\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"40\" y=\"19\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.125s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"61\" y=\"19\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.25s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"19\" y=\"40\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.875s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"61\" y=\"40\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.375s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"19\" y=\"61\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.75s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"40\" y=\"61\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.625s\" calcMode=\"discrete\"></animate>\n </rect>\n <rect x=\"61\" y=\"61\" width=\"20\" height=\"20\" rx=\"5\" ry=\"5\" fill=\"#1d3f72\">\n <animate attributeName=\"fill\" values=\"#5699d2;#1d3f72;#1d3f72\" keyTimes=\"0;0.125;1\" dur=\"1s\"\n repeatCount=\"indefinite\" begin=\"0.5s\" calcMode=\"discrete\"></animate>\n </rect>\n </svg>\n </div>\n </div>\n </ng-template>\n </div>\n</ng-container>","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { BOOTSTRAP, EasyI18nBootstrapComponent, LOADING_COMPONENT } from './lib/easy-i18n-bootstrap.component';\r\nimport { ComponentType } from '@angular/cdk/overlay';\r\nimport { CommonModule } from '@angular/common';\r\nimport { PortalModule } from '@angular/cdk/portal';\r\n\r\nexport * from './lib/easy-i18n-bootstrap.component';\r\n\r\nexport interface EasyI18nBootstrapModuleConfig {\r\n bootstrap: ComponentType<any>;\r\n loadingComponent?: ComponentType<any>;\r\n}\r\n\r\n@NgModule({\r\n imports: [\r\n CommonModule,\r\n PortalModule\r\n ],\r\n declarations: [\r\n EasyI18nBootstrapComponent\r\n ],\r\n exports: [\r\n EasyI18nBootstrapComponent\r\n ]\r\n})\r\nexport class EasyI18nBootstrapModule {\r\n\r\n static forRoot(config: EasyI18nBootstrapModuleConfig): ModuleWithProviders<EasyI18nBootstrapModule> {\r\n return {\r\n ngModule: EasyI18nBootstrapModule,\r\n providers: [\r\n { provide: BOOTSTRAP, useValue: config.bootstrap },\r\n { provide: LOADING_COMPONENT, useValue: config.loadingComponent }\r\n ]\r\n };\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAQa,SAAS,GAAG,IAAI,cAAc,CAAqB,WAAW;MAC9D,iBAAiB,GAAG,IAAI,cAAc,CAAqB,mBAAmB;MAO9E,0BAA0B,CAAA;AAWrC,IAAA,WAAA,CACU,QAAkB,EACC,SAA6B,EACrB,gBAAoC,EAC/D,eAAgC,EAAA;QAHhC,IAAQ,CAAA,QAAA,GAAR,QAAQ;QACW,IAAS,CAAA,SAAA,GAAT,SAAS;QACD,IAAgB,CAA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