@xaypay/tui 0.0.118 → 0.0.120

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 (181) hide show
  1. package/dist/index.es.js +4144 -4294
  2. package/dist/index.js +4144 -4295
  3. package/package.json +1 -1
  4. package/storybook-static/favicon.ico +0 -0
  5. package/tui.config.js +8 -1
  6. package/.eslintrc.js +0 -30
  7. package/.husky/pre-commit +0 -4
  8. package/.prettierrc +0 -10
  9. package/.storybook/main.js +0 -48
  10. package/.storybook/preview.js +0 -9
  11. package/rollup.config.js +0 -37
  12. package/src/assets/attach.svg +0 -4
  13. package/src/assets/delete.svg +0 -4
  14. package/src/assets/down-arrow.svg +0 -4
  15. package/src/assets/figma-image.png +0 -0
  16. package/src/assets/heart-filled.svg +0 -17
  17. package/src/assets/heart-outline.svg +0 -14
  18. package/src/assets/like-filled.svg +0 -21
  19. package/src/assets/like-outline.svg +0 -21
  20. package/src/assets/minus.svg +0 -4
  21. package/src/assets/pdf.svg +0 -3
  22. package/src/assets/plus.svg +0 -4
  23. package/src/assets/range-arrow-default.svg +0 -19
  24. package/src/assets/range-arrow-error.svg +0 -19
  25. package/src/assets/range-arrow-success.svg +0 -19
  26. package/src/assets/star-filled.svg +0 -21
  27. package/src/assets/star-outline.svg +0 -5
  28. package/src/assets/table-settings-icon.svg +0 -3
  29. package/src/assets/up-arrow.svg +0 -4
  30. package/src/assets_old/icons/Read Me.txt +0 -7
  31. package/src/assets_old/icons/demo-files/demo.css +0 -152
  32. package/src/assets_old/icons/demo-files/demo.js +0 -28
  33. package/src/assets_old/icons/demo.html +0 -192
  34. package/src/assets_old/icons/fonts/icomoon.eot +0 -0
  35. package/src/assets_old/icons/fonts/icomoon.svg +0 -21
  36. package/src/assets_old/icons/fonts/icomoon.ttf +0 -0
  37. package/src/assets_old/icons/fonts/icomoon.woff +0 -0
  38. package/src/assets_old/icons/selection.json +0 -1
  39. package/src/assets_old/icons/style.css +0 -58
  40. package/src/components/autocomplate/autocomplate.module.css +0 -95
  41. package/src/components/autocomplate/autocomplate.stories.js +0 -35
  42. package/src/components/autocomplate/index.js +0 -164
  43. package/src/components/button/button.stories.js +0 -13
  44. package/src/components/button/index.js +0 -187
  45. package/src/components/captcha/captcha.module.css +0 -74
  46. package/src/components/captcha/captcha.stories.js +0 -21
  47. package/src/components/captcha/index.js +0 -158
  48. package/src/components/checkbox/checkbox.module.css +0 -0
  49. package/src/components/checkbox/checkbox.stories.js +0 -76
  50. package/src/components/checkbox/index.js +0 -120
  51. package/src/components/file/file.module.css +0 -114
  52. package/src/components/file/file.stories.js +0 -20
  53. package/src/components/file/index.js +0 -138
  54. package/src/components/icon/Active.js +0 -20
  55. package/src/components/icon/Arrow.js +0 -19
  56. package/src/components/icon/Cancel.js +0 -19
  57. package/src/components/icon/CaptchaArrowDown.js +0 -19
  58. package/src/components/icon/CaptchaArrowUp.js +0 -19
  59. package/src/components/icon/CheckboxChecked.js +0 -21
  60. package/src/components/icon/CheckboxUnchecked.js +0 -21
  61. package/src/components/icon/Close.js +0 -19
  62. package/src/components/icon/CloseIcon.js +0 -19
  63. package/src/components/icon/CloseSlide.js +0 -19
  64. package/src/components/icon/DeActive.js +0 -20
  65. package/src/components/icon/DeleteComponent.js +0 -20
  66. package/src/components/icon/Done.js +0 -19
  67. package/src/components/icon/Dots.js +0 -19
  68. package/src/components/icon/DownArrow.js +0 -20
  69. package/src/components/icon/HeartFilled.js +0 -25
  70. package/src/components/icon/HeartOutline.js +0 -25
  71. package/src/components/icon/Heic.js +0 -21
  72. package/src/components/icon/Icon.js +0 -11
  73. package/src/components/icon/ListItemDelete.js +0 -19
  74. package/src/components/icon/ListItemJpeg.js +0 -21
  75. package/src/components/icon/ListItemJpg.js +0 -21
  76. package/src/components/icon/ListItemPdf.js +0 -21
  77. package/src/components/icon/ListItemPng.js +0 -21
  78. package/src/components/icon/Next.js +0 -20
  79. package/src/components/icon/Nextarrow.js +0 -19
  80. package/src/components/icon/PDF.js +0 -19
  81. package/src/components/icon/Prev.js +0 -20
  82. package/src/components/icon/RangeArrowDefault.js +0 -43
  83. package/src/components/icon/RangeArrowError.js +0 -43
  84. package/src/components/icon/RangeArrowSuccess.js +0 -43
  85. package/src/components/icon/Reject.js +0 -19
  86. package/src/components/icon/RemoveFile.js +0 -20
  87. package/src/components/icon/Required.js +0 -19
  88. package/src/components/icon/ToasterClose.js +0 -19
  89. package/src/components/icon/ToasterError.js +0 -19
  90. package/src/components/icon/ToasterInfo.js +0 -19
  91. package/src/components/icon/ToasterSuccess.js +0 -19
  92. package/src/components/icon/ToasterWarning.js +0 -19
  93. package/src/components/icon/Tooltip.js +0 -19
  94. package/src/components/icon/UpArrow.js +0 -20
  95. package/src/components/icon/Upload.js +0 -25
  96. package/src/components/icon/Wrong.js +0 -21
  97. package/src/components/icon/Zoom.js +0 -21
  98. package/src/components/icon/index.js +0 -0
  99. package/src/components/input/index.js +0 -688
  100. package/src/components/input/input.module.css +0 -51
  101. package/src/components/input/input.stories.js +0 -26
  102. package/src/components/modal/index.js +0 -436
  103. package/src/components/modal/modal.module.css +0 -22
  104. package/src/components/modal/modal.stories.js +0 -88
  105. package/src/components/newAutocomplete/NewAutocomplete.stories.js +0 -102
  106. package/src/components/newAutocomplete/autocomplete.module.css +0 -4
  107. package/src/components/newAutocomplete/index.js +0 -592
  108. package/src/components/newFile/fileItem.js +0 -281
  109. package/src/components/newFile/index.js +0 -657
  110. package/src/components/newFile/newFile.stories.js +0 -57
  111. package/src/components/pagination/index.js +0 -234
  112. package/src/components/pagination/pagination.module.css +0 -93
  113. package/src/components/pagination/pagination.stories.js +0 -371
  114. package/src/components/pagination/paginationRange.js +0 -45
  115. package/src/components/radio/index.js +0 -236
  116. package/src/components/radio/radio.module.css +0 -59
  117. package/src/components/radio/radio.stories.js +0 -59
  118. package/src/components/select/index.js +0 -534
  119. package/src/components/select/select.module.css +0 -93
  120. package/src/components/select/select.stories.js +0 -39
  121. package/src/components/singleCheckbox/Checkbox.js +0 -84
  122. package/src/components/singleCheckbox/index.js +0 -65
  123. package/src/components/singleCheckbox/singleCheckbox.stories.js +0 -24
  124. package/src/components/stepper/index.js +0 -45
  125. package/src/components/stepper/stepper.module.css +0 -57
  126. package/src/components/stepper/stepper.stories.js +0 -17
  127. package/src/components/table/index.js +0 -789
  128. package/src/components/table/table.module.css +0 -63
  129. package/src/components/table/table.stories.js +0 -497
  130. package/src/components/table/td.js +0 -428
  131. package/src/components/table/th.js +0 -103
  132. package/src/components/textarea/index.js +0 -251
  133. package/src/components/textarea/textarea.module.css +0 -25
  134. package/src/components/textarea/textarea.stories.js +0 -50
  135. package/src/components/toaster/Toast.js +0 -203
  136. package/src/components/toaster/index.js +0 -131
  137. package/src/components/toaster/toaster.module.css +0 -201
  138. package/src/components/toaster/toaster.stories.js +0 -593
  139. package/src/components/tooltip/index.js +0 -156
  140. package/src/components/tooltip/tooltip.module.css +0 -46
  141. package/src/components/tooltip/tooltip.stories.js +0 -30
  142. package/src/components/typography/index.js +0 -124
  143. package/src/components/typography/typography.module.css +0 -57
  144. package/src/components/typography/typography.stories.js +0 -22
  145. package/src/index.js +0 -19
  146. package/src/stories/Introduction.stories.mdx +0 -210
  147. package/src/stories/assets/code-brackets.svg +0 -1
  148. package/src/stories/assets/colors.svg +0 -1
  149. package/src/stories/assets/comments.svg +0 -1
  150. package/src/stories/assets/direction.svg +0 -1
  151. package/src/stories/assets/flow.svg +0 -1
  152. package/src/stories/assets/plugin.svg +0 -1
  153. package/src/stories/assets/repo.svg +0 -1
  154. package/src/stories/assets/stackalt.svg +0 -1
  155. package/src/stories/changelog.stories.mdx +0 -131
  156. package/src/stories/configuration.stories.mdx +0 -708
  157. package/src/stories/documentation.stories.mdx +0 -118
  158. package/src/stories/static/autocomplete-usage.png +0 -0
  159. package/src/stories/static/button-usage-icon.png +0 -0
  160. package/src/stories/static/button-usage.png +0 -0
  161. package/src/stories/static/captcha-usage.png +0 -0
  162. package/src/stories/static/checkbox-group-usage-2.png +0 -0
  163. package/src/stories/static/checkbox-group-usage.png +0 -0
  164. package/src/stories/static/file-single-usage.png +0 -0
  165. package/src/stories/static/file-usage.png +0 -0
  166. package/src/stories/static/input-usage.png +0 -0
  167. package/src/stories/static/modal-usage.png +0 -0
  168. package/src/stories/static/radio-usage.png +0 -0
  169. package/src/stories/static/select-usage.png +0 -0
  170. package/src/stories/static/table-body-data-structure-first-part-usage.png +0 -0
  171. package/src/stories/static/table-body-data-structure-second-part-usage.png +0 -0
  172. package/src/stories/static/table-body-data-structure-third-part-usage.png +0 -0
  173. package/src/stories/static/table-component-usage.png +0 -0
  174. package/src/stories/static/table-header-data-structure-usage.png +0 -0
  175. package/src/stories/static/table-new-data-structure-usage.png +0 -0
  176. package/src/stories/static/textarea-usage.png +0 -0
  177. package/src/stories/static/toaster-container-usage.png +0 -0
  178. package/src/stories/static/toaster-usage.png +0 -0
  179. package/src/stories/static/tooltip-usage.png +0 -0
  180. package/src/stories/usage.stories.mdx +0 -201
  181. package/src/utils/index.js +0 -29
