@sme.up/doc-alchemist 1.0.0-SNAPSHOT-20250613190613 → 1.0.0-SNAPSHOT-20250616152545

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.
@@ -0,0 +1,298 @@
1
+ import ExcelJS from "exceljs";
2
+ const { ValueType } = ExcelJS;
3
+ import { getFilteredColumns, filterRows, updateMaxValueLength, calculateCellValue, hexToArgb, } from "../utils/generator-utility.js";
4
+ import { exportTypeSupportsFormatting, allowedTotals, } from "./excel-generator.types.js";
5
+ import { isColumnHidden } from "../utils/datastructure-utility.js";
6
+ import { addFooterTotalsRow, getExcelColumnLetter, initializeWorksheet, setHeaderStyling, smeupFormulaToExcelFormula, } from "./commons.js";
7
+ export const dataTableToExcelWorkbook = (component, fileFormat, webupManagerData) => {
8
+ // Create a new ExcelJS.Workbook and return it as a resolved Promise
9
+ const { smeupDataTable: smeupDataTable, props } = component;
10
+ const workbook = new ExcelJS.Workbook();
11
+ const worksheet = initializeWorksheet(workbook);
12
+ const filteredColumns = getFilteredColumns(smeupDataTable.columns);
13
+ const maxColumnValueLenght = {};
14
+ let rowNumber = 1; // Start row number
15
+ // Headers setup
16
+ setDataTableHeaderRow(worksheet, filteredColumns, maxColumnValueLenght);
17
+ // Get active groups (where visible is true)
18
+ const groupsArray = Array.isArray(props?.groups) ? props.groups : [];
19
+ const activeGroups = groupsArray
20
+ .filter((group) => group.visible)
21
+ .map((group) => group.column);
22
+ // Filter and sort rows (if filters are available)
23
+ const rows = filterRows(smeupDataTable, filteredColumns, props?.filters);
24
+ if (activeGroups?.length > 0) {
25
+ // Sort rows based on the first active group column
26
+ rows.sort((a, b) => {
27
+ for (const group of activeGroups) {
28
+ const valA = a.cells && a.cells[group]?.value !== undefined
29
+ ? a.cells[group]?.value
30
+ : "";
31
+ const valB = b.cells && b.cells[group]?.value !== undefined
32
+ ? b.cells[group]?.value
33
+ : "";
34
+ if (valA !== valB)
35
+ return valA.localeCompare(valB);
36
+ }
37
+ return 0;
38
+ });
39
+ // Recursive grouping
40
+ rowNumber = insertDataTableGroupedRows(worksheet, rows, activeGroups, filteredColumns, smeupDataTable.columns, rowNumber, fileFormat, webupManagerData, 1, maxColumnValueLenght, (props?.totals ?? {}));
41
+ //INTERACTIVE GROUPS MANAGING
42
+ //TODO: Add groups subtotals
43
+ if (worksheet.getColumn(1).hidden)
44
+ ensureGroupRowHasDescription(worksheet);
45
+ applyDataTableOutlineLevels(worksheet);
46
+ worksheet.properties.outlineProperties = {
47
+ summaryBelow: false,
48
+ summaryRight: false,
49
+ };
50
+ }
51
+ else {
52
+ // Process rows normally if no grouping
53
+ rowNumber = insertDataTableRows(worksheet, rows, filteredColumns, rowNumber, fileFormat, webupManagerData, maxColumnValueLenght);
54
+ }
55
+ if (exportTypeSupportsFormatting[fileFormat] && props?.totals) {
56
+ addFooterTotalsRow(worksheet, filteredColumns, props, webupManagerData);
57
+ }
58
+ // Apply column width
59
+ worksheet.columns.forEach(col => {
60
+ const columnKey = col.key;
61
+ if (columnKey) {
62
+ col.width = (maxColumnValueLenght[columnKey] ?? 10) * 1.1;
63
+ }
64
+ else {
65
+ col.width = 10 * 1.1; // Default width
66
+ }
67
+ });
68
+ // Apply filter to column headers
69
+ // TODO: look if it breaks groupings
70
+ worksheet.autoFilter = {
71
+ from: { row: 1, column: 1 },
72
+ to: { row: rowNumber, column: filteredColumns.length },
73
+ };
74
+ // Forces full calculation when the workbook is opened
75
+ workbook.calcProperties = {
76
+ fullCalcOnLoad: true,
77
+ };
78
+ return workbook;
79
+ };
80
+ /**
81
+ * Creates the first row of the table by looking at dataTable columns.
82
+ * Also updates column width calculations
83
+ * @param worksheet
84
+ * @param filteredColumns
85
+ * @param maxValueLengthMap
86
+ */
87
+ const setDataTableHeaderRow = (worksheet, filteredColumns, maxValueLengthMap) => {
88
+ worksheet.columns = filteredColumns.map(col => {
89
+ updateMaxValueLength(maxValueLengthMap, col.title, col.name);
90
+ return {
91
+ header: col.title,
92
+ key: col.name,
93
+ width: maxValueLengthMap[col.name], // Set the width to the updated value
94
+ hidden: isColumnHidden(col),
95
+ };
96
+ });
97
+ setHeaderStyling(worksheet);
98
+ };
99
+ const insertDataTableGroupedRows = (worksheet, rows, groups, filteredColumns, unfilteredColumns, rowNumber, fileFormat, webupManagerData, currentOutlineLevel = 1, maxColumnValueLength, totals) => {
100
+ if (!groups.length) {
101
+ return insertDataTableRows(worksheet, rows, filteredColumns, rowNumber, fileFormat, webupManagerData, maxColumnValueLength);
102
+ }
103
+ const [currentGroup, ...remainingGroups] = groups;
104
+ const uniqueGroupValues = [
105
+ ...new Set(rows
106
+ .map(row => row.cells && row.cells[currentGroup]?.value)
107
+ .filter(value => value !== undefined)),
108
+ ].sort();
109
+ const columnTitles = Object.fromEntries(unfilteredColumns.map(col => [col.name, col.title]));
110
+ for (const groupValue of uniqueGroupValues) {
111
+ // Filter rows for the current group
112
+ const groupedRows = rows.filter(row => row.cells && row.cells[currentGroup]?.value === groupValue);
113
+ const indentation = " ".repeat((currentOutlineLevel - 1) * 8);
114
+ // Insert header row
115
+ const headerRow = worksheet.addRow([]);
116
+ headerRow.getCell(1).value =
117
+ `${indentation}▼${columnTitles[currentGroup]} - ${groupValue}`;
118
+ const headerRowNumber = ++rowNumber;
119
+ rowNumber = insertDataTableGroupedRows(worksheet, groupedRows, remainingGroups, filteredColumns, unfilteredColumns, rowNumber, fileFormat, webupManagerData, currentOutlineLevel + 1, maxColumnValueLength, totals);
120
+ const lastDataRow = rowNumber;
121
+ // Compute totals and format cells
122
+ for (const [colIndex, col] of filteredColumns.entries()) {
123
+ const cell = headerRow.getCell(colIndex + 1);
124
+ cell.numFmt = getExcelNumFormat(col.decimals ?? 0, col.integers ?? 0);
125
+ decorateHeaderRow(cell);
126
+ if (!totals)
127
+ continue;
128
+ const totalFormula = totals[col.name];
129
+ if (totalFormula && col.visible) {
130
+ cell.alignment = { horizontal: "right" };
131
+ cell.value = totalFormula.startsWith("MATH")
132
+ ? {
133
+ formula: smeupFormulaToExcelFormula(totalFormula.replace("MATH", ""), headerRowNumber - 1, filteredColumns),
134
+ }
135
+ : {
136
+ formula: getSubGroupTotalFormula(totalFormula, colIndex + 1, headerRowNumber + 1, lastDataRow),
137
+ };
138
+ }
139
+ }
140
+ }
141
+ return rowNumber;
142
+ };
143
+ /**
144
+ * Inserts normal rows (without grouping).
145
+ */
146
+ const insertDataTableRows = (worksheet, rows, filteredColumns, rowNumber, fileFormat, webupManagerData, maxColumnValueLenght) => {
147
+ for (const row of rows) {
148
+ const rowData = filteredColumns.map(column => {
149
+ const cell = (row?.cells ?? {})[column.name];
150
+ updateMaxValueLength(maxColumnValueLenght, cell?.value, column.name);
151
+ return column.formula
152
+ ? {
153
+ formula: `${smeupFormulaToExcelFormula(column.formula, rowNumber, filteredColumns)}`,
154
+ type: ValueType.Formula,
155
+ }
156
+ : calculateCellValue(cell, fileFormat, webupManagerData);
157
+ });
158
+ const newRow = worksheet.addRow(rowData);
159
+ if (exportTypeSupportsFormatting[fileFormat]) {
160
+ addStyleToExceljsRow(newRow, filteredColumns, row);
161
+ }
162
+ rowNumber++;
163
+ }
164
+ return rowNumber;
165
+ };
166
+ export const addStyleToExceljsRow = (exceljsRow, columns, row) => {
167
+ exceljsRow.eachCell((cell, cellIndex) => {
168
+ const columnIndex = cellIndex - 1;
169
+ const columnName = columns[columnIndex]?.name;
170
+ const smeupCell = row?.cells?.[columnName];
171
+ const smeupCellWithStyle = smeupCell;
172
+ if (smeupCellWithStyle?.style &&
173
+ Object.keys(smeupCellWithStyle.style).length > 0) {
174
+ cellToXlsxStyleConverter(smeupCellWithStyle, cell);
175
+ }
176
+ else if (row?.style &&
177
+ Object.keys(row.style ?? {}).length > 0) {
178
+ cellToXlsxStyleConverter(smeupCellWithStyle, cell, row.style);
179
+ }
180
+ });
181
+ };
182
+ /**
183
+ * Converts SmeupDataCell.style attributes to ExcelJS styles
184
+ * @param cell SmeupDataCell - The TBL cell containing styless
185
+ * @param xlsxCell ExcelJS.Cell - XLSX cell where styles will be applied
186
+ * @returns any
187
+ */
188
+ const cellToXlsxStyleConverter = (cell, xlsxCell, optionalRowStyles) => {
189
+ const cellStyle = optionalRowStyles ?? cell?.style;
190
+ if (!cellStyle)
191
+ return;
192
+ if (cellStyle.textAlign) {
193
+ xlsxCell.alignment = {
194
+ horizontal: cellStyle.textAlign,
195
+ };
196
+ }
197
+ if (cellStyle.backgroundColor) {
198
+ xlsxCell.fill = {
199
+ type: "pattern",
200
+ pattern: "solid",
201
+ fgColor: { argb: hexToArgb(cellStyle.backgroundColor) },
202
+ };
203
+ }
204
+ if (cellStyle.fontWeight == "bold") {
205
+ xlsxCell.font = {
206
+ ...xlsxCell.font,
207
+ bold: true,
208
+ };
209
+ }
210
+ if (cellStyle.color) {
211
+ xlsxCell.font = {
212
+ ...xlsxCell.font,
213
+ color: { argb: hexToArgb(cellStyle.color) },
214
+ };
215
+ }
216
+ if (typeof xlsxCell.value === "number" || xlsxCell.formula) {
217
+ xlsxCell.numFmt = getExcelNumFormat(cell.data?.decimals ?? 0, cell.data?.integers ?? 0);
218
+ }
219
+ };
220
+ export const getExcelNumFormat = (cellDecimals, cellIntegers) => {
221
+ // Step 1: Build the integer part with necessary '#' and '0'
222
+ let integerPart = cellIntegers ? "#".repeat(cellIntegers - 1) + "0" : "0";
223
+ // Step 2: Insert commas every three digits from the right
224
+ if (cellIntegers > 3) {
225
+ integerPart = integerPart
226
+ .split("")
227
+ .reverse()
228
+ .map((char, index) => (index > 0 && index % 3 === 0 ? char + "," : char))
229
+ .reverse()
230
+ .join("");
231
+ }
232
+ // Step 3: Build the decimal part
233
+ const decimalPart = cellDecimals > 0 ? "." + "0".repeat(cellDecimals) : ".00";
234
+ // Step 4: Construct the full format, including negative formatting
235
+ let numFmt = integerPart + decimalPart;
236
+ numFmt += `;[Red]-${numFmt}`;
237
+ return numFmt;
238
+ };
239
+ const decorateHeaderRow = (headerCell) => {
240
+ headerCell.font = { bold: true };
241
+ headerCell.alignment = { horizontal: "left" };
242
+ headerCell.fill = {
243
+ type: "pattern",
244
+ pattern: "solid",
245
+ fgColor: { argb: `${hexToArgb("e0e0e0")}` },
246
+ };
247
+ };
248
+ const getSubGroupTotalFormula = (totalOperation, colIndex, firstDataRow, lastDataRow) => {
249
+ const columnExcelLetter = getExcelColumnLetter(colIndex);
250
+ if (!allowedTotals[totalOperation]) {
251
+ console.warn(`Total operation [' ${totalOperation} '] is not supported`, "exportUtils.ts");
252
+ return "";
253
+ }
254
+ // Use full range (includes both subheaders and data rows)
255
+ return `${allowedTotals[totalOperation]}${columnExcelLetter}${firstDataRow}:${columnExcelLetter}${lastDataRow})`;
256
+ };
257
+ const ensureGroupRowHasDescription = (worksheet) => {
258
+ const firstVisibleColumnIndex = getFirstVisibleColumn(worksheet);
259
+ if (!firstVisibleColumnIndex) {
260
+ console.warn("No visible columns found in the worksheet.");
261
+ return;
262
+ }
263
+ // Iterate through each row and check if the first cell contains "▼"
264
+ worksheet.eachRow((row) => {
265
+ const cellValue = row.getCell(1).value;
266
+ if (cellValue && cellValue.toString().includes("▼")) {
267
+ row.getCell(firstVisibleColumnIndex).value = cellValue
268
+ .toString()
269
+ .replace("▼", "");
270
+ }
271
+ });
272
+ };
273
+ const getFirstVisibleColumn = (worksheet) => {
274
+ return ([...Array(worksheet.columnCount)]
275
+ .map((_, i) => i + 1) // Convert to base 1 index
276
+ .find(col => !worksheet.getColumn(col).hidden) || null);
277
+ };
278
+ // Function to analyze header indentation and assign outline levels
279
+ const applyDataTableOutlineLevels = (worksheet) => {
280
+ let lastOutlineLevel = 0;
281
+ worksheet.eachRow((row, rowIndex) => {
282
+ if (rowIndex !== 1) {
283
+ const firstCell = row.getCell(1);
284
+ const isHeader = firstCell.value?.toString().includes("▼");
285
+ if (isHeader) {
286
+ row.getCell(1).value = row.getCell(1).value.replace("▼", "");
287
+ const leadingSpaces = firstCell.value.match(/^ */)?.[0].length || 0;
288
+ const outlineLevel = Math.floor(leadingSpaces / 8) + 1; // Each 8 spaces = 1 level
289
+ row.outlineLevel = outlineLevel - 1; // Ensure headers get an outline level
290
+ lastOutlineLevel = outlineLevel;
291
+ }
292
+ else {
293
+ row.outlineLevel = lastOutlineLevel; // Normal rows follow the last assigned level
294
+ }
295
+ }
296
+ });
297
+ };
298
+ //# sourceMappingURL=matrix-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix-generator.js","sourceRoot":"","sources":["../../../src/excel/matrix-generator.ts"],"names":[],"mappings":"AAQA,OAAO,OAA4B,MAAM,SAAS,CAAC;AACnD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;AAQ9B,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,GACV,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,4BAA4B,EAC5B,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,0BAA0B,GAC3B,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,SAGC,EACD,UAAkC,EAClC,gBAAkC,EAChB,EAAE;IACpB,oEAAoE;IACpE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;IAC5D,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IACxC,MAAM,SAAS,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAEhD,MAAM,eAAe,GAAsB,kBAAkB,CAC3D,cAAc,CAAC,OAAO,CACvB,CAAC;IACF,MAAM,oBAAoB,GAA8B,EAAE,CAAC;IAE3D,IAAI,SAAS,GAAW,CAAC,CAAC,CAAC,mBAAmB;IAE9C,gBAAgB;IAChB,qBAAqB,CAAC,SAAS,EAAE,eAAe,EAA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G,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAgB,CAAC,OAAO,CAC7D,GAAG,EACH,EAAE,CACH,CAAC;gBACF,MAAM,aAAa,GAChB,SAAS,CAAC,KAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;gBAC5D,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,0BAA0B;gBAClF,GAAG,CAAC,YAAY,GAAG,YAAY,GAAG,CAAC,CAAC,CAAC,sCAAsC;gBAC3E,gBAAgB,GAAG,YAAY,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,YAAY,GAAG,gBAAgB,CAAC,CAAC,6CAA6C;YACpF,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import type { Properties as CSSProperties } from \"csstype\";\nimport {\n SmeupDataCell,\n SmeupDataColumn,\n SmeupDataNode,\n SmeupDataRow,\n SmeupDataTable,\n} from \"@sme.up/kokos-sdk-node\";\nimport ExcelJS, { Worksheet, Cell } from \"exceljs\";\nconst { ValueType } = ExcelJS;\nimport {\n GenericObject,\n WebupManagerData,\n ColumnFilter,\n SmeupDataCellStyled,\n SupportedExportFormats,\n} from \"../types/index.js\";\nimport {\n getFilteredColumns,\n filterRows,\n updateMaxValueLength,\n calculateCellValue,\n hexToArgb,\n} from \"../utils/generator-utility.js\";\nimport {\n exportTypeSupportsFormatting,\n allowedTotals,\n} from \"./excel-generator.types.js\";\nimport { isColumnHidden } from \"../utils/datastructure-utility.js\";\nimport {\n addFooterTotalsRow,\n getExcelColumnLetter,\n initializeWorksheet,\n setHeaderStyling,\n smeupFormulaToExcelFormula,\n} from \"./commons.js\";\n\nexport const dataTableToExcelWorkbook = (\n component: {\n smeupDataTable: SmeupDataTable;\n props: GenericObject;\n },\n fileFormat: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n): ExcelJS.Workbook => {\n // Create a new ExcelJS.Workbook and return it as a resolved Promise\n const { smeupDataTable: smeupDataTable, props } = component;\n const workbook = new ExcelJS.Workbook();\n const worksheet = initializeWorksheet(workbook);\n\n const filteredColumns: SmeupDataColumn[] = getFilteredColumns(\n smeupDataTable.columns,\n );\n const maxColumnValueLenght: { [key: string]: number } = {};\n\n let rowNumber: number = 1; // Start row number\n\n // Headers setup\n setDataTableHeaderRow(worksheet, filteredColumns, maxColumnValueLenght);\n\n // Get active groups (where visible is true)\n const groupsArray = Array.isArray(props?.groups) ? props.groups : [];\n const activeGroups = groupsArray\n .filter((group: { column: string; visible: boolean }) => group.visible)\n .map((group: { column: string; visible: boolean }) => group.column);\n\n // Filter and sort rows (if filters are available)\n const rows = filterRows(\n smeupDataTable,\n filteredColumns,\n props?.filters as { [key: string]: ColumnFilter },\n );\n\n if (activeGroups?.length > 0) {\n // Sort rows based on the first active group column\n rows.sort((a, b) => {\n for (const group of activeGroups) {\n const valA =\n a.cells && a.cells[group]?.value !== undefined\n ? a.cells[group]?.value\n : \"\";\n const valB =\n b.cells && b.cells[group]?.value !== undefined\n ? b.cells[group]?.value\n : \"\";\n if (valA !== valB) return valA.localeCompare(valB);\n }\n return 0;\n });\n\n // Recursive grouping\n rowNumber = insertDataTableGroupedRows(\n worksheet,\n rows,\n activeGroups,\n filteredColumns,\n smeupDataTable.columns,\n rowNumber,\n fileFormat,\n webupManagerData,\n 1,\n maxColumnValueLenght,\n (props?.totals ?? {}) as Record<string, string>,\n );\n\n //INTERACTIVE GROUPS MANAGING\n //TODO: Add groups subtotals\n if (worksheet.getColumn(1).hidden) ensureGroupRowHasDescription(worksheet);\n applyDataTableOutlineLevels(worksheet);\n worksheet.properties.outlineProperties = {\n summaryBelow: false,\n summaryRight: false,\n };\n } else {\n // Process rows normally if no grouping\n rowNumber = insertDataTableRows(\n worksheet,\n rows,\n filteredColumns,\n rowNumber,\n fileFormat,\n webupManagerData,\n maxColumnValueLenght,\n );\n }\n\n if (exportTypeSupportsFormatting[fileFormat] && props?.totals) {\n addFooterTotalsRow(worksheet, filteredColumns, props, webupManagerData);\n }\n\n // Apply column width\n worksheet.columns.forEach(col => {\n const columnKey = col.key;\n if (columnKey) {\n col.width = (maxColumnValueLenght[columnKey] ?? 10) * 1.1;\n } else {\n col.width = 10 * 1.1; // Default width\n }\n });\n\n // Apply filter to column headers\n // TODO: look if it breaks groupings\n worksheet.autoFilter = {\n from: { row: 1, column: 1 },\n to: { row: rowNumber, column: filteredColumns.length },\n };\n\n // Forces full calculation when the workbook is opened\n workbook.calcProperties = {\n fullCalcOnLoad: true,\n };\n\n return workbook;\n};\n\n/**\n * Creates the first row of the table by looking at dataTable columns.\n * Also updates column width calculations\n * @param worksheet\n * @param filteredColumns\n * @param maxValueLengthMap\n */\nconst setDataTableHeaderRow = (\n worksheet: Worksheet,\n filteredColumns: SmeupDataColumn[],\n maxValueLengthMap: { [key: string]: number },\n) => {\n worksheet.columns = filteredColumns.map(col => {\n updateMaxValueLength(maxValueLengthMap, col.title, col.name);\n return {\n header: col.title,\n key: col.name,\n width: maxValueLengthMap[col.name], // Set the width to the updated value\n hidden: isColumnHidden(col),\n } as ExcelJS.Column;\n });\n\n setHeaderStyling(worksheet);\n};\n\nconst insertDataTableGroupedRows = (\n worksheet: ExcelJS.Worksheet,\n rows: SmeupDataRow[],\n groups: string[],\n filteredColumns: SmeupDataColumn[],\n unfilteredColumns: SmeupDataColumn[],\n rowNumber: number,\n fileFormat: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n currentOutlineLevel: number = 1,\n maxColumnValueLength: Record<string, number>,\n totals: Record<string, string>,\n): number => {\n if (!groups.length) {\n return insertDataTableRows(\n worksheet,\n rows,\n filteredColumns,\n rowNumber,\n fileFormat,\n webupManagerData,\n maxColumnValueLength,\n );\n }\n\n const [currentGroup, ...remainingGroups] = groups;\n const uniqueGroupValues = [\n ...new Set(\n rows\n .map(row => row.cells && row.cells[currentGroup]?.value)\n .filter(value => value !== undefined),\n ),\n ].sort();\n const columnTitles = Object.fromEntries(\n unfilteredColumns.map(col => [col.name, col.title]),\n );\n\n for (const groupValue of uniqueGroupValues) {\n // Filter rows for the current group\n const groupedRows = rows.filter(\n row => row.cells && row.cells[currentGroup]?.value === groupValue,\n );\n const indentation = \" \".repeat((currentOutlineLevel - 1) * 8);\n\n // Insert header row\n const headerRow = worksheet.addRow([]);\n headerRow.getCell(1).value =\n `${indentation}▼${columnTitles[currentGroup]} - ${groupValue}`;\n const headerRowNumber = ++rowNumber;\n\n rowNumber = insertDataTableGroupedRows(\n worksheet,\n groupedRows,\n remainingGroups,\n filteredColumns,\n unfilteredColumns,\n rowNumber,\n fileFormat,\n webupManagerData,\n currentOutlineLevel + 1,\n maxColumnValueLength,\n totals,\n );\n const lastDataRow = rowNumber;\n\n // Compute totals and format cells\n for (const [colIndex, col] of filteredColumns.entries()) {\n const cell = headerRow.getCell(colIndex + 1);\n cell.numFmt = getExcelNumFormat(col.decimals ?? 0, col.integers ?? 0);\n decorateHeaderRow(cell);\n if (!totals) continue;\n const totalFormula = totals[col.name];\n if (totalFormula && col.visible) {\n cell.alignment = { horizontal: \"right\" };\n\n cell.value = totalFormula.startsWith(\"MATH\")\n ? {\n formula: smeupFormulaToExcelFormula(\n totalFormula.replace(\"MATH\", \"\"),\n headerRowNumber - 1,\n filteredColumns,\n ),\n }\n : {\n formula: getSubGroupTotalFormula(\n totalFormula,\n colIndex + 1,\n headerRowNumber + 1,\n lastDataRow,\n ),\n };\n }\n }\n }\n\n return rowNumber;\n};\n\n/**\n * Inserts normal rows (without grouping).\n */\nconst insertDataTableRows = (\n worksheet: ExcelJS.Worksheet,\n rows: SmeupDataRow[],\n filteredColumns: SmeupDataColumn[],\n rowNumber: number,\n fileFormat: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n maxColumnValueLenght: { [key: string]: number },\n): number => {\n for (const row of rows) {\n const rowData = filteredColumns.map(column => {\n const cell: SmeupDataCell = (row?.cells ?? {})[column.name];\n updateMaxValueLength(maxColumnValueLenght, cell?.value, column.name);\n return column.formula\n ? {\n formula: `${smeupFormulaToExcelFormula(\n column.formula,\n rowNumber,\n filteredColumns,\n )}`,\n type: ValueType.Formula,\n }\n : calculateCellValue(cell, fileFormat, webupManagerData);\n });\n\n const newRow = worksheet.addRow(rowData);\n if (exportTypeSupportsFormatting[fileFormat]) {\n addStyleToExceljsRow(newRow, filteredColumns, row);\n }\n\n rowNumber++;\n }\n\n return rowNumber;\n};\n\nexport const addStyleToExceljsRow = (\n exceljsRow: ExcelJS.Row,\n columns: SmeupDataColumn[],\n row: SmeupDataRow | SmeupDataNode,\n) => {\n exceljsRow.eachCell((cell, cellIndex) => {\n const columnIndex = cellIndex - 1;\n const columnName = columns[columnIndex]?.name;\n const smeupCell = row?.cells?.[columnName];\n const smeupCellWithStyle = smeupCell as SmeupDataCellStyled;\n if (\n smeupCellWithStyle?.style &&\n Object.keys(smeupCellWithStyle.style).length > 0\n ) {\n cellToXlsxStyleConverter(smeupCellWithStyle, cell);\n } else if (\n (row as SmeupDataCellStyled)?.style &&\n Object.keys((row as SmeupDataCellStyled).style ?? {}).length > 0\n ) {\n cellToXlsxStyleConverter(\n smeupCellWithStyle,\n cell,\n (row as SmeupDataCellStyled).style,\n );\n }\n });\n};\n\n/**\n * Converts SmeupDataCell.style attributes to ExcelJS styles\n * @param cell SmeupDataCell - The TBL cell containing styless\n * @param xlsxCell ExcelJS.Cell - XLSX cell where styles will be applied\n * @returns any\n */\nconst cellToXlsxStyleConverter = (\n cell: SmeupDataCell,\n xlsxCell: Cell,\n optionalRowStyles?: CSSProperties,\n) => {\n const cellStyle = optionalRowStyles ?? (cell as SmeupDataCellStyled)?.style;\n if (!cellStyle) return;\n\n if (cellStyle.textAlign) {\n xlsxCell.alignment = {\n horizontal: cellStyle.textAlign as\n | \"left\"\n | \"center\"\n | \"right\"\n | \"fill\"\n | \"justify\"\n | \"centerContinuous\"\n | \"distributed\",\n };\n }\n\n if (cellStyle.backgroundColor) {\n xlsxCell.fill = {\n type: \"pattern\",\n pattern: \"solid\",\n fgColor: { argb: hexToArgb(cellStyle.backgroundColor) },\n };\n }\n if (cellStyle.fontWeight == \"bold\") {\n xlsxCell.font = {\n ...xlsxCell.font,\n bold: true,\n };\n }\n if (cellStyle.color) {\n xlsxCell.font = {\n ...xlsxCell.font,\n color: { argb: hexToArgb(cellStyle.color) },\n };\n }\n\n if (typeof xlsxCell.value === \"number\" || xlsxCell.formula) {\n xlsxCell.numFmt = getExcelNumFormat(\n (cell.data?.decimals as number) ?? 0,\n (cell.data?.integers as number) ?? 0,\n );\n }\n};\n\nexport const getExcelNumFormat = (\n cellDecimals: number,\n cellIntegers: number,\n): string => {\n // Step 1: Build the integer part with necessary '#' and '0'\n let integerPart = cellIntegers ? \"#\".repeat(cellIntegers - 1) + \"0\" : \"0\";\n\n // Step 2: Insert commas every three digits from the right\n if (cellIntegers > 3) {\n integerPart = integerPart\n .split(\"\")\n .reverse()\n .map((char, index) => (index > 0 && index % 3 === 0 ? char + \",\" : char))\n .reverse()\n .join(\"\");\n }\n\n // Step 3: Build the decimal part\n const decimalPart = cellDecimals > 0 ? \".\" + \"0\".repeat(cellDecimals) : \".00\";\n\n // Step 4: Construct the full format, including negative formatting\n let numFmt = integerPart + decimalPart;\n numFmt += `;[Red]-${numFmt}`;\n\n return numFmt;\n};\n\nconst decorateHeaderRow = (headerCell: ExcelJS.Cell) => {\n headerCell.font = { bold: true };\n headerCell.alignment = { horizontal: \"left\" };\n headerCell.fill = {\n type: \"pattern\",\n pattern: \"solid\",\n fgColor: { argb: `${hexToArgb(\"e0e0e0\")}` },\n };\n};\n\nconst getSubGroupTotalFormula = (\n totalOperation: string,\n colIndex: number,\n firstDataRow: number,\n lastDataRow: number,\n): string => {\n const columnExcelLetter = getExcelColumnLetter(colIndex);\n\n if (!allowedTotals[totalOperation]) {\n console.warn(\n `Total operation [' ${totalOperation} '] is not supported`,\n \"exportUtils.ts\",\n );\n return \"\";\n }\n\n // Use full range (includes both subheaders and data rows)\n return `${allowedTotals[totalOperation]}${columnExcelLetter}${firstDataRow}:${columnExcelLetter}${lastDataRow})`;\n};\n\nconst ensureGroupRowHasDescription = (worksheet: ExcelJS.Worksheet) => {\n const firstVisibleColumnIndex = getFirstVisibleColumn(worksheet);\n if (!firstVisibleColumnIndex) {\n console.warn(\"No visible columns found in the worksheet.\");\n return;\n }\n // Iterate through each row and check if the first cell contains \"▼\"\n worksheet.eachRow((row: ExcelJS.Row) => {\n const cellValue = row.getCell(1).value;\n if (cellValue && cellValue.toString().includes(\"▼\")) {\n row.getCell(firstVisibleColumnIndex).value = cellValue\n .toString()\n .replace(\"▼\", \"\");\n }\n });\n};\n\nconst getFirstVisibleColumn = (worksheet: ExcelJS.Worksheet) => {\n return (\n [...Array(worksheet.columnCount)]\n .map((_, i) => i + 1) // Convert to base 1 index\n .find(col => !worksheet.getColumn(col).hidden) || null\n );\n};\n\n// Function to analyze header indentation and assign outline levels\nconst applyDataTableOutlineLevels = (worksheet: ExcelJS.Worksheet) => {\n let lastOutlineLevel = 0;\n\n worksheet.eachRow((row, rowIndex) => {\n if (rowIndex !== 1) {\n const firstCell = row.getCell(1);\n const isHeader = firstCell.value?.toString().includes(\"▼\");\n\n if (isHeader) {\n row.getCell(1).value = (row.getCell(1).value as string).replace(\n \"▼\",\n \"\",\n );\n const leadingSpaces =\n (firstCell.value as string).match(/^ */)?.[0].length || 0;\n const outlineLevel = Math.floor(leadingSpaces / 8) + 1; // Each 8 spaces = 1 level\n row.outlineLevel = outlineLevel - 1; // Ensure headers get an outline level\n lastOutlineLevel = outlineLevel;\n } else {\n row.outlineLevel = lastOutlineLevel; // Normal rows follow the last assigned level\n }\n }\n });\n};\n"]}
@@ -0,0 +1,9 @@
1
+ import { SmeupDataTree } from "@sme.up/kokos-sdk-node";
2
+ import { GenericObject, SupportedExportFormats, WebupManagerData } from "../types/index.js";
3
+ import ExcelJS from "exceljs";
4
+ export declare function dataTreeToExcelWorkbook(component: {
5
+ smeupDataTree: SmeupDataTree;
6
+ props: GenericObject;
7
+ }, fileFormat: SupportedExportFormats, webupManagerData: WebupManagerData, splitNodesToColumns?: boolean): Promise<ExcelJS.Workbook>;
8
+ export declare const TREE_HEADER_COLUMN_NAME = "TREE_NODE_LVL_";
9
+ export declare const getTreeNodeColumnName: (level: number) => string;
@@ -0,0 +1,117 @@
1
+ import { exportTypeSupportsFormatting } from "./excel-generator.types.js";
2
+ import ExcelJS from "exceljs";
3
+ import { addFooterTotalsRow, initializeWorksheet, setHeaderStyling, } from "./commons.js";
4
+ import { isColumnHidden } from "../utils/datastructure-utility.js";
5
+ import { getFilteredColumns, calculateCellValue, } from "../utils/generator-utility.js";
6
+ import { addStyleToExceljsRow } from "./matrix-generator.js";
7
+ export async function dataTreeToExcelWorkbook(component, fileFormat, webupManagerData, splitNodesToColumns = true) {
8
+ const { smeupDataTree, props } = component;
9
+ const workbook = new ExcelJS.Workbook();
10
+ const worksheet = initializeWorksheet(workbook);
11
+ const columnsMaxWidth = {};
12
+ // Add ExcelJS columns
13
+ const headerColumns = addTreeColumns(worksheet, smeupDataTree.columns ?? [], smeupDataTree.children, splitNodesToColumns);
14
+ // Add ExcelJS rows
15
+ addTreeNodeRows(worksheet, fileFormat, webupManagerData, columnsMaxWidth, headerColumns, smeupDataTree.children, splitNodesToColumns);
16
+ // Totals
17
+ if (exportTypeSupportsFormatting[fileFormat] && props?.totals) {
18
+ addFooterTotalsRow(worksheet, headerColumns, props, webupManagerData);
19
+ }
20
+ // Set ExcelJS columns width
21
+ worksheet.columns.forEach(col => {
22
+ if (col.key) {
23
+ col.width = columnsMaxWidth[col.key] ?? 10;
24
+ }
25
+ else {
26
+ col.width = 10;
27
+ }
28
+ });
29
+ // Forces full calculation when the workbook is opened
30
+ workbook.calcProperties = {
31
+ fullCalcOnLoad: true,
32
+ };
33
+ return workbook;
34
+ }
35
+ const addTreeColumns = (worksheet, columns, nodeRows, splitNodesToColumns) => {
36
+ const addTreeNodeColumns = (nodeRows, nodeColumns, level = 0) => {
37
+ if (!nodeColumns.some(nodeColumn => nodeColumn.name === getTreeNodeColumnName(level))) {
38
+ nodeColumns.push({
39
+ name: getTreeNodeColumnName(level),
40
+ title: `.${level + 1}`,
41
+ });
42
+ }
43
+ nodeRows.forEach(row => {
44
+ if (row.children?.length ?? 0 > 0) {
45
+ addTreeNodeColumns(row.children ?? [], nodeColumns, level + 1);
46
+ }
47
+ });
48
+ };
49
+ const nodeColumns = [];
50
+ if (splitNodesToColumns) {
51
+ // New column for each tree node
52
+ addTreeNodeColumns(nodeRows, nodeColumns);
53
+ }
54
+ else {
55
+ // All tree nodes are under the same column
56
+ nodeColumns.push({
57
+ name: getTreeNodeColumnName(0),
58
+ title: "",
59
+ });
60
+ }
61
+ const filteredColumns = getFilteredColumns(columns);
62
+ const headerColumns = [...nodeColumns, ...filteredColumns];
63
+ /* Add ExcelJS columns*/
64
+ worksheet.columns = headerColumns.map(column => ({
65
+ header: column.title ?? "",
66
+ key: column.name,
67
+ hidden: isColumnHidden(column),
68
+ }));
69
+ // Add style to ExcelJS columns
70
+ setHeaderStyling(worksheet, true);
71
+ return headerColumns;
72
+ };
73
+ const addTreeNodeRows = (worksheet, fileFormat, webupManagerData, columnsMaxWidth, columns, nodeRows, splitNodesToColumns, level = 0) => {
74
+ const getParsedRowData = (row) => {
75
+ return columns.map(column => {
76
+ /* Set cell value */
77
+ let cellValue = "";
78
+ if (column.name.includes(TREE_HEADER_COLUMN_NAME)) {
79
+ /* Node column */
80
+ if (!splitNodesToColumns) {
81
+ // Level-based indentation
82
+ const indent = ` `.repeat(level);
83
+ cellValue = `${indent}${row.obj?.k}: ${row.value}`;
84
+ }
85
+ else if (column.name === getTreeNodeColumnName(level)) {
86
+ // No indentation
87
+ cellValue = `${row.obj?.k}: ${row.value}`;
88
+ }
89
+ }
90
+ else {
91
+ /* Standard column */
92
+ cellValue = calculateCellValue(row.cells?.[column.name] ?? { value: "" }, fileFormat, webupManagerData);
93
+ }
94
+ /* Update column max width */
95
+ const currentMaxWidth = columnsMaxWidth[column.name] ?? 10;
96
+ const cellLength = cellValue instanceof Date ? 10 : cellValue.toString().length;
97
+ columnsMaxWidth[column.name] = Math.max(currentMaxWidth, cellLength);
98
+ return cellValue;
99
+ });
100
+ };
101
+ nodeRows.forEach(row => {
102
+ /* Add ExcelJS row */
103
+ const parsedRowData = getParsedRowData(row);
104
+ const exceljsRow = worksheet.addRow(parsedRowData);
105
+ if (exportTypeSupportsFormatting[fileFormat]) {
106
+ addStyleToExceljsRow(exceljsRow, columns, row);
107
+ }
108
+ if (row.children?.length ?? 0 > 0) {
109
+ addTreeNodeRows(worksheet, fileFormat, webupManagerData, columnsMaxWidth, columns, row.children ?? [], splitNodesToColumns, level + 1);
110
+ }
111
+ });
112
+ };
113
+ export const TREE_HEADER_COLUMN_NAME = "TREE_NODE_LVL_";
114
+ export const getTreeNodeColumnName = (level) => {
115
+ return `${TREE_HEADER_COLUMN_NAME}${level}`;
116
+ };
117
+ //# sourceMappingURL=tree-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree-generator.js","sourceRoot":"","sources":["../../../src/excel/tree-generator.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,SAGC,EACD,UAAkC,EAClC,gBAAkC,EAClC,mBAAmB,GAAG,IAAI;IAE1B,MAAM,EAAE,aAAa,E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import {\n GenericObject,\n SupportedExportFormats,\n WebupManagerData,\n} from \"../types/index.js\";\nimport { exportTypeSupportsFormatting } from \"./excel-generator.types.js\";\nimport ExcelJS from \"exceljs\";\nimport {\n addFooterTotalsRow,\n initializeWorksheet,\n setHeaderStyling,\n} from \"./commons.js\";\nimport { isColumnHidden } from \"../utils/datastructure-utility.js\";\nimport {\n getFilteredColumns,\n calculateCellValue,\n} from \"../utils/generator-utility.js\";\nimport { addStyleToExceljsRow } from \"./matrix-generator.js\";\n\nexport async function dataTreeToExcelWorkbook(\n component: {\n smeupDataTree: SmeupDataTree;\n props: GenericObject;\n },\n fileFormat: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n splitNodesToColumns = true,\n): Promise<ExcelJS.Workbook> {\n const { smeupDataTree, props } = component;\n const workbook = new ExcelJS.Workbook();\n const worksheet = initializeWorksheet(workbook);\n const columnsMaxWidth: { [columnName: string]: number } = {};\n\n // Add ExcelJS columns\n const headerColumns = addTreeColumns(\n worksheet,\n smeupDataTree.columns ?? [],\n smeupDataTree.children,\n splitNodesToColumns,\n );\n\n // Add ExcelJS rows\n addTreeNodeRows(\n worksheet,\n fileFormat,\n webupManagerData,\n columnsMaxWidth,\n headerColumns,\n smeupDataTree.children,\n splitNodesToColumns,\n );\n\n // Totals\n if (exportTypeSupportsFormatting[fileFormat] && props?.totals) {\n addFooterTotalsRow(worksheet, headerColumns, props, webupManagerData);\n }\n\n // Set ExcelJS columns width\n worksheet.columns.forEach(col => {\n if (col.key) {\n col.width = columnsMaxWidth[col.key] ?? 10;\n } else {\n col.width = 10;\n }\n });\n\n // Forces full calculation when the workbook is opened\n workbook.calcProperties = {\n fullCalcOnLoad: true,\n };\n return workbook;\n}\n\nconst addTreeColumns = (\n worksheet: ExcelJS.Worksheet,\n columns: SmeupDataColumn[],\n nodeRows: SmeupDataNode[],\n splitNodesToColumns: boolean,\n): SmeupDataColumn[] => {\n const addTreeNodeColumns = (\n nodeRows: SmeupDataNode[],\n nodeColumns: SmeupDataColumn[],\n level = 0,\n ) => {\n if (\n !nodeColumns.some(\n nodeColumn => nodeColumn.name === getTreeNodeColumnName(level),\n )\n ) {\n nodeColumns.push({\n name: getTreeNodeColumnName(level),\n title: `.${level + 1}`,\n });\n }\n\n nodeRows.forEach(row => {\n if (row.children?.length ?? 0 > 0) {\n addTreeNodeColumns(row.children ?? [], nodeColumns, level + 1);\n }\n });\n };\n\n const nodeColumns: SmeupDataColumn[] = [];\n if (splitNodesToColumns) {\n // New column for each tree node\n addTreeNodeColumns(nodeRows, nodeColumns);\n } else {\n // All tree nodes are under the same column\n nodeColumns.push({\n name: getTreeNodeColumnName(0),\n title: \"\",\n });\n }\n\n const filteredColumns: SmeupDataColumn[] = getFilteredColumns(columns);\n const headerColumns: SmeupDataColumn[] = [...nodeColumns, ...filteredColumns];\n\n /* Add ExcelJS columns*/\n worksheet.columns = headerColumns.map<Partial<ExcelJS.Column>>(column => ({\n header: column.title ?? \"\",\n key: column.name,\n hidden: isColumnHidden(column),\n }));\n // Add style to ExcelJS columns\n setHeaderStyling(worksheet, true);\n return headerColumns;\n};\n\nconst addTreeNodeRows = (\n worksheet: ExcelJS.Worksheet,\n fileFormat: SupportedExportFormats,\n webupManagerData: WebupManagerData,\n columnsMaxWidth: { [columnName: string]: number },\n columns: SmeupDataColumn[],\n nodeRows: SmeupDataNode[],\n splitNodesToColumns: boolean,\n level = 0,\n): void => {\n const getParsedRowData = (row: SmeupDataNode): (string | number | Date)[] => {\n return columns.map<string | number | Date>(column => {\n /* Set cell value */\n let cellValue: string | number | Date = \"\";\n\n if (column.name.includes(TREE_HEADER_COLUMN_NAME)) {\n /* Node column */\n if (!splitNodesToColumns) {\n // Level-based indentation\n const indent = ` `.repeat(level);\n cellValue = `${indent}${row.obj?.k}: ${row.value}`;\n } else if (column.name === getTreeNodeColumnName(level)) {\n // No indentation\n cellValue = `${row.obj?.k}: ${row.value}`;\n }\n } else {\n /* Standard column */\n cellValue = calculateCellValue(\n row.cells?.[column.name] ?? { value: \"\" },\n fileFormat,\n webupManagerData,\n );\n }\n\n /* Update column max width */\n const currentMaxWidth = columnsMaxWidth[column.name] ?? 10;\n const cellLength =\n cellValue instanceof Date ? 10 : cellValue.toString().length;\n columnsMaxWidth[column.name] = Math.max(currentMaxWidth, cellLength);\n\n return cellValue;\n });\n };\n\n nodeRows.forEach(row => {\n /* Add ExcelJS row */\n const parsedRowData = getParsedRowData(row);\n const exceljsRow = worksheet.addRow(parsedRowData);\n\n if (exportTypeSupportsFormatting[fileFormat]) {\n addStyleToExceljsRow(exceljsRow, columns, row);\n }\n\n if (row.children?.length ?? 0 > 0) {\n addTreeNodeRows(\n worksheet,\n fileFormat,\n webupManagerData,\n columnsMaxWidth,\n columns,\n row.children ?? [],\n splitNodesToColumns,\n level + 1,\n );\n }\n });\n};\n\nexport const TREE_HEADER_COLUMN_NAME = \"TREE_NODE_LVL_\";\n\nexport const getTreeNodeColumnName = (level: number) => {\n return `${TREE_HEADER_COLUMN_NAME}${level}`;\n};\n"]}
@@ -1 +1 @@
1
- export * from "./excel/excel-generator.js";
1
+ export * from "./excel/matrix-generator.js";
package/dist/src/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from "./excel/excel-generator.js";
1
+ export * from "./excel/matrix-generator.js";
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from \"./excel/excel-generator.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC","sourcesContent":["export * from \"./excel/matrix-generator.js\";\n"]}
@@ -1,10 +1,10 @@
1
1
  import dayjs from "dayjs";
