next-helios-fe 1.7.6 → 1.7.8
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/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +2 -0
- package/package.json +1 -2
- package/src/components/table/index.tsx +32 -7
@@ -49,6 +49,8 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
49
49
|
* https://github.com/wout/svg.filter.js
|
50
50
|
* Copyright (c) 2016 Wout Fierens; Licensed MIT */
|
51
51
|
|
52
|
+
/*! xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */
|
53
|
+
|
52
54
|
/**
|
53
55
|
* @license React
|
54
56
|
* react-jsx-runtime.production.min.js
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "next-helios-fe",
|
3
|
-
"version": "1.7.
|
3
|
+
"version": "1.7.8",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -29,7 +29,6 @@
|
|
29
29
|
"react-easy-sort": "^1.6.0",
|
30
30
|
"react-google-recaptcha": "^3.1.0",
|
31
31
|
"react-google-recaptcha-v3": "^1.10.1",
|
32
|
-
"react-json-to-excel": "^1.0.8",
|
33
32
|
"react-leaflet": "^4.2.1",
|
34
33
|
"react-pin-field": "^3.1.5",
|
35
34
|
"react-syntax-highlighter": "^15.5.0",
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use client";
|
2
2
|
import React, { useState, useEffect, useRef, useMemo } from "react";
|
3
3
|
import { Icon } from "@iconify/react";
|
4
|
-
import
|
4
|
+
import * as xlsx from "xlsx";
|
5
5
|
import dayjs from "dayjs";
|
6
6
|
import { Form, Button, Dropdown } from "../../components";
|
7
7
|
import { Action, type ActionProps } from "./action";
|
@@ -141,6 +141,14 @@ export const Table: TableComponentProps = ({
|
|
141
141
|
});
|
142
142
|
}, [header, data]);
|
143
143
|
|
144
|
+
const handleExportData = (dataTitle: string, data: any[]) => {
|
145
|
+
const fileName = `${dataTitle}-${dayjs().format("YYYY-MM-DD_HH-mm-ss")}`;
|
146
|
+
const worksheet = xlsx.utils.json_to_sheet(data);
|
147
|
+
const workbook = xlsx.utils.book_new();
|
148
|
+
xlsx.utils.book_append_sheet(workbook, worksheet, "Data");
|
149
|
+
xlsx.writeFile(workbook, fileName + ".xlsx");
|
150
|
+
};
|
151
|
+
|
144
152
|
const handleOnPreviousClick = () => {
|
145
153
|
if (page - 1 === 1) {
|
146
154
|
paginationRef.current?.scrollTo({
|
@@ -435,7 +443,7 @@ export const Table: TableComponentProps = ({
|
|
435
443
|
key={headerItem.key}
|
436
444
|
className="px-4 py-1.5 bg-secondary-bg whitespace-nowrap"
|
437
445
|
>
|
438
|
-
{headerItem.render(item)}
|
446
|
+
{headerItem.render(item) || "-"}
|
439
447
|
</td>
|
440
448
|
);
|
441
449
|
} else {
|
@@ -444,7 +452,7 @@ export const Table: TableComponentProps = ({
|
|
444
452
|
key={headerItem.key}
|
445
453
|
className="px-4 py-1.5 bg-secondary-bg whitespace-nowrap"
|
446
454
|
>
|
447
|
-
{item[headerItem.key as keyof typeof item]}
|
455
|
+
{item[headerItem.key as keyof typeof item] || "-"}
|
448
456
|
</td>
|
449
457
|
);
|
450
458
|
}
|
@@ -564,10 +572,27 @@ export const Table: TableComponentProps = ({
|
|
564
572
|
type="button"
|
565
573
|
options={{ variant: "primary", width: "fit" }}
|
566
574
|
onClick={() => {
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
575
|
+
const exportData = filteredData?.map((item) => {
|
576
|
+
return header
|
577
|
+
?.filter(
|
578
|
+
(headerItem) =>
|
579
|
+
!excludedColumn?.includes(headerItem.key)
|
580
|
+
)
|
581
|
+
?.reduce((acc, headerItem) => {
|
582
|
+
return {
|
583
|
+
...acc,
|
584
|
+
"No.": (
|
585
|
+
(page - 1) * maxRow +
|
586
|
+
filteredData?.indexOf(item) +
|
587
|
+
1
|
588
|
+
).toString(),
|
589
|
+
[headerItem.title]:
|
590
|
+
item[headerItem.key as keyof typeof item],
|
591
|
+
};
|
592
|
+
}, {});
|
593
|
+
});
|
594
|
+
|
595
|
+
handleExportData(title || "HMS Data", exportData);
|
571
596
|
}}
|
572
597
|
>
|
573
598
|
Export
|