@seniorsistemas/angular-components 17.30.1 → 17.31.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.
@@ -1,4 +1,4 @@
1
- import { __decorate, __assign, __extends, __read, __spread, __awaiter, __generator, __param, __values, __rest } from 'tslib';
1
+ import { __decorate, __values, __assign, __extends, __read, __spread, __awaiter, __generator, __param, __rest } from 'tslib';
2
2
  import { EventEmitter, Input, Output, Component, ContentChildren, ViewChild, HostListener, forwardRef, NgModule, ɵɵdefineInjectable, Injectable, ElementRef, ApplicationRef, ComponentFactoryResolver, Injector, Renderer2, Directive, TemplateRef, ViewContainerRef, Pipe, ɵɵinject, HostBinding, ChangeDetectorRef, ViewChildren, InjectionToken, Inject, PLATFORM_ID, KeyValueDiffers, ViewEncapsulation, INJECTOR, NgZone, ContentChild, Optional } from '@angular/core';
3
3
  import { trigger, transition, style as style$7, animate, state, group, query, animateChild, stagger } from '@angular/animations';
4
4
  import { Subject, of, from, ReplaySubject, throwError, fromEvent, forkJoin, pipe } from 'rxjs';
@@ -182,68 +182,90 @@ var AccordionPanelComponent = /** @class */ (function () {
182
182
  var AccordionComponent = /** @class */ (function () {
183
183
  function AccordionComponent() {
184
184
  this.multiple = false;
185
- this._unsubscribe$ = new Subject();
186
- this._panels = [];
185
+ this.unsubscribe$ = new Subject();
186
+ this.panels = [];
187
187
  }
188
+ AccordionComponent.prototype.ngOnInit = function () {
189
+ this.validateInputs();
190
+ };
188
191
  AccordionComponent.prototype.ngAfterContentInit = function () {
189
- this._panels = this.panelsComponents.toArray();
190
- this._openSubs = new Array(this._panels.length);
191
- this._setBehavior(this.multiple);
192
- this._setupTabs();
192
+ this.panels = this.panelsComponents.toArray();
193
+ this.openSubs = new Array(this.panels.length);
194
+ this.setBehavior(this.multiple);
195
+ this.setupTabs();
193
196
  };
194
197
  AccordionComponent.prototype.ngOnChanges = function (changes) {
195
198
  if (changes.multiple) {
196
- this._setBehavior(changes.multiple.currentValue);
199
+ this.setBehavior(changes.multiple.currentValue);
197
200
  }
198
201
  };
199
202
  AccordionComponent.prototype.ngOnDestroy = function () {
200
- this._unsubscribe$.next();
201
- this._unsubscribe$.complete();
203
+ this.unsubscribe$.next();
204
+ this.unsubscribe$.complete();
202
205
  };
203
- AccordionComponent.prototype._setupTabs = function () {
204
- var _a;
205
- if ((_a = this._panels) === null || _a === void 0 ? void 0 : _a.length) {
206
+ AccordionComponent.prototype.validateInputs = function () {
207
+ if (!this.multiple && Array.isArray(this.activeIndex)) {
208
+ throw new Error("The activeIndex should not be an array when multiple is set to false.");
209
+ }
210
+ };
211
+ AccordionComponent.prototype.setupTabs = function () {
212
+ var e_1, _a;
213
+ var _this = this;
214
+ var _b;
215
+ if ((_b = this.panels) === null || _b === void 0 ? void 0 : _b.length) {
206
216
  if (this.activeIndex !== undefined && this.activeIndex !== null) {
207
- var activeTab = this._panels[this.activeIndex];
208
- if (!activeTab) {
217
+ var activeTabs = Array.isArray(this.activeIndex)
218
+ ? this.panels.filter(function (_, index) { return _this.activeIndex.includes(index); })
219
+ : [this.panels[this.activeIndex]];
220
+ if (activeTabs.length === 0) {
209
221
  throw new Error("activeIndex does not represent any panel.");
210
222
  }
211
- if (!activeTab.disabled) {
212
- this._panels[this.activeIndex].isOpen = true;
223
+ try {
224
+ for (var activeTabs_1 = __values(activeTabs), activeTabs_1_1 = activeTabs_1.next(); !activeTabs_1_1.done; activeTabs_1_1 = activeTabs_1.next()) {
225
+ var activeTab = activeTabs_1_1.value;
226
+ if (!activeTab.disabled) {
227
+ activeTab.isOpen = true;
228
+ }
229
+ }
230
+ }
231
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
232
+ finally {
233
+ try {
234
+ if (activeTabs_1_1 && !activeTabs_1_1.done && (_a = activeTabs_1.return)) _a.call(activeTabs_1);
235
+ }
236
+ finally { if (e_1) throw e_1.error; }
213
237
  }
214
238
  }
215
239
  }
216
240
  };
217
- AccordionComponent.prototype._closeOtherTabs = function (exception) {
218
- this._panels.forEach(function (panel, index) {
241
+ AccordionComponent.prototype.closeOtherTabs = function (exception) {
242
+ this.panels.forEach(function (panel, index) {
219
243
  if (index !== exception) {
220
244
  panel.isOpen = false;
221
245
  }
222
246
  });
223
247
  };
224
- AccordionComponent.prototype._setBehavior = function (multiple) {
248
+ AccordionComponent.prototype.setBehavior = function (multiple) {
225
249
  if (multiple) {
226
- this._enableMultiplePanelBehavior();
250
+ this.enableMultiplePanelBehavior();
227
251
  }
228
252
  else {
229
- this._enableSinglePanelBehavior();
253
+ this.enableSinglePanelBehavior();
230
254
  }
231
255
  };
232
- AccordionComponent.prototype._enableSinglePanelBehavior = function () {
256
+ AccordionComponent.prototype.enableSinglePanelBehavior = function () {
233
257
  var _this = this;
234
- this._panels.forEach(function (panel, index) {
235
- _this._openSubs[index] = panel.panelOpened
236
- .pipe(takeUntil(_this._unsubscribe$))
237
- .subscribe(function () {
238
- _this._closeOtherTabs(index);
258
+ this.panels.forEach(function (panel, index) {
259
+ _this.openSubs[index] = panel.panelOpened.pipe(takeUntil(_this.unsubscribe$)).subscribe(function () {
260
+ _this.closeOtherTabs(index);
239
261
  });
240
262
  });
241
263
  };
242
- AccordionComponent.prototype._enableMultiplePanelBehavior = function () {
264
+ AccordionComponent.prototype.enableMultiplePanelBehavior = function () {
243
265
  var _this = this;
244
- this._panels.forEach(function (_, index) {
245
- if (_this._openSubs[index]) {
246
- _this._openSubs[index].unsubscribe();
266
+ this.panels.forEach(function (_, index) {
267
+ if (_this.openSubs[index]) {
268
+ _this.openSubs[index].unsubscribe();
247
269
  }
248
270
  });
249
271
  };