@siemens/dashboards-ng 48.3.0 → 48.5.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.
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Usage
4
4
 
5
- Check out our [dashboard demo project](../dashboards-demo/) for examples on how
5
+ Check out our [dashboard demo project](https://github.com/siemens/element/blob/main/projects/dashboards-demo/) for examples on how
6
6
  to integrate the Siemens Dashboards library in your project.
7
7
 
8
8
  ### Install dependencies
@@ -36,8 +36,7 @@ providers: [
36
36
  useFactory: createTranslateLoader,
37
37
  deps: [HttpBackend]
38
38
  }
39
- }),
40
- SiTranslateNgxTModule
39
+ })
41
40
  ),
42
41
  provideAnimations(),
43
42
  provideNgxTranslateForElement(),
@@ -89,7 +88,7 @@ the `angular.json` file.
89
88
 
90
89
  ### Add the dashboard to your application
91
90
 
92
- To add the dashboard to your application, add the `si-flexible-dashboard component
91
+ To add the dashboard to your application, add the `si-flexible-dashboard` component
93
92
  to your template. Configure the widget catalog by setting the _widgetCatalog_ input
94
93
  property.
95
94
 
@@ -174,21 +173,21 @@ The widget instance component has to implement the `WidgetInstance` interface an
174
173
  editor has to implement the `WidgetInstanceEditor` interface. You have to provide a
175
174
  module loader function that is used to load the widget when needed.
176
175
 
177
- The library ships with a [hello-widget](./src/app/widgets/hello-widget/) example for illustration.
176
+ The library ships with a [hello-widget](https://github.com/siemens/element/blob/main/projects/dashboards-demo/src/app/widgets/hello-widget/) example for illustration.
178
177
 
179
178
  E.g. a widget implements a user interface that is added at runtime into the body of a dashboard card.
180
179
  Optionally, the widget template may include a `<ng-template/>` to provides a footer implementation like
181
- `<ng-template #footer><a [siLink]="link">Go to issues</a></ng-template>` in the [value-widget](./src/app/widgets/charts/value-widget.component.ts).
180
+ `<ng-template #footer><a [siLink]="link">Go to issues</a></ng-template>` in the [value-widget](https://github.com/siemens/element/blob/main/projects/dashboards-demo/src/app/widgets/charts/value-widget.component.ts).
182
181
  The Angular component should export the template as the public attribute `footer`.
183
182
 
184
183
  ```ts
185
- `@ViewChild('footer', { static: true }) footer?: TemplateRef<unknown>;`;
184
+ @ViewChild('footer', { static: true }) footer?: TemplateRef<unknown>;
186
185
  ```
187
186
 
188
187
  ### Dashboard persistence
189
188
 
190
189
  The library persists a dashboard configuration by the default `SiDefaultWidgetStorage` implementation
191
- of the API [SiWidgetStorage](./projects/dashboards-ng/src/model/si-widget-storage.ts). The
190
+ of the API [SiWidgetStorage](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/si-widget-storage.ts). The
192
191
  `SiDefaultWidgetStorage` uses the `Storage` implementation `sessionStorage`. You can set a different
193
192
  `Storage` like the `localStorage` by providing the `DEFAULT_WIDGET_STORAGE_TOKEN` in the related module.
194
193
 
@@ -197,7 +196,7 @@ providers: [..., { provide: DEFAULT_WIDGET_STORAGE_TOKEN, useValue: localStorage
197
196
  ```
198
197
 
199
198
  For persistence in a backend service, you should implement your own
200
- [SiWidgetStorage](./projects/dashboards-ng/src/model/si-widget-storage.ts) and provide it in
199
+ [SiWidgetStorage](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/si-widget-storage.ts) and provide it in
201
200
  the library module definition.
202
201
 
203
202
  ```ts
@@ -214,17 +213,17 @@ SiDashboardsNgModule.forRoot({
214
213
 
215
214
  The dashboard is configurable through the Angular inputs of the exposed components and by
216
215
  the usage of the configuration object `Config`, which includes a `GridConfig` and including
217
- the [GridStackOptions](./projects/dashboards-ng/src/model/gridstack.model.ts).
216
+ the [GridStackOptions](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/gridstack.model.ts).
218
217
 
219
218
  To configure all dashboard instances, you can leverage dependency injection when importing
220
219
  the `SiDashboardsNgModule` using `SiDashboardsNgModule.forRoot({...})`.
221
220
  Alternatively, you have the option to configure individual dashboard instances by setting
222
221
  the input property `SiFlexibleDashboardComponent.config = {...}`.
223
222
 
224
- Here is the [demo](./src/app/pages/fixed-widgets-dashboard/fixed-widgets-dashboard.component.ts)
223
+ Here is the [demo](https://github.com/siemens/element/blob/main/projects/dashboards-demo/src/app/pages/fixed-widgets-dashboard/fixed-widgets-dashboard.component.ts)
225
224
 
226
225
  ## License
227
226
 
228
227
  Code and documentation Copyright (c) Siemens 2016 - 2025
229
228
 
230
- See [LICENSE.md](../../LICENSE.md).
229
+ See [LICENSE.md](https://github.com/siemens/element/blob/main/LICENSE.md).
@@ -8,7 +8,7 @@ import { Subject } from 'rxjs';
8
8
  */
9
9
  const setupRemoteComponent = (factory, componentName, host, injector, environmentInjector) => {
10
10
  const result = new Subject();
11
- loadRemoteModule(factory).then((module) => {
11
+ loadRemoteModule(factory).then(module => {
12
12
  const componentType = module[factory[componentName]];
13
13
  const widgetInstanceRef = host.createComponent(componentType, {
14
14
  injector,
@@ -1 +1 @@
1
- {"version":3,"file":"siemens-dashboards-ng-module-federation.mjs","sources":["../../../../projects/dashboards-ng/module-federation/index.ts","../../../../projects/dashboards-ng/module-federation/siemens-dashboards-ng-module-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/module-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule(factory).then(\n (module: any) => {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerModuleFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('module-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,CAC5B,CAAC,MAAW,KAAI;QACd,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;YAC/D,QAAQ;YACR;AACD,SAAA,CAAC;AACF,QAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAC9B,MAAM,CAAC,QAAQ,EAAE;KAClB,EACD,SAAS,IAAG;QACV,MAAM,GAAG,GAAG;AACV,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,CAAA,aAAA,EAAgB,IAAI,CAAC,SAAS,CAC1E,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAA;AACH,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,SAAS;AAC3D,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,MAAM,CAAC,QAAQ,EAAE;AACnB,KAAC,CACF;AACD,IAAA,OAAO,MAAM;AACf,CAAC;AAEM,MAAM,mCAAmC,GAAG,MAAW;AAC5D,IAAA,qBAAqB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,oBAAwC,CAAC;AAC/F;;AC3CA;;AAEG;;;;"}
1
+ {"version":3,"file":"siemens-dashboards-ng-module-federation.mjs","sources":["../../../../projects/dashboards-ng/module-federation/index.ts","../../../../projects/dashboards-ng/module-federation/siemens-dashboards-ng-module-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/module-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule<Type<T>[]>(factory).then(\n module => {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerModuleFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('module-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAY,OAAO,CAAC,CAAC,IAAI,CACvC,MAAM,IAAG;QACP,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;YAC/D,QAAQ;YACR;AACD,SAAA,CAAC;AACF,QAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAC9B,MAAM,CAAC,QAAQ,EAAE;KAClB,EACD,SAAS,IAAG;QACV,MAAM,GAAG,GAAG;AACV,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,CAAA,aAAA,EAAgB,IAAI,CAAC,SAAS,CAC1E,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAA;AACH,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,SAAS;AAC3D,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,MAAM,CAAC,QAAQ,EAAE;AACnB,KAAC,CACF;AACD,IAAA,OAAO,MAAM;AACf,CAAC;AAEM,MAAM,mCAAmC,GAAG,MAAW;AAC5D,IAAA,qBAAqB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,oBAAwC,CAAC;AAC/F;;AC3CA;;AAEG;;;;"}
@@ -1,10 +1,10 @@
1
1
  import { NgClass, AsyncPipe, NgTemplateOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, inject, input, model, output, computed, ViewChild, Component, Injectable, Renderer2, DOCUMENT, ElementRef, Input, EventEmitter, createNgModule, Injector, EnvironmentInjector, viewChild, ViewContainerRef, isSignal, NgZone, signal, NgModule } from '@angular/core';
3
+ import { InjectionToken, inject, input, model, output, viewChild, computed, Component, signal, Injectable, Renderer2, DOCUMENT, ElementRef, ViewChild, Input, Directive, EventEmitter, createNgModule, Injector, EnvironmentInjector, DestroyRef, ViewContainerRef, isSignal, NgZone, inputBinding, outputBinding, NgModule } from '@angular/core';
4
4
  import { SiDashboardCardComponent, SiDashboardComponent } from '@siemens/element-ng/dashboard';
5
5
  import { t, SiTranslatePipe } from '@siemens/element-translate-ng/translate';
6
6
  import { BehaviorSubject, of, Subject, throwError, ReplaySubject, combineLatest } from 'rxjs';
7
- import { takeUntil, take, map } from 'rxjs/operators';
7
+ import { take, takeUntil, map } from 'rxjs/operators';
8
8
  import { BOOTSTRAP_BREAKPOINTS, SiResponsiveContainerDirective } from '@siemens/element-ng/resize-observer';
9
9
  import { ActivatedRoute, RouterLink } from '@angular/router';
10
10
  import { SiContentActionBarComponent } from '@siemens/element-ng/content-action-bar';
@@ -12,6 +12,7 @@ import { SiLinkDirective } from '@siemens/element-ng/link';
12
12
  import { SiLoadingSpinnerComponent, SiLoadingService, SiLoadingSpinnerDirective } from '@siemens/element-ng/loading-spinner';
13
13
  import { SiModalService } from '@siemens/element-ng/modal';
14
14
  import { GridStack } from 'gridstack';
15
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
15
16
  import { SiActionDialogService } from '@siemens/element-ng/action-modal';
16
17
  import { CdkListbox, CdkOption } from '@angular/cdk/listbox';
17
18
  import { SiCircleStatusComponent } from '@siemens/element-ng/circle-status';
@@ -223,7 +224,7 @@ class SiDashboardToolbarComponent {
223
224
  labelCancel = t(() => $localize `:@@DASHBOARD.CANCEL:Cancel`);
224
225
  labelSave = t(() => $localize `:@@DASHBOARD.SAVE:Save`);
225
226
  activatedRoute = inject(ActivatedRoute, { optional: true });
226
- dashboardToolbarContainer;
227
+ dashboardToolbarContainer = viewChild.required(SiResponsiveContainerDirective);
227
228
  showContentActionBar = computed(() => this.primaryEditActions()?.length + this.secondaryEditActions()?.length > 3);
228
229
  editActions = computed(() => [
229
230
  ...this.primaryEditActions(),
@@ -245,11 +246,11 @@ class SiDashboardToolbarComponent {
245
246
  isToolbarItem(item) {
246
247
  return 'label' in item;
247
248
  }
248
- showEditButtonLabelDesktop() {
249
- return this.showEditButtonLabel() && !this.dashboardToolbarContainer?.xs();
250
- }
249
+ showEditButtonLabelDesktop = computed(() => {
250
+ return this.showEditButtonLabel() && !this.dashboardToolbarContainer()?.xs();
251
+ });
251
252
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiDashboardToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
252
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiDashboardToolbarComponent, isStandalone: true, selector: "si-dashboard-toolbar", inputs: { primaryEditActions: { classPropertyName: "primaryEditActions", publicName: "primaryEditActions", isSignal: true, isRequired: false, transformFunction: null }, secondaryEditActions: { classPropertyName: "secondaryEditActions", publicName: "secondaryEditActions", isSignal: true, isRequired: false, transformFunction: null }, disableSaveButton: { classPropertyName: "disableSaveButton", publicName: "disableSaveButton", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, hideEditButton: { classPropertyName: "hideEditButton", publicName: "hideEditButton", isSignal: true, isRequired: false, transformFunction: null }, showEditButtonLabel: { classPropertyName: "showEditButtonLabel", publicName: "showEditButtonLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disableSaveButton: "disableSaveButtonChange", editable: "editableChange", save: "save", cancel: "cancel" }, viewQueries: [{ propertyName: "dashboardToolbarContainer", first: true, predicate: SiResponsiveContainerDirective, descendants: true }], ngImport: i0, template: "<div class=\"row mb-3\" siResponsiveContainer>\n <div class=\"col-12 d-flex justify-content-between\">\n @if (!editable()) {\n <ng-content select=\"[filters-slot]\" />\n @if (!hideEditButton()) {\n <button\n type=\"button\"\n class=\"btn ms-auto\"\n [ngClass]=\"\n showEditButtonLabelDesktop()\n ? 'btn-secondary'\n : 'btn-circle btn-sm btn-tertiary element-edit'\n \"\n [attr.aria-label]=\"labelEdit | translate\"\n [attr.title]=\"!showEditButtonLabelDesktop() ? (labelEdit | translate) : undefined\"\n [disabled]=\"disabled()\"\n (click)=\"onEdit()\"\n >\n @if (showEditButtonLabelDesktop()) {\n {{ labelEdit | translate }}\n }\n </button>\n }\n } @else {\n @if (showContentActionBar()) {\n <si-content-action-bar\n toggleItemLabel=\"toggle\"\n viewType=\"expanded\"\n [disabled]=\"disabled()\"\n [primaryActions]=\"primaryEditActions()\"\n [secondaryActions]=\"secondaryEditActions()\"\n />\n } @else {\n <div>\n @for (action of editActions(); track $index) {\n @if (isToolbarItem(action)) {\n @if (disabled()) {\n <!-- Links do not support disabled, so we need to render a button instead in this case. -->\n <button type=\"button\" class=\"btn btn-secondary me-4\" disabled>\n {{ action.label! | translate }}\n </button>\n } @else {\n @switch (action.type) {\n @case ('action') {\n <!-- eslint-disable @angular-eslint/template/no-any -->\n <!-- This item has a patched action which will inject the grid. But our types do not reflect this. -->\n <!-- TODO: make our types reflect that this item has a patched action. -->\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n (click)=\"$any(action.action)()\"\n >\n {{ action.label! | translate }}\n </button>\n <!-- eslint-disable-enable @angular-eslint/template/no-any -->\n }\n @case ('router-link') {\n <a\n class=\"btn btn-secondary me-4\"\n [routerLink]=\"action.routerLink\"\n [queryParams]=\"action.extras?.queryParams\"\n [queryParamsHandling]=\"action.extras?.queryParamsHandling\"\n [fragment]=\"action.extras?.fragment\"\n [state]=\"action.extras?.state\"\n [relativeTo]=\"action.extras?.relativeTo ?? activatedRoute\"\n [preserveFragment]=\"action.extras?.preserveFragment\"\n [skipLocationChange]=\"action.extras?.skipLocationChange\"\n [replaceUrl]=\"action.extras?.replaceUrl\"\n >\n {{ action.label! | translate }}\n </a>\n }\n @case ('link') {\n <a class=\"btn btn-secondary me-4\" [href]=\"action.href\" [target]=\"action.target\">\n {{ action.label! | translate }}\n </a>\n }\n }\n }\n } @else {\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n [siLink]=\"action\"\n >\n {{ action.title! | translate }}\n </button>\n }\n }\n </div>\n }\n <div>\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n (click)=\"onCancel()\"\n >\n {{ labelCancel | translate }}\n </button>\n <button\n type=\"button\"\n class=\"btn btn-primary\"\n [disabled]=\"disableSaveButton() || disabled()\"\n (click)=\"onSave()\"\n >\n @if (disabled()) {\n <si-loading-spinner />\n } @else {\n <span>{{ labelSave | translate }}</span>\n }\n </button>\n </div>\n }\n </div>\n</div>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}si-loading-spinner{--loading-spinner-size: 1rem;--loading-spinner-color: var(--element-text-inverse)}\n"], dependencies: [{ kind: "component", type: SiContentActionBarComponent, selector: "si-content-action-bar", inputs: ["primaryActions", "secondaryActions", "actionParam", "viewType", "toggleItemLabel", "preventIconsInDropdownMenus", "disabled"] }, { kind: "directive", type: SiLinkDirective, selector: "[siLink]", inputs: ["siLink", "siLinkDefaultTarget", "actionParam", "activeClass", "exactMatch", "ariaCurrent"], outputs: ["activeChange"], exportAs: ["siLink"] }, { kind: "component", type: SiLoadingSpinnerComponent, selector: "si-loading-spinner", inputs: ["isBlockingSpinner", "isSpinnerOverlay", "ariaLabel"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: SiResponsiveContainerDirective, selector: "[siResponsiveContainer]", inputs: ["resizeThrottle", "breakpoints"], exportAs: ["siResponsiveContainer"] }, { kind: "pipe", type: SiTranslatePipe, name: "translate" }] });
253
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.6", type: SiDashboardToolbarComponent, isStandalone: true, selector: "si-dashboard-toolbar", inputs: { primaryEditActions: { classPropertyName: "primaryEditActions", publicName: "primaryEditActions", isSignal: true, isRequired: false, transformFunction: null }, secondaryEditActions: { classPropertyName: "secondaryEditActions", publicName: "secondaryEditActions", isSignal: true, isRequired: false, transformFunction: null }, disableSaveButton: { classPropertyName: "disableSaveButton", publicName: "disableSaveButton", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, hideEditButton: { classPropertyName: "hideEditButton", publicName: "hideEditButton", isSignal: true, isRequired: false, transformFunction: null }, showEditButtonLabel: { classPropertyName: "showEditButtonLabel", publicName: "showEditButtonLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disableSaveButton: "disableSaveButtonChange", editable: "editableChange", save: "save", cancel: "cancel" }, viewQueries: [{ propertyName: "dashboardToolbarContainer", first: true, predicate: SiResponsiveContainerDirective, descendants: true, isSignal: true }], ngImport: i0, template: "<div class=\"row mb-3\" siResponsiveContainer>\n <div class=\"col-12 d-flex justify-content-between\">\n @if (!editable()) {\n <ng-content select=\"[filters-slot]\" />\n @if (!hideEditButton()) {\n @let showEditButtonLabelDesktop = this.showEditButtonLabelDesktop();\n <button\n type=\"button\"\n class=\"btn ms-auto\"\n [ngClass]=\"\n showEditButtonLabelDesktop\n ? 'btn-secondary'\n : 'btn-circle btn-sm btn-tertiary element-edit'\n \"\n [attr.aria-label]=\"labelEdit | translate\"\n [attr.title]=\"!showEditButtonLabelDesktop ? (labelEdit | translate) : undefined\"\n [disabled]=\"disabled()\"\n (click)=\"onEdit()\"\n >\n @if (showEditButtonLabelDesktop) {\n {{ labelEdit | translate }}\n }\n </button>\n }\n } @else {\n @if (showContentActionBar()) {\n <si-content-action-bar\n toggleItemLabel=\"toggle\"\n viewType=\"expanded\"\n [disabled]=\"disabled()\"\n [primaryActions]=\"primaryEditActions()\"\n [secondaryActions]=\"secondaryEditActions()\"\n />\n } @else {\n <div>\n @for (action of editActions(); track $index) {\n @if (isToolbarItem(action)) {\n @if (disabled()) {\n <!-- Links do not support disabled, so we need to render a button instead in this case. -->\n <button type=\"button\" class=\"btn btn-secondary me-4\" disabled>\n {{ action.label! | translate }}\n </button>\n } @else {\n @switch (action.type) {\n @case ('action') {\n <!-- eslint-disable @angular-eslint/template/no-any -->\n <!-- This item has a patched action which will inject the grid. But our types do not reflect this. -->\n <!-- TODO: make our types reflect that this item has a patched action. -->\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n (click)=\"$any(action.action)()\"\n >\n {{ action.label! | translate }}\n </button>\n <!-- eslint-disable-enable @angular-eslint/template/no-any -->\n }\n @case ('router-link') {\n <a\n class=\"btn btn-secondary me-4\"\n [routerLink]=\"action.routerLink\"\n [queryParams]=\"action.extras?.queryParams\"\n [queryParamsHandling]=\"action.extras?.queryParamsHandling\"\n [fragment]=\"action.extras?.fragment\"\n [state]=\"action.extras?.state\"\n [relativeTo]=\"action.extras?.relativeTo ?? activatedRoute\"\n [preserveFragment]=\"action.extras?.preserveFragment\"\n [skipLocationChange]=\"action.extras?.skipLocationChange\"\n [replaceUrl]=\"action.extras?.replaceUrl\"\n >\n {{ action.label! | translate }}\n </a>\n }\n @case ('link') {\n <a class=\"btn btn-secondary me-4\" [href]=\"action.href\" [target]=\"action.target\">\n {{ action.label! | translate }}\n </a>\n }\n }\n }\n } @else {\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n [siLink]=\"action\"\n >\n {{ action.title! | translate }}\n </button>\n }\n }\n </div>\n }\n <div>\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n (click)=\"onCancel()\"\n >\n {{ labelCancel | translate }}\n </button>\n <button\n type=\"button\"\n class=\"btn btn-primary\"\n [disabled]=\"disableSaveButton() || disabled()\"\n (click)=\"onSave()\"\n >\n @if (disabled()) {\n <si-loading-spinner />\n } @else {\n <span>{{ labelSave | translate }}</span>\n }\n </button>\n </div>\n }\n </div>\n</div>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}si-loading-spinner{--loading-spinner-size: 1rem;--loading-spinner-color: var(--element-text-inverse)}\n"], dependencies: [{ kind: "component", type: SiContentActionBarComponent, selector: "si-content-action-bar", inputs: ["primaryActions", "secondaryActions", "actionParam", "viewType", "toggleItemLabel", "preventIconsInDropdownMenus", "disabled"] }, { kind: "directive", type: SiLinkDirective, selector: "[siLink]", inputs: ["siLink", "siLinkDefaultTarget", "actionParam", "activeClass", "exactMatch", "ariaCurrent"], outputs: ["activeChange"], exportAs: ["siLink"] }, { kind: "component", type: SiLoadingSpinnerComponent, selector: "si-loading-spinner", inputs: ["isBlockingSpinner", "isSpinnerOverlay", "ariaLabel"] }, { kind: "directive", type: RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: SiResponsiveContainerDirective, selector: "[siResponsiveContainer]", inputs: ["resizeThrottle", "breakpoints"], exportAs: ["siResponsiveContainer"] }, { kind: "pipe", type: SiTranslatePipe, name: "translate" }] });
253
254
  }
254
255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiDashboardToolbarComponent, decorators: [{
255
256
  type: Component,
@@ -261,11 +262,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
261
262
  NgClass,
262
263
  SiResponsiveContainerDirective,
263
264
  SiTranslatePipe
264
- ], template: "<div class=\"row mb-3\" siResponsiveContainer>\n <div class=\"col-12 d-flex justify-content-between\">\n @if (!editable()) {\n <ng-content select=\"[filters-slot]\" />\n @if (!hideEditButton()) {\n <button\n type=\"button\"\n class=\"btn ms-auto\"\n [ngClass]=\"\n showEditButtonLabelDesktop()\n ? 'btn-secondary'\n : 'btn-circle btn-sm btn-tertiary element-edit'\n \"\n [attr.aria-label]=\"labelEdit | translate\"\n [attr.title]=\"!showEditButtonLabelDesktop() ? (labelEdit | translate) : undefined\"\n [disabled]=\"disabled()\"\n (click)=\"onEdit()\"\n >\n @if (showEditButtonLabelDesktop()) {\n {{ labelEdit | translate }}\n }\n </button>\n }\n } @else {\n @if (showContentActionBar()) {\n <si-content-action-bar\n toggleItemLabel=\"toggle\"\n viewType=\"expanded\"\n [disabled]=\"disabled()\"\n [primaryActions]=\"primaryEditActions()\"\n [secondaryActions]=\"secondaryEditActions()\"\n />\n } @else {\n <div>\n @for (action of editActions(); track $index) {\n @if (isToolbarItem(action)) {\n @if (disabled()) {\n <!-- Links do not support disabled, so we need to render a button instead in this case. -->\n <button type=\"button\" class=\"btn btn-secondary me-4\" disabled>\n {{ action.label! | translate }}\n </button>\n } @else {\n @switch (action.type) {\n @case ('action') {\n <!-- eslint-disable @angular-eslint/template/no-any -->\n <!-- This item has a patched action which will inject the grid. But our types do not reflect this. -->\n <!-- TODO: make our types reflect that this item has a patched action. -->\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n (click)=\"$any(action.action)()\"\n >\n {{ action.label! | translate }}\n </button>\n <!-- eslint-disable-enable @angular-eslint/template/no-any -->\n }\n @case ('router-link') {\n <a\n class=\"btn btn-secondary me-4\"\n [routerLink]=\"action.routerLink\"\n [queryParams]=\"action.extras?.queryParams\"\n [queryParamsHandling]=\"action.extras?.queryParamsHandling\"\n [fragment]=\"action.extras?.fragment\"\n [state]=\"action.extras?.state\"\n [relativeTo]=\"action.extras?.relativeTo ?? activatedRoute\"\n [preserveFragment]=\"action.extras?.preserveFragment\"\n [skipLocationChange]=\"action.extras?.skipLocationChange\"\n [replaceUrl]=\"action.extras?.replaceUrl\"\n >\n {{ action.label! | translate }}\n </a>\n }\n @case ('link') {\n <a class=\"btn btn-secondary me-4\" [href]=\"action.href\" [target]=\"action.target\">\n {{ action.label! | translate }}\n </a>\n }\n }\n }\n } @else {\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n [siLink]=\"action\"\n >\n {{ action.title! | translate }}\n </button>\n }\n }\n </div>\n }\n <div>\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n (click)=\"onCancel()\"\n >\n {{ labelCancel | translate }}\n </button>\n <button\n type=\"button\"\n class=\"btn btn-primary\"\n [disabled]=\"disableSaveButton() || disabled()\"\n (click)=\"onSave()\"\n >\n @if (disabled()) {\n <si-loading-spinner />\n } @else {\n <span>{{ labelSave | translate }}</span>\n }\n </button>\n </div>\n }\n </div>\n</div>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}si-loading-spinner{--loading-spinner-size: 1rem;--loading-spinner-color: var(--element-text-inverse)}\n"] }]
265
- }], propDecorators: { dashboardToolbarContainer: [{
266
- type: ViewChild,
267
- args: [SiResponsiveContainerDirective]
268
- }] } });
265
+ ], template: "<div class=\"row mb-3\" siResponsiveContainer>\n <div class=\"col-12 d-flex justify-content-between\">\n @if (!editable()) {\n <ng-content select=\"[filters-slot]\" />\n @if (!hideEditButton()) {\n @let showEditButtonLabelDesktop = this.showEditButtonLabelDesktop();\n <button\n type=\"button\"\n class=\"btn ms-auto\"\n [ngClass]=\"\n showEditButtonLabelDesktop\n ? 'btn-secondary'\n : 'btn-circle btn-sm btn-tertiary element-edit'\n \"\n [attr.aria-label]=\"labelEdit | translate\"\n [attr.title]=\"!showEditButtonLabelDesktop ? (labelEdit | translate) : undefined\"\n [disabled]=\"disabled()\"\n (click)=\"onEdit()\"\n >\n @if (showEditButtonLabelDesktop) {\n {{ labelEdit | translate }}\n }\n </button>\n }\n } @else {\n @if (showContentActionBar()) {\n <si-content-action-bar\n toggleItemLabel=\"toggle\"\n viewType=\"expanded\"\n [disabled]=\"disabled()\"\n [primaryActions]=\"primaryEditActions()\"\n [secondaryActions]=\"secondaryEditActions()\"\n />\n } @else {\n <div>\n @for (action of editActions(); track $index) {\n @if (isToolbarItem(action)) {\n @if (disabled()) {\n <!-- Links do not support disabled, so we need to render a button instead in this case. -->\n <button type=\"button\" class=\"btn btn-secondary me-4\" disabled>\n {{ action.label! | translate }}\n </button>\n } @else {\n @switch (action.type) {\n @case ('action') {\n <!-- eslint-disable @angular-eslint/template/no-any -->\n <!-- This item has a patched action which will inject the grid. But our types do not reflect this. -->\n <!-- TODO: make our types reflect that this item has a patched action. -->\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n (click)=\"$any(action.action)()\"\n >\n {{ action.label! | translate }}\n </button>\n <!-- eslint-disable-enable @angular-eslint/template/no-any -->\n }\n @case ('router-link') {\n <a\n class=\"btn btn-secondary me-4\"\n [routerLink]=\"action.routerLink\"\n [queryParams]=\"action.extras?.queryParams\"\n [queryParamsHandling]=\"action.extras?.queryParamsHandling\"\n [fragment]=\"action.extras?.fragment\"\n [state]=\"action.extras?.state\"\n [relativeTo]=\"action.extras?.relativeTo ?? activatedRoute\"\n [preserveFragment]=\"action.extras?.preserveFragment\"\n [skipLocationChange]=\"action.extras?.skipLocationChange\"\n [replaceUrl]=\"action.extras?.replaceUrl\"\n >\n {{ action.label! | translate }}\n </a>\n }\n @case ('link') {\n <a class=\"btn btn-secondary me-4\" [href]=\"action.href\" [target]=\"action.target\">\n {{ action.label! | translate }}\n </a>\n }\n }\n }\n } @else {\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n [siLink]=\"action\"\n >\n {{ action.title! | translate }}\n </button>\n }\n }\n </div>\n }\n <div>\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"disabled()\"\n (click)=\"onCancel()\"\n >\n {{ labelCancel | translate }}\n </button>\n <button\n type=\"button\"\n class=\"btn btn-primary\"\n [disabled]=\"disableSaveButton() || disabled()\"\n (click)=\"onSave()\"\n >\n @if (disabled()) {\n <si-loading-spinner />\n } @else {\n <span>{{ labelSave | translate }}</span>\n }\n </button>\n </div>\n }\n </div>\n</div>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}si-loading-spinner{--loading-spinner-size: 1rem;--loading-spinner-color: var(--element-text-inverse)}\n"] }]
266
+ }] });
269
267
 
270
268
  /**
271
269
  * Copyright (c) Siemens 2016 - 2025
@@ -273,7 +271,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
273
271
  */
274
272
  class SiGridService {
275
273
  /** @defaultValue [] */
276
- widgetCatalog = [];
274
+ widgetCatalog = signal([]);
275
+ widgetCatalogMap = computed(() => new Map(this.widgetCatalog().map(widget => [widget.id, widget])));
277
276
  /**
278
277
  * Observable that emits true if si-grid is set to editable.
279
278
  * The owner of the editable state is the si-grid component.
@@ -282,7 +281,7 @@ class SiGridService {
282
281
  */
283
282
  editable$ = new BehaviorSubject(false);
284
283
  getWidget(id) {
285
- return this.widgetCatalog.find(widget => widget.id === id);
284
+ return this.widgetCatalogMap().get(id);
286
285
  }
287
286
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiGridService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
288
287
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiGridService });
@@ -302,8 +301,8 @@ class SiWebComponentWrapperBaseComponent {
302
301
  }
303
302
  set config(config) {
304
303
  this._config = config;
305
- if (this.webComponentHost.nativeElement.children.length > 0) {
306
- this.webComponentHost.nativeElement.children[0].config = config;
304
+ if (this.webComponent) {
305
+ this.webComponent.config = config;
307
306
  }
308
307
  }
309
308
  elementTagName;
@@ -319,20 +318,19 @@ class SiWebComponentWrapperBaseComponent {
319
318
  this.renderer2.appendChild(this.document.body, script);
320
319
  }
321
320
  this.webComponent = this.renderer2.createElement(this.elementTagName);
322
- this.webComponent.config = this.config;
321
+ if (this.webComponent) {
322
+ this.webComponent.config = this.config;
323
+ }
323
324
  }
324
325
  isScriptLoaded(url) {
325
326
  const script = document.querySelector(`script[src='${url}']`);
326
327
  return script ? true : false;
327
328
  }
328
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiWebComponentWrapperBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
329
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.6", type: SiWebComponentWrapperBaseComponent, isStandalone: true, selector: "ng-component", inputs: { config: "config", elementTagName: "elementTagName", url: "url" }, viewQueries: [{ propertyName: "webComponentHost", first: true, predicate: ["webComponentHost"], descendants: true, read: ElementRef, static: true }], ngImport: i0, template: '', isInline: true });
329
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiWebComponentWrapperBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive });
330
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.6", type: SiWebComponentWrapperBaseComponent, isStandalone: true, inputs: { config: "config", elementTagName: "elementTagName", url: "url" }, viewQueries: [{ propertyName: "webComponentHost", first: true, predicate: ["webComponentHost"], descendants: true, read: ElementRef, static: true }], ngImport: i0 });
330
331
  }
