@addsign/moje-agenda-shared-lib 2.0.35 → 2.0.36

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.
@@ -1,10 +1,15 @@
1
1
  import { IOptionItem } from '../../types';
2
2
 
3
+ export interface IDataTableRendexXlsOptions {
4
+ type?: "string" | "number" | "date";
5
+ format?: string;
6
+ }
3
7
  export interface DataTableColumn<T> {
4
8
  key: keyof T | "actions";
5
9
  header: string;
6
10
  render?: (item: T) => React.ReactNode;
7
11
  renderXls?: (item: T) => string | number;
12
+ renderXlsOptions?: IDataTableRendexXlsOptions;
8
13
  actions?: DataTableAction<T>[];
9
14
  filterType?: string;
10
15
  classes?: string;
@@ -508,6 +508,7 @@ function DataTableServer<T extends DataTableInternalItems>({
508
508
 
509
509
  // Handle number formatting
510
510
  if (
511
+ column.renderXlsOptions?.type === "number" ||
511
512
  typeof value === "number" ||
512
513
  (typeof value === "string" && !isNaN(Number(value)))
513
514
  ) {
@@ -540,7 +541,16 @@ function DataTableServer<T extends DataTableInternalItems>({
540
541
  for (let R = range.s.r; R <= range.e.r; ++R) {
541
542
  const cell = worksheet[col + (R + 1)];
542
543
  if (cell && typeof cell.v === "number") {
543
- cell.z = "#,##0"; // Number format without forcing decimals
544
+ // Get the column index by converting the column letter to number
545
+ const colIndex = XLSX.utils.decode_col(col);
546
+ // Find the corresponding column definition
547
+ const column = columns[colIndex];
548
+ // Apply the format if specified in renderXlsOptions
549
+ if (column?.renderXlsOptions?.format) {
550
+ cell.z = column.renderXlsOptions.format;
551
+ } else {
552
+ cell.z = "#,##0"; // Default number format
553
+ }
544
554
  }
545
555
  }
546
556
  }
@@ -1,10 +1,15 @@
1
1
  import { IOptionItem } from "../../types";
2
2
 
3
+ export interface IDataTableRendexXlsOptions {
4
+ type?: "string" | "number" | "date";
5
+ format?: string;
6
+ }
3
7
  export interface DataTableColumn<T> {
4
8
  key: keyof T | "actions";
5
9
  header: string;
6
10
  render?: (item: T) => React.ReactNode;
7
11
  renderXls?: (item: T) => string | number;
12
+ renderXlsOptions?: IDataTableRendexXlsOptions;
8
13
  actions?: DataTableAction<T>[];
9
14
  filterType?: string;
10
15
  classes?: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@addsign/moje-agenda-shared-lib",
3
3
  "private": false,
4
- "version": "2.0.35",
4
+ "version": "2.0.36",
5
5
  "type": "module",
6
6
  "main": "dist/main.js",
7
7
  "types": "dist/main.d.ts",