@topconsultnpm/sdkui-react-beta 6.14.37 → 6.14.38

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,4 +1,4 @@
1
- import { associateColumnsToRows } from "../../utils/TMUtils";
1
+ import { associateColumnsToRows } from "../../helper";
2
2
  // Function to find a specific file or folder based on its ID (used for finding nested items)
3
3
  export const findFileItems = (items, id) => {
4
4
  for (let item of items) {
@@ -1,2 +1,7 @@
1
+ import { DataColumnDescriptor } from '@topconsultnpm/sdk-ts-beta';
1
2
  export declare const getFileIcon: (fileExtension: string | undefined, fileCount: number | undefined, tooltipContent?: JSX.Element | string) => import("react/jsx-runtime").JSX.Element;
2
3
  export declare function formatBytes(bytes: number | undefined, decimalPlaces?: number): string;
4
+ export interface RowData {
5
+ [key: string]: string | number | null;
6
+ }
7
+ export declare const associateColumnsToRows: (columns: Array<DataColumnDescriptor> | undefined, rows: Array<Array<string>> | undefined) => Array<RowData>;
@@ -95,3 +95,23 @@ export function formatBytes(bytes, decimalPlaces = 2) {
95
95
  const value = parseFloat((bytes / Math.pow(k, i)).toFixed(decimalPlaces));
96
96
  return `${value} ${units[i]}`;
97
97
  }
98
+ // Function to associate columns to rows and return an array of RowData objects
99
+ export const associateColumnsToRows = (columns, rows) => {
100
+ if (columns === undefined || rows === undefined)
101
+ return [];
102
+ // Map over each row and associate each value with the corresponding column's caption
103
+ return rows.map(row => {
104
+ // Create an empty object to hold the key-value pairs for each row
105
+ const rowObject = {};
106
+ // Loop through each cell in the row and map its value to the corresponding column's caption
107
+ row.forEach((value, index) => {
108
+ const column = columns[index]; // Get the column corresponding to the current index
109
+ // If a column exists at this index, add the value to the rowObject with the column's caption as the key
110
+ if (column && column.caption) {
111
+ rowObject[column.caption] = value;
112
+ }
113
+ });
114
+ // Return the populated rowObject, which represents the row with columns as keys
115
+ return rowObject;
116
+ });
117
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@topconsultnpm/sdkui-react-beta",
3
- "version": "6.14.37",
3
+ "version": "6.14.38",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -1,5 +0,0 @@
1
- import { DataColumnDescriptor } from '@topconsultnpm/sdk-ts-beta';
2
- export interface RowData {
3
- [key: string]: string | number | null;
4
- }
5
- export declare const associateColumnsToRows: (columns: Array<DataColumnDescriptor> | undefined, rows: Array<Array<string>> | undefined) => Array<RowData>;
@@ -1,20 +0,0 @@
1
- // Function to associate columns to rows and return an array of RowData objects
2
- export const associateColumnsToRows = (columns, rows) => {
3
- if (columns === undefined || rows === undefined)
4
- return [];
5
- // Map over each row and associate each value with the corresponding column's caption
6
- return rows.map(row => {
7
- // Create an empty object to hold the key-value pairs for each row
8
- const rowObject = {};
9
- // Loop through each cell in the row and map its value to the corresponding column's caption
10
- row.forEach((value, index) => {
11
- const column = columns[index]; // Get the column corresponding to the current index
12
- // If a column exists at this index, add the value to the rowObject with the column's caption as the key
13
- if (column && column.caption) {
14
- rowObject[column.caption] = value;
15
- }
16
- });
17
- // Return the populated rowObject, which represents the row with columns as keys
18
- return rowObject;
19
- });
20
- };