otimus-library 0.3.64 → 0.3.65

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.
@@ -2391,13 +2391,33 @@ class OcAccordionComponent {
2391
2391
  this.styleThemeService = styleThemeService;
2392
2392
  this.ocAlternate = true;
2393
2393
  this.ocStyle = 'otimus';
2394
+ this.ocDynamicItems = false;
2395
+ this.itemSubscriptions = [];
2394
2396
  }
2395
2397
  ngAfterViewInit() {
2396
- this.items.forEach((item, i) => {
2398
+ this.subscribeToItems();
2399
+ if (this.ocDynamicItems) {
2400
+ this.changesSubscription = this.items.changes.subscribe(() => {
2401
+ this.subscribeToItems();
2402
+ });
2403
+ }
2404
+ }
2405
+ ngOnDestroy() {
2406
+ this.cleanupSubscriptions();
2407
+ this.changesSubscription?.unsubscribe();
2408
+ }
2409
+ subscribeToItems() {
2410
+ this.cleanupSubscriptions();
2411
+ this.items.forEach((item) => {
2397
2412
  item.ocStyle = this.styleThemeService.getStyleTheme() || this.ocStyle;
2398
- item.closeAllItems.subscribe(() => this.closeAllItems());
2413
+ const sub = item.closeAllItems.subscribe(() => this.closeAllItems());
2414
+ this.itemSubscriptions.push(sub);
2399
2415
  });
2400
2416
  }
2417
+ cleanupSubscriptions() {
2418
+ this.itemSubscriptions.forEach((sub) => sub.unsubscribe());
2419
+ this.itemSubscriptions = [];
2420
+ }
2401
2421
  closeAllItems() {
2402
2422
  if (this.ocAlternate) {
2403
2423
  this.items.forEach((item) => (item.ocIsOpen = false));
@@ -2413,7 +2433,7 @@ class OcAccordionComponent {
2413
2433
  });
2414
2434
  }
2415
2435
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: OcAccordionComponent, deps: [{ token: StyleThemeService }], target: i0.ɵɵFactoryTarget.Component }); }
2416
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: OcAccordionComponent, isStandalone: true, selector: "oc-accordion", inputs: { ocAlternate: "ocAlternate", ocCurrentIndex: "ocCurrentIndex", ocStyle: "ocStyle" }, queries: [{ propertyName: "items", predicate: OcAccordionItemComponent }], ngImport: i0, template: "<div>\n <ng-content></ng-content>\n</div>", styles: [".oc-accordion{display:flex;flex-direction:column}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] }); }
2436
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: OcAccordionComponent, isStandalone: true, selector: "oc-accordion", inputs: { ocAlternate: "ocAlternate", ocCurrentIndex: "ocCurrentIndex", ocStyle: "ocStyle", ocDynamicItems: "ocDynamicItems" }, queries: [{ propertyName: "items", predicate: OcAccordionItemComponent }], ngImport: i0, template: "<div>\n <ng-content></ng-content>\n</div>", styles: [".oc-accordion{display:flex;flex-direction:column}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] }); }
2417
2437
  }
2418
2438
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: OcAccordionComponent, decorators: [{
2419
2439
  type: Component,
@@ -2427,6 +2447,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
2427
2447
  type: Input
2428
2448
  }], ocStyle: [{
2429
2449
  type: Input
2450
+ }], ocDynamicItems: [{
2451
+ type: Input
2430
2452
  }] } });
2431
2453
 
2432
2454
  class OcMessageComponent {