diginet-core-ui 1.3.35 → 1.3.36
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/MHRM09N0005.svg +7 -0
- package/assets/images/menu/dhr/MHRM13N0001.svg +16 -0
- package/assets/images/menu/dhr/MHRP39N0017.svg +11 -0
- package/assets/images/menu/erp/W05F0013N0000.svg +9 -0
- package/components/avatar/index.js +167 -127
- package/components/badge/index.js +5 -5
- package/components/button/index.js +13 -13
- package/components/form-control/attachment/index.js +58 -10
- package/components/form-control/date-range-picker/index.js +6 -6
- package/components/form-control/dropdown/index.js +21 -21
- package/components/form-control/dropdown-box/index.js +94 -97
- package/components/form-control/radio/index.js +11 -11
- package/components/form-control/text-input/index.js +4 -4
- package/components/form-control/toggle/index.js +6 -6
- package/components/popover/index.js +227 -122
- package/components/popup/v2/index.js +7 -7
- package/components/progress/circular.js +12 -12
- package/components/tab/tab-container.js +2 -2
- package/components/tab/tab-header.js +2 -2
- package/components/tab/tab-panel.js +2 -2
- package/components/tab/tab.js +2 -2
- package/components/tooltip/index.js +157 -153
- package/components/typography/index.js +155 -42
- package/icons/effect.js +15 -15
- package/package.json +1 -1
- package/readme.md +11 -0
- package/styles/general.js +21 -0
- package/theme/settings.js +9 -18
- package/utils/intersectionObserver.js +41 -0
- package/utils/number.js +6 -6
|
@@ -158,6 +158,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
158
158
|
const attachmentInputRef = useRef(null);
|
|
159
159
|
const attachmentImageRef = useRef(null);
|
|
160
160
|
const attachedRef = useRef(null);
|
|
161
|
+
const newAttachedRef = useRef([]);
|
|
161
162
|
const popupRef = useRef(null);
|
|
162
163
|
const popoverRef = useRef(null);
|
|
163
164
|
const isDeleteAll = useRef(false);
|
|
@@ -1165,6 +1166,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1165
1166
|
files.splice(index, 1);
|
|
1166
1167
|
allNewAttached.delete('files');
|
|
1167
1168
|
files.forEach(file => allNewAttached.append('files', file));
|
|
1169
|
+
newAttachedRef.current = files || [];
|
|
1168
1170
|
}
|
|
1169
1171
|
|
|
1170
1172
|
attachmentInputRef.current.files = dt.files;
|
|
@@ -1175,10 +1177,12 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1175
1177
|
if (multiple || inputProps && inputProps.multiple) {
|
|
1176
1178
|
for (let file of files) {
|
|
1177
1179
|
allNewAttached.append('files', file);
|
|
1180
|
+
newAttachedRef.current.push(file);
|
|
1178
1181
|
}
|
|
1179
1182
|
} else if (files[0]) {
|
|
1180
1183
|
allNewAttached.delete('files');
|
|
1181
1184
|
allNewAttached.append('files', files[0]);
|
|
1185
|
+
newAttachedRef.current = [files[0]];
|
|
1182
1186
|
} // attachmentInputRef.current.files = allNewAttached.getAll('files');
|
|
1183
1187
|
|
|
1184
1188
|
};
|
|
@@ -1197,6 +1201,20 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1197
1201
|
return false;
|
|
1198
1202
|
};
|
|
1199
1203
|
|
|
1204
|
+
const checkExistingFileInData = newFile => {
|
|
1205
|
+
const files = data;
|
|
1206
|
+
|
|
1207
|
+
if (files && files.length) {
|
|
1208
|
+
const length = files.length;
|
|
1209
|
+
|
|
1210
|
+
for (let i = 0; i < length; i++) {
|
|
1211
|
+
if (parseStringify2(newFile) === parseStringify2(files[i], true)) return true;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
return false;
|
|
1216
|
+
};
|
|
1217
|
+
|
|
1200
1218
|
const checkAcceptFileType = newFile => {
|
|
1201
1219
|
if (!accept || !accept.length) return true;
|
|
1202
1220
|
const type = typeof accept === 'string' ? accept : accept.join('-');
|
|
@@ -1437,18 +1455,26 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1437
1455
|
webkitRelativePath: fileInfo.webkitRelativePath
|
|
1438
1456
|
});
|
|
1439
1457
|
|
|
1458
|
+
const parseStringify2 = (fileInfo, inData) => JSON.stringify({
|
|
1459
|
+
name: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo[inData ? 'FileName' : 'name'],
|
|
1460
|
+
size: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo[inData ? 'FileSize' : 'size']
|
|
1461
|
+
});
|
|
1462
|
+
|
|
1440
1463
|
const mountDomain = item => {
|
|
1441
1464
|
if (!item) return item;
|
|
1465
|
+
const cloneItem = JSON.parse(JSON.stringify(item));
|
|
1442
1466
|
|
|
1443
|
-
if (
|
|
1444
|
-
|
|
1445
|
-
|
|
1467
|
+
if (domain) {
|
|
1468
|
+
if (!/\/$/.test(domain)) {
|
|
1469
|
+
domain = domain + '/';
|
|
1470
|
+
}
|
|
1446
1471
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1472
|
+
if (cloneItem !== null && cloneItem !== void 0 && cloneItem.URL) {
|
|
1473
|
+
cloneItem.URL = cloneItem.URL.indexOf('http') < 0 ? domain + cloneItem.URL : cloneItem.URL;
|
|
1474
|
+
}
|
|
1449
1475
|
}
|
|
1450
1476
|
|
|
1451
|
-
return
|
|
1477
|
+
return cloneItem;
|
|
1452
1478
|
};
|
|
1453
1479
|
|
|
1454
1480
|
const stripDomain = () => {
|
|
@@ -1539,19 +1565,22 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1539
1565
|
};
|
|
1540
1566
|
}, [unitSize, onChange]);
|
|
1541
1567
|
useEffect(() => {
|
|
1568
|
+
var _newAttachedRef$curre;
|
|
1569
|
+
|
|
1542
1570
|
oldAttached.length = 0;
|
|
1571
|
+
afterChangeFile(((data === null || data === void 0 ? void 0 : data.length) || 0) + (((_newAttachedRef$curre = newAttachedRef.current) === null || _newAttachedRef$curre === void 0 ? void 0 : _newAttachedRef$curre.length) || 0));
|
|
1543
1572
|
|
|
1544
1573
|
if (data) {
|
|
1545
|
-
|
|
1546
|
-
|
|
1574
|
+
// Load files data was upload
|
|
1547
1575
|
const length = data.length;
|
|
1548
1576
|
|
|
1549
1577
|
for (let i = 0; i < length; i++) {
|
|
1550
|
-
const item =
|
|
1578
|
+
const item = mountDomain(data[i]);
|
|
1551
1579
|
const newAttach = getItemHTMLFromData(item, i);
|
|
1552
1580
|
|
|
1553
1581
|
if (Object.prototype.toString.call(item) === '[object File]') {
|
|
1554
1582
|
allNewAttached.append('files', item);
|
|
1583
|
+
newAttachedRef.current.push(item);
|
|
1555
1584
|
} else {
|
|
1556
1585
|
oldAttached.push(item);
|
|
1557
1586
|
}
|
|
@@ -1563,6 +1592,25 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1563
1592
|
}
|
|
1564
1593
|
}
|
|
1565
1594
|
|
|
1595
|
+
if (newAttachedRef.current) {
|
|
1596
|
+
const length = newAttachedRef.current.length;
|
|
1597
|
+
|
|
1598
|
+
for (let i = length - 1; i >= 0; i--) {
|
|
1599
|
+
const item = newAttachedRef.current[i];
|
|
1600
|
+
|
|
1601
|
+
if (checkExistingFileInData(item)) {
|
|
1602
|
+
newAttachedRef.current.splice(i, 1);
|
|
1603
|
+
} else {
|
|
1604
|
+
const newAttach = getItemHTMLFromData(item, i);
|
|
1605
|
+
allNewAttached.append('files', item);
|
|
1606
|
+
attached.push(item);
|
|
1607
|
+
const newElement = document.createElement('div');
|
|
1608
|
+
newElement.className = 'attachment-row';
|
|
1609
|
+
ReactDOM.render(newAttach, attachedRef.current.appendChild(newElement));
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1566
1614
|
return () => {
|
|
1567
1615
|
if (attachedRef.current) {
|
|
1568
1616
|
attachedRef.current.innerHTML = null;
|
|
@@ -1688,7 +1736,7 @@ const Attachment = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1688
1736
|
}))), jsx("div", {
|
|
1689
1737
|
css: AttachmentImage,
|
|
1690
1738
|
ref: attachmentImageRef
|
|
1691
|
-
}, !readOnly && jsx("div", {
|
|
1739
|
+
}, !(readOnly || disabled) && jsx("div", {
|
|
1692
1740
|
css: AttachmentImageCenter
|
|
1693
1741
|
}, jsx("div", {
|
|
1694
1742
|
css: AttachmentImageContent
|
|
@@ -458,8 +458,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
458
458
|
tableData = [],
|
|
459
459
|
weekDateFirst = getDateOfWeek(firstDay),
|
|
460
460
|
weekDateLast = getDateOfWeek(lastDay);
|
|
461
|
-
/**
|
|
462
|
-
* days of previous month
|
|
461
|
+
/**
|
|
462
|
+
* days of previous month
|
|
463
463
|
*/
|
|
464
464
|
|
|
465
465
|
for (let i = weekDateFirst; i > 0; i--) {
|
|
@@ -472,8 +472,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
472
472
|
className: unique.day.day
|
|
473
473
|
})));
|
|
474
474
|
}
|
|
475
|
-
/**
|
|
476
|
-
* days of current month
|
|
475
|
+
/**
|
|
476
|
+
* days of current month
|
|
477
477
|
*/
|
|
478
478
|
|
|
479
479
|
|
|
@@ -487,8 +487,8 @@ const DateRangePickerV2 = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
487
487
|
}, jsx(Typography, { ...typographyProps(unique.day.day)
|
|
488
488
|
}, i + 1)));
|
|
489
489
|
}
|
|
490
|
-
/**
|
|
491
|
-
* days of next month
|
|
490
|
+
/**
|
|
491
|
+
* days of next month
|
|
492
492
|
*/
|
|
493
493
|
|
|
494
494
|
|
|
@@ -1754,14 +1754,14 @@ Dropdown.propTypes = {
|
|
|
1754
1754
|
/** display this icon if not found the icon follow iconExpr */
|
|
1755
1755
|
iconDefault: PropTypes.string,
|
|
1756
1756
|
|
|
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
|
-
* }
|
|
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
|
+
* }
|
|
1765
1765
|
*/
|
|
1766
1766
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1767
1767
|
key: PropTypes.string,
|
|
@@ -1779,9 +1779,9 @@ Dropdown.propTypes = {
|
|
|
1779
1779
|
/** field name used for text display in input */
|
|
1780
1780
|
keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1781
1781
|
|
|
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
|
|
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
|
|
1785
1785
|
*/
|
|
1786
1786
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1787
1787
|
|
|
@@ -1791,9 +1791,9 @@ Dropdown.propTypes = {
|
|
|
1791
1791
|
/** the field name used for the returned result */
|
|
1792
1792
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1793
1793
|
|
|
1794
|
-
/**
|
|
1795
|
-
* duration wait enter search content on search<br/>
|
|
1796
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1794
|
+
/**
|
|
1795
|
+
* duration wait enter search content on search<br/>
|
|
1796
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1797
1797
|
*/
|
|
1798
1798
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1799
1799
|
|
|
@@ -1863,19 +1863,19 @@ Dropdown.propTypes = {
|
|
|
1863
1863
|
/** The function to get ref of Dropdown component */
|
|
1864
1864
|
refs: PropTypes.func,
|
|
1865
1865
|
|
|
1866
|
-
/** function displays items by custom<br/>
|
|
1867
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1868
|
-
* --> such as: displayExpr={'name - role'}
|
|
1866
|
+
/** function displays items by custom<br/>
|
|
1867
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1868
|
+
* --> such as: displayExpr={'name - role'}
|
|
1869
1869
|
*/
|
|
1870
1870
|
renderItem: PropTypes.func,
|
|
1871
1871
|
|
|
1872
|
-
/** function displays selected items by custom, example:<br/>
|
|
1873
|
-
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1872
|
+
/** function displays selected items by custom, example:<br/>
|
|
1873
|
+
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1874
1874
|
*/
|
|
1875
1875
|
renderSelectedItem: PropTypes.func,
|
|
1876
1876
|
|
|
1877
|
-
/** the function will run when entering input<br/>
|
|
1878
|
-
* if undefined: the filter function will run (default)
|
|
1877
|
+
/** the function will run when entering input<br/>
|
|
1878
|
+
* if undefined: the filter function will run (default)
|
|
1879
1879
|
*/
|
|
1880
1880
|
onInput: PropTypes.func,
|
|
1881
1881
|
|
|
@@ -14,6 +14,9 @@ const {
|
|
|
14
14
|
paragraph1
|
|
15
15
|
} = typography;
|
|
16
16
|
const {
|
|
17
|
+
system: {
|
|
18
|
+
white
|
|
19
|
+
},
|
|
17
20
|
semantic: {
|
|
18
21
|
info
|
|
19
22
|
},
|
|
@@ -28,6 +31,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
28
31
|
label,
|
|
29
32
|
placeholder,
|
|
30
33
|
startIcon,
|
|
34
|
+
endIcon,
|
|
31
35
|
viewType,
|
|
32
36
|
value,
|
|
33
37
|
openOnClickAt,
|
|
@@ -42,88 +46,19 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
42
46
|
onOpened,
|
|
43
47
|
onClosed,
|
|
44
48
|
onChangeInput,
|
|
45
|
-
delayOnInput
|
|
46
|
-
...props
|
|
49
|
+
delayOnInput
|
|
47
50
|
}, reference) => {
|
|
48
51
|
const ref = useRef(null);
|
|
49
|
-
const inputBaseRef = useRef(null);
|
|
50
52
|
const dropdownBoxRef = useRef(null);
|
|
51
|
-
const dropdownIconRef = useRef(null);
|
|
52
53
|
const [unique] = useState(randomString(6, {
|
|
53
54
|
allowNumber: false,
|
|
54
55
|
allowSymbol: false
|
|
55
56
|
}));
|
|
56
57
|
const [open, setOpen] = useState(false);
|
|
57
|
-
/* Start styled */
|
|
58
|
-
|
|
59
|
-
const DropdownBoxRoot = css`
|
|
60
|
-
&.DGN-UI-Dropdown-Box {
|
|
61
|
-
${displayBlock}
|
|
62
|
-
${positionRelative}
|
|
63
|
-
min-width: 150px;
|
|
64
|
-
height: max-content;
|
|
65
|
-
.end-icon > .DGN-UI-Icon {
|
|
66
|
-
transition: transform 250ms;
|
|
67
|
-
}
|
|
68
|
-
&.dropdown-showing {
|
|
69
|
-
.end-icon > .DGN-UI-ButtonIcon {
|
|
70
|
-
transform: rotateX(180deg);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
.DGN-UI-InputBase {
|
|
74
|
-
background-color: ${bgColor ? bgColor === true ? fillDisabled : bgColor : 'inherit'};
|
|
75
|
-
&.underlined {
|
|
76
|
-
height: 32px;
|
|
77
|
-
}
|
|
78
|
-
&.dropdown-focus {
|
|
79
|
-
background-color: inherit;
|
|
80
|
-
&::after {
|
|
81
|
-
border-bottom-color: ${info};
|
|
82
|
-
transform: scaleX(1);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
`;
|
|
88
|
-
const DropdownBoxCSS = css`
|
|
89
|
-
${displayBlock}
|
|
90
|
-
${paragraph1};
|
|
91
|
-
${positionFixed}
|
|
92
|
-
${borderBox}
|
|
93
|
-
${borderRadius4px}
|
|
94
|
-
width: 100%;
|
|
95
|
-
height: auto;
|
|
96
|
-
max-height: 80%;
|
|
97
|
-
overflow: auto;
|
|
98
|
-
padding: 16px;
|
|
99
|
-
background-color: #fff;
|
|
100
|
-
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
101
|
-
opacity: 0;
|
|
102
|
-
transition: opacity 0.3s;
|
|
103
|
-
z-index: ${zIndex};
|
|
104
|
-
&::-webkit-scrollbar {
|
|
105
|
-
${borderRadius4px}
|
|
106
|
-
width: 8px;
|
|
107
|
-
background-color: #fff !important;
|
|
108
|
-
}
|
|
109
|
-
&::-webkit-scrollbar-thumb {
|
|
110
|
-
${borderRadius4px}
|
|
111
|
-
mix-blend-mode: normal;
|
|
112
|
-
background-color: ${scrollbar} !important;
|
|
113
|
-
background-clip: content-box;
|
|
114
|
-
}
|
|
115
|
-
.DGN-UI-TreeView {
|
|
116
|
-
padding: 1px;
|
|
117
|
-
}
|
|
118
|
-
`;
|
|
119
|
-
/* End styled */
|
|
120
|
-
|
|
121
58
|
/* Start handler */
|
|
122
59
|
|
|
123
60
|
const onTriggerDropdown = e => {
|
|
124
61
|
if (!open) {
|
|
125
|
-
// ref.current.classList.add('dropdown-showing');
|
|
126
|
-
// inputBaseRef.current.classList.add('dropdown-focus');
|
|
127
62
|
openDropdownBox();
|
|
128
63
|
} else {
|
|
129
64
|
closeDropdownBox(true);
|
|
@@ -154,9 +89,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
154
89
|
} = ref.current.getBoundingClientRect();
|
|
155
90
|
let positionTop = top + height + 2;
|
|
156
91
|
dropdownBoxRef.current.style.cssText = `top: ${positionTop}px; left: ${left}px; width: ${width}px;`;
|
|
157
|
-
dropdownBoxRef.current.style.opacity = 1;
|
|
158
|
-
// window.addEventListener('scroll', updatePositionDropdown);
|
|
159
|
-
|
|
92
|
+
dropdownBoxRef.current.style.opacity = 1;
|
|
160
93
|
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
161
94
|
document.addEventListener('keydown', pressESCHandler);
|
|
162
95
|
!!onOpened && onOpened(ref.current);
|
|
@@ -174,13 +107,7 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
174
107
|
|
|
175
108
|
if (dropdownBoxRef.current) {
|
|
176
109
|
dropdownBoxRef.current.style.pointerEvents = `none`;
|
|
177
|
-
dropdownBoxRef.current.style.opacity = 0;
|
|
178
|
-
// ref.current.classList.remove('dropdown-showing');
|
|
179
|
-
// }
|
|
180
|
-
// if (inputBaseRef.current) {
|
|
181
|
-
// inputBaseRef.current.classList.remove('dropdown-focus');
|
|
182
|
-
// }
|
|
183
|
-
|
|
110
|
+
dropdownBoxRef.current.style.opacity = 0;
|
|
184
111
|
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
185
112
|
timing[unique + 'Box'] = setTimeout(() => {
|
|
186
113
|
clearTimeout(timing[unique + 'Box']);
|
|
@@ -213,45 +140,112 @@ const DropdownBox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
213
140
|
closeDropdownBox(true);
|
|
214
141
|
}
|
|
215
142
|
}));
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
143
|
+
|
|
144
|
+
const renderEndIcon = () => {
|
|
145
|
+
return endIcon && jsx(ButtonIcon, {
|
|
146
|
+
viewType: 'ghost',
|
|
147
|
+
name: endIcon,
|
|
148
|
+
onClick: openOnClickAt === 'icon' ? onTriggerDropdown : null
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
|
|
222
152
|
return jsx(Fragment, null, jsx("div", {
|
|
223
153
|
ref: ref,
|
|
224
|
-
css:
|
|
225
|
-
className: ['DGN-UI-Dropdown-Box', open && 'dropdown-showing', className].join(' ').trim(),
|
|
226
|
-
style: style
|
|
227
|
-
|
|
228
|
-
}, label ? jsx(Label, {
|
|
229
|
-
required: required,
|
|
230
|
-
...labelProps
|
|
154
|
+
css: DropdownBoxRootCSS(bgColor),
|
|
155
|
+
className: ['DGN-UI-Dropdown-Box', open && 'dropdown-showing', className].join(' ').trim().replace(/\s+/g, ' '),
|
|
156
|
+
style: style
|
|
157
|
+
}, label ? jsx(Label, { ...labelProps
|
|
231
158
|
}, label) : null, jsx(InputBase, { ...inputProps,
|
|
232
159
|
className: open && 'dropdown-focus',
|
|
233
160
|
style: inputStyle,
|
|
234
161
|
viewType: viewType,
|
|
235
|
-
ref: inputBaseRef,
|
|
236
162
|
inputRef: inputRef,
|
|
237
163
|
placeholder: placeholder,
|
|
238
164
|
value: value,
|
|
239
165
|
startIcon: startIcon,
|
|
240
|
-
endIcon:
|
|
166
|
+
endIcon: renderEndIcon(),
|
|
241
167
|
onChange: _onChangeInput,
|
|
242
168
|
onClick: openOnClickAt === 'full' ? onTriggerDropdown : null
|
|
243
169
|
})), open && /*#__PURE__*/createPortal(jsx("div", {
|
|
244
170
|
ref: dropdownBoxRef,
|
|
245
171
|
className: `DGN-UI-Portal DGN-DropdownBox-${unique}`,
|
|
246
|
-
css: DropdownBoxCSS
|
|
172
|
+
css: DropdownBoxCSS(zIndex)
|
|
247
173
|
}, children), document.body));
|
|
248
174
|
}));
|
|
175
|
+
/* Start styled */
|
|
176
|
+
|
|
177
|
+
const DropdownBoxRootCSS = bgColor => css`
|
|
178
|
+
&.DGN-UI-Dropdown-Box {
|
|
179
|
+
${displayBlock}
|
|
180
|
+
${positionRelative}
|
|
181
|
+
min-width: 150px;
|
|
182
|
+
height: max-content;
|
|
183
|
+
.end-icon > .DGN-UI-Icon {
|
|
184
|
+
transition: transform 250ms;
|
|
185
|
+
}
|
|
186
|
+
&.dropdown-showing {
|
|
187
|
+
.end-icon > .DGN-UI-ButtonIcon {
|
|
188
|
+
transform: rotateX(180deg);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
.DGN-UI-InputBase {
|
|
192
|
+
background-color: ${bgColor ? bgColor === true ? fillDisabled : bgColor : 'inherit'};
|
|
193
|
+
&.underlined {
|
|
194
|
+
height: 32px;
|
|
195
|
+
}
|
|
196
|
+
&.dropdown-focus {
|
|
197
|
+
background-color: inherit;
|
|
198
|
+
&::after {
|
|
199
|
+
border-bottom-color: ${info};
|
|
200
|
+
transform: scaleX(1);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
`;
|
|
206
|
+
|
|
207
|
+
const DropdownBoxCSS = zIndex => css`
|
|
208
|
+
${displayBlock};
|
|
209
|
+
${paragraph1};
|
|
210
|
+
${positionFixed};
|
|
211
|
+
${borderBox};
|
|
212
|
+
${borderRadius4px};
|
|
213
|
+
background-color: ${white};
|
|
214
|
+
z-index: ${zIndex};
|
|
215
|
+
width: 100%;
|
|
216
|
+
height: auto;
|
|
217
|
+
max-height: 80%;
|
|
218
|
+
overflow: auto;
|
|
219
|
+
padding: 16px;
|
|
220
|
+
opacity: 0;
|
|
221
|
+
transition: opacity 0.3s;
|
|
222
|
+
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
223
|
+
&::-webkit-scrollbar {
|
|
224
|
+
${borderRadius4px}
|
|
225
|
+
width: 8px;
|
|
226
|
+
background-color: ${white} !important;
|
|
227
|
+
}
|
|
228
|
+
&::-webkit-scrollbar-thumb {
|
|
229
|
+
${borderRadius4px}
|
|
230
|
+
mix-blend-mode: normal;
|
|
231
|
+
background-color: ${scrollbar} !important;
|
|
232
|
+
background-clip: content-box;
|
|
233
|
+
}
|
|
234
|
+
.DGN-UI-TreeView {
|
|
235
|
+
padding: 1px;
|
|
236
|
+
}
|
|
237
|
+
`;
|
|
238
|
+
/* End styled */
|
|
239
|
+
|
|
240
|
+
|
|
249
241
|
DropdownBox.defaultProps = {
|
|
250
242
|
className: '',
|
|
251
243
|
label: '',
|
|
252
244
|
placeholder: '',
|
|
253
|
-
startIcon: '
|
|
245
|
+
startIcon: 'Search',
|
|
246
|
+
endIcon: 'ArrowDown',
|
|
254
247
|
openOnClickAt: 'icon',
|
|
248
|
+
viewType: 'underlined',
|
|
255
249
|
inputProps: {},
|
|
256
250
|
delayOnInput: 700,
|
|
257
251
|
zIndex: 9001
|
|
@@ -272,6 +266,9 @@ DropdownBox.propTypes = {
|
|
|
272
266
|
/** icon at start */
|
|
273
267
|
startIcon: PropTypes.string,
|
|
274
268
|
|
|
269
|
+
/** icon at end */
|
|
270
|
+
endIcon: PropTypes.string,
|
|
271
|
+
|
|
275
272
|
/** background color of DropdownBox input */
|
|
276
273
|
bgColor: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
277
274
|
|
|
@@ -208,18 +208,18 @@ Radio.defaultProps = {
|
|
|
208
208
|
className: ''
|
|
209
209
|
};
|
|
210
210
|
Radio.propTypes = {
|
|
211
|
-
/**
|
|
212
|
-
* If `true`, the component is disabled.
|
|
211
|
+
/**
|
|
212
|
+
* If `true`, the component is disabled.
|
|
213
213
|
*/
|
|
214
214
|
disabled: PropTypes.bool,
|
|
215
215
|
|
|
216
|
-
/**
|
|
217
|
-
* If `true`, the component is checked.
|
|
216
|
+
/**
|
|
217
|
+
* If `true`, the component is checked.
|
|
218
218
|
*/
|
|
219
219
|
checked: PropTypes.bool,
|
|
220
220
|
|
|
221
|
-
/**
|
|
222
|
-
* If `true`, the component is defaultChecked.
|
|
221
|
+
/**
|
|
222
|
+
* If `true`, the component is defaultChecked.
|
|
223
223
|
*/
|
|
224
224
|
defaultChecked: PropTypes.bool,
|
|
225
225
|
|
|
@@ -241,11 +241,11 @@ Radio.propTypes = {
|
|
|
241
241
|
/** props for input */
|
|
242
242
|
inputProps: PropTypes.object,
|
|
243
243
|
|
|
244
|
-
/** Callback fired when the state is changed.
|
|
245
|
-
*
|
|
246
|
-
* @param {object} event The event source of the callback.
|
|
247
|
-
* You can pull out the new value by accessing `event.target.value` (string).
|
|
248
|
-
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
244
|
+
/** Callback fired when the state is changed.
|
|
245
|
+
*
|
|
246
|
+
* @param {object} event The event source of the callback.
|
|
247
|
+
* You can pull out the new value by accessing `event.target.value` (string).
|
|
248
|
+
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
249
249
|
* */
|
|
250
250
|
onChange: PropTypes.func
|
|
251
251
|
};
|
|
@@ -497,10 +497,10 @@ TextInput.propTypes = {
|
|
|
497
497
|
/** on focus function */
|
|
498
498
|
onFocus: PropTypes.func,
|
|
499
499
|
|
|
500
|
-
/** validation value, argument can:<br/>
|
|
501
|
-
* * string: the validation rule. Example required.<br/>
|
|
502
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
503
|
-
* * array: the validation rule list, insist object/string
|
|
500
|
+
/** validation value, argument can:<br/>
|
|
501
|
+
* * string: the validation rule. Example required.<br/>
|
|
502
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
503
|
+
* * array: the validation rule list, insist object/string
|
|
504
504
|
*/
|
|
505
505
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
506
506
|
|
|
@@ -221,8 +221,8 @@ Toggle.propTypes = {
|
|
|
221
221
|
/** Id is randomized randomly to avoid duplication. */
|
|
222
222
|
id: PropTypes.string,
|
|
223
223
|
|
|
224
|
-
/**
|
|
225
|
-
* Name attribute of the `input` element.
|
|
224
|
+
/**
|
|
225
|
+
* Name attribute of the `input` element.
|
|
226
226
|
*/
|
|
227
227
|
name: PropTypes.string,
|
|
228
228
|
|
|
@@ -238,10 +238,10 @@ Toggle.propTypes = {
|
|
|
238
238
|
/** props for input */
|
|
239
239
|
inputProps: PropTypes.object,
|
|
240
240
|
|
|
241
|
-
/** * Callback fired when the state is changed.
|
|
242
|
-
*
|
|
243
|
-
* @param {object} event The event source of the callback.
|
|
244
|
-
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
241
|
+
/** * Callback fired when the state is changed.
|
|
242
|
+
*
|
|
243
|
+
* @param {object} event The event source of the callback.
|
|
244
|
+
* You can pull out the new checked state by accessing `event.target.checked` (boolean).
|
|
245
245
|
*/
|
|
246
246
|
onChange: PropTypes.func
|
|
247
247
|
};
|