diginet-core-ui 1.3.32-beta.5 → 1.3.32-beta.6
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.
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { Fragment, memo, useState, useEffect, useMemo, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import { jsx, css } from '@emotion/core';
|
|
8
9
|
import { Account } from '../../../icons';
|
|
@@ -494,6 +495,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
494
495
|
};
|
|
495
496
|
|
|
496
497
|
const showDropdown = () => {
|
|
498
|
+
var _searchRef$current;
|
|
499
|
+
|
|
497
500
|
if (displayExpr && Array.isArray(displayExpr)) {
|
|
498
501
|
displayExpr = displayExpr.join(' - ');
|
|
499
502
|
}
|
|
@@ -524,51 +527,68 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
524
527
|
}
|
|
525
528
|
}
|
|
526
529
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
530
|
+
let dropdownStyle = {
|
|
531
|
+
position: 'fixed',
|
|
532
|
+
top: `${positionTop}px`,
|
|
533
|
+
left: `${left}px`,
|
|
534
|
+
width: `${width}px`,
|
|
535
|
+
backgroundColor: '#FFF',
|
|
536
|
+
zIndex: 9001
|
|
537
|
+
};
|
|
538
|
+
if (_isMobile && allowSearch) dropdownStyle = { ...dropdownStyle,
|
|
539
|
+
bottom: 0,
|
|
540
|
+
top: 'auto',
|
|
541
|
+
display: 'flex',
|
|
542
|
+
flexDirection: 'column-reverse',
|
|
543
|
+
height: 'max-content'
|
|
544
|
+
};
|
|
545
|
+
const loadingStyle = {
|
|
546
|
+
display: 'none',
|
|
547
|
+
justifyContent: 'center',
|
|
548
|
+
alignItems: 'center',
|
|
549
|
+
position: 'absolute',
|
|
550
|
+
top: 0,
|
|
551
|
+
width: '100%',
|
|
552
|
+
height: '100%',
|
|
553
|
+
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
|
554
|
+
borderRadius: 4,
|
|
555
|
+
zIndex: 9002
|
|
556
|
+
};
|
|
557
|
+
const defaultSearch = !!onInput ? (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value : '';
|
|
558
|
+
const el = jsx("div", {
|
|
559
|
+
className: `DGN-UI-Portal DGN-Dropdown-${unique}`,
|
|
560
|
+
style: dropdownStyle
|
|
561
|
+
}, (multiple || allowSearch) && itemMode === 'normal' && !children && jsx("div", {
|
|
562
|
+
className: 'DGN-Dropdown-Box-Search'
|
|
563
|
+
}, jsx(InputBase, {
|
|
564
|
+
inputRef: searchRef,
|
|
565
|
+
viewType: 'outlined',
|
|
566
|
+
defaultValue: defaultSearch,
|
|
567
|
+
onChange: onChangeInput,
|
|
568
|
+
style: {
|
|
569
|
+
backgroundColor: '#FFF',
|
|
570
|
+
marginBottom: 1
|
|
571
|
+
},
|
|
572
|
+
onKeyDown: pressESCHandler,
|
|
573
|
+
autoFocus: true
|
|
574
|
+
})), jsx("div", {
|
|
575
|
+
className: 'DGN-Dropdown-Box'
|
|
576
|
+
}, dropdown), jsx("div", {
|
|
577
|
+
className: 'DGN-Dropdown-Loading',
|
|
578
|
+
style: loadingStyle
|
|
579
|
+
}, jsx(CircularProgress, {
|
|
580
|
+
size: 'xs'
|
|
581
|
+
})));
|
|
582
|
+
|
|
583
|
+
if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
|
|
559
584
|
inputRef.current.addEventListener('keydown', pressESCHandler);
|
|
560
585
|
}
|
|
561
586
|
|
|
562
|
-
ReactDOM.render(dropdown, node.appendChild(elBox));
|
|
563
|
-
ReactDOM.render(jsx(CircularProgress, {
|
|
564
|
-
size: 'xs'
|
|
565
|
-
}), node.appendChild(elLoading));
|
|
566
587
|
document.documentElement.style.overflow = 'hidden';
|
|
567
588
|
setTimeout(() => {
|
|
568
|
-
el.style.opacity = 1;
|
|
569
589
|
window.addEventListener('resize', customizeWidthDropdown);
|
|
570
590
|
document.addEventListener('wheel', onWheelHandler);
|
|
571
|
-
document.addEventListener('
|
|
591
|
+
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
572
592
|
document.addEventListener('keydown', preventScroll);
|
|
573
593
|
boxRef.current.addEventListener('keydown', moveOnItem);
|
|
574
594
|
|
|
@@ -576,6 +596,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
576
596
|
boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
577
597
|
}
|
|
578
598
|
}, 10);
|
|
599
|
+
return el;
|
|
579
600
|
};
|
|
580
601
|
|
|
581
602
|
const moveOnItem = e => {
|
|
@@ -643,7 +664,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
643
664
|
boxRef.current = null;
|
|
644
665
|
}, 300);
|
|
645
666
|
setOpenState(false);
|
|
646
|
-
document.removeEventListener('
|
|
667
|
+
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
647
668
|
window.removeEventListener('resize', customizeWidthDropdown);
|
|
648
669
|
document.removeEventListener('wheel', onWheelHandler);
|
|
649
670
|
document.removeEventListener('keydown', preventScroll);
|
|
@@ -1622,13 +1643,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1622
1643
|
}, error), [error, valueProp, disabled, errorState]);
|
|
1623
1644
|
/* End component */
|
|
1624
1645
|
|
|
1625
|
-
return jsx("div", {
|
|
1646
|
+
return jsx(Fragment, null, jsx("div", {
|
|
1626
1647
|
ref: dropdownRef,
|
|
1627
1648
|
css: DropdownRoot,
|
|
1628
1649
|
className: ['DGN-UI-Dropdown', className, errorState && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1629
1650
|
style: style,
|
|
1630
1651
|
...props
|
|
1631
|
-
}, labelComp, inputComp, errorComp);
|
|
1652
|
+
}, labelComp, inputComp, errorComp), openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null);
|
|
1632
1653
|
}));
|
|
1633
1654
|
Dropdown.defaultProps = {
|
|
1634
1655
|
viewType: 'underlined',
|
|
@@ -132,7 +132,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
const onClickOutsideOfInput = event => {
|
|
135
|
-
if (
|
|
135
|
+
if (ref.current && !ref.current.contains(event.target) && dropdownBoxRef.current && !dropdownBoxRef.current.contains(event.target)) {
|
|
136
136
|
closeDropdownBox();
|
|
137
137
|
}
|
|
138
138
|
};
|
|
@@ -157,7 +157,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
157
157
|
dropdownBoxRef.current.style.opacity = 1; // window.addEventListener('resize', customizeWidthDropdown);
|
|
158
158
|
// window.addEventListener('scroll', updatePositionDropdown);
|
|
159
159
|
|
|
160
|
-
document.addEventListener('
|
|
160
|
+
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
161
161
|
document.addEventListener('keydown', pressESCHandler);
|
|
162
162
|
!!onOpened && onOpened(ref.current);
|
|
163
163
|
}, 10);
|
|
@@ -181,7 +181,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
181
181
|
// inputBaseRef.current.classList.remove('dropdown-focus');
|
|
182
182
|
// }
|
|
183
183
|
|
|
184
|
-
document.removeEventListener('
|
|
184
|
+
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
185
185
|
timing[unique + 'Box'] = setTimeout(() => {
|
|
186
186
|
clearTimeout(timing[unique + 'Box']);
|
|
187
187
|
timing[unique + 'Box'] = null;
|