@economic/taco 2.58.2-EC-64961.0 → 2.58.2-EC-64961.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.
package/dist/taco.cjs CHANGED
@@ -33054,30 +33054,6 @@ const dataTypes = {
33054
33054
  TableFilterComparator.IsNotEmpty
33055
33055
  ]
33056
33056
  },
33057
- number: {
33058
- sortingFn: "basic",
33059
- filterComparators: [
33060
- TableFilterComparator.IsEqualTo,
33061
- TableFilterComparator.IsNotEqualTo,
33062
- TableFilterComparator.IsGreaterThan,
33063
- TableFilterComparator.IsLessThan,
33064
- TableFilterComparator.IsGreaterThanOrEqualTo,
33065
- TableFilterComparator.IsLessThanOrEqualTo,
33066
- TableFilterComparator.IsBetween,
33067
- TableFilterComparator.IsEmpty,
33068
- TableFilterComparator.IsNotEmpty
33069
- ],
33070
- getDisplayValue: (value, options) => {
33071
- var _a, _b, _c;
33072
- if (value === void 0) {
33073
- return "";
33074
- }
33075
- if ((_a = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _a.numberFormatOptions) {
33076
- return formatNumber(value, (_b = options == null ? void 0 : options.localization) == null ? void 0 : _b.locale, (_c = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _c.numberFormatOptions);
33077
- }
33078
- return String(value);
33079
- }
33080
- },
33081
33057
  datetime: {
33082
33058
  sortingFn: "datetime",
33083
33059
  filterComparators: [
@@ -33091,7 +33067,7 @@ const dataTypes = {
33091
33067
  TableFilterComparator.IsEmpty,
33092
33068
  TableFilterComparator.IsNotEmpty
33093
33069
  ],
33094
- getDisplayValue: (value, options) => {
33070
+ getDisplayValue: (value, _1, options) => {
33095
33071
  var _a;
33096
33072
  return format$1(value, (_a = options == null ? void 0 : options.localization) == null ? void 0 : _a.formatting.date) ?? "";
33097
33073
  }
@@ -33100,9 +33076,14 @@ const dataTypes = {
33100
33076
  sortingFn: "basic",
33101
33077
  filterComparators: [TableFilterComparator.IsEqualTo, TableFilterComparator.IsNotEqualTo]
33102
33078
  },
33103
- // advanced
33104
- amount: {
33105
- align: "right",
33079
+ // numbers
33080
+ number: createNumberDataType("left"),
33081
+ amount: createNumberDataType("right", { decimals: 2, useGrouping: true }),
33082
+ percentage: createNumberDataType("right", { useGrouping: true, percent: true })
33083
+ };
33084
+ function createNumberDataType(align, defaultOptions2) {
33085
+ return {
33086
+ align,
33106
33087
  sortingFn: "basic",
33107
33088
  filterComparators: [
33108
33089
  TableFilterComparator.IsEqualTo,
@@ -33115,28 +33096,39 @@ const dataTypes = {
33115
33096
  TableFilterComparator.IsEmpty,
33116
33097
  TableFilterComparator.IsNotEmpty
33117
33098
  ],
33118
- getDisplayValue: (value, options) => {
33119
- var _a, _b, _c, _d, _e, _f;
33099
+ getDisplayValue: (value, row, options) => {
33100
+ var _a, _b;
33120
33101
  if (value === void 0) {
33121
33102
  return "";
33122
33103
  }
33123
- const min2 = ((_b = (_a = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _a.numberFormatOptions) == null ? void 0 : _b.minimumFractionDigits) ?? 2;
33124
- const max2 = ((_d = (_c = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _c.numberFormatOptions) == null ? void 0 : _d.maximumFractionDigits) ?? 2;
33104
+ const dataTypeOptions = typeof (options == null ? void 0 : options.dataTypeOptions) === "function" ? options == null ? void 0 : options.dataTypeOptions(row) : options == null ? void 0 : options.dataTypeOptions;
33125
33105
  const numberFormatOptions = {
33126
- minimumFractionDigits: Math.min(min2, max2),
33127
- maximumFractionDigits: Math.max(max2, min2),
33128
- ...(_e = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _e.numberFormatOptions
33106
+ // format
33107
+ useGrouping: (dataTypeOptions == null ? void 0 : dataTypeOptions.useGrouping) ?? (defaultOptions2 == null ? void 0 : defaultOptions2.useGrouping) ?? false,
33108
+ // decimals
33109
+ minimumFractionDigits: (dataTypeOptions == null ? void 0 : dataTypeOptions.decimals) ?? (defaultOptions2 == null ? void 0 : defaultOptions2.decimals),
33110
+ maximumFractionDigits: (dataTypeOptions == null ? void 0 : dataTypeOptions.decimals) ?? (defaultOptions2 == null ? void 0 : defaultOptions2.decimals)
33129
33111
  };
33130
- return formatNumber(value, (_f = options == null ? void 0 : options.localization) == null ? void 0 : _f.locale, numberFormatOptions);
33112
+ if (defaultOptions2 == null ? void 0 : defaultOptions2.percent) {
33113
+ numberFormatOptions.style = "percent";
33114
+ } else if (dataTypeOptions == null ? void 0 : dataTypeOptions.currency) {
33115
+ numberFormatOptions.style = "currency";
33116
+ numberFormatOptions.currency = dataTypeOptions.currency;
33117
+ numberFormatOptions.currencyDisplay = "code";
33118
+ }
33119
+ const localisedValue = new Intl.NumberFormat((_a = options == null ? void 0 : options.localization) == null ? void 0 : _a.locale, numberFormatOptions).format(
33120
+ Number(value)
33121
+ );
33122
+ if (!numberFormatOptions.useGrouping) {
33123
+ return localisedValue;
33124
+ }
33125
+ const localisedValueWithoutThousandsSeperator = new Intl.NumberFormat((_b = options == null ? void 0 : options.localization) == null ? void 0 : _b.locale, {
33126
+ ...numberFormatOptions,
33127
+ useGrouping: false
33128
+ }).format(Number(value));
33129
+ return [localisedValue, localisedValueWithoutThousandsSeperator];
33131
33130
  }
33132
- }
33133
- };
33134
- function formatNumber(value, locale2, numberFormatOptions) {
33135
- const formatter = new Intl.NumberFormat(locale2, numberFormatOptions);
33136
- const decimalSeperator = new Intl.NumberFormat(String(locale2 ?? ""), { minimumFractionDigits: 2 }).format(1.1).substring(1, 2);
33137
- const localisedValue = formatter.format(Number(value));
33138
- const localisedValueWithoutThousandsSeperator = decimalSeperator === "." ? localisedValue.replace(",", "") : localisedValue.replace(".", "");
33139
- return [localisedValue, localisedValueWithoutThousandsSeperator];
33131
+ };
33140
33132
  }
33141
33133
  function getDataTypeProperties(dataType) {
33142
33134
  return dataTypes[dataType ?? "text"] ?? dataTypes.text;
@@ -33259,7 +33251,7 @@ function columnFilterFn(value, filter2) {
33259
33251
  const flattenCellValue = (cellValue) => {
33260
33252
  return typeof cellValue === "object" ? Object.values(cellValue).map(flattenCellValue) : cellValue;
33261
33253
  };
33262
- function isMatched(searchQuery, cellValue, dataType, dataTypeOptions, localization) {
33254
+ function isMatched(searchQuery, cellValue, rowValue, dataType, dataTypeOptions, localization) {
33263
33255
  if (typeof cellValue === "object") {
33264
33256
  return flattenCellValue(cellValue).flat(Infinity).find((y4) => isWeakContains(y4, searchQuery));
33265
33257
  } else {
@@ -33269,7 +33261,10 @@ function isMatched(searchQuery, cellValue, dataType, dataTypeOptions, localizati
33269
33261
  } else {
33270
33262
  const dataTypeProperties = getDataTypeProperties(dataType);
33271
33263
  if (dataTypeProperties.getDisplayValue) {
33272
- const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { dataTypeOptions, localization });
33264
+ const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, rowValue, {
33265
+ dataTypeOptions,
33266
+ localization
33267
+ });
33273
33268
  if (Array.isArray(cellDisplayValue)) {
33274
33269
  for (const displayValue of cellDisplayValue) {
33275
33270
  if (isWeakContains(displayValue, searchQuery)) {
@@ -33290,7 +33285,14 @@ function globalFilterFn(row, columnId, searchQuery, localization) {
33290
33285
  if (row.original) {
33291
33286
  const cellValue = row.original[columnId];
33292
33287
  const columnMeta = (_a = row._getAllCellsByColumnId()[columnId]) == null ? void 0 : _a.column.columnDef.meta;
33293
- return isMatched(searchQuery, cellValue, columnMeta == null ? void 0 : columnMeta.dataType, columnMeta == null ? void 0 : columnMeta.dataTypeOptions, localization);
33288
+ return isMatched(
33289
+ searchQuery,
33290
+ cellValue,
33291
+ row.original,
33292
+ columnMeta == null ? void 0 : columnMeta.dataType,
33293
+ columnMeta == null ? void 0 : columnMeta.dataTypeOptions,
33294
+ localization
33295
+ );
33294
33296
  }
33295
33297
  } catch {
33296
33298
  }
@@ -33319,7 +33321,7 @@ function resetHighlightedColumnIndexes(searchQuery, table, localization) {
33319
33321
  const cellValue = get(row.original, column.id);
33320
33322
  const dataType = (_a = column.columnDef.meta) == null ? void 0 : _a.dataType;
33321
33323
  const dataTypeOptions = (_b = column.columnDef.meta) == null ? void 0 : _b.dataTypeOptions;
33322
- if (isMatched(searchQuery, cellValue, dataType, dataTypeOptions, localization)) {
33324
+ if (isMatched(searchQuery, cellValue, row.original, dataType, dataTypeOptions, localization)) {
33323
33325
  indexes.push([rowIndex, columnIndex]);
33324
33326
  }
33325
33327
  }
@@ -33558,9 +33560,9 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
33558
33560
  header
33559
33561
  }
33560
33562
  };
33561
- const formattedValueRenderer = (value) => {
33563
+ const formattedValueRenderer = (value, row) => {
33562
33564
  var _a;
33563
- const displayValue = (_a = dataTypeProperties.getDisplayValue) == null ? void 0 : _a.call(dataTypeProperties, value, {
33565
+ const displayValue = (_a = dataTypeProperties.getDisplayValue) == null ? void 0 : _a.call(dataTypeProperties, value, row, {
33564
33566
  dataTypeOptions: meta.dataTypeOptions,
33565
33567
  localization
33566
33568
  });
@@ -33571,14 +33573,14 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
33571
33573
  return displayValue ?? safeValue;
33572
33574
  };
33573
33575
  const rendererArgs = (info) => ({
33574
- formattedValue: formattedValueRenderer(info.getValue()),
33576
+ formattedValue: formattedValueRenderer(info.getValue(), info.row.original),
33575
33577
  row: info.row.original,
33576
33578
  value: info.getValue()
33577
33579
  });
33578
33580
  if (typeof renderer2 === "function") {
33579
33581
  column.cell = (info) => renderer2(rendererArgs(info));
33580
33582
  } else {
33581
- column.cell = (info) => formattedValueRenderer(info.getValue());
33583
+ column.cell = (info) => formattedValueRenderer(info.getValue(), info.row.original);
33582
33584
  }
33583
33585
  if (typeof footer === "function") {
33584
33586
  column.footer = (info) => footer(info.table.getRowModel().rows.flatMap((row) => row.original !== void 0 ? row.original : []));