@seniorsistemas/angular-components 17.8.15 → 17.9.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.
Files changed (31) hide show
  1. package/bundles/seniorsistemas-angular-components.umd.js +63 -30
  2. package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-angular-components.umd.min.js +1 -1
  4. package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
  5. package/components/locale/pipes/numeric.pipe.d.ts +1 -1
  6. package/components/locale/services/numeric.service.d.ts +2 -2
  7. package/components/table/table-column/models/column.interface.d.ts +1 -0
  8. package/components/table/table-column/table-columns.component.d.ts +3 -1
  9. package/esm2015/components/locale/pipes/numeric.pipe.js +2 -2
  10. package/esm2015/components/locale/services/numeric.service.js +8 -5
  11. package/esm2015/components/table/table-column/models/column.interface.js +1 -1
  12. package/esm2015/components/table/table-column/table-columns.component.js +34 -29
  13. package/esm2015/utils/currency/currency.service.js +29 -0
  14. package/esm2015/utils/currency/index.js +2 -0
  15. package/esm2015/utils/index.js +2 -1
  16. package/esm5/components/locale/pipes/numeric.pipe.js +2 -2
  17. package/esm5/components/locale/services/numeric.service.js +8 -5
  18. package/esm5/components/table/table-column/models/column.interface.js +1 -1
  19. package/esm5/components/table/table-column/table-columns.component.js +31 -26
  20. package/esm5/utils/currency/currency.service.js +31 -0
  21. package/esm5/utils/currency/index.js +2 -0
  22. package/esm5/utils/index.js +2 -1
  23. package/fesm2015/seniorsistemas-angular-components.js +64 -34
  24. package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
  25. package/fesm5/seniorsistemas-angular-components.js +63 -31
  26. package/fesm5/seniorsistemas-angular-components.js.map +1 -1
  27. package/package.json +1 -1
  28. package/seniorsistemas-angular-components.metadata.json +1 -1
  29. package/utils/currency/currency.service.d.ts +8 -0
  30. package/utils/currency/index.d.ts +1 -0
  31. package/utils/index.d.ts +1 -0
@@ -7309,14 +7309,17 @@
7309
7309
  * Documentation is available at {@link https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat Intl.NumberFormatOptions}.
7310
7310
  *
7311
7311
  * @param {number | string | BigNumber} value The value to be formatted.
7312
- * @param {Intl.NumberFormatOptions} options Options that overwrites the default Intl.NumberFormatOptions.
7312
+ * @param options Locale and numberFormatOptions that overwrites the default Intl.NumberFormatOptions.
7313
7313
  * @return `string` The formatted value.
7314
7314
  */
