@yuuvis/client-core 2.17.0 → 2.19.0

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.
@@ -3,18 +3,20 @@ import { TranslateService, TranslateLoader, MissingTranslationHandler, Translate
3
3
  export { TranslateDirective, TranslateLoader, TranslateModule, TranslatePipe, TranslateService } from '@ngx-translate/core';
4
4
  import { HttpErrorResponse, HttpClient, HttpHeaders, HttpRequest, HttpParams, HttpResponse, HttpEventType, provideHttpClient, withInterceptors } from '@angular/common/http';
5
5
  import * as i0 from '@angular/core';
6
- import { inject, Injectable, InjectionToken, NgZone, Inject, signal, Directive, Pipe, makeEnvironmentProviders, importProvidersFrom, provideAppInitializer } from '@angular/core';
6
+ import { inject, Injectable, InjectionToken, NgZone, Inject, signal, Directive, Pipe, provideEnvironmentInitializer, makeEnvironmentProviders, importProvidersFrom, provideAppInitializer } from '@angular/core';
7
7
  import { tap, finalize, shareReplay, catchError, map, switchMap, first, filter, scan, delay } from 'rxjs/operators';
8
8
  import { EMPTY, Subject, of, forkJoin, Observable, ReplaySubject, BehaviorSubject, tap as tap$1, map as map$1, merge, fromEvent, filter as filter$1, debounceTime, throwError, catchError as catchError$1, switchMap as switchMap$1, isObservable } from 'rxjs';
9
9
  import { StorageMap } from '@ngx-pwa/local-storage';
10
+ import { DOCUMENT, DecimalPipe, PercentPipe, CurrencyPipe, registerLocaleData } from '@angular/common';
10
11
  import { __decorate, __param, __metadata } from 'tslib';
11
12
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
12
13
  import { toSignal, takeUntilDestroyed } from '@angular/core/rxjs-interop';
13
14
  import { DeviceDetectorService } from 'ngx-device-detector';
14
- import { DOCUMENT, DecimalPipe, PercentPipe, CurrencyPipe, registerLocaleData } from '@angular/common';
15
15
  import { FormGroup, FormControl } from '@angular/forms';
16
16
  import { MatTabGroup } from '@angular/material/tabs';
17
17
  import * as i1$1 from '@angular/platform-browser';
18
+ import { MatDialog } from '@angular/material/dialog';
19
+ import { Router, NavigationEnd } from '@angular/router';
18
20
  import localeAr from '@angular/common/locales/ar';
19
21
  import localeBn from '@angular/common/locales/bn';
20
22
  import localeDe from '@angular/common/locales/de';
@@ -2436,6 +2438,7 @@ class UserService {
2436
2438
  #SETTINGS_SECTION_OBJECTCONFIG;
2437
2439
  #user;
2438
2440
  #userSource;
2441
+ #document;
2439
2442
  /**
2440
2443
  * @ignore
2441
2444
  */
@@ -2452,6 +2455,7 @@ class UserService {
2452
2455
  this.#userSource = new BehaviorSubject(this.#user);
2453
2456
  this.user$ = this.#userSource.asObservable();
2454
2457
  this.globalSettings = new Map();
2458
+ this.#document = inject(DOCUMENT);
2455
2459
  this.canCreateObjects = false;
2456
2460
  }
2457
2461
  getUiDirection(iso) {
@@ -2509,6 +2513,8 @@ class UserService {
2509
2513
  this.logger.debug("Changed client locale to '" + iso + "'");
2510
2514
  this.backend.setHeader('Accept-Language', iso);
2511
2515
  this.#user.uiDirection = this.getUiDirection(iso);
2516
+ this.#document.body.dir = this.#user.uiDirection;
2517
+ this.#document.documentElement.lang = iso;
2512
2518
  this.#user.userSettings.locale = iso;
2513
2519
  if (this.translate.currentLang !== iso || this.system.authData?.language !== iso) {
2514
2520
  const ob = persist
@@ -5875,6 +5881,90 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
5875
5881
  }]
5876
5882
  }] });
5877
5883
 