331
332
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiWebComponentWrapperBaseComponent, decorators: [{
332
- type: Component,
333
- args: [{
334
- template: ''
335
- }]
333
+ type: Directive
336
334
  }], propDecorators: { config: [{
337
335
  type: Input
338
336
  }], elementTagName: [{
@@ -356,13 +354,17 @@ class SiWebComponentEditorWrapperComponent extends SiWebComponentWrapperBaseComp
356
354
  * This will be set when setupWidgetInstanceEditor is executed
357
355
  */
358
356
  statusChangesHandler;
359
- webComponentEventListener = (event) => this.configChange.next(event.detail);
357
+ webComponentEventListener = (event) => event.detail && this.configChange.next(event.detail);
360
358
  webComponentStateChangeListener = (event) => {
361
- this.state = event.detail;
362
- this.stateChange.next(event.detail);
359
+ if (event.detail) {
360
+ this.state = event.detail;
361
+ this.stateChange.next(event.detail);
362
+ }
363
363
  };
364
364
  webComponentStatusChangesListener = (event) => {
365
- this.statusChangesHandler?.(event.detail);
365
+ if (event.detail) {
366
+ this.statusChangesHandler?.(event.detail);
367
+ }
366
368
  };
367
369
  ngAfterViewInit() {
368
370
  super.ngAfterViewInit();
@@ -401,8 +403,8 @@ class SiWebComponentWrapperComponent extends SiWebComponentWrapperBaseComponent
401
403
  }
402
404
  set editable(editable) {
403
405
  this._editable = editable;
404
- if (this.webComponentHost.nativeElement.children.length > 0) {
405
- this.webComponentHost.nativeElement.children[0].editable = editable;
406
+ if (this.webComponent) {
407
+ this.webComponent.editable = editable;
406
408
  }
407
409
  }
408
410
  primaryActions;
@@ -410,7 +412,7 @@ class SiWebComponentWrapperComponent extends SiWebComponentWrapperBaseComponent
410
412
  primaryEditActions;
411
413
  secondaryEditActions;
412
414
  configChange = new EventEmitter();
413
- webComponentEventListener = (event) => this.configChanged(event.detail);
415
+ webComponentEventListener = (event) => event.detail && this.configChanged(event.detail);
414
416
  ngAfterViewInit() {
415
417
  super.ngAfterViewInit();
416
418
  this.webComponent?.addEventListener('configChange', this.webComponentEventListener);
@@ -525,7 +527,7 @@ class SiWidgetHostComponent {
525
527
  gridService = inject(SiGridService);
526
528
  injector = inject(Injector);
527
529
  envInjector = inject(EnvironmentInjector);
528
- unsubscribe = new Subject();
530
+ destroyRef = inject(DestroyRef);
529
531
  widgetConfig = input.required();
530
532
  remove = output();
531
533
  edit = output();
@@ -611,13 +613,9 @@ class SiWidgetHostComponent {
611
613
  ngOnInit() {
612
614
  this.attachWidgetInstance();
613
615
  this.editable$
614
- .pipe(takeUntil(this.unsubscribe))
616
+ .pipe(takeUntilDestroyed(this.destroyRef))
615
617
  .subscribe(editable => this.setupEditable(editable));
616
618
  }
617
- ngOnDestroy() {
618
- this.unsubscribe.next();
619
- this.unsubscribe.complete();
620
- }
621
619
  attachWidgetInstance() {
622
620
  const widget = this.gridService.getWidget(this.widgetConfig().widgetId);
623
621
  if (widget) {
@@ -630,7 +628,7 @@ class SiWidgetHostComponent {
630
628
  // on web component, who pushes their configuration through an event after being attached
631
629
  // to the DOM.
632
630
  this.widgetInstance.configChange
633
- .pipe(takeUntil(this.unsubscribe))
631
+ .pipe(takeUntilDestroyed(this.destroyRef))
634
632
  .subscribe(event => setTimeout(() => this.setupEditable(this.editable$.value, event)));
635
633
  }
636
634
  if (isSignal(this.widgetInstance.config)) {
@@ -776,11 +774,12 @@ class SiGridstackWrapperComponent {
776
774
  gridstackContainer = viewChild('gridstackContainer', { read: ViewContainerRef });
777
775
  grid;
778
776
  markedForRender = [];
779
- gridItems = [];
777
+ gridItems = signal([]);
778
+ gridItemsMap = computed(() => new Map(this.gridItems().map(item => [item.id, item])));
780
779
  itemIdAttr = 'item-id';
781
- widgetIdSubscriptionMap = new Map();
782
780
  ngZone = inject(NgZone);
783
781
  elementRef = inject(ElementRef);
782
+ widgetConfigsMap = computed(() => new Map(this.widgetConfigs().map(w => [w.id, w])));
784
783
  ngOnChanges(changes) {
785
784
  if (changes.widgetConfigs) {
786
785
  const { currentValue, previousValue, firstChange } = changes.widgetConfigs;
@@ -789,10 +788,12 @@ class SiGridstackWrapperComponent {
789
788
  this.markedForRender = currentValue;
790
789
  }
791
790
  else {
791
+ const currentIds = new Set(currentValue.map((item) => item.id));
792
+ const previousIds = new Set(previousValue.map((item) => item.id));
792
793
  // Get newly added items
793
- const toBeAdded = currentValue.filter((item) => !previousValue.find((i) => i.id === item.id));
794
+ const toBeAdded = currentValue.filter((item) => !previousIds.has(item.id));
794
795
  // Get deleted items
795
- const toBeRemoved = previousValue.filter((item) => !currentValue.find((i) => i.id === item.id));
796
+ const toBeRemoved = previousValue.filter((item) => !currentIds.has(item.id));
796
797
  if (toBeAdded) {
797
798
  this.mount(toBeAdded);
798
799
  }
@@ -800,8 +801,6 @@ class SiGridstackWrapperComponent {
800
801
  this.unmount(toBeRemoved);
801
802
  }
802
803
  }
803
- // Detect changes
804
- this.updateViewComponents(currentValue);
805
804
  this.updateLayout(currentValue);
806
805
  this.grid?.batchUpdate(false);
807
806
  }
@@ -827,12 +826,6 @@ class SiGridstackWrapperComponent {
827
826
  this.hookEvents(this.grid);
828
827
  this.mount(this.markedForRender);
829
828
  }
830
- ngOnDestroy() {
831
- this.widgetIdSubscriptionMap.forEach(subscriptions => {
832
- subscriptions.forEach(subscription => subscription.unsubscribe());
833
- });
834
- this.widgetIdSubscriptionMap.clear();
835
- }
836
829
  mount(items) {
837
830
  if (items.length > 0) {
838
831
  items.forEach(item => {
@@ -865,35 +858,35 @@ class SiGridstackWrapperComponent {
865
858
  }
866
859
  }
867
860
  updateLayout(widgets) {
868
- const tmp = widgets.map(w => ({ ...w, w: w.width, h: w.height }));
861
+ const widgetConfigMap = new Map(widgets.map(w => [w.id, { ...w, w: w.width, h: w.height }]));
869
862
  if (this.grid) {
870
863
  const gridItems = this.grid.getGridItems();
871
864
  gridItems.forEach(gridItem => {
872
- const config = tmp.find(widget => widget.id === gridItem.getAttribute('item-id'));
873
- this.grid.update(gridItem, { ...config });
865
+ const itemId = gridItem.getAttribute('item-id');
866
+ const config = widgetConfigMap.get(itemId);
867
+ if (config) {
868
+ this.grid.update(gridItem, config);
869
+ }
874
870
  });
875
871
  }
876
872
  }
877
873
  addToView(item) {
878
- const componentRef = this.gridstackContainer().createComponent(SiWidgetHostComponent);
879
- componentRef.setInput('widgetConfig', item);
880
- const subscriptions = [];
881
- const subscriptionRemove = componentRef.instance.remove.subscribe(widgetId => {
882
- const widgetSubscriptions = this.widgetIdSubscriptionMap.get(widgetId);
883
- if (widgetSubscriptions) {
884
- widgetSubscriptions.forEach(sub => sub.unsubscribe());
885
- }
886
- this.widgetInstanceRemove.emit(widgetId);
887
- });
888
- subscriptions.push(subscriptionRemove);
889
- const subscriptionEdit = componentRef.instance.edit.subscribe(widgetConfig => {
890
- this.widgetInstanceEdit.emit(widgetConfig);
874
+ // we use computed here to dynamically bind the widgetConfig to the SiWidgetHostComponent
875
+ const config = computed(() => this.widgetConfigsMap().get(item.id));
876
+ const componentRef = this.gridstackContainer().createComponent(SiWidgetHostComponent, {
877
+ bindings: [
878
+ inputBinding('widgetConfig', config),
879
+ outputBinding('remove', widgetId => {
880
+ this.widgetInstanceRemove.emit(widgetId);
881
+ }),
882
+ outputBinding('edit', widgetConfig => {
883
+ this.widgetInstanceEdit.emit(widgetConfig);
884
+ })
885
+ ]
891
886
  });
892
- subscriptions.push(subscriptionEdit);
893
- this.widgetIdSubscriptionMap.set(item.id, subscriptions);
894
887
  const element = componentRef.location.nativeElement;
895
888
  element.setAttribute(this.itemIdAttr, item.id);
896
- this.gridItems.push({ id: item.id, component: componentRef });
889
+ this.gridItems.update(items => [...items, { id: item.id, component: componentRef }]);
897
890
  this.grid.makeWidget(element, {
898
891
  w: item.width,
899
892
  h: item.height,
@@ -908,22 +901,10 @@ class SiGridstackWrapperComponent {
908
901
  const toRemove = gridItemElements.find((el) => el.getAttribute(this.itemIdAttr) === widgetId);
909
902
  if (toRemove) {
910
903
  this.grid.removeWidget(toRemove);
911
- const index = this.gridItems.findIndex(i => i.id === widgetId);
912
- this.gridItems[index].component.destroy();
913
- this.gridItems.splice(index, 1);
914
- }
915
- }
916
- /**
917
- * GridItemComponents are created dynamically, change detection won't trigger as there is no \@Input binding.
918
- * We have to update instance and run ChangeDetectionRef manually.
919
- */
920
- updateViewComponents(newConfigs) {
921
- // TODO: lookup by id would fasten the update
922
- for (const config of newConfigs) {
923
- const gridItem = this.gridItems.find(item => item.id === config.id);
924
- if (gridItem) {
925
- gridItem.component.setInput('widgetConfig', config);
926
- }
904
+ const gridItemToRemove = this.gridItemsMap().get(widgetId);
905
+ gridItemToRemove?.component.destroy();
906
+ this.gridItemsMap().delete(widgetId);
907
+ this.gridItems.set(Array.from(this.gridItemsMap().values()));
927
908
  }
928
909
  }
929
910
  hookEvents(grid) {
@@ -1290,12 +1271,12 @@ class SiGridComponent {
1290
1271
  }
1291
1272
  }
1292
1273
  if (changes.widgetCatalog) {
1293
- this.gridService.widgetCatalog = this.widgetCatalog();
1274
+ this.gridService.widgetCatalog.set(this.widgetCatalog());
1294
1275
  }
1295
1276
  }
1296
1277
  ngOnInit() {
1297
1278
  queueMicrotask(() => this.loadAndSubscribeWidgets());
1298
- this.gridService.widgetCatalog = this.widgetCatalog();
1279
+ this.gridService.widgetCatalog.set(this.widgetCatalog());
1299
1280
  }
1300
1281
  ngOnDestroy() {
1301
1282
  this.storeSubscription?.unsubscribe();
@@ -1404,7 +1385,7 @@ class SiGridComponent {
1404
1385
  */
1405
1386
  editWidgetInstance(widgetInstanceConfig) {
1406
1387
  // Need to edit a clone to avoid runtime editing
1407
- const widgetConfigClone = JSON.parse(JSON.stringify(widgetInstanceConfig));
1388
+ const widgetConfigClone = structuredClone(widgetInstanceConfig);
1408
1389
  if (this.emitWidgetInstanceEditEvents()) {
1409
1390
  this.widgetInstanceEdit.emit(widgetConfigClone);
1410
1391
  }
@@ -1984,11 +1965,9 @@ class SiFlexibleDashboardComponent {
1984
1965
  }
1985
1966
  });
1986
1967
  viewState = signal('dashboard');
1987
- subscriptions = [];
1988
1968
  widgetStorage = inject(SI_WIDGET_STORE);
1989
1969
  hideAddWidgetInstanceButton$ = new BehaviorSubject(this.hideAddWidgetInstanceButton());
1990
1970
  dashboardId$ = new Subject();
1991
- outputRefSubscription = [];
1992
1971
  toolbar = viewChild.required('toolbar');
1993
1972
  ngOnChanges(changes) {
1994
1973
  if (changes.dashboardId) {
@@ -2018,18 +1997,9 @@ class SiFlexibleDashboardComponent {
2018
1997
  }
2019
1998
  ngOnInit() {
2020
1999
  this.setupMenuItems();
2021
- const grid = this.grid();
2022
- this.outputRefSubscription.push(grid.widgetInstanceEdit.subscribe(widgetConfig => {
2023
- this.editWidgetInstance(widgetConfig);
2024
- }));
2025
- this.outputRefSubscription.push(grid.editable.subscribe(editable => {
2026
- this.editable.set(editable);
2027
- }));
2028
2000
  }
2029
2001
  ngOnDestroy() {
2030
2002
  this.dashboardId$.next(undefined);
2031
- this.subscriptions?.forEach(sub => sub.unsubscribe());
2032
- this.outputRefSubscription?.forEach(sub => sub.unsubscribe());
2033
2003
  }
2034
2004
  /**
2035
2005
  * Shows the widget catalog of the dashboard. If a widget instance is expanded
@@ -2107,14 +2077,11 @@ class SiFlexibleDashboardComponent {
2107
2077
  }
2108
2078
  proxyMenuItemAction(item) {
2109
2079
  if ('action' in item) {
2110
- if (!item.action || item.action instanceof String) {
2111
- return item;
2080
+ if (typeof item.action === 'function') {
2081
+ item.action = item.action.bind(this, this.grid());
2112
2082
  }
2113
2083
  else {
2114
- const realAction = item.action;
2115
- item.action = () => {
2116
- realAction(this.grid());
2117
- };
2084
+ return item;
2118
2085
  }
2119
2086
  }
2120
2087
  return item;
@@ -2123,11 +2090,11 @@ class SiFlexibleDashboardComponent {
2123
2090
  return this.widgetCatalog().find(widget => widget.id === id);
2124
2091
  }
2125
2092
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiFlexibleDashboardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2126
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.0.6", type: SiFlexibleDashboardComponent, isStandalone: true, selector: "si-flexible-dashboard", inputs: { editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, widgetCatalogComponent: { classPropertyName: "widgetCatalogComponent", publicName: "widgetCatalogComponent", isSignal: true, isRequired: false, transformFunction: null }, widgetInstanceEditorDialogComponent: { classPropertyName: "widgetInstanceEditorDialogComponent", publicName: "widgetInstanceEditorDialogComponent", isSignal: true, isRequired: false, transformFunction: null }, dashboardId: { classPropertyName: "dashboardId", publicName: "dashboardId", isSignal: true, isRequired: false, transformFunction: null }, widgetCatalog: { classPropertyName: "widgetCatalog", publicName: "widgetCatalog", isSignal: true, isRequired: false, transformFunction: null }, hideAddWidgetInstanceButton: { classPropertyName: "hideAddWidgetInstanceButton", publicName: "hideAddWidgetInstanceButton", isSignal: true, isRequired: false, transformFunction: null }, hideEditButton: { classPropertyName: "hideEditButton", publicName: "hideEditButton", isSignal: true, isRequired: false, transformFunction: null }, showEditButtonLabel: { classPropertyName: "showEditButtonLabel", publicName: "showEditButtonLabel", isSignal: true, isRequired: false, transformFunction: null }, hideProgressIndicator: { classPropertyName: "hideProgressIndicator", publicName: "hideProgressIndicator", isSignal: true, isRequired: false, transformFunction: null }, config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { editable: "editableChange", isModified: "isModified" }, viewQueries: [{ propertyName: "grid", first: true, predicate: ["grid"], descendants: true, isSignal: true }, { propertyName: "dashboard", first: true, predicate: ["dashboard"], descendants: true, isSignal: true }, { propertyName: "catalogHost", first: true, predicate: ["catalogHost"], descendants: true, read: ViewContainerRef, isSignal: true }, { propertyName: "toolbar", first: true, predicate: ["toolbar"], descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "<si-dashboard #dashboard [heading]=\"pageTitle()\" [sticky]=\"true\">\n <si-dashboard-toolbar\n #toolbar\n menubar\n [class.d-none]=\"!isDashboardVisible()\"\n [primaryEditActions]=\"(primaryEditActions$ | async) ?? []\"\n [secondaryEditActions]=\"(secondaryEditActions$ | async) ?? []\"\n [editable]=\"editable()\"\n [disabled]=\"(grid.isLoading | async) ?? false\"\n [hideEditButton]=\"hideEditButton()\"\n [showEditButtonLabel]=\"showEditButtonLabel()\"\n (editableChange)=\"grid.edit()\"\n (save)=\"grid.save()\"\n (cancel)=\"grid.cancel()\"\n >\n <ng-content select=\"[filters-slot]\" filters-slot />\n </si-dashboard-toolbar>\n\n <div dashboard class=\"d-contents\">\n <si-grid\n #grid\n [class.d-none]=\"!isDashboardVisible()\"\n [gridConfig]=\"config()?.grid\"\n [dashboardId]=\"dashboardId()\"\n [widgetCatalog]=\"widgetCatalog()\"\n [hideProgressIndicator]=\"hideProgressIndicator()\"\n [widgetInstanceEditorDialogComponent]=\"widgetInstanceEditorDialogComponent()\"\n [emitWidgetInstanceEditEvents]=\"true\"\n (isModified)=\"onModified($event)\"\n >\n <ng-content select=\"[empty-state]\" empty-state />\n </si-grid>\n <ng-container #catalogHost />\n </div>\n</si-dashboard>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}\n"], dependencies: [{ kind: "component", type: SiDashboardComponent, selector: "si-dashboard", inputs: ["heading", "enableExpandInteractions", "sticky", "hideMenubar"] }, { kind: "component", type: SiDashboardToolbarComponent, selector: "si-dashboard-toolbar", inputs: ["primaryEditActions", "secondaryEditActions", "disableSaveButton", "disabled", "editable", "hideEditButton", "showEditButtonLabel"], outputs: ["disableSaveButtonChange", "editableChange", "save", "cancel"] }, { kind: "component", type: SiGridComponent, selector: "si-grid", inputs: ["gridConfig", "editable", "dashboardId", "widgetCatalog", "emitWidgetInstanceEditEvents", "hideProgressIndicator", "widgetInstanceEditorDialogComponent"], outputs: ["editableChange", "isModified", "widgetInstanceEdit"] }, { kind: "pipe", type: AsyncPipe, name: "async" }] });
2093
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "20.0.6", type: SiFlexibleDashboardComponent, isStandalone: true, selector: "si-flexible-dashboard", inputs: { editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, heading: { classPropertyName: "heading", publicName: "heading", isSignal: true, isRequired: false, transformFunction: null }, widgetCatalogComponent: { classPropertyName: "widgetCatalogComponent", publicName: "widgetCatalogComponent", isSignal: true, isRequired: false, transformFunction: null }, widgetInstanceEditorDialogComponent: { classPropertyName: "widgetInstanceEditorDialogComponent", publicName: "widgetInstanceEditorDialogComponent", isSignal: true, isRequired: false, transformFunction: null }, dashboardId: { classPropertyName: "dashboardId", publicName: "dashboardId", isSignal: true, isRequired: false, transformFunction: null }, widgetCatalog: { classPropertyName: "widgetCatalog", publicName: "widgetCatalog", isSignal: true, isRequired: false, transformFunction: null }, hideAddWidgetInstanceButton: { classPropertyName: "hideAddWidgetInstanceButton", publicName: "hideAddWidgetInstanceButton", isSignal: true, isRequired: false, transformFunction: null }, hideEditButton: { classPropertyName: "hideEditButton", publicName: "hideEditButton", isSignal: true, isRequired: false, transformFunction: null }, showEditButtonLabel: { classPropertyName: "showEditButtonLabel", publicName: "showEditButtonLabel", isSignal: true, isRequired: false, transformFunction: null }, hideProgressIndicator: { classPropertyName: "hideProgressIndicator", publicName: "hideProgressIndicator", isSignal: true, isRequired: false, transformFunction: null }, config: { classPropertyName: "config", publicName: "config", isSignal: true, isRequired: false, transformFunction: null }, searchPlaceholder: { classPropertyName: "searchPlaceholder", publicName: "searchPlaceholder", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { editable: "editableChange", isModified: "isModified" }, viewQueries: [{ propertyName: "grid", first: true, predicate: ["grid"], descendants: true, isSignal: true }, { propertyName: "dashboard", first: true, predicate: ["dashboard"], descendants: true, isSignal: true }, { propertyName: "catalogHost", first: true, predicate: ["catalogHost"], descendants: true, read: ViewContainerRef, isSignal: true }, { propertyName: "toolbar", first: true, predicate: ["toolbar"], descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "<si-dashboard #dashboard [heading]=\"pageTitle()\" [sticky]=\"true\">\n <si-dashboard-toolbar\n #toolbar\n menubar\n [class.d-none]=\"!isDashboardVisible()\"\n [primaryEditActions]=\"(primaryEditActions$ | async) ?? []\"\n [secondaryEditActions]=\"(secondaryEditActions$ | async) ?? []\"\n [editable]=\"editable()\"\n [disabled]=\"(grid.isLoading | async) ?? false\"\n [hideEditButton]=\"hideEditButton()\"\n [showEditButtonLabel]=\"showEditButtonLabel()\"\n (editableChange)=\"grid.edit()\"\n (save)=\"grid.save()\"\n (cancel)=\"grid.cancel()\"\n >\n <ng-content select=\"[filters-slot]\" filters-slot />\n </si-dashboard-toolbar>\n\n <div dashboard class=\"d-contents\">\n <si-grid\n #grid\n [class.d-none]=\"!isDashboardVisible()\"\n [gridConfig]=\"config()?.grid\"\n [dashboardId]=\"dashboardId()\"\n [widgetCatalog]=\"widgetCatalog()\"\n [hideProgressIndicator]=\"hideProgressIndicator()\"\n [widgetInstanceEditorDialogComponent]=\"widgetInstanceEditorDialogComponent()\"\n [emitWidgetInstanceEditEvents]=\"true\"\n [(editable)]=\"editable\"\n (isModified)=\"onModified($event)\"\n (widgetInstanceEdit)=\"editWidgetInstance($event)\"\n >\n <ng-content select=\"[empty-state]\" empty-state />\n </si-grid>\n <ng-container #catalogHost />\n </div>\n</si-dashboard>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}\n"], dependencies: [{ kind: "component", type: SiDashboardComponent, selector: "si-dashboard", inputs: ["heading", "enableExpandInteractions", "sticky", "hideMenubar"] }, { kind: "component", type: SiDashboardToolbarComponent, selector: "si-dashboard-toolbar", inputs: ["primaryEditActions", "secondaryEditActions", "disableSaveButton", "disabled", "editable", "hideEditButton", "showEditButtonLabel"], outputs: ["disableSaveButtonChange", "editableChange", "save", "cancel"] }, { kind: "component", type: SiGridComponent, selector: "si-grid", inputs: ["gridConfig", "editable", "dashboardId", "widgetCatalog", "emitWidgetInstanceEditEvents", "hideProgressIndicator", "widgetInstanceEditorDialogComponent"], outputs: ["editableChange", "isModified", "widgetInstanceEdit"] }, { kind: "pipe", type: AsyncPipe, name: "async" }] });
2127
2094
  }
2128
2095
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiFlexibleDashboardComponent, decorators: [{
2129
2096
  type: Component,
2130
- args: [{ selector: 'si-flexible-dashboard', imports: [SiDashboardComponent, SiDashboardToolbarComponent, SiGridComponent, AsyncPipe], template: "<si-dashboard #dashboard [heading]=\"pageTitle()\" [sticky]=\"true\">\n <si-dashboard-toolbar\n #toolbar\n menubar\n [class.d-none]=\"!isDashboardVisible()\"\n [primaryEditActions]=\"(primaryEditActions$ | async) ?? []\"\n [secondaryEditActions]=\"(secondaryEditActions$ | async) ?? []\"\n [editable]=\"editable()\"\n [disabled]=\"(grid.isLoading | async) ?? false\"\n [hideEditButton]=\"hideEditButton()\"\n [showEditButtonLabel]=\"showEditButtonLabel()\"\n (editableChange)=\"grid.edit()\"\n (save)=\"grid.save()\"\n (cancel)=\"grid.cancel()\"\n >\n <ng-content select=\"[filters-slot]\" filters-slot />\n </si-dashboard-toolbar>\n\n <div dashboard class=\"d-contents\">\n <si-grid\n #grid\n [class.d-none]=\"!isDashboardVisible()\"\n [gridConfig]=\"config()?.grid\"\n [dashboardId]=\"dashboardId()\"\n [widgetCatalog]=\"widgetCatalog()\"\n [hideProgressIndicator]=\"hideProgressIndicator()\"\n [widgetInstanceEditorDialogComponent]=\"widgetInstanceEditorDialogComponent()\"\n [emitWidgetInstanceEditEvents]=\"true\"\n (isModified)=\"onModified($event)\"\n >\n <ng-content select=\"[empty-state]\" empty-state />\n </si-grid>\n <ng-container #catalogHost />\n </div>\n</si-dashboard>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}\n"] }]
2097
+ args: [{ selector: 'si-flexible-dashboard', imports: [SiDashboardComponent, SiDashboardToolbarComponent, SiGridComponent, AsyncPipe], template: "<si-dashboard #dashboard [heading]=\"pageTitle()\" [sticky]=\"true\">\n <si-dashboard-toolbar\n #toolbar\n menubar\n [class.d-none]=\"!isDashboardVisible()\"\n [primaryEditActions]=\"(primaryEditActions$ | async) ?? []\"\n [secondaryEditActions]=\"(secondaryEditActions$ | async) ?? []\"\n [editable]=\"editable()\"\n [disabled]=\"(grid.isLoading | async) ?? false\"\n [hideEditButton]=\"hideEditButton()\"\n [showEditButtonLabel]=\"showEditButtonLabel()\"\n (editableChange)=\"grid.edit()\"\n (save)=\"grid.save()\"\n (cancel)=\"grid.cancel()\"\n >\n <ng-content select=\"[filters-slot]\" filters-slot />\n </si-dashboard-toolbar>\n\n <div dashboard class=\"d-contents\">\n <si-grid\n #grid\n [class.d-none]=\"!isDashboardVisible()\"\n [gridConfig]=\"config()?.grid\"\n [dashboardId]=\"dashboardId()\"\n [widgetCatalog]=\"widgetCatalog()\"\n [hideProgressIndicator]=\"hideProgressIndicator()\"\n [widgetInstanceEditorDialogComponent]=\"widgetInstanceEditorDialogComponent()\"\n [emitWidgetInstanceEditEvents]=\"true\"\n [(editable)]=\"editable\"\n (isModified)=\"onModified($event)\"\n (widgetInstanceEdit)=\"editWidgetInstance($event)\"\n >\n <ng-content select=\"[empty-state]\" empty-state />\n </si-grid>\n <ng-container #catalogHost />\n </div>\n</si-dashboard>\n", styles: [":host{display:flex;flex:1 1 0;flex-direction:column}\n"] }]
2131
2098
  }] });
2132
2099
 
2133
2100
  /**