@omniumretail/component-library 1.0.74 → 1.0.75

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 (176) hide show
  1. package/.storybook/main.js +16 -16
  2. package/.storybook/preview-head.html +20 -20
  3. package/.storybook/preview.js +27 -27
  4. package/NPMPUBLISH.md +29 -29
  5. package/README.md +54 -54
  6. package/bitbucket-pipelines.yml +94 -94
  7. package/dist/bundle.js +247 -291
  8. package/dist/types/components/AnalyticsBar/AnalyticsBar.stories.d.ts +5 -5
  9. package/dist/types/components/AnalyticsBar/helpers/codeMutation.d.ts +4 -4
  10. package/dist/types/components/AnalyticsBar/index.d.ts +2 -2
  11. package/dist/types/components/AnalyticsBar/interfaces/analyticsBar.d.ts +12 -12
  12. package/dist/types/components/Button/Button.stories.d.ts +6 -6
  13. package/dist/types/components/Button/index.d.ts +7 -7
  14. package/dist/types/components/Category/Category.stories.d.ts +4 -4
  15. package/dist/types/components/Category/CategoryContent/index.d.ts +7 -7
  16. package/dist/types/components/Category/CategorySidebar/index.d.ts +26 -26
  17. package/dist/types/components/Category/index.d.ts +7 -7
  18. package/dist/types/components/CategoryReadOnly/CategoryReadOnly.stories.d.ts +4 -4
  19. package/dist/types/components/CategoryReadOnly/evaluationOptions.d.ts +10 -10
  20. package/dist/types/components/CategoryReadOnly/index.d.ts +9 -9
  21. package/dist/types/components/CategoryResponse/CategoryResponse.stories.d.ts +4 -4
  22. package/dist/types/components/CategoryResponse/evaluationOptions.d.ts +10 -10
  23. package/dist/types/components/CategoryResponse/index.d.ts +9 -9
  24. package/dist/types/components/DatePicker/DatePicker.stories.d.ts +5 -5
  25. package/dist/types/components/DatePicker/index.d.ts +8 -8
  26. package/dist/types/components/DatePickerTag/DatePickerTag.stories.d.ts +5 -5
  27. package/dist/types/components/DatePickerTag/index.d.ts +6 -6
  28. package/dist/types/components/Footer/Footer.stories.d.ts +5 -5
  29. package/dist/types/components/Footer/index.d.ts +4 -4
  30. package/dist/types/components/Input/Input.stories.d.ts +5 -5
  31. package/dist/types/components/Input/index.d.ts +10 -10
  32. package/dist/types/components/InputCountryCode/index.d.ts +10 -10
  33. package/dist/types/components/InputCountryCode/inputCountryCode.stories.d.ts +5 -5
  34. package/dist/types/components/Label/Label.stories.d.ts +6 -6
  35. package/dist/types/components/Label/index.d.ts +7 -7
  36. package/dist/types/components/Link/Link.stories.d.ts +7 -7
  37. package/dist/types/components/Link/index.d.ts +7 -7
  38. package/dist/types/components/Menu/Menu.stories.d.ts +5 -5
  39. package/dist/types/components/Menu/helpers/codeMutation.d.ts +4 -4
  40. package/dist/types/components/Menu/index.d.ts +3 -2
  41. package/dist/types/components/ModalConfirmation/ModalConfirmation.stories.d.ts +5 -5
  42. package/dist/types/components/ModalConfirmation/ModalStatusList.d.ts +5 -5
  43. package/dist/types/components/ModalConfirmation/index.d.ts +9 -9
  44. package/dist/types/components/ModalWithTable/ModalWithTable.stories.d.ts +5 -5
  45. package/dist/types/components/ModalWithTable/index.d.ts +13 -13
  46. package/dist/types/components/Navigation/Navigation.stories.d.ts +5 -5
  47. package/dist/types/components/Navigation/index.d.ts +10 -10
  48. package/dist/types/components/Notification/Notification.stories.d.ts +5 -5
  49. package/dist/types/components/Notification/index.d.ts +9 -9
  50. package/dist/types/components/Questions/Questions.stories.d.ts +4 -4
  51. package/dist/types/components/Questions/SingleQuestion/index.d.ts +1 -1
  52. package/dist/types/components/Questions/index.d.ts +5 -5
  53. package/dist/types/components/Radio/Radio.stories.d.ts +5 -5
  54. package/dist/types/components/Radio/index.d.ts +10 -10
  55. package/dist/types/components/Select/Select.stories.d.ts +6 -6
  56. package/dist/types/components/Select/index.d.ts +5 -5
  57. package/dist/types/components/Separator/Separator.stories.d.ts +6 -6
  58. package/dist/types/components/Separator/index.d.ts +11 -11
  59. package/dist/types/components/Sidebar/Sidebar.stories.d.ts +6 -6
  60. package/dist/types/components/Sidebar/index.d.ts +15 -15
  61. package/dist/types/components/Switch/Switch.stories.d.ts +5 -5
  62. package/dist/types/components/Switch/index.d.ts +2 -2
  63. package/dist/types/components/Table/Table.stories.d.ts +9 -9
  64. package/dist/types/components/Table/index.d.ts +37 -37
  65. package/dist/types/components/Tag/Tag.stories.d.ts +5 -5
  66. package/dist/types/components/Tag/index.d.ts +8 -8
  67. package/dist/types/components/Upload/Upload.stories.d.ts +4 -4
  68. package/dist/types/components/Upload/index.d.ts +8 -8
  69. package/dist/types/components/UserInfo/UserInfo.stories.d.ts +4 -4
  70. package/dist/types/components/UserInfo/index.d.ts +8 -8
  71. package/dist/types/components/index.d.ts +25 -25
  72. package/dist/types/constants/i18n.d.ts +1 -1
  73. package/dist/types/constants/translationHelper.d.ts +2 -2
  74. package/dist/types/index.d.ts +2 -2
  75. package/package.json +198 -198
  76. package/src/assets/scss/_global.scss +89 -89
  77. package/src/assets/scss/index.scss +2 -2
  78. package/src/components/AnalyticsBar/AnalyticsBar.stories.tsx +236 -236
  79. package/src/components/AnalyticsBar/helpers/codeMutation.tsx +19 -19
  80. package/src/components/AnalyticsBar/index.tsx +76 -76
  81. package/src/components/AnalyticsBar/interfaces/analyticsBar.tsx +13 -13
  82. package/src/components/AnalyticsBar/styles.module.scss +108 -108
  83. package/src/components/Button/Button.stories.tsx +26 -26
  84. package/src/components/Button/index.tsx +24 -24
  85. package/src/components/Button/styles.module.scss +65 -65
  86. package/src/components/Category/Category.stories.tsx +88 -88
  87. package/src/components/Category/CategoryContent/index.tsx +188 -188
  88. package/src/components/Category/CategoryContent/styles.module.scss +51 -51
  89. package/src/components/Category/CategorySidebar/index.tsx +268 -268
  90. package/src/components/Category/CategorySidebar/styles.module.scss +28 -28
  91. package/src/components/Category/index.tsx +76 -76
  92. package/src/components/Category/styles.module.scss +13 -13
  93. package/src/components/CategoryReadOnly/CategoryReadOnly.stories.tsx +270 -270
  94. package/src/components/CategoryReadOnly/evaluationOptions.tsx +81 -81
  95. package/src/components/CategoryReadOnly/index.tsx +254 -254
  96. package/src/components/CategoryReadOnly/styles.module.scss +184 -184
  97. package/src/components/CategoryResponse/CategoryResponse.stories.tsx +251 -251
  98. package/src/components/CategoryResponse/evaluationOptions.tsx +81 -81
  99. package/src/components/CategoryResponse/index.tsx +277 -277
  100. package/src/components/CategoryResponse/styles.module.scss +180 -180
  101. package/src/components/DatePicker/DatePicker.stories.tsx +16 -16
  102. package/src/components/DatePicker/index.tsx +38 -38
  103. package/src/components/DatePicker/styles.module.scss +3 -3
  104. package/src/components/DatePickerTag/DatePickerTag.stories.tsx +19 -19
  105. package/src/components/DatePickerTag/index.tsx +89 -89
  106. package/src/components/DatePickerTag/styles.module.scss +31 -31
  107. package/src/components/Footer/Footer.stories.tsx +14 -14
  108. package/src/components/Footer/index.tsx +38 -38
  109. package/src/components/Footer/styles.module.scss +38 -38
  110. package/src/components/Input/Input.stories.tsx +13 -13
  111. package/src/components/Input/index.tsx +31 -31
  112. package/src/components/Input/styles.module.scss +8 -8
  113. package/src/components/InputCountryCode/index.tsx +75 -75
  114. package/src/components/InputCountryCode/inputCountryCode.stories.tsx +55 -55
  115. package/src/components/InputCountryCode/styles.module.scss +3 -3
  116. package/src/components/Label/Label.stories.tsx +21 -21
  117. package/src/components/Label/index.tsx +19 -19
  118. package/src/components/Label/styles.module.scss +16 -16
  119. package/src/components/Link/Link.stories.tsx +30 -30
  120. package/src/components/Link/index.tsx +21 -21
  121. package/src/components/Link/styles.module.scss +24 -24
  122. package/src/components/Menu/Menu.stories.tsx +178 -178
  123. package/src/components/Menu/helpers/codeMutation.tsx +19 -19
  124. package/src/components/Menu/index.tsx +23 -23
  125. package/src/components/ModalConfirmation/ModalConfirmation.stories.tsx +40 -40
  126. package/src/components/ModalConfirmation/ModalStatusList.tsx +5 -5
  127. package/src/components/ModalConfirmation/index.tsx +70 -70
  128. package/src/components/ModalConfirmation/styles.module.scss +62 -62
  129. package/src/components/ModalWithTable/ModalWithTable.stories.tsx +96 -96
  130. package/src/components/ModalWithTable/index.tsx +232 -232
  131. package/src/components/ModalWithTable/styles.module.scss +77 -77
  132. package/src/components/Navigation/Navigation.stories.tsx +17 -17
  133. package/src/components/Navigation/index.tsx +33 -33
  134. package/src/components/Navigation/styles.module.scss +59 -59
  135. package/src/components/Notification/Notification.stories.tsx +29 -29
  136. package/src/components/Notification/index.tsx +21 -21
  137. package/src/components/Questions/Questions.stories.tsx +37 -37
  138. package/src/components/Questions/SingleQuestion/index.tsx +84 -84
  139. package/src/components/Questions/SingleQuestion/styles.module.scss +81 -81
  140. package/src/components/Questions/index.tsx +78 -78
  141. package/src/components/Radio/Radio.stories.tsx +43 -43
  142. package/src/components/Radio/index.tsx +26 -26
  143. package/src/components/Radio/styles.module.scss +23 -23
  144. package/src/components/Select/Select.stories.tsx +39 -39
  145. package/src/components/Select/index.tsx +27 -27
  146. package/src/components/Select/styles.module.scss +13 -13
  147. package/src/components/Separator/Separator.stories.tsx +22 -22
  148. package/src/components/Separator/index.tsx +27 -27
  149. package/src/components/Separator/styles.module.scss +25 -25
  150. package/src/components/Sidebar/Sidebar.stories.tsx +85 -85
  151. package/src/components/Sidebar/index.tsx +103 -103
  152. package/src/components/Sidebar/styles.module.scss +85 -85
  153. package/src/components/Switch/Switch.stories.tsx +14 -14
  154. package/src/components/Switch/index.tsx +8 -8
  155. package/src/components/Switch/styles.module.scss +7 -7
  156. package/src/components/Table/Table.stories.tsx +222 -222
  157. package/src/components/Table/index.tsx +279 -275
  158. package/src/components/Table/styles.module.scss +75 -75
  159. package/src/components/Tag/Tag.stories.tsx +22 -22
  160. package/src/components/Tag/index.tsx +189 -189
  161. package/src/components/Tag/styles.module.scss +60 -60
  162. package/src/components/Upload/Upload.stories.tsx +45 -45
  163. package/src/components/Upload/index.tsx +91 -91
  164. package/src/components/UserInfo/UserInfo.stories.tsx +37 -37
  165. package/src/components/UserInfo/index.tsx +62 -62
  166. package/src/components/UserInfo/styles.module.scss +29 -29
  167. package/src/components/index.tsx +25 -25
  168. package/src/constants/i18n.ts +25 -25
  169. package/src/constants/translationHelper.ts +7 -7
  170. package/src/index.ts +2 -2
  171. package/src/locales/en.json +86 -86
  172. package/src/locales/es.json +86 -86
  173. package/src/locales/pt.json +86 -86
  174. package/src/types/Global.d.ts +4 -4
  175. package/tsconfig.json +29 -29
  176. package/webpack.config.js +51 -51