5884
+ const AVAILABLE_BACKEND_APPS = new InjectionToken('Available Backend application', {
5885
+ factory: () => undefined
5886
+ });
5887
+ const provideAvailabilityManagement = (user) => {
5888
+ return { provide: AVAILABLE_BACKEND_APPS, useValue: user };
5889
+ };
5890
+ const CLIENT_APP_REQUIREMENTS = new InjectionToken('Application / Extension requirements for client shell', {
5891
+ factory: () => null
5892
+ });
5893
+ const provideRequirements = (requirements) => {
5894
+ return { provide: CLIENT_APP_REQUIREMENTS, useValue: requirements || {} };
5895
+ };
5896
+
5897
+ /**
5898
+ * Registers a global `beforeunload` event listener that prevents the browser
5899
+ * from navigating away (tab close / reload) whenever there are pending tasks
5900
+ * tracked by {@link PendingChangesService}.
5901
+ *
5902
+ * Usage in `app.config.ts`:
5903
+ * ```ts
5904
+ * provideBeforeUnloadProtection()
5905
+ * ```
5906
+ */
5907
+ function provideBeforeUnloadProtection() {
5908
+ return provideEnvironmentInitializer(() => {
5909
+ const pendingChanges = inject(PendingChangesService);
5910
+ window.addEventListener('beforeunload', (event) => pendingChanges.hasPendingTask() && event.preventDefault());
5911
+ });
5912
+ }
5913
+
5914
+ /**
5915
+ * Provides environment-level protection against the browser back/forward buttons
5916
+ * while a Material dialog is open.
5917
+ *
5918
+ * Behavior:
5919
+ * 1. Listens for the browser `popstate` event (triggered by back/forward navigation).
5920
+ * 2. If at least one `MatDialog` is open, the URL is immediately restored via
5921
+ * `history.pushState` so the Angular router does not pick up the navigation.
5922
+ * 3. If `PendingChangesService` reports a pending task the user is prompted for
5923
+ * confirmation — the topmost dialog is closed only when the user agrees to discard.
5924
+ * 4. If there are no pending changes the topmost dialog is closed directly.
5925
+ */
5926
+ function providePopstateDialogProtection() {
5927
+ return provideEnvironmentInitializer(() => {
5928
+ const pendingChanges = inject(PendingChangesService);
5929
+ const dialog = inject(MatDialog);
5930
+ const router = inject(Router);
5931
+ // Track the current URL so we can restore it when intercepting popstate.
5932
+ // location.path() cannot be used because by the time popstate fires the
5933
+ // browser has already updated window.location to the *new* (back) URL.
5934
+ let currentUrl = router.url;
5935
+ router.events
5936
+ .pipe(filter$1((navEvent) => navEvent instanceof NavigationEnd))
5937
+ .subscribe((navigationEvent) => {
5938
+ currentUrl = navigationEvent.urlAfterRedirects;
5939
+ });
5940
+ window.addEventListener('popstate', (event) => {
5941
+ if (!dialog.openDialogs.length)
5942
+ return;
5943
+ // Stop Angular's Location service from forwarding this event to the router
5944
+ event.stopImmediatePropagation();
5945
+ // Restore the pre-back URL so window.location matches the Angular router state.
5946
+ // Using replaceState (not pushState) to avoid Chrome's back-button hijack detection
5947
+ // which suppresses subsequent popstate events until the user interacts with the page.
5948
+ history.replaceState(null, '', currentUrl);
5949
+ const topDialog = dialog.openDialogs[dialog.openDialogs.length - 1];
5950
+ if (pendingChanges.hasPendingTask()) {
5951
+ // check() shows window.confirm() — returns true if user CANCELLED
5952
+ const cancelled = pendingChanges.check();
5953
+ if (!cancelled) {
5954
+ topDialog.close();
5955
+ }
5956
+ }
5957
+ else {
5958
+ topDialog.close();
5959
+ }
5960
+ });
5961
+ });
5962
+ }
5963
+
5964
+ function provideNavigationProtection() {
5965
+ return [provideBeforeUnloadProtection(), providePopstateDialogProtection()];
5966
+ }
5967
+
5878
5968
  /**
5879
5969
  * Prevent app from running into 401 issues related to gateway timeouts.
5880
5970
  */
@@ -5974,10 +6064,12 @@ EoxTranslateJsonLoader = __decorate([
5974
6064
  CoreConfig])
5975
6065
  ], EoxTranslateJsonLoader);
5976
6066
 
