@xaypay/tui 0.0.111 → 0.0.113
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 +184 -82
- package/dist/index.js +184 -82
- package/package.json +1 -1
- package/src/components/input/index.js +24 -0
- package/src/components/input/input.stories.js +0 -2
- package/src/components/modal/index.js +2 -3
- package/src/components/newAutocomplete/index.js +2 -3
- package/src/components/newFile/fileItem.js +1 -0
- package/src/components/newFile/index.js +84 -12
- package/src/components/newFile/newFile.stories.js +2 -1
- package/src/components/select/index.js +2 -3
- package/src/components/table/index.js +30 -20
- package/src/components/table/table.stories.js +1 -10
- package/src/components/table/td.js +61 -50
- package/src/components/table/th.js +12 -8
- package/src/components/textarea/index.js +4 -6
- package/src/components/typography/index.js +1 -1
- package/src/utils/index.js +4 -0
package/dist/index.es.js
CHANGED
|
@@ -224,6 +224,9 @@ const compereConfigs = () => {
|
|
|
224
224
|
|
|
225
225
|
return _.merge(packageConfig, projectConfig);
|
|
226
226
|
};
|
|
227
|
+
const hasOwnerProperty = (object, property) => {
|
|
228
|
+
return Object.prototype.hasOwnProperty.call(object, property);
|
|
229
|
+
};
|
|
227
230
|
|
|
228
231
|
const SvgCheckboxUnchecked = ({
|
|
229
232
|
title,
|
|
@@ -379,6 +382,11 @@ const TH = ({
|
|
|
379
382
|
handleHeaderItemClick,
|
|
380
383
|
handleCheckArrowActionHeader
|
|
381
384
|
}) => {
|
|
385
|
+
const handleCheckArrowAction = (e, object, property) => {
|
|
386
|
+
if (hasOwnerProperty(object, property)) {
|
|
387
|
+
handleCheckArrowActionHeader(e, object);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
382
390
|
return /*#__PURE__*/React__default.createElement("th", {
|
|
383
391
|
style: {
|
|
384
392
|
width: 'auto',
|
|
@@ -398,9 +406,9 @@ const TH = ({
|
|
|
398
406
|
style: {
|
|
399
407
|
display: 'flex',
|
|
400
408
|
alignItems: 'flex-start',
|
|
401
|
-
justifyContent:
|
|
409
|
+
justifyContent: hasOwnerProperty(item, 'checkBox') ? 'space-between' : 'center'
|
|
402
410
|
}
|
|
403
|
-
}, item
|
|
411
|
+
}, hasOwnerProperty(item, 'checkBox') ? /*#__PURE__*/React__default.createElement(SingleCheckbox, {
|
|
404
412
|
data: item,
|
|
405
413
|
float: "left",
|
|
406
414
|
checked: item.checkBox.checked,
|
|
@@ -412,8 +420,8 @@ const TH = ({
|
|
|
412
420
|
style: {
|
|
413
421
|
margin: '0px'
|
|
414
422
|
},
|
|
415
|
-
onClick:
|
|
416
|
-
}, item.type === 'show' ? item.content :
|
|
423
|
+
onClick: e => handleCheckArrowAction(e, item, 'arrowComponent')
|
|
424
|
+
}, item.type === 'show' ? item.content : hasOwnerProperty(item, 'arrowComponent') ? item.status === 'close' ? item.closeArrow : item.openArrow : '')));
|
|
417
425
|
};
|
|
418
426
|
|
|
419
427
|
const TD = ({
|
|
@@ -446,6 +454,34 @@ const TD = ({
|
|
|
446
454
|
};
|
|
447
455
|
handleBodyActionClick(e, actionData);
|
|
448
456
|
};
|
|
457
|
+
const handleCheckActions = (e, object, property, objectIndex) => {
|
|
458
|
+
if (hasOwnerProperty(object, property)) {
|
|
459
|
+
handleBodyAction(e, {
|
|
460
|
+
item: object,
|
|
461
|
+
itemIndex: objectIndex
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
};
|
|
465
|
+
const handleMoreOptions = (item, index, optionItem, innerIndex, optionIndex, options) => {
|
|
466
|
+
handleMoreOptionsClick({
|
|
467
|
+
item,
|
|
468
|
+
index,
|
|
469
|
+
options,
|
|
470
|
+
optionItem,
|
|
471
|
+
innerIndex,
|
|
472
|
+
optionIndex
|
|
473
|
+
});
|
|
474
|
+
};
|
|
475
|
+
const handleContentList = (e, item, index, innerIndex, listContentId, listContent, listContentIndex) => {
|
|
476
|
+
handleContentListClick(e, {
|
|
477
|
+
item,
|
|
478
|
+
index,
|
|
479
|
+
innerIndex,
|
|
480
|
+
listContentId,
|
|
481
|
+
listContent,
|
|
482
|
+
listContentIndex
|
|
483
|
+
});
|
|
484
|
+
};
|
|
449
485
|
return /*#__PURE__*/React__default.createElement("td", {
|
|
450
486
|
style: {
|
|
451
487
|
width: 'auto',
|
|
@@ -458,7 +494,7 @@ const TD = ({
|
|
|
458
494
|
textAlign: tBodyTextAlign,
|
|
459
495
|
fontFamily: tBodyFontFamily,
|
|
460
496
|
fontWeight: tBodyFontWeight,
|
|
461
|
-
boxShadow:
|
|
497
|
+
boxShadow: hasOwnerProperty(item, 'colorStatus') ? `inset 3px 0px 0px 0px ${item.colorStatus}` : ''
|
|
462
498
|
}
|
|
463
499
|
}, Array.isArray(item) ? item.length > 0 ? item.map((newItem, newIndex) => {
|
|
464
500
|
if (newItem && !Array.isArray(newItem) && typeof newItem === 'object') {
|
|
@@ -467,16 +503,13 @@ const TD = ({
|
|
|
467
503
|
width: '32px',
|
|
468
504
|
height: '32px',
|
|
469
505
|
marginRight: '10px',
|
|
470
|
-
cursor:
|
|
506
|
+
cursor: hasOwnerProperty(newItem, 'type') ? 'pointer' : 'auto'
|
|
471
507
|
},
|
|
472
508
|
id: newItem.id,
|
|
473
509
|
type: newItem.type,
|
|
474
510
|
className: styles$c['td-span'],
|
|
475
511
|
key: `${newItem.id}_${newIndex}`,
|
|
476
|
-
onClick:
|
|
477
|
-
item: newItem,
|
|
478
|
-
itemIndex: newIndex
|
|
479
|
-
}) : _ => _
|
|
512
|
+
onClick: e => handleCheckActions(e, newItem, 'type', newIndex)
|
|
480
513
|
}, newItem.content);
|
|
481
514
|
} else if (newItem && Array.isArray(newItem)) {
|
|
482
515
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
@@ -492,15 +525,12 @@ const TD = ({
|
|
|
492
525
|
width: '32px',
|
|
493
526
|
height: '32px',
|
|
494
527
|
marginRight: '10px',
|
|
495
|
-
cursor:
|
|
528
|
+
cursor: hasOwnerProperty(iT, 'type') ? 'pointer' : 'auto'
|
|
496
529
|
},
|
|
497
530
|
id: iT.id ? iT.id : '',
|
|
498
531
|
type: iT.type ? iT.type : '',
|
|
499
532
|
className: styles$c['td-span'],
|
|
500
|
-
onClick:
|
|
501
|
-
item: iT,
|
|
502
|
-
itemIndex: iN
|
|
503
|
-
}) : _ => _,
|
|
533
|
+
onClick: e => handleCheckActions(e, iT, 'type', iN),
|
|
504
534
|
key: `${iT.id || iT.content}_${iN}`
|
|
505
535
|
}, iT.content);
|
|
506
536
|
}));
|
|
@@ -513,9 +543,9 @@ const TD = ({
|
|
|
513
543
|
style: {
|
|
514
544
|
display: 'flex',
|
|
515
545
|
alignItems: 'flex-start',
|
|
516
|
-
justifyContent:
|
|
546
|
+
justifyContent: hasOwnerProperty(item, 'contentList') || hasOwnerProperty(item, 'checkBox') ? 'space-between' : 'center'
|
|
517
547
|
}
|
|
518
|
-
},
|
|
548
|
+
}, hasOwnerProperty(item, 'contentList') && /*#__PURE__*/React__default.createElement("div", {
|
|
519
549
|
id: item.id,
|
|
520
550
|
style: {
|
|
521
551
|
width: '21px',
|
|
@@ -524,7 +554,7 @@ const TD = ({
|
|
|
524
554
|
},
|
|
525
555
|
onClick: () => handleOpenCloseRowSingleArrow(index, innerIndex),
|
|
526
556
|
className: styles$c['td-span']
|
|
527
|
-
}, item.status === 'close' ? item.closeArrow : item.openArrow),
|
|
557
|
+
}, item.status === 'close' ? item.closeArrow : item.openArrow), hasOwnerProperty(item, 'checkBox') && /*#__PURE__*/React__default.createElement(SingleCheckbox, {
|
|
528
558
|
data: item,
|
|
529
559
|
index: index,
|
|
530
560
|
innerIndex: innerIndex,
|
|
@@ -540,10 +570,10 @@ const TD = ({
|
|
|
540
570
|
}, /*#__PURE__*/React__default.createElement("p", {
|
|
541
571
|
style: {
|
|
542
572
|
margin: '0px',
|
|
543
|
-
cursor:
|
|
573
|
+
cursor: hasOwnerProperty(item, 'arrowComponent') || hasOwnerProperty(item, 'dots') ? 'pointer' : 'auto'
|
|
544
574
|
},
|
|
545
|
-
onClick:
|
|
546
|
-
}, item.content ? item.content :
|
|
575
|
+
onClick: hasOwnerProperty(item, 'arrowComponent') ? () => handleCheckArrowAction(item, item.checkIndex) : hasOwnerProperty(item, 'dots') ? e => handleCheckDots(e, item, index, innerIndex) : _ => _
|
|
576
|
+
}, item.content ? item.content : hasOwnerProperty(item, 'arrowComponent') ? item.status === 'close' ? item.closeArrow : item.openArrow : hasOwnerProperty(item, 'dots') ? /*#__PURE__*/React__default.createElement("span", {
|
|
547
577
|
style: {
|
|
548
578
|
display: 'block',
|
|
549
579
|
position: 'relative'
|
|
@@ -564,7 +594,7 @@ const TD = ({
|
|
|
564
594
|
backgroundColor: '#FFFFFF',
|
|
565
595
|
boxShadow: '0px 0px 20px 0px #3C393E4D'
|
|
566
596
|
}
|
|
567
|
-
},
|
|
597
|
+
}, hasOwnerProperty(item, 'options') && item.options.map((optionItem, optionIndex) => {
|
|
568
598
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
569
599
|
key: `${optionItem.content}_${optionIndex}`,
|
|
570
600
|
className: styles$c['dots-option-item'],
|
|
@@ -573,14 +603,7 @@ const TD = ({
|
|
|
573
603
|
fontSize: '14px',
|
|
574
604
|
fontFamily: 'Noto Sans Armenian'
|
|
575
605
|
},
|
|
576
|
-
onClick: () =>
|
|
577
|
-
item,
|
|
578
|
-
index,
|
|
579
|
-
optionItem,
|
|
580
|
-
innerIndex,
|
|
581
|
-
optionIndex,
|
|
582
|
-
options: item.options
|
|
583
|
-
})
|
|
606
|
+
onClick: () => handleMoreOptions(item, index, optionItem, innerIndex, optionIndex, item.options)
|
|
584
607
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
585
608
|
style: {
|
|
586
609
|
marginRight: '10px'
|
|
@@ -595,7 +618,7 @@ const TD = ({
|
|
|
595
618
|
},
|
|
596
619
|
title: optionItem.content
|
|
597
620
|
}, optionItem.content));
|
|
598
|
-
}))) : ''),
|
|
621
|
+
}))) : ''), hasOwnerProperty(item, 'contentList') && /*#__PURE__*/React__default.createElement("div", {
|
|
599
622
|
style: {
|
|
600
623
|
overflow: 'auto',
|
|
601
624
|
marginTop: '10px',
|
|
@@ -608,17 +631,11 @@ const TD = ({
|
|
|
608
631
|
key: `${innerItem}_${innerItemIndex}`,
|
|
609
632
|
className: styles$c['list-text'],
|
|
610
633
|
style: {
|
|
611
|
-
color: openListColor
|
|
634
|
+
color: openListColor,
|
|
635
|
+
maxWidth: (item.content.length * 9 <= 100 ? 100 : item.content.length * 9) + 'px'
|
|
612
636
|
},
|
|
613
|
-
onClick: e =>
|
|
614
|
-
|
|
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);
|
|
637
|
+
onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex)
|
|
638
|
+
}, innerItem.content);
|
|
622
639
|
})))) : '');
|
|
623
640
|
};
|
|
624
641
|
|
|
@@ -707,7 +724,7 @@ const Table = ({
|
|
|
707
724
|
bodyData.map((item, index) => {
|
|
708
725
|
if (index === data.index) {
|
|
709
726
|
item.map((innerItem, innerIndex) => {
|
|
710
|
-
if (
|
|
727
|
+
if (hasOwnerProperty(innerItem, 'arrowComponent')) {
|
|
711
728
|
removeItemIndex = innerIndex;
|
|
712
729
|
}
|
|
713
730
|
});
|
|
@@ -731,7 +748,7 @@ const Table = ({
|
|
|
731
748
|
let removeItemIndex;
|
|
732
749
|
let headerWithoutArrow;
|
|
733
750
|
header.map((item, index) => {
|
|
734
|
-
if (
|
|
751
|
+
if (hasOwnerProperty(item, 'arrowComponent')) {
|
|
735
752
|
removeItemIndex = index;
|
|
736
753
|
}
|
|
737
754
|
});
|
|
@@ -771,7 +788,7 @@ const Table = ({
|
|
|
771
788
|
let checkedItems = [];
|
|
772
789
|
data.map((item, index) => {
|
|
773
790
|
item.map((innerItem, innerIndex) => {
|
|
774
|
-
if (
|
|
791
|
+
if (hasOwnerProperty(innerItem, 'checkBox')) {
|
|
775
792
|
if (!checkedItems[innerIndex]) {
|
|
776
793
|
checkedItems[innerIndex] = [];
|
|
777
794
|
}
|
|
@@ -851,7 +868,7 @@ const Table = ({
|
|
|
851
868
|
checkableItemBool = !item.checkBox.checked;
|
|
852
869
|
item.checkBox.checked = !item.checkBox.checked;
|
|
853
870
|
}
|
|
854
|
-
if (
|
|
871
|
+
if (hasOwnerProperty(item, 'arrowComponent')) {
|
|
855
872
|
removeItemIndex = index;
|
|
856
873
|
}
|
|
857
874
|
return item;
|
|
@@ -901,7 +918,7 @@ const Table = ({
|
|
|
901
918
|
const updatedBody = body.slice().map(item => Object.values(item));
|
|
902
919
|
const newData = updatedBody.map((item, index) => {
|
|
903
920
|
return item.map((innerItem, innerIndex) => {
|
|
904
|
-
if (innerItem.id === data.id && innerItem.content == data.content &&
|
|
921
|
+
if (innerItem.id === data.id && innerItem.content == data.content && hasOwnerProperty(innerItem, 'checkBox')) {
|
|
905
922
|
innerItem.checkBox.checked = !innerItem.checkBox.checked;
|
|
906
923
|
handleHeaderCheckedUpdate({
|
|
907
924
|
row: index,
|
|
@@ -958,7 +975,7 @@ const Table = ({
|
|
|
958
975
|
const handleCheckArrowAction = (item, rowPosition) => {
|
|
959
976
|
const status = item.status;
|
|
960
977
|
const checkedOpenableRow = body[rowPosition].map(innerItem => {
|
|
961
|
-
if (
|
|
978
|
+
if (hasOwnerProperty(innerItem, 'status')) {
|
|
962
979
|
if (status === 'close') {
|
|
963
980
|
innerItem.status = 'open';
|
|
964
981
|
} else {
|
|
@@ -984,13 +1001,13 @@ const Table = ({
|
|
|
984
1001
|
}
|
|
985
1002
|
single = item;
|
|
986
1003
|
}
|
|
987
|
-
if (
|
|
1004
|
+
if (hasOwnerProperty(item, 'status') && !hasOwnerProperty(item, 'arrowComponent')) {
|
|
988
1005
|
allArrows.push(item);
|
|
989
1006
|
}
|
|
990
1007
|
return item;
|
|
991
1008
|
});
|
|
992
1009
|
const checkedOpenableRowArrow = checkedOpenableRow.map(item => {
|
|
993
|
-
if (
|
|
1010
|
+
if (hasOwnerProperty(item, 'arrowComponent')) {
|
|
994
1011
|
if (single && single.status === 'close') {
|
|
995
1012
|
item.status = 'close';
|
|
996
1013
|
} else if (single && single.status === 'open') {
|
|
@@ -1020,7 +1037,7 @@ const Table = ({
|
|
|
1020
1037
|
});
|
|
1021
1038
|
const checkedOpenableAllRowsBody = body.map(innerItem => {
|
|
1022
1039
|
return innerItem.map(iElem => {
|
|
1023
|
-
if (
|
|
1040
|
+
if (hasOwnerProperty(iElem, 'status')) {
|
|
1024
1041
|
if (item.status === 'open') {
|
|
1025
1042
|
iElem.status = 'open';
|
|
1026
1043
|
} else {
|
|
@@ -1037,7 +1054,7 @@ const Table = ({
|
|
|
1037
1054
|
e.stopPropagation();
|
|
1038
1055
|
const checkBodyMore = body.map((elemItem, elemIndex) => {
|
|
1039
1056
|
return elemItem.map((elemInnerItem, elemInnerIndex) => {
|
|
1040
|
-
if (elemIndex === index &&
|
|
1057
|
+
if (elemIndex === index && hasOwnerProperty(elemInnerItem, 'dots')) {
|
|
1041
1058
|
if (elemInnerIndex === innerIndex) {
|
|
1042
1059
|
if (item.dotsStatus === 'deActive') {
|
|
1043
1060
|
elemInnerItem.dotsStatus = 'active';
|
|
@@ -1045,7 +1062,7 @@ const Table = ({
|
|
|
1045
1062
|
elemInnerItem.dotsStatus = 'deActive';
|
|
1046
1063
|
}
|
|
1047
1064
|
}
|
|
1048
|
-
} else if (elemIndex !== index &&
|
|
1065
|
+
} else if (elemIndex !== index && hasOwnerProperty(elemInnerItem, 'dots')) {
|
|
1049
1066
|
if (elemInnerIndex === innerIndex) {
|
|
1050
1067
|
elemInnerItem.dotsStatus = 'deActive';
|
|
1051
1068
|
}
|
|
@@ -1060,7 +1077,7 @@ const Table = ({
|
|
|
1060
1077
|
if (disableArr && disableArr.length > 0) {
|
|
1061
1078
|
headerWithDisabled = arr.map((item, index) => {
|
|
1062
1079
|
if (disableArr[index]) {
|
|
1063
|
-
if (
|
|
1080
|
+
if (hasOwnerProperty(item, 'checkBox')) {
|
|
1064
1081
|
item.checkBox.disabled = true;
|
|
1065
1082
|
}
|
|
1066
1083
|
}
|
|
@@ -1104,6 +1121,17 @@ const Table = ({
|
|
|
1104
1121
|
};
|
|
1105
1122
|
getData(moreData);
|
|
1106
1123
|
};
|
|
1124
|
+
const handleTableClick = () => {
|
|
1125
|
+
const checkBodyMore = body.map(elemItem => {
|
|
1126
|
+
return elemItem.map(elemInnerItem => {
|
|
1127
|
+
if (hasOwnerProperty(elemInnerItem, 'dots')) {
|
|
1128
|
+
elemInnerItem.dotsStatus = 'deActive';
|
|
1129
|
+
}
|
|
1130
|
+
return elemInnerItem;
|
|
1131
|
+
});
|
|
1132
|
+
});
|
|
1133
|
+
setBody(() => checkBodyMore);
|
|
1134
|
+
};
|
|
1107
1135
|
useEffect(() => {
|
|
1108
1136
|
let checkedItems = [];
|
|
1109
1137
|
const disabledArray = [];
|
|
@@ -1113,8 +1141,8 @@ const Table = ({
|
|
|
1113
1141
|
const checkForInsertArrow = handleTransformDataForInsertArrow(checkBodyForChackedItems, arrowColumnCount, 'body');
|
|
1114
1142
|
const insert = checkForInsertArrow.map((item, index) => {
|
|
1115
1143
|
item.map((innerItem, innerIndex) => {
|
|
1116
|
-
if (
|
|
1117
|
-
if (
|
|
1144
|
+
if (hasOwnerProperty(innerItem, 'checkBox')) {
|
|
1145
|
+
if (hasOwnerProperty(innerItem.checkBox, 'disabled')) {
|
|
1118
1146
|
if (innerItem.checkBox.disabled === true) {
|
|
1119
1147
|
if (!disabledArray[innerIndex]) {
|
|
1120
1148
|
disabledArray[innerIndex] = {
|
|
@@ -1133,8 +1161,8 @@ const Table = ({
|
|
|
1133
1161
|
} else {
|
|
1134
1162
|
const insert = checkBodyForChackedItems.map((item, index) => {
|
|
1135
1163
|
item.map((innerItem, innerIndex) => {
|
|
1136
|
-
if (
|
|
1137
|
-
if (
|
|
1164
|
+
if (hasOwnerProperty(innerItem, 'checkBox')) {
|
|
1165
|
+
if (hasOwnerProperty(innerItem.checkBox, 'disabled')) {
|
|
1138
1166
|
if (innerItem.checkBox.disabled === true) {
|
|
1139
1167
|
if (!disabledArray[innerIndex]) {
|
|
1140
1168
|
disabledArray[innerIndex] = {
|
|
@@ -1170,7 +1198,8 @@ const Table = ({
|
|
|
1170
1198
|
style: {
|
|
1171
1199
|
width: '100%',
|
|
1172
1200
|
borderCollapse: 'collapse'
|
|
1173
|
-
}
|
|
1201
|
+
},
|
|
1202
|
+
onClick: handleTableClick
|
|
1174
1203
|
}, header && header.length > 0 && /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", {
|
|
1175
1204
|
style: {
|
|
1176
1205
|
color: tHeadColor ? tHeadColor : configStyles.TABLE.tHeadColor,
|
|
@@ -1550,8 +1579,7 @@ const Modal = ({
|
|
|
1550
1579
|
}
|
|
1551
1580
|
}, innerData && innerData.length > 0 && innerData.map((item, index) => {
|
|
1552
1581
|
if (select === index) {
|
|
1553
|
-
|
|
1554
|
-
if (!item.hasOwnProperty('url')) {
|
|
1582
|
+
if (!hasOwnerProperty(item, 'url')) {
|
|
1555
1583
|
alert('Please add url property in data prop on each element');
|
|
1556
1584
|
} else {
|
|
1557
1585
|
return /*#__PURE__*/React__default.createElement("img", {
|
|
@@ -1684,6 +1712,7 @@ const Input = ({
|
|
|
1684
1712
|
maxNumSize,
|
|
1685
1713
|
labelColor,
|
|
1686
1714
|
errorColor,
|
|
1715
|
+
withoutDot,
|
|
1687
1716
|
borderRight,
|
|
1688
1717
|
placeholder,
|
|
1689
1718
|
errorZindex,
|
|
@@ -1829,6 +1858,15 @@ const Input = ({
|
|
|
1829
1858
|
change(newStr);
|
|
1830
1859
|
}
|
|
1831
1860
|
}
|
|
1861
|
+
if (withoutDot && !/^\d+$/.test(currentValue)) {
|
|
1862
|
+
const newStr = currentValue.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
|
|
1863
|
+
return b + c.replace(/\./g, '');
|
|
1864
|
+
});
|
|
1865
|
+
setInnerValue(newStr);
|
|
1866
|
+
if (change) {
|
|
1867
|
+
change(newStr);
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1832
1870
|
if (currentValue === '') {
|
|
1833
1871
|
setInnerValue('');
|
|
1834
1872
|
if (change) {
|
|
@@ -1961,6 +1999,15 @@ const Input = ({
|
|
|
1961
1999
|
change(newStr);
|
|
1962
2000
|
}
|
|
1963
2001
|
}
|
|
2002
|
+
if (withoutDot && !/^\d+$/.test(value)) {
|
|
2003
|
+
const newStr = value.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
|
|
2004
|
+
return b + c.replace(/\./g, '');
|
|
2005
|
+
});
|
|
2006
|
+
setInnerValue(newStr);
|
|
2007
|
+
if (change) {
|
|
2008
|
+
change(newStr);
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
1964
2011
|
if (value === '') {
|
|
1965
2012
|
setInnerValue('');
|
|
1966
2013
|
if (change) {
|
|
@@ -2100,6 +2147,7 @@ Input.propTypes = {
|
|
|
2100
2147
|
padding: PropTypes.string,
|
|
2101
2148
|
fontSize: PropTypes.string,
|
|
2102
2149
|
tooltip: PropTypes.element,
|
|
2150
|
+
withoutDot: PropTypes.bool,
|
|
2103
2151
|
marginTop: PropTypes.string,
|
|
2104
2152
|
transform: PropTypes.string,
|
|
2105
2153
|
className: PropTypes.string,
|
|
@@ -2457,8 +2505,7 @@ const Select = ({
|
|
|
2457
2505
|
};
|
|
2458
2506
|
const isObjectEmpty = obj => {
|
|
2459
2507
|
for (var key in obj) {
|
|
2460
|
-
|
|
2461
|
-
if (obj.hasOwnProperty(key)) {
|
|
2508
|
+
if (hasOwnerProperty(obj, key)) {
|
|
2462
2509
|
return false;
|
|
2463
2510
|
}
|
|
2464
2511
|
}
|
|
@@ -3588,6 +3635,7 @@ const FileItem = /*#__PURE__*/React__default.memo(({
|
|
|
3588
3635
|
}, time));
|
|
3589
3636
|
return () => {
|
|
3590
3637
|
setI(_ => _);
|
|
3638
|
+
setT(_ => _);
|
|
3591
3639
|
clearTimeout(t);
|
|
3592
3640
|
clearInterval(i);
|
|
3593
3641
|
};
|
|
@@ -3847,6 +3895,7 @@ const NewFile = ({
|
|
|
3847
3895
|
listItemPadding,
|
|
3848
3896
|
progressFontSize,
|
|
3849
3897
|
borderHoverColor,
|
|
3898
|
+
maxCHoosenLength,
|
|
3850
3899
|
listItemErrorSize,
|
|
3851
3900
|
progressTrackColor,
|
|
3852
3901
|
fileAreaImageWidth,
|
|
@@ -3857,9 +3906,11 @@ const NewFile = ({
|
|
|
3857
3906
|
progressSuccessColor,
|
|
3858
3907
|
progressLoadingColor,
|
|
3859
3908
|
hiddenBackgroundColor,
|
|
3909
|
+
maxCHoosenLengthError,
|
|
3860
3910
|
extentionsRowMarginTop,
|
|
3861
3911
|
listItemBackgroundColor,
|
|
3862
|
-
listItemBackgroundErrorColor
|
|
3912
|
+
listItemBackgroundErrorColor,
|
|
3913
|
+
maxCHoosenLengthErrorHideTime
|
|
3863
3914
|
}) => {
|
|
3864
3915
|
const ref = useRef(null);
|
|
3865
3916
|
const inpRef = useRef(null);
|
|
@@ -3867,13 +3918,10 @@ const NewFile = ({
|
|
|
3867
3918
|
const [error, setError] = useState('');
|
|
3868
3919
|
const [isHover, setIsHover] = useState(false);
|
|
3869
3920
|
const [singleFile, setSingleFile] = useState(null);
|
|
3921
|
+
const [choosenFileCount, setChoosenFileCount] = useState(0);
|
|
3870
3922
|
const [image, setImage] = useState(!multiple ? defaultData ? defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf' : null : null);
|
|
3871
3923
|
const configStyles = compereConfigs();
|
|
3872
3924
|
const handleRemoveComponent = () => {
|
|
3873
|
-
// eslint-disable-next-line react/no-find-dom-node
|
|
3874
|
-
const node = ReactDOM.findDOMNode(ref.current);
|
|
3875
|
-
const parent = node.parentNode;
|
|
3876
|
-
parent.removeChild(node);
|
|
3877
3925
|
if (!multiple) {
|
|
3878
3926
|
removeFile && removeFile(singleFile);
|
|
3879
3927
|
} else {
|
|
@@ -3885,11 +3933,47 @@ const NewFile = ({
|
|
|
3885
3933
|
setImage(null);
|
|
3886
3934
|
removeFile && removeFile(singleFile);
|
|
3887
3935
|
};
|
|
3888
|
-
const
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3936
|
+
const handleUploadFiles = file => {
|
|
3937
|
+
if (maxCHoosenLength && choosenFileCount > 0) {
|
|
3938
|
+
if (file.length > choosenFileCount || file.length + memoizedItems.length > choosenFileCount) {
|
|
3939
|
+
setError(maxCHoosenLengthError ? maxCHoosenLengthError : `Դիմումին կարող եք կցել առավելագույնը ${choosenFileCount} ֆայլ`);
|
|
3940
|
+
const clearFunc = () => {
|
|
3941
|
+
clearTimeout(time);
|
|
3942
|
+
};
|
|
3943
|
+
const time = setTimeout(() => {
|
|
3944
|
+
setError('');
|
|
3945
|
+
clearFunc();
|
|
3946
|
+
}, maxCHoosenLengthErrorHideTime && typeof maxCHoosenLengthErrorHideTime === 'number' ? Math.round(maxCHoosenLengthErrorHideTime) : 3000);
|
|
3947
|
+
} else {
|
|
3948
|
+
for (let ix = 0; ix < file.length; ix++) {
|
|
3949
|
+
if (file[ix]) {
|
|
3950
|
+
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
3951
|
+
if (fileExtensions.includes(file[ix].type.split('/')[1]) || fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif') {
|
|
3952
|
+
change({
|
|
3953
|
+
id: '',
|
|
3954
|
+
check: '',
|
|
3955
|
+
status: '',
|
|
3956
|
+
file: file[ix],
|
|
3957
|
+
uuid: v4()
|
|
3958
|
+
});
|
|
3959
|
+
} else {
|
|
3960
|
+
change({
|
|
3961
|
+
file: file[ix],
|
|
3962
|
+
uuid: v4(),
|
|
3963
|
+
check: formatError
|
|
3964
|
+
});
|
|
3965
|
+
}
|
|
3966
|
+
} else {
|
|
3967
|
+
change({
|
|
3968
|
+
file: file[ix],
|
|
3969
|
+
uuid: v4(),
|
|
3970
|
+
check: maxSizeError
|
|
3971
|
+
});
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
} else {
|
|
3893
3977
|
for (let ix = 0; ix < file.length; ix++) {
|
|
3894
3978
|
if (file[ix]) {
|
|
3895
3979
|
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
@@ -3917,6 +4001,14 @@ const NewFile = ({
|
|
|
3917
4001
|
}
|
|
3918
4002
|
}
|
|
3919
4003
|
}
|
|
4004
|
+
}
|
|
4005
|
+
};
|
|
4006
|
+
const handleChange = e => {
|
|
4007
|
+
const file = e.target.files;
|
|
4008
|
+
if (multiple) {
|
|
4009
|
+
setError('');
|
|
4010
|
+
setImage(null);
|
|
4011
|
+
handleUploadFiles(file);
|
|
3920
4012
|
if (file.length === 0 && memoizedItems.length === 0) {
|
|
3921
4013
|
setError(noChoosenFile);
|
|
3922
4014
|
}
|
|
@@ -3998,7 +4090,18 @@ const NewFile = ({
|
|
|
3998
4090
|
if (multiple && !removeFile) {
|
|
3999
4091
|
alert('Please add removeFile prop on NewFile component, it is a require in multiple mode');
|
|
4000
4092
|
}
|
|
4001
|
-
|
|
4093
|
+
if (maxCHoosenLength) {
|
|
4094
|
+
if (typeof maxCHoosenLength !== 'number') {
|
|
4095
|
+
alert('maxCHoosenLength prop must be a number, please check it!');
|
|
4096
|
+
} else {
|
|
4097
|
+
if (maxCHoosenLength <= 0) {
|
|
4098
|
+
setChoosenFileCount(1);
|
|
4099
|
+
} else {
|
|
4100
|
+
setChoosenFileCount(Math.round(maxCHoosenLength));
|
|
4101
|
+
}
|
|
4102
|
+
}
|
|
4103
|
+
}
|
|
4104
|
+
}, [multiple, removeFile, filesArray && filesArray.length, defaultData, maxCHoosenLength]);
|
|
4002
4105
|
useEffect(() => {
|
|
4003
4106
|
if (deleteComponent && !removeComponent) {
|
|
4004
4107
|
alert('Please add removeComponent prop on NewFile component it is require when deleteComponent prop is true');
|
|
@@ -4200,6 +4303,7 @@ NewFile.propTypes = {
|
|
|
4200
4303
|
backgroundColor: PropTypes.string,
|
|
4201
4304
|
change: PropTypes.func.isRequired,
|
|
4202
4305
|
listItemPadding: PropTypes.string,
|
|
4306
|
+
maxCHoosenLength: PropTypes.number,
|
|
4203
4307
|
progressFontSize: PropTypes.string,
|
|
4204
4308
|
borderHoverColor: PropTypes.string,
|
|
4205
4309
|
listItemErrorSize: PropTypes.string,
|
|
@@ -4212,9 +4316,11 @@ NewFile.propTypes = {
|
|
|
4212
4316
|
progressSuccessColor: PropTypes.string,
|
|
4213
4317
|
progressLoadingColor: PropTypes.string,
|
|
4214
4318
|
hiddenBackgroundColor: PropTypes.string,
|
|
4319
|
+
maxCHoosenLengthError: PropTypes.string,
|
|
4215
4320
|
extentionsRowMarginTop: PropTypes.string,
|
|
4216
4321
|
listItemBackgroundColor: PropTypes.string,
|
|
4217
4322
|
listItemBackgroundErrorColor: PropTypes.string,
|
|
4323
|
+
maxCHoosenLengthErrorHideTime: PropTypes.number,
|
|
4218
4324
|
filesArray: PropTypes.arrayOf(PropTypes.object),
|
|
4219
4325
|
fileExtensions: PropTypes.arrayOf(PropTypes.string)
|
|
4220
4326
|
};
|
|
@@ -4369,16 +4475,10 @@ const Textarea = ({
|
|
|
4369
4475
|
if (maxLength) {
|
|
4370
4476
|
if (value.length > maxLength) {
|
|
4371
4477
|
onChange(value.substr(0, maxLength));
|
|
4372
|
-
setError('Նիշերի քանակը գերազանցում է');
|
|
4373
|
-
} else {
|
|
4374
|
-
setError('');
|
|
4375
4478
|
}
|
|
4376
4479
|
} else {
|
|
4377
4480
|
if (value.length > configStyles.TEXTAREA.maxLength) {
|
|
4378
|
-
setError('Նիշերի քանակը գերազանցում է');
|
|
4379
4481
|
onChange(value.substr(0, configStyles.TEXTAREA.maxLength));
|
|
4380
|
-
} else {
|
|
4381
|
-
setError('');
|
|
4382
4482
|
}
|
|
4383
4483
|
}
|
|
4384
4484
|
};
|
|
@@ -4389,6 +4489,9 @@ const Textarea = ({
|
|
|
4389
4489
|
if (!onChange) {
|
|
4390
4490
|
alert('Please add onChange function on Textarea component');
|
|
4391
4491
|
}
|
|
4492
|
+
if (value === '') {
|
|
4493
|
+
setError('');
|
|
4494
|
+
}
|
|
4392
4495
|
setInnerValue(value);
|
|
4393
4496
|
}, [value, onChange]);
|
|
4394
4497
|
useEffect(() => {
|
|
@@ -4586,7 +4689,7 @@ Typography.propTypes = {
|
|
|
4586
4689
|
textDecoration: PropTypes.string,
|
|
4587
4690
|
backgroundColor: PropTypes.string,
|
|
4588
4691
|
variant: PropTypes.oneOf(Object.values(TypographyType)),
|
|
4589
|
-
size: PropTypes.
|
|
4692
|
+
size: PropTypes.oneOfType([PropTypes.string, PropTypes.number])
|
|
4590
4693
|
};
|
|
4591
4694
|
Typography.defaultProps = {
|
|
4592
4695
|
variant: 'p'
|
|
@@ -5174,8 +5277,7 @@ const NewAutocomplete = ({
|
|
|
5174
5277
|
alert('Please add options prop');
|
|
5175
5278
|
}
|
|
5176
5279
|
options && options.length > 0 && options.map(item => {
|
|
5177
|
-
|
|
5178
|
-
if (!item.hasOwnProperty(keyNames.name)) {
|
|
5280
|
+
if (!hasOwnerProperty(item, keyNames.name)) {
|
|
5179
5281
|
alert(`Please add ${keyNames.name} property in items of options array`);
|
|
5180
5282
|
}
|
|
5181
5283
|
});
|