@fundamental-ngx/core 0.63.0-rc.10 → 0.63.0-rc.12

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.
@@ -1,12 +1,12 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Attribute, Directive, inject, Injectable, EventEmitter, DestroyRef, ElementRef, ViewChild, Output, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, signal, input, computed, Inject, model, effect, forwardRef, HostListener, HostBinding, Optional, NgModule } from '@angular/core';
2
+ import { Attribute, Directive, inject, Injectable, EventEmitter, effect, ElementRef, ViewChild, Output, Input, ChangeDetectionStrategy, ViewEncapsulation, Component, signal, input, computed, DestroyRef, Inject, model, forwardRef, HostListener, HostBinding, Optional, NgModule } from '@angular/core';
3
3
  import { resolveTranslationSignal, FdTranslatePipe, resolveTranslationSignalFn, FD_LANGUAGE_ENGLISH, FD_LANGUAGE_SIGNAL } from '@fundamental-ngx/i18n';
4
4
  import * as i2 from '@fundamental-ngx/core/datetime';
5
5
  import { DATE_TIME_FORMATS } from '@fundamental-ngx/core/datetime';
6
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
7
6
  import { ButtonComponent } from '@fundamental-ngx/core/button';
8
- import { Subject, Subscription } from 'rxjs';
7
+ import { Subject } from 'rxjs';
9
8
  import { RtlService, FocusableListDirective, FocusableItemDirective } from '@fundamental-ngx/cdk/utils';
9
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
10
10
  import { NgClass } from '@angular/common';
11
11
  import { shallowEqual } from 'fast-equals';
12
12
  import { NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
@@ -312,12 +312,20 @@ class CalendarHeaderComponent {
312
312
  this.previousClicked = new EventEmitter();
313
313
  /** Event emitted when the next button is clicked. */
314
314
  this.nextClicked = new EventEmitter();
315
- /** @hidden */
316
- this._destroyRef = inject(DestroyRef);
317
315
  /** Month names */
318
316
  this._monthNames = [];
319
317
  /** Get information about amount of years displayed at once on year view */
320
318
  this._amountOfYearsPerPeriod = 1;
319
+ /** @hidden */
320
+ this._initiated = false;
321
+ effect(() => {
322
+ this._dateTimeAdapter.locale();
323
+ if (this._initiated) {
324
+ this._calculateMonthNames();
325
+ this._calculateLabels();
326
+ this._changeDetRef.markForCheck();
327
+ }
328
+ });
321
329
  }
322
330
  /** @hidden */
323
331
  ngOnChanges(changes) {
@@ -328,10 +336,10 @@ class CalendarHeaderComponent {
328
336
  }
329
337
  /** @hidden */
330
338
  ngOnInit() {
339
+ this._initiated = true;
331
340
  this._calendarService.leftArrowId = this._prevButtonId;
332
341
  this._calculateMonthNames();
333
342
  this._calculateLabels();
334
- this._listenToLocaleChanges();
335
343
  }
336
344
  /**
337
345
  * Focus on focusable control within the header
@@ -348,14 +356,6 @@ class CalendarHeaderComponent {
348
356
  this.activeViewChange.emit(this.activeView);
349
357
  }
350
358
  /** @hidden */
351
- _listenToLocaleChanges() {
352
- this._dateTimeAdapter.localeChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => {
353
- this._calculateMonthNames();
354
- this._calculateLabels();
355
- this._changeDetRef.markForCheck();
356
- });
357
- }
358
- /** @hidden */
359
359
  _calculateLabels() {
360
360
  this._calculateSelectMonthLabel();
361
361
  this._calculateSelectYearLabel();
@@ -713,6 +713,13 @@ class CalendarAggregatedYearViewComponent {
713
713
  this._initiated = false;
714
714
  // default values
715
715
  this._currentYear = _dateTimeAdapter.getYear(_dateTimeAdapter.today());
716
+ effect(() => {
717
+ this._dateTimeAdapter.locale();
718
+ if (this._initiated) {
719
+ this._constructYearsGrid();
720
+ this._changeDetectorRef.markForCheck();
721
+ }
722
+ });
716
723
  }
717
724
  /** @hidden */
718
725
  ngOnInit() {
@@ -720,10 +727,6 @@ class CalendarAggregatedYearViewComponent {
720
727
  this._setupKeyboardService();
721
728
  this._firstYearInList = this.yearSelected - this._yearsInOnePeriod();
722
729
  this._constructYearsGrid();
723
- this._dateTimeAdapter.localeChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => {
724
- this._constructYearsGrid();
725
- this._changeDetectorRef.markForCheck();
726
- });
727
730
  }
728
731
  /** @hidden */
729
732
  ngOnChanges(changes) {
@@ -1186,6 +1189,15 @@ class CalendarDayViewComponent {
1186
1189
  this._updateLegendFocusState(focusedNumber);
1187
1190
  }
1188
1191
  });
1192
+ // Effect to react to locale changes
1193
+ effect(() => {
1194
+ this._dateTimeAdapter.locale();
1195
+ if (this._isInitiated) {
1196
+ this._refreshShortWeekDays();
1197
+ this._buildDayViewGrid();
1198
+ this.changeDetRef.markForCheck();
1199
+ }
1200
+ });
1189
1201
  }
1190
1202
  /** @hidden */