5977
- const provideYuvClientCore = (options = { translations: [] }, customEvents, customEventsTrustedOrigin) => {
6067
+ const provideYuvClientCore = (options = { translations: [] }, customEvents, customEventsTrustedOrigin, disableBeforeUnloadProtection = false, disablePopstateDialogProtection = false) => {
5978
6068
  return makeEnvironmentProviders([
5979
6069
  importProvidersFrom(TranslateModule.forRoot()),
5980
6070
  provideHttpClient(withInterceptors([AuthInterceptorFnc, OfflineInterceptorFnc])),
6071
+ ...(disableBeforeUnloadProtection ? [] : [provideBeforeUnloadProtection()]),
6072
+ ...(disablePopstateDialogProtection ? [] : [providePopstateDialogProtection()]),
5981
6073
  { provide: CORE_CONFIG, useClass: CoreConfig, deps: [CUSTOM_CONFIG] },
5982
6074
  provideAppInitializer(init_moduleFnc),
5983
6075
  /**
@@ -6003,22 +6095,9 @@ const provideYuvClientCore = (options = { translations: [] }, customEvents, cust
6003
6095
  ]);
6004
6096
  };
6005
6097
 
6006
- const AVAILABLE_BACKEND_APPS = new InjectionToken('Available Backend application', {
6007
- factory: () => undefined
6008
- });
6009
- const provideAvailabilityManagement = (user) => {
6010
- return { provide: AVAILABLE_BACKEND_APPS, useValue: user };
6011
- };
6012
- const CLIENT_APP_REQUIREMENTS = new InjectionToken('Application / Extension requirements for client shell', {
6013
- factory: () => null
6014
- });
6015
- const provideRequirements = (requirements) => {
6016
- return { provide: CLIENT_APP_REQUIREMENTS, useValue: requirements || {} };
6017
- };
6018
-
6019
6098
  /**
6020
6099
  * Generated bundle index. Do not edit.
6021
6100
  */
6022
6101
 
6023
- export { AFO_STATE, AVAILABLE_BACKEND_APPS, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CLIENT_APP_REQUIREMENTS, CORE_CONFIG, CUSTOM_CONFIG, CUSTOM_YUV_EVENT_PREFIX, CatalogService, Classification, ClassificationPrefix, ClientCacheService, ClientDefaultsObjectTypeField, ClipboardService, ColumnConfigSkipFields, ConfigService, ConnectionService, ContentStreamAllowed, ContentStreamField, CoreConfig, DeviceScreenOrientation, DeviceService, DialogCloseGuard, Direction, DmsObject, DmsService, EventService, FileSizePipe, IdmService, InternalFieldType, KeysPipe, LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocaleNumberPipe, LocalePercentPipe, Logger, LoginStateName, NativeNotificationService, NotificationService, ObjectConfigService, ObjectFormControl, ObjectFormControlWrapper, ObjectFormGroup, ObjectTag, ObjectTypeClassification, ObjectTypePropertyClassification, Operator, OperatorLabel, ParentField, PendingChangesGuard, PendingChangesService, PredictionService, ProcessAction, RelationshipTypeField, RetentionField, RetentionService, SafeHtmlPipe, SafeUrlPipe, SearchService, SearchUtils, SecondaryObjectTypeClassification, SessionStorageService, Situation, Sort, SystemResult, SystemSOT, SystemService, SystemType, TENANT_HEADER, TabGuardDirective, ToastService, UploadService, UserRoles, UserService, UserStorageService, Utils, YUV_USER, YuvError, YuvEventType, YuvUser, init_moduleFnc, provideAvailabilityManagement, provideRequirements, provideUser, provideYuvClientCore };
6102
+ export { AFO_STATE, AVAILABLE_BACKEND_APPS, AdministrationRoles, ApiBase, AppCacheService, AuditField, AuditService, AuthService, BackendService, BaseObjectTypeField, BpmService, CLIENT_APP_REQUIREMENTS, CORE_CONFIG, CUSTOM_CONFIG, CUSTOM_YUV_EVENT_PREFIX, CatalogService, Classification, ClassificationPrefix, ClientCacheService, ClientDefaultsObjectTypeField, ClipboardService, ColumnConfigSkipFields, ConfigService, ConnectionService, ContentStreamAllowed, ContentStreamField, CoreConfig, DeviceScreenOrientation, DeviceService, DialogCloseGuard, Direction, DmsObject, DmsService, EventService, FileSizePipe, IdmService, InternalFieldType, KeysPipe, LocaleCurrencyPipe, LocaleDatePipe, LocaleDecimalPipe, LocaleNumberPipe, LocalePercentPipe, Logger, LoginStateName, NativeNotificationService, NotificationService, ObjectConfigService, ObjectFormControl, ObjectFormControlWrapper, ObjectFormGroup, ObjectTag, ObjectTypeClassification, ObjectTypePropertyClassification, Operator, OperatorLabel, ParentField, PendingChangesGuard, PendingChangesService, PredictionService, ProcessAction, RelationshipTypeField, RetentionField, RetentionService, SafeHtmlPipe, SafeUrlPipe, SearchService, SearchUtils, SecondaryObjectTypeClassification, SessionStorageService, Situation, Sort, SystemResult, SystemSOT, SystemService, SystemType, TENANT_HEADER, TabGuardDirective, ToastService, UploadService, UserRoles, UserService, UserStorageService, Utils, YUV_USER, YuvError, YuvEventType, YuvUser, init_moduleFnc, provideAvailabilityManagement, provideBeforeUnloadProtection, provideNavigationProtection, providePopstateDialogProtection, provideRequirements, provideUser, provideYuvClientCore };
6024
6103
  //# sourceMappingURL=yuuvis-client-core.mjs.map