@koalarx/ui 20.1.5 → 20.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -178,11 +178,11 @@ class SnackbarContent {
|
|
|
178
178
|
this.snackbarRef.dismiss();
|
|
179
179
|
}
|
|
180
180
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SnackbarContent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
181
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SnackbarContent, isStandalone: true, selector: "kl-snackbar-content", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, timeout: { classPropertyName: "timeout", publicName: "timeout", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "alertContentRef", first: true, predicate: ["alertContent"], descendants: true, isSignal: true }, { propertyName: "alertIconRef", first: true, predicate: ["alertIcon"], descendants: true, isSignal: true }], ngImport: i0, template: "<div role=\"alert\" #alertContent class=\"relative alert alert-outline bg-base-100! w-full lg:max-w-1/4 rounded-sm\">\n <i #alertIcon class=\"h-
|
|
181
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SnackbarContent, isStandalone: true, selector: "kl-snackbar-content", inputs: { type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: true, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, timeout: { classPropertyName: "timeout", publicName: "timeout", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "alertContentRef", first: true, predicate: ["alertContent"], descendants: true, isSignal: true }, { propertyName: "alertIconRef", first: true, predicate: ["alertIcon"], descendants: true, isSignal: true }], ngImport: i0, template: "<div role=\"alert\" #alertContent class=\"relative alert alert-outline bg-base-100! w-full lg:max-w-1/4 rounded-sm text-sm py-3 border-neutral-600\">\n <i #alertIcon class=\"h-4 w-4 shrink-0 stroke-current text-base fa-solid\"></i>\n <span [innerHTML]=\"message()\"></span>\n <div>\n <button class=\"btn btn-xs btn-outline\" (click)=\"dismiss()\">OK</button>\n </div>\n @if (timePast() > 0) {\n <progress class=\"absolute left-0 bottom-0 progress w-full opacity-20\"\n [value]=\"timePast()\"\n [max]=\"timeout()\">\n </progress>\n }\n</div>\n" });
|
|
182
182
|
}
|
|
183
183
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SnackbarContent, decorators: [{
|
|
184
184
|
type: Component,
|
|
185
|
-
args: [{ selector: 'kl-snackbar-content', template: "<div role=\"alert\" #alertContent class=\"relative alert alert-outline bg-base-100! w-full lg:max-w-1/4 rounded-sm\">\n <i #alertIcon class=\"h-
|
|
185
|
+
args: [{ selector: 'kl-snackbar-content', template: "<div role=\"alert\" #alertContent class=\"relative alert alert-outline bg-base-100! w-full lg:max-w-1/4 rounded-sm text-sm py-3 border-neutral-600\">\n <i #alertIcon class=\"h-4 w-4 shrink-0 stroke-current text-base fa-solid\"></i>\n <span [innerHTML]=\"message()\"></span>\n <div>\n <button class=\"btn btn-xs btn-outline\" (click)=\"dismiss()\">OK</button>\n </div>\n @if (timePast() > 0) {\n <progress class=\"absolute left-0 bottom-0 progress w-full opacity-20\"\n [value]=\"timePast()\"\n [max]=\"timeout()\">\n </progress>\n }\n</div>\n" }]
|
|
186
186
|
}], ctorParameters: () => [] });
|
|
187
187
|
|
|
188
188
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"koalarx-ui-shared-components-snackbar.mjs","sources":["../../projects/koala-ui/shared/components/snackbar/snackbar.ts","../../projects/koala-ui/shared/components/snackbar/snackbar-ref.ts","../../projects/koala-ui/shared/components/snackbar/snackbar-content.ts","../../projects/koala-ui/shared/components/snackbar/snackbar-content.html","../../projects/koala-ui/shared/components/snackbar/koalarx-ui-shared-components-snackbar.ts"],"sourcesContent":["import {\n ApplicationRef,\n createComponent,\n EnvironmentInjector,\n inject,\n Injectable,\n InjectionToken,\n Injector,\n inputBinding,\n} from '@angular/core';\nimport { randomString } from '@koalarx/utils/KlString';\nimport { SnackbarContent } from './snackbar-content';\nimport { SNACKBAR_REF_TOKEN, SnackbarRef } from './snackbar-ref';\n\nexport const SNACKBAR_CONFIG = new InjectionToken('SnackbarConfig');\nexport const SNACKBAR_APP_REF = new InjectionToken('SnackbarAppRef');\n\nexport type SnackbarType = 'info' | 'success' | 'warning' | 'error';\n\nexport interface SnackbarConfig {\n type: SnackbarType;\n message: string;\n timeout?: number;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Snackbar {\n private readonly appRef = inject(ApplicationRef);\n private readonly injector = inject(EnvironmentInjector);\n\n private generateElementId() {\n let elementId: string;\n\n do {\n elementId = randomString(50, {\n numbers: false,\n lowercase: true,\n uppercase: true,\n specialCharacters: false,\n });\n } while (document.getElementById(elementId));\n\n return elementId;\n }\n\n success(message: string, timeout = 5000) {\n this.open({\n type: 'success',\n message,\n timeout,\n });\n }\n\n warning(message: string, timeout = 5000) {\n this.open({\n type: 'warning',\n message,\n timeout,\n });\n }\n\n error(message: string, timeout = 5000) {\n this.open({\n type: 'error',\n message,\n timeout,\n });\n }\n\n info(message: string, timeout = 5000) {\n this.open({\n type: 'info',\n message,\n timeout,\n });\n }\n\n open(config: SnackbarConfig) {\n const main = document.querySelector<HTMLElement>(\n 'kl-snackbar-container div'\n );\n\n if (main) {\n const elementId = this.generateElementId();\n const container = main.appendChild(document.createElement('div'));\n container.id = elementId;\n container.classList.add('flex', 'item-center', 'justify-end');\n\n const componentRef = createComponent(SnackbarContent, {\n environmentInjector: this.injector,\n hostElement: container,\n elementInjector: Injector.create({\n providers: [\n { provide: SNACKBAR_CONFIG, useValue: config },\n { provide: SNACKBAR_APP_REF, useValue: this.appRef },\n {\n provide: SNACKBAR_REF_TOKEN,\n useValue: () => componentRef,\n },\n {\n provide: SnackbarRef,\n deps: [SNACKBAR_CONFIG, SNACKBAR_APP_REF, SNACKBAR_REF_TOKEN],\n },\n ],\n }),\n bindings: [\n inputBinding('type', () => config.type),\n inputBinding('message', () => config.message),\n inputBinding('timeout', () => config.timeout ?? 0),\n ],\n });\n\n this.appRef.attachView(componentRef.hostView);\n\n componentRef.changeDetectorRef.detectChanges();\n }\n }\n}\n","import {\n ApplicationRef,\n ComponentRef,\n inject,\n Injectable,\n InjectionToken,\n} from '@angular/core';\nimport { SNACKBAR_APP_REF } from './snackbar';\nimport { SnackbarContent } from './snackbar-content';\n\nexport const SNACKBAR_REF_TOKEN = new InjectionToken('SnackbarRefToken');\n\n@Injectable()\nexport class SnackbarRef {\n private readonly appRef = inject<ApplicationRef>(SNACKBAR_APP_REF);\n private readonly componentRef =\n inject<() => ComponentRef<SnackbarContent>>(SNACKBAR_REF_TOKEN);\n\n dismiss() {\n this.componentRef().destroy();\n this.appRef.detachView(this.componentRef().hostView);\n }\n}\n","import {\n Component,\n effect,\n ElementRef,\n inject,\n input,\n OnInit,\n signal,\n viewChild,\n} from '@angular/core';\nimport { SnackbarType } from './snackbar';\nimport { SnackbarRef } from './snackbar-ref';\nimport { interval } from 'rxjs/internal/observable/interval';\nimport { startWith } from 'rxjs/internal/operators/startWith';\nimport { map } from 'rxjs/internal/operators/map';\n\n@Component({\n selector: 'kl-snackbar-content',\n templateUrl: './snackbar-content.html',\n})\nexport class SnackbarContent implements OnInit {\n private readonly alertContentRef =\n viewChild<ElementRef<HTMLDivElement>>('alertContent');\n private readonly alertIconRef =\n viewChild<ElementRef<HTMLElement>>('alertIcon');\n private readonly snackbarRef = inject(SnackbarRef);\n\n type = input.required<SnackbarType>();\n message = input.required<string>();\n timeout = input<number>(0);\n timePast = signal(0);\n\n constructor() {\n effect(() => this.addAlertClass());\n effect(() => this.addIconClass());\n }\n\n private addAlertClass() {\n const alertContent = this.alertContentRef()?.nativeElement;\n\n if (alertContent) {\n let className = `alert-${this.type()}`;\n\n switch (this.type()) {\n case 'info':\n className = 'alert-info';\n break;\n case 'success':\n className = 'alert-success';\n break;\n case 'warning':\n className = 'alert-warning';\n break;\n case 'error':\n className = 'alert-error';\n break;\n }\n\n alertContent.classList.add(className);\n }\n }\n\n private addIconClass() {\n const alertIcon = this.alertIconRef()?.nativeElement;\n\n if (alertIcon) {\n let className = '';\n\n switch (this.type()) {\n case 'info':\n className = 'fa-circle-info';\n break;\n case 'success':\n className = 'fa-circle-check';\n break;\n case 'warning':\n className = 'fa-triangle-exclamation';\n break;\n case 'error':\n className = 'fa-circle-xmark';\n break;\n }\n\n alertIcon.classList.add(className);\n }\n }\n\n ngOnInit(): void {\n const timeout = this.timeout();\n\n if (timeout > 0) {\n const timePastInterval = interval(1000)\n .pipe(\n startWith(0),\n map(() => this.timePast.update((past) => past + 1000)),\n map(() => this.timePast())\n )\n .subscribe((timePast) => {\n if (timePast > timeout) {\n timePastInterval?.unsubscribe();\n this.dismiss();\n }\n });\n }\n }\n\n dismiss() {\n this.snackbarRef.dismiss();\n }\n}\n","<div role=\"alert\" #alertContent class=\"relative alert alert-outline bg-base-100! w-full lg:max-w-1/4 rounded-sm\">\n <i #alertIcon class=\"h-6 w-6 shrink-0 stroke-current text-2xl fa-solid\"></i>\n <span [innerHTML]=\"message()\"></span>\n <div>\n <button class=\"btn btn-sm btn-outline\" (click)=\"dismiss()\">OK</button>\n </div>\n @if (timePast() > 0) {\n <progress class=\"absolute left-0 bottom-0 progress w-full opacity-20\"\n [value]=\"timePast()\"\n [max]=\"timeout()\">\n </progress>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAca,eAAe,GAAG,IAAI,cAAc,CAAC,gBAAgB;MACrD,gBAAgB,GAAG,IAAI,cAAc,CAAC,gBAAgB;MAWtD,QAAQ,CAAA;AACF,IAAA,MAAM,GAAG,MAAM,C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gBAAgB,GAAG,QAAQ,CAAC,IAAI;AACnC,iBAAA,IAAI,CACH,SAAS,CAAC,CAAC,CAAC,EACZ,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC,EACtD,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;AAE3B,iBAAA,SAAS,CAAC,CAAC,QAAQ,KAAI;AACtB,gBAAA,IAAI,QAAQ,GAAG,OAAO,EAAE;oBACtB,gBAAgB,EAAE,WAAW,EAAE;oBAC/B,IAAI,CAAC,OAAO,EAAE;;AAElB,aAAC,CAAC;;;IAIR,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;;uGAvFjB,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAf,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,eAAe,urBCpB5B,whBAaA,EAAA,CAAA;;2FDOa,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,SAAS;+BACE,qBAAqB,EAAA,QAAA,EAAA,whBAAA,EAAA;;;AEjBjC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"koalarx-ui-shared-components-snackbar.mjs","sources":["../../projects/koala-ui/shared/components/snackbar/snackbar.ts","../../projects/koala-ui/shared/components/snackbar/snackbar-ref.ts","../../projects/koala-ui/shared/components/snackbar/snackbar-content.ts","../../projects/koala-ui/shared/components/snackbar/snackbar-content.html","../../projects/koala-ui/shared/components/snackbar/koalarx-ui-shared-components-snackbar.ts"],"sourcesContent":["import {\n ApplicationRef,\n createComponent,\n EnvironmentInjector,\n inject,\n Injectable,\n InjectionToken,\n Injector,\n inputBinding,\n} from '@angular/core';\nimport { randomString } from '@koalarx/utils/KlString';\nimport { SnackbarContent } from './snackbar-content';\nimport { SNACKBAR_REF_TOKEN, SnackbarRef } from './snackbar-ref';\n\nexport const SNACKBAR_CONFIG = new InjectionToken('SnackbarConfig');\nexport const SNACKBAR_APP_REF = new InjectionToken('SnackbarAppRef');\n\nexport type SnackbarType = 'info' | 'success' | 'warning' | 'error';\n\nexport interface SnackbarConfig {\n type: SnackbarType;\n message: string;\n timeout?: number;\n}\n\n@Injectable({ providedIn: 'root' })\nexport class Snackbar {\n private readonly appRef = inject(ApplicationRef);\n private readonly injector = inject(EnvironmentInjector);\n\n private generateElementId() {\n let elementId: string;\n\n do {\n elementId = randomString(50, {\n numbers: false,\n lowercase: true,\n uppercase: true,\n specialCharacters: false,\n });\n } while (document.getElementById(elementId));\n\n return elementId;\n }\n\n success(message: string, timeout = 5000) {\n this.open({\n type: 'success',\n message,\n timeout,\n });\n }\n\n warning(message: string, timeout = 5000) {\n this.open({\n type: 'warning',\n message,\n timeout,\n });\n }\n\n error(message: string, timeout = 5000) {\n this.open({\n type: 'error',\n message,\n timeout,\n });\n }\n\n info(message: string, timeout = 5000) {\n this.open({\n type: 'info',\n message,\n timeout,\n });\n }\n\n open(config: SnackbarConfig) {\n const main = document.querySelector<HTMLElement>(\n 'kl-snackbar-container div'\n );\n\n if (main) {\n const elementId = this.generateElementId();\n const container = main.appendChild(document.createElement('div'));\n container.id = elementId;\n container.classList.add('flex', 'item-center', 'justify-end');\n\n const componentRef = createComponent(SnackbarContent, {\n environmentInjector: this.injector,\n hostElement: container,\n elementInjector: Injector.create({\n providers: [\n { provide: SNACKBAR_CONFIG, useValue: config },\n { provide: SNACKBAR_APP_REF, useValue: this.appRef },\n {\n provide: SNACKBAR_REF_TOKEN,\n useValue: () => componentRef,\n },\n {\n provide: SnackbarRef,\n deps: [SNACKBAR_CONFIG, SNACKBAR_APP_REF, SNACKBAR_REF_TOKEN],\n },\n ],\n }),\n bindings: [\n inputBinding('type', () => config.type),\n inputBinding('message', () => config.message),\n inputBinding('timeout', () => config.timeout ?? 0),\n ],\n });\n\n this.appRef.attachView(componentRef.hostView);\n\n componentRef.changeDetectorRef.detectChanges();\n }\n }\n}\n","import {\n ApplicationRef,\n ComponentRef,\n inject,\n Injectable,\n InjectionToken,\n} from '@angular/core';\nimport { SNACKBAR_APP_REF } from './snackbar';\nimport { SnackbarContent } from './snackbar-content';\n\nexport const SNACKBAR_REF_TOKEN = new InjectionToken('SnackbarRefToken');\n\n@Injectable()\nexport class SnackbarRef {\n private readonly appRef = inject<ApplicationRef>(SNACKBAR_APP_REF);\n private readonly componentRef =\n inject<() => ComponentRef<SnackbarContent>>(SNACKBAR_REF_TOKEN);\n\n dismiss() {\n this.componentRef().destroy();\n this.appRef.detachView(this.componentRef().hostView);\n }\n}\n","import {\n Component,\n effect,\n ElementRef,\n inject,\n input,\n OnInit,\n signal,\n viewChild,\n} from '@angular/core';\nimport { SnackbarType } from './snackbar';\nimport { SnackbarRef } from './snackbar-ref';\nimport { interval } from 'rxjs/internal/observable/interval';\nimport { startWith } from 'rxjs/internal/operators/startWith';\nimport { map } from 'rxjs/internal/operators/map';\n\n@Component({\n selector: 'kl-snackbar-content',\n templateUrl: './snackbar-content.html',\n})\nexport class SnackbarContent implements OnInit {\n private readonly alertContentRef =\n viewChild<ElementRef<HTMLDivElement>>('alertContent');\n private readonly alertIconRef =\n viewChild<ElementRef<HTMLElement>>('alertIcon');\n private readonly snackbarRef = inject(SnackbarRef);\n\n type = input.required<SnackbarType>();\n message = input.required<string>();\n timeout = input<number>(0);\n timePast = signal(0);\n\n constructor() {\n effect(() => this.addAlertClass());\n effect(() => this.addIconClass());\n }\n\n private addAlertClass() {\n const alertContent = this.alertContentRef()?.nativeElement;\n\n if (alertContent) {\n let className = `alert-${this.type()}`;\n\n switch (this.type()) {\n case 'info':\n className = 'alert-info';\n break;\n case 'success':\n className = 'alert-success';\n break;\n case 'warning':\n className = 'alert-warning';\n break;\n case 'error':\n className = 'alert-error';\n break;\n }\n\n alertContent.classList.add(className);\n }\n }\n\n private addIconClass() {\n const alertIcon = this.alertIconRef()?.nativeElement;\n\n if (alertIcon) {\n let className = '';\n\n switch (this.type()) {\n case 'info':\n className = 'fa-circle-info';\n break;\n case 'success':\n className = 'fa-circle-check';\n break;\n case 'warning':\n className = 'fa-triangle-exclamation';\n break;\n case 'error':\n className = 'fa-circle-xmark';\n break;\n }\n\n alertIcon.classList.add(className);\n }\n }\n\n ngOnInit(): void {\n const timeout = this.timeout();\n\n if (timeout > 0) {\n const timePastInterval = interval(1000)\n .pipe(\n startWith(0),\n map(() => this.timePast.update((past) => past + 1000)),\n map(() => this.timePast())\n )\n .subscribe((timePast) => {\n if (timePast > timeout) {\n timePastInterval?.unsubscribe();\n this.dismiss();\n }\n });\n }\n }\n\n dismiss() {\n this.snackbarRef.dismiss();\n }\n}\n","<div role=\"alert\" #alertContent class=\"relative alert alert-outline bg-base-100! w-full lg:max-w-1/4 rounded-sm text-sm py-3 border-neutral-600\">\n <i #alertIcon class=\"h-4 w-4 shrink-0 stroke-current text-base fa-solid\"></i>\n <span [innerHTML]=\"message()\"></span>\n <div>\n <button class=\"btn btn-xs btn-outline\" (click)=\"dismiss()\">OK</button>\n </div>\n @if (timePast() > 0) {\n <progress class=\"absolute left-0 bottom-0 progress w-full opacity-20\"\n [value]=\"timePast()\"\n [max]=\"timeout()\">\n </progress>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAca,eAAe,GAAG,IAAI,cAAc,CAAC,gBAAgB;MACrD,gBAAgB,GAAG,IAAI,cAAc,CAAC,gBAAgB;MAWtD,QAAQ,CAAA;AACF,IAAA,MAAM,GAAG,MAAM,CAAC,cAAc,CAAC;AAC/B,IAAA,QAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC;IAE/C,iBAAiB,GAAA;AACvB,QAAA,IAAI,SAAiB;AAErB,QAAA,GAAG;AACD,YAAA,SAAS,GA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,KAAK,IAAI,GAAG,IAAI,CAAC,CAAC,EACtD,GAAG,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;AAE3B,iBAAA,SAAS,CAAC,CAAC,QAAQ,KAAI;AACtB,gBAAA,IAAI,QAAQ,GAAG,OAAO,EAAE;oBACtB,gBAAgB,EAAE,WAAW,EAAE;oBAC/B,IAAI,CAAC,OAAO,EAAE;;AAElB,aAAC,CAAC;;;IAIR,OAAO,GAAA;AACL,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;;uGAvFjB,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAf,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,eAAe,urBCpB5B,yjBAaA,EAAA,CAAA;;2FDOa,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,SAAS;+BACE,qBAAqB,EAAA,QAAA,EAAA,yjBAAA,EAAA;;;AEjBjC;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"koalarx-ui.mjs","sources":["../../projects/koala-ui/core/interceptors/authorization-interceptor.ts","../../projects/koala-ui/core/interceptors/feedback-request-interceptor.ts","../../projects/koala-ui/core/koala-provider.ts","../../projects/koala-ui/koalarx-ui.ts"],"sourcesContent":["import {\n HttpInterceptor as AngularHttpInterceptor,\n HttpEvent,\n HttpHandler,\n HttpRequest,\n} from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { AppConfig } from '@koalarx/ui/core/config';\nimport { Authorization } from '@koalarx/ui/shared/services';\nimport { Observable } from 'rxjs/internal/Observable';\nimport { switchMap } from 'rxjs/internal/operators/switchMap';\n\n@Injectable()\nexport class AuthorizationInterceptor implements AngularHttpInterceptor {\n private readonly authorization = inject(Authorization);\n private readonly authConfig = inject(AppConfig).authConfig;\n\n private setAuthorization(request: HttpRequest<any>) {\n if (this.authorization.hasToken()) {\n return request.clone({\n headers: request.headers.set(\n 'Authorization',\n `Bearer ${\n request.url === this.authConfig?.refreshToken?.url\n ? this.authorization.refreshToken\n : this.authorization.accessToken\n }`\n ),\n });\n }\n\n return request.clone();\n }\n\n intercept(\n request: HttpRequest<any>,\n next: HttpHandler\n ): Observable<HttpEvent<any>> {\n const clonedReq = this.setAuthorization(request);\n\n if (\n this.authorization.hasToken() &&\n this.authorization.isExpired() &&\n !this.authConfig?.refreshToken?.url\n ) {\n return this.authorization\n .updateToken()\n .pipe(switchMap(() => next.handle(this.setAuthorization(request))));\n }\n\n return next.handle(clonedReq);\n }\n}\n","import {\n HttpInterceptor as AngularHttpInterceptor,\n HttpEvent,\n HttpHandler,\n HttpRequest,\n} from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { HttpErrorFeedbackAlert } from '@koalarx/ui/shared/utils';\nimport { Observable } from 'rxjs/internal/Observable';\nimport { tap } from 'rxjs/internal/operators/tap';\n\n@Injectable()\nexport class FeedbackRequestInterceptor implements AngularHttpInterceptor {\n private readonly httpError = inject(HttpErrorFeedbackAlert);\n\n intercept(\n request: HttpRequest<any>,\n next: HttpHandler\n ): Observable<HttpEvent<any>> {\n return next.handle(request.clone()).pipe(\n tap({\n error: (error) => this.httpError.tapError(error),\n })\n );\n }\n}\n","import {\n HTTP_INTERCEPTORS,\n HttpClient,\n HttpInterceptor,\n provideHttpClient,\n withInterceptorsFromDi,\n} from '@angular/common/http';\nimport { Provider } from '@angular/core';\nimport { AppConfig } from '@koalarx/ui/core/config';\nimport { HttpClientErrorsMiddleware } from '@koalarx/ui/core/middlewares';\nimport { AuthConfig } from '@koalarx/ui/core/models';\nimport {\n getTranslationByLanguage,\n KoalaLanguage,\n} from '@koalarx/ui/core/translations';\nimport { MARKED_OPTIONS, provideMarkdown } from 'ngx-markdown';\nimport { NgxMaskConfig, provideEnvironmentNgxMask } from 'ngx-mask';\nimport { AuthorizationInterceptor } from './interceptors/authorization-interceptor';\nimport { FeedbackRequestInterceptor } from './interceptors/feedback-request-interceptor';\n\nconst maskOptions: Partial<NgxMaskConfig> = {\n validation: false,\n thousandSeparator: '.',\n};\n\ninterface KoalaSettings {\n hostApi?: string;\n language?: KoalaLanguage;\n httpClientErrorsMiddleware?: HttpClientErrorsMiddleware;\n authConfig
|
|
1
|
+
{"version":3,"file":"koalarx-ui.mjs","sources":["../../projects/koala-ui/core/interceptors/authorization-interceptor.ts","../../projects/koala-ui/core/interceptors/feedback-request-interceptor.ts","../../projects/koala-ui/core/koala-provider.ts","../../projects/koala-ui/koalarx-ui.ts"],"sourcesContent":["import {\n HttpInterceptor as AngularHttpInterceptor,\n HttpEvent,\n HttpHandler,\n HttpRequest,\n} from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { AppConfig } from '@koalarx/ui/core/config';\nimport { Authorization } from '@koalarx/ui/shared/services';\nimport { Observable } from 'rxjs/internal/Observable';\nimport { switchMap } from 'rxjs/internal/operators/switchMap';\n\n@Injectable()\nexport class AuthorizationInterceptor implements AngularHttpInterceptor {\n private readonly authorization = inject(Authorization);\n private readonly authConfig = inject(AppConfig).authConfig;\n\n private setAuthorization(request: HttpRequest<any>) {\n if (this.authorization.hasToken()) {\n return request.clone({\n headers: request.headers.set(\n 'Authorization',\n `Bearer ${\n request.url === this.authConfig?.refreshToken?.url\n ? this.authorization.refreshToken\n : this.authorization.accessToken\n }`\n ),\n });\n }\n\n return request.clone();\n }\n\n intercept(\n request: HttpRequest<any>,\n next: HttpHandler\n ): Observable<HttpEvent<any>> {\n const clonedReq = this.setAuthorization(request);\n\n if (\n this.authorization.hasToken() &&\n this.authorization.isExpired() &&\n !this.authConfig?.refreshToken?.url\n ) {\n return this.authorization\n .updateToken()\n .pipe(switchMap(() => next.handle(this.setAuthorization(request))));\n }\n\n return next.handle(clonedReq);\n }\n}\n","import {\n HttpInterceptor as AngularHttpInterceptor,\n HttpEvent,\n HttpHandler,\n HttpRequest,\n} from '@angular/common/http';\nimport { inject, Injectable } from '@angular/core';\nimport { HttpErrorFeedbackAlert } from '@koalarx/ui/shared/utils';\nimport { Observable } from 'rxjs/internal/Observable';\nimport { tap } from 'rxjs/internal/operators/tap';\n\n@Injectable()\nexport class FeedbackRequestInterceptor implements AngularHttpInterceptor {\n private readonly httpError = inject(HttpErrorFeedbackAlert);\n\n intercept(\n request: HttpRequest<any>,\n next: HttpHandler\n ): Observable<HttpEvent<any>> {\n return next.handle(request.clone()).pipe(\n tap({\n error: (error) => this.httpError.tapError(error),\n })\n );\n }\n}\n","import {\n HTTP_INTERCEPTORS,\n HttpClient,\n HttpInterceptor,\n provideHttpClient,\n withInterceptorsFromDi,\n} from '@angular/common/http';\nimport { Provider } from '@angular/core';\nimport { AppConfig } from '@koalarx/ui/core/config';\nimport { HttpClientErrorsMiddleware } from '@koalarx/ui/core/middlewares';\nimport { AuthConfig } from '@koalarx/ui/core/models';\nimport {\n getTranslationByLanguage,\n KoalaLanguage,\n} from '@koalarx/ui/core/translations';\nimport { MARKED_OPTIONS, provideMarkdown } from 'ngx-markdown';\nimport { NgxMaskConfig, provideEnvironmentNgxMask } from 'ngx-mask';\nimport { AuthorizationInterceptor } from './interceptors/authorization-interceptor';\nimport { FeedbackRequestInterceptor } from './interceptors/feedback-request-interceptor';\n\nconst maskOptions: Partial<NgxMaskConfig> = {\n validation: false,\n thousandSeparator: '.',\n};\n\ninterface KoalaSettings {\n hostApi?: string;\n language?: KoalaLanguage;\n httpClientErrorsMiddleware?: HttpClientErrorsMiddleware;\n authConfig?: AuthConfig;\n authorizationInterceptor?: HttpInterceptor;\n}\n\nexport function provideKoala(config?: KoalaSettings): Provider {\n const appConfig = new AppConfig();\n\n appConfig.language = config?.language ?? 'en';\n appConfig.translation = getTranslationByLanguage(config?.language ?? 'en');\n appConfig.hostApi = config?.hostApi;\n appConfig.httpClientErrorsMiddleware = config?.httpClientErrorsMiddleware;\n appConfig.authConfig = config?.authConfig;\n\n const providers: Provider = [\n provideEnvironmentNgxMask(maskOptions),\n provideHttpClient(withInterceptorsFromDi()),\n provideMarkdown({\n loader: HttpClient,\n markedOptions: {\n provide: MARKED_OPTIONS,\n useValue: {\n gfm: true,\n breaks: true,\n pedantic: false,\n },\n },\n }),\n {\n provide: HTTP_INTERCEPTORS,\n useClass: FeedbackRequestInterceptor,\n multi: true,\n },\n {\n provide: AppConfig,\n useValue: appConfig,\n },\n ];\n\n if (config?.authConfig) {\n providers.push({\n provide: HTTP_INTERCEPTORS,\n useClass: config?.authorizationInterceptor ?? AuthorizationInterceptor,\n multi: true,\n });\n }\n\n return providers;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;MAaa,wBAAwB,CAAA;AAClB,IAAA,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC;AACrC,IAAA,UAAU,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,UAAU;AAElD,IAAA,gBAAgB,CAAC,OAAyB,EAAA;AAChD,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE;YACjC,OAAO,OAAO,CAAC,KAAK,CAAC;gBACnB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,CAC1B,eAAe,EACf,CAAA,OAAA,EACE,OAAO,CAAC,GAAG,KAAK,IAAI,CAAC,UAAU,EAAE,YAAY,EAAE;AAC7C,sBAAE,IAAI,CAAC,aAAa,CAAC;AACrB,sBAAE,IAAI,CAAC,aAAa,CAAC,WACzB,EAAE,CACH;AACF,aAAA,CAAC;;AAGJ,QAAA,OAAO,OAAO,CAAC,KAAK,EAAE;;IAGxB,SAAS,CACP,OAAyB,EACzB,IAAiB,EAAA;QAEjB,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;AAEhD,QAAA,IACE,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE;AAC7B,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age;
|
|
10
10
|
httpClientErrorsMiddleware?: HttpClientErrorsMiddleware;
|
|
11
|
-
authConfig
|
|
11
|
+
authConfig?: AuthConfig;
|
|
12
12
|
authorizationInterceptor?: HttpInterceptor;
|
|
13
13
|
}
|
|
14
14
|
declare function provideKoala(config?: KoalaSettings): Provider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koalarx/ui",
|
|
3
|
-
"version": "20.1.
|
|
3
|
+
"version": "20.1.7",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@angular/common": ">=20.0.0",
|
|
6
6
|
"@angular/core": ">=20.0.0"
|
|
@@ -210,14 +210,14 @@
|
|
|
210
210
|
"types": "./shared/components/input-field/input-cpf/index.d.ts",
|
|
211
211
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-cpf.mjs"
|
|
212
212
|
},
|
|
213
|
-
"./shared/components/input-field/input-currency": {
|
|
214
|
-
"types": "./shared/components/input-field/input-currency/index.d.ts",
|
|
215
|
-
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-currency.mjs"
|
|
216
|
-
},
|
|
217
213
|
"./shared/components/input-field/input-date": {
|
|
218
214
|
"types": "./shared/components/input-field/input-date/index.d.ts",
|
|
219
215
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-date.mjs"
|
|
220
216
|
},
|
|
217
|
+
"./shared/components/input-field/input-currency": {
|
|
218
|
+
"types": "./shared/components/input-field/input-currency/index.d.ts",
|
|
219
|
+
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-currency.mjs"
|
|
220
|
+
},
|
|
221
221
|
"./shared/components/input-field/input-datetime": {
|
|
222
222
|
"types": "./shared/components/input-field/input-datetime/index.d.ts",
|
|
223
223
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-datetime.mjs"
|
|
@@ -226,14 +226,14 @@
|
|
|
226
226
|
"types": "./shared/components/input-field/input-email/index.d.ts",
|
|
227
227
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-email.mjs"
|
|
228
228
|
},
|
|
229
|
-
"./shared/components/input-field/input-month": {
|
|
230
|
-
"types": "./shared/components/input-field/input-month/index.d.ts",
|
|
231
|
-
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-month.mjs"
|
|
232
|
-
},
|
|
233
229
|
"./shared/components/input-field/input-password": {
|
|
234
230
|
"types": "./shared/components/input-field/input-password/index.d.ts",
|
|
235
231
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-password.mjs"
|
|
236
232
|
},
|
|
233
|
+
"./shared/components/input-field/input-month": {
|
|
234
|
+
"types": "./shared/components/input-field/input-month/index.d.ts",
|
|
235
|
+
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-month.mjs"
|
|
236
|
+
},
|
|
237
237
|
"./shared/components/input-field/input-radio": {
|
|
238
238
|
"types": "./shared/components/input-field/input-radio/index.d.ts",
|
|
239
239
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-radio.mjs"
|
|
@@ -242,14 +242,14 @@
|
|
|
242
242
|
"types": "./shared/components/input-field/input-text/index.d.ts",
|
|
243
243
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-text.mjs"
|
|
244
244
|
},
|
|
245
|
-
"./shared/components/input-field/input-time": {
|
|
246
|
-
"types": "./shared/components/input-field/input-time/index.d.ts",
|
|
247
|
-
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-time.mjs"
|
|
248
|
-
},
|
|
249
245
|
"./shared/components/input-field/input-url": {
|
|
250
246
|
"types": "./shared/components/input-field/input-url/index.d.ts",
|
|
251
247
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-url.mjs"
|
|
252
248
|
},
|
|
249
|
+
"./shared/components/input-field/input-time": {
|
|
250
|
+
"types": "./shared/components/input-field/input-time/index.d.ts",
|
|
251
|
+
"default": "./fesm2022/koalarx-ui-shared-components-input-field-input-time.mjs"
|
|
252
|
+
},
|
|
253
253
|
"./shared/components/input-field/select": {
|
|
254
254
|
"types": "./shared/components/input-field/select/index.d.ts",
|
|
255
255
|
"default": "./fesm2022/koalarx-ui-shared-components-input-field-select.mjs"
|