7315
7315
  NumericService.prototype.instant = function (value, options) {
7316
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
7317
- options = __assign(__assign({}, options), { locale: (_c = (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : (_b = this.localeService.getLocaleOptions()) === null || _b === void 0 ? void 0 : _b.locale) !== null && _c !== void 0 ? _c : "pt-BR", options: __assign(__assign({}, options === null || options === void 0 ? void 0 : options.options), { currency: ((_d = options === null || options === void 0 ? void 0 : options.options) === null || _d === void 0 ? void 0 : _d.style) === "currency" ? (_f = (_e = options === null || options === void 0 ? void 0 : options.options) === null || _e === void 0 ? void 0 : _e.currency) !== null && _f !== void 0 ? _f : "BRL" : undefined, currencyDisplay: ((_g = options === null || options === void 0 ? void 0 : options.options) === null || _g === void 0 ? void 0 : _g.style) === "currency" ? (_j = (_h = options === null || options === void 0 ? void 0 : options.options) === null || _h === void 0 ? void 0 : _h.currencyDisplay) !== null && _j !== void 0 ? _j : "narrowSymbol" : undefined, minimumFractionDigits: (_l = (_k = options === null || options === void 0 ? void 0 : options.options) === null || _k === void 0 ? void 0 : _k.minimumFractionDigits) !== null && _l !== void 0 ? _l : 0 }) });
7316
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
7317
+ options = __assign(__assign({}, options), { locale: (_c = (_a = options === null || options === void 0 ? void 0 : options.locale) !== null && _a !== void 0 ? _a : (_b = this.localeService.getLocaleOptions()) === null || _b === void 0 ? void 0 : _b.locale) !== null && _c !== void 0 ? _c : "pt-BR", numberFormatOptions: __assign(__assign({}, options === null || options === void 0 ? void 0 : options.numberFormatOptions), { currency: ((_d = options === null || options === void 0 ? void 0 : options.numberFormatOptions) === null || _d === void 0 ? void 0 : _d.style) === "currency" ? ((_f = (_e = options === null || options === void 0 ? void 0 : options.numberFormatOptions) === null || _e === void 0 ? void 0 : _e.currency) !== null && _f !== void 0 ? _f : "BRL") : undefined, currencyDisplay: ((_g = options === null || options === void 0 ? void 0 : options.numberFormatOptions) === null || _g === void 0 ? void 0 : _g.style) === "currency"
7318
+ ? ((_j = (_h = options === null || options === void 0 ? void 0 : options.numberFormatOptions) === null || _h === void 0 ? void 0 : _h.currencyDisplay) !== null && _j !== void 0 ? _j : "narrowSymbol")
7319
+ : undefined, minimumFractionDigits: (_l = (_k = options === null || options === void 0 ? void 0 : options.numberFormatOptions) === null || _k === void 0 ? void 0 : _k.minimumFractionDigits) !== null && _l !== void 0 ? _l : 2, maximumFractionDigits: (_o = (_m = options === null || options === void 0 ? void 0 : options.numberFormatOptions) === null || _m === void 0 ? void 0 : _m.maximumFractionDigits) !== null && _o !== void 0 ? _o : 2 }) });
7320
+ options.numberFormatOptions["trailingZeroDisplay"] = "stripIfInteger";
7318
7321
  // From https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat
7319
- return new Intl.NumberFormat(options.locale, options.options).format(this.getType(value) === "number" || this.getType(value) === "string" ? value : value.toString());
7322
+ return new Intl.NumberFormat(options.locale, options.numberFormatOptions).format(this.getType(value) === "number" || this.getType(value) === "string" ? value : value.toString());
7320
7323
  };
7321
7324
  NumericService.prototype.getType = function (value) {
7322
7325
  // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
@@ -7371,7 +7374,7 @@
7371
7374
  : this.localeService.getLocale().pipe(operators.map(function (locale) {
7372
7375
  return _this.numericService.instant(value, {
7373
7376
  locale: locale,
7374
- options: options === null || options === void 0 ? void 0 : options.options,
7377
+ numberFormatOptions: options === null || options === void 0 ? void 0 : options.numberFormatOptions,
7375
7378
  });
7376
7379
  }));
7377
7380
  };
@@ -8341,14 +8344,15 @@
8341
8344
 
8342
8345
  var moment$4 = moment_;
8343
8346
  var TableColumnsComponent = /** @class */ (function () {
8344
- function TableColumnsComponent(localeService, viewContainerRef, translate, hostProjectConfigs) {
8347
+ function TableColumnsComponent(localeService, viewContainerRef, translate, numericService, hostProjectConfigs) {
8345
8348
  this.localeService = localeService;
8346
8349
  this.viewContainerRef = viewContainerRef;
8347
8350
  this.translate = translate;
8351
+ this.numericService = numericService;
8348
8352
  this.hostProjectConfigs = hostProjectConfigs;
8349
8353
  this.locale = {
8350
8354
  calendar: __assign(__assign({}, this.localeService.getLocaleOptions().calendar), { dateFormat: convertToMomentDateFormat(this.localeService.getLocaleOptions().calendar.dateFormat) }),
8351
- number: __assign(__assign({}, this.localeService.getLocaleOptions().number), { scale: 0 })
8355
+ number: __assign(__assign({}, this.localeService.getLocaleOptions().number), { scale: 0 }),
8352
8356
  };
8353
8357
  this.formattedColumns = [];
8354
8358
  }
@@ -8371,7 +8375,7 @@
8371
8375
  return {
8372
8376
  value: string,
8373
8377
  isUninformed: string === uninformed,
8374
- separator: !isLastIndex ? separator : ""
8378
+ separator: !isLastIndex ? separator : "",
8375
8379
  };
8376
8380
  });
8377
8381
  }
@@ -8404,10 +8408,10 @@
8404
8408
  return column.prefix ? column.prefix : this.hostProjectConfigs.domain + "." + this.hostProjectConfigs.service + ".";
8405
8409
  };
8406
8410
  TableColumnsComponent.prototype.isAttributeValueInvalid = function (attributeValue) {
8407
- return attributeValue === null ||
8411
+ return (attributeValue === null ||
8408
8412
  attributeValue === undefined ||
8409
8413
  (this.isArray(attributeValue) && !attributeValue.length) ||
8410
- (typeof attributeValue === 'string' && attributeValue.trim() === '');
8414
+ (typeof attributeValue === "string" && attributeValue.trim() === ""));
8411
8415
  };
