@seniorsistemas/angular-components 15.0.1 → 15.0.3

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.
Files changed (25) hide show
  1. package/bundles/seniorsistemas-angular-components.umd.js +95 -70
  2. package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-angular-components.umd.min.js +2 -2
  4. package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
  5. package/components/table/table-column/table-columns.component.d.ts +10 -3
  6. package/components/token-list/index.d.ts +3 -2
  7. package/components/token-list/models/index.d.ts +1 -0
  8. package/components/token-list/models/token.d.ts +5 -0
  9. package/components/token-list/token-list.component.d.ts +1 -4
  10. package/esm2015/components/table/table-column/table-columns.component.js +97 -73
  11. package/esm2015/components/token-list/index.js +3 -3
  12. package/esm2015/components/token-list/models/index.js +1 -0
  13. package/esm2015/components/token-list/models/token.js +1 -0
  14. package/esm2015/components/token-list/token-list.component.js +2 -2
  15. package/esm5/components/table/table-column/table-columns.component.js +97 -73
  16. package/esm5/components/token-list/index.js +3 -3
  17. package/esm5/components/token-list/models/index.js +1 -0
  18. package/esm5/components/token-list/models/token.js +1 -0
  19. package/esm5/components/token-list/token-list.component.js +2 -2
  20. package/fesm2015/seniorsistemas-angular-components.js +95 -70
  21. package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
  22. package/fesm5/seniorsistemas-angular-components.js +95 -70
  23. package/fesm5/seniorsistemas-angular-components.js.map +1 -1
  24. package/package.json +1 -1
  25. package/seniorsistemas-angular-components.metadata.json +1 -1
@@ -4324,12 +4324,15 @@
4324
4324
  };
4325
4325
  TableColumnsComponent.prototype.validateComponentAttributes = function (changes) {
4326
4326
  var _a, _b, _c;
4327
- if (!((_a = changes.columns) === null || _a === void 0 ? void 0 : _a.currentValue))
4327
+ if (!((_a = changes.columns) === null || _a === void 0 ? void 0 : _a.currentValue)) {
4328
4328
  throw new Error("The 'columns' attribute must be informed!");
4329
- if (!((_b = changes.rowValue) === null || _b === void 0 ? void 0 : _b.currentValue))
4329
+ }
4330
+ if (!((_b = changes.rowValue) === null || _b === void 0 ? void 0 : _b.currentValue)) {
4330
4331
  throw new Error("The 'rowValue' attribute must be informed!");
4331
- if (!((_c = changes.locale) === null || _c === void 0 ? void 0 : _c.currentValue))
4332
+ }
4333
+ if (!((_c = changes.locale) === null || _c === void 0 ? void 0 : _c.currentValue)) {
4332
4334
  throw new Error("The 'locale' attribute must be informed!");
4335
+ }
4333
4336
  };
4334
4337
  TableColumnsComponent.prototype.createColumnsTemplate = function (changes) {
4335
4338
  var _this = this;
@@ -4340,14 +4343,61 @@
4340
4343
  columns.forEach(function (column) { return _this.formattedColumns.push(_this.getColumnValue(column, rowValue, locale)); });
4341
4344
  this.viewContainerRef.createEmbeddedView(this.columnsTemplate);
4342
4345
  };
