@omniumretail/component-library 1.2.70 → 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.
Files changed (249) hide show
  1. package/dist/component-library.umd.js +1154 -0
  2. package/dist/{types/components → components}/AnalyticsBar/helpers/codeMutation.d.ts +2 -2
  3. package/dist/{types/components → components}/AnalyticsBar/index.d.ts +2 -1
  4. package/dist/{types/components → components}/Button/index.d.ts +2 -1
  5. package/dist/{types/components → components}/Category/index.d.ts +2 -1
  6. package/dist/{types/components → components}/CategoryReadOnly/index.d.ts +2 -1
  7. package/dist/{types/components → components}/CategoryResponse/index.d.ts +3 -2
  8. package/dist/{types/components → components}/DatePicker/index.d.ts +2 -1
  9. package/dist/{types/components → components}/DatePickerTag/index.d.ts +2 -1
  10. package/dist/{types/components → components}/DropdownButton/index.d.ts +3 -2
  11. package/dist/{types/components → components}/Footer2/index.d.ts +2 -1
  12. package/dist/{types/components → components}/Header/Header.data.d.ts +2 -1
  13. package/dist/{types/components → components}/Header/Header.types.d.ts +2 -1
  14. package/dist/{types/components → components}/Header/index.d.ts +2 -1
  15. package/dist/{types/components → components}/Input/index.d.ts +2 -1
  16. package/dist/{types/components → components}/InputCountryCode/index.d.ts +2 -1
  17. package/dist/{types/components → components}/Link/index.d.ts +2 -1
  18. package/dist/{types/components → components}/Menu/helpers/codeMutation.d.ts +2 -2
  19. package/dist/{types/components → components}/Menu/index.d.ts +2 -1
  20. package/dist/{types/components → components}/MobileTable/index.d.ts +2 -1
  21. package/dist/{types/components → components}/ModalWithTable/index.d.ts +2 -1
  22. package/dist/{types/components → components}/Notification/index.d.ts +2 -1
  23. package/dist/{types/components → components}/Radio/index.d.ts +3 -2
  24. package/dist/{types/components → components}/ResponsiveTable/index.d.ts +2 -1
  25. package/dist/{types/components → components}/Select/index.d.ts +2 -1
  26. package/dist/{types/components → components}/Switch/index.d.ts +2 -1
  27. package/dist/{types/components → components}/Table/index.d.ts +2 -1
  28. package/dist/{types/components → components}/Tag/index.d.ts +3 -2
  29. package/dist/{types/components → components}/Upload/index.d.ts +3 -2
  30. package/dist/{types/components → components}/WebCam/index.d.ts +2 -1
  31. package/{src/locales/en.json → dist/locales/en.json.d.ts} +4 -2
  32. package/{src/locales/es.json → dist/locales/es.json.d.ts} +4 -2
  33. package/{src/locales/pt.json → dist/locales/pt.json.d.ts} +4 -1
  34. package/package.json +98 -183
  35. package/NPMPUBLISH.md +0 -29
  36. package/bitbucket-pipelines.yml +0 -95
  37. package/dist/780.bundle.js +0 -1
  38. package/dist/838.bundle.js +0 -2
  39. package/dist/838.bundle.js.LICENSE.txt +0 -1
  40. package/dist/bundle.js +0 -2
  41. package/dist/bundle.js.LICENSE.txt +0 -451
  42. package/dist/main.css +0 -36
  43. package/dist/types/components/AnalyticsBar/AnalyticsBar.stories.d.ts +0 -4
  44. package/dist/types/components/BellNotifications/BellNotifications.stories.d.ts +0 -4
  45. package/dist/types/components/Button/Button.stories.d.ts +0 -5
  46. package/dist/types/components/Category/Category.stories.d.ts +0 -3
  47. package/dist/types/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +0 -3
  48. package/dist/types/components/CategoryResponse/CategoryResponse.stories.d.ts +0 -3
  49. package/dist/types/components/DatePicker/DatePicker.stories.d.ts +0 -4
  50. package/dist/types/components/DatePickerTag/DatePickerTag.stories.d.ts +0 -4
  51. package/dist/types/components/DropdownButton/DropdownButton.stories.d.ts +0 -4
  52. package/dist/types/components/ExportTableData/ExportTableData.stories.d.ts +0 -3
  53. package/dist/types/components/Footer/Footer.stories.d.ts +0 -4
  54. package/dist/types/components/Footer2/Footer.stories.d.ts +0 -5
  55. package/dist/types/components/Header/Header.stories.d.ts +0 -4
  56. package/dist/types/components/Input/Input.stories.d.ts +0 -4
  57. package/dist/types/components/InputCountryCode/inputCountryCode.stories.d.ts +0 -4
  58. package/dist/types/components/Label/Label.stories.d.ts +0 -5
  59. package/dist/types/components/Link/Link.stories.d.ts +0 -6
  60. package/dist/types/components/Menu/Menu.stories.d.ts +0 -4
  61. package/dist/types/components/MobileTable/MobileTable.stories.d.ts +0 -4
  62. package/dist/types/components/ModalConfirmation/ModalConfirmation.stories.d.ts +0 -4
  63. package/dist/types/components/ModalWithTable/ModalWithTable.stories.d.ts +0 -4
  64. package/dist/types/components/Navigation/Navigation.stories.d.ts +0 -4
  65. package/dist/types/components/Notification/Notification.stories.d.ts +0 -4
  66. package/dist/types/components/Questions/Questions.stories.d.ts +0 -3
  67. package/dist/types/components/Radio/Radio.stories.d.ts +0 -4
  68. package/dist/types/components/ResponseType/ResponseType.stories.d.ts +0 -3
  69. package/dist/types/components/ResponsiveTable/ResponsiveTable.stories.d.ts +0 -8
  70. package/dist/types/components/Select/Select.stories.d.ts +0 -5
  71. package/dist/types/components/Separator/Separator.stories.d.ts +0 -5
  72. package/dist/types/components/Sidebar/Sidebar.stories.d.ts +0 -5
  73. package/dist/types/components/Switch/Switch.stories.d.ts +0 -4
  74. package/dist/types/components/Table/Table.stories.d.ts +0 -8
  75. package/dist/types/components/Tag/Tag.stories.d.ts +0 -4
  76. package/dist/types/components/Upload/Upload.stories.d.ts +0 -3
  77. package/dist/types/components/UserInfo/UserInfo.stories.d.ts +0 -3
  78. package/dist/types/components/WebCam/WebCam.stories.d.ts +0 -3
  79. package/src/assets/code-brackets.svg +0 -1
  80. package/src/assets/colors.svg +0 -1
  81. package/src/assets/comments.svg +0 -1
  82. package/src/assets/direction.svg +0 -1
  83. package/src/assets/flow.svg +0 -1
  84. package/src/assets/fonts/Silka-Bold.woff2 +0 -0
  85. package/src/assets/fonts/Silka-Regular.woff2 +0 -0
  86. package/src/assets/images/A2AI-logo.png +0 -0
  87. package/src/assets/images/omnium-retail-logo-white.png +0 -0
  88. package/src/assets/images/omnium-retail-logo.png +0 -0
  89. package/src/assets/images/omnium-retail_icon.png +0 -0
  90. package/src/assets/plugin.svg +0 -1
  91. package/src/assets/repo.svg +0 -1
  92. package/src/assets/scss/_combinations.scss +0 -0
  93. package/src/assets/scss/_global.scss +0 -89
  94. package/src/assets/scss/index.scss +0 -2
  95. package/src/assets/stackalt.svg +0 -1
  96. package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +0 -236
  97. package/src/components/AnalyticsBar/helpers/codeMutation.tsx +0 -19
  98. package/src/components/AnalyticsBar/index.tsx +0 -76
  99. package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +0 -13
  100. package/src/components/AnalyticsBar/styles.module.scss +0 -137
  101. package/src/components/BellNotifications/BellNotifications.stories.tsx +0 -200
  102. package/src/components/BellNotifications/index.tsx +0 -154
  103. package/src/components/BellNotifications/styles.module.scss +0 -239
  104. package/src/components/Button/Button.stories.tsx +0 -26
  105. package/src/components/Button/index.tsx +0 -24
  106. package/src/components/Button/styles.module.scss +0 -70
  107. package/src/components/Category/Category.stories.tsx +0 -371
  108. package/src/components/Category/CategoryContent/index.tsx +0 -255
  109. package/src/components/Category/CategoryContent/styles.module.scss +0 -69
  110. package/src/components/Category/CategorySidebar/index.tsx +0 -344
  111. package/src/components/Category/CategorySidebar/styles.module.scss +0 -28
  112. package/src/components/Category/index.tsx +0 -58
  113. package/src/components/Category/styles.module.scss +0 -13
  114. package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +0 -274
  115. package/src/components/CategoryReadOnly/evaluationOptions.tsx +0 -81
  116. package/src/components/CategoryReadOnly/index.tsx +0 -328
  117. package/src/components/CategoryReadOnly/styles.module.scss +0 -214
  118. package/src/components/CategoryResponse/CategoryResponse.stories.tsx +0 -312
  119. package/src/components/CategoryResponse/evaluationOptions.tsx +0 -81
  120. package/src/components/CategoryResponse/index.tsx +0 -502
  121. package/src/components/CategoryResponse/styles.module.scss +0 -365
  122. package/src/components/DatePicker/DatePicker.stories.tsx +0 -16
  123. package/src/components/DatePicker/index.tsx +0 -38
  124. package/src/components/DatePicker/styles.module.scss +0 -3
  125. package/src/components/DatePickerTag/DatePickerTag.stories.tsx +0 -19
  126. package/src/components/DatePickerTag/index.tsx +0 -91
  127. package/src/components/DatePickerTag/styles.module.scss +0 -32
  128. package/src/components/DropdownButton/DropdownButton.stories.tsx +0 -24
  129. package/src/components/DropdownButton/index.tsx +0 -36
  130. package/src/components/DropdownButton/styles.module.scss +0 -9
  131. package/src/components/ExportTableData/ExportTableData.stories.tsx +0 -43
  132. package/src/components/ExportTableData/index.tsx +0 -37
  133. package/src/components/ExportTableData/styles.module.scss +0 -4
  134. package/src/components/Footer/Footer.stories.tsx +0 -15
  135. package/src/components/Footer/index.tsx +0 -45
  136. package/src/components/Footer/styles.module.scss +0 -38
  137. package/src/components/Footer2/Footer.stories.tsx +0 -184
  138. package/src/components/Footer2/index.tsx +0 -322
  139. package/src/components/Footer2/styles.module.scss +0 -292
  140. package/src/components/Header/Header.data.ts +0 -26
  141. package/src/components/Header/Header.stories.tsx +0 -236
  142. package/src/components/Header/Header.types.ts +0 -32
  143. package/src/components/Header/README.md +0 -38
  144. package/src/components/Header/index.tsx +0 -200
  145. package/src/components/Header/styles.module.scss +0 -216
  146. package/src/components/Input/Input.stories.tsx +0 -13
  147. package/src/components/Input/index.tsx +0 -31
  148. package/src/components/Input/styles.module.scss +0 -8
  149. package/src/components/InputCountryCode/index.tsx +0 -79
  150. package/src/components/InputCountryCode/inputCountryCode.stories.tsx +0 -55
  151. package/src/components/InputCountryCode/styles.module.scss +0 -3
  152. package/src/components/Label/Label.stories.tsx +0 -21
  153. package/src/components/Label/index.tsx +0 -19
  154. package/src/components/Label/styles.module.scss +0 -17
  155. package/src/components/Link/Link.stories.tsx +0 -30
  156. package/src/components/Link/index.tsx +0 -21
  157. package/src/components/Link/styles.module.scss +0 -24
  158. package/src/components/Menu/Menu.stories.tsx +0 -178
  159. package/src/components/Menu/helpers/codeMutation.tsx +0 -19
  160. package/src/components/Menu/index.tsx +0 -24
  161. package/src/components/Menu/styles.module.scss +0 -0
  162. package/src/components/MobileTable/MobileTable.stories.tsx +0 -27
  163. package/src/components/MobileTable/index.tsx +0 -102
  164. package/src/components/MobileTable/styles.module.scss +0 -75
  165. package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +0 -40
  166. package/src/components/ModalConfirmation/ModalStatusList.tsx +0 -5
  167. package/src/components/ModalConfirmation/index.tsx +0 -71
  168. package/src/components/ModalConfirmation/styles.module.scss +0 -62
  169. package/src/components/ModalWithTable/ModalWithTable.stories.tsx +0 -99
  170. package/src/components/ModalWithTable/index.tsx +0 -238
  171. package/src/components/ModalWithTable/styles.module.scss +0 -77
  172. package/src/components/Navigation/Navigation.stories.tsx +0 -21
  173. package/src/components/Navigation/index.tsx +0 -91
  174. package/src/components/Navigation/styles.module.scss +0 -91
  175. package/src/components/Notification/Notification.stories.tsx +0 -32
  176. package/src/components/Notification/index.tsx +0 -28
  177. package/src/components/Questions/Questions.stories.tsx +0 -37
  178. package/src/components/Questions/SingleQuestion/index.tsx +0 -337
  179. package/src/components/Questions/SingleQuestion/styles.module.scss +0 -142
  180. package/src/components/Questions/index.tsx +0 -124
  181. package/src/components/Questions/styles.modules.scss +0 -0
  182. package/src/components/Radio/Radio.stories.tsx +0 -43
  183. package/src/components/Radio/index.tsx +0 -26
  184. package/src/components/Radio/styles.module.scss +0 -24
  185. package/src/components/ResponseType/ResponseType.stories.tsx +0 -393
  186. package/src/components/ResponseType/index.tsx +0 -100
  187. package/src/components/ResponseType/styles.module.scss +0 -31
  188. package/src/components/ResponsiveTable/ResponsiveTable.stories.tsx +0 -386
  189. package/src/components/ResponsiveTable/index.tsx +0 -389
  190. package/src/components/ResponsiveTable/styles.module.scss +0 -153
  191. package/src/components/Select/Select.stories.tsx +0 -39
  192. package/src/components/Select/index.tsx +0 -27
  193. package/src/components/Select/styles.module.scss +0 -19
  194. package/src/components/Separator/Separator.stories.tsx +0 -22
  195. package/src/components/Separator/index.tsx +0 -27
  196. package/src/components/Separator/styles.module.scss +0 -25
  197. package/src/components/Sidebar/Sidebar.stories.tsx +0 -85
  198. package/src/components/Sidebar/index.tsx +0 -127
  199. package/src/components/Sidebar/styles.module.scss +0 -141
  200. package/src/components/Switch/Switch.stories.tsx +0 -14
  201. package/src/components/Switch/index.tsx +0 -18
  202. package/src/components/Switch/styles.module.scss +0 -7
  203. package/src/components/Table/Table.stories.tsx +0 -337
  204. package/src/components/Table/index.tsx +0 -313
  205. package/src/components/Table/styles.module.scss +0 -97
  206. package/src/components/Tag/Tag.stories.tsx +0 -32
  207. package/src/components/Tag/index.tsx +0 -295
  208. package/src/components/Tag/styles.module.scss +0 -104
  209. package/src/components/Upload/Upload.stories.tsx +0 -45
  210. package/src/components/Upload/index.tsx +0 -112
  211. package/src/components/Upload/styles.module.scss +0 -29
  212. package/src/components/UserInfo/UserInfo.stories.tsx +0 -38
  213. package/src/components/UserInfo/index.tsx +0 -77
  214. package/src/components/UserInfo/styles.module.scss +0 -35
  215. package/src/components/WebCam/WebCam.stories.tsx +0 -24
  216. package/src/components/WebCam/index.tsx +0 -73
  217. package/src/components/WebCam/styles.module.scss +0 -37
  218. package/src/components/index.tsx +0 -34
  219. package/src/constants/i18n.ts +0 -25
  220. package/src/constants/logoCompanyHelper.ts +0 -52
  221. package/src/constants/translationHelper.ts +0 -7
  222. package/src/index.ts +0 -3
  223. package/src/types/Global.d.ts +0 -4
  224. package/tsconfig.json +0 -29
  225. package/webpack.config.js +0 -51
  226. /package/dist/{types/components → components}/AnalyticsBar/interfaces/analyticsBar.d.ts +0 -0
  227. /package/dist/{types/components → components}/BellNotifications/index.d.ts +0 -0
  228. /package/dist/{types/components → components}/Category/CategoryContent/index.d.ts +0 -0
  229. /package/dist/{types/components → components}/Category/CategorySidebar/index.d.ts +0 -0
  230. /package/dist/{types/components → components}/CategoryReadOnly/evaluationOptions.d.ts +0 -0
  231. /package/dist/{types/components → components}/CategoryResponse/evaluationOptions.d.ts +0 -0
  232. /package/dist/{types/components → components}/ExportTableData/index.d.ts +0 -0
  233. /package/dist/{types/components → components}/Footer/index.d.ts +0 -0
  234. /package/dist/{types/components → components}/Label/index.d.ts +0 -0
  235. /package/dist/{types/components → components}/ModalConfirmation/ModalStatusList.d.ts +0 -0
  236. /package/dist/{types/components → components}/ModalConfirmation/index.d.ts +0 -0
  237. /package/dist/{types/components → components}/Navigation/index.d.ts +0 -0
  238. /package/dist/{types/components → components}/Questions/SingleQuestion/index.d.ts +0 -0
  239. /package/dist/{types/components → components}/Questions/index.d.ts +0 -0
  240. /package/dist/{types/components → components}/ResponseType/index.d.ts +0 -0
  241. /package/dist/{types/components → components}/Separator/index.d.ts +0 -0
  242. /package/dist/{types/components → components}/Sidebar/index.d.ts +0 -0
  243. /package/dist/{types/components → components}/UserInfo/index.d.ts +0 -0
  244. /package/dist/{types/components → components}/index.d.ts +0 -0
  245. /package/dist/{types/constants → constants}/i18n.d.ts +0 -0
  246. /package/dist/{types/constants → constants}/logoCompanyHelper.d.ts +0 -0
  247. /package/dist/{types/constants → constants}/translationHelper.d.ts +0 -0
  248. /package/dist/{types/index.d.ts → index.d.ts} +0 -0
  249. /package/{public → dist}/index.ts +0 -0
@@ -1,337 +0,0 @@
1
- import { Meta, StoryFn } from "@storybook/react-webpack5";
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
- };