@xaypay/tui 0.0.109 → 0.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +784 -20
- package/dist/index.js +784 -19
- package/package.json +1 -1
- package/src/components/icon/Active.js +20 -0
- package/src/components/icon/Cancel.js +19 -0
- package/src/components/icon/DeActive.js +20 -0
- package/src/components/icon/Done.js +19 -0
- package/src/components/icon/DownArrow.js +20 -0
- package/src/components/icon/Reject.js +19 -0
- package/src/components/icon/Required.js +4 -4
- package/src/components/icon/UpArrow.js +20 -0
- package/src/components/newFile/index.js +13 -0
- package/src/components/newFile/newFile.stories.js +6 -0
- package/src/components/table/index.js +399 -60
- package/src/components/table/table.module.css +40 -2
- package/src/components/table/table.stories.js +107 -16
- package/src/components/table/td.js +137 -23
- package/src/components/table/th.js +27 -5
- package/src/components/typography/index.js +1 -1
- package/src/stories/configuration.stories.mdx +25 -0
- package/tui.config.js +17 -14
|
@@ -4,15 +4,22 @@ import PropTypes from 'prop-types'
|
|
|
4
4
|
import TH from './th'
|
|
5
5
|
import TD from './td'
|
|
6
6
|
|
|
7
|
+
import SvgUpArrow from './../icon/UpArrow'
|
|
8
|
+
import SvgDownArrow from './../icon/DownArrow'
|
|
9
|
+
|
|
7
10
|
import { compereConfigs } from './../../utils'
|
|
8
11
|
|
|
9
|
-
const Table = ({
|
|
12
|
+
export const Table = ({
|
|
13
|
+
getData,
|
|
10
14
|
dataBody,
|
|
15
|
+
arrowShow,
|
|
11
16
|
dataHeader,
|
|
17
|
+
arrowColumn,
|
|
12
18
|
|
|
13
19
|
tHeadColor,
|
|
14
20
|
tHeadFamily,
|
|
15
21
|
tHeadPadding,
|
|
22
|
+
tHeadFontSize,
|
|
16
23
|
tHeadFontWeight,
|
|
17
24
|
tHeadBorderRadius,
|
|
18
25
|
tHeadBackgroundColor,
|
|
@@ -25,73 +32,201 @@ const Table = ({
|
|
|
25
32
|
tBodyFontFamily,
|
|
26
33
|
|
|
27
34
|
tBodyRowBorder,
|
|
35
|
+
openListColor,
|
|
28
36
|
}) => {
|
|
29
37
|
const [body, setBody] = useState([])
|
|
30
38
|
const [header, setHeader] = useState([])
|
|
39
|
+
const [disableArr, setDisableArr] = useState([])
|
|
40
|
+
const [checkedArray, setCheckedArray] = useState([])
|
|
31
41
|
|
|
32
42
|
const configStyles = compereConfigs()
|
|
33
43
|
|
|
34
|
-
const [checkedFirstCount, setCheckedFirstCount] = useState(0)
|
|
35
|
-
const [checkedSecondCount, setCheckedSecondCount] = useState(0)
|
|
36
|
-
|
|
37
44
|
const handleHeaderItemClick = (e) => {
|
|
38
45
|
e.stopPropagation()
|
|
39
|
-
|
|
46
|
+
|
|
47
|
+
if (!e.target.tagName.startsWith('svg') && e.target.innerText !== undefined && e.target.innerText !== '') {
|
|
48
|
+
let removeItemIndex
|
|
49
|
+
let headerWithoutArrow
|
|
50
|
+
|
|
51
|
+
header.map((item, index) => {
|
|
52
|
+
if (Object.prototype.hasOwnProperty.call(item, 'arrowComponent')) {
|
|
53
|
+
removeItemIndex = index
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
if (removeItemIndex !== undefined) {
|
|
58
|
+
const firstPart = header.slice(0, removeItemIndex)
|
|
59
|
+
const secondPart = header.slice(removeItemIndex + 1, header.length)
|
|
60
|
+
headerWithoutArrow = [...firstPart, ...secondPart]
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const returnedData = {
|
|
64
|
+
from: 'header',
|
|
65
|
+
content: e.target.innerText,
|
|
66
|
+
row: headerWithoutArrow !== undefined ? headerWithoutArrow : header,
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
getData(returnedData)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const handleBodyActionClick = (e, data) => {
|
|
74
|
+
e.stopPropagation()
|
|
75
|
+
// const dataRow =
|
|
76
|
+
|
|
77
|
+
const actionData = {
|
|
78
|
+
row: '',
|
|
79
|
+
item: data.item,
|
|
80
|
+
id: data.item.id,
|
|
81
|
+
items: data.items,
|
|
82
|
+
type: data.item.type,
|
|
83
|
+
rowIndex: data.index,
|
|
84
|
+
itemIndex: data.innerIndex,
|
|
85
|
+
itemInnerIndex: data.itemIndex,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
console.log(actionData)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const handleSetCheckboxArray = (data) => {
|
|
92
|
+
let checkedItems = []
|
|
93
|
+
data.map((item, index) => {
|
|
94
|
+
item.map((innerItem, innerIndex) => {
|
|
95
|
+
if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
|
|
96
|
+
if (!checkedItems[innerIndex]) {
|
|
97
|
+
checkedItems[innerIndex] = []
|
|
98
|
+
}
|
|
99
|
+
checkedItems[innerIndex].push({
|
|
100
|
+
rowCount: index,
|
|
101
|
+
columnCount: innerIndex,
|
|
102
|
+
checked: innerItem.checkBox.checked,
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
return checkedItems
|
|
40
108
|
}
|
|
41
109
|
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
110
|
+
const handleSetInsertIndex = (data, count) => {
|
|
111
|
+
let arrowColumnCount
|
|
112
|
+
if (typeof count !== 'number') {
|
|
113
|
+
alert('arrowColumn props must be a number, please check it')
|
|
114
|
+
} else {
|
|
115
|
+
if (count <= 0) {
|
|
116
|
+
arrowColumnCount = 0
|
|
117
|
+
} else {
|
|
118
|
+
if (count >= data.length - 1) {
|
|
119
|
+
arrowColumnCount = data.length
|
|
120
|
+
} else {
|
|
121
|
+
arrowColumnCount = count
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return arrowColumnCount
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const handleInsertArrow = (data, count, arrowObject) => {
|
|
129
|
+
if (count === 0) {
|
|
130
|
+
data.unshift(arrowObject)
|
|
131
|
+
} else if (count >= data.length - 1) {
|
|
132
|
+
data.push(arrowObject)
|
|
133
|
+
} else {
|
|
134
|
+
data.splice(count, 0, arrowObject)
|
|
135
|
+
}
|
|
136
|
+
return data
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const handleTransformDataForInsertArrow = (data, count, type) => {
|
|
140
|
+
const arrowObject = {
|
|
141
|
+
status: 'close',
|
|
142
|
+
checkIndex: null,
|
|
143
|
+
arrowComponent: true,
|
|
144
|
+
openArrow: <SvgUpArrow />,
|
|
145
|
+
closeArrow: <SvgDownArrow />,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (type === 'body') {
|
|
149
|
+
return data.map((item, index) => {
|
|
150
|
+
const newObjWithArrow = { ...arrowObject }
|
|
151
|
+
newObjWithArrow.checkIndex = index
|
|
152
|
+
return handleInsertArrow(item, count, newObjWithArrow)
|
|
153
|
+
})
|
|
154
|
+
} else {
|
|
155
|
+
const newObjWithArrow = { ...arrowObject }
|
|
156
|
+
newObjWithArrow.checkIndex = count
|
|
157
|
+
return handleInsertArrow(data, count, newObjWithArrow)
|
|
158
|
+
}
|
|
45
159
|
}
|
|
46
160
|
|
|
47
161
|
const handleCheckedHeader = (data, e) => {
|
|
48
162
|
e.stopPropagation()
|
|
49
|
-
let
|
|
163
|
+
let removeItemIndex
|
|
50
164
|
let checkableItemBool
|
|
51
|
-
|
|
52
|
-
|
|
165
|
+
let checkableItemIndex
|
|
166
|
+
let headerWithoutArrow
|
|
167
|
+
let checkableBodyRowItems = []
|
|
168
|
+
|
|
169
|
+
const updatedHeader = header.slice()
|
|
170
|
+
const updatedBody = body.slice().map((item) => Object.values(item))
|
|
53
171
|
const newData = updatedHeader.map((item, index) => {
|
|
54
172
|
if (item.content === data.content) {
|
|
55
173
|
checkableItemIndex = index
|
|
56
174
|
checkableItemBool = !item.checkBox.checked
|
|
57
175
|
item.checkBox.checked = !item.checkBox.checked
|
|
58
176
|
}
|
|
177
|
+
if (Object.prototype.hasOwnProperty.call(item, 'arrowComponent')) {
|
|
178
|
+
removeItemIndex = index
|
|
179
|
+
}
|
|
59
180
|
return item
|
|
60
181
|
})
|
|
61
182
|
|
|
62
|
-
const newUpdatedBody = updatedBody.map((item) => {
|
|
183
|
+
const newUpdatedBody = updatedBody.map((item, index) => {
|
|
63
184
|
return item.map((innerItem, innerIndex) => {
|
|
64
185
|
if (checkableItemIndex === innerIndex) {
|
|
65
186
|
innerItem.checkBox.checked = checkableItemBool
|
|
187
|
+
checkableBodyRowItems.push({ column: innerIndex, columnItem: innerItem })
|
|
188
|
+
handleHeaderCheckedUpdate({
|
|
189
|
+
row: index,
|
|
190
|
+
column: innerIndex,
|
|
191
|
+
checked: { checked: checkableItemBool },
|
|
192
|
+
})
|
|
66
193
|
}
|
|
67
194
|
return innerItem
|
|
68
195
|
})
|
|
69
196
|
})
|
|
197
|
+
|
|
198
|
+
if (removeItemIndex !== undefined) {
|
|
199
|
+
const firstPart = newData.slice(0, removeItemIndex)
|
|
200
|
+
const secondPart = newData.slice(removeItemIndex + 1, newData.length)
|
|
201
|
+
headerWithoutArrow = [...firstPart, ...secondPart]
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const returnedData = {
|
|
205
|
+
from: 'header',
|
|
206
|
+
content: data.content,
|
|
207
|
+
checkBox: data.checkBox,
|
|
208
|
+
columnArray: checkableBodyRowItems,
|
|
209
|
+
row: headerWithoutArrow !== undefined ? headerWithoutArrow : newData,
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
getData(returnedData)
|
|
213
|
+
|
|
70
214
|
setHeader(newData)
|
|
71
215
|
setBody(newUpdatedBody)
|
|
72
216
|
}
|
|
73
217
|
|
|
74
218
|
const handleCheckedBody = (data, e) => {
|
|
75
219
|
e.stopPropagation()
|
|
76
|
-
|
|
77
|
-
const
|
|
78
|
-
const newData = updatedBody.map((item) => {
|
|
220
|
+
const updatedBody = body.slice().map((item) => Object.values(item))
|
|
221
|
+
const newData = updatedBody.map((item, index) => {
|
|
79
222
|
return item.map((innerItem, innerIndex) => {
|
|
80
|
-
if (innerItem.id === data.id && innerItem.content === data.content) {
|
|
81
|
-
if (innerIndex === 0) {
|
|
82
|
-
if (innerItem.checkBox.checked === false) {
|
|
83
|
-
setCheckedFirstCount((prev) => prev + 1)
|
|
84
|
-
} else {
|
|
85
|
-
setCheckedFirstCount((prev) => prev - 1)
|
|
86
|
-
}
|
|
87
|
-
} else if (innerIndex === 3) {
|
|
88
|
-
if (innerItem.checkBox.checked === false) {
|
|
89
|
-
setCheckedSecondCount((prev) => prev + 1)
|
|
90
|
-
} else {
|
|
91
|
-
setCheckedSecondCount((prev) => prev - 1)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
223
|
+
if (innerItem.id === data.id && innerItem.content === data.content && innerItem.checkBox) {
|
|
94
224
|
innerItem.checkBox.checked = !innerItem.checkBox.checked
|
|
225
|
+
handleHeaderCheckedUpdate({
|
|
226
|
+
row: index,
|
|
227
|
+
column: innerIndex,
|
|
228
|
+
checked: innerItem.checkBox,
|
|
229
|
+
})
|
|
95
230
|
}
|
|
96
231
|
return innerItem
|
|
97
232
|
})
|
|
@@ -99,43 +234,239 @@ const Table = ({
|
|
|
99
234
|
setBody(newData)
|
|
100
235
|
}
|
|
101
236
|
|
|
102
|
-
const handleHeaderCheckedUpdate = () => {
|
|
103
|
-
const updatedHeader =
|
|
237
|
+
const handleHeaderCheckedUpdate = (checkedData) => {
|
|
238
|
+
const updatedHeader = header.slice()
|
|
239
|
+
const newCheckedArray = checkedArray.map((item, index) => {
|
|
240
|
+
return item.map((innerItem, innerIndex) => {
|
|
241
|
+
if (index === checkedData.column) {
|
|
242
|
+
if (innerIndex === checkedData.row) {
|
|
243
|
+
innerItem.checked = checkedData.checked.checked
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return innerItem
|
|
247
|
+
})
|
|
248
|
+
})
|
|
104
249
|
|
|
105
250
|
const newData = updatedHeader.map((item, index) => {
|
|
106
|
-
if (
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
251
|
+
if (newCheckedArray[index]) {
|
|
252
|
+
const tempCheckedArray = []
|
|
253
|
+
newCheckedArray[index].map((innerItem) => {
|
|
254
|
+
tempCheckedArray.push(innerItem.checked)
|
|
255
|
+
})
|
|
256
|
+
if (tempCheckedArray.every((i) => i)) {
|
|
257
|
+
item.checkBox.checked = true
|
|
258
|
+
} else {
|
|
259
|
+
item.checkBox.checked = false
|
|
260
|
+
}
|
|
110
261
|
}
|
|
262
|
+
return item
|
|
263
|
+
})
|
|
111
264
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
265
|
+
setHeader(newData)
|
|
266
|
+
setCheckedArray(newCheckedArray)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const handleCheckArrowAction = (item, rowPosition) => {
|
|
270
|
+
const status = item.status
|
|
271
|
+
const checkedOpenableRow = body[rowPosition].map((innerItem) => {
|
|
272
|
+
if (Object.prototype.hasOwnProperty.call(innerItem, 'status')) {
|
|
273
|
+
if (status === 'close') {
|
|
274
|
+
innerItem.status = 'open'
|
|
275
|
+
} else {
|
|
276
|
+
innerItem.status = 'close'
|
|
277
|
+
}
|
|
116
278
|
}
|
|
279
|
+
return innerItem
|
|
280
|
+
})
|
|
281
|
+
setBody((prev) => {
|
|
282
|
+
prev[rowPosition] = checkedOpenableRow
|
|
283
|
+
return [...prev]
|
|
284
|
+
})
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const handleOpenCloseRowSingleArrow = (arrowRowIndex, arrowIndex) => {
|
|
288
|
+
let single = {}
|
|
289
|
+
const allArrows = []
|
|
290
|
+
const checkedOpenableRow = body[arrowRowIndex].map((item, index) => {
|
|
291
|
+
if (index === arrowIndex) {
|
|
292
|
+
if (item.status === 'close') {
|
|
293
|
+
item.status = 'open'
|
|
294
|
+
} else {
|
|
295
|
+
item.status = 'close'
|
|
296
|
+
}
|
|
297
|
+
single = item
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (
|
|
301
|
+
Object.prototype.hasOwnProperty.call(item, 'status') &&
|
|
302
|
+
!Object.prototype.hasOwnProperty.call(item, 'arrowComponent')
|
|
303
|
+
) {
|
|
304
|
+
allArrows.push(item)
|
|
305
|
+
}
|
|
306
|
+
|
|
117
307
|
return item
|
|
118
308
|
})
|
|
119
|
-
|
|
309
|
+
|
|
310
|
+
const checkedOpenableRowArrow = checkedOpenableRow.map((item) => {
|
|
311
|
+
if (Object.prototype.hasOwnProperty.call(item, 'arrowComponent')) {
|
|
312
|
+
if (single && single.status === 'close') {
|
|
313
|
+
item.status = 'close'
|
|
314
|
+
} else if (single && single.status === 'open') {
|
|
315
|
+
if (allArrows.every((i) => i.status === 'open')) {
|
|
316
|
+
item.status = 'open'
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return item
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
setBody((prev) => {
|
|
324
|
+
prev[arrowRowIndex] = checkedOpenableRowArrow
|
|
325
|
+
return [...prev]
|
|
326
|
+
})
|
|
120
327
|
}
|
|
121
328
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
329
|
+
const handleCheckArrowActionHeader = (e, item) => {
|
|
330
|
+
e.stopPropagation()
|
|
331
|
+
const checkedOpenableAllRows = header.map((innerItem, innerIndex) => {
|
|
332
|
+
if (item.checkIndex === innerIndex) {
|
|
333
|
+
if (item.status === 'close') {
|
|
334
|
+
innerItem.status = 'open'
|
|
335
|
+
} else {
|
|
336
|
+
innerItem.status = 'close'
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return innerItem
|
|
340
|
+
})
|
|
341
|
+
|
|
342
|
+
const checkedOpenableAllRowsBody = body.map((innerItem) => {
|
|
343
|
+
return innerItem.map((iElem) => {
|
|
344
|
+
if (Object.prototype.hasOwnProperty.call(iElem, 'status')) {
|
|
345
|
+
if (item.status === 'open') {
|
|
346
|
+
iElem.status = 'open'
|
|
347
|
+
} else {
|
|
348
|
+
iElem.status = 'close'
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return iElem
|
|
352
|
+
})
|
|
353
|
+
})
|
|
354
|
+
setHeader(() => checkedOpenableAllRows)
|
|
355
|
+
setBody(() => checkedOpenableAllRowsBody)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const handleCheckDots = (e, item, index, innerIndex) => {
|
|
359
|
+
e.stopPropagation()
|
|
360
|
+
const checkBodyMore = body.map((elemItem, elemIndex) => {
|
|
361
|
+
return elemItem.map((elemInnerItem, elemInnerIndex) => {
|
|
362
|
+
if (elemIndex === index && Object.prototype.hasOwnProperty.call(elemInnerItem, 'dots')) {
|
|
363
|
+
if (elemInnerIndex === innerIndex) {
|
|
364
|
+
if (item.dotsStatus === 'deActive') {
|
|
365
|
+
elemInnerItem.dotsStatus = 'active'
|
|
366
|
+
} else {
|
|
367
|
+
elemInnerItem.dotsStatus = 'deActive'
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
} else if (elemIndex !== index && Object.prototype.hasOwnProperty.call(elemInnerItem, 'dots')) {
|
|
371
|
+
if (elemInnerIndex === innerIndex) {
|
|
372
|
+
elemInnerItem.dotsStatus = 'deActive'
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
return elemInnerItem
|
|
376
|
+
})
|
|
377
|
+
})
|
|
378
|
+
setBody(() => checkBodyMore)
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
const handleCheckDisable = (arr, disableArr) => {
|
|
382
|
+
let headerWithDisabled = []
|
|
383
|
+
if (disableArr && disableArr.length > 0) {
|
|
384
|
+
headerWithDisabled = arr.map((item, index) => {
|
|
385
|
+
if (disableArr[index]) {
|
|
386
|
+
if (Object.prototype.hasOwnProperty.call(item, 'checkBox')) {
|
|
387
|
+
item.checkBox.disabled = true
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
return item
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
return headerWithDisabled
|
|
394
|
+
}
|
|
125
395
|
|
|
126
396
|
useEffect(() => {
|
|
127
|
-
|
|
128
|
-
|
|
397
|
+
let checkedItems = []
|
|
398
|
+
const disabledArray = []
|
|
399
|
+
const checkBodyForChackedItems = dataBody.slice().map((item) => Object.values(item))
|
|
400
|
+
|
|
401
|
+
if (arrowShow) {
|
|
402
|
+
const arrowColumnCount = handleSetInsertIndex(checkBodyForChackedItems[0], arrowColumn)
|
|
403
|
+
|
|
404
|
+
const checkForInsertArrow = handleTransformDataForInsertArrow(
|
|
405
|
+
checkBodyForChackedItems,
|
|
406
|
+
arrowColumnCount,
|
|
407
|
+
'body'
|
|
408
|
+
)
|
|
409
|
+
|
|
410
|
+
checkForInsertArrow.map((item, index) => {
|
|
411
|
+
item.map((innerItem, innerIndex) => {
|
|
412
|
+
if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
|
|
413
|
+
if (Object.prototype.hasOwnProperty.call(innerItem.checkBox, 'disabled')) {
|
|
414
|
+
if (innerItem.checkBox.disabled === true) {
|
|
415
|
+
if (!disabledArray[innerIndex]) {
|
|
416
|
+
disabledArray[innerIndex] = { rowIndex: index, columnIndex: innerIndex }
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
})
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
checkedItems = handleSetCheckboxArray(checkForInsertArrow)
|
|
425
|
+
setBody(() => checkForInsertArrow)
|
|
426
|
+
} else {
|
|
427
|
+
checkedItems = handleSetCheckboxArray(checkBodyForChackedItems)
|
|
428
|
+
checkBodyForChackedItems.map((item, index) => {
|
|
429
|
+
item.map((innerItem, innerIndex) => {
|
|
430
|
+
if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
|
|
431
|
+
if (Object.prototype.hasOwnProperty.call(innerItem.checkBox, 'disabled')) {
|
|
432
|
+
if (innerItem.checkBox.disabled === true) {
|
|
433
|
+
if (!disabledArray[innerIndex]) {
|
|
434
|
+
disabledArray[innerIndex] = { rowIndex: index, columnIndex: innerIndex }
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
})
|
|
440
|
+
})
|
|
441
|
+
setBody(() => dataBody)
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
setDisableArr(disabledArray)
|
|
445
|
+
setCheckedArray(() => checkedItems)
|
|
446
|
+
}, [dataBody, arrowColumn, arrowShow])
|
|
129
447
|
|
|
130
448
|
useEffect(() => {
|
|
131
|
-
|
|
132
|
-
|
|
449
|
+
if (arrowShow) {
|
|
450
|
+
const header = dataHeader.slice()
|
|
451
|
+
|
|
452
|
+
const arrowColumnCount = handleSetInsertIndex(header, arrowColumn)
|
|
453
|
+
|
|
454
|
+
const checkForInsertArrow = handleTransformDataForInsertArrow(header, arrowColumnCount, 'header')
|
|
455
|
+
|
|
456
|
+
const headerWithDisabled = handleCheckDisable(checkForInsertArrow, disableArr)
|
|
457
|
+
|
|
458
|
+
setHeader(() => (headerWithDisabled.length > 0 ? headerWithDisabled : checkForInsertArrow))
|
|
459
|
+
} else {
|
|
460
|
+
const headerWithDisabled = handleCheckDisable(dataHeader, disableArr)
|
|
461
|
+
setHeader(() => (headerWithDisabled.length > 0 ? headerWithDisabled : dataHeader))
|
|
462
|
+
}
|
|
463
|
+
}, [dataHeader, arrowColumn, arrowShow, disableArr])
|
|
133
464
|
|
|
134
465
|
return (
|
|
135
466
|
<>
|
|
136
467
|
<table
|
|
137
468
|
style={{
|
|
138
|
-
width: '
|
|
469
|
+
width: '100%',
|
|
139
470
|
borderCollapse: 'collapse',
|
|
140
471
|
}}
|
|
141
472
|
>
|
|
@@ -154,10 +485,12 @@ const Table = ({
|
|
|
154
485
|
<TH
|
|
155
486
|
item={item}
|
|
156
487
|
key={`${item}_${index}`}
|
|
488
|
+
handleCheckedHeader={handleCheckedHeader}
|
|
489
|
+
handleHeaderItemClick={handleHeaderItemClick}
|
|
490
|
+
handleCheckArrowActionHeader={handleCheckArrowActionHeader}
|
|
157
491
|
tHeadFamily={tHeadFamily ? tHeadFamily : configStyles.TABLE.tHeadFamily}
|
|
158
|
-
handleCheckedHeader={handleCheckedHeader ? handleCheckedHeader : (_) => _}
|
|
159
492
|
tHeadPadding={tHeadPadding ? tHeadPadding : configStyles.TABLE.tHeadPadding}
|
|
160
|
-
|
|
493
|
+
tHeadFontSize={tHeadFontSize ? tHeadFontSize : configStyles.TABLE.tHeadFontSize}
|
|
161
494
|
tHeadFontWeight={
|
|
162
495
|
tHeadFontWeight ? tHeadFontWeight : configStyles.TABLE.tHeadFontWeight
|
|
163
496
|
}
|
|
@@ -202,20 +535,23 @@ const Table = ({
|
|
|
202
535
|
}}
|
|
203
536
|
>
|
|
204
537
|
{Object.values(item).map((innerItem, innerIndex) => {
|
|
205
|
-
console.log(innerItem, ' - - - - - >>>>')
|
|
206
538
|
return (
|
|
207
539
|
<TD
|
|
540
|
+
index={index}
|
|
208
541
|
item={innerItem}
|
|
542
|
+
innerIndex={innerIndex}
|
|
209
543
|
id={item.id ? item.id : ''}
|
|
210
|
-
|
|
211
|
-
|
|
544
|
+
handleCheckDots={handleCheckDots}
|
|
545
|
+
key={`${innerItem}_${index}_${innerIndex}`}
|
|
546
|
+
openListColor={
|
|
547
|
+
openListColor ? openListColor : configStyles.TABLE.openListColor
|
|
548
|
+
}
|
|
549
|
+
handleCheckedBody={handleCheckedBody}
|
|
550
|
+
handleBodyActionClick={handleBodyActionClick}
|
|
212
551
|
tBodyColor={tBodyColor ? tBodyColor : configStyles.TABLE.tBodyColor}
|
|
213
552
|
tBodyPadding={
|
|
214
553
|
tBodyPadding ? tBodyPadding : configStyles.TABLE.tBodyPadding
|
|
215
554
|
}
|
|
216
|
-
handleBodyActionClick={
|
|
217
|
-
handleBodyActionClick ? handleBodyActionClick : (_) => _
|
|
218
|
-
}
|
|
219
555
|
tBodyFontSize={
|
|
220
556
|
tBodyFontSize ? tBodyFontSize : configStyles.TABLE.tBodyFontSize
|
|
221
557
|
}
|
|
@@ -237,6 +573,8 @@ const Table = ({
|
|
|
237
573
|
? 'none'
|
|
238
574
|
: configStyles.TABLE.tBodyRowBorder
|
|
239
575
|
}
|
|
576
|
+
handleCheckArrowAction={handleCheckArrowAction}
|
|
577
|
+
handleOpenCloseRowSingleArrow={handleOpenCloseRowSingleArrow}
|
|
240
578
|
/>
|
|
241
579
|
)
|
|
242
580
|
})}
|
|
@@ -251,12 +589,16 @@ const Table = ({
|
|
|
251
589
|
}
|
|
252
590
|
|
|
253
591
|
Table.propTypes = {
|
|
592
|
+
getData: PropTypes.func,
|
|
254
593
|
dataBody: PropTypes.array,
|
|
594
|
+
arrowShow: PropTypes.bool,
|
|
255
595
|
dataHeader: PropTypes.array,
|
|
596
|
+
arrowColumn: PropTypes.number,
|
|
256
597
|
|
|
257
598
|
tHeadColor: PropTypes.string,
|
|
258
599
|
tHeadFamily: PropTypes.string,
|
|
259
600
|
tHeadPadding: PropTypes.string,
|
|
601
|
+
tHeadFontSize: PropTypes.string,
|
|
260
602
|
tHeadFontWeight: PropTypes.number,
|
|
261
603
|
tHeadBorderRadius: PropTypes.string,
|
|
262
604
|
tHeadBackgroundColor: PropTypes.string,
|
|
@@ -269,8 +611,5 @@ Table.propTypes = {
|
|
|
269
611
|
tBodyFontFamily: PropTypes.string,
|
|
270
612
|
|
|
271
613
|
tBodyRowBorder: PropTypes.string,
|
|
272
|
-
|
|
273
|
-
setTableDataHeader: PropTypes.func,
|
|
614
|
+
openListColor: PropTypes.string,
|
|
274
615
|
}
|
|
275
|
-
|
|
276
|
-
export default Table
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
.td-span {
|
|
18
18
|
position: relative;
|
|
19
19
|
display: inline-block;
|
|
20
|
-
cursor: pointer;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
.td-span > svg {
|
|
@@ -25,4 +24,43 @@
|
|
|
25
24
|
top: 0px;
|
|
26
25
|
left: 0px;
|
|
27
26
|
z-index: -1;
|
|
28
|
-
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.list-text {
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
text-align: left;
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
margin: 0px 0px 8px 0px;
|
|
35
|
+
text-overflow: ellipsis;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.dots-option-item {
|
|
39
|
+
display: flex;
|
|
40
|
+
position: relative;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 39px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
padding: 10px;
|
|
45
|
+
margin-bottom: 2px;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.dots-option-item::after {
|
|
50
|
+
content: '';
|
|
51
|
+
position: absolute;
|
|
52
|
+
top: calc(100% - 2px);
|
|
53
|
+
left: 10px;
|
|
54
|
+
height: 2px;
|
|
55
|
+
width: calc(100% - 20px);
|
|
56
|
+
background-color: #EEEEEE;
|
|
57
|
+
border-radius: 1px;
|
|
58
|
+
-webkit-border-radius: 1px;
|
|
59
|
+
-moz-border-radius: 1px;
|
|
60
|
+
-ms-border-radius: 1px;
|
|
61
|
+
-o-border-radius: 1px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.dots-option-item:last-child::after {
|
|
65
|
+
display: none;
|
|
66
|
+
}
|