diginet-core-ui 1.3.36 → 1.3.37
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/assets/images/menu/dhr/MHRM29N0002.svg +13 -0
- package/assets/images/menu/dhr/MHRP39N0018.svg +11 -0
- package/components/alert/index.js +115 -103
- package/components/alert/notify.js +0 -2
- package/components/avatar/index.js +19 -19
- package/components/chip/index.js +13 -10
- package/components/form-control/attachment/index.js +21 -20
- package/components/form-control/dropdown/index.js +132 -78
- package/components/modal/header.js +63 -65
- package/components/modal/modal.js +84 -130
- package/components/popover/index.js +21 -21
- package/components/slider/slider-item.js +65 -25
- package/icons/basic.js +75 -408
- package/package.json +1 -1
- package/readme.md +14 -0
- package/styles/general.js +33 -5
- package/theme/settings.js +3 -2
|
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { jsx, css } from '@emotion/core';
|
|
9
9
|
import { Account } from '../../../icons';
|
|
10
10
|
import AvatarDefault from '../../../assets/avatar/default.svg';
|
|
11
|
-
import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon } from '../../';
|
|
11
|
+
import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon, Typography } from '../../';
|
|
12
12
|
import { mapParent, randomString, updatePosition } from '../../../utils';
|
|
13
13
|
import { getGlobal } from '../../../global';
|
|
14
14
|
import { color as colors } from '../../../styles/colors';
|
|
@@ -88,6 +88,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
88
88
|
onInput,
|
|
89
89
|
onChange,
|
|
90
90
|
onLoadMore,
|
|
91
|
+
onClosed,
|
|
91
92
|
renderItem,
|
|
92
93
|
renderSelectedItem,
|
|
93
94
|
valueObjectDefault,
|
|
@@ -97,10 +98,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
97
98
|
formStyle,
|
|
98
99
|
labelProps,
|
|
99
100
|
errorStyle,
|
|
100
|
-
refs,
|
|
101
101
|
children,
|
|
102
102
|
dropdownItemStyle
|
|
103
|
-
},
|
|
103
|
+
}, reference) => {
|
|
104
104
|
const dropdownRef = useRef(null);
|
|
105
105
|
const timerRef = useRef(null);
|
|
106
106
|
const formRef = useRef(null);
|
|
@@ -115,7 +115,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
115
115
|
allowSymbol: false
|
|
116
116
|
}));
|
|
117
117
|
const [openState, setOpenState] = useState(false);
|
|
118
|
-
const [errorState, setErrorState] = useState(error && !valueProp && valueProp !== 0);
|
|
119
118
|
const [showClear, setShowClear] = useState(false);
|
|
120
119
|
|
|
121
120
|
const _isMobile = isMobile.any();
|
|
@@ -377,6 +376,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
377
376
|
}
|
|
378
377
|
|
|
379
378
|
document.documentElement.style.overflow = 'auto';
|
|
379
|
+
onClosed === null || onClosed === void 0 ? void 0 : onClosed();
|
|
380
380
|
};
|
|
381
381
|
|
|
382
382
|
const renderDropdown = pattern => {
|
|
@@ -838,10 +838,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
838
838
|
startIcon: icon,
|
|
839
839
|
label: displayText,
|
|
840
840
|
size: itemMultipleSize,
|
|
841
|
+
disabled: disabled,
|
|
841
842
|
clearAble: true,
|
|
842
843
|
onRemove: e => onRemove(e, value),
|
|
843
844
|
style: {
|
|
844
|
-
margin: '3px 0'
|
|
845
|
+
margin: '3px 0',
|
|
846
|
+
width: '100%'
|
|
845
847
|
}
|
|
846
848
|
});
|
|
847
849
|
}
|
|
@@ -1049,10 +1051,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1049
1051
|
startIcon: icon,
|
|
1050
1052
|
label: text,
|
|
1051
1053
|
size: itemMultipleSize,
|
|
1054
|
+
disabled: disabled,
|
|
1052
1055
|
clearAble: true,
|
|
1053
1056
|
onRemove: e => onRemove(e, value),
|
|
1054
1057
|
style: {
|
|
1055
|
-
margin: '3px 0'
|
|
1058
|
+
margin: '3px 0',
|
|
1059
|
+
width: '100%'
|
|
1056
1060
|
}
|
|
1057
1061
|
});
|
|
1058
1062
|
}
|
|
@@ -1081,8 +1085,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1081
1085
|
const icon = getIconFromData(data);
|
|
1082
1086
|
const valueWithIcon = jsx(Fragment, null, icon && jsx("div", {
|
|
1083
1087
|
css: DropdownIconCSS
|
|
1084
|
-
}, icon), jsx(
|
|
1085
|
-
|
|
1088
|
+
}, icon), jsx(Typography, {
|
|
1089
|
+
type: 'p1',
|
|
1090
|
+
lineClamp: 1,
|
|
1091
|
+
hoverTooltip: !_isMobile
|
|
1086
1092
|
}, text));
|
|
1087
1093
|
const el = document.createElement('div');
|
|
1088
1094
|
el.style.cssText = 'display: flex; align-items: center; min-height:24px;';
|
|
@@ -1092,17 +1098,43 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1092
1098
|
}
|
|
1093
1099
|
};
|
|
1094
1100
|
|
|
1095
|
-
useImperativeHandle(
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1101
|
+
useImperativeHandle(reference, () => {
|
|
1102
|
+
const currentRef = dropdownRef.current || {};
|
|
1103
|
+
const _instance = {
|
|
1104
|
+
closeDropdown: () => {
|
|
1105
|
+
closeDropdown();
|
|
1106
|
+
},
|
|
1107
|
+
showDropdown: () => {
|
|
1108
|
+
showDropdown();
|
|
1109
|
+
},
|
|
1110
|
+
onClear,
|
|
1111
|
+
setPreviousValue,
|
|
1112
|
+
setValue: value => {
|
|
1113
|
+
if (allValue[unique][allValue[unique].length - 1] !== value) {
|
|
1114
|
+
allValue[unique].push(value);
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
setValueIntoInput(value);
|
|
1118
|
+
}
|
|
1119
|
+
}; // methods
|
|
1120
|
+
|
|
1121
|
+
_instance.__proto__ = {}; // hidden methods
|
|
1122
|
+
|
|
1123
|
+
currentRef.instance = _instance; // keep old method
|
|
1124
|
+
|
|
1125
|
+
currentRef.closeDropdown = () => closeDropdown();
|
|
1126
|
+
|
|
1127
|
+
currentRef.showDropdown = () => showDropdown();
|
|
1128
|
+
|
|
1129
|
+
currentRef.onClear = onClear, currentRef.setPreviousValue = setPreviousValue, currentRef.setValue = value => {
|
|
1130
|
+
if (allValue[unique][allValue[unique].length - 1] !== value) {
|
|
1131
|
+
allValue[unique].push(value);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
setValueIntoInput(value);
|
|
1135
|
+
}, currentRef.DOM = dropdownRef.current;
|
|
1136
|
+
return currentRef;
|
|
1137
|
+
});
|
|
1106
1138
|
useEffect(() => {
|
|
1107
1139
|
setShowClear(clearAble && checkHasValue(valueProp) && !disabled && !readOnly && !loading);
|
|
1108
1140
|
}, [clearAble, valueProp, disabled, readOnly, loading]);
|
|
@@ -1122,7 +1154,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1122
1154
|
};
|
|
1123
1155
|
}, [valueObjectDefault]);
|
|
1124
1156
|
useEffect(() => {
|
|
1125
|
-
!!refs && refs(dropdownRef);
|
|
1126
1157
|
allValue[unique] = [];
|
|
1127
1158
|
|
|
1128
1159
|
if (defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
|
|
@@ -1186,9 +1217,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1186
1217
|
};
|
|
1187
1218
|
}
|
|
1188
1219
|
}, [loading]);
|
|
1189
|
-
useEffect(() => {
|
|
1190
|
-
setErrorState(error && (!valueProp && valueProp !== 0 || (valueProp === null || valueProp === void 0 ? void 0 : valueProp.length) === 0));
|
|
1191
|
-
}, [error, valueProp]);
|
|
1192
1220
|
useEffect(() => {
|
|
1193
1221
|
if (valueProp !== undefined && (!boxRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
|
|
1194
1222
|
setValueIntoInput(valueProp);
|
|
@@ -1295,7 +1323,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1295
1323
|
const inputComp = useMemo(() => {
|
|
1296
1324
|
const _InputCSS = InputCSS(multiple, renderSelectedItem, clearAble);
|
|
1297
1325
|
|
|
1298
|
-
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
|
|
1326
|
+
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
|
|
1299
1327
|
|
|
1300
1328
|
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
|
|
1301
1329
|
|
|
@@ -1305,7 +1333,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1305
1333
|
className: ['DGN-UI-Dropdown-Form', openState && 'dropdown-showing'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1306
1334
|
style: formStyle
|
|
1307
1335
|
}, jsx("div", {
|
|
1308
|
-
css: _InputCSS
|
|
1336
|
+
css: _InputCSS,
|
|
1337
|
+
className: 'DGN-UI-Dropdown-Form-Input'
|
|
1309
1338
|
}, multiple ? jsx("div", { ...inputProps,
|
|
1310
1339
|
style: {
|
|
1311
1340
|
cursor: 'text',
|
|
@@ -1337,7 +1366,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1337
1366
|
ref: inputRef,
|
|
1338
1367
|
css: _DropdownInputCSS,
|
|
1339
1368
|
type: "text",
|
|
1340
|
-
placeholder: placeholder
|
|
1369
|
+
placeholder: placeholder,
|
|
1370
|
+
disabled: disabled
|
|
1341
1371
|
})), jsx("div", {
|
|
1342
1372
|
ref: iconRef,
|
|
1343
1373
|
css: IconCSS(viewType, loading, showClear),
|
|
@@ -1363,7 +1393,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1363
1393
|
disabled: disabled || readOnly
|
|
1364
1394
|
})));
|
|
1365
1395
|
}, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear]);
|
|
1366
|
-
const errorComp = useMemo(() =>
|
|
1396
|
+
const errorComp = useMemo(() => error && jsx(HelperText, {
|
|
1367
1397
|
disabled: disabled,
|
|
1368
1398
|
style: {
|
|
1369
1399
|
minHeight: '16px',
|
|
@@ -1371,13 +1401,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1371
1401
|
top: '100%',
|
|
1372
1402
|
...errorStyle
|
|
1373
1403
|
}
|
|
1374
|
-
}, error), [error,
|
|
1404
|
+
}, error), [error, disabled, errorStyle]);
|
|
1375
1405
|
/* End component */
|
|
1376
1406
|
|
|
1377
1407
|
return jsx(Fragment, null, jsx("div", {
|
|
1378
1408
|
ref: dropdownRef,
|
|
1379
1409
|
css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
|
|
1380
|
-
className: ['DGN-UI-Dropdown', className,
|
|
1410
|
+
className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1381
1411
|
style: style
|
|
1382
1412
|
}, labelComp, inputComp, errorComp), openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null);
|
|
1383
1413
|
}));
|
|
@@ -1385,7 +1415,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1385
1415
|
|
|
1386
1416
|
const InputCSS = (multiple, renderSelectedItem, clearAble) => css`
|
|
1387
1417
|
${flexRow};
|
|
1388
|
-
|
|
1418
|
+
width: 100%;
|
|
1389
1419
|
${!multiple && renderSelectedItem ? `width: calc(100% - 34px${clearAble ? ' - 18px' : ''})` : ''}
|
|
1390
1420
|
`;
|
|
1391
1421
|
|
|
@@ -1397,11 +1427,15 @@ const DropdownIconCSS = css`
|
|
|
1397
1427
|
height: inherit;
|
|
1398
1428
|
margin-right: 8px;
|
|
1399
1429
|
height: 32px;
|
|
1430
|
+
min-height: 32px;
|
|
1400
1431
|
width: 32px;
|
|
1432
|
+
min-width: 32px;
|
|
1401
1433
|
border-radius: 16px;
|
|
1402
1434
|
img {
|
|
1403
1435
|
height: 32px;
|
|
1436
|
+
min-height: 32px;
|
|
1404
1437
|
width: 32px;
|
|
1438
|
+
min-width: 32px;
|
|
1405
1439
|
object-fit: cover;
|
|
1406
1440
|
}
|
|
1407
1441
|
`;
|
|
@@ -1423,8 +1457,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1423
1457
|
${flexWrap};
|
|
1424
1458
|
${overflowHidden};
|
|
1425
1459
|
${breakWord};
|
|
1426
|
-
|
|
1427
|
-
${!multiple ? 'min-height: 24px; max-width: 100%; white-space: nowrap;' : ''}
|
|
1460
|
+
${!multiple ? 'min-height: 24px; max-width: 100%;' : ''}
|
|
1428
1461
|
&::after {
|
|
1429
1462
|
${flexRow};
|
|
1430
1463
|
${positionAbsolute};
|
|
@@ -1455,10 +1488,14 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1455
1488
|
min-width: 24px;
|
|
1456
1489
|
` : `
|
|
1457
1490
|
height: 24px;
|
|
1491
|
+
min-height: 24px;
|
|
1458
1492
|
width: 24px;
|
|
1493
|
+
min-width: 24px;
|
|
1459
1494
|
img {
|
|
1460
1495
|
height: 24px;
|
|
1496
|
+
min-height: 24px;
|
|
1461
1497
|
width: 24px;
|
|
1498
|
+
min-width: 24px;
|
|
1462
1499
|
}
|
|
1463
1500
|
`}
|
|
1464
1501
|
}
|
|
@@ -1479,22 +1516,25 @@ const IconCSS = (viewType, loading, showClear) => css`
|
|
|
1479
1516
|
}
|
|
1480
1517
|
`;
|
|
1481
1518
|
|
|
1482
|
-
const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem) => viewType !== 'outlined' ? css`
|
|
1519
|
+
const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled) => viewType !== 'outlined' ? css`
|
|
1483
1520
|
${flexRow};
|
|
1484
1521
|
${alignCenter};
|
|
1485
1522
|
${positionRelative};
|
|
1486
1523
|
${borderBox};
|
|
1487
|
-
|
|
1524
|
+
width: 100%;
|
|
1488
1525
|
padding-bottom: ${multiple ? 1 : 4}px;
|
|
1489
1526
|
padding-top: ${multiple ? 1 : 4}px;
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1527
|
+
${!disabled && `
|
|
1528
|
+
&:not(:focus-within):hover {
|
|
1529
|
+
&::before {
|
|
1530
|
+
border-bottom-color: ${active};
|
|
1531
|
+
}
|
|
1532
|
+
.css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1533
|
+
color: ${active};
|
|
1534
|
+
}
|
|
1497
1535
|
}
|
|
1536
|
+
`}
|
|
1537
|
+
|
|
1498
1538
|
&:focus-within {
|
|
1499
1539
|
border-bottom-color: ${focus};
|
|
1500
1540
|
&::after {
|
|
@@ -1539,15 +1579,17 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1539
1579
|
${borderRadius4px};
|
|
1540
1580
|
${borderBox};
|
|
1541
1581
|
${border(1, rest)};
|
|
1542
|
-
|
|
1582
|
+
width: 100%;
|
|
1543
1583
|
min-height: 40px;
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1584
|
+
${!disabled && `
|
|
1585
|
+
&:not(:focus-within):hover {
|
|
1586
|
+
background-color: ${hover};
|
|
1587
|
+
border-color: ${active};
|
|
1588
|
+
input {
|
|
1589
|
+
background-color: ${hover};
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
`}
|
|
1551
1593
|
&:focus-within {
|
|
1552
1594
|
border-color: ${focus};
|
|
1553
1595
|
}
|
|
@@ -1644,7 +1686,6 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1644
1686
|
${displayBlock};
|
|
1645
1687
|
${positionRelative};
|
|
1646
1688
|
margin-bottom: 20px;
|
|
1647
|
-
/* min-width: 150px; */
|
|
1648
1689
|
height: max-content;
|
|
1649
1690
|
&.error {
|
|
1650
1691
|
.css-${DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
@@ -1659,8 +1700,6 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1659
1700
|
}
|
|
1660
1701
|
&.dgn-dropdown-loading,
|
|
1661
1702
|
&.disabled {
|
|
1662
|
-
${pointerEventsNone};
|
|
1663
|
-
${userSelectNone};
|
|
1664
1703
|
.css-${DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1665
1704
|
border-color: ${systemDisabled};
|
|
1666
1705
|
.css-${IconCSS(viewType, loading, showClear).name} {
|
|
@@ -1754,14 +1793,14 @@ Dropdown.propTypes = {
|
|
|
1754
1793
|
/** display this icon if not found the icon follow iconExpr */
|
|
1755
1794
|
iconDefault: PropTypes.string,
|
|
1756
1795
|
|
|
1757
|
-
/** field name used for icon display<br/>
|
|
1758
|
-
* Example:<br/>
|
|
1759
|
-
* string: 'icon'<br/>
|
|
1760
|
-
* object: {<br/>
|
|
1761
|
-
* key: 'icon',<br/>
|
|
1762
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1763
|
-
* suffix: '.jpg'<br/>
|
|
1764
|
-
* }
|
|
1796
|
+
/** field name used for icon display<br/>
|
|
1797
|
+
* Example:<br/>
|
|
1798
|
+
* string: 'icon'<br/>
|
|
1799
|
+
* object: {<br/>
|
|
1800
|
+
* key: 'icon',<br/>
|
|
1801
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1802
|
+
* suffix: '.jpg'<br/>
|
|
1803
|
+
* }
|
|
1765
1804
|
*/
|
|
1766
1805
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1767
1806
|
key: PropTypes.string,
|
|
@@ -1779,9 +1818,9 @@ Dropdown.propTypes = {
|
|
|
1779
1818
|
/** field name used for text display in input */
|
|
1780
1819
|
keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1781
1820
|
|
|
1782
|
-
/** field name used for text display<br/>
|
|
1783
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1784
|
-
* Note: don't use 'id - name', return undefined
|
|
1821
|
+
/** field name used for text display<br/>
|
|
1822
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1823
|
+
* Note: don't use 'id - name', return undefined
|
|
1785
1824
|
*/
|
|
1786
1825
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1787
1826
|
|
|
@@ -1791,9 +1830,9 @@ Dropdown.propTypes = {
|
|
|
1791
1830
|
/** the field name used for the returned result */
|
|
1792
1831
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1793
1832
|
|
|
1794
|
-
/**
|
|
1795
|
-
* duration wait enter search content on search<br/>
|
|
1796
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1833
|
+
/**
|
|
1834
|
+
* duration wait enter search content on search<br/>
|
|
1835
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1797
1836
|
*/
|
|
1798
1837
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1799
1838
|
|
|
@@ -1860,22 +1899,19 @@ Dropdown.propTypes = {
|
|
|
1860
1899
|
/** The array of elements that appear in the dropdown */
|
|
1861
1900
|
dataSource: PropTypes.array,
|
|
1862
1901
|
|
|
1863
|
-
/**
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
/** function displays items by custom<br/>
|
|
1867
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1868
|
-
* --> such as: displayExpr={'name - role'}
|
|
1902
|
+
/** function displays items by custom<br/>
|
|
1903
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1904
|
+
* --> such as: displayExpr={'name - role'}
|
|
1869
1905
|
*/
|
|
1870
1906
|
renderItem: PropTypes.func,
|
|
1871
1907
|
|
|
1872
|
-
/** function displays selected items by custom, example:<br/>
|
|
1873
|
-
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1908
|
+
/** function displays selected items by custom, example:<br/>
|
|
1909
|
+
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1874
1910
|
*/
|
|
1875
1911
|
renderSelectedItem: PropTypes.func,
|
|
1876
1912
|
|
|
1877
|
-
/** the function will run when entering input<br/>
|
|
1878
|
-
* if undefined: the filter function will run (default)
|
|
1913
|
+
/** the function will run when entering input<br/>
|
|
1914
|
+
* if undefined: the filter function will run (default)
|
|
1879
1915
|
*/
|
|
1880
1916
|
onInput: PropTypes.func,
|
|
1881
1917
|
|
|
@@ -1888,10 +1924,28 @@ Dropdown.propTypes = {
|
|
|
1888
1924
|
/** the function will run when scroll near the end */
|
|
1889
1925
|
onLoadMore: PropTypes.func,
|
|
1890
1926
|
|
|
1927
|
+
/** the function will run when dropdown closed */
|
|
1928
|
+
onClosed: PropTypes.func,
|
|
1929
|
+
|
|
1891
1930
|
/** the contents in Dropdown box (Exp: TreeView) */
|
|
1892
1931
|
children: PropTypes.node,
|
|
1893
1932
|
|
|
1894
|
-
/**
|
|
1895
|
-
|
|
1933
|
+
/**
|
|
1934
|
+
* ref methods
|
|
1935
|
+
*
|
|
1936
|
+
* how to get component element? ref.current
|
|
1937
|
+
*
|
|
1938
|
+
* how to call method? ref.current.instance.{method}
|
|
1939
|
+
*
|
|
1940
|
+
* * showDropdown(): Show dropdown
|
|
1941
|
+
* * closeDropdown(): Close dropdown
|
|
1942
|
+
* * onClear(): Clear selected value
|
|
1943
|
+
* * setPreviousValue(): Set value to previous value
|
|
1944
|
+
* * setValue(value): Set value of dropdown
|
|
1945
|
+
* * @param {value} - string || number || array
|
|
1946
|
+
*/
|
|
1947
|
+
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1948
|
+
current: PropTypes.instanceOf(Element)
|
|
1949
|
+
})])
|
|
1896
1950
|
};
|
|
1897
1951
|
export default Dropdown;
|
|
@@ -1,102 +1,100 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
|
-
import { memo, useMemo,
|
|
4
|
+
import { memo, useMemo, useContext, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { jsx, css } from '@emotion/core';
|
|
7
7
|
import ModalContext from './context';
|
|
8
|
-
import { brand22 } from '../../styles/colors';
|
|
9
8
|
import { ButtonIcon, Typography } from '../';
|
|
9
|
+
import { alignCenter, borderBox, flexRow, justifyBetween, positionRelative } from '../../styles/general';
|
|
10
|
+
import { color as colors } from '../../styles/colors';
|
|
11
|
+
const {
|
|
12
|
+
fill: {
|
|
13
|
+
headerbar
|
|
14
|
+
}
|
|
15
|
+
} = colors;
|
|
10
16
|
const ModalHeader = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
11
17
|
title,
|
|
12
18
|
className,
|
|
13
19
|
children,
|
|
14
20
|
style,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, ref) => {
|
|
18
|
-
if (!ref) {
|
|
19
|
-
ref = useRef(null);
|
|
20
|
-
}
|
|
21
|
-
|
|
21
|
+
showClose
|
|
22
|
+
}, reference) => {
|
|
22
23
|
const modal = useContext(ModalContext);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const HeaderTitle = css`
|
|
40
|
-
display: flex;
|
|
41
|
-
position: relative;
|
|
42
|
-
align-items: center;
|
|
43
|
-
width: calc(100% - 40px);
|
|
44
|
-
`;
|
|
45
|
-
const ClearIconBox = css`
|
|
46
|
-
display: flex;
|
|
47
|
-
position: relative;
|
|
48
|
-
width: 24px;
|
|
49
|
-
height: 24px;
|
|
50
|
-
justify-content: center;
|
|
51
|
-
align-items: center;
|
|
52
|
-
margin-left: 16px;
|
|
53
|
-
`;
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
!!refs && refs(ref);
|
|
56
|
-
}, []);
|
|
57
|
-
const Header = useMemo(() => jsx("div", {
|
|
58
|
-
css: ModalHeaderBox,
|
|
59
|
-
className: 'DGN-UI-Modal-Header ' + className,
|
|
60
|
-
...props,
|
|
24
|
+
const ref = useRef(null);
|
|
25
|
+
|
|
26
|
+
const _ModalHeaderCSS = ModalHeaderCSS(modal);
|
|
27
|
+
|
|
28
|
+
useImperativeHandle(reference, () => {
|
|
29
|
+
const currentRef = ref.current || {};
|
|
30
|
+
const _instance = {}; // methods
|
|
31
|
+
|
|
32
|
+
_instance.__proto__ = {}; // hidden methods
|
|
33
|
+
|
|
34
|
+
currentRef.instance = _instance;
|
|
35
|
+
return currentRef;
|
|
36
|
+
});
|
|
37
|
+
return useMemo(() => jsx("div", {
|
|
38
|
+
css: _ModalHeaderCSS,
|
|
39
|
+
className: ['DGN-UI-Modal-Header', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
61
40
|
style: style,
|
|
62
41
|
onMouseDown: modal.onMoveModal,
|
|
63
42
|
ref: ref
|
|
64
|
-
}, jsx("div", {
|
|
65
|
-
css: HeaderTitle
|
|
66
43
|
}, jsx(Typography, {
|
|
67
44
|
type: 'h3',
|
|
68
45
|
style: {
|
|
69
46
|
whiteSpace: 'nowrap',
|
|
70
47
|
overflow: 'hidden',
|
|
71
|
-
textOverflow: 'ellipsis'
|
|
48
|
+
textOverflow: 'ellipsis',
|
|
49
|
+
width: '100%'
|
|
72
50
|
}
|
|
73
|
-
}, children ? children : title)
|
|
74
|
-
css: ClearIconBox
|
|
75
|
-
}, jsx(ButtonIcon, {
|
|
51
|
+
}, children ? children : title), showClose && jsx(ButtonIcon, {
|
|
76
52
|
viewType: 'ghost',
|
|
77
|
-
name: '
|
|
53
|
+
name: 'Close',
|
|
54
|
+
style: {
|
|
55
|
+
marginLeft: 16
|
|
56
|
+
},
|
|
78
57
|
onClick: modal.close
|
|
79
|
-
}))
|
|
80
|
-
return Header;
|
|
58
|
+
})), [children, title, style, className, showClose]);
|
|
81
59
|
}));
|
|
60
|
+
|
|
61
|
+
const ModalHeaderCSS = modal => css`
|
|
62
|
+
${flexRow};
|
|
63
|
+
${positionRelative};
|
|
64
|
+
${justifyBetween};
|
|
65
|
+
${alignCenter};
|
|
66
|
+
${borderBox};
|
|
67
|
+
background-color: ${headerbar};
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 56px;
|
|
70
|
+
padding: 16px 24px;
|
|
71
|
+
margin-bottom: 2px;
|
|
72
|
+
border-radius: 4px 4px 0px 0px;
|
|
73
|
+
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);
|
|
74
|
+
cursor: ${modal.onMoveModal ? 'move' : 'inherit'};
|
|
75
|
+
order: 1;
|
|
76
|
+
`;
|
|
77
|
+
|
|
82
78
|
ModalHeader.defaultProps = {
|
|
83
79
|
title: '',
|
|
84
|
-
className: ''
|
|
80
|
+
className: '',
|
|
81
|
+
style: {},
|
|
82
|
+
showClose: true
|
|
85
83
|
};
|
|
86
84
|
ModalHeader.propTypes = {
|
|
87
|
-
/**
|
|
85
|
+
/** style inline of component */
|
|
88
86
|
style: PropTypes.object,
|
|
89
87
|
|
|
90
|
-
/** class
|
|
88
|
+
/** class for component */
|
|
91
89
|
className: PropTypes.string,
|
|
92
90
|
|
|
93
|
-
/**
|
|
94
|
-
|
|
91
|
+
/** content for header (not work when have children) */
|
|
92
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
95
93
|
|
|
96
|
-
/**
|
|
97
|
-
|
|
94
|
+
/** content in header (priority) */
|
|
95
|
+
children: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
98
96
|
|
|
99
|
-
/**
|
|
100
|
-
|
|
97
|
+
/** show close modal button */
|
|
98
|
+
showClose: PropTypes.bool
|
|
101
99
|
};
|
|
102
100
|
export default ModalHeader;
|