2
- import "dayjs/locale/es";
3
- import "dayjs/locale/fr";
4
- import "dayjs/locale/it";
5
- import "dayjs/locale/pl";
6
- import "dayjs/locale/ru";
7
- import "dayjs/locale/zh";
2
+ import "dayjs/locale/es.js";
3
+ import "dayjs/locale/fr.js";
4
+ import "dayjs/locale/it.js";
5
+ import "dayjs/locale/pl.js";
6
+ import "dayjs/locale/ru.js";
7
+ import "dayjs/locale/zh.js";
8
8
  export declare const datesFormat: (input: dayjs.ConfigType, locale: string, format?: string) => string;
9
9
  export declare const datesIsIsoDate: (dateString: string) => boolean;
10
10
  export declare const datesToDate: (input: dayjs.ConfigType, locale: string, format?: string) => Date;
@@ -1,14 +1,14 @@
1
1
  import dayjs from "dayjs";
2
- import utc from "dayjs/plugin/utc";
3
- import customParseFormat from "dayjs/plugin/customParseFormat";
4
- import localizedFormat from "dayjs/plugin/localizedFormat";
5
- import minMax from "dayjs/plugin/minMax";
6
- import "dayjs/locale/es";
7
- import "dayjs/locale/fr";
8
- import "dayjs/locale/it";
9
- import "dayjs/locale/pl";
10
- import "dayjs/locale/ru";
11
- import "dayjs/locale/zh";
2
+ import utc from "dayjs/plugin/utc.js";
3
+ import customParseFormat from "dayjs/plugin/customParseFormat.js";
4
+ import localizedFormat from "dayjs/plugin/localizedFormat.js";
5
+ import minMax from "dayjs/plugin/minMax.js";
6
+ import "dayjs/locale/es.js";
7
+ import "dayjs/locale/fr.js";
8
+ import "dayjs/locale/it.js";
9
+ import "dayjs/locale/pl.js";
10
+ import "dayjs/locale/ru.js";
11
+ import "dayjs/locale/zh.js";
12
12
  import { DatesFormats } from "../types/index.js";