1191
1203
  ngOnInit() {
@@ -1194,11 +1206,6 @@ class CalendarDayViewComponent {
1194
1206
  this._refreshShortWeekDays();
1195
1207
  this._buildDayViewGrid();
1196
1208
  this._computeWeekHeaderClasses();
1197
- this._dateTimeAdapter.localeChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => {
1198
- this._refreshShortWeekDays();
1199
- this._buildDayViewGrid();
1200
- this.changeDetRef.markForCheck();
1201
- });
1202
1209
  }
1203
1210
  /** @hidden */
1204
1211
  ngOnChanges(changes) {
@@ -2308,16 +2315,19 @@ class CalendarMonthViewComponent {
2308
2315
  /** @hidden */
2309
2316
  this._initiated = false;
2310
2317
  this._isOnRangePick = false;
2318
+ effect(() => {
2319
+ this._dateTimeAdapter.locale();
2320
+ if (this._initiated) {
2321
+ this._constructMonthGrid();
2322
+ this._changeDetectorRef.markForCheck();
2323
+ }
2324
+ });
2311
2325
  }
2312
2326
  /** @hidden */
2313
2327
  ngOnInit() {
2314
2328
  this._initiated = true;
2315
2329
  this._setupKeyboardService();
2316
2330
  this._constructMonthGrid();
2317
- this._dateTimeAdapter.localeChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => {
2318
- this._constructMonthGrid();
2319
- this._changeDetectorRef.markForCheck();
2320
- });
2321
2331
  }
2322
2332
  /** @hidden */
2323
2333
  ngOnChanges(changes) {
@@ -2721,6 +2731,13 @@ class CalendarYearViewComponent {
2721
2731
  // default values
2722
2732
  this._currentYear = _dateTimeAdapter.getYear(_dateTimeAdapter.today());
2723
2733
  this._firstYearInList = this._currentYear;
2734
+ effect(() => {
2735
+ this._dateTimeAdapter.locale();
2736
+ if (this._initiated) {
2737
+ this._constructYearGrid();
2738
+ this._changeDetectorRef.markForCheck();
2739
+ }
2740
+ });
2724
2741
  }
2725
2742
  /** @hidden */
2726
2743
  ngOnInit() {
@@ -2728,10 +2745,6 @@ class CalendarYearViewComponent {
2728
2745
  this._setupKeyboardService();
2729
2746
  this._firstYearInList = this.yearSelected;
2730
2747
  this._constructYearGrid();
2731
- this._dateTimeAdapter.localeChanges.pipe(takeUntilDestroyed(this._destroyRef)).subscribe(() => {
2732
- this._constructYearGrid();
2733
- this._changeDetectorRef.markForCheck();
2734
- });
2735
2748
  }
2736
2749
  /** @hidden */
2737
2750
  ngOnChanges(changes) {
@@ -3308,9 +3321,8 @@ class CalendarComponent {
3308
3321
  */
3309
3322
  this.legendCol = false;
3310
3323
  /** @hidden */
3311
- this.calendarRoleDescription = resolveTranslationSignal('coreCalendar.calendarRoleDescription');
3312
3324
  /** @hidden */
3313
- this._subscriptions = new Subscription();
3325
+ this.calendarRoleDescription = resolveTranslationSignal('coreCalendar.calendarRoleDescription');
3314
3326
  /** That allows to define function that should happen, when focus should normally escape of component */
3315
3327
  this.escapeFocusFunction = (event) => {
3316
3328
  event?.preventDefault();
@@ -3343,7 +3355,11 @@ class CalendarComponent {
3343
3355
  this._adapterStartingDayOfWeek = (this._dateTimeAdapter.getFirstDayOfWeek() + 1);
3344
3356
  this.selectedDate = this._dateTimeAdapter.today();
3345
3357
  this._changeDetectorRef.markForCheck();
3346
- this._listenToLocaleChanges();
3358
+ effect(() => {
3359
+ this._dateTimeAdapter.locale();
3360
+ this._adapterStartingDayOfWeek = (this._dateTimeAdapter.getFirstDayOfWeek() + 1);
3361
+ this._changeDetectorRef.markForCheck();
3362
+ });
3347
3363
  }
3348
3364
  /** @hidden */
3349
3365
  focusOut(event) {
@@ -3367,10 +3383,6 @@ class CalendarComponent {
3367
3383
  getWeekStartDay() {
3368
3384
  return this.startingDayOfWeek === undefined ? this._adapterStartingDayOfWeek : this.startingDayOfWeek;
3369
3385
  }
3370
- /** @hidden */
3371
- ngOnDestroy() {
3372
- this._subscriptions.unsubscribe();
3373
- }
3374
3386
  /**
3375
3387
  * @hidden
3376
3388
  * Function that provides support for ControlValueAccessor that allows to use [(ngModel)] or forms.
@@ -3708,13 +3720,6 @@ class CalendarComponent {
3708
3720
  isDateRangeYearFormat() {
3709
3721
  return this.dateRangeFormat === 'year';
3710
3722
  }
3711
- /** @hidden */
3712
- _listenToLocaleChanges() {
3713
- this._subscriptions.add(this._dateTimeAdapter.localeChanges.subscribe(() => {
3714
- this._adapterStartingDayOfWeek = (this._dateTimeAdapter.getFirstDayOfWeek() + 1);
3715
- this._changeDetectorRef.markForCheck();
3716
- }));
3717
- }
3718
3723
  /**
3719
3724
  * @hidden
3720
3725
  * Method that sets up the currently displayed variables, like shown month and year.