@xaypay/tui 0.0.110 → 0.0.111

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 CHANGED
@@ -269,9 +269,11 @@ const SvgCheckboxChecked = ({
269
269
 
270
270
  const Checkbox$1 = ({
271
271
  data,
272
+ index,
272
273
  styles,
273
274
  checked,
274
275
  disabled,
276
+ innerIndex,
275
277
  checkedColor,
276
278
  handleChecked,
277
279
  unCheckedColor,
@@ -281,7 +283,11 @@ const Checkbox$1 = ({
281
283
  const [innerChecked, setInnerChecked] = useState(false);
282
284
  const [innerDisabled, setInnerDisabled] = useState(false);
283
285
  const handleClick = e => {
284
- handleChecked(data, e);
286
+ if (index !== undefined && innerIndex !== undefined && typeof index === 'number' && typeof innerIndex === 'number') {
287
+ handleChecked(data, e, index, innerIndex);
288
+ } else {
289
+ handleChecked(data, e);
290
+ }
285
291
  };
286
292
  useEffect(() => {
287
293
  setInnerDisabled(disabled);
@@ -308,9 +314,11 @@ const Checkbox$1 = ({
308
314
 
309
315
  const SingleCheckbox = ({
310
316
  data,
317
+ index,
311
318
  styles,
312
319
  checked,
313
320
  disabled,
321
+ innerIndex,
314
322
  checkedColor,
315
323
  handleChecked,
316
324
  unCheckedColor,
@@ -330,10 +338,12 @@ const SingleCheckbox = ({
330
338
  setInnerData(data);
331
339
  }, [data]);
332
340
  return /*#__PURE__*/React__default.createElement(Checkbox$1, {
341
+ index: index,
333
342
  styles: styles,
334
343
  data: innerData,
335
344
  checked: checked,
336
345
  disabled: disabled,
346
+ innerIndex: innerIndex,
337
347
  checkedColor: checkedColor,
338
348
  handleChecked: handleChecked,
339
349
  unCheckedColor: unCheckedColor,
@@ -343,8 +353,10 @@ const SingleCheckbox = ({
343
353
  SingleCheckbox.propTypes = {
344
354
  data: PropTypes.object,
345
355
  onClick: PropTypes.func,
356
+ index: PropTypes.number,
346
357
  styles: PropTypes.object,
347
358
  disabled: PropTypes.bool,
359
+ innerIndex: PropTypes.number,
348
360
  checkedColor: PropTypes.string,
349
361
  unCheckedColor: PropTypes.string,
350
362
  ignoreDisabledForChecked: PropTypes.bool
@@ -419,9 +431,21 @@ const TD = ({
419
431
  handleCheckDots,
420
432
  handleCheckedBody,
421
433
  handleBodyActionClick,
434
+ handleMoreOptionsClick,
435
+ handleContentListClick,
422
436
  handleCheckArrowAction,
423
437
  handleOpenCloseRowSingleArrow
424
438
  }) => {
439
+ const handleBodyAction = (e, data) => {
440
+ const actionData = {
441
+ index,
442
+ innerIndex,
443
+ items: item,
444
+ item: data.item,
445
+ itemIndex: data.itemIndex
446
+ };
447
+ handleBodyActionClick(e, actionData);
448
+ };
425
449
  return /*#__PURE__*/React__default.createElement("td", {
426
450
  style: {
427
451
  width: 'auto',
@@ -434,7 +458,7 @@ const TD = ({
434
458
  textAlign: tBodyTextAlign,
435
459
  fontFamily: tBodyFontFamily,
436
460
  fontWeight: tBodyFontWeight,
437
- boxShadow: item.colorStatus ? `inset 3px 0px 0px 0px ${item.colorStatus}` : ''
461
+ boxShadow: Object.prototype.hasOwnProperty.call(item, 'colorStatus') ? `inset 3px 0px 0px 0px ${item.colorStatus}` : ''
438
462
  }
439
463
  }, Array.isArray(item) ? item.length > 0 ? item.map((newItem, newIndex) => {
440
464
  if (newItem && !Array.isArray(newItem) && typeof newItem === 'object') {
@@ -449,10 +473,9 @@ const TD = ({
449
473
  type: newItem.type,
450
474
  className: styles$c['td-span'],
451
475
  key: `${newItem.id}_${newIndex}`,
452
- onClick: Object.prototype.hasOwnProperty.call(newItem, 'type') ? e => handleBodyActionClick(e, {
453
- item,
454
- index,
455
- innerIndex
476
+ onClick: Object.prototype.hasOwnProperty.call(newItem, 'type') ? e => handleBodyAction(e, {
477
+ item: newItem,
478
+ itemIndex: newIndex
456
479
  }) : _ => _
457
480
  }, newItem.content);
458
481
  } else if (newItem && Array.isArray(newItem)) {
@@ -474,10 +497,7 @@ const TD = ({
474
497
  id: iT.id ? iT.id : '',
475
498
  type: iT.type ? iT.type : '',
476
499
  className: styles$c['td-span'],
477
- onClick: Object.prototype.hasOwnProperty.call(iT, 'type') ? e => handleBodyActionClick(e, {
478
- index,
479
- innerIndex,
480
- items: item,
500
+ onClick: Object.prototype.hasOwnProperty.call(iT, 'type') ? e => handleBodyAction(e, {
481
501
  item: iT,
482
502
  itemIndex: iN
483
503
  }) : _ => _,
@@ -493,20 +513,23 @@ const TD = ({
493
513
  style: {
494
514
  display: 'flex',
495
515
  alignItems: 'flex-start',
496
- justifyContent: item.contentList || item.checkBox ? 'space-between' : 'center'
516
+ justifyContent: Object.prototype.hasOwnProperty.call(item, 'contentList') || Object.prototype.hasOwnProperty.call(item, 'checkBox') ? 'space-between' : 'center'
497
517
  }
498
- }, item.contentList && /*#__PURE__*/React__default.createElement("div", {
518
+ }, Object.prototype.hasOwnProperty.call(item, 'contentList') && /*#__PURE__*/React__default.createElement("div", {
499
519
  id: item.id,
500
520
  style: {
501
521
  width: '21px',
502
- height: '21px'
522
+ height: '21px',
523
+ cursor: 'pointer'
503
524
  },
504
525
  onClick: () => handleOpenCloseRowSingleArrow(index, innerIndex),
505
526
  className: styles$c['td-span']
506
- }, item.status === 'close' ? item.closeArrow : item.openArrow), item.checkBox && /*#__PURE__*/React__default.createElement(SingleCheckbox, {
527
+ }, item.status === 'close' ? item.closeArrow : item.openArrow), Object.prototype.hasOwnProperty.call(item, 'checkBox') && /*#__PURE__*/React__default.createElement(SingleCheckbox, {
507
528
  data: item,
508
- handleChecked: handleCheckedBody,
529
+ index: index,
530
+ innerIndex: innerIndex,
509
531
  checked: item.checkBox.checked,
532
+ handleChecked: handleCheckedBody,
510
533
  disabled: item.checkBox.disabled,
511
534
  checkedColor: item.checkBox.checkedColor,
512
535
  unCheckedColor: item.checkBox.unCheckedColor
@@ -530,6 +553,7 @@ const TD = ({
530
553
  position: 'absolute',
531
554
  display: item.dotsStatus === 'deActive' ? 'none' : 'block',
532
555
  top: '0px',
556
+ zIndex: 100,
533
557
  right: 'calc(100% + 6px)',
534
558
  width: '223px',
535
559
  height: 'auto',
@@ -540,21 +564,28 @@ const TD = ({
540
564
  backgroundColor: '#FFFFFF',
541
565
  boxShadow: '0px 0px 20px 0px #3C393E4D'
542
566
  }
543
- }, item.options && item.options.map((item, index) => {
567
+ }, Object.prototype.hasOwnProperty.call(item, 'options') && item.options.map((optionItem, optionIndex) => {
544
568
  return /*#__PURE__*/React__default.createElement("span", {
545
- key: `${item.content}_${index}`,
569
+ key: `${optionItem.content}_${optionIndex}`,
546
570
  className: styles$c['dots-option-item'],
547
571
  style: {
548
572
  color: '#3C393E',
549
573
  fontSize: '14px',
550
574
  fontFamily: 'Noto Sans Armenian'
551
- }
552
- // TODO: onClick
575
+ },
576
+ onClick: () => handleMoreOptionsClick({
577
+ item,
578
+ index,
579
+ optionItem,
580
+ innerIndex,
581
+ optionIndex,
582
+ options: item.options
583
+ })
553
584
  }, /*#__PURE__*/React__default.createElement("span", {
554
585
  style: {
555
586
  marginRight: '10px'
556
587
  }
557
- }, item.icon), /*#__PURE__*/React__default.createElement("span", {
588
+ }, optionItem.icon), /*#__PURE__*/React__default.createElement("span", {
558
589
  style: {
559
590
  width: 'calc(100% - 36px)',
560
591
  textAlign: 'left',
@@ -562,23 +593,32 @@ const TD = ({
562
593
  whiteSpace: 'nowrap',
563
594
  textOverflow: 'ellipsis'
564
595
  },
565
- title: item.content
566
- }, item.content));
567
- }))) : ''), item.contentList && /*#__PURE__*/React__default.createElement("div", {
596
+ title: optionItem.content
597
+ }, optionItem.content));
598
+ }))) : ''), Object.prototype.hasOwnProperty.call(item, 'contentList') && /*#__PURE__*/React__default.createElement("div", {
568
599
  style: {
569
- overflow: 'hidden',
600
+ overflow: 'auto',
570
601
  marginTop: '10px',
602
+ maxHeight: '300px',
603
+ maxWidth: '100%',
571
604
  height: item.status === 'close' ? '0px' : 'auto'
572
605
  }
573
- }, item.contentList.map((innerItem, innerIndex) => {
606
+ }, item.contentList.map((innerItem, innerItemIndex) => {
574
607
  return /*#__PURE__*/React__default.createElement("p", {
575
- key: `${innerItem}_${innerIndex}`,
608
+ key: `${innerItem}_${innerItemIndex}`,
576
609
  className: styles$c['list-text'],
577
610
  style: {
578
611
  color: openListColor
579
- }
580
- // TODO: add onClick
581
- }, innerItem);
612
+ },
613
+ onClick: e => handleContentListClick(e, {
614
+ item,
615
+ index,
616
+ innerIndex,
617
+ listContentId: innerItem.id,
618
+ listContent: innerItem.content,
619
+ listContentIndex: innerItemIndex
620
+ })
621
+ }, innerItem.content.length >= item.content.length ? innerItem.content.substr(0, item.content.length - 4) + '...' : innerItem.content);
582
622
  })))) : '');
583
623
  };
584
624
 
@@ -661,6 +701,30 @@ const Table = ({
661
701
  const [disableArr, setDisableArr] = useState([]);
662
702
  const [checkedArray, setCheckedArray] = useState([]);
663
703
  const configStyles = compereConfigs();
704
+ const handleCheckIfArrow = (bodyData, data) => {
705
+ let removeItemIndex;
706
+ let headerWithoutArrow = [];
707
+ bodyData.map((item, index) => {
708
+ if (index === data.index) {
709
+ item.map((innerItem, innerIndex) => {
710
+ if (Object.prototype.hasOwnProperty.call(innerItem, 'arrowComponent')) {
711
+ removeItemIndex = innerIndex;
712
+ }
713
+ });
714
+ if (removeItemIndex !== undefined) {
715
+ const firstPart = item.slice(0, removeItemIndex);
716
+ const secondPart = item.slice(removeItemIndex + 1, item.length);
717
+ headerWithoutArrow = [...firstPart, ...secondPart];
718
+ } else {
719
+ headerWithoutArrow.push(item);
720
+ }
721
+ }
722
+ });
723
+ return {
724
+ removeItemIndex,
725
+ headerWithoutArrow
726
+ };
727
+ };
664
728
  const handleHeaderItemClick = e => {
665
729
  e.stopPropagation();
666
730
  if (!e.target.tagName.startsWith('svg') && e.target.innerText !== undefined && e.target.innerText !== '') {
@@ -686,19 +750,22 @@ const Table = ({
686
750
  };
687
751
  const handleBodyActionClick = (e, data) => {
688
752
  e.stopPropagation();
689
- // const dataRow =
690
-
753
+ const {
754
+ removeItemIndex,
755
+ headerWithoutArrow
756
+ } = handleCheckIfArrow(body, data);
691
757
  const actionData = {
692
- row: '',
758
+ from: 'body',
693
759
  item: data.item,
694
760
  id: data.item.id,
695
761
  items: data.items,
696
762
  type: data.item.type,
697
763
  rowIndex: data.index,
698
- itemIndex: data.innerIndex,
699
- itemInnerIndex: data.itemIndex
764
+ row: headerWithoutArrow,
765
+ itemInnerIndex: data.itemIndex,
766
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex
700
767
  };
701
- console.log(actionData);
768
+ getData(actionData);
702
769
  };
703
770
  const handleSetCheckboxArray = data => {
704
771
  let checkedItems = [];
@@ -779,7 +846,7 @@ const Table = ({
779
846
  const updatedHeader = header.slice();
780
847
  const updatedBody = body.slice().map(item => Object.values(item));
781
848
  const newData = updatedHeader.map((item, index) => {
782
- if (item.content === data.content) {
849
+ if (item.content == data.content) {
783
850
  checkableItemIndex = index;
784
851
  checkableItemBool = !item.checkBox.checked;
785
852
  item.checkBox.checked = !item.checkBox.checked;
@@ -824,12 +891,17 @@ const Table = ({
824
891
  setHeader(newData);
825
892
  setBody(newUpdatedBody);
826
893
  };
827
- const handleCheckedBody = (data, e) => {
894
+ const handleCheckedBody = (data, e, dataRowIndex, dataItemIndex) => {
828
895
  e.stopPropagation();
896
+ const transformedData = {
897
+ ...data
898
+ };
899
+ transformedData.index = dataRowIndex;
900
+ transformedData.innerIndex = dataItemIndex;
829
901
  const updatedBody = body.slice().map(item => Object.values(item));
830
902
  const newData = updatedBody.map((item, index) => {
831
903
  return item.map((innerItem, innerIndex) => {
832
- if (innerItem.id === data.id && innerItem.content === data.content && innerItem.checkBox) {
904
+ if (innerItem.id === data.id && innerItem.content == data.content && Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
833
905
  innerItem.checkBox.checked = !innerItem.checkBox.checked;
834
906
  handleHeaderCheckedUpdate({
835
907
  row: index,
@@ -840,6 +912,18 @@ const Table = ({
840
912
  return innerItem;
841
913
  });
842
914
  });
915
+ const {
916
+ removeItemIndex,
917
+ headerWithoutArrow
918
+ } = handleCheckIfArrow(body, transformedData);
919
+ const checkedData = {
920
+ item: data,
921
+ from: 'body',
922
+ row: removeItemIndex !== undefined ? headerWithoutArrow : headerWithoutArrow[0],
923
+ rowIndex: transformedData.index,
924
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < transformedData.innerIndex ? transformedData.innerIndex - 1 : transformedData.innerIndex
925
+ };
926
+ getData(checkedData);
843
927
  setBody(newData);
844
928
  };
845
929
  const handleHeaderCheckedUpdate = checkedData => {
@@ -985,6 +1069,41 @@ const Table = ({
985
1069
  }
986
1070
  return headerWithDisabled;
987
1071
  };
1072
+ const handleContentListClick = (e, data) => {
1073
+ e.stopPropagation();
1074
+ const {
1075
+ removeItemIndex,
1076
+ headerWithoutArrow
1077
+ } = handleCheckIfArrow(body, data);
1078
+ const listData = {
1079
+ from: 'body',
1080
+ item: data.item,
1081
+ rowIndex: data.index,
1082
+ row: headerWithoutArrow,
1083
+ listItemId: data.listContentId,
1084
+ listItemContent: data.listContent,
1085
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex,
1086
+ listItemInnerIndex: data.listContentIndex
1087
+ };
1088
+ getData(listData);
1089
+ };
1090
+ const handleMoreOptionsClick = data => {
1091
+ const {
1092
+ removeItemIndex,
1093
+ headerWithoutArrow
1094
+ } = handleCheckIfArrow(body, data);
1095
+ const moreData = {
1096
+ from: 'body',
1097
+ item: data.item,
1098
+ rowIndex: data.index,
1099
+ options: data.options,
1100
+ row: headerWithoutArrow,
1101
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex,
1102
+ optionItem: data.optionItem,
1103
+ optionIndex: data.optionIndex
1104
+ };
1105
+ getData(moreData);
1106
+ };
988
1107
  useEffect(() => {
989
1108
  let checkedItems = [];
990
1109
  const disabledArray = [];
@@ -992,7 +1111,7 @@ const Table = ({
992
1111
  if (arrowShow) {
993
1112
  const arrowColumnCount = handleSetInsertIndex(checkBodyForChackedItems[0], arrowColumn);
994
1113
  const checkForInsertArrow = handleTransformDataForInsertArrow(checkBodyForChackedItems, arrowColumnCount, 'body');
995
- checkForInsertArrow.map((item, index) => {
1114
+ const insert = checkForInsertArrow.map((item, index) => {
996
1115
  item.map((innerItem, innerIndex) => {
997
1116
  if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
998
1117
  if (Object.prototype.hasOwnProperty.call(innerItem.checkBox, 'disabled')) {
@@ -1007,12 +1126,12 @@ const Table = ({
1007
1126
  }
1008
1127
  }
1009
1128
  });
1129
+ return item;
1010
1130
  });
1011
- checkedItems = handleSetCheckboxArray(checkForInsertArrow);
1012
- setBody(() => checkForInsertArrow);
1131
+ checkedItems = handleSetCheckboxArray(insert);
1132
+ setBody(() => insert);
1013
1133
  } else {
1014
- checkedItems = handleSetCheckboxArray(checkBodyForChackedItems);
1015
- checkBodyForChackedItems.map((item, index) => {
1134
+ const insert = checkBodyForChackedItems.map((item, index) => {
1016
1135
  item.map((innerItem, innerIndex) => {
1017
1136
  if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
1018
1137
  if (Object.prototype.hasOwnProperty.call(innerItem.checkBox, 'disabled')) {
@@ -1027,8 +1146,10 @@ const Table = ({
1027
1146
  }
1028
1147
  }
1029
1148
  });
1149
+ return item;
1030
1150
  });
1031
- setBody(() => dataBody);
1151
+ checkedItems = handleSetCheckboxArray(insert);
1152
+ setBody(() => insert);
1032
1153
  }
1033
1154
  setDisableArr(disabledArray);
1034
1155
  setCheckedArray(() => checkedItems);
@@ -1090,6 +1211,8 @@ const Table = ({
1090
1211
  openListColor: openListColor ? openListColor : configStyles.TABLE.openListColor,
1091
1212
  handleCheckedBody: handleCheckedBody,
1092
1213
  handleBodyActionClick: handleBodyActionClick,
1214
+ handleMoreOptionsClick: handleMoreOptionsClick,
1215
+ handleContentListClick: handleContentListClick,
1093
1216
  tBodyColor: tBodyColor ? tBodyColor : configStyles.TABLE.tBodyColor,
1094
1217
  tBodyPadding: tBodyPadding ? tBodyPadding : configStyles.TABLE.tBodyPadding,
1095
1218
  tBodyFontSize: tBodyFontSize ? tBodyFontSize : configStyles.TABLE.tBodyFontSize,
@@ -3245,7 +3368,7 @@ for (let i = 0; i < 256; ++i) {
3245
3368
  function unsafeStringify(arr, offset = 0) {
3246
3369
  // Note: Be careful editing this code! It's been tuned for performance
3247
3370
  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
3248
- return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
3371
+ return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
3249
3372
  }
3250
3373
 
3251
3374
  const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);