@seniorsistemas/angular-components 16.12.0 → 16.12.2

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.
@@ -2632,6 +2632,9 @@ class BooleanSwitchField extends Field {
2632
2632
  constructor(config) {
2633
2633
  super(config);
2634
2634
  this.onChange = config.onChange;
2635
+ if (config.optionsLabel) {
2636
+ this.optionsLabel = new BooleanOptionsLabel(config.optionsLabel);
2637
+ }
2635
2638
  this.representedBy = "switch";
2636
2639
  }
2637
2640
  }
@@ -5163,20 +5166,7 @@ let TableFrozenPositionDirective = class TableFrozenPositionDirective {
5163
5166
  this.table.styleClass = (this.table.styleClass || "") + " s-table-frozen-position";
5164
5167
  this.setUpTableEvents();
5165
5168
  window.addEventListener("resize", this.handleWindowResize.bind(this));
5166
- const componentId = new Date().getTime();
5167
5169
  const htmlHead = document.getElementsByTagName("head")[0];
5168
- this.resetRowHeightClassName = `resetTableRowsHeight_${componentId}`;
5169
- const styleReset = document.createElement("style");
5170
- styleReset.innerHTML = `.${this.resetRowHeightClassName} tbody > tr, .${this.resetRowHeightClassName} thead > tr { height: auto; }`;
5171
- htmlHead.appendChild(styleReset);
5172
- this.fixBodyRowClassName = `fixTableBodyRowsHeight_${componentId}`;
5173
- this.styleFixBodyRowHeight = document.createElement("style");
5174
- this.styleFixBodyRowHeight.innerHTML = `.${this.fixBodyRowClassName} tbody > tr { height: auto; }`;
5175
- htmlHead.appendChild(this.styleFixBodyRowHeight);
5176
- this.fixHeadRowClassName = `fixTableHeadRowsHeight_${componentId}`;
5177
- this.styleFixHeadRowHeight = document.createElement("style");
5178
- this.styleFixHeadRowHeight.innerHTML = `.${this.fixHeadRowClassName} thead > tr { height: auto; }`;
5179
- htmlHead.appendChild(this.styleFixHeadRowHeight);
5180
5170
  const expandFrozenStyle = document.createElement("style");
5181
5171
  expandFrozenStyle.innerHTML = ".s-table-frozen-position .ui-table-frozen-view .sds-expanded-row > td { visibility: hidden; }";
5182
5172
  htmlHead.appendChild(expandFrozenStyle);
@@ -5298,44 +5288,39 @@ let TableFrozenPositionDirective = class TableFrozenPositionDirective {
5298
5288
  synchronizeRowHeight() {
5299
5289
  const tableBodyWrappers = this.el.nativeElement.getElementsByClassName("ui-table-scrollable-body");
5300
5290
  const tableBodies = [...tableBodyWrappers].map(divWrapper => [...divWrapper.childNodes].find(p => p.tagName === "TABLE"));
5301
- this.recalculateDefaultRowHeight(tableBodies);
5302
- this.applyMaxRowHeight(tableBodies);
5291
+ this._resetRowHeight(tableBodies);
5292
+ this._applyMaxRowHeight(tableBodies);
5303
5293
  const tableHeadWrappers = this.el.nativeElement.getElementsByClassName("ui-table-scrollable-header-box");
5304
5294
  const tableHeads = [...tableHeadWrappers].map(divWrapper => [...divWrapper.childNodes].find(p => p.tagName === "TABLE"));
5305
- this.recalculateDefaultRowHeight(tableHeads);
5306
- this.applyMaxRowHeight(tableHeads, true);
5295
+ this._resetRowHeight(tableHeads);
5296
+ this._applyMaxRowHeight(tableHeads);
5307
5297
  }
5308
- recalculateDefaultRowHeight(tables) {
5309
- for (const table of tables) {
5310
- table.classList.remove(this.fixBodyRowClassName);
5311
- table.classList.remove(this.fixHeadRowClassName);
5312
- table.classList.add(this.resetRowHeightClassName);
5298
+ _applyMaxRowHeight(tables) {
5299
+ if (!tables || !tables.length) {
5300
+ return;
5313
5301
  }
5314
- }
5315
- applyMaxRowHeight(tables, isHead = false) {
5316
- const rowSizes = [];
5317
- for (const table of tables) {
5318
- for (const tr of table.rows) {
5319
- if (tr.classList.contains("sds-expanded-row"))
5320
- continue;
5321
- rowSizes.push(tr.getBoundingClientRect().height);
5322
- }
5302
+ const lengths = tables.map(table => table.rows.length);
5303
+ const maxLength = lengths.reduce((accumulator, currentValue) => Math.max(accumulator, currentValue), lengths[0]);
5304
+ const minLength = lengths.reduce((accumulator, currentValue) => Math.min(accumulator, currentValue), lengths[0]);
5305
+ if (maxLength !== minLength) {
5306
+ throw new Error("The number of rows in both tables must be the same");
5323
5307
  }
5324
- if (!rowSizes.length)
5325
- return;
5326
- const maxHeight = Math.max(...rowSizes);
5327
- if (isHead) {
5328
- this.styleFixHeadRowHeight.innerHTML = `.${this.fixHeadRowClassName} thead > tr { height: ${maxHeight}px; }`;
5308
+ const table = tables[0];
5309
+ for (let i = 0; i < table.rows.length; i++) {
5310
+ const trs = [];
5329
5311
  for (const table of tables) {
5330
- table.classList.remove(this.resetRowHeightClassName);
5331
- table.classList.add(this.fixHeadRowClassName);
5312
+ trs.push(table.rows[i]);
5313
+ }
5314
+ const max = trs.reduce((accumulator, currentValue) => Math.max(accumulator, currentValue.getBoundingClientRect().height), trs[0].getBoundingClientRect().height);
5315
+ for (const tr of trs) {
5316
+ tr.style.height = `${max}px`;
5332
5317
  }
5333
5318
  }
5334
- else {
5335
- this.styleFixBodyRowHeight.innerHTML = `.${this.fixBodyRowClassName} tbody > tr { height: ${maxHeight}px; }`;
5336
- for (const table of tables) {
5337
- table.classList.remove(this.resetRowHeightClassName);
5338
- table.classList.add(this.fixBodyRowClassName);
5319
+ }
5320
+ _resetRowHeight(tables) {
5321
+ for (const table of tables) {
5322
+ for (const row of table.rows) {
5323
+ row.style.height = "unset";
5339
5324
  }
5340
5325
  }
5341
5326
  }
@@ -6448,7 +6433,7 @@ __decorate([
6448
6433
  ], BooleanSwitchFieldComponent.prototype, "formControl", void 0);
6449
6434
  BooleanSwitchFieldComponent = __decorate([
6450
6435
  Component({
6451
- template: "<div class=\"ui-g\">\n <p-inputSwitch\n [id]=\"(field.id || field.name)\"\n [name]=\"field.name\"\n [formControl]=\"formControl\"\n [sTooltip]=\"field.tooltip\"\n tooltipPosition=\"top\"\n (onChange)=\"field.onChange ? field.onChange($event) : null\">\n </p-inputSwitch>\n</div>"
6436
+ template: "<div class=\"ui-grid ui-grid-responsive ui-grid-pad ui-fluid\">\n <div class=\"ui-grid-row\">\n <div class=\"i-grid-col-1\">\n <p-inputSwitch [id]=\"(field.id || field.name)\" [name]=\"field.name\" [formControl]=\"formControl\"\n [sTooltip]=\"field.tooltip\" tooltipPosition=\"top\"\n (onChange)=\"field.onChange ? field.onChange($event) : null\">\n </p-inputSwitch>\n </div>\n <div class=\"i-grid-col-1\" *ngIf=\"field.optionsLabel\">\n <ng-container *ngIf=\"formControl.value; else caseFalse\">\n <span>{{ field.optionsLabel.true }}</span>\n </ng-container>\n <ng-template #caseFalse>\n <span>{{ field.optionsLabel.false }}</span>\n </ng-template>\n </div>\n </div>\n</div>"
6452
6437
  })
6453
6438
  ], BooleanSwitchFieldComponent);
6454
6439