@omniumretail/component-library 1.2.71 → 1.2.72
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 +12 -3
- package/NPMPUBLISH.md +0 -29
- package/bitbucket-pipelines.yml +0 -95
- package/dist/components/AnalyticsBar/AnalyticsBar.stories.d.ts +0 -5
- package/dist/components/BellNotifications/BellNotifications.stories.d.ts +0 -5
- package/dist/components/Button/Button.stories.d.ts +0 -6
- package/dist/components/Category/Category.stories.d.ts +0 -3
- package/dist/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +0 -3
- package/dist/components/CategoryResponse/CategoryResponse.stories.d.ts +0 -3
- package/dist/components/DatePicker/DatePicker.stories.d.ts +0 -5
- package/dist/components/DatePickerTag/DatePickerTag.stories.d.ts +0 -5
- package/dist/components/DropdownButton/DropdownButton.stories.d.ts +0 -5
- package/dist/components/ExportTableData/ExportTableData.stories.d.ts +0 -3
- package/dist/components/Footer/Footer.stories.d.ts +0 -5
- package/dist/components/Footer2/Footer.stories.d.ts +0 -6
- package/dist/components/Header/Header.stories.d.ts +0 -5
- package/dist/components/Input/Input.stories.d.ts +0 -5
- package/dist/components/InputCountryCode/inputCountryCode.stories.d.ts +0 -5
- package/dist/components/Label/Label.stories.d.ts +0 -6
- package/dist/components/Link/Link.stories.d.ts +0 -7
- package/dist/components/Menu/Menu.stories.d.ts +0 -5
- package/dist/components/MobileTable/MobileTable.stories.d.ts +0 -5
- package/dist/components/ModalConfirmation/ModalConfirmation.stories.d.ts +0 -5
- package/dist/components/ModalWithTable/ModalWithTable.stories.d.ts +0 -5
- package/dist/components/Navigation/Navigation.stories.d.ts +0 -5
- package/dist/components/Notification/Notification.stories.d.ts +0 -5
- package/dist/components/Questions/Questions.stories.d.ts +0 -3
- package/dist/components/Radio/Radio.stories.d.ts +0 -5
- package/dist/components/ResponseType/ResponseType.stories.d.ts +0 -3
- package/dist/components/ResponsiveTable/ResponsiveTable.stories.d.ts +0 -9
- package/dist/components/Select/Select.stories.d.ts +0 -6
- package/dist/components/Separator/Separator.stories.d.ts +0 -6
- package/dist/components/Sidebar/Sidebar.stories.d.ts +0 -6
- package/dist/components/Switch/Switch.stories.d.ts +0 -5
- package/dist/components/Table/Table.stories.d.ts +0 -9
- package/dist/components/Tag/Tag.stories.d.ts +0 -5
- package/dist/components/Upload/Upload.stories.d.ts +0 -3
- package/dist/components/UserInfo/UserInfo.stories.d.ts +0 -3
- package/dist/components/WebCam/WebCam.stories.d.ts +0 -3
- package/dist/types/index.d.ts +0 -2
- package/public/index.ts +0 -0
- package/src/assets/code-brackets.svg +0 -1
- package/src/assets/colors.svg +0 -1
- package/src/assets/comments.svg +0 -1
- package/src/assets/direction.svg +0 -1
- package/src/assets/flow.svg +0 -1
- package/src/assets/fonts/Silka-Bold.woff2 +0 -0
- package/src/assets/fonts/Silka-Regular.woff2 +0 -0
- package/src/assets/images/A2AI-logo.png +0 -0
- package/src/assets/images/omnium-retail-logo-white.png +0 -0
- package/src/assets/images/omnium-retail-logo.png +0 -0
- package/src/assets/images/omnium-retail_icon.png +0 -0
- package/src/assets/plugin.svg +0 -1
- package/src/assets/repo.svg +0 -1
- package/src/assets/scss/_combinations.scss +0 -0
- package/src/assets/scss/_global.scss +0 -89
- package/src/assets/scss/index.scss +0 -2
- package/src/assets/stackalt.svg +0 -1
- package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +0 -236
- package/src/components/AnalyticsBar/helpers/codeMutation.tsx +0 -19
- package/src/components/AnalyticsBar/index.tsx +0 -76
- package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +0 -13
- package/src/components/AnalyticsBar/styles.module.scss +0 -137
- package/src/components/BellNotifications/BellNotifications.stories.tsx +0 -200
- package/src/components/BellNotifications/index.tsx +0 -154
- package/src/components/BellNotifications/styles.module.scss +0 -239
- package/src/components/Button/Button.stories.tsx +0 -26
- package/src/components/Button/index.tsx +0 -24
- package/src/components/Button/styles.module.scss +0 -70
- package/src/components/Category/Category.stories.tsx +0 -371
- package/src/components/Category/CategoryContent/index.tsx +0 -255
- package/src/components/Category/CategoryContent/styles.module.scss +0 -69
- package/src/components/Category/CategorySidebar/index.tsx +0 -344
- package/src/components/Category/CategorySidebar/styles.module.scss +0 -28
- package/src/components/Category/index.tsx +0 -58
- package/src/components/Category/styles.module.scss +0 -13
- package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +0 -274
- package/src/components/CategoryReadOnly/evaluationOptions.tsx +0 -81
- package/src/components/CategoryReadOnly/index.tsx +0 -328
- package/src/components/CategoryReadOnly/styles.module.scss +0 -214
- package/src/components/CategoryResponse/CategoryResponse.stories.tsx +0 -311
- package/src/components/CategoryResponse/evaluationOptions.tsx +0 -81
- package/src/components/CategoryResponse/index.tsx +0 -502
- package/src/components/CategoryResponse/styles.module.scss +0 -365
- package/src/components/DatePicker/DatePicker.stories.tsx +0 -16
- package/src/components/DatePicker/index.tsx +0 -38
- package/src/components/DatePicker/styles.module.scss +0 -3
- package/src/components/DatePickerTag/DatePickerTag.stories.tsx +0 -19
- package/src/components/DatePickerTag/index.tsx +0 -91
- package/src/components/DatePickerTag/styles.module.scss +0 -32
- package/src/components/DropdownButton/DropdownButton.stories.tsx +0 -24
- package/src/components/DropdownButton/index.tsx +0 -36
- package/src/components/DropdownButton/styles.module.scss +0 -9
- package/src/components/ExportTableData/ExportTableData.stories.tsx +0 -43
- package/src/components/ExportTableData/index.tsx +0 -37
- package/src/components/ExportTableData/styles.module.scss +0 -4
- package/src/components/Footer/Footer.stories.tsx +0 -15
- package/src/components/Footer/index.tsx +0 -45
- package/src/components/Footer/styles.module.scss +0 -38
- package/src/components/Footer2/Footer.stories.tsx +0 -184
- package/src/components/Footer2/index.tsx +0 -322
- package/src/components/Footer2/styles.module.scss +0 -292
- package/src/components/Header/Header.data.ts +0 -26
- package/src/components/Header/Header.stories.tsx +0 -236
- package/src/components/Header/Header.types.ts +0 -32
- package/src/components/Header/README.md +0 -38
- package/src/components/Header/index.tsx +0 -200
- package/src/components/Header/styles.module.scss +0 -216
- package/src/components/Input/Input.stories.tsx +0 -13
- package/src/components/Input/index.tsx +0 -31
- package/src/components/Input/styles.module.scss +0 -8
- package/src/components/InputCountryCode/index.tsx +0 -79
- package/src/components/InputCountryCode/inputCountryCode.stories.tsx +0 -55
- package/src/components/InputCountryCode/styles.module.scss +0 -3
- package/src/components/Label/Label.stories.tsx +0 -21
- package/src/components/Label/index.tsx +0 -19
- package/src/components/Label/styles.module.scss +0 -17
- package/src/components/Link/Link.stories.tsx +0 -30
- package/src/components/Link/index.tsx +0 -21
- package/src/components/Link/styles.module.scss +0 -24
- package/src/components/Menu/Menu.stories.tsx +0 -178
- package/src/components/Menu/helpers/codeMutation.tsx +0 -19
- package/src/components/Menu/index.tsx +0 -24
- package/src/components/Menu/styles.module.scss +0 -0
- package/src/components/MobileTable/MobileTable.stories.tsx +0 -27
- package/src/components/MobileTable/index.tsx +0 -102
- package/src/components/MobileTable/styles.module.scss +0 -75
- package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +0 -40
- package/src/components/ModalConfirmation/ModalStatusList.tsx +0 -5
- package/src/components/ModalConfirmation/index.tsx +0 -71
- package/src/components/ModalConfirmation/styles.module.scss +0 -62
- package/src/components/ModalWithTable/ModalWithTable.stories.tsx +0 -99
- package/src/components/ModalWithTable/index.tsx +0 -238
- package/src/components/ModalWithTable/styles.module.scss +0 -77
- package/src/components/Navigation/Navigation.stories.tsx +0 -21
- package/src/components/Navigation/index.tsx +0 -91
- package/src/components/Navigation/styles.module.scss +0 -91
- package/src/components/Notification/Notification.stories.tsx +0 -32
- package/src/components/Notification/index.tsx +0 -28
- package/src/components/Questions/Questions.stories.tsx +0 -37
- package/src/components/Questions/SingleQuestion/index.tsx +0 -337
- package/src/components/Questions/SingleQuestion/styles.module.scss +0 -142
- package/src/components/Questions/index.tsx +0 -124
- package/src/components/Questions/styles.modules.scss +0 -0
- package/src/components/Radio/Radio.stories.tsx +0 -43
- package/src/components/Radio/index.tsx +0 -26
- package/src/components/Radio/styles.module.scss +0 -24
- package/src/components/ResponseType/ResponseType.stories.tsx +0 -393
- package/src/components/ResponseType/index.tsx +0 -100
- package/src/components/ResponseType/styles.module.scss +0 -31
- package/src/components/ResponsiveTable/ResponsiveTable.stories.tsx +0 -386
- package/src/components/ResponsiveTable/index.tsx +0 -389
- package/src/components/ResponsiveTable/styles.module.scss +0 -153
- package/src/components/Select/Select.stories.tsx +0 -39
- package/src/components/Select/index.tsx +0 -27
- package/src/components/Select/styles.module.scss +0 -19
- package/src/components/Separator/Separator.stories.tsx +0 -22
- package/src/components/Separator/index.tsx +0 -27
- package/src/components/Separator/styles.module.scss +0 -25
- package/src/components/Sidebar/Sidebar.stories.tsx +0 -85
- package/src/components/Sidebar/index.tsx +0 -127
- package/src/components/Sidebar/styles.module.scss +0 -141
- package/src/components/Switch/Switch.stories.tsx +0 -14
- package/src/components/Switch/index.tsx +0 -18
- package/src/components/Switch/styles.module.scss +0 -7
- package/src/components/Table/Table.stories.tsx +0 -337
- package/src/components/Table/index.tsx +0 -313
- package/src/components/Table/styles.module.scss +0 -97
- package/src/components/Tag/Tag.stories.tsx +0 -32
- package/src/components/Tag/index.tsx +0 -295
- package/src/components/Tag/styles.module.scss +0 -104
- package/src/components/Upload/Upload.stories.tsx +0 -45
- package/src/components/Upload/index.tsx +0 -112
- package/src/components/Upload/styles.module.scss +0 -29
- package/src/components/UserInfo/UserInfo.stories.tsx +0 -38
- package/src/components/UserInfo/index.tsx +0 -77
- package/src/components/UserInfo/styles.module.scss +0 -35
- package/src/components/WebCam/WebCam.stories.tsx +0 -24
- package/src/components/WebCam/index.tsx +0 -73
- package/src/components/WebCam/styles.module.scss +0 -37
- package/src/components/index.tsx +0 -34
- package/src/constants/i18n.ts +0 -25
- package/src/constants/logoCompanyHelper.ts +0 -52
- package/src/constants/translationHelper.ts +0 -7
- package/src/index.ts +0 -3
- package/src/locales/en.json +0 -142
- package/src/locales/es.json +0 -142
- package/src/locales/pt.json +0 -142
- package/src/types/Global.d.ts +0 -4
- package/tsconfig.json +0 -24
- package/vite.config.js +0 -51
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryFn } from "@storybook/react-vite";
|
|
2
|
-
import { Table, TableCustomProps } from '.';
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Table',
|
|
8
|
-
component: Table,
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
const Template: StoryFn<TableCustomProps> = (args: any) => {
|
|
12
|
-
const { t } = useTranslation();
|
|
13
|
-
const [pageInfo, setPageInfo] = useState<any>({});
|
|
14
|
-
const [rowSelectionInfo, setRowSelectionInfo] = useState<any>({});
|
|
15
|
-
const [sortBy, setSortBy] = useState<string[]>(['id', 'desc']);
|
|
16
|
-
|
|
17
|
-
const handleSortByColumnChange = (sortState: any) => {
|
|
18
|
-
console.log('handleSortChange called with:', sortState);
|
|
19
|
-
// Do something with the new sort state
|
|
20
|
-
// For example, trigger an API call
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return <Table scroll={{y: 1000, x: 3000}} fixedColumns={[
|
|
24
|
-
{ dataIndex: 'name', side: 'left' },
|
|
25
|
-
{ dataIndex: 'mecanographicNumber', side: 'left' },
|
|
26
|
-
]} customColumnWidths={[{columnName: 'name', width: "2%"}]} columnsSortChange={handleSortByColumnChange} paginationInfo={setPageInfo} headingTranslationsKey={'tableHeadings'} rowSelectionInfo={setRowSelectionInfo} actionsArray={
|
|
27
|
-
[
|
|
28
|
-
{ key: '1', label: `${t('actions.one')}`, onClick: () => {
|
|
29
|
-
console.log('onClick');
|
|
30
|
-
} },
|
|
31
|
-
{ key: '2', label: `${t('actions.two')}` },
|
|
32
|
-
{
|
|
33
|
-
key: '3', label: 'label 3'
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
} {...args}></Table>;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export const Primary = Template.bind({});
|
|
40
|
-
Primary.args = {
|
|
41
|
-
selectPlaceholder: 'Order by',
|
|
42
|
-
rowKeyValue: 'mecanographicNumber',
|
|
43
|
-
dataSource: [
|
|
44
|
-
{
|
|
45
|
-
id: `1`,
|
|
46
|
-
name: `João Cachulo`,
|
|
47
|
-
mecanographicNumber: "232",
|
|
48
|
-
store: `Levi's Sta Catarina`,
|
|
49
|
-
role: `Gerente`,
|
|
50
|
-
type: `Efetivo`
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
id: `2`,
|
|
54
|
-
name: `Filipe Martins`,
|
|
55
|
-
mecanographicNumber: "32",
|
|
56
|
-
store: `Levi's Sta Catarina`,
|
|
57
|
-
role: `Comercial`,
|
|
58
|
-
type: `Efetivo`
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: `3`,
|
|
62
|
-
name: `Anna Astori`,
|
|
63
|
-
mecanographicNumber: "3212",
|
|
64
|
-
store: `Levi's Sta Catarina`,
|
|
65
|
-
role: `Funcionário`,
|
|
66
|
-
type: `Efetivo`
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
id: `4`,
|
|
70
|
-
name: `Yield Ona`,
|
|
71
|
-
mecanographicNumber: "21232",
|
|
72
|
-
store: `Adidas Restaurantes`,
|
|
73
|
-
role: `Gerente`,
|
|
74
|
-
type: `Efetivo`
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
id: `5`,
|
|
78
|
-
name: `João Cachulo`,
|
|
79
|
-
mecanographicNumber: "232",
|
|
80
|
-
store: `Levi's Sta Catarina`,
|
|
81
|
-
role: `Gerente`,
|
|
82
|
-
type: `Efetivo`
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: `6`,
|
|
86
|
-
name: `Filipe Martins`,
|
|
87
|
-
mecanographicNumber: "32",
|
|
88
|
-
store: `Levi's Sta Catarina`,
|
|
89
|
-
role: `Comercial`,
|
|
90
|
-
type: `Efetivo`
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: `7`,
|
|
94
|
-
name: `Anna Astori`,
|
|
95
|
-
mecanographicNumber: "3212",
|
|
96
|
-
store: `Levi's Sta Catarina`,
|
|
97
|
-
role: `Funcionário`,
|
|
98
|
-
type: `Efetivo`
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
id: `8`,
|
|
102
|
-
name: `Yield Ona`,
|
|
103
|
-
mecanographicNumber: "21232",
|
|
104
|
-
store: `Adidas Restaurantes`,
|
|
105
|
-
role: `Gerente`,
|
|
106
|
-
type: `Efetivo`
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: `9`,
|
|
110
|
-
name: `João Cachulo`,
|
|
111
|
-
mecanographicNumber: "232",
|
|
112
|
-
store: `Levi's Sta Catarina`,
|
|
113
|
-
role: `Gerente`,
|
|
114
|
-
type: `Efetivo`
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: `10`,
|
|
118
|
-
name: `Filipe Martins`,
|
|
119
|
-
mecanographicNumber: "32",
|
|
120
|
-
store: `Levi's Sta Catarina`,
|
|
121
|
-
role: `Comercial`,
|
|
122
|
-
type: `Efetivo`
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: `11`,
|
|
126
|
-
name: `Anna Astori`,
|
|
127
|
-
mecanographicNumber: "3212",
|
|
128
|
-
store: `Levi's Sta Catarina`,
|
|
129
|
-
role: `Funcionário`,
|
|
130
|
-
type: `Efetivo`
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
id: `12`,
|
|
134
|
-
name: `Yield Ona`,
|
|
135
|
-
mecanographicNumber: "21232",
|
|
136
|
-
store: `Adidas Restaurantes`,
|
|
137
|
-
role: `Gerente`,
|
|
138
|
-
type: `Efetivo`
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
id: `13`,
|
|
142
|
-
name: `João Cachulo`,
|
|
143
|
-
mecanographicNumber: "232",
|
|
144
|
-
store: `Levi's Sta Catarina`,
|
|
145
|
-
role: `Gerente`,
|
|
146
|
-
type: `Efetivo`
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
id: `14`,
|
|
150
|
-
name: `João Cachulo`,
|
|
151
|
-
mecanographicNumber: "232",
|
|
152
|
-
store: `Levi's Sta Catarina`,
|
|
153
|
-
role: `Gerente`,
|
|
154
|
-
type: `Efetivo`
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
id: `15`,
|
|
158
|
-
name: `João Cachulo`,
|
|
159
|
-
mecanographicNumber: "232",
|
|
160
|
-
store: `Levi's Sta Catarina`,
|
|
161
|
-
role: `Gerente`,
|
|
162
|
-
type: `Efetivo`
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
id: `16`,
|
|
166
|
-
name: `João Cachulo`,
|
|
167
|
-
mecanographicNumber: "232",
|
|
168
|
-
store: `Levi's Sta Catarina`,
|
|
169
|
-
role: `Gerente`,
|
|
170
|
-
type: `Efetivo`
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
id: `17`,
|
|
174
|
-
name: `João Cachulo`,
|
|
175
|
-
mecanographicNumber: "232",
|
|
176
|
-
store: `Levi's Sta Catarina`,
|
|
177
|
-
role: `Gerente`,
|
|
178
|
-
type: `Efetivo`
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
id: `18`,
|
|
182
|
-
name: `João Cachulo`,
|
|
183
|
-
mecanographicNumber: "232",
|
|
184
|
-
store: `Levi's Sta Catarina`,
|
|
185
|
-
role: `Gerente`,
|
|
186
|
-
type: `Efetivo`
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
pagination: {
|
|
190
|
-
total: 24,
|
|
191
|
-
pageSize: 20
|
|
192
|
-
},
|
|
193
|
-
hiddenColumns: ['id'],
|
|
194
|
-
sortByColumns: true,
|
|
195
|
-
columnsToSort: ["name", "mecanographicNumber"]
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
export const Secondary = Template.bind({});
|
|
199
|
-
Secondary.args = {
|
|
200
|
-
dataSource: [
|
|
201
|
-
{
|
|
202
|
-
key: `1`,
|
|
203
|
-
name: `as John Brown`,
|
|
204
|
-
mecanographicNumber: 232,
|
|
205
|
-
store: `Levi's Sta Catarina`,
|
|
206
|
-
role: `Gerente`,
|
|
207
|
-
type: `Efetivo`
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
key: `2`,
|
|
211
|
-
name: `bv Mary Brown`,
|
|
212
|
-
mecanographicNumber: 32,
|
|
213
|
-
store: `Levi's Sta Catarina`,
|
|
214
|
-
role: `Comercial`,
|
|
215
|
-
type: `Efetivo`
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
key: `3`,
|
|
219
|
-
name: `as Anna Astori`,
|
|
220
|
-
mecanographicNumber: 3212,
|
|
221
|
-
store: `Levi's Sta Catarina`,
|
|
222
|
-
role: `Funcionário`,
|
|
223
|
-
type: `Efetivo`
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
key: `4`,
|
|
227
|
-
name: `bv Yield Ona`,
|
|
228
|
-
mecanographicNumber: 21232,
|
|
229
|
-
store: `Adidas Restaurantes`,
|
|
230
|
-
role: `Gerente`,
|
|
231
|
-
type: `Efetivo`
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
pagination: {
|
|
235
|
-
total: 4,
|
|
236
|
-
pageSize: 10
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
export const WithCheckbox = Template.bind({});
|
|
241
|
-
WithCheckbox.args = {
|
|
242
|
-
dataSource: [
|
|
243
|
-
{
|
|
244
|
-
key: `1`,
|
|
245
|
-
name: `John Brown`,
|
|
246
|
-
mecanographicNumber: 232,
|
|
247
|
-
store: `Levi's Sta Catarina`,
|
|
248
|
-
role: `Gerente`,
|
|
249
|
-
type: `Efetivo`
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
key: `2`,
|
|
253
|
-
name: `Mary Brown`,
|
|
254
|
-
mecanographicNumber: 32,
|
|
255
|
-
store: `Levi's Sta Catarina`,
|
|
256
|
-
role: `Comercial`,
|
|
257
|
-
type: `Efetivo`
|
|
258
|
-
},
|
|
259
|
-
{
|
|
260
|
-
key: `3`,
|
|
261
|
-
name: `Anna Astori`,
|
|
262
|
-
mecanographicNumber: 3212,
|
|
263
|
-
store: `Levi's Sta Catarina`,
|
|
264
|
-
role: `Funcionário`,
|
|
265
|
-
type: `Efetivo`
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
key: `4`,
|
|
269
|
-
name: `Yield Ona`,
|
|
270
|
-
mecanographicNumber: 21232,
|
|
271
|
-
store: `Adidas Restaurantes`,
|
|
272
|
-
role: `Gerente`,
|
|
273
|
-
type: `Efetivo`
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
export const withActions = Template.bind({});
|
|
279
|
-
withActions.args = {
|
|
280
|
-
fieldsToSort: ['store', 'mecanographicNumber'],
|
|
281
|
-
selectPlaceholder: 'Order by',
|
|
282
|
-
dataSource: [
|
|
283
|
-
{
|
|
284
|
-
key: `1`,
|
|
285
|
-
name: `John Brown`,
|
|
286
|
-
mecanographicNumber: "232",
|
|
287
|
-
store: `Levi's Sta Catarina`,
|
|
288
|
-
role: `Gerente`,
|
|
289
|
-
type: `Efetivo`
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
key: `2`,
|
|
293
|
-
name: `Mary Brown`,
|
|
294
|
-
mecanographicNumber: "32",
|
|
295
|
-
store: `Levi's Sta Catarina`,
|
|
296
|
-
role: `Comercial`,
|
|
297
|
-
type: `Efetivo`
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
key: `3`,
|
|
301
|
-
name: `Anna Astori`,
|
|
302
|
-
mecanographicNumber: "3212",
|
|
303
|
-
store: `Levi's Sta Catarina`,
|
|
304
|
-
role: `Funcionário`,
|
|
305
|
-
type: `Efetivo`
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
key: `4`,
|
|
309
|
-
name: `Yield Ona`,
|
|
310
|
-
mecanographicNumber: "21232",
|
|
311
|
-
store: `Adidas Restaurantes`,
|
|
312
|
-
role: `Gerente`,
|
|
313
|
-
type: `Efetivo`
|
|
314
|
-
},
|
|
315
|
-
],
|
|
316
|
-
pagination: {
|
|
317
|
-
total: 24,
|
|
318
|
-
pageSize: 4
|
|
319
|
-
},
|
|
320
|
-
rowSelection: {
|
|
321
|
-
type: 'checkbox',
|
|
322
|
-
selectedRowKeys: ['1']
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
|
|
326
|
-
export const NoData = Template.bind({});
|
|
327
|
-
NoData.args = {
|
|
328
|
-
fieldsToSort: ['store', 'mecanographicNumber'],
|
|
329
|
-
selectPlaceholder: 'Order by',
|
|
330
|
-
rowKeyValue: 'mecanographicNumber',
|
|
331
|
-
dataSource: undefined,
|
|
332
|
-
pagination: {
|
|
333
|
-
total: 24,
|
|
334
|
-
pageSize: 4
|
|
335
|
-
},
|
|
336
|
-
hiddenColumns: ['id']
|
|
337
|
-
};
|
|
@@ -1,313 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
import { Space, TableProps, Select, Dropdown } from 'antd';
|
|
3
|
-
import { Table as AntdTable } from 'antd';
|
|
4
|
-
import type { ColumnsType } from 'antd/es/table/interface';
|
|
5
|
-
import styles from './styles.module.scss';
|
|
6
|
-
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import { MoreOutlined } from '@ant-design/icons';
|
|
8
|
-
import classnames from 'classnames';
|
|
9
|
-
import { Button } from '../Button';
|
|
10
|
-
|
|
11
|
-
export interface FilterOptions {
|
|
12
|
-
value: string;
|
|
13
|
-
label: string;
|
|
14
|
-
direction: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface Actions {
|
|
18
|
-
key: string;
|
|
19
|
-
label: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export enum sortBy {
|
|
23
|
-
asc = 'asc',
|
|
24
|
-
desc = 'desc',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface TableCustomProps extends TableProps<any> {
|
|
28
|
-
fieldsToSort?: any[],
|
|
29
|
-
selectPlaceholder?: string,
|
|
30
|
-
onSort?: (field: any, sortBy: any) => void;
|
|
31
|
-
sortInfo?: any;
|
|
32
|
-
paginationInfo?: any;
|
|
33
|
-
headingTranslationsKey?: string;
|
|
34
|
-
actionsArray?: any;
|
|
35
|
-
rowSelectionInfo?: any;
|
|
36
|
-
rowKeyValue?: string;
|
|
37
|
-
hiddenColumns?: string[];
|
|
38
|
-
rowSelection?: any;
|
|
39
|
-
onSelectAllButtonClick?: () => void;
|
|
40
|
-
AllItemsShowing?: boolean;
|
|
41
|
-
selectAllStatus?: any;
|
|
42
|
-
isTableDataRefreshed?: any;
|
|
43
|
-
tableLoading?: any;
|
|
44
|
-
tableMaxHeight?: any;
|
|
45
|
-
columnsSortChange?: any;
|
|
46
|
-
sortByColumns?: boolean;
|
|
47
|
-
columnsToSort?: string[];
|
|
48
|
-
fixedColumns?: { dataIndex: string; side: 'left' | 'right' }[];
|
|
49
|
-
customColumnWidths?: { columnName: string; width: string }[];
|
|
50
|
-
getRowActions?: (record: any) => any;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export const Table = (props: TableCustomProps) => {
|
|
54
|
-
const { t } = useTranslation();
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
dataSource = undefined,
|
|
58
|
-
fieldsToSort,
|
|
59
|
-
selectPlaceholder = 'Sort By',
|
|
60
|
-
onSort,
|
|
61
|
-
headingTranslationsKey,
|
|
62
|
-
actionsArray: items,
|
|
63
|
-
rowKeyValue,
|
|
64
|
-
hiddenColumns,
|
|
65
|
-
rowSelection,
|
|
66
|
-
onSelectAllButtonClick,
|
|
67
|
-
AllItemsShowing,
|
|
68
|
-
selectAllStatus,
|
|
69
|
-
isTableDataRefreshed,
|
|
70
|
-
tableLoading,
|
|
71
|
-
tableMaxHeight,
|
|
72
|
-
sortByColumns,
|
|
73
|
-
columnsToSort,
|
|
74
|
-
fixedColumns,
|
|
75
|
-
customColumnWidths,
|
|
76
|
-
getRowActions
|
|
77
|
-
} = props;
|
|
78
|
-
|
|
79
|
-
const [customFilters, setCustomFilters] = useState<any>([]);
|
|
80
|
-
const [customColumns, setCustomColumns] = useState<ColumnsType<any>>([]);
|
|
81
|
-
const [sortInfo, setSortInfo] = useState<any>([]);
|
|
82
|
-
const [selectedRowKeys, setselectedRowKeys] = useState<any>(rowSelection?.selectedRowKeys || []);
|
|
83
|
-
const [selectedAllRowKeys, setSelectedAllRowKeys] = useState(false);
|
|
84
|
-
const [deselectAll, setDeselectAll] = useState(false);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const onSelectChange = (newSelectedRowKeys: React.Key[]) => {
|
|
88
|
-
if (rowSelection.type === 'radio') {
|
|
89
|
-
setselectedRowKeys(newSelectedRowKeys);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
setselectedRowKeys((prevKeys: any) => {
|
|
94
|
-
const dataSourceIds = dataSource?.map((data) => data[rowKeyValue as any])
|
|
95
|
-
|
|
96
|
-
const oldKeys = prevKeys.filter((key: any) => {
|
|
97
|
-
return !dataSourceIds?.includes(key)
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return [...oldKeys, ...newSelectedRowKeys];
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
setSelectedAllRowKeys(false);
|
|
104
|
-
setDeselectAll(false);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const handleChange: TableProps<any>['onChange'] = (pagination, filters, sorter: any, extra) => {
|
|
108
|
-
const getPagination = {
|
|
109
|
-
currentPage: pagination.current,
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const getSortAndPaginationInfo = { ...sortInfo, ...getPagination }
|
|
113
|
-
props.paginationInfo(getSortAndPaginationInfo);
|
|
114
|
-
|
|
115
|
-
// SORT
|
|
116
|
-
if (sortByColumns) {
|
|
117
|
-
const { field, order } = sorter;
|
|
118
|
-
let mappedOrder = null;
|
|
119
|
-
if (order === "ascend") {
|
|
120
|
-
mappedOrder = "asc";
|
|
121
|
-
} else if (order === "descend") {
|
|
122
|
-
mappedOrder = "desc";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
if (field && mappedOrder) {
|
|
126
|
-
props.columnsSortChange({ field, order: mappedOrder });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const setSorter = (option: any) => {
|
|
132
|
-
onSort?.(option.value.split('-')[0], option.direction);
|
|
133
|
-
const sortData = {
|
|
134
|
-
sortDirection: option.direction,
|
|
135
|
-
sortValue: option.value.split('-')[0],
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
setSortInfo(sortData)
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const selectAllRows = () => {
|
|
142
|
-
if (selectedAllRowKeys) {
|
|
143
|
-
setDeselectAll(true);
|
|
144
|
-
} else {
|
|
145
|
-
onSelectAllButtonClick?.(); // Call the onSelectAllButtonClick callback
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
if (isTableDataRefreshed && !tableLoading || AllItemsShowing) {
|
|
151
|
-
if (selectAllStatus && AllItemsShowing) {
|
|
152
|
-
const allRowKeys = dataSource?.map((record) => record[rowKeyValue as any]);
|
|
153
|
-
setselectedRowKeys(allRowKeys);
|
|
154
|
-
setSelectedAllRowKeys(true);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}, [isTableDataRefreshed, tableLoading, selectAllStatus, AllItemsShowing]);
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (deselectAll) {
|
|
161
|
-
setselectedRowKeys([]);
|
|
162
|
-
setDeselectAll(false);
|
|
163
|
-
setSelectedAllRowKeys(false);
|
|
164
|
-
}
|
|
165
|
-
}, [deselectAll]);
|
|
166
|
-
|
|
167
|
-
useEffect(() => {
|
|
168
|
-
props.rowSelectionInfo(selectedRowKeys);
|
|
169
|
-
}, [selectedRowKeys]);
|
|
170
|
-
|
|
171
|
-
useEffect(() => {
|
|
172
|
-
if (dataSource && (dataSource as any)?.length > 0) {
|
|
173
|
-
// Columns
|
|
174
|
-
let columns = Object.keys(dataSource?.[0]).map(key => {
|
|
175
|
-
if (hiddenColumns?.includes(key)) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
const isColumnSortable = columnsToSort?.includes(key) ? sortByColumns : false;
|
|
180
|
-
|
|
181
|
-
const column = {
|
|
182
|
-
title: headingTranslationsKey ? t(`${headingTranslationsKey}.${key}`) : key,
|
|
183
|
-
dataIndex: key,
|
|
184
|
-
key: key,
|
|
185
|
-
ellipsis: false,
|
|
186
|
-
sorter: isColumnSortable,
|
|
187
|
-
// No fixed property here, we'll add it later based on the fixedColumns prop
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
return column;
|
|
191
|
-
|
|
192
|
-
}).filter(el => el !== undefined) as any;
|
|
193
|
-
|
|
194
|
-
let columnActions = {
|
|
195
|
-
key: 'action',
|
|
196
|
-
title: headingTranslationsKey ? t(`${headingTranslationsKey}.${'action'}`) : 'action',
|
|
197
|
-
dataIndex: 6,
|
|
198
|
-
ellipsis: false,
|
|
199
|
-
render: (_: any, record: any) => {
|
|
200
|
-
const rowActions = getRowActions ? getRowActions(record) : null;
|
|
201
|
-
|
|
202
|
-
if ((!items?.[0] && !rowActions)) return null;
|
|
203
|
-
|
|
204
|
-
const actions = rowActions ? rowActions : items;
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<Space size="middle">
|
|
208
|
-
<Dropdown menu={{ items: actions }}>
|
|
209
|
-
<a>
|
|
210
|
-
<MoreOutlined style={{ color: 'var(--color-blue)', transform: 'scale(1.6)' }} />
|
|
211
|
-
</a>
|
|
212
|
-
</Dropdown>
|
|
213
|
-
</Space>
|
|
214
|
-
);
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
(items || getRowActions) && columns.push(columnActions as any);
|
|
219
|
-
|
|
220
|
-
if (fixedColumns) {
|
|
221
|
-
fixedColumns.forEach((column) => {
|
|
222
|
-
const { dataIndex, side } = column;
|
|
223
|
-
const foundColumn = columns.find((col: any) => col.dataIndex === dataIndex);
|
|
224
|
-
if (foundColumn) {
|
|
225
|
-
foundColumn.fixed = side;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
if (customColumnWidths) {
|
|
231
|
-
customColumnWidths.forEach((column) => {
|
|
232
|
-
const { columnName, width } = column;
|
|
233
|
-
const foundColumn = columns.find((col: any) => col.dataIndex === columnName);
|
|
234
|
-
if (foundColumn) {
|
|
235
|
-
foundColumn.width = width;
|
|
236
|
-
}
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
setCustomColumns(columns);
|
|
241
|
-
|
|
242
|
-
// Filters
|
|
243
|
-
const dataKeysToFilter = Object.keys(dataSource?.[0]).filter((el) => fieldsToSort?.includes(el));
|
|
244
|
-
|
|
245
|
-
const filters = ([] as FilterOptions[]).concat(
|
|
246
|
-
...dataKeysToFilter.map(key => ({
|
|
247
|
-
value: `${key}-${sortBy.desc}`,
|
|
248
|
-
label: `${headingTranslationsKey ? t(`${headingTranslationsKey}.${key}`) : key} (${sortBy.desc})`,
|
|
249
|
-
direction: `${sortBy.desc}`,
|
|
250
|
-
})),
|
|
251
|
-
...dataKeysToFilter.map(key => ({
|
|
252
|
-
value: `${key}-${sortBy.asc}`,
|
|
253
|
-
label: `${headingTranslationsKey ? t(`${headingTranslationsKey}.${key}`) : key} (${sortBy.asc})`,
|
|
254
|
-
direction: `${sortBy.asc}`,
|
|
255
|
-
}))
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
setCustomFilters(filters);
|
|
259
|
-
}
|
|
260
|
-
}, [dataSource]);
|
|
261
|
-
|
|
262
|
-
const shouldRenderSortDropdown = customFilters.length > 0;
|
|
263
|
-
|
|
264
|
-
const tableWrapperClasses = classnames({
|
|
265
|
-
[styles.tableWrapperNoSelection]: !rowSelection
|
|
266
|
-
}, [styles.tableWrapper]);
|
|
267
|
-
|
|
268
|
-
return (
|
|
269
|
-
<div className={tableWrapperClasses}>
|
|
270
|
-
{shouldRenderSortDropdown &&
|
|
271
|
-
<Space style={{ marginBottom: 16 }}>
|
|
272
|
-
<Select
|
|
273
|
-
style={{ width: 'auto', minWidth: 200 }}
|
|
274
|
-
placeholder={selectPlaceholder}
|
|
275
|
-
onSelect={(_, option: any) => {
|
|
276
|
-
setSorter(option);
|
|
277
|
-
}}
|
|
278
|
-
optionFilterProp="children"
|
|
279
|
-
filterOption={(input, option) => (option?.label ?? '').includes(input)}
|
|
280
|
-
filterSort={(optionA, optionB) =>
|
|
281
|
-
(optionA?.label ?? '').toLowerCase().localeCompare((optionB?.label ?? '').toLowerCase())
|
|
282
|
-
}
|
|
283
|
-
options={customFilters}
|
|
284
|
-
/>
|
|
285
|
-
</Space>
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
<AntdTable
|
|
289
|
-
dataSource={dataSource}
|
|
290
|
-
onChange={handleChange}
|
|
291
|
-
{...props}
|
|
292
|
-
columns={customColumns}
|
|
293
|
-
{...props.rowSelection ? (
|
|
294
|
-
{
|
|
295
|
-
rowSelection: {
|
|
296
|
-
selectedRowKeys: selectedRowKeys,
|
|
297
|
-
onChange: onSelectChange,
|
|
298
|
-
type: props.rowSelection?.type,
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
) : null}
|
|
302
|
-
rowKey={rowKeyValue}
|
|
303
|
-
{...(tableMaxHeight ? { scroll: { y: tableMaxHeight } } : {})}
|
|
304
|
-
/>
|
|
305
|
-
{
|
|
306
|
-
onSelectAllButtonClick &&
|
|
307
|
-
<Button onClick={selectAllRows} className={styles.selectAllRows}>
|
|
308
|
-
{selectedAllRowKeys ? t('components.table.deselectAll') : t('components.table.selectAll')}
|
|
309
|
-
</Button>
|
|
310
|
-
}
|
|
311
|
-
</div>
|
|
312
|
-
);
|
|
313
|
-
};
|