8412
8416
  TableColumnsComponent.prototype.getFormattedColumnValue = function (column, columnValue, unifiedColumnValues, uninformedText, uninformedNumber) {
8413
8417
  if (uninformedNumber === column.attributes.length) {
@@ -8420,13 +8424,9 @@
8420
8424
  };
8421
8425
  TableColumnsComponent.prototype.getAttributeValue = function (attribute, rowValue) {
8422
8426
  var attributeValue;
8423
- attribute
8424
- .split("/")
8425
- .forEach(function (value) {
8427
+ attribute.split("/").forEach(function (value) {
8426
8428
  if (!attributeValue) {
8427
- value
8428
- .split(".")
8429
- .forEach(function (val, i) {
8429
+ value.split(".").forEach(function (val, i) {
8430
8430
  if (!rowValue) {
8431
8431
  return;
8432
8432
  }
@@ -8444,9 +8444,7 @@
8444
8444
  return attributeValue;
8445
8445
  };
8446
8446
  TableColumnsComponent.prototype.getNumberConfigs = function (column) {
8447
- return __assign(__assign({}, this.locale.number), { scale: column.scale !== null && column.scale !== undefined
8448
- ? this.getColumnScale(column.scale)
8449
- : this.locale.number.scale, prefix: this.locale.number.currencySymbol + " " });
8447
+ return __assign(__assign({}, this.locale.number), { scale: column.scale !== null && column.scale !== undefined ? this.getColumnScale(column.scale) : this.locale.number.scale, prefix: this.locale.number.currencySymbol + " " });
8450
8448
  };
8451
8449
  TableColumnsComponent.prototype.getDateFormat = function (column, locale) {
8452
8450
  return column.dateFormat ? column.dateFormat : locale.calendar.dateFormat;
@@ -8458,8 +8456,8 @@
8458
8456
  var separator = this.getColumnSeparator(column);
8459
8457
  var uninformed = this.translate.instant(prefix + "empty_label");
8460
8458
  var style = column.style;
8461
- var columnValue = column.attributes
8462
- .map(function (attribute) {
8459
+ var columnValue = column.attributes.map(function (attribute) {
8460
+ var _a, _b;
8463
8461
  var attributeValue = _this.getAttributeValue(attribute, rowValue);
8464
8462
  if (_this.isAttributeValueInvalid(attributeValue)) {
8465
8463
  return uninformed;
@@ -8469,7 +8467,10 @@
8469
8467
  case exports.EnumColumnFieldType.ENUM:
8470
8468
  return _this.translate.instant(column.enumPrefix + attributeValue.toString().toLowerCase());
8471
8469
  case exports.EnumColumnFieldType.CURRENCY:
8472
- return ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
8470
+ return ((_a = attributeValue === null || attributeValue === void 0 ? void 0 : attributeValue.options) === null || _a === void 0 ? void 0 : _a.numberFormatOptions) ? _this.numericService.instant(attributeValue.value, {
8471
+ numberFormatOptions: attributeValue.options.numberFormatOptions,
8472
+ })
8473
+ : ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
8473
8474
  case exports.EnumColumnFieldType.DATE:
8474
8475
  var dateFormat = _this.getDateFormat(column, locale);
8475
8476
  return moment$4(attributeValue).format(dateFormat);
@@ -8478,7 +8479,14 @@
8478
8479
  return _this.translate.instant(prefix + value);
8479
8480
  case exports.EnumColumnFieldType.NUMBER:
8480
8481
  numberConfigs.prefix = "";
8481
- return ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
8482
+ return ((_b = attributeValue === null || attributeValue === void 0 ? void 0 : attributeValue.options) === null || _b === void 0 ? void 0 : _b.numberFormatOptions) ? _this.numericService.instant(attributeValue.value, {
8483
+ numberFormatOptions: attributeValue.options.numberFormatOptions,
8484
+ })
8485
+ : column.numberFormatOptions
8486
+ ? _this.numericService.instant(attributeValue, {
8487
+ numberFormatOptions: column.numberFormatOptions,
8488
+ })
8489
+ : ng2CurrencyMask.applyMask(attributeValue, numberConfigs, _this.isNumber(attributeValue));
8482
8490
  case exports.EnumColumnFieldType.TOKENS:
8483
8491
  return _this.getTokens(attributeValue);
8484
8492
  default:
@@ -8486,9 +8494,7 @@
8486
8494
  }
8487
8495
  });
8488
8496
  var unifiedColumnValues = columnValue.join(separator);
8489
- var uninformedNumber = unifiedColumnValues
8490
- .split(separator)
8491
- .filter(function (value) { return value === uninformed; }).length;
8497
+ var uninformedNumber = unifiedColumnValues.split(separator).filter(function (value) { return value === uninformed; }).length;
8492
8498
  var formattedColumnValue = this.getFormattedColumnValue(column, columnValue, unifiedColumnValues, uninformed, uninformedNumber);
8493
8499
  return {
8494
8500
  style: style,
@@ -8500,7 +8506,7 @@
8500
8506
  tooltip: this.getColumnTooltip(column.tooltip),
8501
8507
  infoSign: this.getColumnInfoSign(column.infoSign),
8502
8508
  onLinkClick: column.onLinkClick,
8503
- onColumnClick: column.onColumnClick
8509
+ onColumnClick: column.onColumnClick,
8504
8510
  };
8505
8511
  };
8506
8512
  TableColumnsComponent.prototype.getColumnScale = function (scale) {
@@ -8528,7 +8534,7 @@
8528
8534
  return "";
8529
8535
  };
8530
8536
  TableColumnsComponent.prototype.isNumber = function (value) {
8531
- return !(new BigNumber__default(value).isNaN());
8537
+ return !new BigNumber__default(value).isNaN();
8532
8538
  };
8533
8539
  TableColumnsComponent.prototype.getTokens = function (values) {
8534
8540
  if (!this.isArray(values)) {
@@ -8545,7 +8551,7 @@
8545
8551
  .map(function (value) {
8546
8552
  var label = typeof value === "symbol" ? value.toString() : "" + value;
8547
8553
  return {
8548
- label: label
8554
+ label: label,
8549
8555
  };
8550
8556
  });
8551
8557
  };
@@ -8565,6 +8571,7 @@
8565
8571
  { type: LocaleService },
8566
8572
  { type: core.ViewContainerRef },
8567
8573
  { type: core$1.TranslateService },
8574
+ { type: NumericService },
8568
8575
  { type: undefined, decorators: [{ type: core.Inject, args: [HostProjectConfigsInjectionToken,] }] }
8569
8576
  ]; };
8570
8577
  __decorate([
@@ -8585,7 +8592,7 @@
8585
8592
  selector: "s-table-columns",
8586
8593
  styles: [":host{display:none}"]
8587
8594
  }),
8588
- __param(3, core.Inject(HostProjectConfigsInjectionToken))
8595
+ __param(4, core.Inject(HostProjectConfigsInjectionToken))
8589
8596
  ], TableColumnsComponent);
8590
8597
  return TableColumnsComponent;
8591
8598
  }());
@@ -18006,6 +18013,31 @@
18006
18013
  return WorkspaceSwitchModule;
18007
18014
  }());
18008
18015
 
18016
+ var CurrencyService = /** @class */ (function () {
18017
+ function CurrencyService(localeService) {
18018
+ this.localeService = localeService;
18019
+ }
18020
+ CurrencyService.prototype.getCurrencySymbol = function (_a) {
18021
+ var currency = _a.currency;
18022
+ var _b, _c;
18023
+ var numberFormat = new Intl.NumberFormat(this.localeService.getLocaleOptions().locale, {
18024
+ style: "currency",
18025
+ currency: currency !== null && currency !== void 0 ? currency : "BRL",
18026
+ currencyDisplay: 'narrowSymbol',
18027
+ maximumFractionDigits: 5,
18028
+ });
18029
+ return (_c = (_b = numberFormat.formatToParts(1).find(function (x) { return x.type === "currency"; })) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : "";
18030
+ };
18031
+ CurrencyService.ctorParameters = function () { return [
18032
+ { type: LocaleService }
18033
+ ]; };
18034
+ CurrencyService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function CurrencyService_Factory() { return new CurrencyService(core["ɵɵinject"](LocaleService)); }, token: CurrencyService, providedIn: "root" });
18035
+ CurrencyService = __decorate([
18036
+ core.Injectable({ providedIn: "root" })
18037
+ ], CurrencyService);
18038
+ return CurrencyService;
18039
+ }());
18040
+
18009
18041
  var fallback = {
18010
18042
  "platform.angular_components.drag_your_photo_or": "Arraste sua foto ou",
18011
18043
  "platform.angular_components.select_a_file": "selecione um arquivo",
@@ -18356,6 +18388,7 @@
18356
18388
  exports.CountryPhonePickerComponent = CountryPhonePickerComponent;
18357
18389
  exports.CountryPhonePickerModule = CountryPhonePickerModule;
18358
18390
  exports.CurrencyField = CurrencyField;
18391
+ exports.CurrencyService = CurrencyService;
18359
18392
  exports.CustomFieldsComponent = CustomFieldsComponent;
18360
18393
  exports.CustomFieldsModule = CustomFieldsModule;
18361
18394
  exports.CustomFieldsService = CustomFieldsService;