4346
+ TableColumnsComponent.prototype.getColumnSeparator = function (column) {
4347
+ return column.separator ? column.separator : " - ";
4348
+ };
4349
+ TableColumnsComponent.prototype.getTranslationPrefix = function (column) {
4350
+ return column.prefix ? column.prefix : this.hostProjectConfigs.domain + "." + this.hostProjectConfigs.service + ".";
4351
+ };
4352
+ TableColumnsComponent.prototype.isAttributeValueInvalid = function (attributeValue) {
4353
+ return attributeValue === null || attributeValue === undefined || (this.isArray(attributeValue) && !attributeValue.length);
4354
+ };
4355
+ TableColumnsComponent.prototype.getFormattedColumnValue = function (column, columnValue, unifiedColumnValues, uninformedText, uninformedNumber) {
4356
+ if (uninformedNumber === column.attributes.length) {
4357
+ return uninformedText;
4358
+ }
4359
+ if (column.type === exports.EnumColumnFieldType.TOKENS) {
4360
+ return [].concat.apply([], columnValue.filter(function (values) { return values !== uninformedText; }));
4361
+ }
4362
+ return unifiedColumnValues;
4363
+ };
4364
+ TableColumnsComponent.prototype.getAttributeValue = function (attribute, rowValue) {
4365
+ var attributeValue;
4366
+ attribute
4367
+ .split("/")
4368
+ .forEach(function (value) {
4369
+ if (!attributeValue) {
4370
+ value
4371
+ .split(".")
4372
+ .forEach(function (val, i) {
4373
+ if (!rowValue) {
4374
+ return;
4375
+ }
4376
+ if (i === 0) {
4377
+ attributeValue = rowValue[val];
4378
+ }
4379
+ else {
4380
+ if (attributeValue) {
4381
+ attributeValue = attributeValue[val];
4382
+ }
4383
+ }
4384
+ });
4385
+ }
4386
+ });
4387
+ return attributeValue;
4388
+ };
4389
+ TableColumnsComponent.prototype.getNumberConfigs = function (column, locale) {
4390
+ return __assign(__assign({}, locale.number), { scale: column.scale !== null && column.scale !== undefined
4391
+ ? this.getColumnScale(column.scale)
4392
+ : locale.number.scale, prefix: locale.number.currencySymbol + " " });
4393
+ };
4394
+ TableColumnsComponent.prototype.getDateFormat = function (column, locale) {
4395
+ return column.dateFormat ? column.dateFormat : locale.calendar.dateFormat;
4396
+ };
4343
4397
  TableColumnsComponent.prototype.getColumnValue = function (column, rowValue, locale) {
4344
4398
  var _this = this;
4345
- var prefix = column.prefix
4346
- ? column.prefix
4347
- : this.hostProjectConfigs.domain + "." + this.hostProjectConfigs.service + ".";
4348
- var separator = column.separator
4349
- ? column.separator
4350
- : " - ";
4399
+ var prefix = this.getTranslationPrefix(column);
4400
+ var separator = this.getColumnSeparator(column);
4351
4401
  var uninformed = this.translate.instant(prefix + "empty_label");
4352
4402
  var style = column.style;
4353
4403
  var badgeClass = {
@@ -4355,69 +4405,40 @@
4355
4405
  };
4356
4406
  var columnValue = column.attributes
4357
4407
  .map(function (attribute) {
4358
- var attributeValue;
4359
- attribute
4360
- .split("/")
4361
- .forEach(function (value) {
4362
- if (!attributeValue) {
4363
- value
4364
- .split(".")
4365
- .forEach(function (val, i) {
4366
- if (rowValue) {
4367
- if (i === 0) {
4368
- attributeValue = rowValue[val];
4369
- }
4370
- else if (attributeValue) {
4371
- attributeValue = attributeValue[val];
4372
- }
4373
- }
4374
- });
4375
- }
4376
- });
4377
- if (attributeValue === null || attributeValue === undefined || (_this.isArray(attributeValue) && !attributeValue.length)) {
4408
+ var _a;
4409
+ var attributeValue = _this.getAttributeValue(attribute, rowValue);
4410
+ if (_this.isAttributeValueInvalid(attributeValue)) {
4378
4411
  return uninformed;
4379
4412
  }
4380
- else {
4381
- var numberConfigs = __assign(__assign({}, locale.number), { scale: column.scale ? _this.getColumnScale(column.scale) : locale.number.scale, prefix: locale.number.currencySymbol + " " });
4382
- switch (column.type) {
4383
- case exports.EnumColumnFieldType.ENUM:
4384
- if (column.badgeConfigs && column.badgeConfigs.length) {
4385
- badgeClass = _this.getBadgeClass(attributeValue, column.badgeConfigs);
4386
- }
4387
- return _this.translate.instant(column.enumPrefix + attributeValue.toString().toLowerCase());
4388
- case exports.EnumColumnFieldType.CURRENCY:
4389
- return ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
4390
- case exports.EnumColumnFieldType.DATE:
4391
- var dateFormat = column.dateFormat ? column.dateFormat : locale.calendar.dateFormat;
4392
- return moment_(attributeValue).format(dateFormat);
4393
- case exports.EnumColumnFieldType.BOOLEAN:
4394
- var value = attributeValue ? "yes" : "no";
4395
- return _this.translate.instant(prefix + value);
4396
- case exports.EnumColumnFieldType.LINK:
4397
- case exports.EnumColumnFieldType.STRING:
4398
- return attributeValue;
4399
- case exports.EnumColumnFieldType.NUMBER:
4400
- numberConfigs.prefix = "";
4401
- return ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
4402
- case exports.EnumColumnFieldType.TOKENS:
4403
- return _this.getTokens(attributeValue);
4404
- }
4413
+ var numberConfigs = _this.getNumberConfigs(column, locale);
4414
+ switch (column.type) {
4415
+ case exports.EnumColumnFieldType.ENUM:
4416
+ if ((_a = column.badgeConfigs) === null || _a === void 0 ? void 0 : _a.length) {
4417
+ badgeClass = _this.getBadgeClass(attributeValue, column.badgeConfigs);
4418
+ }
4419
+ return _this.translate.instant(column.enumPrefix + attributeValue.toString().toLowerCase());
4420
+ case exports.EnumColumnFieldType.CURRENCY:
4421
+ return ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
4422
+ case exports.EnumColumnFieldType.DATE:
4423
+ var dateFormat = _this.getDateFormat(column, locale);
4424
+ return moment_(attributeValue).format(dateFormat);
4425
+ case exports.EnumColumnFieldType.BOOLEAN:
4426
+ var value = attributeValue ? "yes" : "no";
4427
+ return _this.translate.instant(prefix + value);
4428
+ case exports.EnumColumnFieldType.NUMBER:
4429
+ numberConfigs.prefix = "";
4430
+ return ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
4431
+ case exports.EnumColumnFieldType.TOKENS:
4432
+ return _this.getTokens(attributeValue);
4433
+ default:
4434
+ return attributeValue;
4405
4435
  }
4406
4436
  });
4407
4437
  var unifiedColumnValues = columnValue.join(separator);
4408
4438
  var uninformedNumber = unifiedColumnValues
4409
4439
  .split(separator)
4410
4440
  .filter(function (value) { return value === uninformed; }).length;
4411
- var formattedColumnValue;
4412
- if (uninformedNumber === column.attributes.length) {
4413
- formattedColumnValue = uninformed;
4414
- }
4415
- else if (column.type === exports.EnumColumnFieldType.TOKENS) {
4416
- formattedColumnValue = [].concat.apply([], columnValue.filter(function (values) { return values !== uninformed; }));
4417
- }
4418
- else {
4419
- formattedColumnValue = unifiedColumnValues;
4420
- }
4441
+ var formattedColumnValue = this.getFormattedColumnValue(column, columnValue, unifiedColumnValues, uninformed, uninformedNumber);
4421
4442
  return {
4422
4443
  style: style,
4423
4444
  columnValue: formattedColumnValue,
@@ -4452,18 +4473,21 @@
4452
4473
  }
4453
4474
  return tooltip;
4454
4475
  }
4476
+ return "";
4455
4477
  };
4456
4478
  TableColumnsComponent.prototype.isNumber = function (value) {
4457
4479
  return !(new BigNumber__default(value).isNaN());
4458
4480
  };
4459
4481
  TableColumnsComponent.prototype.getTokens = function (values) {
4460
- if (!this.isArray(values))
4482
+ if (!this.isArray(values)) {
4461
4483
  throw new Error("To use tokens an array must be informed");
4462
- // tslint:disable-next-line: max-line-length
4463
- if (!this.isValidTokenArray(values))
4464
- throw new Error("Not a valid token array. Token array must be a primitive values array or an objects with label attribute array");
4465
- if (this.isLabelObjectArray(values))
4484
+ }
4485
+ if (!this.isValidTokenArray(values)) {
4486
+ throw new Error("Not a valid token array. Must be a primitive values array or an objects with label attribute array");
4487
+ }
4488
+ if (this.isLabelObjectArray(values)) {
4466
4489
  return values;
4490
+ }
4467
4491
  return values
4468
4492
  .filter(function (value) { return value !== undefined && value !== null; })
4469
4493
  .map(function (value) {
@@ -4498,6 +4522,7 @@
4498
4522
  };
4499
4523
  });
4500
4524
  }
