diginet-core-ui 1.3.78 → 1.3.79
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/details.js +2 -6
- package/components/accordion/group.js +2 -9
- package/components/accordion/index.js +2 -15
- package/components/accordion/summary.js +4 -27
- package/components/alert/index.js +98 -137
- package/components/alert/notify.js +97 -166
- package/components/avatar/index.js +4 -63
- package/components/badge/index.js +7 -34
- package/components/button/icon.js +120 -186
- package/components/button/index.js +136 -205
- package/components/button/more.js +0 -12
- package/components/button/ripple-effect.js +46 -44
- package/components/card/body.js +2 -7
- package/components/card/extra.js +2 -7
- package/components/card/footer.js +2 -7
- package/components/card/header.js +2 -7
- package/components/card/index.js +2 -22
- package/components/chart/Pie/Circle.js +0 -1
- package/components/chart/Pie/Sector.js +0 -17
- package/components/chart/Pie/Sectors.js +0 -10
- package/components/chart/Pie/index.js +4 -36
- package/components/chart/Pie-v2/Circle.js +0 -1
- package/components/chart/Pie-v2/Sector.js +0 -13
- package/components/chart/Pie-v2/Sectors.js +0 -20
- package/components/chart/Pie-v2/index.js +11 -38
- package/components/chart/bar/Axis.js +0 -12
- package/components/chart/bar/Bar.js +13 -35
- package/components/chart/bar/Grid.js +0 -18
- package/components/chart/bar/Labels.js +0 -18
- package/components/chart/bar/Points.js +0 -17
- package/components/chart/bar/index.js +6 -26
- package/components/chart/bar-v2/Axis.js +0 -12
- package/components/chart/bar-v2/Bar.js +15 -36
- package/components/chart/bar-v2/Grid.js +0 -18
- package/components/chart/bar-v2/Labels.js +0 -18
- package/components/chart/bar-v2/Points.js +0 -17
- package/components/chart/bar-v2/index.js +6 -26
- package/components/chart/line/Axis.js +4 -16
- package/components/chart/line/Grid.js +2 -19
- package/components/chart/line/Labels.js +0 -18
- package/components/chart/line/Path.js +23 -33
- package/components/chart/line/Point.js +6 -40
- package/components/chart/line/Title.js +0 -3
- package/components/chart/line/index.js +12 -35
- package/components/chart/line-v2/Axis.js +0 -13
- package/components/chart/line-v2/Grid.js +0 -18
- package/components/chart/line-v2/Labels.js +0 -18
- package/components/chart/line-v2/Path.js +23 -33
- package/components/chart/line-v2/Point.js +6 -35
- package/components/chart/line-v2/Title.js +0 -3
- package/components/chart/line-v2/index.js +12 -30
- package/components/check-text/index.js +0 -8
- package/components/check-text/interview-confirmation.js +0 -7
- package/components/check-text/interview-status.js +0 -7
- package/components/chip/attach.js +4 -17
- package/components/chip/index.js +6 -33
- package/components/collapse/index.js +0 -13
- package/components/divider/index.js +0 -8
- package/components/form-control/attachment/index.js +24 -202
- package/components/form-control/calendar/function.js +40 -94
- package/components/form-control/calendar/index.js +5 -30
- package/components/form-control/calendar/range.js +11 -28
- package/components/form-control/checkbox/index.js +4 -37
- package/components/form-control/control/index.js +3 -13
- package/components/form-control/date-picker/index-old.js +18 -0
- package/components/form-control/date-picker/index.js +23 -99
- package/components/form-control/date-range-picker/index.js +86 -221
- package/components/form-control/dropdown/index.js +72 -289
- package/components/form-control/dropdown-box/index.js +6 -35
- package/components/form-control/form/index.js +0 -2
- package/components/form-control/form-group/index.js +1 -6
- package/components/form-control/helper-text/index.js +2 -9
- package/components/form-control/input-base/index.js +218 -399
- package/components/form-control/label/index.js +2 -12
- package/components/form-control/money-input/index.js +43 -132
- package/components/form-control/number-input/index.js +15 -113
- package/components/form-control/number-input/index2.js +78 -119
- package/components/form-control/phone-input/index.js +16 -78
- package/components/form-control/radio/index.js +4 -23
- package/components/form-control/text-input/index.js +33 -256
- package/components/form-control/time-picker/index.js +14 -71
- package/components/form-control/time-picker/swiper.js +21 -73
- package/components/form-control/toggle/index.js +4 -19
- package/components/form-view/helper-text.js +2 -2
- package/components/form-view/index.js +0 -14
- package/components/form-view/input.js +2 -13
- package/components/form-view/label.js +0 -2
- package/components/grid/Col.js +2 -15
- package/components/grid/Container.js +2 -21
- package/components/grid/Row.js +2 -21
- package/components/grid/index.js +2 -43
- package/components/image/index.js +2 -22
- package/components/index.js +62 -31
- package/components/list/list-item-action.js +0 -9
- package/components/list/list-item-icon.js +0 -9
- package/components/list/list-item-text.js +0 -5
- package/components/list/list-item.js +0 -11
- package/components/list/list.js +0 -13
- package/components/list/sub-header.js +0 -4
- package/components/modal/body.js +2 -6
- package/components/modal/footer.js +2 -11
- package/components/modal/header.js +2 -12
- package/components/modal/index.js +2 -10
- package/components/modal/modal.js +11 -52
- package/components/others/extra/index.js +3 -10
- package/components/others/import/index.js +0 -7
- package/components/others/option-wrapper/index.js +4 -7
- package/components/others/scrollbar/index.js +0 -3
- package/components/paging/page-info.js +39 -101
- package/components/paging/page-selector.js +7 -35
- package/components/paging/page-selector2.js +35 -74
- package/components/paper/index.js +0 -11
- package/components/popover/body.js +2 -6
- package/components/popover/footer.js +2 -11
- package/components/popover/header.js +2 -7
- package/components/popover/index.js +39 -123
- package/components/popup/danger_popup.js +0 -19
- package/components/popup/index.js +2 -48
- package/components/popup/proposals_popup.js +10 -49
- package/components/popup/v2/index.js +0 -31
- package/components/progress/circular.js +19 -81
- package/components/progress/linear.js +4 -20
- package/components/rating/index.js +0 -24
- package/components/slider/slider-container.js +3 -40
- package/components/slider/slider-item.js +10 -25
- package/components/status/index.js +2 -16
- package/components/tab/tab-container.js +2 -16
- package/components/tab/tab-header.js +4 -24
- package/components/tab/tab-panel.js +4 -16
- package/components/tab/tab.js +4 -28
- package/components/tooltip/index.js +12 -97
- package/components/tooltip/portal.js +0 -2
- package/components/transfer/index.js +22 -67
- package/components/tree-view/index.js +62 -202
- package/components/typography/index.js +3 -31
- package/global/index.js +0 -8
- package/icons/basic.js +0 -48
- package/icons/effect.js +17 -29
- package/icons/general/clock/clock.js +0 -2
- package/icons/general/color-handler/background.js +0 -2
- package/icons/general/color-handler/text.js +0 -2
- package/icons/general/emoji/emoji.js +0 -2
- package/icons/general/font-properties/bold.js +0 -2
- package/icons/general/font-properties/font-family.js +0 -2
- package/icons/general/font-properties/font-size.js +0 -2
- package/icons/general/font-properties/italic.js +0 -2
- package/icons/general/font-properties/underline.js +0 -2
- package/icons/general/hyperlink/hyperlink.js +0 -2
- package/icons/general/indent/decrease.js +0 -2
- package/icons/general/indent/increase.js +0 -2
- package/icons/general/list/bullets.js +0 -2
- package/icons/general/list/numbering.js +0 -2
- package/icons/general/picture/picture.js +0 -2
- package/icons/general/steps/redo.js +0 -2
- package/icons/general/steps/undo.js +0 -2
- package/icons/general/text-align/center.js +0 -2
- package/icons/general/text-align/justify.js +0 -2
- package/icons/general/text-align/left.js +0 -2
- package/icons/general/text-align/right.js +0 -2
- package/icons/menu/dhr.js +2 -1
- package/icons/menu/index.js +2 -2
- package/icons/menu/v2/index.js +0 -10
- package/package.json +1 -1
- package/readme.md +11 -1
- package/styles/animation.js +15 -58
- package/styles/color-helper.js +24 -54
- package/styles/colors.js +17 -9
- package/styles/general.js +6 -2
- package/styles/typography.js +4 -4
- package/styles/utils.js +2 -2
- package/theme/createBreakpoints.js +7 -18
- package/theme/make-styles.js +2 -5
- package/theme/set-theme.js +3 -6
- package/theme/settings.js +3 -2
- package/theme/theme-provider.js +0 -1
- package/utils/array/array.js +14 -23
- package/utils/classNames.js +0 -5
- package/utils/console.js +0 -6
- package/utils/date.js +13 -82
- package/utils/error/error.js +1 -9
- package/utils/error/errors.js +1 -48
- package/utils/getFileType.js +0 -9
- package/utils/handleBreakpoints.js +0 -5
- package/utils/intersectionObserver.js +0 -5
- package/utils/iterator.js +0 -9
- package/utils/map-parent.js +3 -10
- package/utils/object/extend.js +0 -10
- package/utils/object/object.js +12 -11
- package/utils/parseHTML.js +0 -1
- package/utils/promisify.js +0 -5
- package/utils/randomString.js +0 -7
- package/utils/remove-unicode.js +0 -1
- package/utils/render-portal.js +1 -9
- package/utils/renderHTML.js +4 -6
- package/utils/renderIcon.js +4 -14
- package/utils/sb-template.js +6 -5
- package/utils/string/capitalize.js +0 -1
- package/utils/string/capitalizeSentenceCase.js +0 -2
- package/utils/string/string.js +0 -13
- package/utils/type.js +0 -21
- package/utils/updatePosition.js +4 -5
- package/utils/useDelayUnmount.js +0 -4
- package/utils/useElementSize.js +9 -3
- package/utils/useEventListener.js +12 -6
- package/utils/useInput.js +0 -6
- package/utils/useMediaQuery.js +8 -10
- package/utils/useOnClickOutside.js +0 -2
- package/utils/usePortal.js +3 -10
- package/utils/validate.js +6 -20
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** @jsxRuntime classic */
|
|
2
|
-
|
|
3
2
|
/** @jsx jsx */
|
|
4
3
|
import { memo, useMemo, useState, useEffect, useRef, forwardRef, Fragment, useImperativeHandle } from 'react';
|
|
5
4
|
import { render } from 'react-dom';
|
|
@@ -28,7 +27,7 @@ const {
|
|
|
28
27
|
} = theme;
|
|
29
28
|
const separatorPattern = /\{\w+\}/g;
|
|
30
29
|
const currentValue = {},
|
|
31
|
-
|
|
30
|
+
itemsRenderAsync = {};
|
|
32
31
|
const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
33
32
|
action = {},
|
|
34
33
|
allowSearch,
|
|
@@ -72,7 +71,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
72
71
|
allowNumber: false,
|
|
73
72
|
allowSymbol: false
|
|
74
73
|
}));
|
|
75
|
-
|
|
76
74
|
const determinateCheckbox = (input, determinate) => {
|
|
77
75
|
if (multipleValueMode === 'multiple' || disabledRelevantValue) {
|
|
78
76
|
input.classList[determinate ? 'add' : 'remove']('determinate');
|
|
@@ -80,7 +78,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
80
78
|
input.nextElementSibling.firstChild.classList[determinate ? 'add' : 'remove']('determinate');
|
|
81
79
|
input.nextElementSibling.firstChild.classList[determinate ? 'remove' : 'add']('indeterminate');
|
|
82
80
|
}
|
|
83
|
-
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// const triggerCheckboxRecursion = (nodes, isChecked) => {
|
|
84
84
|
// nodes.forEach(el => {
|
|
85
85
|
// if (el.classList.contains('non-child')) {
|
|
86
86
|
// el.querySelector('input').checked = isChecked;
|
|
@@ -91,40 +91,32 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
91
91
|
// });
|
|
92
92
|
// };
|
|
93
93
|
|
|
94
|
-
|
|
95
94
|
const checkedParentFollowValue = nodes => {
|
|
96
95
|
if (nodes && nodes !== null && nodes !== void 0 && nodes.length) {
|
|
97
96
|
nodes.forEach(node => {
|
|
98
97
|
if (!node.classList.contains('non-child')) {
|
|
99
98
|
const input = node.firstChild.querySelector('input');
|
|
100
|
-
|
|
101
99
|
if (input.checked) {
|
|
102
100
|
if (!input.classList.contains('determinate')) {
|
|
103
101
|
determinateCheckbox(input, true);
|
|
104
102
|
}
|
|
105
|
-
|
|
106
103
|
Array.from(node.querySelectorAll('input')).forEach(el => {
|
|
107
104
|
el.checked = true;
|
|
108
|
-
|
|
109
105
|
if (!el.classList.contains('determinate')) {
|
|
110
106
|
determinateCheckbox(el, true);
|
|
111
107
|
}
|
|
112
108
|
});
|
|
113
109
|
} else {
|
|
114
110
|
var _node$lastChild, _node$lastChild$first;
|
|
115
|
-
|
|
116
111
|
const checkedLeastOfOne = Array.from(node.querySelectorAll('input')).some(el => el.checked);
|
|
117
|
-
|
|
118
112
|
if (checkedLeastOfOne) {
|
|
119
113
|
input.checked = checkedLeastOfOne;
|
|
120
|
-
|
|
121
114
|
if (input.classList.contains('determinate')) {
|
|
122
115
|
determinateCheckbox(input, false);
|
|
123
116
|
}
|
|
124
117
|
} else if (input.checked) {
|
|
125
118
|
input.checked = false;
|
|
126
119
|
}
|
|
127
|
-
|
|
128
120
|
const childNodes = Array.from((node === null || node === void 0 ? void 0 : (_node$lastChild = node.lastChild) === null || _node$lastChild === void 0 ? void 0 : (_node$lastChild$first = _node$lastChild.firstChild) === null || _node$lastChild$first === void 0 ? void 0 : _node$lastChild$first.childNodes) || '');
|
|
129
121
|
checkedParentFollowValue(childNodes);
|
|
130
122
|
}
|
|
@@ -132,48 +124,39 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
132
124
|
});
|
|
133
125
|
}
|
|
134
126
|
};
|
|
135
|
-
|
|
136
127
|
const checkParentCheckbox = node => {
|
|
137
128
|
while (ref.current.contains(node)) {
|
|
138
129
|
node = node.parentNode;
|
|
139
|
-
|
|
140
130
|
if (multipleValueMode === 'multiple' && node.classList.contains('DGN-UI-Accordion-Details-Content')) {
|
|
141
131
|
const childNodes = Array.from(node.childNodes);
|
|
142
|
-
|
|
143
132
|
if (childNodes) {
|
|
144
133
|
var _node$parentNode;
|
|
145
|
-
|
|
146
134
|
// Số lượng input đã check, dùng để kiểm tra là đã check tất cả, check chưa đầy đủ hoặc chưa check phần tử nào
|
|
147
135
|
let determinateQuantity = 0;
|
|
148
136
|
const checkedQuantity = childNodes.reduce((quantity, el) => {
|
|
149
137
|
const input = el.querySelector('input');
|
|
150
138
|
determinateQuantity += +input.classList.contains('determinate');
|
|
151
139
|
return quantity + +input.checked;
|
|
152
|
-
}, 0);
|
|
153
|
-
|
|
140
|
+
}, 0);
|
|
141
|
+
// Accordion root
|
|
154
142
|
node = (_node$parentNode = node.parentNode) === null || _node$parentNode === void 0 ? void 0 : _node$parentNode.parentNode;
|
|
155
|
-
|
|
156
143
|
if (node && node.firstChild) {
|
|
157
144
|
const input = node.firstChild.querySelector('input');
|
|
158
|
-
|
|
159
145
|
if (input) {
|
|
160
146
|
if (!checkedQuantity) {
|
|
161
147
|
input.checked = false;
|
|
162
148
|
currentValue[unique][input.value] = false;
|
|
163
149
|
} else {
|
|
164
150
|
input.checked = true;
|
|
165
|
-
|
|
166
151
|
if (checkedQuantity === (childNodes === null || childNodes === void 0 ? void 0 : childNodes.length) && checkedQuantity === determinateQuantity) {
|
|
167
152
|
if (!input.classList.contains('determinate')) {
|
|
168
153
|
determinateCheckbox(input, true);
|
|
169
154
|
}
|
|
170
|
-
|
|
171
155
|
currentValue[unique][input.value] = true;
|
|
172
156
|
} else {
|
|
173
157
|
if (input.classList.contains('determinate')) {
|
|
174
158
|
determinateCheckbox(input, false);
|
|
175
159
|
}
|
|
176
|
-
|
|
177
160
|
currentValue[unique][input.value] = false;
|
|
178
161
|
}
|
|
179
162
|
}
|
|
@@ -187,7 +170,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
187
170
|
}
|
|
188
171
|
}
|
|
189
172
|
};
|
|
190
|
-
|
|
191
173
|
const checkChildrenCheckbox = (node, isChecked) => {
|
|
192
174
|
// node = node.nextElementSibling?.firstChild;
|
|
193
175
|
// if (node) {
|
|
@@ -201,18 +183,14 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
201
183
|
if (!el.classList.contains('determinate')) {
|
|
202
184
|
determinateCheckbox(el, true);
|
|
203
185
|
}
|
|
204
|
-
|
|
205
186
|
el.checked = isChecked;
|
|
206
187
|
});
|
|
207
188
|
}
|
|
208
189
|
};
|
|
209
|
-
|
|
210
190
|
const checkedSelectAllCheckbox = () => {
|
|
211
191
|
const allInput = Array.from(ref.current.querySelectorAll('input'));
|
|
212
|
-
|
|
213
192
|
if (allInput.some(i => i.checked)) {
|
|
214
193
|
const isCheckedAll = allInput.every(i => i.checked);
|
|
215
|
-
|
|
216
194
|
if (isCheckedAll) {
|
|
217
195
|
if (!selectAllRef.current.classList.contains('determinate')) {
|
|
218
196
|
determinateCheckbox(selectAllRef.current, true);
|
|
@@ -222,18 +200,15 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
222
200
|
determinateCheckbox(selectAllRef.current, false);
|
|
223
201
|
}
|
|
224
202
|
}
|
|
225
|
-
|
|
226
203
|
selectAllRef.current.checked = true;
|
|
227
204
|
} else if (selectAllRef.current.checked) {
|
|
228
205
|
selectAllRef.current.checked = false;
|
|
229
206
|
}
|
|
230
207
|
};
|
|
231
|
-
|
|
232
208
|
const handleDisabledChildren = (node, isChecked) => {
|
|
233
209
|
if (node) {
|
|
234
210
|
node.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion').forEach(el => {
|
|
235
211
|
el.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
236
|
-
|
|
237
212
|
if (el.classList.contains('DGN-UI-Accordion')) {
|
|
238
213
|
el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.classList[isChecked ? 'add' : 'remove']('disabled');
|
|
239
214
|
el.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild.disabled = isChecked;
|
|
@@ -248,25 +223,20 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
248
223
|
});
|
|
249
224
|
}
|
|
250
225
|
};
|
|
251
|
-
|
|
252
226
|
const handleDisabledParent = (node, isChecked) => {
|
|
253
227
|
while (ref.current.contains(node)) {
|
|
254
228
|
node = node.parentNode;
|
|
255
|
-
|
|
256
229
|
if (node.classList.contains('DGN-UI-Accordion') && node.firstChild.classList.contains('DGN-UI-Accordion-Summary')) {
|
|
257
230
|
var _node$querySelectorAl;
|
|
258
|
-
|
|
259
231
|
const summaryEl = node.firstChild;
|
|
260
|
-
|
|
261
232
|
if (!summaryEl.classList.contains('expanding')) {
|
|
262
233
|
summaryEl.lastChild.firstChild.click();
|
|
263
234
|
}
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
235
|
+
const checkbox = node.firstChild.firstChild.lastChild.firstChild.firstChild.firstChild;
|
|
236
|
+
// Trường hợp phải set về false để xét các input đã check không bao gồm node này
|
|
267
237
|
checkbox.firstChild.checked = isChecked;
|
|
268
|
-
const mustDisabled = !!((_node$querySelectorAl = node.querySelectorAll('input:checked')) !== null && _node$querySelectorAl !== void 0 && _node$querySelectorAl.length);
|
|
269
|
-
|
|
238
|
+
const mustDisabled = !!((_node$querySelectorAl = node.querySelectorAll('input:checked')) !== null && _node$querySelectorAl !== void 0 && _node$querySelectorAl.length);
|
|
239
|
+
// Nếu có ít nhất một input con được check thì phải checked cho input này
|
|
270
240
|
checkbox.firstChild.checked = mustDisabled;
|
|
271
241
|
determinateCheckbox(checkbox.firstChild, !mustDisabled);
|
|
272
242
|
node.classList[mustDisabled || isChecked ? 'add' : 'remove']('disabled');
|
|
@@ -279,13 +249,10 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
279
249
|
}
|
|
280
250
|
}
|
|
281
251
|
};
|
|
282
|
-
|
|
283
252
|
const setValue = (data, isChecked) => {
|
|
284
253
|
if (multiple && multipleValueMode !== 'single') {
|
|
285
254
|
var _data$childItems;
|
|
286
|
-
|
|
287
255
|
currentValue[unique][typeof data === 'object' ? data[valueExpr] : data] = isChecked;
|
|
288
|
-
|
|
289
256
|
if (data.childItems && (_data$childItems = data.childItems) !== null && _data$childItems !== void 0 && _data$childItems.length) {
|
|
290
257
|
data.childItems.forEach(d => {
|
|
291
258
|
setValue(d, isChecked);
|
|
@@ -293,7 +260,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
293
260
|
}
|
|
294
261
|
}
|
|
295
262
|
};
|
|
296
|
-
|
|
297
263
|
const clearAllValue = () => {
|
|
298
264
|
inputValueRef.current.value = '';
|
|
299
265
|
clearIconRef.current.style.opacity = 0;
|
|
@@ -308,22 +274,17 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
308
274
|
data: []
|
|
309
275
|
}, []);
|
|
310
276
|
};
|
|
311
|
-
|
|
312
277
|
const setValueIntoInput = data => {
|
|
313
278
|
var _clearIconRef$current2;
|
|
314
|
-
|
|
315
279
|
if (!data || !(data !== null && data !== void 0 && data.length)) {
|
|
316
280
|
var _clearIconRef$current;
|
|
317
|
-
|
|
318
281
|
inputValueRef.current.value = '';
|
|
319
282
|
if ((_clearIconRef$current = clearIconRef.current) !== null && _clearIconRef$current !== void 0 && _clearIconRef$current.element) clearIconRef.current.element.style.opacity = 0;
|
|
320
283
|
return;
|
|
321
284
|
}
|
|
322
|
-
|
|
323
285
|
if ((_clearIconRef$current2 = clearIconRef.current) !== null && _clearIconRef$current2 !== void 0 && _clearIconRef$current2.element && clearIconRef.current.element.style.opacity === '0') {
|
|
324
286
|
clearIconRef.current.element.style.opacity = null;
|
|
325
287
|
}
|
|
326
|
-
|
|
327
288
|
let result = '';
|
|
328
289
|
const keyArr = displayExpr.match(separatorPattern);
|
|
329
290
|
data.forEach(d => {
|
|
@@ -331,7 +292,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
331
292
|
});
|
|
332
293
|
inputValueRef.current.value = result.replace(/, $/, '');
|
|
333
294
|
};
|
|
334
|
-
|
|
335
295
|
const handleCheckbox = (isChecked = false, value = 'all') => {
|
|
336
296
|
if ((selectBox || multiple) && ref.current) {
|
|
337
297
|
if (value === 'all') {
|
|
@@ -340,10 +300,8 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
340
300
|
if (typeof value === 'string') {
|
|
341
301
|
value = [value];
|
|
342
302
|
}
|
|
343
|
-
|
|
344
303
|
value.forEach(v => {
|
|
345
304
|
const input = ref.current.querySelector(`input[value="${v}"]`);
|
|
346
|
-
|
|
347
305
|
if (input) {
|
|
348
306
|
input.checked = isChecked;
|
|
349
307
|
}
|
|
@@ -351,7 +309,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
351
309
|
}
|
|
352
310
|
}
|
|
353
311
|
};
|
|
354
|
-
|
|
355
312
|
const onClickHandler = (e, data) => {
|
|
356
313
|
if (disabled) return;
|
|
357
314
|
const target = e.target;
|
|
@@ -360,13 +317,11 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
360
317
|
const justSelected = value;
|
|
361
318
|
const result = [];
|
|
362
319
|
const checkBoxEl = currentTarget.querySelector('.TreeView-Item-Checkbox');
|
|
363
|
-
|
|
364
320
|
if (multiple) {
|
|
365
321
|
var _value;
|
|
366
|
-
|
|
367
322
|
let checked = false;
|
|
368
|
-
let inputEl = null;
|
|
369
|
-
|
|
323
|
+
let inputEl = null;
|
|
324
|
+
// Click on text (not checkbox)
|
|
370
325
|
if (!checkBoxEl.contains(target)) {
|
|
371
326
|
inputEl = checkBoxEl.querySelector('input');
|
|
372
327
|
checked = !inputEl.checked || inputEl.classList.contains('indeterminate');
|
|
@@ -376,52 +331,43 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
376
331
|
checked = inputEl.checked || inputEl.classList.contains('indeterminate');
|
|
377
332
|
inputEl.checked = checked;
|
|
378
333
|
}
|
|
379
|
-
|
|
380
334
|
if (multipleValueMode !== 'single') {
|
|
381
335
|
if (!currentTarget.classList.contains('non-child')) {
|
|
382
336
|
checkChildrenCheckbox(currentTarget.nextElementSibling, checked);
|
|
383
|
-
|
|
384
337
|
if (checked) {
|
|
385
338
|
determinateCheckbox(inputEl, true);
|
|
386
339
|
}
|
|
387
340
|
}
|
|
388
|
-
|
|
389
341
|
if (checked || multipleValueMode === 'multiple') {
|
|
390
342
|
checkParentCheckbox(currentTarget);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
343
|
+
}
|
|
344
|
+
// Handle result when multiple
|
|
394
345
|
setValue(data, checked);
|
|
395
346
|
} else {
|
|
396
347
|
currentValue[unique][value] = checked;
|
|
397
|
-
|
|
398
348
|
if (disabledRelevantValue) {
|
|
399
349
|
// Disabled/Enabled parent and children node
|
|
400
350
|
if (!currentTarget.classList.contains('non-child')) {
|
|
401
351
|
handleDisabledChildren(currentTarget.nextElementSibling, checked);
|
|
402
352
|
}
|
|
403
|
-
|
|
404
353
|
handleDisabledParent(currentTarget.parentNode, checked);
|
|
405
354
|
}
|
|
406
355
|
}
|
|
407
|
-
|
|
408
356
|
result.push(...Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]));
|
|
409
357
|
value = result;
|
|
410
|
-
|
|
411
358
|
if ((_value = value) !== null && _value !== void 0 && _value.length) {
|
|
412
359
|
data = dataSource.filter(obj => value.includes(typeof obj === 'object' ? obj[valueExpr] : obj));
|
|
413
360
|
} else {
|
|
414
361
|
data = [];
|
|
415
362
|
}
|
|
416
|
-
|
|
417
363
|
if (showSelectedItems) {
|
|
418
364
|
setValueIntoInput(data);
|
|
419
365
|
}
|
|
420
366
|
} else {
|
|
421
367
|
if (selectBox) {
|
|
422
368
|
const checkedInput = ref.current.querySelectorAll('input:checked');
|
|
423
|
-
let input = currentTarget.querySelector('input');
|
|
424
|
-
|
|
369
|
+
let input = currentTarget.querySelector('input');
|
|
370
|
+
// Click on checkbox
|
|
425
371
|
if (checkBoxEl.contains(target)) {
|
|
426
372
|
if (!input.checked) {
|
|
427
373
|
input.checked = true;
|
|
@@ -430,31 +376,24 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
430
376
|
} else if (checkedInput[0].isSameNode(input)) {
|
|
431
377
|
return;
|
|
432
378
|
}
|
|
433
|
-
|
|
434
379
|
if (checkedInput) {
|
|
435
380
|
checkedInput.forEach(el => el.checked = false);
|
|
436
381
|
}
|
|
437
|
-
|
|
438
382
|
input.checked = true;
|
|
439
383
|
}
|
|
440
|
-
|
|
441
384
|
currentValue[unique][value] = true;
|
|
442
385
|
result.push(value);
|
|
443
386
|
}
|
|
444
|
-
|
|
445
387
|
if (selectAllRef.current) {
|
|
446
388
|
checkedSelectAllCheckbox();
|
|
447
389
|
}
|
|
448
|
-
|
|
449
390
|
e.value = value;
|
|
450
391
|
e.justSelected = justSelected;
|
|
451
392
|
e.data = data;
|
|
452
393
|
!!onChange && onChange(e, result);
|
|
453
394
|
};
|
|
454
|
-
|
|
455
395
|
const onSelectAll = e => {
|
|
456
396
|
let result;
|
|
457
|
-
|
|
458
397
|
if (!e.target.checked && e.target.classList.contains('determinate')) {
|
|
459
398
|
ref.current.querySelectorAll('input:checked').forEach(input => input.checked = false);
|
|
460
399
|
e.value = [];
|
|
@@ -463,11 +402,9 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
463
402
|
if (!e.target.classList.contains('determinate')) {
|
|
464
403
|
determinateCheckbox(e.target, true);
|
|
465
404
|
}
|
|
466
|
-
|
|
467
405
|
e.target.checked = true;
|
|
468
406
|
ref.current.querySelectorAll('input').forEach(input => {
|
|
469
407
|
input.checked = true;
|
|
470
|
-
|
|
471
408
|
if (!input.classList.contains('determinate')) {
|
|
472
409
|
determinateCheckbox(input, true);
|
|
473
410
|
}
|
|
@@ -475,13 +412,10 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
475
412
|
result = Object.keys(currentValue[unique]).map(v => v);
|
|
476
413
|
e.value = result;
|
|
477
414
|
}
|
|
478
|
-
|
|
479
415
|
!!onChange && onChange(e, result);
|
|
480
416
|
};
|
|
481
|
-
|
|
482
417
|
const onChangeHandler = e => {
|
|
483
418
|
const value = e.target.value;
|
|
484
|
-
|
|
485
419
|
if (timeout.current) {
|
|
486
420
|
if (timer.current) clearTimeout(timer.current);
|
|
487
421
|
timer.current = setTimeout(() => {
|
|
@@ -491,15 +425,13 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
491
425
|
onSearchHandler(value);
|
|
492
426
|
}
|
|
493
427
|
};
|
|
494
|
-
|
|
495
428
|
const onSearchHandler = value => {
|
|
496
429
|
const entries = ref.current.querySelectorAll('.TreeView-Item.non-child, .DGN-UI-Accordion');
|
|
497
|
-
|
|
498
430
|
if (value) {
|
|
499
431
|
entries.forEach(entry => {
|
|
500
432
|
if (compareTwoString(value, entry.textContent)) {
|
|
501
|
-
entry.classList.remove('DGN-Hidden');
|
|
502
|
-
|
|
433
|
+
entry.classList.remove('DGN-Hidden');
|
|
434
|
+
// Check exactly entry
|
|
503
435
|
if (entry.classList.contains('TreeView-Item')) {
|
|
504
436
|
if (!disabledBoldResult && !entry.classList.contains('TreeView-Item-active')) {
|
|
505
437
|
entry.classList.add('TreeView-Item-active');
|
|
@@ -507,14 +439,12 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
507
439
|
} else {
|
|
508
440
|
const summaryEl = entry.firstChild;
|
|
509
441
|
const TreeViewItemEl = summaryEl.querySelector('.TreeView-Item');
|
|
510
|
-
|
|
511
442
|
if (TreeViewItemEl) {
|
|
512
443
|
if (compareTwoString(value, TreeViewItemEl.textContent)) {
|
|
513
444
|
if (!disabledBoldResult && !TreeViewItemEl.classList.contains('TreeView-Item-active')) {
|
|
514
445
|
TreeViewItemEl.classList.add('TreeView-Item-active');
|
|
515
446
|
entry.classList.add('TreeView-Item-contain-children-active');
|
|
516
447
|
}
|
|
517
|
-
|
|
518
448
|
if (!compareTwoString(value, entry.lastChild.textContent)) {
|
|
519
449
|
summaryEl.lastChild.classList.add('DGN-Invisible');
|
|
520
450
|
} else {
|
|
@@ -524,7 +454,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
524
454
|
TreeViewItemEl.classList.remove('TreeView-Item-active');
|
|
525
455
|
entry.classList.remove('TreeView-Item-contain-children-active');
|
|
526
456
|
}
|
|
527
|
-
|
|
528
457
|
if (autoExpandToResult && !summaryEl.classList.contains('expanding')) {
|
|
529
458
|
summaryEl.lastChild.firstChild.click();
|
|
530
459
|
}
|
|
@@ -532,33 +461,27 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
532
461
|
}
|
|
533
462
|
} else {
|
|
534
463
|
entry.classList.add('DGN-Hidden');
|
|
535
|
-
|
|
536
464
|
if (entry.classList.contains('TreeView-Item')) {
|
|
537
465
|
if (entry.classList.contains('TreeView-Item-active')) {
|
|
538
466
|
entry.classList.remove('TreeView-Item-active');
|
|
539
467
|
}
|
|
540
|
-
|
|
541
468
|
entry.classList.remove('TreeView-Item-contain-children-active');
|
|
542
469
|
} else {
|
|
543
470
|
const summaryEl = entry.firstChild;
|
|
544
471
|
const TreeViewItemEl = summaryEl.querySelector('.TreeView-Item');
|
|
545
|
-
|
|
546
472
|
if (TreeViewItemEl) {
|
|
547
473
|
if (TreeViewItemEl.classList.contains('TreeView-Item-active')) {
|
|
548
474
|
TreeViewItemEl.classList.remove('TreeView-Item-active');
|
|
549
475
|
}
|
|
550
|
-
|
|
551
476
|
summaryEl.lastChild.classList.remove('DGN-Invisible');
|
|
552
477
|
}
|
|
553
478
|
}
|
|
554
479
|
}
|
|
555
480
|
});
|
|
556
|
-
|
|
557
481
|
if (showChildrenOfResult) {
|
|
558
482
|
entries.forEach(entry => {
|
|
559
483
|
if (entry.classList.contains('TreeView-Item-contain-children-active')) {
|
|
560
484
|
const hiddenEls = entry.querySelectorAll('.DGN-Hidden, .DGN-Invisible');
|
|
561
|
-
|
|
562
485
|
if (hiddenEls && hiddenEls !== null && hiddenEls !== void 0 && hiddenEls.length) {
|
|
563
486
|
hiddenEls.forEach(hiddenEl => hiddenEl.classList.remove('DGN-Hidden', 'DGN-Invisible'));
|
|
564
487
|
}
|
|
@@ -568,13 +491,11 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
568
491
|
} else {
|
|
569
492
|
entries.forEach(entry => {
|
|
570
493
|
entry.classList.remove('DGN-Hidden');
|
|
571
|
-
|
|
572
494
|
if (!entry.classList.contains('TreeView-Item') && entry.firstChild.lastChild.classList.contains('DGN-Invisible')) {
|
|
573
495
|
entry.firstChild.lastChild.classList.remove('DGN-Invisible');
|
|
574
496
|
}
|
|
575
497
|
});
|
|
576
498
|
const activeEls = ref.current.querySelectorAll('.TreeView-Item-active');
|
|
577
|
-
|
|
578
499
|
if (!disabledBoldResult && activeEls && activeEls !== null && activeEls !== void 0 && activeEls.length) {
|
|
579
500
|
activeEls.forEach(activeEl => {
|
|
580
501
|
activeEl.classList.remove('TreeView-Item-active', 'TreeView-Item-contain-children-active');
|
|
@@ -582,16 +503,13 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
582
503
|
}
|
|
583
504
|
}
|
|
584
505
|
};
|
|
585
|
-
|
|
586
506
|
const compareTwoString = (search, content) => {
|
|
587
507
|
if (searchMode === 'similar') {
|
|
588
508
|
search = removeUnicode(search.normalize(), '.*?');
|
|
589
509
|
content = removeUnicode(content);
|
|
590
510
|
}
|
|
591
|
-
|
|
592
511
|
return new RegExp(search.normalize(), 'img').test(content.normalize());
|
|
593
512
|
};
|
|
594
|
-
|
|
595
513
|
const renderDataAsync = (id, array) => {
|
|
596
514
|
return new Promise(res => {
|
|
597
515
|
const node = array.map(({
|
|
@@ -602,26 +520,21 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
602
520
|
return renderTreeView(data, index, level, false);
|
|
603
521
|
});
|
|
604
522
|
const container = document.getElementById(id);
|
|
605
|
-
|
|
606
523
|
if (container && node) {
|
|
607
524
|
render(node, container.firstChild, () => res(1));
|
|
608
525
|
}
|
|
609
526
|
});
|
|
610
527
|
};
|
|
611
|
-
|
|
612
528
|
const renderData = (data, keyArr) => {
|
|
613
529
|
const pattern = keyArr.join('|').replace(/([{}])/g, '\\$1');
|
|
614
530
|
const separatorArr = displayExpr.split(new RegExp(pattern));
|
|
615
531
|
let str = '';
|
|
616
532
|
let i = 0;
|
|
617
|
-
|
|
618
533
|
for (i; i < (keyArr === null || keyArr === void 0 ? void 0 : keyArr.length); i++) {
|
|
619
534
|
str += separatorArr[i] + (data[keyArr[i].replace(/\W/g, '')] !== undefined ? data[keyArr[i].replace(/\W/g, '')] : keyArr[i]);
|
|
620
535
|
}
|
|
621
|
-
|
|
622
536
|
return str + separatorArr[i];
|
|
623
537
|
};
|
|
624
|
-
|
|
625
538
|
const renderContent = (item, keyArr, index) => {
|
|
626
539
|
const displayText = renderItem && typeof renderItem === 'function' ? renderItem({
|
|
627
540
|
data: item,
|
|
@@ -635,7 +548,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
635
548
|
}
|
|
636
549
|
}, displayText);
|
|
637
550
|
};
|
|
638
|
-
|
|
639
551
|
const renderTreeView = (data, index, level, sync = true, id) => {
|
|
640
552
|
if (level > renderAsyncFromLevel - 1 && sync) {
|
|
641
553
|
if (itemsRenderAsync[unique][id]) {
|
|
@@ -651,16 +563,14 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
651
563
|
level
|
|
652
564
|
}];
|
|
653
565
|
}
|
|
654
|
-
|
|
655
566
|
return null;
|
|
656
567
|
}
|
|
657
|
-
|
|
658
568
|
const keyArr = displayExpr.match(separatorPattern);
|
|
659
569
|
const isTrue = value.includes(data[valueExpr] || data);
|
|
660
570
|
const isParentTrue = value.includes(data[parentID]);
|
|
661
571
|
const focusClass = isTrue && !selectBox && !multiple ? 'focus' : '';
|
|
662
|
-
const childItems = data.childItems;
|
|
663
|
-
|
|
572
|
+
const childItems = data.childItems;
|
|
573
|
+
// is Summary
|
|
664
574
|
if (childItems && childItems !== null && childItems !== void 0 && childItems.length) {
|
|
665
575
|
const id = randomString(6, {
|
|
666
576
|
allowSymbol: false,
|
|
@@ -706,7 +616,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
706
616
|
id: id
|
|
707
617
|
}, childItems.map((child, i) => renderTreeView(child, index + i, level + 1, sync, id))));
|
|
708
618
|
}
|
|
709
|
-
|
|
710
619
|
return jsx("div", {
|
|
711
620
|
className: 'TreeView-Item non-child ' + focusClass,
|
|
712
621
|
style: {
|
|
@@ -725,7 +634,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
725
634
|
disabled: disabled
|
|
726
635
|
})), renderContent(data, keyArr, index));
|
|
727
636
|
};
|
|
728
|
-
|
|
729
637
|
useEffect(() => {
|
|
730
638
|
currentValue[unique] = {};
|
|
731
639
|
return () => {
|
|
@@ -735,7 +643,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
735
643
|
useEffect(() => {
|
|
736
644
|
if (searchDelayTime) {
|
|
737
645
|
var _searchDelayTime$matc, _searchDelayTime$matc2;
|
|
738
|
-
|
|
739
646
|
if (searchDelayTime === true) searchDelayTime = getGlobal('delayOnInput');
|
|
740
647
|
const units = {
|
|
741
648
|
m: 60000,
|
|
@@ -750,17 +657,14 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
750
657
|
}, [searchDelayTime]);
|
|
751
658
|
useEffect(() => {
|
|
752
659
|
var _value2;
|
|
753
|
-
|
|
754
660
|
dataSource.forEach(data => {
|
|
755
661
|
currentValue[unique][typeof data === 'object' ? data[valueExpr] : data] = false;
|
|
756
662
|
});
|
|
757
|
-
|
|
758
663
|
if (value && (_value2 = value) !== null && _value2 !== void 0 && _value2.length) {
|
|
759
664
|
value.forEach(v => {
|
|
760
665
|
currentValue[unique][v] = true;
|
|
761
666
|
});
|
|
762
667
|
}
|
|
763
|
-
|
|
764
668
|
return () => {
|
|
765
669
|
currentValue[unique] = {};
|
|
766
670
|
};
|
|
@@ -769,16 +673,13 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
769
673
|
if (value && multiple) {
|
|
770
674
|
if (multipleValueMode !== 'single') {
|
|
771
675
|
const childNodes = Array.from(ref.current.childNodes);
|
|
772
|
-
|
|
773
676
|
if (childNodes && childNodes !== null && childNodes !== void 0 && childNodes.length) {
|
|
774
677
|
checkedParentFollowValue(childNodes);
|
|
775
678
|
}
|
|
776
|
-
|
|
777
679
|
if (showSelectedItems) {
|
|
778
680
|
const data = dataSource.filter(d => value.includes(d[valueExpr]));
|
|
779
681
|
setValueIntoInput(data);
|
|
780
682
|
}
|
|
781
|
-
|
|
782
683
|
return () => {
|
|
783
684
|
if (ref.current) {
|
|
784
685
|
Array.from(ref.current.querySelectorAll('input')).forEach(input => {
|
|
@@ -792,7 +693,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
792
693
|
if (!el.classList.contains('non-child')) {
|
|
793
694
|
handleDisabledChildren(el, true);
|
|
794
695
|
}
|
|
795
|
-
|
|
796
696
|
handleDisabledParent(el.parentNode, true);
|
|
797
697
|
}
|
|
798
698
|
});
|
|
@@ -803,12 +703,10 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
803
703
|
if (selectAllRef.current) {
|
|
804
704
|
checkedSelectAllCheckbox();
|
|
805
705
|
}
|
|
806
|
-
|
|
807
706
|
if (ref.current.querySelector('.DGN-UI-Accordion-Details-Content')) {
|
|
808
707
|
if (!ref.current.parentNode.classList.contains('expand-able')) {
|
|
809
708
|
ref.current.parentNode.classList.add('expand-able');
|
|
810
709
|
}
|
|
811
|
-
|
|
812
710
|
return () => {
|
|
813
711
|
if (ref.current) {
|
|
814
712
|
ref.current.parentNode.classList.remove('expand-able');
|
|
@@ -818,7 +716,6 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
818
716
|
}, [dataSource, value, multiple, selectBox]);
|
|
819
717
|
useEffect(() => {
|
|
820
718
|
var _Object$keys;
|
|
821
|
-
|
|
822
719
|
if ((_Object$keys = Object.keys(itemsRenderAsync[unique])) !== null && _Object$keys !== void 0 && _Object$keys.length) {
|
|
823
720
|
Object.keys(itemsRenderAsync[unique]).forEach(async key => {
|
|
824
721
|
await renderDataAsync(key, itemsRenderAsync[unique][key]);
|
|
@@ -828,40 +725,32 @@ const TreeView = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
828
725
|
useImperativeHandle(reference, () => {
|
|
829
726
|
const currentRef = ref.current || {};
|
|
830
727
|
currentRef.element = ref.current;
|
|
831
|
-
const _instance = {
|
|
728
|
+
const _instance = {
|
|
729
|
+
...action
|
|
832
730
|
}; // methods
|
|
833
|
-
|
|
834
731
|
_instance.__proto__ = {}; // hidden methods
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
732
|
+
currentRef.instance = _instance;
|
|
733
|
+
// keep old method
|
|
838
734
|
currentRef.disabled = disabled;
|
|
839
735
|
currentRef.displayExpr = displayExpr;
|
|
840
736
|
currentRef.valueExpr = valueExpr;
|
|
841
737
|
currentRef.id = id;
|
|
842
738
|
currentRef.parentID = parentID;
|
|
843
739
|
currentRef.value = value;
|
|
844
|
-
|
|
845
740
|
currentRef.getValue = () => Object.keys(currentValue[unique]).filter(v => currentValue[unique][v]);
|
|
846
|
-
|
|
847
741
|
currentRef.setValue = setValue;
|
|
848
742
|
currentRef.handleCheckbox = handleCheckbox;
|
|
849
|
-
|
|
850
743
|
currentRef.get = () => ref.current;
|
|
851
|
-
|
|
852
744
|
return currentRef;
|
|
853
745
|
});
|
|
854
746
|
return useMemo(() => {
|
|
855
747
|
var _value3;
|
|
856
|
-
|
|
857
748
|
if (typeof value === 'string') {
|
|
858
749
|
value = [value];
|
|
859
750
|
}
|
|
860
|
-
|
|
861
751
|
if (!multiple && ((_value3 = value) === null || _value3 === void 0 ? void 0 : _value3.length) > 1) {
|
|
862
752
|
value.length = 1;
|
|
863
753
|
}
|
|
864
|
-
|
|
865
754
|
itemsRenderAsync[unique] = {};
|
|
866
755
|
const sync = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) > renderAsyncWithLength;
|
|
867
756
|
return jsx("div", {
|
|
@@ -1031,129 +920,100 @@ TreeView.defaultProps = {
|
|
|
1031
920
|
TreeView.propTypes = {
|
|
1032
921
|
/** expand immediate if true */
|
|
1033
922
|
expand: PropTypes.bool,
|
|
1034
|
-
|
|
1035
923
|
/** prevent all event if true */
|
|
1036
924
|
disabled: PropTypes.bool,
|
|
1037
|
-
|
|
1038
925
|
/** show checkbox in each item */
|
|
1039
926
|
selectBox: PropTypes.bool,
|
|
1040
|
-
|
|
1041
927
|
/** allow select multiple item if true */
|
|
1042
928
|
multiple: PropTypes.bool,
|
|
1043
|
-
|
|
1044
929
|
/** allow select/unselect all items on one click (just support for multiple) */
|
|
1045
930
|
selectAll: PropTypes.bool,
|
|
1046
|
-
|
|
1047
931
|
/** display input box search if true */
|
|
1048
932
|
allowSearch: PropTypes.bool,
|
|
1049
|
-
|
|
1050
933
|
/** display all value in a box */
|
|
1051
934
|
showSelectedItems: PropTypes.bool,
|
|
1052
|
-
|
|
1053
935
|
/** disabled parent and children item if true (only supported for multipleValueMode is single) */
|
|
1054
936
|
disabledRelevantValue: PropTypes.bool,
|
|
1055
|
-
|
|
1056
937
|
/** prevent display content of match values with bold style */
|
|
1057
938
|
disabledBoldResult: PropTypes.bool,
|
|
1058
|
-
|
|
1059
939
|
/** expand TreeView to match result if true */
|
|
1060
940
|
autoExpandToResult: PropTypes.bool,
|
|
1061
|
-
|
|
1062
941
|
/** still show children of last result was found if true */
|
|
1063
942
|
showChildrenOfResult: PropTypes.bool,
|
|
1064
|
-
|
|
1065
943
|
/** Used to identify the parent key */
|
|
1066
944
|
id: PropTypes.string.isRequired,
|
|
1067
|
-
|
|
1068
945
|
/** used for mapping into a nested list */
|
|
1069
946
|
parentID: PropTypes.string.isRequired,
|
|
1070
|
-
|
|
1071
947
|
/** class on element */
|
|
1072
948
|
className: PropTypes.string,
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
*
|
|
1076
|
-
*
|
|
1077
|
-
* Note: don't use 'id - name', return undefined
|
|
949
|
+
/**
|
|
950
|
+
* field name used for text display<br/>
|
|
951
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
952
|
+
* Note: don't use 'id - name', return undefined
|
|
1078
953
|
*/
|
|
1079
954
|
displayExpr: PropTypes.string,
|
|
1080
|
-
|
|
1081
955
|
/** the key to determine value to return */
|
|
1082
956
|
valueExpr: PropTypes.string,
|
|
1083
|
-
|
|
1084
957
|
/** return value for the select multiple use case */
|
|
1085
958
|
multipleValueMode: PropTypes.oneOf(['single', 'multiple', 'inheritance']),
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
*
|
|
1089
|
-
* *
|
|
1090
|
-
* * similar: "Công ty" contains "công" and "cong"
|
|
959
|
+
/**
|
|
960
|
+
* return value for the select multiple use case
|
|
961
|
+
* * contains: "Công ty" contains "công", but not contains "cong"
|
|
962
|
+
* * similar: "Công ty" contains "công" and "cong"
|
|
1091
963
|
*/
|
|
1092
964
|
searchMode: PropTypes.oneOf(['contains', 'similar']),
|
|
1093
|
-
|
|
1094
965
|
/** The content display for label of checkbox select all */
|
|
1095
966
|
selectAllLabel: PropTypes.string,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
*
|
|
1099
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
967
|
+
/**
|
|
968
|
+
* duration wait enter search content on search<br/>
|
|
969
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1100
970
|
*/
|
|
1101
971
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1102
|
-
|
|
1103
972
|
/** will render asynchronously if the number of elements is greater than this number */
|
|
1104
973
|
renderAsyncWithLength: PropTypes.number,
|
|
1105
|
-
|
|
1106
974
|
/** will render asynchronously from level equal this number */
|
|
1107
975
|
renderAsyncFromLevel: PropTypes.oneOf([2, 3, 4, 5]),
|
|
1108
|
-
|
|
1109
976
|
/** data to show in tree list */
|
|
1110
977
|
dataSource: PropTypes.array,
|
|
1111
|
-
|
|
1112
978
|
/** the value was selected */
|
|
1113
979
|
value: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
*
|
|
1117
|
-
* --> such as: displayExpr={'name - role'}
|
|
980
|
+
/** function displays items by custom<br/>
|
|
981
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
982
|
+
* --> such as: displayExpr={'name - role'}
|
|
1118
983
|
*/
|
|
1119
984
|
renderItem: PropTypes.func,
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
*
|
|
1125
|
-
* +
|
|
1126
|
-
* +
|
|
1127
|
-
*
|
|
1128
|
-
* * data: array of selected values (not recommend because it's the same e.value)
|
|
985
|
+
/**
|
|
986
|
+
* on change value function<br />
|
|
987
|
+
* return 2 parameters (e, data)<br />
|
|
988
|
+
* * e: element (insist {value, justSelected, data})<br/>
|
|
989
|
+
* + value is one or an array of selected values<br />
|
|
990
|
+
* + justSelected is value has just been selected (either true or false))<br />
|
|
991
|
+
* + data is one or an array of selected values with full information<br />
|
|
992
|
+
* * data: array of selected values (not recommend because it's the same e.value)
|
|
1129
993
|
*/
|
|
1130
994
|
onChange: PropTypes.func,
|
|
1131
|
-
|
|
1132
995
|
/** the icon to display for expand icon */
|
|
1133
996
|
expandIcon: PropTypes.any,
|
|
1134
|
-
|
|
1135
997
|
/** the props for InputBase */
|
|
1136
998
|
searchProps: PropTypes.object,
|
|
1137
|
-
|
|
1138
999
|
/** the icon to display for collapse icon */
|
|
1139
1000
|
collapseIcon: PropTypes.any,
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
*
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1146
|
-
*
|
|
1147
|
-
*
|
|
1148
|
-
*
|
|
1149
|
-
*
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
-
* +
|
|
1154
|
-
*  
|
|
1155
|
-
*
|
|
1156
|
-
* }
|
|
1001
|
+
/**
|
|
1002
|
+
* get ref of TreeView component, insist:<br/>
|
|
1003
|
+
* {<br/>
|
|
1004
|
+
* disabled: true/false,<br/>
|
|
1005
|
+
* displayExpr: string,<br/>
|
|
1006
|
+
* valueExpr: string,<br/>
|
|
1007
|
+
* id: string,<br/>
|
|
1008
|
+
* parentID: string,<br/>
|
|
1009
|
+
* value: string/array<br/>
|
|
1010
|
+
* getValue: get selected values (instead of onChange function),<br/>
|
|
1011
|
+
* setValue: set array of value (only multiple),<br/>
|
|
1012
|
+
* handleCheckbox: checked/unchecked a Checkbox, includes 2 parameters (isChecked, value):<br/>
|
|
1013
|
+
* + isChecked: checked if true (default is false) <br/>
|
|
1014
|
+
* + value: selected values, use 'all' for all values (default is 'all') <br/>
|
|
1015
|
+
* get: get DOM of TreeView component<br/>
|
|
1016
|
+
* }
|
|
1157
1017
|
*/
|
|
1158
1018
|
ref: PropTypes.any
|
|
1159
1019
|
};
|