next-helios-fe 1.0.0 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.0.0",
4
- "description": "",
3
+ "version": "1.0.2",
4
+ "description": "fix export data bug in table component",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "scripts": {
@@ -1,14 +1,18 @@
1
1
  "use client";
2
2
  import React, { useState, useEffect, useMemo } from "react";
3
3
  import { Icon } from "@iconify/react";
4
- import { Form, Button, Dropdown } from "../../components";
5
4
  import { exportToExcel } from "react-json-to-excel";
6
5
  import dayjs from "dayjs";
6
+ import { Form, Button, Dropdown } from "../../components";
7
7
  import { Action, type ActionProps } from "./action";
8
8
 
9
9
  interface TableProps {
10
10
  title?: string;
11
- header: { title: string; key: string }[];
11
+ header: {
12
+ title: string;
13
+ key: string;
14
+ render?: (item: any) => React.ReactNode;
15
+ }[];
12
16
  data: any[];
13
17
  options?: {
14
18
  hideToolbar?: boolean;
@@ -190,14 +194,25 @@ export const Table: TableComponentProps = ({
190
194
  {header
191
195
  ?.filter((headerItem) => !excluded.includes(headerItem.key))
192
196
  ?.map((headerItem) => {
193
- return (
194
- <td
195
- key={headerItem.key}
196
- className="px-4 py-1 border-b bg-secondary-bg whitespace-nowrap"
197
- >
198
- {item[headerItem.key as keyof typeof item]}
199
- </td>
200
- );
197
+ if (headerItem?.render) {
198
+ return (
199
+ <td
200
+ key={headerItem.key}
201
+ className="px-4 py-1 border-b bg-secondary-bg whitespace-nowrap"
202
+ >
203
+ {headerItem.render(item)}
204
+ </td>
205
+ );
206
+ } else {
207
+ return (
208
+ <td
209
+ key={headerItem.key}
210
+ className="px-4 py-1 border-b bg-secondary-bg whitespace-nowrap"
211
+ >
212
+ {item[headerItem.key as keyof typeof item]}
213
+ </td>
214
+ );
215
+ }
201
216
  })}
202
217
  {actions && (
203
218
  <td className="px-4 py-1 border-b bg-secondary-bg text-center">
@@ -259,7 +274,7 @@ export const Table: TableComponentProps = ({
259
274
  options={{ variant: "primary", width: "fit" }}
260
275
  onClick={() => {
261
276
  exportToExcel(
262
- data,
277
+ filteredData,
263
278
  `${title}-data_${dayjs().format("YYYY-MM-DD_HH-mm-ss")}`
264
279
  );
265
280
  }}