4525
+ return null;
4501
4526
  };
4502
4527
  TableColumnsComponent.ctorParameters = function () { return [
4503
4528
  { type: core.ViewContainerRef },
@@ -4559,7 +4584,7 @@
4559
4584
  TokenListComponent = TokenListComponent_1 = __decorate([
4560
4585
  core.Component({
4561
4586
  selector: "s-token-list",
4562
- template: "<div\n [id]=\"id\"\n class=\"token-list\">\n <ng-container *ngFor=\"let token of tokens\">\n <span\n [id]=\"token.id\"\n class=\"token\"\n [ngClass]=\"{ 'no-pointer-events': hidePointerEvents }\">\n <a\n [id]=\"(token.id || 'token') + '-label'\"\n class=\"token-label\"\n (click)=\"tokenSelected.next(token)\">\n {{ token.label }}\n </a>\n <span\n *ngIf=\"removableTokens\"\n [id]=\"token.id + '-remove'\"\n class=\"token-icon fa fa-fw fa-close\"\n (click)=\"tokenRemoved.next(token)\">\n </span>\n </span>\n </ng-container>\n</div>",
4587
+ template: "<div\n [id]=\"id\"\n class=\"token-list\">\n <ng-container *ngFor=\"let token of tokens\">\n <span\n [id]=\"token.id\"\n class=\"token\"\n [ngClass]=\"{ 'no-pointer-events': hidePointerEvents }\">\n <a\n [id]=\"(token.id || 'token') + '-label'\"\n class=\"token-label\"\n (click)=\"tokenSelected.next(token)\">\n {{ token.label }}\n </a>\n <span\n *ngIf=\"removableTokens && !token.notRemovable\"\n [id]=\"token.id + '-remove'\"\n class=\"token-icon fa fa-fw fa-close\"\n (click)=\"tokenRemoved.next(token)\">\n </span>\n </span>\n </ng-container>\n</div>",
4563
4588
  styles: [".no-pointer-events{pointer-events:none}.token-list{-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-wrap:wrap;flex-wrap:wrap;max-width:100%;padding:0 10px;text-transform:none}.token-list .token{-ms-flex-align:center;align-items:center;background-color:#ccc;border-radius:4px;color:#333;display:-ms-flexbox;display:flex;font:400 12px/150% \"Open Sans\",sans-serif;margin:2px 5px 0 0;max-width:100%;padding:2px 8px}.token-list .token-label{max-width:50ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.token-list .token:focus,.token-list .token:hover{background-color:#e5eaea}.token-list .token a{text-decoration:none;color:#333}"]
4564
4589
  })
4565
4590
  ], TokenListComponent);