diginet-core-ui 1.3.57 → 1.3.58
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.
|
@@ -44,6 +44,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
44
44
|
forTreeView,
|
|
45
45
|
width,
|
|
46
46
|
labelProps,
|
|
47
|
+
stopPropagation,
|
|
47
48
|
...props
|
|
48
49
|
}, reference) => {
|
|
49
50
|
if (!inputRef) {
|
|
@@ -68,7 +69,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
68
69
|
const _CheckBoxInputCSS = CheckBoxInputCSS(_CheckBoxSquareCSS.name, clMain);
|
|
69
70
|
|
|
70
71
|
const handleChange = event => {
|
|
71
|
-
event.stopPropagation();
|
|
72
|
+
stopPropagation && event.stopPropagation();
|
|
72
73
|
if (readOnly || inputProps.readOnly || disabled || inputProps.disabled) return;
|
|
73
74
|
const oldLogicChecked = inputRef.current.checked; //Use for TreeView
|
|
74
75
|
|
|
@@ -278,7 +279,8 @@ Checkbox.defaultProps = {
|
|
|
278
279
|
determinate: true,
|
|
279
280
|
inputProps: {},
|
|
280
281
|
labelProps: {},
|
|
281
|
-
width: 18
|
|
282
|
+
width: 18,
|
|
283
|
+
stopPropagation: true
|
|
282
284
|
};
|
|
283
285
|
Checkbox.propTypes = {
|
|
284
286
|
/** If `true`, the component is checked. */
|
|
@@ -548,10 +548,10 @@ MoneyInput.propTypes = {
|
|
|
548
548
|
/** style inline of input in MoneyInput component */
|
|
549
549
|
inputStyle: PropTypes.object,
|
|
550
550
|
|
|
551
|
-
/** validation value, argument can:<br/>
|
|
552
|
-
* * string: the validation rule. Example required.<br/>
|
|
553
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
554
|
-
* * array: the validation rule list, insist object/string
|
|
551
|
+
/** validation value, argument can:<br/>
|
|
552
|
+
* * string: the validation rule. Example required.<br/>
|
|
553
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
554
|
+
* * array: the validation rule list, insist object/string
|
|
555
555
|
*/
|
|
556
556
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
557
557
|
|
|
@@ -564,13 +564,13 @@ MoneyInput.propTypes = {
|
|
|
564
564
|
/** on input function */
|
|
565
565
|
onInput: PropTypes.func,
|
|
566
566
|
|
|
567
|
-
/**
|
|
568
|
-
* on change function, return an object:<br/>
|
|
569
|
-
* {<br/>
|
|
570
|
-
* value: is a number or null value<br/>
|
|
571
|
-
* target.value: value of input<br/>
|
|
572
|
-
* ...element<br/>
|
|
573
|
-
* }
|
|
567
|
+
/**
|
|
568
|
+
* on change function, return an object:<br/>
|
|
569
|
+
* {<br/>
|
|
570
|
+
* value: is a number or null value<br/>
|
|
571
|
+
* target.value: value of input<br/>
|
|
572
|
+
* ...element<br/>
|
|
573
|
+
* }
|
|
574
574
|
*/
|
|
575
575
|
onChange: PropTypes.func,
|
|
576
576
|
|
|
@@ -4,18 +4,27 @@
|
|
|
4
4
|
import { memo, useMemo, useState, useEffect, useRef, forwardRef, Fragment, useImperativeHandle } from 'react';
|
|
5
5
|
import { render } from 'react-dom';
|
|
6
6
|
import PropTypes from 'prop-types';
|
|
7
|
-
import { jsx } from '@emotion/core';
|
|
8
|
-
import { TreeViewRootCSS } from './css';
|
|
7
|
+
import { jsx, css } from '@emotion/core';
|
|
9
8
|
import { Accordion, AccordionSummary, AccordionDetails, Typography, Checkbox, Divider, InputBase, ButtonIcon } from '..';
|
|
10
9
|
import { mapParent, randomString, removeUnicode } from '../../utils';
|
|
11
10
|
import { getGlobal } from '../../global';
|
|
11
|
+
import { alignCenter, borderBox, cursorPointer, displayBlock, displayInlineBlock, flexRow, positionRelative } from '../../styles/general';
|
|
12
|
+
import theme from '../../theme/settings';
|
|
13
|
+
const {
|
|
14
|
+
colors: {
|
|
15
|
+
fill: {
|
|
16
|
+
focus: fillFocus,
|
|
17
|
+
hover: fillHover,
|
|
18
|
+
pressed: fillPressed
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
} = theme;
|
|
12
22
|
const separatorPattern = /\{\w+\}/g;
|
|
13
23
|
const currentValue = {},
|
|
14
24
|
itemsRenderAsync = {};
|
|
15
25
|
const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
16
26
|
expand,
|
|
17
27
|
disabled,
|
|
18
|
-
disabledMap,
|
|
19
28
|
selectBox,
|
|
20
29
|
multiple,
|
|
21
30
|
selectAll,
|
|
@@ -60,22 +69,20 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
60
69
|
if (multipleValueMode === 'multiple' || disabledRelevantValue) {
|
|
61
70
|
input.classList[determinate ? 'add' : 'remove']('determinate');
|
|
62
71
|
input.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
63
|
-
input.nextElementSibling.classList[determinate ? 'add' : 'remove']('determinate');
|
|
64
|
-
input.nextElementSibling.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
72
|
+
input.nextElementSibling.firstChild.classList[determinate ? 'add' : 'remove']('determinate');
|
|
73
|
+
input.nextElementSibling.firstChild.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
65
74
|
}
|
|
66
|
-
}; //
|
|
67
|
-
|
|
75
|
+
}; // const triggerCheckboxRecursion = (nodes, isChecked) => {
|
|
76
|
+
// nodes.forEach(el => {
|
|
77
|
+
// if (el.classList.contains('non-child')) {
|
|
78
|
+
// el.querySelector('input').checked = isChecked;
|
|
79
|
+
// } else {
|
|
80
|
+
// el.firstChild.querySelector('input').checked = isChecked;
|
|
81
|
+
// triggerCheckboxRecursion(Array.from(el.lastChild.firstChild.childNodes), isChecked);
|
|
82
|
+
// }
|
|
83
|
+
// });
|
|
84
|
+
// };
|
|
68
85
|
|
|
69
|
-
const triggerCheckboxRecursion = (nodes, isChecked) => {
|
|
70
|
-
nodes.forEach(el => {
|
|
71
|
-
if (el.classList.contains('non-child')) {
|
|
72
|
-
el.querySelector('input').checked = isChecked;
|
|
73
|
-
} else {
|
|
74
|
-
el.firstChild.querySelector('input').checked = isChecked;
|
|
75
|
-
triggerCheckboxRecursion(Array.from(el.lastChild.firstChild.childNodes), isChecked);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
86
|
|
|
80
87
|
const checkedParentFollowValue = nodes => {
|
|
81
88
|
if (nodes && nodes !== null && nodes !== void 0 && nodes.length) {
|
|
@@ -331,6 +338,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
331
338
|
};
|
|
332
339
|
|
|
333
340
|
const onClickHandler = (e, data) => {
|
|
341
|
+
if (disabled) return;
|
|
334
342
|
const target = e.target;
|
|
335
343
|
const currentTarget = e.currentTarget;
|
|
336
344
|
let value = typeof data === 'object' ? data[valueExpr] : data;
|
|
@@ -665,9 +673,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
665
673
|
}, jsx(Checkbox, {
|
|
666
674
|
forTreeView: true,
|
|
667
675
|
checked: isTrue,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
676
|
+
value: typeof data === 'object' ? data[valueExpr] : data,
|
|
677
|
+
stopPropagation: false,
|
|
678
|
+
disabled: disabled
|
|
671
679
|
})), renderContent(data, keyArr, index))), jsx(AccordionDetails, {
|
|
672
680
|
id: id
|
|
673
681
|
}, childItems.map((child, i) => renderTreeView(child, index + i, level + 1, sync, id))));
|
|
@@ -686,9 +694,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
686
694
|
}, jsx(Checkbox, {
|
|
687
695
|
forTreeView: true,
|
|
688
696
|
checked: isTrue,
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
697
|
+
value: typeof data === 'object' ? data[valueExpr] : data,
|
|
698
|
+
stopPropagation: false,
|
|
699
|
+
disabled: disabled
|
|
692
700
|
})), renderContent(data, keyArr, index));
|
|
693
701
|
};
|
|
694
702
|
|
|
@@ -702,6 +710,7 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
702
710
|
if (searchDelayTime) {
|
|
703
711
|
var _searchDelayTime$matc, _searchDelayTime$matc2;
|
|
704
712
|
|
|
713
|
+
if (searchDelayTime === true) searchDelayTime = getGlobal('delayOnInput');
|
|
705
714
|
const units = {
|
|
706
715
|
m: 60000,
|
|
707
716
|
s: 1000,
|
|
@@ -781,19 +790,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
781
790
|
};
|
|
782
791
|
}
|
|
783
792
|
}, [dataSource, value, multiple, selectBox]);
|
|
784
|
-
useEffect(() => {
|
|
785
|
-
if (disabled && ref.current) {
|
|
786
|
-
const childNodes = ref.current.childNodes;
|
|
787
|
-
Array.from(childNodes).forEach(node => {
|
|
788
|
-
node.classList.add('disabled');
|
|
789
|
-
});
|
|
790
|
-
return () => {
|
|
791
|
-
Array.from(childNodes).forEach(node => {
|
|
792
|
-
node.classList.remove('disabled');
|
|
793
|
-
});
|
|
794
|
-
};
|
|
795
|
-
}
|
|
796
|
-
}, [disabled]);
|
|
797
793
|
useEffect(() => {
|
|
798
794
|
var _Object$keys;
|
|
799
795
|
|
|
@@ -860,14 +856,111 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
860
856
|
forTreeView: true,
|
|
861
857
|
label: selectAllLabel,
|
|
862
858
|
onChange: onSelectAll,
|
|
863
|
-
inputRef: selectAllRef
|
|
859
|
+
inputRef: selectAllRef,
|
|
860
|
+
stopPropagation: false,
|
|
861
|
+
disabled: disabled
|
|
864
862
|
})), jsx(Divider, null)), jsx("div", {
|
|
865
863
|
ref: ref,
|
|
866
864
|
...props,
|
|
867
865
|
className: ['TreeView-Content', disabled ? 'disabled' : '', className].join(' ').trim().replace(/\s+/g, ' ')
|
|
868
|
-
},
|
|
869
|
-
}, [dataSource, value, multiple, selectBox, disabledBoldResult, autoExpandToResult, showChildrenOfResult, searchMode, onChange, searchProps]);
|
|
866
|
+
}, mapParent(dataSource, id, parentID, true).map((data, index) => renderTreeView(data, index.toString(), 0, sync))));
|
|
867
|
+
}, [dataSource, value, renderAsyncWithLength, disabled, showSelectedItems, allowSearch, multiple, selectAll, selectAllLabel, className, selectBox, id, parentID, disabledBoldResult, autoExpandToResult, showChildrenOfResult, searchMode, onChange, searchProps]);
|
|
870
868
|
}));
|
|
869
|
+
const TreeViewRootCSS = css`
|
|
870
|
+
${displayBlock};
|
|
871
|
+
${positionRelative};
|
|
872
|
+
.DGN-UI-Accordion {
|
|
873
|
+
box-shadow: none !important;
|
|
874
|
+
.DGN-UI-Accordion-Summary {
|
|
875
|
+
${alignCenter};
|
|
876
|
+
min-height: 40px;
|
|
877
|
+
padding: 0;
|
|
878
|
+
border-radius: 0;
|
|
879
|
+
&.focus {
|
|
880
|
+
background-color: ${theme.colors.focus};
|
|
881
|
+
}
|
|
882
|
+
.Accordion-Icon-Root {
|
|
883
|
+
${flexRow};
|
|
884
|
+
margin-right: 4px;
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
.DGN-UI-Accordion-Details-Content {
|
|
888
|
+
padding: 0;
|
|
889
|
+
border-radius: 0;
|
|
890
|
+
}
|
|
891
|
+
.Accordion-Icon-Root {
|
|
892
|
+
${flexRow};
|
|
893
|
+
transition: opacity 0.2s ease-out;
|
|
894
|
+
opacity: 1;
|
|
895
|
+
&.DGN-Invisible {
|
|
896
|
+
opacity: 0;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
&.DGN-Hidden {
|
|
900
|
+
display: none !important;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
.TreeView-All,
|
|
904
|
+
.TreeView-Content {
|
|
905
|
+
${displayBlock};
|
|
906
|
+
${positionRelative};
|
|
907
|
+
.DGN-UI-Accordion {
|
|
908
|
+
margin-bottom: 0;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
.TreeView-Item-Checkbox {
|
|
912
|
+
${displayInlineBlock};
|
|
913
|
+
${positionRelative};
|
|
914
|
+
height: 100%;
|
|
915
|
+
margin-right: 8px;
|
|
916
|
+
}
|
|
917
|
+
.TreeView-Item {
|
|
918
|
+
${flexRow};
|
|
919
|
+
${positionRelative};
|
|
920
|
+
${alignCenter};
|
|
921
|
+
${borderBox};
|
|
922
|
+
min-height: 40px;
|
|
923
|
+
text-align: left;
|
|
924
|
+
color: ${theme.colors.text.main};
|
|
925
|
+
width: 100%;
|
|
926
|
+
&.non-child {
|
|
927
|
+
${cursorPointer};
|
|
928
|
+
transition: background-color 300ms ease;
|
|
929
|
+
&.disabled {
|
|
930
|
+
color: ${theme.colors.disabled};
|
|
931
|
+
cursor: no-drop;
|
|
932
|
+
}
|
|
933
|
+
&:not(.disabled) {
|
|
934
|
+
&:hover {
|
|
935
|
+
background-color: ${fillHover};
|
|
936
|
+
}
|
|
937
|
+
&:focus {
|
|
938
|
+
background-color: ${fillFocus};
|
|
939
|
+
}
|
|
940
|
+
&:active {
|
|
941
|
+
background-color: ${fillPressed};
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
&.DGN-Hidden {
|
|
945
|
+
display: none !important;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
&.focus {
|
|
949
|
+
background-color: ${theme.colors.focus};
|
|
950
|
+
}
|
|
951
|
+
&.TreeView-Item-active .DGN-UI-Typography {
|
|
952
|
+
font-weight: bold;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
&.expand-able {
|
|
956
|
+
.TreeView-All {
|
|
957
|
+
margin-left: 34px;
|
|
958
|
+
}
|
|
959
|
+
.TreeView-Item.non-child {
|
|
960
|
+
padding-left: 34px;
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
`;
|
|
871
964
|
TreeView.defaultProps = {
|
|
872
965
|
expand: false,
|
|
873
966
|
disabled: false,
|
|
@@ -903,9 +996,6 @@ TreeView.propTypes = {
|
|
|
903
996
|
/** prevent all event if true */
|
|
904
997
|
disabled: PropTypes.bool,
|
|
905
998
|
|
|
906
|
-
/** Will not map parent from data */
|
|
907
|
-
disabledMap: PropTypes.bool,
|
|
908
|
-
|
|
909
999
|
/** show checkbox in each item */
|
|
910
1000
|
selectBox: PropTypes.bool,
|
|
911
1001
|
|
package/icons/basic.js
CHANGED
|
@@ -1342,6 +1342,54 @@ export const ChatBubble = /*#__PURE__*/memo(({
|
|
|
1342
1342
|
fill: colors[color] || color
|
|
1343
1343
|
}));
|
|
1344
1344
|
});
|
|
1345
|
+
export const Checkin = /*#__PURE__*/memo(({
|
|
1346
|
+
width,
|
|
1347
|
+
height,
|
|
1348
|
+
color = '#7F828E',
|
|
1349
|
+
viewBox = false
|
|
1350
|
+
}) => {
|
|
1351
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
1352
|
+
width: width || 24,
|
|
1353
|
+
height: height || 24,
|
|
1354
|
+
viewBox: "0 0 24 24",
|
|
1355
|
+
fill: "none"
|
|
1356
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
1357
|
+
d: "M11 7L9.6 8.4L12.2 11H2V13H12.2L9.6 15.6L11 17L16 12L11 7ZM20 19H12V21H20C21.1 21 22 20.1 22 19V5C22 3.9 21.1 3 20 3H12V5H20V19Z",
|
|
1358
|
+
fill: colors[color] || color
|
|
1359
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
1360
|
+
width: width || 20,
|
|
1361
|
+
height: height || 18,
|
|
1362
|
+
viewBox: "0 0 20 18",
|
|
1363
|
+
fill: "none"
|
|
1364
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
1365
|
+
d: "M9 4L7.6 5.4L10.2 8H0V10H10.2L7.6 12.6L9 14L14 9L9 4ZM18 16H10V18H18C19.1 18 20 17.1 20 16V2C20 0.9 19.1 0 18 0H10V2H18V16Z",
|
|
1366
|
+
fill: colors[color] || color
|
|
1367
|
+
}));
|
|
1368
|
+
});
|
|
1369
|
+
export const Checkout = /*#__PURE__*/memo(({
|
|
1370
|
+
width,
|
|
1371
|
+
height,
|
|
1372
|
+
color = '#7F828E',
|
|
1373
|
+
viewBox = false
|
|
1374
|
+
}) => {
|
|
1375
|
+
return viewBox ? /*#__PURE__*/React.createElement("svg", {
|
|
1376
|
+
width: width || 24,
|
|
1377
|
+
height: height || 24,
|
|
1378
|
+
viewBox: "0 0 24 24",
|
|
1379
|
+
fill: "none"
|
|
1380
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
1381
|
+
d: "M17 7L15.59 8.41L18.17 11H8V13H18.17L15.59 15.58L17 17L22 12L17 7ZM4 5H12V3H4C2.9 3 2 3.9 2 5V19C2 20.1 2.9 21 4 21H12V19H4V5Z",
|
|
1382
|
+
fill: colors[color] || color
|
|
1383
|
+
})) : /*#__PURE__*/React.createElement("svg", {
|
|
1384
|
+
width: width || 20,
|
|
1385
|
+
height: height || 18,
|
|
1386
|
+
viewBox: "0 0 20 18",
|
|
1387
|
+
fill: "none"
|
|
1388
|
+
}, /*#__PURE__*/React.createElement("path", {
|
|
1389
|
+
d: "M15 4L13.59 5.41L16.17 8H6V10H16.17L13.59 12.58L15 14L20 9L15 4ZM2 2H10V0H2C0.9 0 0 0.9 0 2V16C0 17.1 0.9 18 2 18H10V16H2V2Z",
|
|
1390
|
+
fill: colors[color] || color
|
|
1391
|
+
}));
|
|
1392
|
+
});
|
|
1345
1393
|
export const CheckList = /*#__PURE__*/memo(({
|
|
1346
1394
|
width,
|
|
1347
1395
|
height,
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -38,6 +38,10 @@ npm test
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
## Changelog
|
|
41
|
+
## 1.3.58
|
|
42
|
+
- \[Added\]: Icon– Checkin, Checkout
|
|
43
|
+
- \[Fixed\]: TreeView, Checkbox – Fix bug cannot select by click checkbox
|
|
44
|
+
|
|
41
45
|
## 1.3.57
|
|
42
46
|
- \[Added\]: MenuIcon – MHRM29N0005
|
|
43
47
|
- \[Changed\]: MoneyInput – Update PagingSelector with new design
|