@seniorsistemas/angular-components 17.6.0 → 17.6.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.
@@ -15221,9 +15221,23 @@ var SelectButtonComponent = /** @class */ (function () {
15221
15221
  var _this = this;
15222
15222
  if (!value)
15223
15223
  return;
15224
- value.forEach(function (item) {
15225
- _this.activeItems.add(item);
15226
- });
15224
+ this.activeItems.clear();
15225
+ if (Array.isArray(value)) {
15226
+ value.forEach(function (item) {
15227
+ _this.items.forEach(function (iItem) {
15228
+ if (_this._compareItems(item, iItem)) {
15229
+ _this.activeItems.add(iItem);
15230
+ }
15231
+ });
15232
+ });
15233
+ }
15234
+ else {
15235
+ this.items.forEach(function (iItem) {
15236
+ if (_this._compareItems(value, iItem)) {
15237
+ _this.activeItems.add(iItem);
15238
+ }
15239
+ });
15240
+ }
15227
15241
  };
15228
15242
  SelectButtonComponent.prototype.registerOnChange = function (onChange) {
15229
15243
  this.onChange = onChange;
@@ -15247,6 +15261,39 @@ var SelectButtonComponent = /** @class */ (function () {
15247
15261
  (_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this, __spread(this.activeItems));
15248
15262
  (_b = this.onTouched) === null || _b === void 0 ? void 0 : _b.call(this, __spread(this.activeItems));
15249
15263
  };
15264
+ SelectButtonComponent.prototype._compareItems = function (item1, item2) {
15265
+ var _compare = function (a, b) {
15266
+ var e_1, _a;
15267
+ if (a === b) {
15268
+ return true;
15269
+ }
15270
+ if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
15271
+ return false;
15272
+ }
15273
+ var keysA = Object.keys(a);
15274
+ var keysB = Object.keys(b);
15275
+ if (keysA.length !== keysB.length) {
15276
+ return false;
15277
+ }
15278
+ try {
15279
+ for (var keysA_1 = __values(keysA), keysA_1_1 = keysA_1.next(); !keysA_1_1.done; keysA_1_1 = keysA_1.next()) {
15280
+ var key = keysA_1_1.value;
15281
+ if (!keysB.includes(key) || !_compare(a[key], b[key])) {
15282
+ return false;
15283
+ }
15284
+ }
15285
+ }
15286
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
15287
+ finally {
15288
+ try {
15289
+ if (keysA_1_1 && !keysA_1_1.done && (_a = keysA_1.return)) _a.call(keysA_1);
15290
+ }
15291
+ finally { if (e_1) throw e_1.error; }
15292
+ }
15293
+ return true;
15294
+ };
15295
+ return _compare(item1, item2);
15296
+ };
15250
15297
  var SelectButtonComponent_1;
15251
15298
  __decorate([
15252
15299
  Input()
@@ -15264,11 +15311,13 @@ var SelectButtonComponent = /** @class */ (function () {
15264
15311
  Component({
15265
15312
  selector: "s-select-button",
15266
15313
  template: "<div\n class=\"select-button\"\n [ngClass]=\"{ 'select-button--disabled': disabled }\">\n <s-select-button-item\n *ngFor=\"let item of items; index as i\"\n [label]=\"item.label\"\n [active]=\"activeItems?.has(item)\"\n [disabled]=\"disabled || item.disabled\"\n [first]=\"i === 0\"\n [last]=\"i === items.length - 1\"\n (click)=\"onItemSelect(item)\">\n </s-select-button-item>\n</div>",
15267
- providers: [{
15314
+ providers: [
15315
+ {
15268
15316
  provide: NG_VALUE_ACCESSOR,
15269
15317
  useExisting: forwardRef(function () { return SelectButtonComponent_1; }),
15270
15318
  multi: true,
15271
- }],
15319
+ },
15320
+ ],
15272
15321
  styles: [".select-button{overflow:hidden}"]
15273
15322
  })
15274
15323
  ], SelectButtonComponent);