@economic/taco 2.58.2-EC-64962.1 → 2.58.2-EC-64961.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.
package/dist/taco.d.ts CHANGED
@@ -3148,6 +3148,21 @@ export declare type TableColumnClassNameHandler<TType = unknown> = string | ((ro
3148
3148
 
3149
3149
  export declare type TableColumnDataType = 'text' | 'number' | 'datetime' | 'boolean' | 'amount';
3150
3150
 
3151
+ export declare type TableColumnDataTypeOptions = {
3152
+ numberFormatOptions?: Intl.NumberFormatOptions;
3153
+ };
3154
+
3155
+ export declare type TableColumnDataTypeProps = {
3156
+ dataType?: TableColumnDataType;
3157
+ dataTypeOptions?: TableColumnDataTypeOptions;
3158
+ } & ({
3159
+ dataType?: 'number' | 'amount';
3160
+ dataTypeOptions?: Pick<TableColumnDataTypeOptions, 'numberFormatOptions'>;
3161
+ } | {
3162
+ dataType?: Omit<TableColumnDataType, 'number' | 'amount'>;
3163
+ dataTypeOptions?: never;
3164
+ });
3165
+
3151
3166
  export declare type TableColumnFilter = ColumnFilter;
3152
3167
 
3153
3168
  export declare type TableColumnIdentifierProps<TType = unknown> = {
@@ -3166,7 +3181,7 @@ export declare type TableColumnIdentifierProps<TType = unknown> = {
3166
3181
 
3167
3182
  export declare type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];
3168
3183
 
3169
- export declare type TableColumnProps<TType = unknown> = TableColumnIdentifierProps<TType> & {
3184
+ export declare type TableColumnProps<TType = unknown> = TableColumnIdentifierProps<TType> & TableColumnDataTypeProps & {
3170
3185
  control?: TableColumnRendererControl<TType> | undefined;
3171
3186
  footer?: TableColumnRendererFooter<TType> | undefined;
3172
3187
  header: TableColumnRendererHeader;
@@ -3375,7 +3390,7 @@ export declare type TableRowActionRenderer<TType = unknown> = (row: TType, inter
3375
3390
 
3376
3391
  export declare type TableRowClickHandler<TType = unknown> = (row: TType) => void;
3377
3392
 
3378
- export declare type TableRowDragHandler<TType = unknown> = (rows: TType[], showPlaceholder: (string: any) => void, setDataTransfer: (data: string) => void) => void;
3393
+ export declare type TableRowDragHandler<TType = unknown> = (rows: TType[], showPlaceholder: (text: string) => void, setDataTransfer: (data: string) => void) => void;
3379
3394
 
3380
3395
  export declare type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;
3381
3396
 
@@ -4046,6 +4061,7 @@ declare module '@tanstack/table-core' {
4046
4061
  className?: TableColumnClassNameHandler<TData>;
4047
4062
  control?: TableColumnRendererControl<TData>;
4048
4063
  dataType?: TableColumnDataType;
4064
+ dataTypeOptions?: TableColumnDataTypeOptions;
4049
4065
  defaultWidth?: number;
4050
4066
  enableEditing?: boolean;
4051
4067
  enableOrdering?: boolean;
package/dist/taco.js CHANGED
@@ -33048,7 +33048,17 @@ const dataTypes = {
33048
33048
  TableFilterComparator.IsBetween,
33049
33049
  TableFilterComparator.IsEmpty,
33050
33050
  TableFilterComparator.IsNotEmpty
33051
- ]
33051
+ ],
33052
+ getDisplayValue: (value, options) => {
33053
+ var _a, _b, _c;
33054
+ if (value === void 0) {
33055
+ return "";
33056
+ }
33057
+ if ((_a = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _a.numberFormatOptions) {
33058
+ 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);
33059
+ }
33060
+ return String(value);
33061
+ }
33052
33062
  },
33053
33063
  datetime: {
33054
33064
  sortingFn: "datetime",
@@ -33088,18 +33098,28 @@ const dataTypes = {
33088
33098
  TableFilterComparator.IsNotEmpty
33089
33099
  ],
33090
33100
  getDisplayValue: (value, options) => {
33091
- var _a;
33101
+ var _a, _b, _c, _d, _e, _f;
33092
33102
  if (value === void 0) {
33093
33103
  return "";
33094
33104
  }
33095
- const formatter = new Intl.NumberFormat((_a = options == null ? void 0 : options.localization) == null ? void 0 : _a.locale, { minimumFractionDigits: 2 });
33096
- const decimalSeperator = formatter.format(1.1).substring(1, 2);
33097
- const localisedValue = formatter.format(Number(value));
33098
- const localisedValueWithoutThousandsSeperator = decimalSeperator === "." ? localisedValue.replace(",", "") : localisedValue.replace(".", "");
33099
- return [localisedValue, localisedValueWithoutThousandsSeperator];
33105
+ const min2 = ((_b = (_a = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _a.numberFormatOptions) == null ? void 0 : _b.minimumFractionDigits) ?? 2;
33106
+ const max2 = ((_d = (_c = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _c.numberFormatOptions) == null ? void 0 : _d.maximumFractionDigits) ?? 2;
33107
+ const numberFormatOptions = {
33108
+ minimumFractionDigits: Math.min(min2, max2),
33109
+ maximumFractionDigits: Math.max(max2, min2),
33110
+ ...(_e = options == null ? void 0 : options.dataTypeOptions) == null ? void 0 : _e.numberFormatOptions
33111
+ };
33112
+ return formatNumber(value, (_f = options == null ? void 0 : options.localization) == null ? void 0 : _f.locale, numberFormatOptions);
33100
33113
  }
33101
33114
  }
33102
33115
  };
33116
+ function formatNumber(value, locale2, numberFormatOptions) {
33117
+ const formatter = new Intl.NumberFormat(locale2, numberFormatOptions);
33118
+ const decimalSeperator = new Intl.NumberFormat(String(locale2 ?? ""), { minimumFractionDigits: 2 }).format(1.1).substring(1, 2);
33119
+ const localisedValue = formatter.format(Number(value));
33120
+ const localisedValueWithoutThousandsSeperator = decimalSeperator === "." ? localisedValue.replace(",", "") : localisedValue.replace(".", "");
33121
+ return [localisedValue, localisedValueWithoutThousandsSeperator];
33122
+ }
33103
33123
  function getDataTypeProperties(dataType) {
33104
33124
  return dataTypes[dataType ?? "text"] ?? dataTypes.text;
33105
33125
  }
@@ -33221,7 +33241,7 @@ function columnFilterFn(value, filter2) {
33221
33241
  const flattenCellValue = (cellValue) => {
33222
33242
  return typeof cellValue === "object" ? Object.values(cellValue).map(flattenCellValue) : cellValue;
33223
33243
  };
33224
- function isMatched(searchQuery, cellValue, dataType, localization) {
33244
+ function isMatched(searchQuery, cellValue, dataType, dataTypeOptions, localization) {
33225
33245
  if (typeof cellValue === "object") {
33226
33246
  return flattenCellValue(cellValue).flat(Infinity).find((y4) => isWeakContains(y4, searchQuery));
33227
33247
  } else {
@@ -33231,7 +33251,7 @@ function isMatched(searchQuery, cellValue, dataType, localization) {
33231
33251
  } else {
33232
33252
  const dataTypeProperties = getDataTypeProperties(dataType);
33233
33253
  if (dataTypeProperties.getDisplayValue) {
33234
- const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { localization });
33254
+ const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { dataTypeOptions, localization });
33235
33255
  if (Array.isArray(cellDisplayValue)) {
33236
33256
  for (const displayValue of cellDisplayValue) {
33237
33257
  if (isWeakContains(displayValue, searchQuery)) {
@@ -33247,12 +33267,12 @@ function isMatched(searchQuery, cellValue, dataType, localization) {
33247
33267
  return false;
33248
33268
  }
33249
33269
  function globalFilterFn(row, columnId, searchQuery, localization) {
33250
- var _a, _b;
33270
+ var _a;
33251
33271
  try {
33252
33272
  if (row.original) {
33253
33273
  const cellValue = row.original[columnId];
33254
- const dataType = (_b = (_a = row._getAllCellsByColumnId()[columnId]) == null ? void 0 : _a.column.columnDef.meta) == null ? void 0 : _b.dataType;
33255
- return isMatched(searchQuery, cellValue, dataType, localization);
33274
+ const columnMeta = (_a = row._getAllCellsByColumnId()[columnId]) == null ? void 0 : _a.column.columnDef.meta;
33275
+ return isMatched(searchQuery, cellValue, columnMeta == null ? void 0 : columnMeta.dataType, columnMeta == null ? void 0 : columnMeta.dataTypeOptions, localization);
33256
33276
  }
33257
33277
  } catch {
33258
33278
  }
@@ -33267,7 +33287,7 @@ function resetHighlightedColumnIndexes(searchQuery, table, localization) {
33267
33287
  const rowGrouping = table.getState().grouping;
33268
33288
  table.getRowModel().rows.forEach((row, rowIndex) => {
33269
33289
  columns.forEach((column, columnIndex) => {
33270
- var _a;
33290
+ var _a, _b;
33271
33291
  try {
33272
33292
  let allowSearch = true;
33273
33293
  if (rowGrouping == null ? void 0 : rowGrouping.length) {
@@ -33280,7 +33300,8 @@ function resetHighlightedColumnIndexes(searchQuery, table, localization) {
33280
33300
  if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {
33281
33301
  const cellValue = get(row.original, column.id);
33282
33302
  const dataType = (_a = column.columnDef.meta) == null ? void 0 : _a.dataType;
33283
- if (isMatched(searchQuery, cellValue, dataType, localization)) {
33303
+ const dataTypeOptions = (_b = column.columnDef.meta) == null ? void 0 : _b.dataTypeOptions;
33304
+ if (isMatched(searchQuery, cellValue, dataType, dataTypeOptions, localization)) {
33284
33305
  indexes.push([rowIndex, columnIndex]);
33285
33306
  }
33286
33307
  }
@@ -33521,7 +33542,10 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
33521
33542
  };
33522
33543
  const formattedValueRenderer = (value) => {
33523
33544
  var _a;
33524
- const displayValue = (_a = dataTypeProperties.getDisplayValue) == null ? void 0 : _a.call(dataTypeProperties, value, { localization });
33545
+ const displayValue = (_a = dataTypeProperties.getDisplayValue) == null ? void 0 : _a.call(dataTypeProperties, value, {
33546
+ dataTypeOptions: meta.dataTypeOptions,
33547
+ localization
33548
+ });
33525
33549
  const safeValue = value !== void 0 && value !== null ? String(value) : value;
33526
33550
  if (Array.isArray(displayValue)) {
33527
33551
  return displayValue[0] ?? safeValue;