@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.
@@ -328,68 +328,90 @@
328
328
  var AccordionComponent = /** @class */ (function () {
329
329
  function AccordionComponent() {
330
330
  this.multiple = false;
331
- this._unsubscribe$ = new rxjs.Subject();
332
- this._panels = [];
331
+ this.unsubscribe$ = new rxjs.Subject();
332
+ this.panels = [];
333
333
  }
334
+ AccordionComponent.prototype.ngOnInit = function () {
335
+ this.validateInputs();
336
+ };
334
337
  AccordionComponent.prototype.ngAfterContentInit = function () {
335
- this._panels = this.panelsComponents.toArray();
336
- this._openSubs = new Array(this._panels.length);
337
- this._setBehavior(this.multiple);
338
- this._setupTabs();
338
+ this.panels = this.panelsComponents.toArray();
339
+ this.openSubs = new Array(this.panels.length);
340
+ this.setBehavior(this.multiple);
341
+ this.setupTabs();
339
342
  };
340
343
  AccordionComponent.prototype.ngOnChanges = function (changes) {
341
344
  if (changes.multiple) {
342
- this._setBehavior(changes.multiple.currentValue);
345
+ this.setBehavior(changes.multiple.currentValue);
343
346
  }
344
347
  };
345
348
  AccordionComponent.prototype.ngOnDestroy = function () {
346
- this._unsubscribe$.next();
347
- this._unsubscribe$.complete();
349
+ this.unsubscribe$.next();
350
+ this.unsubscribe$.complete();
348
351
  };
349
- AccordionComponent.prototype._setupTabs = function () {
350
- var _a;
351
- if ((_a = this._panels) === null || _a === void 0 ? void 0 : _a.length) {
352
+ AccordionComponent.prototype.validateInputs = function () {
353
+ if (!this.multiple && Array.isArray(this.activeIndex)) {
354
+ throw new Error("The activeIndex should not be an array when multiple is set to false.");
355
+ }
356
+ };
357
+ AccordionComponent.prototype.setupTabs = function () {
358
+ var e_1, _a;
359
+ var _this = this;
360
+ var _b;
361
+ if ((_b = this.panels) === null || _b === void 0 ? void 0 : _b.length) {
352
362
  if (this.activeIndex !== undefined && this.activeIndex !== null) {
353
- var activeTab = this._panels[this.activeIndex];
354
- if (!activeTab) {
363
+ var activeTabs = Array.isArray(this.activeIndex)
364
+ ? this.panels.filter(function (_, index) { return _this.activeIndex.includes(index); })
365
+ : [this.panels[this.activeIndex]];
366
+ if (activeTabs.length === 0) {
355
367
  throw new Error("activeIndex does not represent any panel.");
356
368
  }
357
- if (!activeTab.disabled) {
358
- this._panels[this.activeIndex].isOpen = true;
369
+ try {
370
+ for (var activeTabs_1 = __values(activeTabs), activeTabs_1_1 = activeTabs_1.next(); !activeTabs_1_1.done; activeTabs_1_1 = activeTabs_1.next()) {
371
+ var activeTab = activeTabs_1_1.value;
372
+ if (!activeTab.disabled) {
373
+ activeTab.isOpen = true;
374
+ }
375
+ }
376
+ }
377
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
378
+ finally {
379
+ try {
380
+ if (activeTabs_1_1 && !activeTabs_1_1.done && (_a = activeTabs_1.return)) _a.call(activeTabs_1);
381
+ }
382
+ finally { if (e_1) throw e_1.error; }
359
383
  }
360
384
  }
361
385
  }
362
386
  };
363
- AccordionComponent.prototype._closeOtherTabs = function (exception) {
364
- this._panels.forEach(function (panel, index) {
387
+ AccordionComponent.prototype.closeOtherTabs = function (exception) {
388
+ this.panels.forEach(function (panel, index) {
365
389
  if (index !== exception) {
366
390
  panel.isOpen = false;
367
391
  }
368
392
  });
369
393
  };
370
- AccordionComponent.prototype._setBehavior = function (multiple) {
394
+ AccordionComponent.prototype.setBehavior = function (multiple) {
371
395
  if (multiple) {
372
- this._enableMultiplePanelBehavior();
396
+ this.enableMultiplePanelBehavior();
373
397
  }
374
398
  else {
375
- this._enableSinglePanelBehavior();
399
+ this.enableSinglePanelBehavior();
376
400
  }
377
401
  };
378
- AccordionComponent.prototype._enableSinglePanelBehavior = function () {
402
+ AccordionComponent.prototype.enableSinglePanelBehavior = function () {
379
403
  var _this = this;
380
- this._panels.forEach(function (panel, index) {
381
- _this._openSubs[index] = panel.panelOpened
382
- .pipe(operators.takeUntil(_this._unsubscribe$))
383
- .subscribe(function () {
384
- _this._closeOtherTabs(index);
404
+ this.panels.forEach(function (panel, index) {
405
+ _this.openSubs[index] = panel.panelOpened.pipe(operators.takeUntil(_this.unsubscribe$)).subscribe(function () {
406
+ _this.closeOtherTabs(index);
385
407
  });
386
408
  });
387
409
  };
388
- AccordionComponent.prototype._enableMultiplePanelBehavior = function () {
410
+ AccordionComponent.prototype.enableMultiplePanelBehavior = function () {
389
411
  var _this = this;
390
- this._panels.forEach(function (_, index) {
391
- if (_this._openSubs[index]) {
392
- _this._openSubs[index].unsubscribe();
412
+ this.panels.forEach(function (_, index) {
413
+ if (_this.openSubs[index]) {
414
+ _this.openSubs[index].unsubscribe();
393
415
  }
394
416
  });
395
417
  };