@omniumretail/component-library 1.2.54 → 1.2.55

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.
@@ -48,6 +48,6 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
48
48
  cleanRowSelection?: boolean;
49
49
  getRowActions?: (record: any) => any;
50
50
  customSelectAllButton?: string;
51
- buttonActionIcon?: any;
51
+ buttonActionIcon?: (record: any) => any | null;
52
52
  }
53
53
  export declare const ResponsiveTable: (props: ResponsiveTableCustomProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omniumretail/component-library",
3
- "version": "1.2.54",
3
+ "version": "1.2.55",
4
4
  "private": false,
5
5
  "main": "dist/bundle.js",
6
6
  "typings": "./dist/types/index",
@@ -2,6 +2,7 @@ import { Meta, Story } from "@storybook/react";
2
2
  import { ResponsiveTable, ResponsiveTableCustomProps } from '.';
3
3
  import { useState } from "react";
4
4
  import { useTranslation } from "react-i18next";
5
+ import { DownloadOutlined } from "@ant-design/icons";
5
6
 
6
7
  export default {
7
8
  title: 'ResponsiveTable',
@@ -23,10 +24,10 @@ const Template: Story<ResponsiveTableCustomProps> = (args) => {
23
24
 
24
25
  const getButtonLabel = (record: any) => {
25
26
  return (record as any)?.type === "Efetivo" ? "Pog" : null;
26
- };
27
+ };
27
28
 
28
- const getActionsForRecord = (record: any) => {
29
- return (record as any)?.role === "Gerente"
29
+ const getActionsForRecord = (record: any) => {
30
+ return (record as any)?.role === "Gerente"
30
31
  ? [
31
32
  {
32
33
  key: '1', label: `${t('actions.one')}`, onClick: () => {
@@ -52,14 +53,23 @@ const getActionsForRecord = (record: any) => {
52
53
  key: '4', label: 'label 4'
53
54
  }
54
55
  ];
55
- };
56
+ };
57
+
58
+ const getIcon = (record: any) => {
59
+ return record.id === "1"
60
+ ? <DownloadOutlined />
61
+ : record.id === "3"
62
+ ? <DownloadOutlined />
63
+ : null;
64
+ };
56
65
 
66
+ const actionsArray = [{ key: '1', label: `` }];
57
67
 
58
68
  return <ResponsiveTable
59
69
  cleanRowSelection={clearRowSelection}
60
70
  columnsSortChange={handleSortByColumnChange} paginationInfo={setPageInfo} headingTranslationsKey={'tableHeadings'} rowSelectionInfo={setRowSelectionInfo}
61
- getRowActions={getActionsForRecord}
62
- fixedColumns={[{ dataIndex: 'action', side: 'right' }]} buttonActionMethod={() => handleSortByColumnChange} buttonActionLabel={getButtonLabel} {...args}>
71
+ actionsArray={actionsArray}
72
+ fixedColumns={[{ dataIndex: 'action', side: 'right' }]} buttonActionIcon={getIcon} {...args}>
63
73
  </ResponsiveTable>;
64
74
  };
65
75
 
@@ -54,7 +54,7 @@ export interface ResponsiveTableCustomProps extends TableProps<any> {
54
54
  cleanRowSelection?: boolean;
55
55
  getRowActions?: (record: any) => any;
56
56
  customSelectAllButton?: string;
57
- buttonActionIcon?: any;
57
+ buttonActionIcon?: (record: any) => any | null;
58
58
  }
59
59
 
60
60
  export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
@@ -225,18 +225,20 @@ export const ResponsiveTable = (props: ResponsiveTableCustomProps) => {
225
225
 
226
226
  const buttonLabel = buttonActionLabel ? buttonActionLabel(record) : null;
227
227
 
228
+ const icon = buttonActionIcon ? buttonActionIcon(record) : null;
229
+
228
230
  const buttonClass = typeof buttonActionStyle === 'function'
229
231
  ? buttonActionStyle(record) // Se for uma função, chama com o `record`
230
232
  : buttonActionStyle || ''; // Se for string, usa diretamente
231
233
 
232
234
  const renderActionElement = () => {
233
- if (buttonActionIcon) {
235
+ if (icon) {
234
236
  return (
235
237
  <span
236
238
  className={buttonClass}
237
239
  onClick={() => buttonActionMethod?.()}
238
240
  >
239
- {buttonActionIcon}
241
+ {icon}
240
242
  </span>
241
243
  );
242
244
  }