Skip to content

Commit 73e1d6b

Browse files
authored
Merge branch 'main' into docs/provide-stackblitz-button
2 parents f3cffd2 + befe77f commit 73e1d6b

File tree

20 files changed

+126
-141
lines changed

20 files changed

+126
-141
lines changed

api-goldens/element-ng/dashboard/index.api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class SiDashboardCardComponent extends SiCardComponent implements OnDestr
5656
}
5757

5858
// @public (undocumented)
59-
export class SiDashboardComponent implements OnChanges, OnDestroy, AfterViewInit {
59+
export class SiDashboardComponent implements OnChanges, AfterViewInit {
6060
constructor();
6161
// (undocumented)
6262
protected dashboardFrameEndPadding: number | null;
@@ -71,8 +71,6 @@ export class SiDashboardComponent implements OnChanges, OnDestroy, AfterViewInit
7171
ngAfterViewInit(): void;
7272
// (undocumented)
7373
ngOnChanges(changes: SimpleChanges): void;
74-
// (undocumented)
75-
ngOnDestroy(): void;
7674
restore(): void;
7775
readonly sticky: _angular_core.InputSignalWithTransform<boolean, unknown>;
7876
// (undocumented)

api-goldens/element-ng/filtered-search/index.api.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { BackgroundColorVariant } from '@siemens/element-ng/common';
99
import { DatepickerInputConfig } from '@siemens/element-ng/datepicker';
1010
import { Observable } from 'rxjs';
1111
import { OnChanges } from '@angular/core';
12-
import { OnDestroy } from '@angular/core';
1312
import { OnInit } from '@angular/core';
1413
import { SimpleChanges } from '@angular/core';
1514
import { TranslatableString } from '@siemens/element-translate-ng/translate';
@@ -64,7 +63,7 @@ export interface SearchCriteria {
6463
}
6564

6665
// @public (undocumented)
67-
export class SiFilteredSearchComponent implements OnInit, OnChanges, OnDestroy {
66+
export class SiFilteredSearchComponent implements OnInit, OnChanges {
6867
constructor();
6968
// (undocumented)
7069
protected autoEditCriteria: boolean;
@@ -109,8 +108,6 @@ export class SiFilteredSearchComponent implements OnInit, OnChanges, OnDestroy {
109108
// (undocumented)
110109
ngOnChanges(changes: SimpleChanges): void;
111110
// (undocumented)
112-
ngOnDestroy(): void;
113-
// (undocumented)
114111
ngOnInit(): void;
115112
readonly onlySelectValue: _angular_core.InputSignalWithTransform<boolean, unknown>;
116113
readonly optionsInScrollableView: _angular_core.InputSignal<number>;

api-goldens/element-ng/navbar-vertical/index.api.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { IsActiveMatchOptions } from '@angular/router';
1010
import { MenuItem } from '@siemens/element-ng/common';
1111
import { NavigationExtras } from '@angular/router';
1212
import { OnChanges } from '@angular/core';
13-
import { OnDestroy } from '@angular/core';
1413
import { OnInit } from '@angular/core';
1514
import * as _siemens_element_translate_ng_translate_types from '@siemens/element-translate-ng/translate-types';
1615
import { SimpleChanges } from '@angular/core';
@@ -81,7 +80,7 @@ export interface NavbarVerticalItemRouterLink extends NavbarVerticalItemBase {
8180
export type NavbarVerticalSubItem = NavbarVerticalItemRouterLink | NavbarVerticalItemLink | NavbarVerticalItemAction;
8281

8382
// @public (undocumented)
84-
export class SiNavbarVerticalComponent implements OnChanges, OnInit, OnDestroy {
83+
export class SiNavbarVerticalComponent implements OnChanges, OnInit {
8584
constructor();
8685
// (undocumented)
8786
protected readonly activatedRoute: ActivatedRoute | null;
@@ -100,8 +99,6 @@ export class SiNavbarVerticalComponent implements OnChanges, OnInit, OnDestroy {
10099
// (undocumented)
101100
ngOnChanges(changes: SimpleChanges): void;
102101
// (undocumented)
103-
ngOnDestroy(): void;
104-
// (undocumented)
105102
ngOnInit(): void;
106103
// (undocumented)
107104
protected readonly ready = true;
Lines changed: 2 additions & 2 deletions
Loading
Lines changed: 1 addition & 1 deletion
Loading

projects/dashboards-ng/src/components/widget-host/si-widget-host.component.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,21 @@ import { AsyncPipe, NgClass, NgTemplateOutlet } from '@angular/common';
66
import {
77
Component,
88
ComponentRef,
9+
DestroyRef,
910
EnvironmentInjector,
1011
inject,
1112
Injector,
1213
input,
1314
isSignal,
1415
OnChanges,
15-
OnDestroy,
1616
OnInit,
1717
output,
1818
SimpleChanges,
1919
TemplateRef,
2020
viewChild,
2121
ViewContainerRef
2222
} from '@angular/core';
23+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2324
import { SiActionDialogService } from '@siemens/element-ng/action-modal';
2425
// We need one import from the main entry.
2526
// Otherwise, module federation is confused.
@@ -29,8 +30,6 @@ import { ContentActionBarMainItem, ViewType } from '@siemens/element-ng/content-
2930
import { SiDashboardCardComponent } from '@siemens/element-ng/dashboard';
3031
import { MenuItem } from '@siemens/element-ng/menu';
3132
import { t } from '@siemens/element-translate-ng/translate';
32-
import { Subject } from 'rxjs';
33-
import { takeUntil } from 'rxjs/operators';
3433

3534
import { WidgetConfig, WidgetConfigEvent, WidgetInstance } from '../../model/widgets.model';
3635
import { SiGridService } from '../../services/si-grid.service';
@@ -45,13 +44,12 @@ import { setupWidgetInstance } from '../../widget-loader';
4544
class: 'grid-stack-item'
4645
}
4746
})
48-
export class SiWidgetHostComponent implements OnInit, OnDestroy, OnChanges {
49-
private siModal = inject(SiActionDialogService);
50-
private gridService = inject(SiGridService);
51-
private injector = inject(Injector);
52-
private envInjector = inject(EnvironmentInjector);
53-
54-
private unsubscribe = new Subject<void>();
47+
export class SiWidgetHostComponent implements OnInit, OnChanges {
48+
private readonly siModal = inject(SiActionDialogService);
49+
private readonly gridService = inject(SiGridService);
50+
private readonly injector = inject(Injector);
51+
private readonly envInjector = inject(EnvironmentInjector);
52+
private readonly destroyRef = inject(DestroyRef);
5553

5654
readonly widgetConfig = input.required<WidgetConfig>();
5755

@@ -156,15 +154,10 @@ export class SiWidgetHostComponent implements OnInit, OnDestroy, OnChanges {
156154
ngOnInit(): void {
157155
this.attachWidgetInstance();
158156
this.editable$
159-
.pipe<boolean>(takeUntil(this.unsubscribe))
157+
.pipe<boolean>(takeUntilDestroyed(this.destroyRef))
160158
.subscribe(editable => this.setupEditable(editable));
161159
}
162160

163-
ngOnDestroy(): void {
164-
this.unsubscribe.next();
165-
this.unsubscribe.complete();
166-
}
167-
168161
private attachWidgetInstance(): void {
169162
const widget = this.gridService.getWidget(this.widgetConfig().widgetId);
170163
if (widget) {
@@ -182,7 +175,7 @@ export class SiWidgetHostComponent implements OnInit, OnDestroy, OnChanges {
182175
// on web component, who pushes their configuration through an event after being attached
183176
// to the DOM.
184177
this.widgetInstance.configChange
185-
.pipe(takeUntil(this.unsubscribe))
178+
.pipe(takeUntilDestroyed(this.destroyRef))
186179
.subscribe(event =>
187180
setTimeout(() => this.setupEditable(this.editable$.value, event))
188181
);

projects/element-ng/accordion/si-collapsible-panel.component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import {
99
ChangeDetectionStrategy,
1010
Component,
1111
computed,
12-
DestroyRef,
1312
ElementRef,
1413
inject,
1514
input,
@@ -131,7 +130,6 @@ export class SiCollapsiblePanelComponent {
131130
protected isHCollapsible = false;
132131
protected readonly icons = addIcons({ elementDown2 });
133132

134-
private readonly destroyRef = inject(DestroyRef);
135133
private readonly accordionService = inject(SiAccordionService, { optional: true });
136134
private readonly accordionHCollapseService = inject(SiAccordionHCollapseService, {
137135
optional: true
@@ -145,7 +143,7 @@ export class SiCollapsiblePanelComponent {
145143
this.isHCollapsible = !!this.accordionHCollapseService;
146144
this.accordionService?.toggle$
147145
.pipe(
148-
takeUntilDestroyed(this.destroyRef),
146+
takeUntilDestroyed(),
149147
filter(item => item !== this)
150148
)
151149
.subscribe(() => this.openClose(false));

projects/element-ng/dashboard/si-dashboard.component.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,24 @@ import {
1010
ChangeDetectorRef,
1111
Component,
1212
computed,
13+
DestroyRef,
1314
DOCUMENT,
1415
ElementRef,
1516
inject,
1617
input,
1718
OnChanges,
18-
OnDestroy,
1919
signal,
2020
SimpleChanges,
2121
viewChild
2222
} from '@angular/core';
23+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2324
import { ScrollbarHelper } from '@siemens/element-ng/common';
2425
import {
2526
BOOTSTRAP_BREAKPOINTS,
2627
ElementDimensions,
2728
ResizeObserverService
2829
} from '@siemens/element-ng/resize-observer';
2930
import { SiTranslatePipe } from '@siemens/element-translate-ng/translate';
30-
import { Subject } from 'rxjs';
31-
import { takeUntil } from 'rxjs/operators';
3231

3332
import { SiDashboardCardComponent } from './si-dashboard-card.component';
3433
import { SiDashboardService } from './si-dashboard.service';
@@ -43,7 +42,8 @@ const FIX_SCROLL_PADDING_RESIZE_OBSERVER_THROTTLE = 10;
4342
providers: [SiDashboardService],
4443
host: { class: 'si-layout-fixed-height' }
4544
})
46-
export class SiDashboardComponent implements OnChanges, OnDestroy, AfterViewInit {
45+
export class SiDashboardComponent implements OnChanges, AfterViewInit {
46+
private readonly destroyRef = inject(DestroyRef);
4747
/**
4848
* Heading for the dashboard page.
4949
*/
@@ -84,7 +84,6 @@ export class SiDashboardComponent implements OnChanges, OnDestroy, AfterViewInit
8484
);
8585

8686
private _isExpanded = false;
87-
private unsubscribe = new Subject<void>();
8887
private scrollPosition: [number, number] = [0, 0];
8988

9089
private cards: SiDashboardCardComponent[] = [];
@@ -107,7 +106,7 @@ export class SiDashboardComponent implements OnChanges, OnDestroy, AfterViewInit
107106

108107
constructor() {
109108
this.dashboardService.cards$
110-
.pipe(takeUntil(this.unsubscribe))
109+
.pipe(takeUntilDestroyed())
111110
.subscribe(cards => this.subscribeToCards(cards));
112111
}
113112

@@ -120,19 +119,14 @@ export class SiDashboardComponent implements OnChanges, OnDestroy, AfterViewInit
120119
ngAfterViewInit(): void {
121120
this.resizeObserver
122121
.observe(this.dashboard().nativeElement, FIX_SCROLL_PADDING_RESIZE_OBSERVER_THROTTLE)
123-
.pipe(takeUntil(this.unsubscribe))
122+
.pipe(takeUntilDestroyed(this.destroyRef))
124123
.subscribe(x => this.setDashboardFrameEndPadding(this.dashboardFrameDimensions, x));
125124
this.resizeObserver
126125
.observe(this.dashboardFrame().nativeElement, FIX_SCROLL_PADDING_RESIZE_OBSERVER_THROTTLE)
127-
.pipe(takeUntil(this.unsubscribe))
126+
.pipe(takeUntilDestroyed(this.destroyRef))
128127
.subscribe(dims => this.setDashboardFrameEndPadding(dims, this.dashboardDimensions));
129128
}
130129

131-
ngOnDestroy(): void {
132-
this.unsubscribe.next();
133-
this.unsubscribe.complete();
134-
}
135-
136130
private subscribeToCards(cards: SiDashboardCardComponent[]): void {
137131
this.cards = cards;
138132
this.initCards();

projects/element-ng/filtered-search/si-filtered-search.component.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@ import {
77
ChangeDetectorRef,
88
Component,
99
computed,
10+
DestroyRef,
1011
ElementRef,
1112
inject,
1213
input,
1314
LOCALE_ID,
1415
model,
1516
OnChanges,
16-
OnDestroy,
1717
OnInit,
1818
output,
1919
signal,
2020
SimpleChanges,
2121
viewChild,
2222
viewChildren
2323
} from '@angular/core';
24+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
2425
import { FormsModule } from '@angular/forms';
2526
import { BackgroundColorVariant, isRTL } from '@siemens/element-ng/common';
2627
import { addIcons, elementCancel, elementSearch, SiIconComponent } from '@siemens/element-ng/icon';
@@ -32,7 +33,7 @@ import {
3233
TranslatableString
3334
} from '@siemens/element-translate-ng/translate';
3435
import { BehaviorSubject, Observable, of, Subject, switchMap } from 'rxjs';
35-
import { debounceTime, map, takeUntil } from 'rxjs/operators';
36+
import { debounceTime, map } from 'rxjs/operators';
3637

3738
import {
3839
differenceByName,
@@ -66,7 +67,7 @@ import {
6667
'[class.dark-background]': "colorVariant() === 'base-0'"
6768
}
6869
})
69-
export class SiFilteredSearchComponent implements OnInit, OnChanges, OnDestroy {
70+
export class SiFilteredSearchComponent implements OnInit, OnChanges {
7071
private static readonly criterionRegex = /(.+?):(.*)$/;
7172

7273
/**
@@ -317,10 +318,10 @@ export class SiFilteredSearchComponent implements OnInit, OnChanges, OnDestroy {
317318
private typeaheadInputChange = new BehaviorSubject<string>('');
318319
/** Used to debounce the Search emissions */
319320
private searchEmitQueue = new Subject<SearchCriteria | undefined>();
320-
private destroySubscriptions = new Subject<boolean>();
321-
private cdRef = inject(ChangeDetectorRef);
322-
private translateService = injectSiTranslateService();
323-
private locale = inject(LOCALE_ID).toString();
321+
private readonly destroyRef = inject(DestroyRef);
322+
private readonly cdRef = inject(ChangeDetectorRef);
323+
private readonly translateService = injectSiTranslateService();
324+
private readonly locale = inject(LOCALE_ID).toString();
324325
/**
325326
* The cache is used to control when the interceptDisplayedCriteria event needs to be called.
326327
* Every time a criteria gain the focus we have to reset the cache to call the interceptor.
@@ -397,15 +398,10 @@ export class SiFilteredSearchComponent implements OnInit, OnChanges, OnDestroy {
397398
}
398399

399400
this.searchEmitQueue
400-
.pipe(debounceTime(this.searchDebounceTime()), takeUntil(this.destroySubscriptions))
401+
.pipe(debounceTime(this.searchDebounceTime()), takeUntilDestroyed(this.destroyRef))
401402
.subscribe(searchCriteria => this.doSearch.emit(searchCriteria!));
402403
}
403404

404-
ngOnDestroy(): void {
405-
this.destroySubscriptions.next(true);
406-
this.destroySubscriptions.unsubscribe();
407-
}
408-
409405
private initCriteria(): void {
410406
this.internalCriterionDefinitions = this.loadedCriteria().map(c => toInternalCriteria(c));
411407
}

projects/element-ng/navbar-vertical/si-navbar-vertical.component.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,20 @@ import {
2424
input,
2525
model,
2626
OnChanges,
27-
OnDestroy,
2827
OnInit,
2928
output,
3029
signal,
3130
SimpleChanges,
3231
viewChild,
3332
viewChildren
3433
} from '@angular/core';
34+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
3535
import { ActivatedRoute, RouterLink, RouterLinkActive } from '@angular/router';
3636
import { MenuItem, SI_UI_STATE_SERVICE } from '@siemens/element-ng/common';
3737
import { BOOTSTRAP_BREAKPOINTS } from '@siemens/element-ng/resize-observer';
3838
import { SiSearchBarComponent } from '@siemens/element-ng/search-bar';
3939
import { SiSkipLinkTargetDirective } from '@siemens/element-ng/skip-links';
4040
import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate';
41-
import { Subject } from 'rxjs';
42-
import { takeUntil } from 'rxjs/operators';
4341

4442
import { SiNavbarVerticalDividerComponent } from './si-navbar-vertical-divider.component';
4543
import { SiNavbarVerticalGroupTriggerDirective } from './si-navbar-vertical-group-trigger.directive';
@@ -143,7 +141,7 @@ export class SiNavbarVerticalItemGuardDirective {
143141
])
144142
]
145143
})
146-
export class SiNavbarVerticalComponent implements OnChanges, OnInit, OnDestroy {
144+
export class SiNavbarVerticalComponent implements OnChanges, OnInit {
147145
/**
148146
* Whether the navbar-vertical is collapsed.
149147
*
@@ -281,15 +279,14 @@ export class SiNavbarVerticalComponent implements OnChanges, OnInit, OnDestroy {
281279

282280
protected readonly smallScreen = signal(false);
283281
protected readonly uiStateExpandedItems = signal<Record<string, boolean>>({});
284-
private destroyer = new Subject<void>();
285282

286283
// Indicates if the user prefers a collapsed navbar. Relevant for resizing.
287284
private preferCollapse = false;
288285

289286
constructor() {
290287
this.breakpointObserver
291288
.observe(`(max-width: ${BOOTSTRAP_BREAKPOINTS.lgMinimum}px)`)
292-
.pipe(takeUntil(this.destroyer))
289+
.pipe(takeUntilDestroyed())
293290
.subscribe(({ matches }) => {
294291
this.collapsed.set(matches || this.preferCollapse);
295292
this.smallScreen.set(matches);
@@ -315,11 +312,6 @@ export class SiNavbarVerticalComponent implements OnChanges, OnInit, OnDestroy {
315312
}
316313
}
317314

318-
ngOnDestroy(): void {
319-
this.destroyer.next();
320-
this.destroyer.complete();
321-
}
322-
323315
protected toggleCollapse(): void {
324316
if (this.collapsed()) {
325317
this.expand();

0 commit comments

Comments
 (0)