@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.
- package/bundles/seniorsistemas-angular-components.umd.js +53 -31
- package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js +1 -1
- package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
- package/components/accordion/accordion.component.d.ts +13 -11
- package/esm2015/components/accordion/accordion.component.js +41 -31
- package/esm5/components/accordion/accordion.component.js +55 -33
- package/fesm2015/seniorsistemas-angular-components.js +40 -30
- package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
- package/fesm5/seniorsistemas-angular-components.js +54 -32
- package/fesm5/seniorsistemas-angular-components.js.map +1 -1
- package/package.json +1 -1
- package/seniorsistemas-angular-components.metadata.json +1 -1
|
@@ -328,68 +328,90 @@
|
|
|
328
328
|
var AccordionComponent = /** @class */ (function () {
|
|
329
329
|
function AccordionComponent() {
|
|
330
330
|
this.multiple = false;
|
|
331
|
-
this.
|
|
332
|
-
this.
|
|
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.
|
|
336
|
-
this.
|
|
337
|
-
this.
|
|
338
|
-
this.
|
|
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.
|
|
345
|
+
this.setBehavior(changes.multiple.currentValue);
|
|
343
346
|
}
|
|
344
347
|
};
|
|
345
348
|
AccordionComponent.prototype.ngOnDestroy = function () {
|
|
346
|
-
this.
|
|
347
|
-
this.
|
|
349
|
+
this.unsubscribe$.next();
|
|
350
|
+
this.unsubscribe$.complete();
|
|
348
351
|
};
|
|
349
|
-
AccordionComponent.prototype.
|
|
350
|
-
|
|
351
|
-
|
|
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
|
|
354
|
-
|
|
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
|
-
|
|
358
|
-
|
|
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.
|
|
364
|
-
this.
|
|
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.
|
|
394
|
+
AccordionComponent.prototype.setBehavior = function (multiple) {
|
|
371
395
|
if (multiple) {
|
|
372
|
-
this.
|
|
396
|
+
this.enableMultiplePanelBehavior();
|
|
373
397
|
}
|
|
374
398
|
else {
|
|
375
|
-
this.
|
|
399
|
+
this.enableSinglePanelBehavior();
|
|
376
400
|
}
|
|
377
401
|
};
|
|
378
|
-
AccordionComponent.prototype.
|
|
402
|
+
AccordionComponent.prototype.enableSinglePanelBehavior = function () {
|
|
379
403
|
var _this = this;
|
|
380
|
-
this.
|
|
381
|
-
_this.
|
|
382
|
-
.
|
|
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.
|
|
410
|
+
AccordionComponent.prototype.enableMultiplePanelBehavior = function () {
|
|
389
411
|
var _this = this;
|
|
390
|
-
this.
|
|
391
|
-
if (_this.
|
|
392
|
-
_this.
|
|
412
|
+
this.panels.forEach(function (_, index) {
|
|
413
|
+
if (_this.openSubs[index]) {
|
|
414
|
+
_this.openSubs[index].unsubscribe();
|
|
393
415
|
}
|
|
394
416
|
});
|
|
395
417
|
};
|