@siemens/dashboards-ng 48.4.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(),
@@ -174,11 +173,11 @@ 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
@@ -188,7 +187,7 @@ The Angular component should export the template as the public attribute `footer
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,6 +1,6 @@
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, DestroyRef, 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';
@@ -224,7 +224,7 @@ class SiDashboardToolbarComponent {
224
224
  labelCancel = t(() => $localize `:@@DASHBOARD.CANCEL:Cancel`);
225
225
  labelSave = t(() => $localize `:@@DASHBOARD.SAVE:Save`);
226
226
  activatedRoute = inject(ActivatedRoute, { optional: true });
227
- dashboardToolbarContainer;
227
+ dashboardToolbarContainer = viewChild.required(SiResponsiveContainerDirective);
228
228
  showContentActionBar = computed(() => this.primaryEditActions()?.length + this.secondaryEditActions()?.length > 3);
229
229
  editActions = computed(() => [
230
230
  ...this.primaryEditActions(),
@@ -246,11 +246,11 @@ class SiDashboardToolbarComponent {
246
246
  isToolbarItem(item) {
247
247
  return 'label' in item;
248
248
  }
249
- showEditButtonLabelDesktop() {
250
- return this.showEditButtonLabel() && !this.dashboardToolbarContainer?.xs();
251
- }
249
+ showEditButtonLabelDesktop = computed(() => {
250
+ return this.showEditButtonLabel() && !this.dashboardToolbarContainer()?.xs();
251
+ });
252
252
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiDashboardToolbarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
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 }], 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" }] });
254
254
  }
255
255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiDashboardToolbarComponent, decorators: [{
256
256
  type: Component,
@@ -262,11 +262,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
262
262
  NgClass,
263
263
  SiResponsiveContainerDirective,
264
264
  SiTranslatePipe
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 <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
- }], propDecorators: { dashboardToolbarContainer: [{
267
- type: ViewChild,
268
- args: [SiResponsiveContainerDirective]
269
- }] } });
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
+ }] });
270
267
 
271
268
  /**
272
269
  * Copyright (c) Siemens 2016 - 2025
@@ -274,7 +271,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImpor
274
271
  */
275
272
  class SiGridService {
276
273
  /** @defaultValue [] */
277
- widgetCatalog = [];
274
+ widgetCatalog = signal([]);
275
+ widgetCatalogMap = computed(() => new Map(this.widgetCatalog().map(widget => [widget.id, widget])));
278
276
  /**
279
277
  * Observable that emits true if si-grid is set to editable.
280
278
  * The owner of the editable state is the si-grid component.
@@ -283,7 +281,7 @@ class SiGridService {
283
281
  */
284
282
  editable$ = new BehaviorSubject(false);
285
283
  getWidget(id) {
286
- return this.widgetCatalog.find(widget => widget.id === id);
284
+ return this.widgetCatalogMap().get(id);
287
285
  }
288
286
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiGridService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
289
287
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiGridService });
@@ -303,8 +301,8 @@ class SiWebComponentWrapperBaseComponent {
303
301
  }
304
302
  set config(config) {
305
303
  this._config = config;
306
- if (this.webComponentHost.nativeElement.children.length > 0) {
307
- this.webComponentHost.nativeElement.children[0].config = config;
304
+ if (this.webComponent) {
305
+ this.webComponent.config = config;
308
306
  }
309
307
  }
310
308
  elementTagName;
@@ -320,20 +318,19 @@ class SiWebComponentWrapperBaseComponent {
320
318
  this.renderer2.appendChild(this.document.body, script);
321
319
  }
322
320
  this.webComponent = this.renderer2.createElement(this.elementTagName);
323
- this.webComponent.config = this.config;
321
+ if (this.webComponent) {
322
+ this.webComponent.config = this.config;
323
+ }
324
324
  }
325
325
  isScriptLoaded(url) {
326
326
  const script = document.querySelector(`script[src='${url}']`);
327
327
  return script ? true : false;
328
328
  }
329
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiWebComponentWrapperBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
330
- 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 });
331
331
  }
332
332
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiWebComponentWrapperBaseComponent, decorators: [{
333
- type: Component,
334
- args: [{
335
- template: ''
336
- }]
333
+ type: Directive
337
334
  }], propDecorators: { config: [{
338
335
  type: Input
339
336
  }], elementTagName: [{
@@ -357,13 +354,17 @@ class SiWebComponentEditorWrapperComponent extends SiWebComponentWrapperBaseComp
357
354
  * This will be set when setupWidgetInstanceEditor is executed
358
355
  */
359
356
  statusChangesHandler;
360
- webComponentEventListener = (event) => this.configChange.next(event.detail);
357
+ webComponentEventListener = (event) => event.detail && this.configChange.next(event.detail);
361
358
  webComponentStateChangeListener = (event) => {
362
- this.state = event.detail;
363
- this.stateChange.next(event.detail);
359
+ if (event.detail) {
360
+ this.state = event.detail;
361
+ this.stateChange.next(event.detail);
362
+ }
364
363
  };
365
364
  webComponentStatusChangesListener = (event) => {
366
- this.statusChangesHandler?.(event.detail);
365
+ if (event.detail) {
366
+ this.statusChangesHandler?.(event.detail);
367
+ }
367
368
  };
368
369
  ngAfterViewInit() {
369
370
  super.ngAfterViewInit();
@@ -402,8 +403,8 @@ class SiWebComponentWrapperComponent extends SiWebComponentWrapperBaseComponent
402
403
  }
403
404
  set editable(editable) {
404
405
  this._editable = editable;
405
- if (this.webComponentHost.nativeElement.children.length > 0) {
406
- this.webComponentHost.nativeElement.children[0].editable = editable;
406
+ if (this.webComponent) {
407
+ this.webComponent.editable = editable;
407
408
  }
408
409
  }
409
410
  primaryActions;
@@ -411,7 +412,7 @@ class SiWebComponentWrapperComponent extends SiWebComponentWrapperBaseComponent
411
412
  primaryEditActions;
412
413
  secondaryEditActions;
413
414
  configChange = new EventEmitter();
414
- webComponentEventListener = (event) => this.configChanged(event.detail);
415
+ webComponentEventListener = (event) => event.detail && this.configChanged(event.detail);
415
416
  ngAfterViewInit() {
416
417
  super.ngAfterViewInit();
417
418
  this.webComponent?.addEventListener('configChange', this.webComponentEventListener);
@@ -773,11 +774,12 @@ class SiGridstackWrapperComponent {
773
774
  gridstackContainer = viewChild('gridstackContainer', { read: ViewContainerRef });
774
775
  grid;
775
776
  markedForRender = [];
776
- gridItems = [];
777
+ gridItems = signal([]);
778
+ gridItemsMap = computed(() => new Map(this.gridItems().map(item => [item.id, item])));
777
779
  itemIdAttr = 'item-id';
778
- widgetIdSubscriptionMap = new Map();
779
780
  ngZone = inject(NgZone);
780
781
  elementRef = inject(ElementRef);
782
+ widgetConfigsMap = computed(() => new Map(this.widgetConfigs().map(w => [w.id, w])));
781
783
  ngOnChanges(changes) {
782
784
  if (changes.widgetConfigs) {
783
785
  const { currentValue, previousValue, firstChange } = changes.widgetConfigs;
@@ -786,10 +788,12 @@ class SiGridstackWrapperComponent {
786
788
  this.markedForRender = currentValue;
787
789
  }
788
790
  else {
791
+ const currentIds = new Set(currentValue.map((item) => item.id));
792
+ const previousIds = new Set(previousValue.map((item) => item.id));
789
793
  // Get newly added items
790
- const toBeAdded = currentValue.filter((item) => !previousValue.find((i) => i.id === item.id));
794
+ const toBeAdded = currentValue.filter((item) => !previousIds.has(item.id));
791
795
  // Get deleted items
792
- const toBeRemoved = previousValue.filter((item) => !currentValue.find((i) => i.id === item.id));
796
+ const toBeRemoved = previousValue.filter((item) => !currentIds.has(item.id));
793
797
  if (toBeAdded) {
794
798
  this.mount(toBeAdded);
795
799
  }
@@ -797,8 +801,6 @@ class SiGridstackWrapperComponent {
797
801
  this.unmount(toBeRemoved);
798
802
  }
799
803
  }
800
- // Detect changes
801
- this.updateViewComponents(currentValue);
802
804
  this.updateLayout(currentValue);
803
805
  this.grid?.batchUpdate(false);
804
806
  }
@@ -824,12 +826,6 @@ class SiGridstackWrapperComponent {
824
826
  this.hookEvents(this.grid);
825
827
  this.mount(this.markedForRender);
826
828
  }
827
- ngOnDestroy() {
828
- this.widgetIdSubscriptionMap.forEach(subscriptions => {
829
- subscriptions.forEach(subscription => subscription.unsubscribe());
830
- });
831
- this.widgetIdSubscriptionMap.clear();
832
- }
833
829
  mount(items) {
834
830
  if (items.length > 0) {
835
831
  items.forEach(item => {
@@ -862,35 +858,35 @@ class SiGridstackWrapperComponent {
862
858
  }
863
859
  }
864
860
  updateLayout(widgets) {
865
- 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 }]));
866
862
  if (this.grid) {
867
863
  const gridItems = this.grid.getGridItems();
868
864
  gridItems.forEach(gridItem => {
869
- const config = tmp.find(widget => widget.id === gridItem.getAttribute('item-id'));
870
- 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
+ }
871
870
  });
872
871
  }
873
872
  }
874
873
  addToView(item) {
875
- const componentRef = this.gridstackContainer().createComponent(SiWidgetHostComponent);
876
- componentRef.setInput('widgetConfig', item);
877
- const subscriptions = [];
878
- const subscriptionRemove = componentRef.instance.remove.subscribe(widgetId => {
879
- const widgetSubscriptions = this.widgetIdSubscriptionMap.get(widgetId);
880
- if (widgetSubscriptions) {
881
- widgetSubscriptions.forEach(sub => sub.unsubscribe());
882
- }
883
- this.widgetInstanceRemove.emit(widgetId);
884
- });
885
- subscriptions.push(subscriptionRemove);
886
- const subscriptionEdit = componentRef.instance.edit.subscribe(widgetConfig => {
887
- 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
+ ]
888
886
  });
889
- subscriptions.push(subscriptionEdit);
890
- this.widgetIdSubscriptionMap.set(item.id, subscriptions);
891
887
  const element = componentRef.location.nativeElement;
892
888
  element.setAttribute(this.itemIdAttr, item.id);
893
- this.gridItems.push({ id: item.id, component: componentRef });
889
+ this.gridItems.update(items => [...items, { id: item.id, component: componentRef }]);
894
890
  this.grid.makeWidget(element, {
895
891
  w: item.width,
896
892
  h: item.height,
@@ -905,22 +901,10 @@ class SiGridstackWrapperComponent {
905
901
  const toRemove = gridItemElements.find((el) => el.getAttribute(this.itemIdAttr) === widgetId);
906
902
  if (toRemove) {
907
903
  this.grid.removeWidget(toRemove);
908
- const index = this.gridItems.findIndex(i => i.id === widgetId);
909
- this.gridItems[index].component.destroy();
910
- this.gridItems.splice(index, 1);
911
- }
912
- }
913
- /**
914
- * GridItemComponents are created dynamically, change detection won't trigger as there is no \@Input binding.
915
- * We have to update instance and run ChangeDetectionRef manually.
916
- */
917
- updateViewComponents(newConfigs) {
918
- // TODO: lookup by id would fasten the update
919
- for (const config of newConfigs) {
920
- const gridItem = this.gridItems.find(item => item.id === config.id);
921
- if (gridItem) {
922
- gridItem.component.setInput('widgetConfig', config);
923
- }
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()));
924
908
  }
925
909
  }
926
910
  hookEvents(grid) {
@@ -1287,12 +1271,12 @@ class SiGridComponent {
1287
1271
  }
1288
1272
  }
1289
1273
  if (changes.widgetCatalog) {
1290
- this.gridService.widgetCatalog = this.widgetCatalog();
1274
+ this.gridService.widgetCatalog.set(this.widgetCatalog());
1291
1275
  }
1292
1276
  }
1293
1277
  ngOnInit() {
1294
1278
  queueMicrotask(() => this.loadAndSubscribeWidgets());
1295
- this.gridService.widgetCatalog = this.widgetCatalog();
1279
+ this.gridService.widgetCatalog.set(this.widgetCatalog());
1296
1280
  }
1297
1281
  ngOnDestroy() {
1298
1282
  this.storeSubscription?.unsubscribe();
@@ -1401,7 +1385,7 @@ class SiGridComponent {
1401
1385
  */
1402
1386
  editWidgetInstance(widgetInstanceConfig) {
1403
1387
  // Need to edit a clone to avoid runtime editing
1404
- const widgetConfigClone = JSON.parse(JSON.stringify(widgetInstanceConfig));
1388
+ const widgetConfigClone = structuredClone(widgetInstanceConfig);
1405
1389
  if (this.emitWidgetInstanceEditEvents()) {
1406
1390
  this.widgetInstanceEdit.emit(widgetConfigClone);
1407
1391
  }
@@ -1981,11 +1965,9 @@ class SiFlexibleDashboardComponent {
1981
1965
  }
1982
1966
  });
1983
1967
  viewState = signal('dashboard');
1984
- subscriptions = [];
1985
1968
  widgetStorage = inject(SI_WIDGET_STORE);
1986
1969
  hideAddWidgetInstanceButton$ = new BehaviorSubject(this.hideAddWidgetInstanceButton());
1987
1970
  dashboardId$ = new Subject();
1988
- outputRefSubscription = [];
1989
1971
  toolbar = viewChild.required('toolbar');
1990
1972
  ngOnChanges(changes) {
1991
1973
  if (changes.dashboardId) {
@@ -2015,18 +1997,9 @@ class SiFlexibleDashboardComponent {
2015
1997
  }
2016
1998
  ngOnInit() {
2017
1999
  this.setupMenuItems();
2018
- const grid = this.grid();
2019
- this.outputRefSubscription.push(grid.widgetInstanceEdit.subscribe(widgetConfig => {
2020
- this.editWidgetInstance(widgetConfig);
2021
- }));
2022
- this.outputRefSubscription.push(grid.editable.subscribe(editable => {
2023
- this.editable.set(editable);
2024
- }));
2025
2000
  }
2026
2001
  ngOnDestroy() {
2027
2002
  this.dashboardId$.next(undefined);
2028
- this.subscriptions?.forEach(sub => sub.unsubscribe());
2029
- this.outputRefSubscription?.forEach(sub => sub.unsubscribe());
2030
2003
  }
2031
2004
  /**
2032
2005
  * Shows the widget catalog of the dashboard. If a widget instance is expanded
@@ -2104,14 +2077,11 @@ class SiFlexibleDashboardComponent {
2104
2077
  }
2105
2078
  proxyMenuItemAction(item) {
2106
2079
  if ('action' in item) {
2107
- if (!item.action || item.action instanceof String) {
2108
- return item;
2080
+ if (typeof item.action === 'function') {
2081
+ item.action = item.action.bind(this, this.grid());
2109
2082
  }
2110
2083
  else {
2111
- const realAction = item.action;
2112
- item.action = () => {
2113
- realAction(this.grid());
2114
- };
2084
+ return item;
2115
2085
  }
2116
2086
  }
2117
2087
  return item;
@@ -2120,11 +2090,11 @@ class SiFlexibleDashboardComponent {
2120
2090
  return this.widgetCatalog().find(widget => widget.id === id);
2121
2091
  }
2122
2092
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiFlexibleDashboardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
2123
- 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" }] });
2124
2094
  }
2125
2095
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.6", ngImport: i0, type: SiFlexibleDashboardComponent, decorators: [{
2126
2096
  type: Component,
2127
- 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"] }]
2128
2098
  }] });
2129
2099
 
2130
2100
  /**