@@ -1,232 +1,232 @@
1
- import { Button } from '../Button';
2
- import { Modal } from 'antd';
3
- import { useEffect, useRef, useState } from 'react';
4
- import { CloseOutlined } from '@ant-design/icons';
5
- import styles from './styles.module.scss';
6
- import { TagField } from '../Tag';
7
- import { Table, TableCustomProps } from '../Table';
8
- import classnames from 'classnames';
9
-
10
- export interface ModalWithTableProps {
11
- closeText: string;
12
- buttonText: string;
13
- isOpen: boolean;
14
- tableData: TableCustomProps,
15
- modalData?: any;
16
- isLoading?: boolean;
17
- confirmLoading?: boolean;
18
- initialRowSelectedInfo?: any;
19
- // Tags List for advanced search
20
- advancedTagsList?: string[];
21
- }
22
- function objectsAreEqual(obj1: any, obj2: any) {
23
- const keys1 = Object.keys(obj1);
24
- const keys2 = Object.keys(obj2);
25
-
26
- if (keys1.length !== keys2.length) {
27
- return false;
28
- }
29
-
30
- for (const key of keys1) {
31
- if (!keys2.includes(key) || obj1[key] !== obj2[key]) {
32
- return false;
33
- }
34
- }
35
-
36
- return true;
37
- }
38
-
39
- function arrayContainsObject(array: any, newObj: any) {
40
- return array.some((existingObj: any) => objectsAreEqual(existingObj, newObj));
41
- }
42
-
43
- export const ModalWithTable = (props: ModalWithTableProps) => {
44
- const {
45
- closeText,
46
- buttonText,
47
- isOpen = false,
48
- tableData,
49
- modalData,
50
- isLoading,
51
- initialRowSelectedInfo,
52
- advancedTagsList
53
- } = props;
54
-
55
- const prevIsOpenRef = useRef<boolean>();
56
- useEffect(() => {
57
- prevIsOpenRef.current = isOpen;
58
- }, [isOpen]);
59
- const prevIsOpen = prevIsOpenRef.current;
60
-
61
- // Add a new state to store the initial values
62
- const [initialValues, setInitialValues] = useState<any>({
63
- pageInfo: {},
64
- rowSelectionInfo: [],
65
- tagsInfo: [],
66
- advancedTagsInfo: [],
67
- selectedData: [],
68
- });
69
- const pageBase = { currentPage: 1 };
70
- const [open, setOpen] = useState((isOpen));
71
- const [confirmLoading, setConfirmLoading] = useState(false);
72
- const [pageInfo, setPageInfo] = useState<any>(pageBase);
73
- const [rowSelectionInfo, setRowSelectionInfo] = useState<any>(undefined);
74
- const [tagsInfo, setTagsInfo] = useState<any>([]);
75
- const [advancedTagsInfo, setAdvancedTagsInfo] = useState<any>([]);
76
- const [selectedData, setSelectedData] = useState<any>([]);
77
-
78
- useEffect(() => {
79
- setOpen(isOpen);
80
-
81
- if (isOpen && !prevIsOpen) {
82
- setInitialValues({
83
- pageInfo: pageInfo,
84
- rowSelectionInfo: rowSelectionInfo,
85
- tagsInfo: tagsInfo,
86
- advancedTagsInfo: advancedTagsInfo,
87
- selectedData: selectedData,
88
- });
89
- }
90
- }, [isOpen])
91
-
92
- useEffect(() => {
93
- initialRowSelectedInfo && setRowSelectionInfo(initialRowSelectedInfo);
94
- }, [initialRowSelectedInfo])
95
-
96
- const hideModal = () => {
97
- setOpen(false);
98
- setPageInfo(initialValues.pageInfo);
99
- setRowSelectionInfo(initialValues.rowSelectionInfo);
100
- setTagsInfo(initialValues.tagsInfo);
101
- setAdvancedTagsInfo(initialValues.advancedTagsInfo)
102
- setSelectedData(initialValues.selectedData);
103
- };
104
-
105
- const saveChanges = () => {
106
- setOpen(false);
107
- if (tableData?.rowSelection?.type === 'radio') {
108
- setSelectedData([selectedData[selectedData.length - 1]]);
109
- }
110
- };
111
-
112
- useEffect(() => {
113
- if (!open) {
114
- setPageInfo(pageBase);
115
- }
116
-
117
- const modalDataObj = {
118
- pageInfo: pageInfo,
119
- rowSelectionInfo: rowSelectionInfo,
120
- tagsInfo: tagsInfo,
121
- advancedTagsInfo: advancedTagsInfo,
122
- open: open,
123
- selectedData: selectedData,
124
- };
125
-
126
- modalData(modalDataObj);
127
- }, [tagsInfo, advancedTagsInfo, open, rowSelectionInfo, selectedData]);
128
-
129
- useEffect(() => {
130
- const selectedRowKeys = rowSelectionInfo || tableData.rowSelection.selectedRowKeys;
131
-
132
- if (tableData?.rowSelection?.type === 'radio') {
133
- setSelectedData((prevData: any) => {
134
- const newData = tableData?.dataSource?.filter((element) => {
135
- return selectedRowKeys.includes(element[tableData.rowKeyValue as any]);
136
- }) || [];
137
-
138
- if (newData.length < 1) {
139
- return selectedData;
140
- }
141
- if (arrayContainsObject(selectedData, newData[0])) {
142
- return selectedData;
143
- }
144
- const combinedData = [...selectedData, ...newData];
145
- return combinedData;
146
- });
147
-
148
- return;
149
- }
150
-
151
- setSelectedData((prevData: any) => {
152
- const newData = tableData?.dataSource?.filter((element) => {
153
- return selectedRowKeys.includes(element[tableData.rowKeyValue as any]);
154
- }) || [];
155
-
156
- const oldData = prevData.filter((dataItem: any) => {
157
- return !tableData?.dataSource?.some(
158
- (element) => element[tableData.rowKeyValue as any] === dataItem[tableData.rowKeyValue as any]
159
- );
160
- });
161
-
162
- const combinedData = [...oldData, ...newData].filter((dataItem, index, self) => {
163
- return (
164
- index ===
165
- self.findIndex(
166
- (item) => item[tableData.rowKeyValue as any] === dataItem[tableData.rowKeyValue as any]
167
- )
168
- );
169
- });
170
-
171
- setInitialValues({ ...initialValues, selectedData: combinedData });
172
- return combinedData;
173
- });
174
- }, [rowSelectionInfo])
175
-
176
- useEffect(() => {
177
- if (tagsInfo.length > 0) {
178
- setConfirmLoading(true);
179
- }
180
- }, [tagsInfo]);
181
-
182
- useEffect(() => {
183
- if (advancedTagsInfo.length > 0) {
184
- setConfirmLoading(true);
185
- }
186
- }, [advancedTagsInfo]);
187
-
188
- useEffect(() => {
189
- setConfirmLoading(isLoading!);
190
- }, [isLoading]);
191
-
192
- const modalClasses = classnames({
193
- [styles.disabled]: confirmLoading,
194
- }, styles.modal);
195
-
196
- return (
197
- <>
198
- <Modal
199
- destroyOnClose={true}
200
- closeIcon={
201
- <div className={styles.closeButton}>
202
- <p>{closeText}</p><CloseOutlined />
203
- </div>
204
- }
205
- open={open}
206
- onOk={hideModal}
207
- onCancel={hideModal}
208
- maskClosable={false}
209
- centered
210
- width={'100%'}
211
- footer={[
212
- <Button key="submit" onClick={saveChanges}>
213
- {buttonText}
214
- </Button>
215
- ]}
216
- className={modalClasses}
217
- >
218
- <div className={styles.tagsWrapper}>
219
- <TagField tagsInfo={setTagsInfo} advancedTagsInfo={setAdvancedTagsInfo} advancedTags={advancedTagsList} />
220
- </div>
221
-
222
- <div className={styles.tableWrapper}>
223
- {tableData &&
224
- <Table {...tableData} paginationInfo={setPageInfo} rowSelectionInfo={setRowSelectionInfo} headingTranslationsKey={'tableHeadings'} />
225
- }
226
- </div>
227
-
228
- </Modal>
229
- </>
230
- )
231
- }
232
-
1
+ import { Button } from '../Button';
2
+ import { Modal } from 'antd';
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { CloseOutlined } from '@ant-design/icons';
5
+ import styles from './styles.module.scss';
6
+ import { TagField } from '../Tag';
7
+ import { Table, TableCustomProps } from '../Table';
8
+ import classnames from 'classnames';
9
+
10
+ export interface ModalWithTableProps {
11
+ closeText: string;
12
+ buttonText: string;
13
+ isOpen: boolean;
14
+ tableData: TableCustomProps,
15
+ modalData?: any;
16
+ isLoading?: boolean;
17
+ confirmLoading?: boolean;
18
+ initialRowSelectedInfo?: any;
19
+ // Tags List for advanced search
20
+ advancedTagsList?: string[];
21
+ }
22
+ function objectsAreEqual(obj1: any, obj2: any) {
23
+ const keys1 = Object.keys(obj1);
24
+ const keys2 = Object.keys(obj2);
25
+
26
+ if (keys1.length !== keys2.length) {
27
+ return false;
28
+ }
29
+
30
+ for (const key of keys1) {
31
+ if (!keys2.includes(key) || obj1[key] !== obj2[key]) {
32
+ return false;
33
+ }
34
+ }
35
+
36
+ return true;
37
+ }
38
+
39
+ function arrayContainsObject(array: any, newObj: any) {
40
+ return array.some((existingObj: any) => objectsAreEqual(existingObj, newObj));
41
+ }
42
+
43
+ export const ModalWithTable = (props: ModalWithTableProps) => {
44
+ const {
45
+ closeText,
46
+ buttonText,
47
+ isOpen = false,
48
+ tableData,
49
+ modalData,
50
+ isLoading,
51
+ initialRowSelectedInfo,
52
+ advancedTagsList
53
+ } = props;
54
+
55
+ const prevIsOpenRef = useRef<boolean>();
56
+ useEffect(() => {
57
+ prevIsOpenRef.current = isOpen;
58
+ }, [isOpen]);
59
+ const prevIsOpen = prevIsOpenRef.current;
60
+
61
+ // Add a new state to store the initial values
62
+ const [initialValues, setInitialValues] = useState<any>({
63
+ pageInfo: {},
64
+ rowSelectionInfo: [],
65
+ tagsInfo: [],
66
+ advancedTagsInfo: [],
67
+ selectedData: [],
68
+ });
69
+ const pageBase = { currentPage: 1 };
70
+ const [open, setOpen] = useState((isOpen));
71
+ const [confirmLoading, setConfirmLoading] = useState(false);
72
+ const [pageInfo, setPageInfo] = useState<any>(pageBase);
73
+ const [rowSelectionInfo, setRowSelectionInfo] = useState<any>(undefined);
74
+ const [tagsInfo, setTagsInfo] = useState<any>([]);
75
+ const [advancedTagsInfo, setAdvancedTagsInfo] = useState<any>([]);
76
+ const [selectedData, setSelectedData] = useState<any>([]);
77
+
78
+ useEffect(() => {
79
+ setOpen(isOpen);
80
+
81
+ if (isOpen && !prevIsOpen) {
82
+ setInitialValues({
83
+ pageInfo: pageInfo,
84
+ rowSelectionInfo: rowSelectionInfo,
85
+ tagsInfo: tagsInfo,
86
+ advancedTagsInfo: advancedTagsInfo,
87
+ selectedData: selectedData,
88
+ });
89
+ }
90
+ }, [isOpen])
91
+
92
+ useEffect(() => {
93
+ initialRowSelectedInfo && setRowSelectionInfo(initialRowSelectedInfo);
94
+ }, [initialRowSelectedInfo])
95
+
96
+ const hideModal = () => {
97
+ setOpen(false);
98
+ setPageInfo(initialValues.pageInfo);
99
+ setRowSelectionInfo(initialValues.rowSelectionInfo);
100
+ setTagsInfo(initialValues.tagsInfo);
101
+ setAdvancedTagsInfo(initialValues.advancedTagsInfo)
102
+ setSelectedData(initialValues.selectedData);
103
+ };
104
+
105
+ const saveChanges = () => {
106
+ setOpen(false);
107
+ if (tableData?.rowSelection?.type === 'radio') {
108
+ setSelectedData([selectedData[selectedData.length - 1]]);
109
+ }
110
+ };
111
+
112
+ useEffect(() => {
113
+ if (!open) {
114
+ setPageInfo(pageBase);
115
+ }
116
+
117
+ const modalDataObj = {
118
+ pageInfo: pageInfo,
119
+ rowSelectionInfo: rowSelectionInfo,
120
+ tagsInfo: tagsInfo,
121
+ advancedTagsInfo: advancedTagsInfo,
122
+ open: open,
123
+ selectedData: selectedData,
124
+ };
125
+
126
+ modalData(modalDataObj);
127
+ }, [tagsInfo, advancedTagsInfo, open, rowSelectionInfo, selectedData]);
128
+
129
+ useEffect(() => {
130
+ const selectedRowKeys = rowSelectionInfo || tableData.rowSelection.selectedRowKeys;
131
+
132
+ if (tableData?.rowSelection?.type === 'radio') {
133
+ setSelectedData((prevData: any) => {
134
+ const newData = tableData?.dataSource?.filter((element) => {
135
+ return selectedRowKeys.includes(element[tableData.rowKeyValue as any]);
136
+ }) || [];
137
+
138
+ if (newData.length < 1) {
139
+ return selectedData;
140
+ }
141
+ if (arrayContainsObject(selectedData, newData[0])) {
142
+ return selectedData;
143
+ }
144
+ const combinedData = [...selectedData, ...newData];
145
+ return combinedData;
146
+ });
147
+
148
+ return;
149
+ }
150
+
151
+ setSelectedData((prevData: any) => {
152
+ const newData = tableData?.dataSource?.filter((element) => {
153
+ return selectedRowKeys.includes(element[tableData.rowKeyValue as any]);
154
+ }) || [];
155
+
156
+ const oldData = prevData.filter((dataItem: any) => {
157
+ return !tableData?.dataSource?.some(
158
+ (element) => element[tableData.rowKeyValue as any] === dataItem[tableData.rowKeyValue as any]
159
+ );
160
+ });
161
+
162
+ const combinedData = [...oldData, ...newData].filter((dataItem, index, self) => {
163
+ return (
164
+ index ===
165
+ self.findIndex(
166
+ (item) => item[tableData.rowKeyValue as any] === dataItem[tableData.rowKeyValue as any]
167
+ )
168
+ );
169
+ });
170
+
171
+ setInitialValues({ ...initialValues, selectedData: combinedData });
172
+ return combinedData;
173
+ });
174
+ }, [rowSelectionInfo])
175
+
176
+ useEffect(() => {
177
+ if (tagsInfo.length > 0) {
178
+ setConfirmLoading(true);
179
+ }
180
+ }, [tagsInfo]);
181
+
182
+ useEffect(() => {
183
+ if (advancedTagsInfo.length > 0) {
184
+ setConfirmLoading(true);
185
+ }
186
+ }, [advancedTagsInfo]);
187
+
188
+ useEffect(() => {
189
+ setConfirmLoading(isLoading!);
190
+ }, [isLoading]);
191
+
192
+ const modalClasses = classnames({
193
+ [styles.disabled]: confirmLoading,
194
+ }, styles.modal);
195
+
196
+ return (
197
+ <>
198
+ <Modal
199
+ destroyOnClose={true}
200
+ closeIcon={
201
+ <div className={styles.closeButton}>
202
+ <p>{closeText}</p><CloseOutlined />
203
+ </div>
204
+ }
205
+ open={open}
206
+ onOk={hideModal}
207
+ onCancel={hideModal}
208
+ maskClosable={false}
209
+ centered
210
+ width={'100%'}
211
+ footer={[
212
+ <Button key="submit" onClick={saveChanges}>
213
+ {buttonText}
214
+ </Button>
215
+ ]}
216
+ className={modalClasses}
217
+ >
218
+ <div className={styles.tagsWrapper}>
219
+ <TagField tagsInfo={setTagsInfo} advancedTagsInfo={setAdvancedTagsInfo} advancedTags={advancedTagsList} />
220
+ </div>
221
+
222
+ <div className={styles.tableWrapper}>
223
+ {tableData &&
224
+ <Table {...tableData} paginationInfo={setPageInfo} rowSelectionInfo={setRowSelectionInfo} headingTranslationsKey={'tableHeadings'} />
225
+ }
226
+ </div>
227
+
228
+ </Modal>
229
+ </>
230
+ )
231
+ }
232
+
@@ -1,77 +1,77 @@
1
- .modal {
2
- &.disabled {
3
- pointer-events: none;
4
- position: relative;
5
-
6
- &:after {
7
- content: '';
8
- position: absolute;
9
- top: 0;
10
- left: 0;
11
- width: 100%;
12
- height: 100%;
13
- background-color: rgba(var(--color-white-rgb), .6);
14
- z-index: 9999999;
15
- }
16
- }
17
-
18
- :global {
19
- .ant-modal-close {
20
- width: auto;
21
- color: var(--button-default-background);
22
-
23
- &:hover {
24
- background-color: transparent;
25
- color: var(--button-default-background-hover-color);
26
- }
27
- }
28
-
29
- .ant-modal-content {
30
- padding: 36px 24px;
31
- display: flex;
32
- justify-content: center;
33
- flex-direction: column;
34
- text-align: center;
35
-
36
- @media(min-width: 742px) {
37
- padding: 32px;
38
- }
39
- }
40
-
41
- .ant-modal-body {
42
- width: 100%;
43
- padding-top: 24px;
44
- }
45
-
46
- .ant-modal-footer {
47
- button {
48
- margin-left: auto;
49
- }
50
- }
51
- }
52
-
53
- .closeButton {
54
- display: flex;
55
- align-items: center;
56
- justify-content: center;
57
- flex-direction: row;
58
- gap: 8px;
59
- color: inherit;
60
- font-size: var(--font-size-body-3);
61
- line-height: 100%;
62
- font-weight: var(--font-weight-light);
63
- text-transform: capitalize;
64
- letter-spacing: .6px;
65
- justify-self: flex-end;
66
-
67
- > p {
68
- padding: 0;
69
- margin: 0;
70
- }
71
- }
72
-
73
- .tagsWrapper {
74
- max-width: 640px;
75
- text-align: left;
76
- }
77
- }
1
+ .modal {
2
+ &.disabled {
3
+ pointer-events: none;
4
+ position: relative;
5
+
6
+ &:after {
7
+ content: '';
8
+ position: absolute;
9
+ top: 0;
10
+ left: 0;
11
+ width: 100%;
12
+ height: 100%;
13
+ background-color: rgba(var(--color-white-rgb), .6);
14
+ z-index: 9999999;
15
+ }
16
+ }
17
+
18
+ :global {
19
+ .ant-modal-close {
20
+ width: auto;
21
+ color: var(--button-default-background);
22
+
23
+ &:hover {
24
+ background-color: transparent;
25
+ color: var(--button-default-background-hover-color);
26
+ }
27
+ }
28
+
29
+ .ant-modal-content {
30
+ padding: 36px 24px;
31
+ display: flex;
32
+ justify-content: center;
33
+ flex-direction: column;
34
+ text-align: center;
35
+
36
+ @media(min-width: 742px) {
37
+ padding: 32px;
38
+ }
39
+ }
40
+
41
+ .ant-modal-body {
42
+ width: 100%;
43
+ padding-top: 24px;
44
+ }
45
+
46
+ .ant-modal-footer {
47
+ button {
48
+ margin-left: auto;
49
+ }
50
+ }
51
+ }
52
+
53
+ .closeButton {
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ flex-direction: row;
58
+ gap: 8px;
59
+ color: inherit;
60
+ font-size: var(--font-size-body-3);
61
+ line-height: 100%;
62
+ font-weight: var(--font-weight-light);
63
+ text-transform: capitalize;
64
+ letter-spacing: .6px;
65
+ justify-self: flex-end;
66
+
67
+ > p {
68
+ padding: 0;
69
+ margin: 0;
70
+ }
71
+ }
72
+
73
+ .tagsWrapper {
74
+ max-width: 640px;
75
+ text-align: left;
76
+ }
77
+ }
@@ -1,17 +1,17 @@
1
- import { Meta, Story } from "@storybook/react";
2
- import { Navigation, NavigationProps } from '.';
3
-
4
- export default {
5
- title: 'Navigation',
6
- component: Navigation,
7
- } as Meta;
8
-
9
- const Template: Story<NavigationProps> = (args) => <Navigation {...args}></Navigation>;
10
-
11
- export const Primary = Template.bind({});
12
- Primary.args = {
13
- backLink: true,
14
- title: 'Gestão de Aplicações',
15
- homeLink: true,
16
- loginLink: true,
17
- };
1
+ import { Meta, Story } from "@storybook/react";
2
+ import { Navigation, NavigationProps } from '.';
3
+
4
+ export default {
5
+ title: 'Navigation',
6
+ component: Navigation,
7
+ } as Meta;
8
+
9
+ const Template: Story<NavigationProps> = (args) => <Navigation {...args}></Navigation>;
10
+
11
+ export const Primary = Template.bind({});
12
+ Primary.args = {
13
+ backLink: true,
14
+ title: 'Gestão de Aplicações',
15
+ homeLink: true,
16
+ loginLink: true,
17
+ };