@@ -1,789 +0,0 @@
1
- import React, { useState, useEffect } from 'react'
2
- import PropTypes from 'prop-types'
3
-
4
- import TH from './th'
5
- import TD from './td'
6
-
7
- import SvgUpArrow from './../icon/UpArrow'
8
- import SvgDownArrow from './../icon/DownArrow'
9
-
10
- import { compereConfigs, hasOwnerProperty } from './../../utils'
11
-
12
- export const Table = ({
13
- getData,
14
- dataBody,
15
- arrowShow,
16
- dataHeader,
17
- arrowColumn,
18
- tableRowItem,
19
- tableRowRadius,
20
- tableRowBGColor,
21
- tableRowBoxShadow,
22
- tableColumnMaxWidth,
23
- tableColumnMinWidth,
24
-
25
- tHeadColor,
26
- tHeadFamily,
27
- tHeadPadding,
28
- tHeadFontSize,
29
- tHeadTextAlign,
30
- tHeadFontWeight,
31
- tHeadBorderRadius,
32
- tHeadBackgroundColor,
33
-
34
- tBodyColor,
35
- tBodyPadding,
36
- tBodyFontSize,
37
- tBodyTextAlign,
38
- tBodyRowBorder,
39
- tBodyBoxShadow,
40
- tBodyFontWeight,
41
- tBodyFontFamily,
42
- tBodyRowMarginTop,
43
-
44
- className,
45
- openListColor,
46
- openListFontSize,
47
- openListFontFamily,
48
- hideBorder,
49
- }) => {
50
- const [body, setBody] = useState([])
51
- const [header, setHeader] = useState([])
52
- const [disableArr, setDisableArr] = useState([])
53
- const [checkedArray, setCheckedArray] = useState([])
54
-
55
- const configStyles = compereConfigs()
56
-
57
- const handleCheckIfArrow = (bodyData, data) => {
58
- let removeItemIndex
59
- let headerWithoutArrow = []
60
-
61
- bodyData.map((item, index) => {
62
- if (index === data.index) {
63
- item.map((innerItem, innerIndex) => {
64
- if (hasOwnerProperty(innerItem, 'arrowComponent')) {
65
- removeItemIndex = innerIndex
66
- }
67
- })
68
- if (removeItemIndex !== undefined) {
69
- const firstPart = item.slice(0, removeItemIndex)
70
- const secondPart = item.slice(removeItemIndex + 1, item.length)
71
- headerWithoutArrow = [...firstPart, ...secondPart]
72
- } else {
73
- headerWithoutArrow.push(item)
74
- }
75
- }
76
- })
77
-
78
- return { removeItemIndex, headerWithoutArrow }
79
- }
80
-
81
- const handleHeaderItemClick = (e) => {
82
- e.stopPropagation()
83
-
84
- if (!e.target.tagName.startsWith('svg') && e.target.innerText !== undefined && e.target.innerText !== '') {
85
- let removeItemIndex
86
- let headerWithoutArrow
87
-
88
- header.map((item, index) => {
89
- if (hasOwnerProperty(item, 'arrowComponent')) {
90
- removeItemIndex = index
91
- }
92
- })
93
-
94
- if (removeItemIndex !== undefined) {
95
- const firstPart = header.slice(0, removeItemIndex)
96
- const secondPart = header.slice(removeItemIndex + 1, header.length)
97
- headerWithoutArrow = [...firstPart, ...secondPart]
98
- }
99
-
100
- const returnedData = {
101
- from: 'header',
102
- content: e.target.innerText,
103
- row: headerWithoutArrow !== undefined ? headerWithoutArrow : header,
104
- }
105
-
106
- getData(returnedData)
107
- }
108
- }
109
-
110
- const handleBodyActionClick = (e, data) => {
111
- e.stopPropagation()
112
-
113
- const { removeItemIndex, headerWithoutArrow } = handleCheckIfArrow(body, data)
114
-
115
- const actionData = {
116
- from: 'body',
117
- item: data.item,
118
- id: data.item.id,
119
- items: data.items,
120
- type: data.item.type,
121
- rowIndex: data.index,
122
- row: headerWithoutArrow,
123
- itemInnerIndex: data.itemIndex,
124
- itemIndex:
125
- removeItemIndex !== undefined && removeItemIndex < data.innerIndex
126
- ? data.innerIndex - 1
127
- : data.innerIndex,
128
- }
129
-
130
- getData(actionData)
131
- }
132
-
133
- const handleSetCheckboxArray = (data) => {
134
- let checkedItems = []
135
- data.map((item, index) => {
136
- item.map((innerItem, innerIndex) => {
137
- if (hasOwnerProperty(innerItem, 'checkBox')) {
138
- if (!checkedItems[innerIndex]) {
139
- checkedItems[innerIndex] = []
140
- }
141
- checkedItems[innerIndex].push({
142
- rowCount: index,
143
- columnCount: innerIndex,
144
- checked: innerItem.checkBox.checked,
145
- })
146
- }
147
- })
148
- })
149
- return checkedItems
150
- }
151
-
152
- const handleSetInsertIndex = (data, count) => {
153
- let arrowColumnCount
154
- if (typeof count !== 'number') {
155
- alert('arrowColumn props must be a number, please check it')
156
- } else {
157
- if (count <= 0) {
158
- arrowColumnCount = 0
159
- } else {
160
- if (count >= data.length - 1) {
161
- arrowColumnCount = data.length
162
- } else {
163
- arrowColumnCount = count
164
- }
165
- }
166
- }
167
- return arrowColumnCount
168
- }
169
-
170
- const handleInsertArrow = (data, count, arrowObject) => {
171
- if (count === 0) {
172
- data.unshift(arrowObject)
173
- } else if (count >= data.length - 1) {
174
- data.push(arrowObject)
175
- } else {
176
- data.splice(count, 0, arrowObject)
177
- }
178
- return data
179
- }
180
-
181
- const handleTransformDataForInsertArrow = (data, count, type) => {
182
- const arrowObject = {
183
- status: 'close',
184
- checkIndex: null,
185
- arrowComponent: true,
186
- openArrow: <SvgUpArrow />,
187
- closeArrow: <SvgDownArrow />,
188
- }
189
-
190
- if (type === 'body') {
191
- return data.map((item, index) => {
192
- const newObjWithArrow = { ...arrowObject }
193
- newObjWithArrow.checkIndex = index
194
- return handleInsertArrow(item, count, newObjWithArrow)
195
- })
196
- } else {
197
- const newObjWithArrow = { ...arrowObject }
198
- newObjWithArrow.checkIndex = count
199
- return handleInsertArrow(data, count, newObjWithArrow)
200
- }
201
- }
202
-
203
- const handleCheckedHeader = (data, e) => {
204
- e.stopPropagation()
205
- let removeItemIndex
206
- let checkableItemBool
207
- let checkableItemIndex
208
- let headerWithoutArrow
209
- let checkableBodyRowItems = []
210
-
211
- const updatedHeader = header.slice()
212
- const updatedBody = body.slice().map((item) => Object.values(item))
213
- const newData = updatedHeader.map((item, index) => {
214
- if (item.content == data.content) {
215
- checkableItemIndex = index
216
- checkableItemBool = !item.checkBox.checked
217
- item.checkBox.checked = !item.checkBox.checked
218
- }
219
- if (hasOwnerProperty(item, 'arrowComponent')) {
220
- removeItemIndex = index
221
- }
222
- return item
223
- })
224
-
225
- const newUpdatedBody = updatedBody.map((item, index) => {
226
- return item.map((innerItem, innerIndex) => {
227
- if (checkableItemIndex === innerIndex) {
228
- if (!hasOwnerProperty(innerItem.checkBox, 'disabled') || innerItem.checkBox.disabled !== true) {
229
- innerItem.checkBox.checked = checkableItemBool
230
- checkableBodyRowItems.push({ column: innerIndex, columnItem: innerItem })
231
- }
232
- handleHeaderCheckedUpdate({
233
- row: index,
234
- column: innerIndex,
235
- checked: { checked: checkableItemBool },
236
- })
237
- }
238
- return innerItem
239
- })
240
- })
241
-
242
- if (removeItemIndex !== undefined) {
243
- const firstPart = newData.slice(0, removeItemIndex)
244
- const secondPart = newData.slice(removeItemIndex + 1, newData.length)
245
- headerWithoutArrow = [...firstPart, ...secondPart]
246
- }
247
-
248
- const returnedData = {
249
- from: 'header',
250
- content: data.content,
251
- checkBox: data.checkBox,
252
- columnArray: checkableBodyRowItems,
253
- row: headerWithoutArrow !== undefined ? headerWithoutArrow : newData,
254
- }
255
-
256
- getData(returnedData)
257
-
258
- setHeader(newData)
259
- setBody(newUpdatedBody)
260
- }
261
-
262
- const handleCheckedBody = (data, e, dataRowIndex, dataItemIndex) => {
263
- e.stopPropagation()
264
- const transformedData = { ...data }
265
- transformedData.index = dataRowIndex
266
- transformedData.innerIndex = dataItemIndex
267
- const updatedBody = body.slice().map((item) => Object.values(item))
268
- const newData = updatedBody.map((item, index) => {
269
- return item.map((innerItem, innerIndex) => {
270
- if (
271
- innerItem.id === data.id &&
272
- innerItem.content == data.content &&
273
- hasOwnerProperty(innerItem, 'checkBox')
274
- ) {
275
- innerItem.checkBox.checked = !innerItem.checkBox.checked
276
- handleHeaderCheckedUpdate({
277
- row: index,
278
- column: innerIndex,
279
- checked: innerItem.checkBox,
280
- })
281
- }
282
- return innerItem
283
- })
284
- })
285
- const { removeItemIndex, headerWithoutArrow } = handleCheckIfArrow(body, transformedData)
286
-
287
- const checkedData = {
288
- item: data,
289
- from: 'body',
290
- row: removeItemIndex !== undefined ? headerWithoutArrow : headerWithoutArrow[0],
291
- rowIndex: transformedData.index,
292
- itemIndex:
293
- removeItemIndex !== undefined && removeItemIndex < transformedData.innerIndex
294
- ? transformedData.innerIndex - 1
295
- : transformedData.innerIndex,
296
- }
297
- getData(checkedData)
298
- setBody(newData)
299
- }
300
-
301
- const handleHeaderCheckedUpdate = (checkedData) => {
302
- const updatedHeader = header.slice()
303
- const newCheckedArray = checkedArray.map((item, index) => {
304
- return item.map((innerItem, innerIndex) => {
305
- if (index === checkedData.column) {
306
- if (innerIndex === checkedData.row) {
307
- innerItem.checked = checkedData.checked.checked
308
- }
309
- }
310
- return innerItem
311
- })
312
- })
313
-
314
- const newData = updatedHeader.map((item, index) => {
315
- if (newCheckedArray[index]) {
316
- const tempCheckedArray = []
317
- newCheckedArray[index].map((innerItem) => {
318
- tempCheckedArray.push(innerItem.checked)
319
- })
320
- if (tempCheckedArray.every((i) => i)) {
321
- item.checkBox.checked = true
322
- } else {
323
- item.checkBox.checked = false
324
- }
325
- }
326
- return item
327
- })
328
-
329
- setHeader(newData)
330
- setCheckedArray(newCheckedArray)
331
- }
332
-
333
- const handleCheckArrowAction = (item, rowPosition) => {
334
- const status = item.status
335
- const checkedOpenableRow = body[rowPosition].map((innerItem) => {
336
- if (hasOwnerProperty(innerItem, 'status')) {
337
- if (status === 'close') {
338
- innerItem.status = 'open'
339
- } else {
340
- innerItem.status = 'close'
341
- }
342
- }
343
- return innerItem
344
- })
345
- setBody((prev) => {
346
- prev[rowPosition] = checkedOpenableRow
347
- return [...prev]
348
- })
349
- }
350
-
351
- const handleOpenCloseRowSingleArrow = (arrowRowIndex, arrowIndex, clickableItem) => {
352
- let single = {}
353
- const allArrows = []
354
- const checkedOpenableRow = body[arrowRowIndex].map((item, index) => {
355
- if (index === arrowIndex) {
356
- if (item.status === 'close') {
357
- item.status = 'open'
358
- } else {
359
- item.status = 'close'
360
- }
361
-
362
- single = item
363
- }
364
-
365
- if (hasOwnerProperty(item, 'status') && !hasOwnerProperty(item, 'arrowComponent')) {
366
- allArrows.push(item)
367
- }
368
-
369
- return item
370
- })
371
-
372
- const checkedOpenableRowArrow = checkedOpenableRow.map((item) => {
373
- if (hasOwnerProperty(item, 'arrowComponent')) {
374
- if (single && single.status === 'close') {
375
- item.status = 'close'
376
- } else if (single && single.status === 'open') {
377
- if (allArrows.every((i) => i.status === 'open')) {
378
- item.status = 'open'
379
- }
380
- }
381
- }
382
-
383
- if (
384
- hasOwnerProperty(clickableItem, 'theSame') &&
385
- hasOwnerProperty(item, 'theSame') &&
386
- clickableItem.theSame === item.theSame
387
- ) {
388
- item.status = clickableItem.status
389
- }
390
-
391
- return item
392
- })
393
-
394
- setBody((prev) => {
395
- prev[arrowRowIndex] = checkedOpenableRowArrow
396
- return [...prev]
397
- })
398
- }
399
-
400
- const handleCheckArrowActionHeader = (e, item) => {
401
- e.stopPropagation()
402
- const checkedOpenableAllRows = header.map((innerItem, innerIndex) => {
403
- if (item.checkIndex === innerIndex) {
404
- if (item.status === 'close') {
405
- innerItem.status = 'open'
406
- } else {
407
- innerItem.status = 'close'
408
- }
409
- }
410
- return innerItem
411
- })
412
-
413
- const checkedOpenableAllRowsBody = body.map((innerItem) => {
414
- return innerItem.map((iElem) => {
415
- if (hasOwnerProperty(iElem, 'status')) {
416
- if (item.status === 'open') {
417
- iElem.status = 'open'
418
- } else {
419
- iElem.status = 'close'
420
- }
421
- }
422
- return iElem
423
- })
424
- })
425
- setHeader(() => checkedOpenableAllRows)
426
- setBody(() => checkedOpenableAllRowsBody)
427
- }
428
-
429
- const handleCheckDots = (e, item, index, innerIndex) => {
430
- e.stopPropagation()
431
- const checkBodyMore = body.map((elemItem, elemIndex) => {
432
- return elemItem.map((elemInnerItem, elemInnerIndex) => {
433
- if (elemIndex === index && hasOwnerProperty(elemInnerItem, 'dots')) {
434
- if (elemInnerIndex === innerIndex) {
435
- if (item.dotsStatus === 'deActive') {
436
- elemInnerItem.dotsStatus = 'active'
437
- } else {
438
- elemInnerItem.dotsStatus = 'deActive'
439
- }
440
- }
441
- } else if (elemIndex !== index && hasOwnerProperty(elemInnerItem, 'dots')) {
442
- if (elemInnerIndex === innerIndex) {
443
- elemInnerItem.dotsStatus = 'deActive'
444
- }
445
- }
446
- return elemInnerItem
447
- })
448
- })
449
- setBody(() => checkBodyMore)
450
- }
451
-
452
- const handleContentListClick = (e, data) => {
453
- e.stopPropagation()
454
-
455
- const { removeItemIndex, headerWithoutArrow } = handleCheckIfArrow(body, data)
456
-
457
- const listData = {
458
- from: 'body',
459
- item: data.item,
460
- rowIndex: data.index,
461
- row: headerWithoutArrow,
462
- listItemId: data.listContentId,
463
- listItemContent: data.listContent,
464
- itemIndex:
465
- removeItemIndex !== undefined && removeItemIndex < data.innerIndex
466
- ? data.innerIndex - 1
467
- : data.innerIndex,
468
- listItemInnerIndex: data.listContentIndex,
469
- }
470
-
471
- getData(listData)
472
- }
473
-
474
- const handleMoreOptionsClick = (data) => {
475
- const { removeItemIndex, headerWithoutArrow } = handleCheckIfArrow(body, data)
476
-
477
- const moreData = {
478
- from: 'body',
479
- item: data.item,
480
- rowIndex: data.index,
481
- options: data.options,
482
- row: headerWithoutArrow,
483
- itemIndex:
484
- removeItemIndex !== undefined && removeItemIndex < data.innerIndex
485
- ? data.innerIndex - 1
486
- : data.innerIndex,
487
- optionItem: data.optionItem,
488
- optionIndex: data.optionIndex,
489
- }
490
-
491
- getData(moreData)
492
- }
493
-
494
- const handleTableClick = () => {
495
- const checkBodyMore = body.map((elemItem) => {
496
- return elemItem.map((elemInnerItem) => {
497
- if (hasOwnerProperty(elemInnerItem, 'dots')) {
498
- elemInnerItem.dotsStatus = 'deActive'
499
- }
500
- return elemInnerItem
501
- })
502
- })
503
- setBody(() => checkBodyMore)
504
- }
505
-
506
- useEffect(() => {
507
- let checkedItems = []
508
- const disabledArray = []
509
- const checkBodyForChackedItems = dataBody.slice().map((item) => Object.values(item))
510
-
511
- if (arrowShow) {
512
- const arrowColumnCount = handleSetInsertIndex(checkBodyForChackedItems[0], arrowColumn)
513
-
514
- const checkForInsertArrow = handleTransformDataForInsertArrow(
515
- checkBodyForChackedItems,
516
- arrowColumnCount,
517
- 'body'
518
- )
519
- const insert = checkForInsertArrow.map((item, index) => {
520
- item.map((innerItem, innerIndex) => {
521
- if (hasOwnerProperty(innerItem, 'checkBox')) {
522
- if (hasOwnerProperty(innerItem.checkBox, 'disabled')) {
523
- if (innerItem.checkBox.disabled === true) {
524
- if (!disabledArray[innerIndex]) {
525
- disabledArray[innerIndex] = { rowIndex: index, columnIndex: innerIndex }
526
- }
527
- }
528
- }
529
- }
530
- })
531
- return item
532
- })
533
- checkedItems = handleSetCheckboxArray(insert)
534
- setBody(() => insert)
535
- } else {
536
- const insert = checkBodyForChackedItems.map((item, index) => {
537
- item.map((innerItem, innerIndex) => {
538
- if (hasOwnerProperty(innerItem, 'checkBox')) {
539
- if (hasOwnerProperty(innerItem.checkBox, 'disabled')) {
540
- if (innerItem.checkBox.disabled === true) {
541
- if (!disabledArray[innerIndex]) {
542
- disabledArray[innerIndex] = { rowIndex: index, columnIndex: innerIndex }
543
- }
544
- }
545
- }
546
- }
547
- })
548
- return item
549
- })
550
- checkedItems = handleSetCheckboxArray(insert)
551
- setBody(() => insert)
552
- }
553
-
554
- setDisableArr(disabledArray)
555
- setCheckedArray(() => checkedItems)
556
- }, [dataBody, arrowColumn, arrowShow])
557
-
558
- useEffect(() => {
559
- if (arrowShow) {
560
- const header = dataHeader.slice()
561
- const arrowColumnCount = handleSetInsertIndex(header, arrowColumn)
562
- const checkForInsertArrow = handleTransformDataForInsertArrow(header, arrowColumnCount, 'header')
563
- setHeader(() => checkForInsertArrow)
564
- } else {
565
- setHeader(() => dataHeader)
566
- }
567
- }, [dataHeader, arrowColumn, arrowShow, disableArr])
568
-
569
- return (
570
- <>
571
- <table
572
- style={{
573
- width: '100%',
574
- borderCollapse: (tableRowItem ? tableRowItem : configStyles.TABLE.tableRowItem)
575
- ? 'separate'
576
- : 'collapse',
577
- borderSpacing: `0 ${tBodyRowMarginTop ? tBodyRowMarginTop : configStyles.TABLE.tBodyRowMarginTop}`,
578
- }}
579
- onClick={handleTableClick}
580
- className={className ? className : configStyles.TABLE.className}
581
- >
582
- {header && header.length > 0 && (
583
- <thead>
584
- <tr
585
- style={{
586
- color: tHeadColor ? tHeadColor : configStyles.TABLE.tHeadColor,
587
- backgroundColor: tHeadBackgroundColor
588
- ? tHeadBackgroundColor
589
- : configStyles.TABLE.tHeadBackgroundColor,
590
- borderColor: hideBorder ? 'transparent' : '#eeeeee',
591
- }}
592
- >
593
- {header.map((item, index) => {
594
- return (
595
- <TH
596
- item={item}
597
- hideBorder={hideBorder}
598
- key={`${item}_${index}`}
599
- handleCheckedHeader={handleCheckedHeader}
600
- handleHeaderItemClick={handleHeaderItemClick}
601
- handleCheckArrowActionHeader={handleCheckArrowActionHeader}
602
- tHeadFamily={tHeadFamily ? tHeadFamily : configStyles.TABLE.tHeadFamily}
603
- tHeadPadding={tHeadPadding ? tHeadPadding : configStyles.TABLE.tHeadPadding}
604
- tHeadFontSize={tHeadFontSize ? tHeadFontSize : configStyles.TABLE.tHeadFontSize}
605
- tHeadTextAlign={
606
- tHeadTextAlign ? tHeadTextAlign : configStyles.TABLE.tHeadTextAlign
607
- }
608
- tHeadFontWeight={
609
- tHeadFontWeight ? tHeadFontWeight : configStyles.TABLE.tHeadFontWeight
610
- }
611
- borderTopLeftRadius={
612
- index === 0
613
- ? tHeadBorderRadius
614
- ? tHeadBorderRadius
615
- : configStyles.TABLE.tHeadBorderRadius
616
- : '0px'
617
- }
618
- borderTopRightRadius={
619
- index === header.length - 1
620
- ? tHeadBorderRadius
621
- ? tHeadBorderRadius
622
- : configStyles.TABLE.tHeadBorderRadius
623
- : '0px'
624
- }
625
- tableColumnMinWidth={
626
- tableColumnMinWidth
627
- ? tableColumnMinWidth
628
- : configStyles.TABLE.tableColumnMinWidth
629
- }
630
- tableColumnMaxWidth={
631
- tableColumnMaxWidth
632
- ? tableColumnMaxWidth
633
- : configStyles.TABLE.tableColumnMaxWidth
634
- }
635
- />
636
- )
637
- })}
638
- </tr>
639
- </thead>
640
- )}
641
-
642
- {body && body.length > 0 && (
643
- <tbody
644
- style={{
645
- boxShadow: tBodyBoxShadow ? tBodyBoxShadow : configStyles.TABLE.tBodyBoxShadow,
646
- }}
647
- >
648
- {body.map((item, index) => {
649
- return (
650
- <tr
651
- key={`${item}_${index}`}
652
- style={{
653
- backgroundColor: tableRowBGColor
654
- ? tableRowBGColor
655
- : configStyles.TABLE.tableRowBGColor,
656
- borderBottom:
657
- index === body.length - 1
658
- ? 'none'
659
- : tBodyRowBorder
660
- ? tBodyRowBorder
661
- : configStyles.TABLE.tBodyRowBorder,
662
- borderColor: hideBorder ? 'transparent' : '#eeeeee',
663
- boxShadow: (tableRowItem ? tableRowItem : configStyles.TABLE.tableRowItem)
664
- ? tableRowBoxShadow
665
- ? tableRowBoxShadow
666
- : configStyles.TABLE.tableRowBoxShadow
667
- : 'none',
668
- }}
669
- >
670
- {Object.values(item).map((innerItem, innerIndex) => {
671
- return (
672
- <TD
673
- index={index}
674
- item={innerItem}
675
- hideBorder={hideBorder}
676
- innerIndex={innerIndex}
677
- row={Object.values(item)}
678
- id={item.id ? item.id : ''}
679
- handleCheckDots={handleCheckDots}
680
- key={`${innerItem}_${index}_${innerIndex}`}
681
- openListColor={
682
- openListColor ? openListColor : configStyles.TABLE.openListColor
683
- }
684
- tableColumnMinWidth={
685
- tableColumnMinWidth
686
- ? tableColumnMinWidth
687
- : configStyles.TABLE.tableColumnMinWidth
688
- }
689
- tableColumnMaxWidth={
690
- tableColumnMaxWidth
691
- ? tableColumnMaxWidth
692
- : configStyles.TABLE.tableColumnMaxWidth
693
- }
694
- openListFontSize={
695
- openListFontSize
696
- ? openListFontSize
697
- : configStyles.TABLE.openListFontSize
698
- }
699
- openListFontFamily={
700
- openListFontFamily
701
- ? openListFontFamily
702
- : configStyles.TABLE.openListFontFamily
703
- }
704
- handleCheckedBody={handleCheckedBody}
705
- handleBodyActionClick={handleBodyActionClick}
706
- handleMoreOptionsClick={handleMoreOptionsClick}
707
- handleContentListClick={handleContentListClick}
708
- tBodyColor={tBodyColor ? tBodyColor : configStyles.TABLE.tBodyColor}
709
- rowItem={tableRowItem ? tableRowItem : configStyles.TABLE.tableRowItem}
710
- rowRadius={
711
- tableRowRadius ? tableRowRadius : configStyles.TABLE.tableRowRadius
712
- }
713
- tBodyPadding={
714
- tBodyPadding ? tBodyPadding : configStyles.TABLE.tBodyPadding
715
- }
716
- tBodyFontSize={
717
- tBodyFontSize ? tBodyFontSize : configStyles.TABLE.tBodyFontSize
718
- }
719
- tBodyTextAlign={
720
- tBodyTextAlign ? tBodyTextAlign : configStyles.TABLE.tBodyTextAlign
721
- }
722
- tBodyFontFamily={
723
- tBodyFontFamily
724
- ? tBodyFontFamily
725
- : configStyles.TABLE.tBodyFontFamily
726
- }
727
- tBodyFontWeight={
728
- tBodyFontWeight
729
- ? tBodyFontWeight
730
- : configStyles.TABLE.tBodyFontWeight
731
- }
732
- borderRight={
733
- innerIndex === Object.values(item).length - 1
734
- ? 'none'
735
- : configStyles.TABLE.tBodyRowBorder
736
- }
737
- handleCheckArrowAction={handleCheckArrowAction}
738
- handleOpenCloseRowSingleArrow={handleOpenCloseRowSingleArrow}
739
- />
740
- )
741
- })}
742
- </tr>
743
- )
744
- })}
745
- </tbody>
746
- )}
747
- </table>
748
- </>
749
- )
750
- }
751
-
752
- Table.propTypes = {
753
- getData: PropTypes.func,
754
- dataBody: PropTypes.array,
755
- arrowShow: PropTypes.bool,
756
- dataHeader: PropTypes.array,
757
- arrowColumn: PropTypes.number,
758
- tableRowItem: PropTypes.bool,
759
- tableRowRadius: PropTypes.string,
760
- tableRowBGColor: PropTypes.string,
761
- tableRowBoxShadow: PropTypes.string,
762
- tableColumnMaxWidth: PropTypes.string,
763
- tableColumnMinWidth: PropTypes.string,
764
-
765
- tHeadColor: PropTypes.string,
766
- tHeadFamily: PropTypes.string,
767
- tHeadPadding: PropTypes.string,
768
- tHeadFontSize: PropTypes.string,
769
- tHeadTextAlign: PropTypes.string,
770
- tHeadFontWeight: PropTypes.number,
771
- tHeadBorderRadius: PropTypes.string,
772
- tHeadBackgroundColor: PropTypes.string,
773
-
774
- tBodyColor: PropTypes.string,
775
- tBodyPadding: PropTypes.string,
776
- tBodyFontSize: PropTypes.string,
777
- tBodyBoxShadow: PropTypes.string,
778
- tBodyTextAlign: PropTypes.string,
779
- tBodyFontWeight: PropTypes.string,
780
- tBodyFontFamily: PropTypes.string,
781
- tBodyRowMarginTop: PropTypes.string,
782
-
783
- className: PropTypes.string,
784
- tBodyRowBorder: PropTypes.string,
785
- openListColor: PropTypes.string,
786
- openListFontSize: PropTypes.string,
787
- openListFontFamily: PropTypes.string,
788
- hideBorder: PropTypes.bool,
789
- }