nillud-data-table 1.0.5 → 1.0.7
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 +27 -0
- package/dist/index.d.ts +34 -3
- package/dist/index.js +205 -188
- package/package.json +5 -3
package/README.md
CHANGED
@@ -40,6 +40,9 @@ const data = [{ name: 'Иван' }]
|
|
40
40
|
import { DataTable } from 'nillud-data-table'
|
41
41
|
import 'nillud-data-table/styles.css'
|
42
42
|
|
43
|
+
import ExportExcel from 'nillud-data-table/export/ExportExcel';
|
44
|
+
import WordExport from 'nillud-data-table/export/WordExport';
|
45
|
+
|
43
46
|
const columns = [{ field: 'name', title: 'Имя' }]
|
44
47
|
const data = [{ name: 'Иван' }]
|
45
48
|
|
@@ -55,6 +58,8 @@ const data = [{ name: 'Иван' }]
|
|
55
58
|
scrollHeight={410}
|
56
59
|
excelBtn
|
57
60
|
wordBtn
|
61
|
+
WordExportComponent={WordExport}
|
62
|
+
ExportExcelComponent={ExportExcel}
|
58
63
|
downloadSectionLeftSideContent={<button className='base-button' onClick={() => setCanvas(true)}>OffCanvas</button>}
|
59
64
|
excelCustomColumns={[
|
60
65
|
{
|
@@ -440,6 +445,17 @@ npm i exceljs
|
|
440
445
|
yarn add exceljs
|
441
446
|
```
|
442
447
|
|
448
|
+
```tsx
|
449
|
+
import ExportExcel from 'nillud-data-table/export/ExportExcel';
|
450
|
+
|
451
|
+
<DataTable>
|
452
|
+
...
|
453
|
+
excelBtn
|
454
|
+
ExportExcelComponent={ExportExcel}
|
455
|
+
...
|
456
|
+
</DataTable>
|
457
|
+
```
|
458
|
+
|
443
459
|
### wordBtn
|
444
460
|
|
445
461
|
Необязательный параметр. Тип **boolean**, по умолчанию **false**. При значении **true** над таблицей с правой стороны появляется кнопка экспорта Word, которая по умолчанию принимает в себя исходный массив **tableData**
|
@@ -452,6 +468,17 @@ npm i docx file-saver
|
|
452
468
|
yarn add docx file-saver
|
453
469
|
```
|
454
470
|
|
471
|
+
```tsx
|
472
|
+
import WordExport from 'nillud-data-table/export/WordExport';
|
473
|
+
|
474
|
+
<DataTable>
|
475
|
+
...
|
476
|
+
wordBtn
|
477
|
+
WordExportComponent={WordExport}
|
478
|
+
...
|
479
|
+
</DataTable>
|
480
|
+
```
|
481
|
+
|
455
482
|
### wordOptions
|
456
483
|
|
457
484
|
Необязательный параметр. Используется вместе с **wordBtn**. Принимает в себя объект
|
package/dist/index.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import React, { ReactElement } from 'react';
|
1
|
+
import React$1, { ReactElement } from 'react';
|
2
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
2
3
|
|
3
4
|
type TableElement = {
|
4
5
|
[key: string]: string | number;
|
@@ -46,12 +47,42 @@ type TableProps = {
|
|
46
47
|
groupBy?: string | null;
|
47
48
|
isTitles?: boolean;
|
48
49
|
wordOptions?: ExportOptions;
|
50
|
+
WordExportComponent?: React.ComponentType<{
|
51
|
+
wordData: TableData;
|
52
|
+
columns: Array<Column>;
|
53
|
+
title: string;
|
54
|
+
options?: ExportOptions;
|
55
|
+
exportCustomColumns?: TableProps["exportCustomColumns"];
|
56
|
+
}>;
|
57
|
+
ExportExcelComponent?: React.ComponentType<{
|
58
|
+
excelData: TableData;
|
59
|
+
columns: Array<Column>;
|
60
|
+
title: string;
|
61
|
+
exportCustomColumns?: TableProps["exportCustomColumns"];
|
62
|
+
}>;
|
49
63
|
};
|
50
64
|
type DataTableRef = {
|
51
65
|
getData: () => TableData;
|
52
66
|
getCurrentData: () => TableData;
|
53
67
|
};
|
54
68
|
|
55
|
-
declare const DataTable: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<DataTableRef>>;
|
69
|
+
declare const DataTable: React$1.ForwardRefExoticComponent<TableProps & React$1.RefAttributes<DataTableRef>>;
|
70
|
+
|
71
|
+
type Props$1 = {
|
72
|
+
wordData: TableData;
|
73
|
+
columns: Array<Column>;
|
74
|
+
title: string;
|
75
|
+
options?: ExportOptions;
|
76
|
+
exportCustomColumns?: TableProps["exportCustomColumns"];
|
77
|
+
};
|
78
|
+
declare const WordExport: ({ wordData, columns, title, options }: Props$1) => react_jsx_runtime.JSX.Element;
|
79
|
+
|
80
|
+
type Props = {
|
81
|
+
columns: Array<Column>;
|
82
|
+
excelData: Array<TableElement>;
|
83
|
+
title: string;
|
84
|
+
exportCustomColumns: TableProps["exportCustomColumns"];
|
85
|
+
};
|
86
|
+
declare const ExportExcel: ({ columns, excelData, title, exportCustomColumns }: Props) => react_jsx_runtime.JSX.Element;
|
56
87
|
|
57
|
-
export { type Column, DataTable, type TableElement, type TableProps };
|
88
|
+
export { type Column, DataTable, ExportExcel, type TableElement, type TableProps, WordExport };
|
package/dist/index.js
CHANGED
@@ -393,6 +393,204 @@ function useDebouncedEffect(callback, deps, delay) {
|
|
393
393
|
}, [...deps, delay]);
|
394
394
|
}
|
395
395
|
|
396
|
+
// components/ExportSection.tsx
|
397
|
+
import { Fragment as Fragment2, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
398
|
+
var ExportSection = ({
|
399
|
+
wordBtn,
|
400
|
+
excelBtn,
|
401
|
+
downloadSectionLeftSideContent,
|
402
|
+
tableData,
|
403
|
+
columns,
|
404
|
+
tableName,
|
405
|
+
exportCustomColumns,
|
406
|
+
wordOptions,
|
407
|
+
WordExportComponent,
|
408
|
+
ExportExcelComponent
|
409
|
+
}) => {
|
410
|
+
return /* @__PURE__ */ jsx13(Fragment2, { children: /* @__PURE__ */ jsxs5("div", { className: "ndt-download-section", children: [
|
411
|
+
/* @__PURE__ */ jsx13("div", { className: "ndt-download-content", children: (wordBtn || excelBtn) && downloadSectionLeftSideContent !== null && downloadSectionLeftSideContent }),
|
412
|
+
/* @__PURE__ */ jsxs5("div", { className: "ndt-download-buttons", children: [
|
413
|
+
wordBtn && WordExportComponent && /* @__PURE__ */ jsx13(
|
414
|
+
WordExportComponent,
|
415
|
+
{
|
416
|
+
wordData: tableData,
|
417
|
+
columns,
|
418
|
+
title: tableName,
|
419
|
+
exportCustomColumns,
|
420
|
+
options: wordOptions
|
421
|
+
}
|
422
|
+
),
|
423
|
+
excelBtn && ExportExcelComponent && /* @__PURE__ */ jsx13(
|
424
|
+
ExportExcelComponent,
|
425
|
+
{
|
426
|
+
excelData: tableData,
|
427
|
+
columns,
|
428
|
+
title: tableName,
|
429
|
+
exportCustomColumns
|
430
|
+
}
|
431
|
+
)
|
432
|
+
] })
|
433
|
+
] }) });
|
434
|
+
};
|
435
|
+
var ExportSection_default = ExportSection;
|
436
|
+
|
437
|
+
// components/DataTable.tsx
|
438
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
439
|
+
var DataTable = forwardRef(({
|
440
|
+
tableData,
|
441
|
+
columns,
|
442
|
+
tableName = "table-data",
|
443
|
+
loading = false,
|
444
|
+
loadingElement = null,
|
445
|
+
isFooter = false,
|
446
|
+
paginationCounts = null,
|
447
|
+
scrollable = false,
|
448
|
+
scrollHeight = 300,
|
449
|
+
exportCustomColumns = null,
|
450
|
+
excelBtn = false,
|
451
|
+
wordBtn = false,
|
452
|
+
downloadSectionLeftSideContent = null,
|
453
|
+
headerGroup = null,
|
454
|
+
groupBy = null,
|
455
|
+
isTitles = false,
|
456
|
+
wordOptions,
|
457
|
+
WordExportComponent,
|
458
|
+
ExportExcelComponent
|
459
|
+
}, ref) => {
|
460
|
+
const [filters, setFilters] = useState({});
|
461
|
+
const [sortBy, setSortBy] = useState({ col: "", type: "asc" });
|
462
|
+
const [paginationSize, setPaginationSize] = useState((paginationCounts == null ? void 0 : paginationCounts[0]) || 10);
|
463
|
+
const [paginationPage, setPaginationPage] = useState(0);
|
464
|
+
const [collapsedGroups, setCollapsedGroups] = useState({});
|
465
|
+
const toggleGroup = (groupKey) => {
|
466
|
+
setCollapsedGroups((prev) => ({
|
467
|
+
...prev,
|
468
|
+
[groupKey]: !prev[groupKey]
|
469
|
+
}));
|
470
|
+
};
|
471
|
+
const widths = useMemo2(() => {
|
472
|
+
return columns.map((c) => c.width ? `${c.width}px` : "1fr").join(" ");
|
473
|
+
}, [columns]);
|
474
|
+
const loadFromLocalStorage = useCallback(() => {
|
475
|
+
try {
|
476
|
+
const s = localStorage.getItem(`${tableName}-sort-by`);
|
477
|
+
const f = localStorage.getItem(`${tableName}-filters`);
|
478
|
+
const c = localStorage.getItem(`${tableName}-counts`);
|
479
|
+
const p = localStorage.getItem(`${tableName}-page`);
|
480
|
+
if (s) setSortBy(JSON.parse(s));
|
481
|
+
if (f) setFilters(JSON.parse(f));
|
482
|
+
if (c) setPaginationSize(c === "all" ? 0 : Number(c));
|
483
|
+
if (p) setPaginationPage(Number(p));
|
484
|
+
} catch (e) {
|
485
|
+
console.error("Error parsing localStorage data:", e);
|
486
|
+
setSortBy({ col: "", type: "asc" });
|
487
|
+
setFilters({});
|
488
|
+
setPaginationSize((paginationCounts == null ? void 0 : paginationCounts[0]) || 10);
|
489
|
+
setPaginationPage(0);
|
490
|
+
}
|
491
|
+
}, [tableName, paginationCounts]);
|
492
|
+
useEffect2(() => {
|
493
|
+
loadFromLocalStorage();
|
494
|
+
}, [loadFromLocalStorage]);
|
495
|
+
const processedData = useMemo2(() => {
|
496
|
+
let result = [...tableData];
|
497
|
+
const columnMap = new Map(columns.map((col) => [col.field, col]));
|
498
|
+
for (const field in filters) {
|
499
|
+
const filterValue = String(filters[field]);
|
500
|
+
if (filterValue === "") continue;
|
501
|
+
const column = columnMap.get(field);
|
502
|
+
if (!column) continue;
|
503
|
+
result = column.headerFilter ? result.filter((e) => column.headerFilter(filterValue, String(e[field]))) : filterData(result, field, filterValue);
|
504
|
+
}
|
505
|
+
if (sortBy.col) {
|
506
|
+
result = sortData(result, sortBy.col, sortBy.type);
|
507
|
+
}
|
508
|
+
return result;
|
509
|
+
}, [tableData, filters, sortBy, columns]);
|
510
|
+
const displayData = useMemo2(() => {
|
511
|
+
if (paginationSize === 0) return processedData;
|
512
|
+
const start = paginationPage * paginationSize;
|
513
|
+
return processedData.slice(start, start + paginationSize);
|
514
|
+
}, [processedData, paginationPage, paginationSize]);
|
515
|
+
useEffect2(() => {
|
516
|
+
setPaginationPage(0);
|
517
|
+
}, [filters, sortBy]);
|
518
|
+
useDebouncedEffect(() => {
|
519
|
+
localStorage.setItem(`${tableName}-filters`, JSON.stringify(filters));
|
520
|
+
}, [filters, tableName], 500);
|
521
|
+
useDebouncedEffect(() => {
|
522
|
+
localStorage.setItem(`${tableName}-sort-by`, JSON.stringify(sortBy));
|
523
|
+
}, [sortBy, tableName], 500);
|
524
|
+
useEffect2(() => {
|
525
|
+
localStorage.setItem(`${tableName}-counts`, paginationSize === 0 ? "all" : paginationSize.toString());
|
526
|
+
}, [paginationSize, tableName]);
|
527
|
+
useEffect2(() => {
|
528
|
+
localStorage.setItem(`${tableName}-page`, paginationPage.toString());
|
529
|
+
}, [paginationPage, tableName]);
|
530
|
+
useImperativeHandle(ref, () => ({
|
531
|
+
getData: () => processedData,
|
532
|
+
getCurrentData: () => displayData
|
533
|
+
}), [processedData, displayData]);
|
534
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ndt-table-container", children: [
|
535
|
+
(wordBtn || excelBtn) && /* @__PURE__ */ jsx14(
|
536
|
+
ExportSection_default,
|
537
|
+
{
|
538
|
+
wordBtn,
|
539
|
+
excelBtn,
|
540
|
+
downloadSectionLeftSideContent,
|
541
|
+
tableData: displayData,
|
542
|
+
columns,
|
543
|
+
tableName,
|
544
|
+
exportCustomColumns,
|
545
|
+
wordOptions,
|
546
|
+
WordExportComponent,
|
547
|
+
ExportExcelComponent
|
548
|
+
}
|
549
|
+
),
|
550
|
+
/* @__PURE__ */ jsxs6("div", { className: "ndt-table", children: [
|
551
|
+
/* @__PURE__ */ jsx14(
|
552
|
+
TableHeader_default,
|
553
|
+
{
|
554
|
+
columns,
|
555
|
+
sortBy,
|
556
|
+
getSortField: setSortBy,
|
557
|
+
filters,
|
558
|
+
getFilters: setFilters,
|
559
|
+
widths,
|
560
|
+
headerGroup
|
561
|
+
}
|
562
|
+
),
|
563
|
+
loading ? loadingElement !== null ? loadingElement : /* @__PURE__ */ jsx14("span", { style: { marginLeft: 10, fontWeight: "bold" }, children: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0434\u0430\u043D\u043D\u044B\u0445..." }) : /* @__PURE__ */ jsx14(
|
564
|
+
TableBody_default,
|
565
|
+
{
|
566
|
+
tableData: displayData,
|
567
|
+
columns,
|
568
|
+
scrollable,
|
569
|
+
scrollHeight,
|
570
|
+
widths,
|
571
|
+
groupBy,
|
572
|
+
collapsedGroups,
|
573
|
+
toggleGroup,
|
574
|
+
isTitles
|
575
|
+
}
|
576
|
+
),
|
577
|
+
isFooter && /* @__PURE__ */ jsx14(
|
578
|
+
TableFooter_default,
|
579
|
+
{
|
580
|
+
paginationCounts,
|
581
|
+
tableData: processedData,
|
582
|
+
paginationSize,
|
583
|
+
getPaginationSize: setPaginationSize,
|
584
|
+
paginationPage,
|
585
|
+
getPaginationPage: setPaginationPage
|
586
|
+
}
|
587
|
+
)
|
588
|
+
] })
|
589
|
+
] });
|
590
|
+
});
|
591
|
+
DataTable.displayName = "DataTable";
|
592
|
+
var DataTable_default = DataTable;
|
593
|
+
|
396
594
|
// utils/exportUtils/ExportHelpers.ts
|
397
595
|
function prepareExportRows(columns, data) {
|
398
596
|
return data.map(
|
@@ -407,7 +605,7 @@ function prepareExportHeaders(columns) {
|
|
407
605
|
}
|
408
606
|
|
409
607
|
// components/export/WordExport.tsx
|
410
|
-
import { jsx as
|
608
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
411
609
|
var WordExport = ({
|
412
610
|
wordData,
|
413
611
|
columns,
|
@@ -485,7 +683,7 @@ var WordExport = ({
|
|
485
683
|
saveAs(blob, `${title}.docx`);
|
486
684
|
});
|
487
685
|
};
|
488
|
-
return /* @__PURE__ */
|
686
|
+
return /* @__PURE__ */ jsx15("button", { className: `ndt-buttonExport ndt-Word}`, onClick: createNewWord, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Word" });
|
489
687
|
};
|
490
688
|
var WordExport_default = WordExport;
|
491
689
|
|
@@ -559,7 +757,7 @@ var setColumnAutoWidths = (sheet) => {
|
|
559
757
|
};
|
560
758
|
|
561
759
|
// components/export/ExportExcel.tsx
|
562
|
-
import { jsx as
|
760
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
563
761
|
var ExportExcel = ({ columns, excelData, title, exportCustomColumns }) => {
|
564
762
|
const exportExcel = async () => {
|
565
763
|
const ExcelJS = await import("exceljs");
|
@@ -603,192 +801,11 @@ var ExportExcel = ({ columns, excelData, title, exportCustomColumns }) => {
|
|
603
801
|
window.URL.revokeObjectURL(url);
|
604
802
|
});
|
605
803
|
};
|
606
|
-
return /* @__PURE__ */
|
804
|
+
return /* @__PURE__ */ jsx16("button", { className: `ndt-buttonExport ndt-Excel`, onClick: exportExcel, children: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C Excel" });
|
607
805
|
};
|
608
806
|
var ExportExcel_default = ExportExcel;
|
609
|
-
|
610
|
-
// components/ExportSection.tsx
|
611
|
-
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs5 } from "react/jsx-runtime";
|
612
|
-
var ExportSection = ({ wordBtn, excelBtn, downloadSectionLeftSideContent, tableData, columns, tableName, exportCustomColumns, wordOptions }) => {
|
613
|
-
return /* @__PURE__ */ jsx15(Fragment2, { children: /* @__PURE__ */ jsxs5("div", { className: "ndt-download-section", children: [
|
614
|
-
/* @__PURE__ */ jsx15("div", { className: "ndt-download-content", children: (wordBtn || excelBtn) && downloadSectionLeftSideContent !== null && downloadSectionLeftSideContent }),
|
615
|
-
/* @__PURE__ */ jsxs5("div", { className: "ndt-download-buttons", children: [
|
616
|
-
wordBtn && /* @__PURE__ */ jsx15(
|
617
|
-
WordExport_default,
|
618
|
-
{
|
619
|
-
wordData: tableData,
|
620
|
-
columns,
|
621
|
-
title: tableName,
|
622
|
-
exportCustomColumns,
|
623
|
-
options: wordOptions
|
624
|
-
}
|
625
|
-
),
|
626
|
-
excelBtn && /* @__PURE__ */ jsx15(
|
627
|
-
ExportExcel_default,
|
628
|
-
{
|
629
|
-
excelData: tableData,
|
630
|
-
columns,
|
631
|
-
title: tableName,
|
632
|
-
exportCustomColumns
|
633
|
-
}
|
634
|
-
)
|
635
|
-
] })
|
636
|
-
] }) });
|
637
|
-
};
|
638
|
-
var ExportSection_default = ExportSection;
|
639
|
-
|
640
|
-
// components/DataTable.tsx
|
641
|
-
import { jsx as jsx16, jsxs as jsxs6 } from "react/jsx-runtime";
|
642
|
-
var DataTable = forwardRef(({
|
643
|
-
tableData,
|
644
|
-
columns,
|
645
|
-
tableName = "table-data",
|
646
|
-
loading = false,
|
647
|
-
loadingElement = null,
|
648
|
-
isFooter = false,
|
649
|
-
paginationCounts = null,
|
650
|
-
scrollable = false,
|
651
|
-
scrollHeight = 300,
|
652
|
-
exportCustomColumns = null,
|
653
|
-
excelBtn = false,
|
654
|
-
wordBtn = false,
|
655
|
-
downloadSectionLeftSideContent = null,
|
656
|
-
headerGroup = null,
|
657
|
-
groupBy = null,
|
658
|
-
isTitles = false,
|
659
|
-
wordOptions
|
660
|
-
}, ref) => {
|
661
|
-
const [filters, setFilters] = useState({});
|
662
|
-
const [sortBy, setSortBy] = useState({ col: "", type: "asc" });
|
663
|
-
const [paginationSize, setPaginationSize] = useState((paginationCounts == null ? void 0 : paginationCounts[0]) || 10);
|
664
|
-
const [paginationPage, setPaginationPage] = useState(0);
|
665
|
-
const [collapsedGroups, setCollapsedGroups] = useState({});
|
666
|
-
const toggleGroup = (groupKey) => {
|
667
|
-
setCollapsedGroups((prev) => ({
|
668
|
-
...prev,
|
669
|
-
[groupKey]: !prev[groupKey]
|
670
|
-
}));
|
671
|
-
};
|
672
|
-
const widths = useMemo2(() => {
|
673
|
-
return columns.map((c) => c.width ? `${c.width}px` : "1fr").join(" ");
|
674
|
-
}, [columns]);
|
675
|
-
const loadFromLocalStorage = useCallback(() => {
|
676
|
-
try {
|
677
|
-
const s = localStorage.getItem(`${tableName}-sort-by`);
|
678
|
-
const f = localStorage.getItem(`${tableName}-filters`);
|
679
|
-
const c = localStorage.getItem(`${tableName}-counts`);
|
680
|
-
const p = localStorage.getItem(`${tableName}-page`);
|
681
|
-
if (s) setSortBy(JSON.parse(s));
|
682
|
-
if (f) setFilters(JSON.parse(f));
|
683
|
-
if (c) setPaginationSize(c === "all" ? 0 : Number(c));
|
684
|
-
if (p) setPaginationPage(Number(p));
|
685
|
-
} catch (e) {
|
686
|
-
console.error("Error parsing localStorage data:", e);
|
687
|
-
setSortBy({ col: "", type: "asc" });
|
688
|
-
setFilters({});
|
689
|
-
setPaginationSize((paginationCounts == null ? void 0 : paginationCounts[0]) || 10);
|
690
|
-
setPaginationPage(0);
|
691
|
-
}
|
692
|
-
}, [tableName, paginationCounts]);
|
693
|
-
useEffect2(() => {
|
694
|
-
loadFromLocalStorage();
|
695
|
-
}, [loadFromLocalStorage]);
|
696
|
-
const processedData = useMemo2(() => {
|
697
|
-
let result = [...tableData];
|
698
|
-
const columnMap = new Map(columns.map((col) => [col.field, col]));
|
699
|
-
for (const field in filters) {
|
700
|
-
const filterValue = String(filters[field]);
|
701
|
-
if (filterValue === "") continue;
|
702
|
-
const column = columnMap.get(field);
|
703
|
-
if (!column) continue;
|
704
|
-
result = column.headerFilter ? result.filter((e) => column.headerFilter(filterValue, String(e[field]))) : filterData(result, field, filterValue);
|
705
|
-
}
|
706
|
-
if (sortBy.col) {
|
707
|
-
result = sortData(result, sortBy.col, sortBy.type);
|
708
|
-
}
|
709
|
-
return result;
|
710
|
-
}, [tableData, filters, sortBy, columns]);
|
711
|
-
const displayData = useMemo2(() => {
|
712
|
-
if (paginationSize === 0) return processedData;
|
713
|
-
const start = paginationPage * paginationSize;
|
714
|
-
return processedData.slice(start, start + paginationSize);
|
715
|
-
}, [processedData, paginationPage, paginationSize]);
|
716
|
-
useEffect2(() => {
|
717
|
-
setPaginationPage(0);
|
718
|
-
}, [filters, sortBy]);
|
719
|
-
useDebouncedEffect(() => {
|
720
|
-
localStorage.setItem(`${tableName}-filters`, JSON.stringify(filters));
|
721
|
-
}, [filters, tableName], 500);
|
722
|
-
useDebouncedEffect(() => {
|
723
|
-
localStorage.setItem(`${tableName}-sort-by`, JSON.stringify(sortBy));
|
724
|
-
}, [sortBy, tableName], 500);
|
725
|
-
useEffect2(() => {
|
726
|
-
localStorage.setItem(`${tableName}-counts`, paginationSize === 0 ? "all" : paginationSize.toString());
|
727
|
-
}, [paginationSize, tableName]);
|
728
|
-
useEffect2(() => {
|
729
|
-
localStorage.setItem(`${tableName}-page`, paginationPage.toString());
|
730
|
-
}, [paginationPage, tableName]);
|
731
|
-
useImperativeHandle(ref, () => ({
|
732
|
-
getData: () => processedData,
|
733
|
-
getCurrentData: () => displayData
|
734
|
-
}), [processedData, displayData]);
|
735
|
-
return /* @__PURE__ */ jsxs6("div", { className: "ndt-table-container", children: [
|
736
|
-
(wordBtn || excelBtn) && /* @__PURE__ */ jsx16(
|
737
|
-
ExportSection_default,
|
738
|
-
{
|
739
|
-
wordBtn,
|
740
|
-
excelBtn,
|
741
|
-
downloadSectionLeftSideContent,
|
742
|
-
tableData: displayData,
|
743
|
-
columns,
|
744
|
-
tableName,
|
745
|
-
exportCustomColumns,
|
746
|
-
wordOptions
|
747
|
-
}
|
748
|
-
),
|
749
|
-
/* @__PURE__ */ jsxs6("div", { className: "ndt-table", children: [
|
750
|
-
/* @__PURE__ */ jsx16(
|
751
|
-
TableHeader_default,
|
752
|
-
{
|
753
|
-
columns,
|
754
|
-
sortBy,
|
755
|
-
getSortField: setSortBy,
|
756
|
-
filters,
|
757
|
-
getFilters: setFilters,
|
758
|
-
widths,
|
759
|
-
headerGroup
|
760
|
-
}
|
761
|
-
),
|
762
|
-
loading ? loadingElement !== null ? loadingElement : /* @__PURE__ */ jsx16("span", { style: { marginLeft: 10, fontWeight: "bold" }, children: "\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0434\u0430\u043D\u043D\u044B\u0445..." }) : /* @__PURE__ */ jsx16(
|
763
|
-
TableBody_default,
|
764
|
-
{
|
765
|
-
tableData: displayData,
|
766
|
-
columns,
|
767
|
-
scrollable,
|
768
|
-
scrollHeight,
|
769
|
-
widths,
|
770
|
-
groupBy,
|
771
|
-
collapsedGroups,
|
772
|
-
toggleGroup,
|
773
|
-
isTitles
|
774
|
-
}
|
775
|
-
),
|
776
|
-
isFooter && /* @__PURE__ */ jsx16(
|
777
|
-
TableFooter_default,
|
778
|
-
{
|
779
|
-
paginationCounts,
|
780
|
-
tableData: processedData,
|
781
|
-
paginationSize,
|
782
|
-
getPaginationSize: setPaginationSize,
|
783
|
-
paginationPage,
|
784
|
-
getPaginationPage: setPaginationPage
|
785
|
-
}
|
786
|
-
)
|
787
|
-
] })
|
788
|
-
] });
|
789
|
-
});
|
790
|
-
DataTable.displayName = "DataTable";
|
791
|
-
var DataTable_default = DataTable;
|
792
807
|
export {
|
793
|
-
DataTable_default as DataTable
|
808
|
+
DataTable_default as DataTable,
|
809
|
+
ExportExcel_default as ExportExcel,
|
810
|
+
WordExport_default as WordExport
|
794
811
|
};
|
package/package.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
2
|
"name": "nillud-data-table",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.7",
|
4
4
|
"type": "module",
|
5
|
-
"main": "./dist/index.
|
5
|
+
"main": "./dist/index.js",
|
6
6
|
"module": "./dist/index.js",
|
7
7
|
"types": "./dist/index.d.ts",
|
8
8
|
"style": "./dist/styles.css",
|
@@ -13,6 +13,8 @@
|
|
13
13
|
".": {
|
14
14
|
"import": "./dist/index.js"
|
15
15
|
},
|
16
|
+
"./export/ExportExcel": "./dist/components/export/ExportExcel.js",
|
17
|
+
"./export/WordExport": "./dist/components/export/WordExport.js",
|
16
18
|
"./types": "./dist/index.d.ts",
|
17
19
|
"./styles.css": "./dist/styles.css"
|
18
20
|
},
|
@@ -35,4 +37,4 @@
|
|
35
37
|
"build": "tsup && npm run build:styles",
|
36
38
|
"build:styles": "node build-styles.js"
|
37
39
|
}
|
38
|
-
}
|
40
|
+
}
|