diginet-core-ui 1.3.49 → 1.3.51-beta.2
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/components/accordion/css.js +27 -30
- package/components/accordion/details.js +17 -15
- package/components/accordion/group.js +10 -10
- package/components/accordion/index.js +25 -21
- package/components/accordion/summary.js +28 -37
- package/components/alert/index.js +1 -1
- package/components/avatar/index.js +46 -32
- package/components/chip/index.js +1 -2
- package/components/form-control/checkbox/index.js +1 -1
- package/components/form-control/dropdown/index.js +84 -79
- package/components/form-control/input-base/index.js +33 -25
- package/components/modal/modal.js +4 -4
- package/components/popover/index.js +45 -17
- package/components/tree-view/css.js +1 -0
- package/components/typography/index.js +75 -68
- package/package.json +55 -35
- package/readme.md +8 -0
- package/styles/general.js +1 -1
- package/theme/make-styles.js +19 -2
- package/theme/theme-provider.js +2 -1
- package/utils/useDelayUnmount.js +19 -0
|
@@ -70,7 +70,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
70
70
|
total,
|
|
71
71
|
placeholder,
|
|
72
72
|
error,
|
|
73
|
-
keyExpr,
|
|
74
73
|
displayExpr,
|
|
75
74
|
subText,
|
|
76
75
|
valueExpr,
|
|
@@ -156,10 +155,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
156
155
|
const onClickInput = e => {
|
|
157
156
|
if (!boxRef.current) {
|
|
158
157
|
if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e.target))) {
|
|
159
|
-
if ((renderSelectedItem || iconExpr && iconExpr !== 'none') && !multiple) {
|
|
158
|
+
if ((typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none') && !multiple) {
|
|
159
|
+
var _inputRef$current$chi;
|
|
160
|
+
|
|
160
161
|
inputRef.current.innerHTML = inputRef.current.textContent.trim();
|
|
161
162
|
inputRef.current.contentEditable = 'plaintext-only';
|
|
162
|
-
const caret = inputRef.current.childNodes.length ? 1 : 0;
|
|
163
|
+
const caret = (_inputRef$current$chi = inputRef.current.childNodes) !== null && _inputRef$current$chi !== void 0 && _inputRef$current$chi.length ? 1 : 0;
|
|
163
164
|
const range = document.createRange();
|
|
164
165
|
range.setStart(inputRef.current, caret);
|
|
165
166
|
range.setEnd(inputRef.current, caret);
|
|
@@ -281,7 +282,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
281
282
|
window.addEventListener('resize', customizeWidthDropdown);
|
|
282
283
|
document.addEventListener('wheel', onWheelHandler);
|
|
283
284
|
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
284
|
-
document.addEventListener('keydown', preventScroll);
|
|
285
285
|
boxRef.current && boxRef.current.addEventListener('keydown', moveOnItem);
|
|
286
286
|
|
|
287
287
|
if (onLoadMore && dataSource.length < total) {
|
|
@@ -306,15 +306,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
308
|
|
|
309
|
-
const preventScroll = e => {
|
|
310
|
-
if (/Arrow(Up|Down)/.test(e.key)) {
|
|
311
|
-
e.preventDefault();
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
return true;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
309
|
const pressESCHandler = event => {
|
|
319
310
|
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
320
311
|
closeDropdown();
|
|
@@ -339,11 +330,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
339
330
|
};
|
|
340
331
|
|
|
341
332
|
const closeDropdown = () => {
|
|
342
|
-
const node = document.querySelector(`.DGN-Dropdown-${unique}`);
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
inputRef.current.contentEditable = true;
|
|
346
|
-
}
|
|
333
|
+
const node = document.querySelector(`.DGN-Dropdown-${unique}`); // if ((renderSelectedItem || (iconExpr && iconExpr !== 'none')) && !multiple && inputRef.current && !disabled) {
|
|
334
|
+
// inputRef.current.contentEditable = true;
|
|
335
|
+
// }
|
|
347
336
|
|
|
348
337
|
if (node) {
|
|
349
338
|
node.style.pointerEvents = `none`;
|
|
@@ -359,7 +348,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
359
348
|
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
360
349
|
window.removeEventListener('resize', customizeWidthDropdown);
|
|
361
350
|
document.removeEventListener('wheel', onWheelHandler);
|
|
362
|
-
document.removeEventListener('keydown', preventScroll);
|
|
363
351
|
|
|
364
352
|
if (onLoadMore && boxRef.current) {
|
|
365
353
|
boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
@@ -400,12 +388,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
400
388
|
};
|
|
401
389
|
|
|
402
390
|
const mapDropdown = (pattern, keyArr) => {
|
|
391
|
+
var _currentObjectDefault;
|
|
392
|
+
|
|
403
393
|
const items = [];
|
|
404
394
|
const dataSourceUsable = [...dataSource];
|
|
405
395
|
|
|
406
396
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
407
397
|
|
|
408
|
-
if (currentObjectDefault[unique] && currentObjectDefault[unique].length) {
|
|
398
|
+
if (currentObjectDefault[unique] && (_currentObjectDefault = currentObjectDefault[unique]) !== null && _currentObjectDefault !== void 0 && _currentObjectDefault.length) {
|
|
409
399
|
const length = currentObjectDefault[unique].length;
|
|
410
400
|
let existItemQuantity = 0;
|
|
411
401
|
|
|
@@ -455,13 +445,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
455
445
|
items.push(jsx("div", {
|
|
456
446
|
key: index,
|
|
457
447
|
css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
|
|
458
|
-
onClick:
|
|
459
|
-
if (itemDisabled) return;
|
|
460
|
-
|
|
448
|
+
onClick: () => {
|
|
449
|
+
if (itemDisabled) return; // onChangeValueWithCheckbox(e) & onChangeValue(displayText, value, icon, data, index);
|
|
450
|
+
|
|
451
|
+
onChangeValue(displayText, value, icon, data, index);
|
|
461
452
|
},
|
|
462
453
|
onKeyPress: e => {
|
|
463
|
-
if (itemDisabled) return;
|
|
464
|
-
|
|
454
|
+
if (itemDisabled) return; // if (e.key === 'Enter') e.currentTarget.firstChild.click();
|
|
455
|
+
|
|
456
|
+
if (e.key === 'Enter') onChangeValue(displayText, value, icon, data, index);
|
|
465
457
|
},
|
|
466
458
|
tabIndex: -1
|
|
467
459
|
}, jsx(Checkbox, {
|
|
@@ -472,7 +464,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
472
464
|
padding: '0 16px'
|
|
473
465
|
},
|
|
474
466
|
value: value,
|
|
475
|
-
disabled: itemDisabled
|
|
467
|
+
disabled: itemDisabled,
|
|
468
|
+
onChange: () => onChangeValue(displayText, value, icon, data, index)
|
|
476
469
|
}, icon && jsx("div", {
|
|
477
470
|
css: DropdownIconCSS
|
|
478
471
|
}, icon), jsx("div", {
|
|
@@ -500,7 +493,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
500
493
|
}, displayText)));
|
|
501
494
|
}
|
|
502
495
|
|
|
503
|
-
if (items.length === limit) {
|
|
496
|
+
if ((items === null || items === void 0 ? void 0 : items.length) === limit) {
|
|
504
497
|
timerRef.current = setTimeout(() => {
|
|
505
498
|
loadMoreItemsDropdown(index + 1, pattern);
|
|
506
499
|
}, 1000);
|
|
@@ -511,7 +504,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
511
504
|
return jsx("div", {
|
|
512
505
|
css: DropdownBoxCSS,
|
|
513
506
|
ref: boxRef
|
|
514
|
-
}, items.length ? items : jsx("div", {
|
|
507
|
+
}, items !== null && items !== void 0 && items.length ? items : jsx("div", {
|
|
515
508
|
css: _DropdownItemCSS,
|
|
516
509
|
className: 'no-data'
|
|
517
510
|
}, ' ', noDataText, ' '));
|
|
@@ -544,13 +537,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
544
537
|
};
|
|
545
538
|
|
|
546
539
|
const loadMoreItemsDropdown = (i = 0, pattern) => {
|
|
547
|
-
var _displayExpr3;
|
|
540
|
+
var _currentObjectDefault2, _displayExpr3;
|
|
548
541
|
|
|
549
542
|
const dataSourceUsable = [...dataSource]; // Nếu có load more thì đẩy đội tượng mặc định lên đầu
|
|
550
543
|
|
|
551
544
|
let notExistItem = 0;
|
|
552
545
|
|
|
553
|
-
if (onLoadMore && currentObjectDefault[unique].length) {
|
|
546
|
+
if (onLoadMore && (_currentObjectDefault2 = currentObjectDefault[unique]) !== null && _currentObjectDefault2 !== void 0 && _currentObjectDefault2.length) {
|
|
554
547
|
const length = currentObjectDefault[unique].length;
|
|
555
548
|
|
|
556
549
|
for (let index = length - 1; index >= 0; index--) {
|
|
@@ -741,7 +734,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
741
734
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
742
735
|
|
|
743
736
|
if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && boxRef.current) {
|
|
744
|
-
|
|
737
|
+
var _boxRef$current$query;
|
|
738
|
+
|
|
739
|
+
const length = (_boxRef$current$query = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query === void 0 ? void 0 : _boxRef$current$query.length;
|
|
745
740
|
boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
746
741
|
!!onLoadMore && onLoadMore({
|
|
747
742
|
skip: length,
|
|
@@ -759,9 +754,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
759
754
|
if (searchRef.current) lastSearchRef.current = searchRef.current.value;
|
|
760
755
|
|
|
761
756
|
if (onInput) {
|
|
762
|
-
isSearch[unique] = true;
|
|
763
|
-
const
|
|
764
|
-
const text = (valueInput || e.target.textContent).normalize();
|
|
757
|
+
isSearch[unique] = true; // const valueInput = e.target.value;
|
|
758
|
+
// const text = (valueInput || e.target.textContent).normalize();
|
|
765
759
|
|
|
766
760
|
if (timeout.current) {
|
|
767
761
|
if (timing[unique]) {
|
|
@@ -769,14 +763,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
769
763
|
}
|
|
770
764
|
|
|
771
765
|
timing[unique] = setTimeout(() => {
|
|
772
|
-
e.target.value = text;
|
|
773
|
-
onInput(e);
|
|
774
|
-
|
|
775
|
-
}, timeout.current);
|
|
766
|
+
// e.target.value = text;
|
|
767
|
+
onInput(e); // e.target.value = valueInput;
|
|
768
|
+
}, timeout.current || searchDelayTime);
|
|
776
769
|
} else {
|
|
777
|
-
e.target.value = text;
|
|
778
|
-
onInput(e);
|
|
779
|
-
e.target.value = valueInput;
|
|
770
|
+
// e.target.value = text;
|
|
771
|
+
onInput(e); // e.target.value = valueInput;
|
|
780
772
|
}
|
|
781
773
|
|
|
782
774
|
return;
|
|
@@ -784,7 +776,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
784
776
|
|
|
785
777
|
const value = e.target.value || e.target.textContent;
|
|
786
778
|
|
|
787
|
-
if (renderSelectedItem && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
|
|
779
|
+
if (typeof renderSelectedItem === 'function' && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
|
|
788
780
|
const cursor = document.getSelection().anchorOffset;
|
|
789
781
|
e.target.innerHTML = value;
|
|
790
782
|
document.getSelection().collapse(e.target, cursor);
|
|
@@ -798,7 +790,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
798
790
|
}
|
|
799
791
|
|
|
800
792
|
renderDropdown(new RegExp(value.normalize(), 'gim'));
|
|
801
|
-
}, timeout.current ||
|
|
793
|
+
}, timeout.current || searchDelayTime);
|
|
802
794
|
};
|
|
803
795
|
|
|
804
796
|
const onChangeValue = (displayText, value, icon, data, index) => {
|
|
@@ -824,7 +816,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
824
816
|
if (valueProp === undefined) {
|
|
825
817
|
let item = null;
|
|
826
818
|
|
|
827
|
-
if (
|
|
819
|
+
if (typeof renderSelectedItem === 'function') {
|
|
828
820
|
item = renderSelectedItem({
|
|
829
821
|
data,
|
|
830
822
|
index
|
|
@@ -894,15 +886,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
894
886
|
if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
|
|
895
887
|
closeDropdown();
|
|
896
888
|
}
|
|
897
|
-
};
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
889
|
+
}; // const onChangeValueWithCheckbox = e => {
|
|
890
|
+
// const firstChild = e.currentTarget.firstChild;
|
|
891
|
+
// if (!firstChild.contains(e.target)) {
|
|
892
|
+
// firstChild.click();
|
|
893
|
+
// }
|
|
894
|
+
// };
|
|
901
895
|
|
|
902
|
-
if (!firstChild.contains(e.target)) {
|
|
903
|
-
firstChild.click();
|
|
904
|
-
}
|
|
905
|
-
};
|
|
906
896
|
|
|
907
897
|
const onRemove = (e, value) => {
|
|
908
898
|
const index = currentValue[unique].findIndex(v => JSON.stringify(v) === JSON.stringify(value));
|
|
@@ -928,7 +918,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
928
918
|
};
|
|
929
919
|
|
|
930
920
|
const onClear = e => {
|
|
931
|
-
if (disabled || readOnly || loading) return;
|
|
921
|
+
if (disabled || readOnly || loading || !clearAble) return;
|
|
932
922
|
currentValue[unique] = multiple ? [] : '';
|
|
933
923
|
|
|
934
924
|
if (inputRef.current.tagName.toLowerCase() === 'div') {
|
|
@@ -942,6 +932,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
942
932
|
} // onChangeValue('', '');
|
|
943
933
|
|
|
944
934
|
|
|
935
|
+
setShowClear(false);
|
|
945
936
|
e && e.target && e.target.blur();
|
|
946
937
|
updatePositionDropdown();
|
|
947
938
|
onInput === null || onInput === void 0 ? void 0 : onInput({ ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
|
|
@@ -965,7 +956,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
965
956
|
inputRef.current.innerHTML = '';
|
|
966
957
|
currentValue[unique] = [];
|
|
967
958
|
} else {
|
|
968
|
-
if (renderSelectedItem || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
|
|
959
|
+
if (typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
|
|
969
960
|
inputRef.current.innerHTML = '';
|
|
970
961
|
} else if (!isSearch[unique]) {
|
|
971
962
|
inputRef.current.value = '';
|
|
@@ -978,7 +969,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
978
969
|
}
|
|
979
970
|
|
|
980
971
|
const length = dataSource.length;
|
|
981
|
-
const displayKey =
|
|
972
|
+
const displayKey = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr;
|
|
982
973
|
|
|
983
974
|
if (displayKey && Array.isArray(displayKey)) {
|
|
984
975
|
displayExpr = displayExpr.join(' - ');
|
|
@@ -997,6 +988,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
997
988
|
currentValue[unique] = [];
|
|
998
989
|
inputRef.current.innerHTML = '';
|
|
999
990
|
valueArr.forEach(v => {
|
|
991
|
+
var _currentObjectDefault3;
|
|
992
|
+
|
|
1000
993
|
for (let i = 0; i < length; i++) {
|
|
1001
994
|
if (typeof dataSource[i] === 'object' && dataSource[i][valueExpr] === v || dataSource[i] === v) {
|
|
1002
995
|
setMultipleValueHandler(dataSource[i], v, keyArr, i);
|
|
@@ -1004,7 +997,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1004
997
|
}
|
|
1005
998
|
}
|
|
1006
999
|
|
|
1007
|
-
if (currentObjectDefault[unique].length) {
|
|
1000
|
+
if ((_currentObjectDefault3 = currentObjectDefault[unique]) !== null && _currentObjectDefault3 !== void 0 && _currentObjectDefault3.length) {
|
|
1008
1001
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === v || valueObject === v);
|
|
1009
1002
|
|
|
1010
1003
|
if (itemOfValue) {
|
|
@@ -1013,6 +1006,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1013
1006
|
}
|
|
1014
1007
|
});
|
|
1015
1008
|
} else {
|
|
1009
|
+
var _currentObjectDefault4;
|
|
1010
|
+
|
|
1016
1011
|
currentValue[unique] = source;
|
|
1017
1012
|
|
|
1018
1013
|
for (let i = 0; i < length; i++) {
|
|
@@ -1022,7 +1017,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1022
1017
|
}
|
|
1023
1018
|
}
|
|
1024
1019
|
|
|
1025
|
-
if (currentObjectDefault[unique].length) {
|
|
1020
|
+
if ((_currentObjectDefault4 = currentObjectDefault[unique]) !== null && _currentObjectDefault4 !== void 0 && _currentObjectDefault4.length) {
|
|
1026
1021
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === source || valueObject === source);
|
|
1027
1022
|
|
|
1028
1023
|
if (itemOfValue) {
|
|
@@ -1040,14 +1035,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1040
1035
|
const setMultipleValueHandler = (data, value, keyArr, index) => {
|
|
1041
1036
|
let item = null;
|
|
1042
1037
|
|
|
1043
|
-
if (
|
|
1038
|
+
if (typeof renderSelectedItem === 'function') {
|
|
1044
1039
|
item = renderSelectedItem({
|
|
1045
1040
|
data,
|
|
1046
1041
|
index
|
|
1047
1042
|
});
|
|
1048
1043
|
} else {
|
|
1049
1044
|
const icon = getIconFromData(data);
|
|
1050
|
-
const text = keyArr ? renderData(data, keyArr) : data[
|
|
1045
|
+
const text = keyArr ? renderData(data, keyArr) : data[renderSelectedItem || displayExpr];
|
|
1051
1046
|
item = jsx(Chip, {
|
|
1052
1047
|
startIcon: icon,
|
|
1053
1048
|
label: text,
|
|
@@ -1070,9 +1065,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1070
1065
|
};
|
|
1071
1066
|
|
|
1072
1067
|
const setSingleValueHandler = (data, keyArr) => {
|
|
1073
|
-
const text = keyArr ? renderData(data, keyArr) : data[
|
|
1068
|
+
const text = keyArr ? renderData(data, keyArr) : typeof renderSelectedItem === 'string' ? data[renderSelectedItem] : data[displayExpr || valueExpr] || data;
|
|
1074
1069
|
|
|
1075
|
-
if (
|
|
1070
|
+
if (typeof renderSelectedItem === 'function') {
|
|
1076
1071
|
inputRef.current.innerHTML = '';
|
|
1077
1072
|
const item = renderSelectedItem({
|
|
1078
1073
|
data
|
|
@@ -1288,15 +1283,17 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1288
1283
|
}
|
|
1289
1284
|
|
|
1290
1285
|
if (boxRef.current) {
|
|
1286
|
+
var _boxRef$current$query2, _currentObjectDefault5;
|
|
1287
|
+
|
|
1291
1288
|
if (!disabled && !readOnly) {
|
|
1292
1289
|
inputRef.current.addEventListener('input', onChangeInput);
|
|
1293
1290
|
}
|
|
1294
1291
|
|
|
1295
1292
|
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
1296
1293
|
|
|
1297
|
-
const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
|
|
1294
|
+
const length = (_boxRef$current$query2 = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query2 === void 0 ? void 0 : _boxRef$current$query2.length;
|
|
1298
1295
|
|
|
1299
|
-
if (length < dataSource.length + currentObjectDefault[unique].length && !isSearch[unique]) {
|
|
1296
|
+
if (length < dataSource.length + ((_currentObjectDefault5 = currentObjectDefault[unique]) === null || _currentObjectDefault5 === void 0 ? void 0 : _currentObjectDefault5.length) && !isSearch[unique]) {
|
|
1300
1297
|
loadMoreItemsDropdown(length);
|
|
1301
1298
|
!!onLoadMore && dataSource.length < total && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
1302
1299
|
} else {
|
|
@@ -1327,11 +1324,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1327
1324
|
...labelProps
|
|
1328
1325
|
}, label) : null, [label, required, disabled, labelProps]);
|
|
1329
1326
|
const inputComp = useMemo(() => {
|
|
1330
|
-
const _InputCSS = InputCSS(multiple, renderSelectedItem);
|
|
1327
|
+
const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
|
|
1331
1328
|
|
|
1332
|
-
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
|
|
1329
|
+
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', disabled);
|
|
1333
1330
|
|
|
1334
|
-
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
|
|
1331
|
+
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', disabled);
|
|
1335
1332
|
|
|
1336
1333
|
return jsx("div", {
|
|
1337
1334
|
css: _DropdownFormCSS,
|
|
@@ -1354,8 +1351,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1354
1351
|
e.preventDefault();
|
|
1355
1352
|
return false;
|
|
1356
1353
|
}
|
|
1357
|
-
}) : renderSelectedItem || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
|
|
1358
|
-
contentEditable:
|
|
1354
|
+
}) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
|
|
1355
|
+
contentEditable: !disabled,
|
|
1359
1356
|
style: inputStyle,
|
|
1360
1357
|
ref: inputRef,
|
|
1361
1358
|
css: _DropdownInputCSS,
|
|
@@ -1415,7 +1412,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1415
1412
|
|
|
1416
1413
|
return jsx(Fragment, null, jsx("div", {
|
|
1417
1414
|
ref: dropdownRef,
|
|
1418
|
-
css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
|
|
1415
|
+
css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', loading, showClear),
|
|
1419
1416
|
className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1420
1417
|
style: style
|
|
1421
1418
|
}, labelComp, inputComp, errorComp), dropdownComp);
|
|
@@ -1449,7 +1446,7 @@ const DropdownIconCSS = css`
|
|
|
1449
1446
|
}
|
|
1450
1447
|
`;
|
|
1451
1448
|
|
|
1452
|
-
const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem) => css`
|
|
1449
|
+
const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled) => css`
|
|
1453
1450
|
${flexRow};
|
|
1454
1451
|
${alignCenter};
|
|
1455
1452
|
${outlineNone};
|
|
@@ -1457,7 +1454,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1457
1454
|
${borderNone};
|
|
1458
1455
|
${paragraph1};
|
|
1459
1456
|
width: 100%;
|
|
1460
|
-
color: ${main};
|
|
1457
|
+
color: ${disabled ? systemDisabled : main};
|
|
1461
1458
|
padding-top: 0;
|
|
1462
1459
|
padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
|
|
1463
1460
|
padding-left: ${viewType !== 'outlined' ? 0 : '16px'};
|
|
@@ -1491,7 +1488,19 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1491
1488
|
padding: ${itemMultipleSize === 'medium' ? 2 : 1}px;
|
|
1492
1489
|
}
|
|
1493
1490
|
}
|
|
1491
|
+
.DGN-UI-Typography {
|
|
1492
|
+
${disabled && `
|
|
1493
|
+
color: ${systemDisabled}
|
|
1494
|
+
`}
|
|
1495
|
+
}
|
|
1494
1496
|
.css-${DropdownIconCSS.name} {
|
|
1497
|
+
${disabled && `
|
|
1498
|
+
svg {
|
|
1499
|
+
path {
|
|
1500
|
+
fill: ${systemDisabled};
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
`}
|
|
1495
1504
|
${renderSelectedItem ? `
|
|
1496
1505
|
min-height: 24px;
|
|
1497
1506
|
min-width: 24px;
|
|
@@ -1540,10 +1549,9 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1540
1549
|
}
|
|
1541
1550
|
.css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1542
1551
|
color: ${active};
|
|
1552
|
+
}
|
|
1543
1553
|
}
|
|
1544
|
-
}
|
|
1545
1554
|
`}
|
|
1546
|
-
|
|
1547
1555
|
&:focus-within {
|
|
1548
1556
|
border-bottom-color: ${focus};
|
|
1549
1557
|
&::after {
|
|
@@ -1568,7 +1576,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1568
1576
|
left: 0;
|
|
1569
1577
|
right: 0;
|
|
1570
1578
|
bottom: 0;
|
|
1571
|
-
border-bottom: 1px solid ${rest};
|
|
1579
|
+
border-bottom: 1px solid ${disabled ? systemDisabled : rest};
|
|
1572
1580
|
}
|
|
1573
1581
|
&::after {
|
|
1574
1582
|
${positionAbsolute};
|
|
@@ -1587,7 +1595,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1587
1595
|
${positionRelative};
|
|
1588
1596
|
${borderRadius4px};
|
|
1589
1597
|
${borderBox};
|
|
1590
|
-
${border(1, rest)};
|
|
1598
|
+
${border(1, disabled ? systemDisabled : rest)};
|
|
1591
1599
|
width: 100%;
|
|
1592
1600
|
min-height: 40px;
|
|
1593
1601
|
${!disabled && `
|
|
@@ -1823,9 +1831,6 @@ Dropdown.propTypes = {
|
|
|
1823
1831
|
/** the displayed value for each change */
|
|
1824
1832
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1825
1833
|
|
|
1826
|
-
/** field name used for text display in input */
|
|
1827
|
-
keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1828
|
-
|
|
1829
1834
|
/** field name used for text display<br/>
|
|
1830
1835
|
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1831
1836
|
* Note: don't use 'id - name', return undefined
|
|
@@ -1917,7 +1922,7 @@ Dropdown.propTypes = {
|
|
|
1917
1922
|
/** function displays selected items by custom, example:<br/>
|
|
1918
1923
|
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1919
1924
|
*/
|
|
1920
|
-
renderSelectedItem: PropTypes.func,
|
|
1925
|
+
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1921
1926
|
|
|
1922
1927
|
/** the function will run when entering input<br/>
|
|
1923
1928
|
* if undefined: the filter function will run (default)
|
|
@@ -86,7 +86,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
86
86
|
padding-top: 4px;
|
|
87
87
|
&:not(:focus-within):hover {
|
|
88
88
|
&::before {
|
|
89
|
-
border-bottom-color: ${colors.brand};
|
|
89
|
+
${!readOnly && `border-bottom-color: ${colors.brand}`};
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
&:focus-within {
|
|
@@ -125,11 +125,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
125
125
|
box-sizing: border-box;
|
|
126
126
|
background-color: ${colors.white};
|
|
127
127
|
&:not(:focus-within):hover {
|
|
128
|
-
|
|
129
|
-
border-color: ${colors.brand};
|
|
130
|
-
input {
|
|
128
|
+
${!readOnly && `
|
|
131
129
|
background-color: ${colors.hover};
|
|
132
|
-
|
|
130
|
+
border-color: ${colors.brand};
|
|
131
|
+
input {
|
|
132
|
+
background-color: ${colors.hover};
|
|
133
|
+
}
|
|
134
|
+
`};
|
|
133
135
|
}
|
|
134
136
|
&:focus-within {
|
|
135
137
|
${!readOnly && `
|
|
@@ -203,9 +205,9 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
203
205
|
&.outlined {
|
|
204
206
|
background-color: ${colors.dark12};
|
|
205
207
|
}
|
|
206
|
-
input {
|
|
208
|
+
/* input {
|
|
207
209
|
color: ${colors.disabled};
|
|
208
|
-
}
|
|
210
|
+
} */
|
|
209
211
|
.start-icon,
|
|
210
212
|
.end-icon {
|
|
211
213
|
&:not(.non-effect),
|
|
@@ -276,15 +278,17 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
276
278
|
position: relative;
|
|
277
279
|
resize: ${resize};
|
|
278
280
|
box-sizing: border-box;
|
|
279
|
-
&:disabled {
|
|
281
|
+
/* &:disabled {
|
|
280
282
|
color: ${colors.disabled};
|
|
281
|
-
}
|
|
283
|
+
} */
|
|
282
284
|
&:hover:not(:focus-within) {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
::placeholder {
|
|
285
|
+
${!readOnly && `
|
|
286
|
+
border-color: ${colors.brand};
|
|
286
287
|
color: ${colors.primary};
|
|
287
|
-
|
|
288
|
+
::placeholder {
|
|
289
|
+
color: ${colors.primary};
|
|
290
|
+
}
|
|
291
|
+
`};
|
|
288
292
|
}
|
|
289
293
|
&:focus-within {
|
|
290
294
|
color: ${colors.primary};
|
|
@@ -316,11 +320,13 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
316
320
|
height: 24px;
|
|
317
321
|
}
|
|
318
322
|
&:not(:focus-within):hover {
|
|
319
|
-
|
|
320
|
-
border-color: ${colors.brand};
|
|
321
|
-
input {
|
|
323
|
+
${!readOnly && `
|
|
322
324
|
background-color: ${colors.hover};
|
|
323
|
-
|
|
325
|
+
border-color: ${colors.brand};
|
|
326
|
+
input {
|
|
327
|
+
background-color: ${colors.hover};
|
|
328
|
+
}
|
|
329
|
+
`};
|
|
324
330
|
}
|
|
325
331
|
&:focus-within {
|
|
326
332
|
${!readOnly && `
|
|
@@ -351,17 +357,19 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
351
357
|
height: 24px;
|
|
352
358
|
}
|
|
353
359
|
&:not(:focus-within):hover {
|
|
354
|
-
|
|
360
|
+
${!readOnly && `
|
|
361
|
+
&::before {
|
|
355
362
|
border-bottom-color: ${colors.brand};
|
|
356
|
-
|
|
363
|
+
}
|
|
364
|
+
`};
|
|
357
365
|
}
|
|
358
366
|
&:focus-within {
|
|
359
367
|
${!readOnly && `
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
368
|
+
&::after {
|
|
369
|
+
border-bottom-color: ${colors.info5};
|
|
370
|
+
transform: scaleX(1);
|
|
371
|
+
}
|
|
372
|
+
`}
|
|
365
373
|
}
|
|
366
374
|
&::before {
|
|
367
375
|
content: '';
|
|
@@ -386,7 +394,7 @@ const InputBase = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
386
394
|
&.disabled {
|
|
387
395
|
pointer-events: none;
|
|
388
396
|
resize: none;
|
|
389
|
-
color: ${colors.disabled};
|
|
397
|
+
/* color: ${colors.disabled}; */
|
|
390
398
|
&.outlined {
|
|
391
399
|
background-color: ${colors.dark12};
|
|
392
400
|
}
|
|
@@ -8,6 +8,10 @@ import { jsx, css } from '@emotion/core';
|
|
|
8
8
|
import ModalContext from './context';
|
|
9
9
|
import { animations } from '../../styles/animation';
|
|
10
10
|
import { typography } from '../../styles/typography';
|
|
11
|
+
import { useTheme } from '../../theme';
|
|
12
|
+
const {
|
|
13
|
+
zIndex: zIndexCORE
|
|
14
|
+
} = useTheme();
|
|
11
15
|
import { borderBox, borderRadius4px, flexCol, flexRow, justifyCenter, parseWidth, positionFixed, positionRelative } from '../../styles/general';
|
|
12
16
|
import { color as colors } from '../../styles/colors';
|
|
13
17
|
const {
|
|
@@ -19,10 +23,6 @@ const {
|
|
|
19
23
|
}
|
|
20
24
|
} = colors;
|
|
21
25
|
const fadeInDown = animations.fadeInDown;
|
|
22
|
-
import { useTheme } from '../../theme';
|
|
23
|
-
const {
|
|
24
|
-
zIndex: zIndexCORE
|
|
25
|
-
} = useTheme();
|
|
26
26
|
const Modal = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
27
27
|
open,
|
|
28
28
|
moveable,
|