@onecx/angular-accelerator 8.2.2 → 8.3.1

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.
@@ -2,4 +2,6 @@
2
2
 
3
3
  @import '/node_modules/primeflex/primeflex.scss';
4
4
 
5
- @import '../src/lib/directives/loading-indicator.directive.scss';
5
+ @import '../src/lib/directives/loading-indicator.directive.scss';
6
+
7
+ @import '../src/lib/directives/content.directive.scss';
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ElementRef, input, effect, Directive, signal, Renderer2, ViewContainerRef, TemplateRef, DestroyRef, computed, HostListener, EventEmitter, Output, OutputEmitterRef, assertInInjectionContext, NgZone, Injectable, Injector, LOCALE_ID, Pipe, model, output, contentChild, ViewChild, ViewEncapsulation, Component, contentChildren, viewChild, Input, ChangeDetectorRef, viewChildren, untracked, ChangeDetectionStrategy, Type, NgModule, APP_INITIALIZER } from '@angular/core';
2
+ import { inject, ElementRef, input, effect, Directive, signal, Renderer2, ViewContainerRef, TemplateRef, DestroyRef, computed, HostListener, EventEmitter, Output, OutputEmitterRef, assertInInjectionContext, NgZone, Injectable, Injector, LOCALE_ID, Pipe, model, output, contentChild, ViewChild, ViewEncapsulation, Component, contentChildren, viewChild, untracked, Input, ChangeDetectorRef, viewChildren, ChangeDetectionStrategy, Type, NgModule, APP_INITIALIZER } from '@angular/core';
3
3
  import { toObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
4
4
  import { UserService, AppStateService, ConfigurationService, CONFIG_KEY, ShellCapabilityService, Capability, AppConfigService } from '@onecx/angular-integration-interface';
5
- import { HAS_PERMISSION_CHECKER, SKIP_STYLE_SCOPING, getScopeIdentifier, dataStyleIdKey, dataNoPortalLayoutStylesKey, MultiLanguageMissingTranslationHandler, providePermissionChecker, provideTranslationPathFromMeta, provideMultiLanguageIdentifier, provideTranslationConnectionService } from '@onecx/angular-utils';
5
+ import { HAS_PERMISSION_CHECKER, SKIP_STYLE_SCOPING, getScopeIdentifier, dataStyleIdKey, dataNoPortalLayoutStylesKey, MultiLanguageMissingTranslationHandler, localeLoaders, DynamicLocaleId, providePermissionChecker, provideTranslationPathFromMeta, provideMultiLanguageIdentifier, provideTranslationConnectionService } from '@onecx/angular-utils';
6
6
  import { switchMap, of, from, take, map, BehaviorSubject, filter, concat, tap, combineLatest, mergeMap, startWith, debounceTime, firstValueFrom, ReplaySubject, timestamp, isObservable, withLatestFrom, Subject, skip } from 'rxjs';
7
7
  import { createLoggerFactory, Topic, getLocation, isValidDate, getUTCDateWithoutTimezoneIssues } from '@onecx/accelerator';
8
8
  import { HttpClient } from '@angular/common/http';
@@ -12,7 +12,7 @@ import { LiveAnnouncer } from '@angular/cdk/a11y';
12
12
  import * as i8 from '@ngx-translate/core';
13
13
  import { TranslateService, TranslatePipe, TranslateModule } from '@ngx-translate/core';
14
14
  import * as i1 from '@angular/common';
15
- import { DatePipe, DecimalPipe, CurrencyPipe, formatDate, CommonModule } from '@angular/common';
15
+ import { DatePipe, DecimalPipe, CurrencyPipe, formatDate, registerLocaleData, CommonModule } from '@angular/common';
16
16
  import * as i2$1 from 'primeng/button';
17
17
  import { ButtonModule } from 'primeng/button';
18
18
  import * as i5 from 'primeng/skeleton';
@@ -174,7 +174,7 @@ class OcxContentDirective {
174
174
  }
175
175
  addContentStyles() {
176
176
  const addClasses = (classes) => this.el.nativeElement.classList.add(...classes);
177
- addClasses(['card']);
177
+ addClasses(['ocx-card']);
178
178
  }
179
179
  prependTitle() {
180
180
  const titleElementId = this.titleElementId();
@@ -1038,11 +1038,11 @@ class SearchHeaderComponent {
1038
1038
  this.visibleFormControls = contentChildren(FormControlName, { ...(ngDevMode ? { debugName: "visibleFormControls" } : {}), descendants: true });
1039
1039
  this.searchParameterFields = viewChild('searchParameterFields', ...(ngDevMode ? [{ debugName: "searchParameterFields" }] : []));
1040
1040
  this.hasAdvanced = signal(false, ...(ngDevMode ? [{ debugName: "hasAdvanced" }] : []));
1041
- this.simpleAdvancedAction = signal({
1041
+ this.simpleAdvancedAction = {
1042
1042
  id: 'simpleAdvancedButton',
1043
1043
  actionCallback: () => this.toggleViewMode(),
1044
1044
  show: 'always',
1045
- }, ...(ngDevMode ? [{ debugName: "simpleAdvancedAction" }] : []));
1045
+ };
1046
1046
  this.headerActions = signal([], ...(ngDevMode ? [{ debugName: "headerActions" }] : []));
1047
1047
  this.searchButtonsReversed$ = of(null);
1048
1048
  this.fieldValues$ = combineLatest([
@@ -1055,12 +1055,22 @@ class SearchHeaderComponent {
1055
1055
  this.searchConfigChangedSlotEmitter = new EventEmitter();
1056
1056
  effect(() => {
1057
1057
  const viewMode = this.viewMode();
1058
- this.viewModeChanged?.emit(viewMode);
1059
- this.componentStateChanged.emit({
1060
- activeViewMode: viewMode,
1058
+ untracked(() => {
1059
+ this.viewModeChanged?.emit(viewMode);
1060
+ this.componentStateChanged.emit({
1061
+ activeViewMode: viewMode,
1062
+ });
1063
+ });
1064
+ });
1065
+ // Update header actions whenever view mode, advanced availability or actions input changes
1066
+ effect(() => {
1067
+ this.viewMode();
1068
+ this.hasAdvanced();
1069
+ this.actions();
1070
+ untracked(() => {
1071
+ this.updateHeaderActions();
1072
+ setTimeout(() => this.addKeyUpEventListener());
1061
1073
  });
1062
- this.updateHeaderActions();
1063
- setTimeout(() => this.addKeyUpEventListener());
1064
1074
  });
1065
1075
  this.announceSearchResults();
1066
1076
  const configurationService = inject(ConfigurationService);
@@ -1084,7 +1094,7 @@ class SearchHeaderComponent {
1084
1094
  updateHeaderActions() {
1085
1095
  const headerActions = [];
1086
1096
  if (this.hasAdvanced()) {
1087
- const simpleAdvancedAction = this.simpleAdvancedAction();
1097
+ const simpleAdvancedAction = this.simpleAdvancedAction;
1088
1098
  simpleAdvancedAction.labelKey =
1089
1099
  this.viewMode() === 'basic'
1090
1100
  ? 'OCX_SEARCH_HEADER.TOGGLE_BUTTON.ADVANCED.TEXT'
@@ -1126,7 +1136,9 @@ class SearchHeaderComponent {
1126
1136
  else {
1127
1137
  announmentKey = 'OCX_SEARCH_HEADER.ANNOUNCEMENTS.RESULTS_FOUND';
1128
1138
  }
1129
- firstValueFrom(this.translate.get(announmentKey, { count: !this.loading() && this.searchResultsCount() ? this.searchResultsCount() : null })).then((translatedText) => {
1139
+ firstValueFrom(this.translate.get(announmentKey, {
1140
+ count: !this.loading() && this.searchResultsCount() ? this.searchResultsCount() : null,
1141
+ })).then((translatedText) => {
1130
1142
  this.liveAnnouncer.announce(translatedText, 'polite');
1131
1143
  });
1132
1144
  });
@@ -5763,38 +5775,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.1", ngImpor
5763
5775
  }]
5764
5776
  }] });
5765
5777
 
5766
- /**
5767
- * @deprecated Use DynamicLocaleId from @onecx/angular-utils instead
5768
- */
5769
- class DynamicLocaleId {
5770
- constructor(userService) {
5771
- this.userService = userService;
5772
- Object.getOwnPropertyNames(String.prototype).forEach((k) => {
5773
- if (k != 'valueOf' && k != 'length') {
5774
- ;
5775
- this[k] = function (...args) {
5776
- const str = this.valueOf();
5777
- return str[k](...args);
5778
- };
5779
- }
5780
- });
5781
- }
5782
- valueOf() {
5783
- return this.userService.lang$.getValue();
5784
- }
5785
- get length() {
5786
- return this.valueOf().length;
5787
- }
5788
- }
5789
-
5790
5778
  const LIB_NAME = '@onecx/angular-accelerator';
5791
- const LIB_VERSION = '8.2.2';
5779
+ const LIB_VERSION = '8.3.1';
5792
5780
 
5793
5781
  class AngularAcceleratorMissingTranslationHandler extends MultiLanguageMissingTranslationHandler {
5794
5782
  }
5795
5783
  function appInitializer(userService) {
5796
5784
  return async () => {
5797
- await firstValueFrom(userService.lang$.pipe(skip(1)));
5785
+ const lang = await firstValueFrom(userService.lang$.pipe(skip(1)));
5786
+ try {
5787
+ await localeLoaders[lang]?.().then(data => registerLocaleData(data.default ?? data));
5788
+ }
5789
+ catch (error) {
5790
+ console.warn(`Could not load locale data for '${lang}'. Angular pipes may not format correctly.`, error);
5791
+ }
5798
5792
  };
5799
5793
  }
5800
5794
  class AngularAcceleratorModule {
@@ -6122,7 +6116,7 @@ function _hasShowTime(datePickers, formKey) {
6122
6116
  /**
6123
6117
  * Safely builds the search criteria based on form values
6124
6118
  * @param formRawValue the raw value of the form to use
6125
- * @param datePickers a list of primeng datePickers of the form (use `@ViewChildren(DatePicker) datePickers!: QueryList<DatePicker>;`)
6119
+ * @param datePickers a list of primeng datePickers of the form (use `viewChildren` to get list of datePickers)
6126
6120
  * @param parameters {@link BuildSearchCriteriaParameters} to use when building the search criteria
6127
6121
  * @returns the search criteria as a partial of T (T = type of the search criteria)
6128
6122
  */