next-helios-fe 1.1.14 → 1.1.15

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,6 +1,6 @@
1
1
  {
2
2
  "name": "next-helios-fe",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,24 @@ interface TableProps {
18
18
  [key: string]: any;
19
19
  }[];
20
20
  options?: {
21
- hideToolbar?: boolean;
21
+ toolbar?: {
22
+ addData?: {
23
+ show?: boolean;
24
+ onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
25
+ };
26
+ search?: {
27
+ show?: boolean;
28
+ };
29
+ filter?: {
30
+ show?: boolean;
31
+ };
32
+ export?: {
33
+ show?: boolean;
34
+ };
35
+ pagination?: {
36
+ show?: boolean;
37
+ };
38
+ };
22
39
  hideNumberColumn?: boolean;
23
40
  enableBorder?: boolean;
24
41
  maxRow?: 10 | 20 | 50 | 100;
@@ -36,8 +53,7 @@ interface TableProps {
36
53
  }[]
37
54
  ) => void;
38
55
  };
39
- actions?: (e: any) => React.ReactNode;
40
- onAddData?: (e: React.MouseEvent<HTMLButtonElement>) => void;
56
+ actionColumn?: (e: any) => React.ReactNode;
41
57
  }
42
58
 
43
59
  interface TableComponentProps extends React.FC<TableProps> {
@@ -50,8 +66,7 @@ export const Table: TableComponentProps = ({
50
66
  data,
51
67
  options,
52
68
  checkbox,
53
- actions,
54
- onAddData,
69
+ actionColumn,
55
70
  }) => {
56
71
  const [search, setSearch] = useState<string>("");
57
72
  const [filter, setFilter] = useState<any[]>([]);
@@ -260,9 +275,9 @@ export const Table: TableComponentProps = ({
260
275
  );
261
276
  }
262
277
  })}
263
- {actions && (
278
+ {actionColumn && (
264
279
  <td className="px-4 py-1 border-b bg-secondary-bg text-center">
265
- {actions(item)}
280
+ {actionColumn(item)}
266
281
  </td>
267
282
  )}
268
283
  </tr>
@@ -271,21 +286,22 @@ export const Table: TableComponentProps = ({
271
286
 
272
287
  return (
273
288
  <div className="flex flex-col gap-6 h-full">
274
- {!options?.hideToolbar && (
275
- <div className="flex justify-between items-center gap-4 w-full h-fit">
276
- <span className="text-lg">{title}</span>
277
- <div className="flex items-center gap-4">
278
- {onAddData && (
279
- <button
280
- type="button"
281
- className="p-1.5 rounded-full bg-primary text-white hover:bg-primary-dark"
282
- onClick={(e) => {
283
- onAddData && onAddData(e);
284
- }}
285
- >
286
- <Icon icon="ic:round-plus" className="text-2xl" />
287
- </button>
288
- )}
289
+ <div className="flex justify-between items-center gap-4 w-full h-fit">
290
+ <span className="text-lg">{title}</span>
291
+ <div className="flex items-center gap-4">
292
+ {options?.toolbar?.addData?.show !== false && (
293
+ <button
294
+ type="button"
295
+ className="p-1.5 rounded-full bg-primary text-white hover:bg-primary-dark"
296
+ onClick={(e) => {
297
+ options?.toolbar?.addData?.onClick &&
298
+ options?.toolbar?.addData?.onClick(e);
299
+ }}
300
+ >
301
+ <Icon icon="ic:round-plus" className="text-2xl" />
302
+ </button>
303
+ )}
304
+ {options?.toolbar?.filter?.show !== false && (
289
305
  <Dropdown
290
306
  trigger={
291
307
  <button
@@ -319,6 +335,8 @@ export const Table: TableComponentProps = ({
319
335
  );
320
336
  })}
321
337
  </Dropdown>
338
+ )}
339
+ {options?.toolbar?.search?.show !== false && (
322
340
  <Form.Search
323
341
  options={{ width: "fit" }}
324
342
  placeholder="search.."
@@ -327,6 +345,8 @@ export const Table: TableComponentProps = ({
327
345
  setSearch(e.target.value);
328
346
  }}
329
347
  />
348
+ )}
349
+ {options?.toolbar?.export?.show !== false && (
330
350
  <Button
331
351
  type="button"
332
352
  options={{ variant: "primary", width: "fit" }}
@@ -339,9 +359,9 @@ export const Table: TableComponentProps = ({
339
359
  >
340
360
  Export
341
361
  </Button>
342
- </div>
362
+ )}
343
363
  </div>
344
- )}
364
+ </div>
345
365
  <div
346
366
  className={`overflow-auto ${height} ${
347
367
  options?.enableBorder && "border rounded-md"
@@ -387,7 +407,7 @@ export const Table: TableComponentProps = ({
387
407
  </th>
388
408
  )}
389
409
  {headerArr}
390
- {actions && (
410
+ {actionColumn && (
391
411
  <th className="w-min px-4 py-2 bg-secondary-bg font-medium text-center">
392
412
  <div className="flex flex-col">
393
413
  <span>Actions</span>
@@ -405,7 +425,7 @@ export const Table: TableComponentProps = ({
405
425
  <tbody>{dataArr}</tbody>
406
426
  </table>
407
427
  </div>
408
- {!options?.hideToolbar && (
428
+ {options?.toolbar?.pagination?.show !== false && (
409
429
  <div className="flex justify-between items-end gap-2 w-full h-fit">
410
430
  <div className="!text-sm">
411
431
  <Form.Select