13
13
  dayjs.extend(utc);
14
14
  dayjs.extend(customParseFormat);
@@ -1 +1 @@
1
- {"version":3,"file":"dates-utility.js","sourceRoot":"","sources":["../../../src/utils/dates-utility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,kBAAkB,CAAC;AACnC,OAAO,iBAAiB,MAAM,gCAAgC,CAAC;AAC/D,OAAO,eAAe,MAAM,8BAA8B,CAAC;AAC3D,OAAO,MAAM,MAAM,qBAAqB,CAAC;AACzC,OAAO,iB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CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,CAAC;QAC9D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;QAC1D,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,KAAuB,EACvB,MAAc,EACd,MAAe,EACT,EAAE;IACR,MAAM,MAAM,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,MAAM,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport minMax from \"dayjs/plugin/minMax\";\nimport \"dayjs/locale/es\";\nimport \"dayjs/locale/fr\";\nimport \"dayjs/locale/it\";\nimport \"dayjs/locale/pl\";\nimport \"dayjs/locale/ru\";\nimport \"dayjs/locale/zh\";\nimport { DatesFormats } from \"../types/index.js\";\n\ndayjs.extend(utc);\ndayjs.extend(customParseFormat);\ndayjs.extend(localizedFormat);\ndayjs.extend(minMax);\n\nexport const datesFormat = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): string => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (!format) {\n format = \"L\"; // MM/DD/YYYY, DD/MM/YYYY depending on locale\n }\n return _dayjs.utc(input).format(format);\n};\n\nexport const datesIsIsoDate = (dateString: string): boolean => {\n const isoDate = dayjs(dateString, [\n DatesFormats.ISO_DATE,\n DatesFormats.ISO_DATE_TIME,\n \"YYYY-MM-DDTHH:mm:ss.SSSZ\",\n ]);\n if (!isoDate.isValid()) {\n return false;\n }\n\n if (Number(dateString.substring(0, 4)) != isoDate.year()) {\n return false;\n }\n if (Number(dateString.substring(5, 7)) != isoDate.month() + 1) {\n return false;\n }\n if (Number(dateString.substring(8, 10)) != isoDate.date()) {\n return false;\n }\n return true;\n};\n\nexport const datesToDate = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): Date => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (format && format != null) {\n return _dayjs.utc(input, format).toDate();\n } else {\n return _dayjs.utc(input).toDate();\n }\n};\n"]}
1
+ {"version":3,"file":"dates-utility.js","sourceRoot":"","sources":["../../../src/utils/dates-utility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,qBAAqB,CAAC;AACtC,OAAO,iBAAiB,MAAM,mCAAmC,CAAC;AAClE,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAClB,KAAK,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAChC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;AAC9B,KAAK,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,CACzB,KAAuB,EACvB,MAAc,EACd,MAAe,EACT,EAAE;IACR,MAAM,MAAM,GAAG,KAAK,CAAC;IACrB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,MAAM,IAAI,MAAM,IAAI,IAAI,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import dayjs from \"dayjs\";\nimport utc from \"dayjs/plugin/utc.js\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat.js\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat.js\";\nimport minMax from \"dayjs/plugin/minMax.js\";\nimport \"dayjs/locale/es.js\";\nimport \"dayjs/locale/fr.js\";\nimport \"dayjs/locale/it.js\";\nimport \"dayjs/locale/pl.js\";\nimport \"dayjs/locale/ru.js\";\nimport \"dayjs/locale/zh.js\";\nimport { DatesFormats } from \"../types/index.js\";\n\ndayjs.extend(utc);\ndayjs.extend(customParseFormat);\ndayjs.extend(localizedFormat);\ndayjs.extend(minMax);\n\nexport const datesFormat = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): string => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (!format) {\n format = \"L\"; // MM/DD/YYYY, DD/MM/YYYY depending on locale\n }\n return _dayjs.utc(input).format(format);\n};\n\nexport const datesIsIsoDate = (dateString: string): boolean => {\n const isoDate = dayjs(dateString, [\n DatesFormats.ISO_DATE,\n DatesFormats.ISO_DATE_TIME,\n \"YYYY-MM-DDTHH:mm:ss.SSSZ\",\n ]);\n if (!isoDate.isValid()) {\n return false;\n }\n\n if (Number(dateString.substring(0, 4)) != isoDate.year()) {\n return false;\n }\n if (Number(dateString.substring(5, 7)) != isoDate.month() + 1) {\n return false;\n }\n if (Number(dateString.substring(8, 10)) != isoDate.date()) {\n return false;\n }\n return true;\n};\n\nexport const datesToDate = (\n input: dayjs.ConfigType,\n locale: string,\n format?: string,\n): Date => {\n const _dayjs = dayjs;\n _dayjs.locale(locale);\n if (format && format != null) {\n return _dayjs.utc(input, format).toDate();\n } else {\n return _dayjs.utc(input).toDate();\n }\n};\n"]}
@@ -1,17 +1 @@
1
- import { SmeupDataTable } from "@sme.up/kokos-sdk-node";
2
- export declare const table_footer_actions: (action: string, groups: {
3
- column: string;
4
- visible: boolean;
5
- }[], rowsNumber?: number, rowRepetitions?: number) => {
6
- smeupDataTable: SmeupDataTable;
7
- props: {
8
- groups: {
9
- column: string;
10
- visible: boolean;
11
- }[];
12
- totals: never[] | {
13
- [x: string]: string;
14
- };
15
- filter: never[];
16
- };
17
- };
1
+ export {};