@xaypay/tui 0.0.110 → 0.0.112

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,33 @@ 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
- color: openListColor
579
- }
580
- // TODO: add onClick
581
- }, innerItem);
611
+ color: openListColor,
612
+ maxWidth: (item.content.length * 9 <= 100 ? 100 : item.content.length * 9) + 'px'
613
+ },
614
+ onClick: e => handleContentListClick(e, {
615
+ item,
616
+ index,
617
+ innerIndex,
618
+ listContentId: innerItem.id,
619
+ listContent: innerItem.content,
620
+ listContentIndex: innerItemIndex
621
+ })
622
+ }, innerItem.content);
582
623
  })))) : '');
583
624
  };
584
625
 
@@ -661,6 +702,30 @@ const Table = ({
661
702
  const [disableArr, setDisableArr] = useState([]);
662
703
  const [checkedArray, setCheckedArray] = useState([]);
663
704
  const configStyles = compereConfigs();
705
+ const handleCheckIfArrow = (bodyData, data) => {
706
+ let removeItemIndex;
707
+ let headerWithoutArrow = [];
708
+ bodyData.map((item, index) => {
709
+ if (index === data.index) {
710
+ item.map((innerItem, innerIndex) => {
711
+ if (Object.prototype.hasOwnProperty.call(innerItem, 'arrowComponent')) {
712
+ removeItemIndex = innerIndex;
713
+ }
714
+ });
715
+ if (removeItemIndex !== undefined) {
716
+ const firstPart = item.slice(0, removeItemIndex);
717
+ const secondPart = item.slice(removeItemIndex + 1, item.length);
718
+ headerWithoutArrow = [...firstPart, ...secondPart];
719
+ } else {
720
+ headerWithoutArrow.push(item);
721
+ }
722
+ }
723
+ });
724
+ return {
725
+ removeItemIndex,
726
+ headerWithoutArrow
727
+ };
728
+ };
664
729
  const handleHeaderItemClick = e => {
665
730
  e.stopPropagation();
666
731
  if (!e.target.tagName.startsWith('svg') && e.target.innerText !== undefined && e.target.innerText !== '') {
@@ -686,19 +751,22 @@ const Table = ({
686
751
  };
687
752
  const handleBodyActionClick = (e, data) => {
688
753
  e.stopPropagation();
689
- // const dataRow =
690
-
754
+ const {
755
+ removeItemIndex,
756
+ headerWithoutArrow
757
+ } = handleCheckIfArrow(body, data);
691
758
  const actionData = {
692
- row: '',
759
+ from: 'body',
693
760
  item: data.item,
694
761
  id: data.item.id,
695
762
  items: data.items,
696
763
  type: data.item.type,
697
764
  rowIndex: data.index,
698
- itemIndex: data.innerIndex,
699
- itemInnerIndex: data.itemIndex
765
+ row: headerWithoutArrow,
766
+ itemInnerIndex: data.itemIndex,
767
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex
700
768
  };
701
- console.log(actionData);
769
+ getData(actionData);
702
770
  };
703
771
  const handleSetCheckboxArray = data => {
704
772
  let checkedItems = [];
@@ -779,7 +847,7 @@ const Table = ({
779
847
  const updatedHeader = header.slice();
780
848
  const updatedBody = body.slice().map(item => Object.values(item));
781
849
  const newData = updatedHeader.map((item, index) => {
782
- if (item.content === data.content) {
850
+ if (item.content == data.content) {
783
851
  checkableItemIndex = index;
784
852
  checkableItemBool = !item.checkBox.checked;
785
853
  item.checkBox.checked = !item.checkBox.checked;
@@ -824,12 +892,17 @@ const Table = ({
824
892
  setHeader(newData);
825
893
  setBody(newUpdatedBody);
826
894
  };
827
- const handleCheckedBody = (data, e) => {
895
+ const handleCheckedBody = (data, e, dataRowIndex, dataItemIndex) => {
828
896
  e.stopPropagation();
897
+ const transformedData = {
898
+ ...data
899
+ };
900
+ transformedData.index = dataRowIndex;
901
+ transformedData.innerIndex = dataItemIndex;
829
902
  const updatedBody = body.slice().map(item => Object.values(item));
830
903
  const newData = updatedBody.map((item, index) => {
831
904
  return item.map((innerItem, innerIndex) => {
832
- if (innerItem.id === data.id && innerItem.content === data.content && innerItem.checkBox) {
905
+ if (innerItem.id === data.id && innerItem.content == data.content && Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
833
906
  innerItem.checkBox.checked = !innerItem.checkBox.checked;
834
907
  handleHeaderCheckedUpdate({
835
908
  row: index,
@@ -840,6 +913,18 @@ const Table = ({
840
913
  return innerItem;
841
914
  });
842
915
  });
916
+ const {
917
+ removeItemIndex,
918
+ headerWithoutArrow
919
+ } = handleCheckIfArrow(body, transformedData);
920
+ const checkedData = {
921
+ item: data,
922
+ from: 'body',
923
+ row: removeItemIndex !== undefined ? headerWithoutArrow : headerWithoutArrow[0],
924
+ rowIndex: transformedData.index,
925
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < transformedData.innerIndex ? transformedData.innerIndex - 1 : transformedData.innerIndex
926
+ };
927
+ getData(checkedData);
843
928
  setBody(newData);
844
929
  };
845
930
  const handleHeaderCheckedUpdate = checkedData => {
@@ -985,6 +1070,52 @@ const Table = ({
985
1070
  }
986
1071
  return headerWithDisabled;
987
1072
  };
1073
+ const handleContentListClick = (e, data) => {
1074
+ e.stopPropagation();
1075
+ const {
1076
+ removeItemIndex,
1077
+ headerWithoutArrow
1078
+ } = handleCheckIfArrow(body, data);
1079
+ const listData = {
1080
+ from: 'body',
1081
+ item: data.item,
1082
+ rowIndex: data.index,
1083
+ row: headerWithoutArrow,
1084
+ listItemId: data.listContentId,
1085
+ listItemContent: data.listContent,
1086
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex,
1087
+ listItemInnerIndex: data.listContentIndex
1088
+ };
1089
+ getData(listData);
1090
+ };
1091
+ const handleMoreOptionsClick = data => {
1092
+ const {
1093
+ removeItemIndex,
1094
+ headerWithoutArrow
1095
+ } = handleCheckIfArrow(body, data);
1096
+ const moreData = {
1097
+ from: 'body',
1098
+ item: data.item,
1099
+ rowIndex: data.index,
1100
+ options: data.options,
1101
+ row: headerWithoutArrow,
1102
+ itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex,
1103
+ optionItem: data.optionItem,
1104
+ optionIndex: data.optionIndex
1105
+ };
1106
+ getData(moreData);
1107
+ };
1108
+ const handleTableClick = () => {
1109
+ const checkBodyMore = body.map(elemItem => {
1110
+ return elemItem.map(elemInnerItem => {
1111
+ if (Object.prototype.hasOwnProperty.call(elemInnerItem, 'dots')) {
1112
+ elemInnerItem.dotsStatus = 'deActive';
1113
+ }
1114
+ return elemInnerItem;
1115
+ });
1116
+ });
1117
+ setBody(() => checkBodyMore);
1118
+ };
988
1119
  useEffect(() => {
989
1120
  let checkedItems = [];
990
1121
  const disabledArray = [];
@@ -992,7 +1123,7 @@ const Table = ({
992
1123
  if (arrowShow) {
993
1124
  const arrowColumnCount = handleSetInsertIndex(checkBodyForChackedItems[0], arrowColumn);
994
1125
  const checkForInsertArrow = handleTransformDataForInsertArrow(checkBodyForChackedItems, arrowColumnCount, 'body');
995
- checkForInsertArrow.map((item, index) => {
1126
+ const insert = checkForInsertArrow.map((item, index) => {
996
1127
  item.map((innerItem, innerIndex) => {
997
1128
  if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
998
1129
  if (Object.prototype.hasOwnProperty.call(innerItem.checkBox, 'disabled')) {
@@ -1007,12 +1138,12 @@ const Table = ({
1007
1138
  }
1008
1139
  }
1009
1140
  });
1141
+ return item;
1010
1142
  });
1011
- checkedItems = handleSetCheckboxArray(checkForInsertArrow);
1012
- setBody(() => checkForInsertArrow);
1143
+ checkedItems = handleSetCheckboxArray(insert);
1144
+ setBody(() => insert);
1013
1145
  } else {
1014
- checkedItems = handleSetCheckboxArray(checkBodyForChackedItems);
1015
- checkBodyForChackedItems.map((item, index) => {
1146
+ const insert = checkBodyForChackedItems.map((item, index) => {
1016
1147
  item.map((innerItem, innerIndex) => {
1017
1148
  if (Object.prototype.hasOwnProperty.call(innerItem, 'checkBox')) {
1018
1149
  if (Object.prototype.hasOwnProperty.call(innerItem.checkBox, 'disabled')) {
@@ -1027,8 +1158,10 @@ const Table = ({
1027
1158
  }
1028
1159
  }
1029
1160
  });
1161
+ return item;
1030
1162
  });
1031
- setBody(() => dataBody);
1163
+ checkedItems = handleSetCheckboxArray(insert);
1164
+ setBody(() => insert);
1032
1165
  }
1033
1166
  setDisableArr(disabledArray);
1034
1167
  setCheckedArray(() => checkedItems);
@@ -1049,7 +1182,8 @@ const Table = ({
1049
1182
  style: {
1050
1183
  width: '100%',
1051
1184
  borderCollapse: 'collapse'
1052
- }
1185
+ },
1186
+ onClick: handleTableClick
1053
1187
  }, header && header.length > 0 && /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", {
1054
1188
  style: {
1055
1189
  color: tHeadColor ? tHeadColor : configStyles.TABLE.tHeadColor,
@@ -1090,6 +1224,8 @@ const Table = ({
1090
1224
  openListColor: openListColor ? openListColor : configStyles.TABLE.openListColor,
1091
1225
  handleCheckedBody: handleCheckedBody,
1092
1226
  handleBodyActionClick: handleBodyActionClick,
1227
+ handleMoreOptionsClick: handleMoreOptionsClick,
1228
+ handleContentListClick: handleContentListClick,
1093
1229
  tBodyColor: tBodyColor ? tBodyColor : configStyles.TABLE.tBodyColor,
1094
1230
  tBodyPadding: tBodyPadding ? tBodyPadding : configStyles.TABLE.tBodyPadding,
1095
1231
  tBodyFontSize: tBodyFontSize ? tBodyFontSize : configStyles.TABLE.tBodyFontSize,
@@ -4266,6 +4402,9 @@ const Textarea = ({
4266
4402
  if (!onChange) {
4267
4403
  alert('Please add onChange function on Textarea component');
4268
4404
  }
4405
+ if (value === '') {
4406
+ setError('');
4407
+ }
4269
4408
  setInnerValue(value);
4270
4409
  }, [value, onChange]);
4271
4410
  useEffect(() => {