nillud-data-table 1.0.1 → 1.0.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/README.md +8 -12
- package/dist/ExportSection-ZYOK6KMB.js +247 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +11 -256
- package/package.json +9 -4
- package/dist/index.cjs +0 -821
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -58
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
@@ -434,23 +434,19 @@ excelCustomColumns={[
|
|
434
434
|
|
435
435
|
Для использования модуля Excel необходимо установить библиотеку [exceljs](https://www.npmjs.com/package/exceljs)
|
436
436
|
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
```
|
437
|
+
Для использования модуля экспорта необходимо его подключить
|
438
|
+
```ts
|
439
|
+
import { exportToExcel } from 'nillud-data-table/export-excel';
|
440
|
+
```
|
442
441
|
|
443
442
|
### wordBtn
|
444
443
|
|
445
444
|
Необязательный параметр. Тип **boolean**, по умолчанию **false**. При значении **true** над таблицей с правой стороны появляется кнопка экспорта Word, которая по умолчанию принимает в себя исходный массив **tableData**
|
446
445
|
|
447
|
-
Для использования модуля
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
-или-
|
452
|
-
yarn add docx file-saver
|
453
|
-
```
|
446
|
+
Для использования модуля экспорта необходимо его подключить
|
447
|
+
```ts
|
448
|
+
import { exportToWord } from 'nillud-data-table/export-word';
|
449
|
+
```
|
454
450
|
|
455
451
|
### wordOptions
|
456
452
|
|
@@ -0,0 +1,247 @@
|
|
1
|
+
// components/export/WordExport.tsx
|
2
|
+
import {
|
3
|
+
AlignmentType,
|
4
|
+
Document,
|
5
|
+
Packer,
|
6
|
+
PageOrientation,
|
7
|
+
Paragraph,
|
8
|
+
Table,
|
9
|
+
TableCell,
|
10
|
+
TableRow,
|
11
|
+
TextRun,
|
12
|
+
VerticalAlign,
|
13
|
+
WidthType
|
14
|
+
} from "docx";
|
15
|
+
import saveAs from "file-saver";
|
16
|
+
|
17
|
+
// utils/exportUtils/ExportHelpers.ts
|
18
|
+
function prepareExportRows(columns, data) {
|
19
|
+
return data.map(
|
20
|
+
(row) => columns.map((col) => {
|
21
|
+
const value = row[col.field];
|
22
|
+
return typeof col.exportCustomCell !== "undefined" ? col.exportCustomCell(String(value), row) : String(value != null ? value : "");
|
23
|
+
})
|
24
|
+
);
|
25
|
+
}
|
26
|
+
function prepareExportHeaders(columns) {
|
27
|
+
return columns.map((col) => col.title);
|
28
|
+
}
|
29
|
+
|
30
|
+
// components/export/WordExport.tsx
|
31
|
+
import { jsx } from "react/jsx-runtime";
|
32
|
+
var WordExport = ({
|
33
|
+
wordData,
|
34
|
+
columns,
|
35
|
+
title,
|
36
|
+
options = {
|
37
|
+
fontSize: 20,
|
38
|
+
boldHeaders: false,
|
39
|
+
autoLandscape: false,
|
40
|
+
maxColumnsBeforeLandscape: 5
|
41
|
+
}
|
42
|
+
// exportCustomColumns
|
43
|
+
}) => {
|
44
|
+
const createNewWord = async () => {
|
45
|
+
const {
|
46
|
+
fontSize = 0,
|
47
|
+
boldHeaders = true,
|
48
|
+
autoLandscape = true,
|
49
|
+
maxColumnsBeforeLandscape = 5
|
50
|
+
} = options;
|
51
|
+
const isLandscape = autoLandscape && columns.length > maxColumnsBeforeLandscape;
|
52
|
+
const headerCells = prepareExportHeaders(columns).map((header) => new TableCell({
|
53
|
+
children: [new Paragraph({
|
54
|
+
children: [new TextRun({
|
55
|
+
text: header,
|
56
|
+
size: fontSize,
|
57
|
+
bold: boldHeaders
|
58
|
+
})],
|
59
|
+
alignment: AlignmentType.CENTER
|
60
|
+
})],
|
61
|
+
verticalAlign: VerticalAlign.CENTER
|
62
|
+
}));
|
63
|
+
const tableHeaderRow = new TableRow({ children: headerCells });
|
64
|
+
const rows = prepareExportRows(columns, wordData).map((cells) => {
|
65
|
+
const rowCells = cells.map(
|
66
|
+
(value) => new TableCell({
|
67
|
+
children: [new Paragraph({
|
68
|
+
children: [new TextRun({
|
69
|
+
text: value,
|
70
|
+
size: fontSize
|
71
|
+
})],
|
72
|
+
alignment: AlignmentType.CENTER
|
73
|
+
})],
|
74
|
+
verticalAlign: VerticalAlign.CENTER
|
75
|
+
})
|
76
|
+
);
|
77
|
+
return new TableRow({ children: rowCells });
|
78
|
+
});
|
79
|
+
const table = new Table({
|
80
|
+
rows: [tableHeaderRow, ...rows],
|
81
|
+
width: { size: 11e3, type: WidthType.DXA },
|
82
|
+
indent: { size: -1e3, type: WidthType.DXA }
|
83
|
+
});
|
84
|
+
const doc = new Document({
|
85
|
+
sections: [{
|
86
|
+
children: [table, new Paragraph({ text: "" })],
|
87
|
+
properties: isLandscape ? { page: { size: { orientation: PageOrientation.LANDSCAPE } } } : {}
|
88
|
+
}]
|
89
|
+
});
|
90
|
+
Packer.toBlob(doc).then((blob) => {
|
91
|
+
saveAs(blob, `${title}.docx`);
|
92
|
+
});
|
93
|
+
};
|
94
|
+
return /* @__PURE__ */ jsx("button", { className: `ndt-buttonExport ndt-Word}`, onClick: createNewWord, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Word" });
|
95
|
+
};
|
96
|
+
var WordExport_default = WordExport;
|
97
|
+
|
98
|
+
// utils/exportUtils/exportUtils.ts
|
99
|
+
var generateExcelColumns = (columns, exportCustomColumns) => {
|
100
|
+
let excelColumns = columns.map((column) => ({
|
101
|
+
header: column.title,
|
102
|
+
key: column.field,
|
103
|
+
width: 20
|
104
|
+
}));
|
105
|
+
if (exportCustomColumns) {
|
106
|
+
exportCustomColumns.forEach((custom) => {
|
107
|
+
excelColumns = excelColumns.map(
|
108
|
+
(col) => col.key === custom.key ? { ...col, ...custom } : col
|
109
|
+
);
|
110
|
+
});
|
111
|
+
}
|
112
|
+
return excelColumns;
|
113
|
+
};
|
114
|
+
var applyHeaderStyles = (row, columnCount) => {
|
115
|
+
row.height = 40;
|
116
|
+
row.font = { size: 12, bold: true };
|
117
|
+
row.alignment = { vertical: "middle", horizontal: "center" };
|
118
|
+
for (let i = 1; i <= columnCount; i++) {
|
119
|
+
const cell = row.getCell(i);
|
120
|
+
cell.alignment = { wrapText: true, vertical: "middle", horizontal: "center" };
|
121
|
+
cell.border = {
|
122
|
+
top: { style: "thin" },
|
123
|
+
left: { style: "thin" },
|
124
|
+
bottom: { style: "thin" },
|
125
|
+
right: { style: "thin" }
|
126
|
+
};
|
127
|
+
}
|
128
|
+
};
|
129
|
+
var applyRowStyles = (row, columnCount) => {
|
130
|
+
row.height = 40;
|
131
|
+
row.font = { size: 12 };
|
132
|
+
row.alignment = { vertical: "middle", horizontal: "center" };
|
133
|
+
for (let i = 1; i <= columnCount; i++) {
|
134
|
+
const cell = row.getCell(i);
|
135
|
+
cell.alignment = { wrapText: true, vertical: "middle", horizontal: "center" };
|
136
|
+
cell.border = {
|
137
|
+
top: { style: "thin" },
|
138
|
+
left: { style: "thin" },
|
139
|
+
bottom: { style: "thin" },
|
140
|
+
right: { style: "thin" }
|
141
|
+
};
|
142
|
+
}
|
143
|
+
};
|
144
|
+
var generateExcelDataRows = (columns, data) => {
|
145
|
+
return data.map((element) => {
|
146
|
+
const rowData = {};
|
147
|
+
columns.forEach((col) => {
|
148
|
+
const value = element[col.field];
|
149
|
+
rowData[col.field] = typeof col.exportCustomCell !== "undefined" ? col.exportCustomCell(String(value), element) : value != null ? value : "";
|
150
|
+
});
|
151
|
+
return rowData;
|
152
|
+
});
|
153
|
+
};
|
154
|
+
var setColumnAutoWidths = (sheet) => {
|
155
|
+
var _a;
|
156
|
+
(_a = sheet.columns) == null ? void 0 : _a.forEach((column) => {
|
157
|
+
var _a2;
|
158
|
+
let maxLength = 10;
|
159
|
+
(_a2 = column.eachCell) == null ? void 0 : _a2.call(column, { includeEmpty: true }, (cell) => {
|
160
|
+
const cellValue = cell.value ? String(cell.value) : "";
|
161
|
+
maxLength = Math.max(maxLength, cellValue.length + 5);
|
162
|
+
});
|
163
|
+
column.width = maxLength;
|
164
|
+
});
|
165
|
+
};
|
166
|
+
|
167
|
+
// components/export/ExportExcel.tsx
|
168
|
+
import ExcelJS from "exceljs";
|
169
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
170
|
+
var ExportExcel = ({ columns, excelData, title, exportCustomColumns }) => {
|
171
|
+
const exportExcel = () => {
|
172
|
+
const workbook = new ExcelJS.Workbook();
|
173
|
+
const sheet = workbook.addWorksheet(title, {
|
174
|
+
pageSetup: {
|
175
|
+
fitToPage: true,
|
176
|
+
fitToHeight: 2,
|
177
|
+
fitToWidth: 1,
|
178
|
+
orientation: "landscape"
|
179
|
+
},
|
180
|
+
headerFooter: {
|
181
|
+
oddFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N",
|
182
|
+
evenFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N"
|
183
|
+
}
|
184
|
+
});
|
185
|
+
const excelColumns = generateExcelColumns(columns, exportCustomColumns);
|
186
|
+
sheet.columns = excelColumns;
|
187
|
+
const headerRow = sheet.getRow(1);
|
188
|
+
applyHeaderStyles(headerRow, sheet.columns.length);
|
189
|
+
const dataRows = generateExcelDataRows(columns, excelData);
|
190
|
+
dataRows.forEach((data) => {
|
191
|
+
const row = sheet.addRow(data);
|
192
|
+
applyRowStyles(row, sheet.columns.length);
|
193
|
+
});
|
194
|
+
setColumnAutoWidths(sheet);
|
195
|
+
if (excelData.length > 15) {
|
196
|
+
sheet.pageSetup.fitToHeight = Math.floor(excelData.length / 15);
|
197
|
+
} else {
|
198
|
+
sheet.pageSetup.fitToHeight = 1;
|
199
|
+
}
|
200
|
+
workbook.xlsx.writeBuffer().then((data) => {
|
201
|
+
const blob = new Blob([data], {
|
202
|
+
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
203
|
+
});
|
204
|
+
const url = window.URL.createObjectURL(blob);
|
205
|
+
const anchor = document.createElement("a");
|
206
|
+
anchor.href = url;
|
207
|
+
anchor.download = `${title}.xlsx`;
|
208
|
+
anchor.click();
|
209
|
+
window.URL.revokeObjectURL(url);
|
210
|
+
});
|
211
|
+
};
|
212
|
+
return /* @__PURE__ */ jsx2("button", { className: `ndt-buttonExport ndt-Excel`, onClick: exportExcel, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Excel" });
|
213
|
+
};
|
214
|
+
var ExportExcel_default = ExportExcel;
|
215
|
+
|
216
|
+
// components/ExportSection.tsx
|
217
|
+
import { Fragment, jsx as jsx3, jsxs } from "react/jsx-runtime";
|
218
|
+
var ExportSection = ({ wordBtn, excelBtn, downloadSectionLeftSideContent, tableData, columns, tableName, exportCustomColumns, wordOptions }) => {
|
219
|
+
return /* @__PURE__ */ jsx3(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "ndt-download-section", children: [
|
220
|
+
/* @__PURE__ */ jsx3("div", { className: "ndt-download-content", children: (wordBtn || excelBtn) && downloadSectionLeftSideContent !== null && downloadSectionLeftSideContent }),
|
221
|
+
/* @__PURE__ */ jsxs("div", { className: "ndt-download-buttons", children: [
|
222
|
+
wordBtn && /* @__PURE__ */ jsx3(
|
223
|
+
WordExport_default,
|
224
|
+
{
|
225
|
+
wordData: tableData,
|
226
|
+
columns,
|
227
|
+
title: tableName,
|
228
|
+
exportCustomColumns,
|
229
|
+
options: wordOptions
|
230
|
+
}
|
231
|
+
),
|
232
|
+
excelBtn && /* @__PURE__ */ jsx3(
|
233
|
+
ExportExcel_default,
|
234
|
+
{
|
235
|
+
excelData: tableData,
|
236
|
+
columns,
|
237
|
+
title: tableName,
|
238
|
+
exportCustomColumns
|
239
|
+
}
|
240
|
+
)
|
241
|
+
] })
|
242
|
+
] }) });
|
243
|
+
};
|
244
|
+
var ExportSection_default = ExportSection;
|
245
|
+
export {
|
246
|
+
ExportSection_default as default
|
247
|
+
};
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import
|
2
|
-
import { ReactElement } from 'react';
|
1
|
+
import React, { ReactElement } from 'react';
|
3
2
|
|
4
3
|
type TableElement = {
|
5
4
|
[key: string]: string | number;
|
@@ -53,6 +52,6 @@ type DataTableRef = {
|
|
53
52
|
getCurrentData: () => TableData;
|
54
53
|
};
|
55
54
|
|
56
|
-
declare const DataTable:
|
55
|
+
declare const DataTable: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<DataTableRef>>;
|
57
56
|
|
58
57
|
export { type Column, DataTable, type TableElement, type TableProps };
|
package/dist/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// components/DataTable.tsx
|
2
|
-
import { useImperativeHandle, useEffect as useEffect2, useState, useCallback, useMemo as useMemo2, forwardRef } from "react";
|
2
|
+
import React3, { useImperativeHandle, useEffect as useEffect2, useState, useCallback, useMemo as useMemo2, forwardRef, Suspense } from "react";
|
3
3
|
|
4
4
|
// components/TableHeader.tsx
|
5
5
|
import React from "react";
|
@@ -384,251 +384,6 @@ var filterData = (data, filter, value) => {
|
|
384
384
|
return filteredData;
|
385
385
|
};
|
386
386
|
|
387
|
-
// components/export/WordExport.tsx
|
388
|
-
import {
|
389
|
-
AlignmentType,
|
390
|
-
Document,
|
391
|
-
Packer,
|
392
|
-
PageOrientation,
|
393
|
-
Paragraph,
|
394
|
-
Table,
|
395
|
-
TableCell,
|
396
|
-
TableRow,
|
397
|
-
TextRun,
|
398
|
-
VerticalAlign,
|
399
|
-
WidthType
|
400
|
-
} from "docx";
|
401
|
-
import saveAs from "file-saver";
|
402
|
-
|
403
|
-
// utils/exportUtils/ExportHelpers.ts
|
404
|
-
function prepareExportRows(columns, data) {
|
405
|
-
return data.map(
|
406
|
-
(row) => columns.map((col) => {
|
407
|
-
const value = row[col.field];
|
408
|
-
return typeof col.exportCustomCell !== "undefined" ? col.exportCustomCell(String(value), row) : String(value != null ? value : "");
|
409
|
-
})
|
410
|
-
);
|
411
|
-
}
|
412
|
-
function prepareExportHeaders(columns) {
|
413
|
-
return columns.map((col) => col.title);
|
414
|
-
}
|
415
|
-
|
416
|
-
// components/export/WordExport.tsx
|
417
|
-
import { jsx as jsx13 } from "react/jsx-runtime";
|
418
|
-
var WordExport = ({
|
419
|
-
wordData,
|
420
|
-
columns,
|
421
|
-
title,
|
422
|
-
options = {
|
423
|
-
fontSize: 20,
|
424
|
-
boldHeaders: false,
|
425
|
-
autoLandscape: false,
|
426
|
-
maxColumnsBeforeLandscape: 5
|
427
|
-
}
|
428
|
-
// exportCustomColumns
|
429
|
-
}) => {
|
430
|
-
const createNewWord = async () => {
|
431
|
-
const {
|
432
|
-
fontSize = 0,
|
433
|
-
boldHeaders = true,
|
434
|
-
autoLandscape = true,
|
435
|
-
maxColumnsBeforeLandscape = 5
|
436
|
-
} = options;
|
437
|
-
const isLandscape = autoLandscape && columns.length > maxColumnsBeforeLandscape;
|
438
|
-
const headerCells = prepareExportHeaders(columns).map((header) => new TableCell({
|
439
|
-
children: [new Paragraph({
|
440
|
-
children: [new TextRun({
|
441
|
-
text: header,
|
442
|
-
size: fontSize,
|
443
|
-
bold: boldHeaders
|
444
|
-
})],
|
445
|
-
alignment: AlignmentType.CENTER
|
446
|
-
})],
|
447
|
-
verticalAlign: VerticalAlign.CENTER
|
448
|
-
}));
|
449
|
-
const tableHeaderRow = new TableRow({ children: headerCells });
|
450
|
-
const rows = prepareExportRows(columns, wordData).map((cells) => {
|
451
|
-
const rowCells = cells.map(
|
452
|
-
(value) => new TableCell({
|
453
|
-
children: [new Paragraph({
|
454
|
-
children: [new TextRun({
|
455
|
-
text: value,
|
456
|
-
size: fontSize
|
457
|
-
})],
|
458
|
-
alignment: AlignmentType.CENTER
|
459
|
-
})],
|
460
|
-
verticalAlign: VerticalAlign.CENTER
|
461
|
-
})
|
462
|
-
);
|
463
|
-
return new TableRow({ children: rowCells });
|
464
|
-
});
|
465
|
-
const table = new Table({
|
466
|
-
rows: [tableHeaderRow, ...rows],
|
467
|
-
width: { size: 11e3, type: WidthType.DXA },
|
468
|
-
indent: { size: -1e3, type: WidthType.DXA }
|
469
|
-
});
|
470
|
-
const doc = new Document({
|
471
|
-
sections: [{
|
472
|
-
children: [table, new Paragraph({ text: "" })],
|
473
|
-
properties: isLandscape ? { page: { size: { orientation: PageOrientation.LANDSCAPE } } } : {}
|
474
|
-
}]
|
475
|
-
});
|
476
|
-
Packer.toBlob(doc).then((blob) => {
|
477
|
-
saveAs(blob, `${title}.docx`);
|
478
|
-
});
|
479
|
-
};
|
480
|
-
return /* @__PURE__ */ jsx13("button", { className: `ndt-buttonExport ndt-Word}`, onClick: createNewWord, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Word" });
|
481
|
-
};
|
482
|
-
var WordExport_default = WordExport;
|
483
|
-
|
484
|
-
// utils/exportUtils/exportUtils.ts
|
485
|
-
var generateExcelColumns = (columns, exportCustomColumns) => {
|
486
|
-
let excelColumns = columns.map((column) => ({
|
487
|
-
header: column.title,
|
488
|
-
key: column.field,
|
489
|
-
width: 20
|
490
|
-
}));
|
491
|
-
if (exportCustomColumns) {
|
492
|
-
exportCustomColumns.forEach((custom) => {
|
493
|
-
excelColumns = excelColumns.map(
|
494
|
-
(col) => col.key === custom.key ? { ...col, ...custom } : col
|
495
|
-
);
|
496
|
-
});
|
497
|
-
}
|
498
|
-
return excelColumns;
|
499
|
-
};
|
500
|
-
var applyHeaderStyles = (row, columnCount) => {
|
501
|
-
row.height = 40;
|
502
|
-
row.font = { size: 12, bold: true };
|
503
|
-
row.alignment = { vertical: "middle", horizontal: "center" };
|
504
|
-
for (let i = 1; i <= columnCount; i++) {
|
505
|
-
const cell = row.getCell(i);
|
506
|
-
cell.alignment = { wrapText: true, vertical: "middle", horizontal: "center" };
|
507
|
-
cell.border = {
|
508
|
-
top: { style: "thin" },
|
509
|
-
left: { style: "thin" },
|
510
|
-
bottom: { style: "thin" },
|
511
|
-
right: { style: "thin" }
|
512
|
-
};
|
513
|
-
}
|
514
|
-
};
|
515
|
-
var applyRowStyles = (row, columnCount) => {
|
516
|
-
row.height = 40;
|
517
|
-
row.font = { size: 12 };
|
518
|
-
row.alignment = { vertical: "middle", horizontal: "center" };
|
519
|
-
for (let i = 1; i <= columnCount; i++) {
|
520
|
-
const cell = row.getCell(i);
|
521
|
-
cell.alignment = { wrapText: true, vertical: "middle", horizontal: "center" };
|
522
|
-
cell.border = {
|
523
|
-
top: { style: "thin" },
|
524
|
-
left: { style: "thin" },
|
525
|
-
bottom: { style: "thin" },
|
526
|
-
right: { style: "thin" }
|
527
|
-
};
|
528
|
-
}
|
529
|
-
};
|
530
|
-
var generateExcelDataRows = (columns, data) => {
|
531
|
-
return data.map((element) => {
|
532
|
-
const rowData = {};
|
533
|
-
columns.forEach((col) => {
|
534
|
-
const value = element[col.field];
|
535
|
-
rowData[col.field] = typeof col.exportCustomCell !== "undefined" ? col.exportCustomCell(String(value), element) : value != null ? value : "";
|
536
|
-
});
|
537
|
-
return rowData;
|
538
|
-
});
|
539
|
-
};
|
540
|
-
var setColumnAutoWidths = (sheet) => {
|
541
|
-
var _a;
|
542
|
-
(_a = sheet.columns) == null ? void 0 : _a.forEach((column) => {
|
543
|
-
var _a2;
|
544
|
-
let maxLength = 10;
|
545
|
-
(_a2 = column.eachCell) == null ? void 0 : _a2.call(column, { includeEmpty: true }, (cell) => {
|
546
|
-
const cellValue = cell.value ? String(cell.value) : "";
|
547
|
-
maxLength = Math.max(maxLength, cellValue.length + 5);
|
548
|
-
});
|
549
|
-
column.width = maxLength;
|
550
|
-
});
|
551
|
-
};
|
552
|
-
|
553
|
-
// components/export/ExportExcel.tsx
|
554
|
-
import ExcelJS from "exceljs";
|
555
|
-
import { jsx as jsx14 } from "react/jsx-runtime";
|
556
|
-
var ExportExcel = ({ columns, excelData, title, exportCustomColumns }) => {
|
557
|
-
const exportExcel = () => {
|
558
|
-
const workbook = new ExcelJS.Workbook();
|
559
|
-
const sheet = workbook.addWorksheet(title, {
|
560
|
-
pageSetup: {
|
561
|
-
fitToPage: true,
|
562
|
-
fitToHeight: 2,
|
563
|
-
fitToWidth: 1,
|
564
|
-
orientation: "landscape"
|
565
|
-
},
|
566
|
-
headerFooter: {
|
567
|
-
oddFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N",
|
568
|
-
evenFooter: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 &P \u0438\u0437 &N"
|
569
|
-
}
|
570
|
-
});
|
571
|
-
const excelColumns = generateExcelColumns(columns, exportCustomColumns);
|
572
|
-
sheet.columns = excelColumns;
|
573
|
-
const headerRow = sheet.getRow(1);
|
574
|
-
applyHeaderStyles(headerRow, sheet.columns.length);
|
575
|
-
const dataRows = generateExcelDataRows(columns, excelData);
|
576
|
-
dataRows.forEach((data) => {
|
577
|
-
const row = sheet.addRow(data);
|
578
|
-
applyRowStyles(row, sheet.columns.length);
|
579
|
-
});
|
580
|
-
setColumnAutoWidths(sheet);
|
581
|
-
if (excelData.length > 15) {
|
582
|
-
sheet.pageSetup.fitToHeight = Math.floor(excelData.length / 15);
|
583
|
-
} else {
|
584
|
-
sheet.pageSetup.fitToHeight = 1;
|
585
|
-
}
|
586
|
-
workbook.xlsx.writeBuffer().then((data) => {
|
587
|
-
const blob = new Blob([data], {
|
588
|
-
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
589
|
-
});
|
590
|
-
const url = window.URL.createObjectURL(blob);
|
591
|
-
const anchor = document.createElement("a");
|
592
|
-
anchor.href = url;
|
593
|
-
anchor.download = `${title}.xlsx`;
|
594
|
-
anchor.click();
|
595
|
-
window.URL.revokeObjectURL(url);
|
596
|
-
});
|
597
|
-
};
|
598
|
-
return /* @__PURE__ */ jsx14("button", { className: `ndt-buttonExport ndt-Excel`, onClick: exportExcel, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Excel" });
|
599
|
-
};
|
600
|
-
var ExportExcel_default = ExportExcel;
|
601
|
-
|
602
|
-
// components/ExportSection.tsx
|
603
|
-
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
|
604
|
-
var ExportSection = ({ wordBtn, excelBtn, downloadSectionLeftSideContent, tableData, columns, tableName, exportCustomColumns, wordOptions }) => {
|
605
|
-
return /* @__PURE__ */ jsx15(Fragment2, { children: /* @__PURE__ */ jsxs5("div", { className: "ndt-download-section", children: [
|
606
|
-
/* @__PURE__ */ jsx15("div", { className: "ndt-download-content", children: (wordBtn || excelBtn) && downloadSectionLeftSideContent !== null && downloadSectionLeftSideContent }),
|
607
|
-
/* @__PURE__ */ jsxs5("div", { className: "ndt-download-buttons", children: [
|
608
|
-
wordBtn && /* @__PURE__ */ jsx15(
|
609
|
-
WordExport_default,
|
610
|
-
{
|
611
|
-
wordData: tableData,
|
612
|
-
columns,
|
613
|
-
title: tableName,
|
614
|
-
exportCustomColumns,
|
615
|
-
options: wordOptions
|
616
|
-
}
|
617
|
-
),
|
618
|
-
excelBtn && /* @__PURE__ */ jsx15(
|
619
|
-
ExportExcel_default,
|
620
|
-
{
|
621
|
-
excelData: tableData,
|
622
|
-
columns,
|
623
|
-
title: tableName,
|
624
|
-
exportCustomColumns
|
625
|
-
}
|
626
|
-
)
|
627
|
-
] })
|
628
|
-
] }) });
|
629
|
-
};
|
630
|
-
var ExportSection_default = ExportSection;
|
631
|
-
|
632
387
|
// utils/useDebouncedEffect.tsx
|
633
388
|
import { useEffect } from "react";
|
634
389
|
function useDebouncedEffect(callback, deps, delay) {
|
@@ -639,7 +394,8 @@ function useDebouncedEffect(callback, deps, delay) {
|
|
639
394
|
}
|
640
395
|
|
641
396
|
// components/DataTable.tsx
|
642
|
-
import { jsx as
|
397
|
+
import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
398
|
+
var ExportSection = React3.lazy(() => import("./ExportSection-ZYOK6KMB.js"));
|
643
399
|
var DataTable = forwardRef(({
|
644
400
|
tableData,
|
645
401
|
columns,
|
@@ -733,9 +489,9 @@ var DataTable = forwardRef(({
|
|
733
489
|
getData: () => processedData,
|
734
490
|
getCurrentData: () => displayData
|
735
491
|
}), [processedData, displayData]);
|
736
|
-
return /* @__PURE__ */
|
737
|
-
(wordBtn || excelBtn) && /* @__PURE__ */
|
738
|
-
|
492
|
+
return /* @__PURE__ */ jsxs5("div", { className: "ndt-table-container", children: [
|
493
|
+
/* @__PURE__ */ jsx13(Suspense, { fallback: /* @__PURE__ */ jsx13("div", { children: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430..." }), children: (wordBtn || excelBtn) && /* @__PURE__ */ jsx13(
|
494
|
+
ExportSection,
|
739
495
|
{
|
740
496
|
wordBtn,
|
741
497
|
excelBtn,
|
@@ -746,9 +502,9 @@ var DataTable = forwardRef(({
|
|
746
502
|
exportCustomColumns,
|
747
503
|
wordOptions
|
748
504
|
}
|
749
|
-
),
|
750
|
-
/* @__PURE__ */
|
751
|
-
/* @__PURE__ */
|
505
|
+
) }),
|
506
|
+
/* @__PURE__ */ jsxs5("div", { className: "ndt-table", children: [
|
507
|
+
/* @__PURE__ */ jsx13(
|
752
508
|
TableHeader_default,
|
753
509
|
{
|
754
510
|
columns,
|
@@ -760,7 +516,7 @@ var DataTable = forwardRef(({
|
|
760
516
|
headerGroup
|
761
517
|
}
|
762
518
|
),
|
763
|
-
loading ? loadingElement !== null ? loadingElement : /* @__PURE__ */
|
519
|
+
loading ? loadingElement !== null ? loadingElement : /* @__PURE__ */ jsx13("span", { style: { marginLeft: 10, fontWeight: "bold" }, children: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0434\u0430\u043D\u043D\u044B\u0445..." }) : /* @__PURE__ */ jsx13(
|
764
520
|
TableBody_default,
|
765
521
|
{
|
766
522
|
tableData: displayData,
|
@@ -774,7 +530,7 @@ var DataTable = forwardRef(({
|
|
774
530
|
isTitles
|
775
531
|
}
|
776
532
|
),
|
777
|
-
isFooter && /* @__PURE__ */
|
533
|
+
isFooter && /* @__PURE__ */ jsx13(
|
778
534
|
TableFooter_default,
|
779
535
|
{
|
780
536
|
paginationCounts,
|
@@ -793,4 +549,3 @@ var DataTable_default = DataTable;
|
|
793
549
|
export {
|
794
550
|
DataTable_default as DataTable
|
795
551
|
};
|
796
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "nillud-data-table",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.2",
|
4
4
|
"type": "module",
|
5
5
|
"main": "./dist/index.cjs",
|
6
6
|
"module": "./dist/index.js",
|
@@ -11,10 +11,15 @@
|
|
11
11
|
],
|
12
12
|
"exports": {
|
13
13
|
".": {
|
14
|
-
"
|
15
|
-
"import": "./dist/index.js",
|
16
|
-
"types": "./dist/index.d.ts"
|
14
|
+
"import": "./dist/index.js"
|
17
15
|
},
|
16
|
+
"./export-excel": {
|
17
|
+
"import": "./dist/export-excel.js"
|
18
|
+
},
|
19
|
+
"./export-word": {
|
20
|
+
"import": "./dist/export-word.js"
|
21
|
+
},
|
22
|
+
"./types": "./dist/index.d.ts",
|
18
23
|
"./styles.css": "./dist/styles.css"
|
19
24
|
},
|
20
25
|
"peerDependencies": {
|