diginet-core-ui 1.3.55 → 1.3.56
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/button/icon.js +21 -21
- package/components/form-control/dropdown/index.js +313 -340
- package/components/form-control/number-input/index2.js +3 -1
- package/components/index.js +1 -1
- package/components/modal/body.js +58 -48
- package/components/modal/footer.js +43 -41
- package/components/modal/header.js +22 -18
- package/components/modal/modal.js +70 -48
- package/components/paging/page-selector2.js +373 -0
- package/package.json +1 -1
- package/readme.md +7 -0
- package/utils/useElementSize.js +48 -0
- package/utils/useEventListener.js +45 -0
- package/utils/useInput.js +1 -1
|
@@ -11,40 +11,39 @@ import AvatarDefault from '../../../assets/avatar/default.svg';
|
|
|
11
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
|
-
import {
|
|
15
|
-
import { typography } from '../../../styles/typography';
|
|
16
|
-
import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, breakWord, cursorPointer, displayBlock, flexRow, flexWrap, inlineFlex, justifyCenter, justifyStart, outlineNone, overflowHidden, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../../styles/general';
|
|
14
|
+
import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, breakWord, cursorPointer, displayBlock, flexColReverse, flexRow, flexWrap, inlineFlex, justifyCenter, justifyStart, outlineNone, overflowAuto, overflowHidden, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, userSelectNone } from '../../../styles/general';
|
|
17
15
|
import isMobile from '../../../utils/isMobile';
|
|
18
|
-
import
|
|
16
|
+
import theme from '../../../theme/settings';
|
|
19
17
|
const {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
18
|
+
colors: {
|
|
19
|
+
system: {
|
|
20
|
+
active,
|
|
21
|
+
disabled: systemDisabled,
|
|
22
|
+
rest,
|
|
23
|
+
white
|
|
24
|
+
},
|
|
25
|
+
semantic: {
|
|
26
|
+
danger
|
|
27
|
+
},
|
|
28
|
+
fill: {
|
|
29
|
+
hover,
|
|
30
|
+
'scrollbar-tabbar': scrollbar
|
|
31
|
+
},
|
|
32
|
+
line: {
|
|
33
|
+
focus
|
|
34
|
+
},
|
|
35
|
+
text: {
|
|
36
|
+
main,
|
|
37
|
+
sub
|
|
38
|
+
}
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
typography: {
|
|
41
|
+
paragraph1,
|
|
42
|
+
paragraph3
|
|
42
43
|
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
} = colors;
|
|
44
|
+
spacing,
|
|
45
|
+
zIndex: zIndexCORE
|
|
46
|
+
} = theme;
|
|
48
47
|
const timing = {},
|
|
49
48
|
currentValue = {},
|
|
50
49
|
currentObjectDefault = {},
|
|
@@ -70,7 +69,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
70
69
|
total,
|
|
71
70
|
placeholder,
|
|
72
71
|
error,
|
|
73
|
-
keyExpr,
|
|
74
72
|
displayExpr,
|
|
75
73
|
subText,
|
|
76
74
|
valueExpr,
|
|
@@ -106,12 +104,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
106
104
|
dropdownItemStyle
|
|
107
105
|
}, reference) => {
|
|
108
106
|
if (multiple && selectBox === undefined) selectBox = true;
|
|
107
|
+
const ref = useRef(null);
|
|
109
108
|
const dropdownRef = useRef(null);
|
|
109
|
+
const loadingProgressRef = useRef(null);
|
|
110
110
|
const timerRef = useRef(null);
|
|
111
111
|
const formRef = useRef(null);
|
|
112
112
|
const inputRef = useRef(null);
|
|
113
113
|
const iconRef = useRef(null);
|
|
114
|
-
const
|
|
114
|
+
const dropdownListRef = useRef(null);
|
|
115
115
|
const searchRef = useRef(null);
|
|
116
116
|
const lastSearchRef = useRef(null);
|
|
117
117
|
const timeout = useRef(null);
|
|
@@ -123,6 +123,20 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
123
123
|
const [showClear, setShowClear] = useState(false);
|
|
124
124
|
|
|
125
125
|
const _isMobile = isMobile.any();
|
|
126
|
+
|
|
127
|
+
const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
|
|
128
|
+
|
|
129
|
+
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', disabled);
|
|
130
|
+
|
|
131
|
+
const _IconCSS = IconCSS(viewType, loading, showClear);
|
|
132
|
+
|
|
133
|
+
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, disabled, _DropdownInputCSS.name);
|
|
134
|
+
|
|
135
|
+
const _DropdownListCSS = DropdownListCSS(loading);
|
|
136
|
+
|
|
137
|
+
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
138
|
+
|
|
139
|
+
const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _IconCSS.name, _DropdownInputCSS.name);
|
|
126
140
|
/* Start handler */
|
|
127
141
|
|
|
128
142
|
|
|
@@ -130,7 +144,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
130
144
|
const target = e.currentTarget;
|
|
131
145
|
target.style.pointerEvents = 'none';
|
|
132
146
|
|
|
133
|
-
if (!
|
|
147
|
+
if (!dropdownListRef.current) {
|
|
134
148
|
onClickInput();
|
|
135
149
|
} else {
|
|
136
150
|
onClickOutsideOfInput({
|
|
@@ -154,9 +168,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
154
168
|
};
|
|
155
169
|
|
|
156
170
|
const onClickInput = e => {
|
|
157
|
-
if (!
|
|
171
|
+
if (!dropdownListRef.current) {
|
|
158
172
|
if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e === null || e === void 0 ? void 0 : e.target))) {
|
|
159
|
-
if ((renderSelectedItem || iconExpr && iconExpr !== 'none') && !multiple) {
|
|
173
|
+
if ((typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none') && !multiple) {
|
|
160
174
|
var _inputRef$current$chi;
|
|
161
175
|
|
|
162
176
|
inputRef.current.innerHTML = inputRef.current.textContent.trim();
|
|
@@ -175,14 +189,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
175
189
|
} else if (multiple || itemMode === 'treeview') {
|
|
176
190
|
if (searchRef.current) {
|
|
177
191
|
searchRef.current.focus();
|
|
178
|
-
} else if (children &&
|
|
179
|
-
|
|
192
|
+
} else if (children && dropdownListRef.current && dropdownListRef.current.querySelector('input')) {
|
|
193
|
+
dropdownListRef.current.querySelector('input').focus();
|
|
180
194
|
}
|
|
181
195
|
}
|
|
182
196
|
};
|
|
183
197
|
|
|
184
198
|
const onClickOutsideOfInput = event => {
|
|
185
|
-
|
|
199
|
+
var _inputRef$current, _iconRef$current, _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3;
|
|
200
|
+
|
|
201
|
+
if (inputRef.current && !((_inputRef$current = inputRef.current) !== null && _inputRef$current !== void 0 && _inputRef$current.contains(event === null || event === void 0 ? void 0 : event.target)) && iconRef.current && !((_iconRef$current = iconRef.current) !== null && _iconRef$current !== void 0 && _iconRef$current.contains(event === null || event === void 0 ? void 0 : event.target)) && dropdownListRef.current && !((_dropdownListRef$curr = dropdownListRef.current) !== null && _dropdownListRef$curr !== void 0 && (_dropdownListRef$curr2 = _dropdownListRef$curr.parentNode) !== null && _dropdownListRef$curr2 !== void 0 && (_dropdownListRef$curr3 = _dropdownListRef$curr2.parentNode) !== null && _dropdownListRef$curr3 !== void 0 && _dropdownListRef$curr3.contains(event === null || event === void 0 ? void 0 : event.target))) {
|
|
186
202
|
closeDropdown();
|
|
187
203
|
triggerBlur(false);
|
|
188
204
|
}
|
|
@@ -197,8 +213,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
197
213
|
|
|
198
214
|
const keyArr = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.match(separatorPattern);
|
|
199
215
|
const dropdown = children ? jsx("div", {
|
|
200
|
-
css:
|
|
201
|
-
ref:
|
|
216
|
+
css: _DropdownListCSS,
|
|
217
|
+
ref: dropdownListRef,
|
|
218
|
+
className: 'DGN-Dropdown-List'
|
|
202
219
|
}, children) : itemMode === 'normal' ? mapDropdown(null, keyArr) : mapTreeView();
|
|
203
220
|
const {
|
|
204
221
|
innerHeight
|
|
@@ -221,55 +238,32 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
221
238
|
}
|
|
222
239
|
}
|
|
223
240
|
|
|
224
|
-
let dropdownStyle = {
|
|
225
|
-
position: 'fixed',
|
|
226
|
-
top: `${positionTop}px`,
|
|
227
|
-
left: `${left}px`,
|
|
228
|
-
width: `${width}px`,
|
|
229
|
-
backgroundColor: '#FFF',
|
|
230
|
-
zIndex: zIndex(1)
|
|
231
|
-
};
|
|
232
|
-
if (_isMobile && allowSearch) dropdownStyle = { ...dropdownStyle,
|
|
233
|
-
bottom: 0,
|
|
234
|
-
top: 'auto',
|
|
235
|
-
display: 'flex',
|
|
236
|
-
flexDirection: 'column-reverse',
|
|
237
|
-
height: 'max-content'
|
|
238
|
-
};
|
|
239
|
-
const loadingStyle = {
|
|
240
|
-
display: 'none',
|
|
241
|
-
justifyContent: 'center',
|
|
242
|
-
alignItems: 'center',
|
|
243
|
-
position: 'absolute',
|
|
244
|
-
top: 0,
|
|
245
|
-
width: '100%',
|
|
246
|
-
height: '100%',
|
|
247
|
-
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
|
248
|
-
borderRadius: 4,
|
|
249
|
-
zIndex: zIndex(2)
|
|
250
|
-
};
|
|
251
241
|
const defaultSearch = lastSearchRef.current || (onInput ? (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value : '');
|
|
242
|
+
|
|
243
|
+
const _DropdownCSS = DropdownCSS(positionTop, left, width, _isMobile, allowSearch);
|
|
244
|
+
|
|
252
245
|
const el = jsx("div", {
|
|
253
|
-
|
|
254
|
-
|
|
246
|
+
css: _DropdownCSS,
|
|
247
|
+
ref: dropdownRef,
|
|
248
|
+
className: `DGN-UI-Portal DGN-Dropdown-${unique}`
|
|
255
249
|
}, (multiple || allowSearch) && itemMode === 'normal' && !children && jsx("div", {
|
|
256
|
-
className: 'DGN-Dropdown-
|
|
250
|
+
className: 'DGN-Dropdown-Search'
|
|
257
251
|
}, jsx(InputBase, {
|
|
258
252
|
inputRef: searchRef,
|
|
259
253
|
viewType: 'outlined',
|
|
260
254
|
defaultValue: defaultSearch,
|
|
261
255
|
onChange: onChangeInput,
|
|
262
256
|
style: {
|
|
263
|
-
backgroundColor: '#FFF',
|
|
264
257
|
marginBottom: 1
|
|
265
258
|
},
|
|
266
259
|
onKeyDown: pressESCHandler,
|
|
267
260
|
autoFocus: true
|
|
268
261
|
})), jsx("div", {
|
|
269
262
|
className: 'DGN-Dropdown-Box'
|
|
270
|
-
}, dropdown), jsx("div", {
|
|
271
|
-
|
|
272
|
-
|
|
263
|
+
}, dropdown), loading && jsx("div", {
|
|
264
|
+
css: LoadingProgressCSS,
|
|
265
|
+
ref: loadingProgressRef,
|
|
266
|
+
className: 'DGN-Dropdown-Loading-Progress'
|
|
273
267
|
}, jsx(CircularProgress, {
|
|
274
268
|
size: 'xs'
|
|
275
269
|
})));
|
|
@@ -283,16 +277,21 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
283
277
|
window.addEventListener('resize', customizeWidthDropdown);
|
|
284
278
|
document.addEventListener('wheel', onWheelHandler);
|
|
285
279
|
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
286
|
-
|
|
280
|
+
dropdownListRef.current && dropdownListRef.current.addEventListener('keydown', moveOnItem);
|
|
287
281
|
|
|
288
282
|
if (onLoadMore && dataSource.length < total) {
|
|
289
|
-
|
|
283
|
+
dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
290
284
|
}
|
|
291
285
|
}, 10);
|
|
292
286
|
return el;
|
|
293
287
|
};
|
|
294
288
|
|
|
295
289
|
const moveOnItem = e => {
|
|
290
|
+
if (e.key === 'Escape' || e.key === 'Tab') {
|
|
291
|
+
closeDropdown();
|
|
292
|
+
triggerBlur();
|
|
293
|
+
}
|
|
294
|
+
|
|
296
295
|
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
|
|
297
296
|
let activeEl = document.activeElement;
|
|
298
297
|
activeEl = e.key === 'ArrowDown' ? activeEl.nextElementSibling : activeEl.previousElementSibling;
|
|
@@ -307,52 +306,49 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
307
306
|
}
|
|
308
307
|
};
|
|
309
308
|
|
|
310
|
-
const pressESCHandler =
|
|
311
|
-
if (
|
|
309
|
+
const pressESCHandler = e => {
|
|
310
|
+
if (e.key === 'Escape' || e.key === 'Tab') {
|
|
312
311
|
closeDropdown();
|
|
313
312
|
triggerBlur();
|
|
314
|
-
} else if (
|
|
315
|
-
|
|
313
|
+
} else if (e.key === 'ArrowDown' && dropdownListRef.current) {
|
|
314
|
+
e.preventDefault();
|
|
315
|
+
dropdownListRef.current.firstChild.focus();
|
|
316
316
|
}
|
|
317
317
|
};
|
|
318
318
|
|
|
319
319
|
const onWheelHandler = e => {
|
|
320
|
-
|
|
320
|
+
var _dropdownRef$current;
|
|
321
321
|
|
|
322
|
-
if (!
|
|
322
|
+
if (!dropdownRef.current) {
|
|
323
323
|
document.removeEventListener('wheel', onWheelHandler);
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
|
-
if (!
|
|
327
|
+
if (!((_dropdownRef$current = dropdownRef.current) !== null && _dropdownRef$current !== void 0 && _dropdownRef$current.contains(e.target))) {
|
|
328
328
|
closeDropdown();
|
|
329
329
|
triggerBlur();
|
|
330
330
|
}
|
|
331
331
|
};
|
|
332
332
|
|
|
333
333
|
const closeDropdown = () => {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
timing[unique + 'Box'] = null;
|
|
345
|
-
node.remove();
|
|
346
|
-
boxRef.current = null;
|
|
347
|
-
}, 300);
|
|
334
|
+
if (dropdownRef.current) {
|
|
335
|
+
// dropdownRef.current.style.pointerEvents = `none`;
|
|
336
|
+
// dropdownRef.current.style.transition = `opacity 0.5s`;
|
|
337
|
+
// dropdownRef.current.style.opacity = 0;
|
|
338
|
+
// timing[unique + 'Box'] = setTimeout(() => {
|
|
339
|
+
// clearTimeout(timing[unique + 'Box']);
|
|
340
|
+
// timing[unique + 'Box'] = null;
|
|
341
|
+
// dropdownRef.current?.remove();
|
|
342
|
+
// dropdownListRef.current = null;
|
|
343
|
+
// }, 300);
|
|
348
344
|
setOpenState(false);
|
|
349
345
|
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
350
346
|
window.removeEventListener('resize', customizeWidthDropdown);
|
|
351
347
|
document.removeEventListener('wheel', onWheelHandler);
|
|
352
348
|
|
|
353
|
-
if (onLoadMore &&
|
|
354
|
-
|
|
355
|
-
|
|
349
|
+
if (onLoadMore && dropdownListRef.current) {
|
|
350
|
+
dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
351
|
+
dropdownListRef.current = null;
|
|
356
352
|
} // if (!multiple) {
|
|
357
353
|
// inputRef.current.removeEventListener('keydown', pressESCHandler);
|
|
358
354
|
// inputRef.current.removeEventListener('input', onChangeInput);
|
|
@@ -371,16 +367,17 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
371
367
|
const dropdown = mapDropdown(pattern, keyArr);
|
|
372
368
|
const el = document.createElement('div');
|
|
373
369
|
el.className = `DGN-Dropdown-Box`;
|
|
374
|
-
const node = document.querySelector(`.DGN-Dropdown-${unique}`);
|
|
375
370
|
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
|
|
371
|
+
if (dropdownRef.current) {
|
|
372
|
+
var _dropdownRef$current$;
|
|
373
|
+
|
|
374
|
+
(_dropdownRef$current$ = dropdownRef.current.querySelector('.DGN-Dropdown-Box')) === null || _dropdownRef$current$ === void 0 ? void 0 : _dropdownRef$current$.remove();
|
|
375
|
+
ReactDOM.render(dropdown, dropdownRef.current.appendChild(el));
|
|
379
376
|
setTimeout(() => {
|
|
380
|
-
|
|
377
|
+
dropdownListRef.current && dropdownListRef.current.addEventListener('keydown', moveOnItem);
|
|
381
378
|
|
|
382
379
|
if (onLoadMore && dataSource.length < total) {
|
|
383
|
-
|
|
380
|
+
dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
384
381
|
}
|
|
385
382
|
|
|
386
383
|
updatePositionDropdown();
|
|
@@ -394,8 +391,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
394
391
|
const items = [];
|
|
395
392
|
const dataSourceUsable = [...dataSource];
|
|
396
393
|
|
|
397
|
-
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
398
|
-
|
|
399
394
|
if (currentObjectDefault[unique] && (_currentObjectDefault = currentObjectDefault[unique]) !== null && _currentObjectDefault !== void 0 && _currentObjectDefault.length) {
|
|
400
395
|
const length = currentObjectDefault[unique].length;
|
|
401
396
|
let existItemQuantity = 0;
|
|
@@ -446,19 +441,20 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
446
441
|
items.push(jsx("div", {
|
|
447
442
|
key: index,
|
|
448
443
|
css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}
|
|
444
|
+
className: 'DGN-UI-Dropdown-Item' // onClick={() => {
|
|
445
|
+
// if (itemDisabled) return;
|
|
446
|
+
// onChangeValueWithCheckbox(e) & onChangeValue(displayText, value, icon, data, index);
|
|
447
|
+
// onChangeValue(displayText, value, icon, data, index);
|
|
448
|
+
// }}
|
|
449
|
+
,
|
|
454
450
|
onKeyPress: e => {
|
|
455
|
-
if (itemDisabled) return;
|
|
456
|
-
|
|
457
|
-
if (e.key === 'Enter') onChangeValue(displayText, value, icon, data, index);
|
|
451
|
+
if (itemDisabled) return;
|
|
452
|
+
if (e.key === 'Enter') e.currentTarget.firstChild.click(); // if (e.key === 'Enter') onChangeValue(displayText, value, icon, data, index);
|
|
458
453
|
},
|
|
459
454
|
tabIndex: -1
|
|
460
455
|
}, jsx(Checkbox, {
|
|
461
|
-
|
|
456
|
+
forTreeView: true,
|
|
457
|
+
checked: checked,
|
|
462
458
|
style: {
|
|
463
459
|
width: '100%',
|
|
464
460
|
height: '100%',
|
|
@@ -492,20 +488,20 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
492
488
|
}, icon), jsx("div", {
|
|
493
489
|
css: DropdownTextCSS
|
|
494
490
|
}, displayText)));
|
|
495
|
-
}
|
|
491
|
+
} // if (items?.length === limit) {
|
|
492
|
+
// timerRef.current = setTimeout(() => {
|
|
493
|
+
// loadMoreItemsDropdown(index + 1, pattern);
|
|
494
|
+
// }, 1000);
|
|
495
|
+
// break;
|
|
496
|
+
// }
|
|
496
497
|
|
|
497
|
-
if (items.length === limit) {
|
|
498
|
-
timerRef.current = setTimeout(() => {
|
|
499
|
-
loadMoreItemsDropdown(index + 1, pattern);
|
|
500
|
-
}, 1000);
|
|
501
|
-
break;
|
|
502
|
-
}
|
|
503
498
|
}
|
|
504
499
|
|
|
505
500
|
return jsx("div", {
|
|
506
|
-
css:
|
|
507
|
-
ref:
|
|
508
|
-
|
|
501
|
+
css: _DropdownListCSS,
|
|
502
|
+
ref: dropdownListRef,
|
|
503
|
+
className: 'DGN-Dropdown-List'
|
|
504
|
+
}, items !== null && items !== void 0 && items.length ? items : jsx("div", {
|
|
509
505
|
css: _DropdownItemCSS,
|
|
510
506
|
className: 'no-data'
|
|
511
507
|
}, ' ', noDataText, ' '));
|
|
@@ -514,8 +510,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
514
510
|
const mapTreeView = () => {
|
|
515
511
|
// if (!treeView[unique]) {
|
|
516
512
|
return jsx("div", {
|
|
517
|
-
css:
|
|
518
|
-
ref:
|
|
513
|
+
css: _DropdownListCSS,
|
|
514
|
+
ref: dropdownListRef,
|
|
515
|
+
className: 'DGN-Dropdown-List'
|
|
519
516
|
}, jsx(TreeView, {
|
|
520
517
|
dataSource: dataSource,
|
|
521
518
|
displayExpr: displayExpr,
|
|
@@ -564,8 +561,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
564
561
|
|
|
565
562
|
const keyArr = (_displayExpr3 = displayExpr) === null || _displayExpr3 === void 0 ? void 0 : _displayExpr3.match(separatorPattern);
|
|
566
563
|
|
|
567
|
-
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
568
|
-
|
|
569
564
|
for (i; i < length; i++) {
|
|
570
565
|
const data = { ...dataSourceUsable[i]
|
|
571
566
|
}; // Nếu đối tượng đã được hiển thị ở trên rồi thì không hiển thị ra nữa
|
|
@@ -604,7 +599,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
604
599
|
if (multiple && selectBox) {
|
|
605
600
|
const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
|
|
606
601
|
item = jsx(Checkbox, {
|
|
607
|
-
|
|
602
|
+
forTreeView: true,
|
|
603
|
+
checked: checked,
|
|
608
604
|
style: {
|
|
609
605
|
width: '100%',
|
|
610
606
|
height: '100%',
|
|
@@ -623,11 +619,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
623
619
|
}, displayText));
|
|
624
620
|
}
|
|
625
621
|
|
|
626
|
-
if (!
|
|
622
|
+
if (!dropdownListRef.current) {
|
|
627
623
|
return;
|
|
628
624
|
}
|
|
629
625
|
|
|
630
|
-
ReactDOM.render(item,
|
|
626
|
+
ReactDOM.render(item, dropdownListRef.current.appendChild(dropdownItem));
|
|
631
627
|
|
|
632
628
|
if (++num === 100) {
|
|
633
629
|
timerRef.current = setTimeout(() => {
|
|
@@ -696,33 +692,31 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
696
692
|
};
|
|
697
693
|
|
|
698
694
|
const customizeWidthDropdown = () => {
|
|
699
|
-
if (
|
|
695
|
+
if (dropdownListRef.current && _isMobile) dropdownListRef.current.style.maxHeight = `${Math.min(280, window.innerHeight) - (allowSearch ? 40 : 0)}px`;
|
|
700
696
|
|
|
701
|
-
if (!
|
|
697
|
+
if (!ref.current) {
|
|
702
698
|
window.removeEventListener('resize', customizeWidthDropdown);
|
|
703
699
|
return;
|
|
704
700
|
}
|
|
705
701
|
|
|
706
702
|
const {
|
|
707
703
|
width
|
|
708
|
-
} =
|
|
704
|
+
} = ref.current.getBoundingClientRect();
|
|
709
705
|
|
|
710
|
-
if (
|
|
711
|
-
|
|
706
|
+
if (dropdownRef.current) {
|
|
707
|
+
dropdownRef.current.style.width = width + 'px';
|
|
712
708
|
}
|
|
713
709
|
|
|
714
710
|
updatePositionDropdown();
|
|
715
711
|
};
|
|
716
712
|
|
|
717
713
|
const updatePositionDropdown = () => {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
if (!formRef.current || !node) {
|
|
714
|
+
if (!formRef.current || !dropdownRef.current) {
|
|
721
715
|
document.removeEventListener('wheel', onWheelHandler);
|
|
722
716
|
return;
|
|
723
717
|
}
|
|
724
718
|
|
|
725
|
-
_isMobile ? updatePosition(formRef.current,
|
|
719
|
+
_isMobile ? updatePosition(formRef.current, dropdownRef.current, null) : updatePosition(formRef.current, dropdownRef.current, closeDropdown);
|
|
726
720
|
};
|
|
727
721
|
|
|
728
722
|
const onLoadMoreHandler = e => {
|
|
@@ -732,13 +726,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
732
726
|
offsetHeight
|
|
733
727
|
} = e.target;
|
|
734
728
|
|
|
735
|
-
|
|
729
|
+
if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
|
|
730
|
+
var _dropdownListRef$curr4, _currentObjectDefault3;
|
|
736
731
|
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
const length = (_boxRef$current$query = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query === void 0 ? void 0 : _boxRef$current$query.length;
|
|
741
|
-
boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
732
|
+
const length = ((_dropdownListRef$curr4 = dropdownListRef.current.children) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.length) - (((_currentObjectDefault3 = currentObjectDefault[unique]) === null || _currentObjectDefault3 === void 0 ? void 0 : _currentObjectDefault3.length) || 0);
|
|
733
|
+
dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
742
734
|
!!onLoadMore && onLoadMore({
|
|
743
735
|
skip: length,
|
|
744
736
|
limit: limit
|
|
@@ -777,7 +769,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
777
769
|
|
|
778
770
|
const value = e.target.value || e.target.textContent;
|
|
779
771
|
|
|
780
|
-
if (renderSelectedItem && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
|
|
772
|
+
if (typeof renderSelectedItem === 'function' && e.target.childNodes && Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')) {
|
|
781
773
|
const cursor = document.getSelection().anchorOffset;
|
|
782
774
|
e.target.innerHTML = value;
|
|
783
775
|
document.getSelection().collapse(e.target, cursor);
|
|
@@ -785,11 +777,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
785
777
|
|
|
786
778
|
if (timing[unique]) clearTimeout(timing[unique]);
|
|
787
779
|
timing[unique] = setTimeout(() => {
|
|
788
|
-
if (timerRef.current) {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
}
|
|
792
|
-
|
|
780
|
+
// if (timerRef.current) {
|
|
781
|
+
// clearTimeout(timerRef.current);
|
|
782
|
+
// timerRef.current = null;
|
|
783
|
+
// }
|
|
793
784
|
renderDropdown(new RegExp(value.normalize(), 'gim'));
|
|
794
785
|
}, timeout.current || searchDelayTime);
|
|
795
786
|
};
|
|
@@ -817,7 +808,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
817
808
|
if (valueProp === undefined) {
|
|
818
809
|
let item = null;
|
|
819
810
|
|
|
820
|
-
if (
|
|
811
|
+
if (typeof renderSelectedItem === 'function') {
|
|
821
812
|
item = renderSelectedItem({
|
|
822
813
|
data,
|
|
823
814
|
index
|
|
@@ -847,7 +838,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
847
838
|
value: newValueArr,
|
|
848
839
|
data
|
|
849
840
|
});
|
|
850
|
-
} else
|
|
841
|
+
} else {
|
|
851
842
|
const index = newValueArr.indexOf(value);
|
|
852
843
|
newValueArr.splice(index, 1);
|
|
853
844
|
|
|
@@ -901,15 +892,17 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
901
892
|
if (index !== -1) {
|
|
902
893
|
currentValue[unique].splice(index, 1);
|
|
903
894
|
setTimeout(() => {
|
|
904
|
-
|
|
905
|
-
|
|
895
|
+
var _e$parentNode;
|
|
896
|
+
|
|
897
|
+
if (dropdownListRef.current && multiple && selectBox && !children) {
|
|
898
|
+
const input = dropdownListRef.current.querySelector(`input[value="${value}"]`);
|
|
906
899
|
|
|
907
900
|
if (input) {
|
|
908
901
|
input.checked = false;
|
|
909
902
|
}
|
|
910
903
|
}
|
|
911
904
|
|
|
912
|
-
|
|
905
|
+
e === null || e === void 0 ? void 0 : (_e$parentNode = e.parentNode) === null || _e$parentNode === void 0 ? void 0 : _e$parentNode.remove();
|
|
913
906
|
}, 0);
|
|
914
907
|
!!onChange && onChange({
|
|
915
908
|
value: currentValue[unique],
|
|
@@ -925,14 +918,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
925
918
|
if (inputRef.current.tagName.toLowerCase() === 'div') {
|
|
926
919
|
inputRef.current.innerHTML = '';
|
|
927
920
|
|
|
928
|
-
if (
|
|
929
|
-
|
|
921
|
+
if (dropdownListRef.current) {
|
|
922
|
+
dropdownListRef.current.querySelectorAll('input').forEach(input => input.checked = false);
|
|
930
923
|
}
|
|
931
924
|
} else {
|
|
932
925
|
inputRef.current.value = '';
|
|
933
926
|
} // onChangeValue('', '');
|
|
934
927
|
|
|
935
928
|
|
|
929
|
+
setShowClear(false);
|
|
936
930
|
e && e.target && e.target.blur();
|
|
937
931
|
updatePositionDropdown();
|
|
938
932
|
onInput === null || onInput === void 0 ? void 0 : onInput({ ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
|
|
@@ -956,7 +950,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
956
950
|
inputRef.current.innerHTML = '';
|
|
957
951
|
currentValue[unique] = [];
|
|
958
952
|
} else {
|
|
959
|
-
if (renderSelectedItem || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
|
|
953
|
+
if (typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
|
|
960
954
|
inputRef.current.innerHTML = '';
|
|
961
955
|
} else if (!isSearch[unique]) {
|
|
962
956
|
inputRef.current.value = '';
|
|
@@ -969,7 +963,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
969
963
|
}
|
|
970
964
|
|
|
971
965
|
const length = dataSource.length;
|
|
972
|
-
const displayKey =
|
|
966
|
+
const displayKey = typeof renderSelectedItem === 'string' ? renderSelectedItem : displayExpr;
|
|
973
967
|
|
|
974
968
|
if (displayKey && Array.isArray(displayKey)) {
|
|
975
969
|
displayExpr = displayExpr.join(' - ');
|
|
@@ -988,7 +982,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
988
982
|
currentValue[unique] = [];
|
|
989
983
|
inputRef.current.innerHTML = '';
|
|
990
984
|
valueArr.forEach(v => {
|
|
991
|
-
var
|
|
985
|
+
var _currentObjectDefault4;
|
|
992
986
|
|
|
993
987
|
for (let i = 0; i < length; i++) {
|
|
994
988
|
if (typeof dataSource[i] === 'object' && dataSource[i][valueExpr] === v || dataSource[i] === v) {
|
|
@@ -997,7 +991,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
997
991
|
}
|
|
998
992
|
}
|
|
999
993
|
|
|
1000
|
-
if ((
|
|
994
|
+
if ((_currentObjectDefault4 = currentObjectDefault[unique]) !== null && _currentObjectDefault4 !== void 0 && _currentObjectDefault4.length) {
|
|
1001
995
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === v || valueObject === v);
|
|
1002
996
|
|
|
1003
997
|
if (itemOfValue) {
|
|
@@ -1006,7 +1000,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1006
1000
|
}
|
|
1007
1001
|
});
|
|
1008
1002
|
} else {
|
|
1009
|
-
var
|
|
1003
|
+
var _currentObjectDefault5;
|
|
1010
1004
|
|
|
1011
1005
|
currentValue[unique] = source;
|
|
1012
1006
|
|
|
@@ -1017,7 +1011,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1017
1011
|
}
|
|
1018
1012
|
}
|
|
1019
1013
|
|
|
1020
|
-
if ((
|
|
1014
|
+
if ((_currentObjectDefault5 = currentObjectDefault[unique]) !== null && _currentObjectDefault5 !== void 0 && _currentObjectDefault5.length) {
|
|
1021
1015
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === source || valueObject === source);
|
|
1022
1016
|
|
|
1023
1017
|
if (itemOfValue) {
|
|
@@ -1035,14 +1029,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1035
1029
|
const setMultipleValueHandler = (data, value, keyArr, index) => {
|
|
1036
1030
|
let item = null;
|
|
1037
1031
|
|
|
1038
|
-
if (
|
|
1032
|
+
if (typeof renderSelectedItem === 'function') {
|
|
1039
1033
|
item = renderSelectedItem({
|
|
1040
1034
|
data,
|
|
1041
1035
|
index
|
|
1042
1036
|
});
|
|
1043
1037
|
} else {
|
|
1044
1038
|
const icon = getIconFromData(data);
|
|
1045
|
-
const text = keyArr ? renderData(data, keyArr) : data[
|
|
1039
|
+
const text = keyArr ? renderData(data, keyArr) : data[renderSelectedItem || displayExpr];
|
|
1046
1040
|
item = jsx(Chip, {
|
|
1047
1041
|
startIcon: icon,
|
|
1048
1042
|
label: text,
|
|
@@ -1065,9 +1059,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1065
1059
|
};
|
|
1066
1060
|
|
|
1067
1061
|
const setSingleValueHandler = (data, keyArr) => {
|
|
1068
|
-
const text = keyArr ? renderData(data, keyArr) : data[
|
|
1062
|
+
const text = keyArr ? renderData(data, keyArr) : typeof renderSelectedItem === 'string' ? data[renderSelectedItem] : data[displayExpr || valueExpr] || data;
|
|
1069
1063
|
|
|
1070
|
-
if (
|
|
1064
|
+
if (typeof renderSelectedItem === 'function') {
|
|
1071
1065
|
inputRef.current.innerHTML = '';
|
|
1072
1066
|
const item = renderSelectedItem({
|
|
1073
1067
|
data
|
|
@@ -1095,7 +1089,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1095
1089
|
};
|
|
1096
1090
|
|
|
1097
1091
|
useImperativeHandle(reference, () => {
|
|
1098
|
-
const currentRef =
|
|
1092
|
+
const currentRef = ref.current || {};
|
|
1099
1093
|
const _instance = {
|
|
1100
1094
|
closeDropdown: () => {
|
|
1101
1095
|
closeDropdown();
|
|
@@ -1133,7 +1127,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1133
1127
|
setValueIntoInput(value);
|
|
1134
1128
|
};
|
|
1135
1129
|
|
|
1136
|
-
currentRef.DOM =
|
|
1130
|
+
currentRef.DOM = ref.current;
|
|
1137
1131
|
return currentRef;
|
|
1138
1132
|
});
|
|
1139
1133
|
useEffect(() => {
|
|
@@ -1189,38 +1183,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1189
1183
|
}
|
|
1190
1184
|
}, [valueProp]);
|
|
1191
1185
|
useEffect(() => {
|
|
1192
|
-
if (
|
|
1193
|
-
if (boxRef.current) {
|
|
1194
|
-
var _boxRef$current$paren, _boxRef$current$paren2;
|
|
1195
|
-
|
|
1196
|
-
const loadingNode = (_boxRef$current$paren = boxRef.current.parentNode) === null || _boxRef$current$paren === void 0 ? void 0 : (_boxRef$current$paren2 = _boxRef$current$paren.parentNode) === null || _boxRef$current$paren2 === void 0 ? void 0 : _boxRef$current$paren2.querySelector('.DGN-Dropdown-Loading');
|
|
1197
|
-
|
|
1198
|
-
if (loadingNode) {
|
|
1199
|
-
loadingNode.style.display = 'flex';
|
|
1200
|
-
setTimeout(() => {
|
|
1201
|
-
loadingNode.style.opacity = 1;
|
|
1202
|
-
}, 0);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
|
|
1206
|
-
return () => {
|
|
1207
|
-
if (iconRef.current && dropdownRef.current) {
|
|
1208
|
-
if (boxRef.current) {
|
|
1209
|
-
const loadingNode = document.querySelector('.DGN-Dropdown-Loading');
|
|
1210
|
-
|
|
1211
|
-
if (loadingNode) {
|
|
1212
|
-
loadingNode.style.opacity = 0;
|
|
1213
|
-
setTimeout(() => {
|
|
1214
|
-
loadingNode.style.display = 'none';
|
|
1215
|
-
}, 300);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
};
|
|
1220
|
-
}
|
|
1221
|
-
}, [loading]);
|
|
1222
|
-
useEffect(() => {
|
|
1223
|
-
if (valueProp !== undefined && (!boxRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
|
|
1186
|
+
if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
|
|
1224
1187
|
setValueIntoInput(valueProp);
|
|
1225
1188
|
}
|
|
1226
1189
|
}, [valueProp, dataSource]);
|
|
@@ -1230,7 +1193,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1230
1193
|
if (!readOnly && !disabled) {
|
|
1231
1194
|
inputRef.current.addEventListener('click', onClickInput);
|
|
1232
1195
|
inputRef.current.addEventListener('input', onChangeInput);
|
|
1233
|
-
!!onLoadMore &&
|
|
1196
|
+
!!onLoadMore && dropdownListRef.current && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
1234
1197
|
} else {
|
|
1235
1198
|
if (multiple) {
|
|
1236
1199
|
inputRef.current.contentEditable = false;
|
|
@@ -1244,7 +1207,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1244
1207
|
}
|
|
1245
1208
|
|
|
1246
1209
|
return () => {
|
|
1247
|
-
if (!
|
|
1210
|
+
if (!ref.current || !inputRef.current || !iconRef.current) return;
|
|
1248
1211
|
|
|
1249
1212
|
if (!readOnly && !disabled) {
|
|
1250
1213
|
inputRef.current.removeEventListener('click', onClickInput);
|
|
@@ -1282,20 +1245,18 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1282
1245
|
inputRef.current.addEventListener('click', onClickInput);
|
|
1283
1246
|
}
|
|
1284
1247
|
|
|
1285
|
-
if (
|
|
1286
|
-
var
|
|
1248
|
+
if (dropdownListRef.current) {
|
|
1249
|
+
var _dropdownListRef$curr5, _dropdownListRef$curr6, _currentObjectDefault6;
|
|
1287
1250
|
|
|
1288
1251
|
if (!disabled && !readOnly) {
|
|
1289
1252
|
inputRef.current.addEventListener('input', onChangeInput);
|
|
1290
1253
|
}
|
|
1291
1254
|
|
|
1292
|
-
const
|
|
1293
|
-
|
|
1294
|
-
const length = (_boxRef$current$query2 = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`)) === null || _boxRef$current$query2 === void 0 ? void 0 : _boxRef$current$query2.length;
|
|
1255
|
+
const length = (_dropdownListRef$curr5 = dropdownListRef.current) === null || _dropdownListRef$curr5 === void 0 ? void 0 : (_dropdownListRef$curr6 = _dropdownListRef$curr5.children) === null || _dropdownListRef$curr6 === void 0 ? void 0 : _dropdownListRef$curr6.length;
|
|
1295
1256
|
|
|
1296
|
-
if (length < dataSource.length + ((
|
|
1257
|
+
if (length < dataSource.length + ((_currentObjectDefault6 = currentObjectDefault[unique]) === null || _currentObjectDefault6 === void 0 ? void 0 : _currentObjectDefault6.length) && !isSearch[unique]) {
|
|
1297
1258
|
loadMoreItemsDropdown(length);
|
|
1298
|
-
!!onLoadMore && dataSource.length < total &&
|
|
1259
|
+
!!onLoadMore && dataSource.length < total && dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
1299
1260
|
} else {
|
|
1300
1261
|
isSearch[unique] = false;
|
|
1301
1262
|
}
|
|
@@ -1311,25 +1272,19 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1311
1272
|
inputRef.current.removeEventListener('click', onClickInput);
|
|
1312
1273
|
}
|
|
1313
1274
|
|
|
1314
|
-
!!
|
|
1275
|
+
!!dropdownListRef.current && dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
1315
1276
|
};
|
|
1316
1277
|
}, [dataSource]);
|
|
1317
1278
|
/* End handler */
|
|
1318
1279
|
|
|
1319
1280
|
/* Start component */
|
|
1320
1281
|
|
|
1321
|
-
const
|
|
1282
|
+
const LabelView = useMemo(() => label ? jsx(Label, {
|
|
1322
1283
|
required: required,
|
|
1323
1284
|
disabled: disabled,
|
|
1324
1285
|
...labelProps
|
|
1325
1286
|
}, label) : null, [label, required, disabled, labelProps]);
|
|
1326
|
-
const
|
|
1327
|
-
const _InputCSS = InputCSS(multiple, renderSelectedItem);
|
|
1328
|
-
|
|
1329
|
-
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
|
|
1330
|
-
|
|
1331
|
-
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled);
|
|
1332
|
-
|
|
1287
|
+
const InputView = useMemo(() => {
|
|
1333
1288
|
return jsx("div", {
|
|
1334
1289
|
css: _DropdownFormCSS,
|
|
1335
1290
|
ref: formRef,
|
|
@@ -1346,18 +1301,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1346
1301
|
ref: inputRef,
|
|
1347
1302
|
css: _DropdownInputCSS,
|
|
1348
1303
|
className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
|
|
1349
|
-
type: "text",
|
|
1350
1304
|
onChange: e => {
|
|
1351
1305
|
e.preventDefault();
|
|
1352
1306
|
return false;
|
|
1353
1307
|
}
|
|
1354
|
-
}) : renderSelectedItem || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
|
|
1308
|
+
}) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
|
|
1355
1309
|
contentEditable: !disabled,
|
|
1356
1310
|
style: inputStyle,
|
|
1357
1311
|
ref: inputRef,
|
|
1358
1312
|
css: _DropdownInputCSS,
|
|
1359
1313
|
className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
|
|
1360
|
-
type: "text",
|
|
1361
1314
|
onKeyDown: e => {
|
|
1362
1315
|
if (e.key === 'Enter') {
|
|
1363
1316
|
e.preventDefault();
|
|
@@ -1373,7 +1326,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1373
1326
|
disabled: disabled
|
|
1374
1327
|
})), jsx("div", {
|
|
1375
1328
|
ref: iconRef,
|
|
1376
|
-
css:
|
|
1329
|
+
css: _IconCSS,
|
|
1377
1330
|
className: 'DGN-UI-Dropdown-Icon'
|
|
1378
1331
|
}, jsx("span", {
|
|
1379
1332
|
className: 'dgn-dropdown-loading'
|
|
@@ -1396,7 +1349,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1396
1349
|
disabled: disabled || readOnly
|
|
1397
1350
|
})));
|
|
1398
1351
|
}, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear]);
|
|
1399
|
-
const
|
|
1352
|
+
const ErrorView = useMemo(() => error && jsx(HelperText, {
|
|
1400
1353
|
disabled: disabled,
|
|
1401
1354
|
style: {
|
|
1402
1355
|
minHeight: '16px',
|
|
@@ -1405,17 +1358,17 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1405
1358
|
...errorStyle
|
|
1406
1359
|
}
|
|
1407
1360
|
}, error), [error, disabled, errorStyle]);
|
|
1408
|
-
const
|
|
1361
|
+
const DropdownView = useMemo(() => {
|
|
1409
1362
|
return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
|
|
1410
|
-
}, [openState, dataSource]);
|
|
1363
|
+
}, [openState, dataSource, loading, multiple, selectBox]);
|
|
1411
1364
|
/* End component */
|
|
1412
1365
|
|
|
1413
1366
|
return jsx(Fragment, null, jsx("div", {
|
|
1414
|
-
ref:
|
|
1415
|
-
css:
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
},
|
|
1367
|
+
ref: ref,
|
|
1368
|
+
css: _DropdownRootCSS,
|
|
1369
|
+
style: style,
|
|
1370
|
+
className: ['DGN-UI-Dropdown', className, error && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' ')
|
|
1371
|
+
}, LabelView, InputView, ErrorView), DropdownView);
|
|
1419
1372
|
}));
|
|
1420
1373
|
/* Start styled */
|
|
1421
1374
|
|
|
@@ -1430,17 +1383,14 @@ const DropdownIconCSS = css`
|
|
|
1430
1383
|
${alignCenter};
|
|
1431
1384
|
${positionRelative};
|
|
1432
1385
|
${overflowHidden};
|
|
1433
|
-
|
|
1434
|
-
margin-right:
|
|
1435
|
-
height: 32px;
|
|
1386
|
+
${parseWidthHeight(32)};
|
|
1387
|
+
margin-right: ${spacing([2])};
|
|
1436
1388
|
min-height: 32px;
|
|
1437
|
-
width: 32px;
|
|
1438
1389
|
min-width: 32px;
|
|
1439
1390
|
border-radius: 16px;
|
|
1440
1391
|
img {
|
|
1441
|
-
|
|
1392
|
+
${parseWidthHeight(32)};
|
|
1442
1393
|
min-height: 32px;
|
|
1443
|
-
width: 32px;
|
|
1444
1394
|
min-width: 32px;
|
|
1445
1395
|
object-fit: cover;
|
|
1446
1396
|
}
|
|
@@ -1457,7 +1407,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1457
1407
|
color: ${disabled ? systemDisabled : main};
|
|
1458
1408
|
padding-top: 0;
|
|
1459
1409
|
padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
|
|
1460
|
-
padding-left: ${viewType !== 'outlined' ? 0 :
|
|
1410
|
+
padding-left: ${viewType !== 'outlined' ? 0 : spacing([4])};
|
|
1461
1411
|
min-height: ${multiple ? 30 : 24}px;
|
|
1462
1412
|
&.dgn-dropdown-multiple {
|
|
1463
1413
|
${flexWrap};
|
|
@@ -1522,19 +1472,19 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
|
|
|
1522
1472
|
const IconCSS = (viewType, loading, showClear) => css`
|
|
1523
1473
|
${flexRow};
|
|
1524
1474
|
${alignCenter};
|
|
1525
|
-
margin-left:
|
|
1526
|
-
margin-right: ${viewType !== 'outlined' ?
|
|
1475
|
+
margin-left: ${spacing([2])};
|
|
1476
|
+
margin-right: ${viewType !== 'outlined' ? 0 : spacing([4])};
|
|
1527
1477
|
color: inherit;
|
|
1528
1478
|
.icon-close {
|
|
1529
1479
|
display: ${showClear ? 'flex' : 'none'};
|
|
1530
|
-
margin-right:
|
|
1480
|
+
margin-right: ${spacing([1])};
|
|
1531
1481
|
}
|
|
1532
1482
|
.dgn-dropdown-loading {
|
|
1533
1483
|
display: ${loading ? 'flex' : 'none'};
|
|
1534
1484
|
}
|
|
1535
1485
|
`;
|
|
1536
1486
|
|
|
1537
|
-
const DropdownFormCSS = (viewType, multiple,
|
|
1487
|
+
const DropdownFormCSS = (viewType, multiple, disabled, DropdownInputCSSName) => viewType !== 'outlined' ? css`
|
|
1538
1488
|
${flexRow};
|
|
1539
1489
|
${alignCenter};
|
|
1540
1490
|
${positionRelative};
|
|
@@ -1547,7 +1497,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1547
1497
|
&::before {
|
|
1548
1498
|
border-bottom-color: ${active};
|
|
1549
1499
|
}
|
|
1550
|
-
.css-${
|
|
1500
|
+
.css-${DropdownInputCSSName} {
|
|
1551
1501
|
color: ${active};
|
|
1552
1502
|
}
|
|
1553
1503
|
}
|
|
@@ -1558,7 +1508,7 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1558
1508
|
border-bottom-color: inherit;
|
|
1559
1509
|
transform: scaleX(1);
|
|
1560
1510
|
}
|
|
1561
|
-
.css-${
|
|
1511
|
+
.css-${DropdownInputCSSName} {
|
|
1562
1512
|
color: ${active};
|
|
1563
1513
|
}
|
|
1564
1514
|
}
|
|
@@ -1631,20 +1581,20 @@ const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1631
1581
|
}
|
|
1632
1582
|
`;
|
|
1633
1583
|
|
|
1634
|
-
const
|
|
1584
|
+
const DropdownListCSS = loading => css`
|
|
1635
1585
|
${displayBlock};
|
|
1636
1586
|
${positionRelative};
|
|
1637
1587
|
${borderBox};
|
|
1638
1588
|
${borderRadius4px};
|
|
1639
1589
|
width: 100%;
|
|
1640
1590
|
max-height: 280px;
|
|
1641
|
-
|
|
1591
|
+
${loading ? overflowHidden : overflowAuto};
|
|
1642
1592
|
background-color: ${white};
|
|
1643
1593
|
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
1644
|
-
z-index: ${
|
|
1594
|
+
z-index: ${zIndexCORE(1)};
|
|
1645
1595
|
&::-webkit-scrollbar {
|
|
1646
1596
|
${borderRadius4px};
|
|
1647
|
-
|
|
1597
|
+
${parseWidth(24)};
|
|
1648
1598
|
background-color: ${white} !important;
|
|
1649
1599
|
}
|
|
1650
1600
|
&::-webkit-scrollbar-thumb {
|
|
@@ -1670,6 +1620,7 @@ const DropdownItemCSS = (multiple, selectBox) => css`
|
|
|
1670
1620
|
min-height: 40px;
|
|
1671
1621
|
width: 100%;
|
|
1672
1622
|
background-color: ${white};
|
|
1623
|
+
padding: ${spacing([2, multiple && selectBox ? 0 : 4])};
|
|
1673
1624
|
padding: 8px ${multiple && selectBox ? 0 : '16px'};
|
|
1674
1625
|
color: ${main};
|
|
1675
1626
|
&.no-data {
|
|
@@ -1699,13 +1650,13 @@ const DropdownTextCSS = css`
|
|
|
1699
1650
|
}
|
|
1700
1651
|
`;
|
|
1701
1652
|
|
|
1702
|
-
const DropdownRootCSS = (
|
|
1653
|
+
const DropdownRootCSS = (DropdownFormCSSName, IconCSSName, DropdownInputCSSName) => css`
|
|
1703
1654
|
${displayBlock};
|
|
1704
1655
|
${positionRelative};
|
|
1705
1656
|
margin-bottom: 20px;
|
|
1706
1657
|
height: max-content;
|
|
1707
1658
|
&.error {
|
|
1708
|
-
.css-${
|
|
1659
|
+
.css-${DropdownFormCSSName} {
|
|
1709
1660
|
border-color: ${danger};
|
|
1710
1661
|
path {
|
|
1711
1662
|
fill: ${danger};
|
|
@@ -1717,9 +1668,9 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1717
1668
|
}
|
|
1718
1669
|
&.dgn-dropdown-loading,
|
|
1719
1670
|
&.disabled {
|
|
1720
|
-
.css-${
|
|
1671
|
+
.css-${DropdownFormCSSName} {
|
|
1721
1672
|
border-color: ${systemDisabled};
|
|
1722
|
-
.css-${
|
|
1673
|
+
.css-${IconCSSName} {
|
|
1723
1674
|
path {
|
|
1724
1675
|
fill: transparent;
|
|
1725
1676
|
}
|
|
@@ -1730,10 +1681,10 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1730
1681
|
}
|
|
1731
1682
|
}
|
|
1732
1683
|
&.readOnly {
|
|
1733
|
-
.css-${
|
|
1684
|
+
.css-${IconCSSName} {
|
|
1734
1685
|
${pointerEventsNone};
|
|
1735
1686
|
}
|
|
1736
|
-
.css-${
|
|
1687
|
+
.css-${DropdownInputCSSName} {
|
|
1737
1688
|
.dropdown-item {
|
|
1738
1689
|
${pointerEventsNone};
|
|
1739
1690
|
}
|
|
@@ -1741,6 +1692,32 @@ const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, rend
|
|
|
1741
1692
|
}
|
|
1742
1693
|
`;
|
|
1743
1694
|
|
|
1695
|
+
const DropdownCSS = (top, left, width, isMobile, allowSearch) => css`
|
|
1696
|
+
${positionFixed};
|
|
1697
|
+
${parseWidth(width)};
|
|
1698
|
+
top: ${top}px;
|
|
1699
|
+
left: ${left}px;
|
|
1700
|
+
background-color: ${white};
|
|
1701
|
+
z-index: ${zIndexCORE(1)};
|
|
1702
|
+
${isMobile && allowSearch && `
|
|
1703
|
+
bottom: 0;
|
|
1704
|
+
top: auto;
|
|
1705
|
+
height: max-content;
|
|
1706
|
+
${flexColReverse.styles};
|
|
1707
|
+
`}
|
|
1708
|
+
`;
|
|
1709
|
+
|
|
1710
|
+
const LoadingProgressCSS = css`
|
|
1711
|
+
${flexRow};
|
|
1712
|
+
${justifyCenter};
|
|
1713
|
+
${alignCenter};
|
|
1714
|
+
${positionAbsolute};
|
|
1715
|
+
${borderRadius4px};
|
|
1716
|
+
${parseWidthHeight('100%')}
|
|
1717
|
+
top: 0;
|
|
1718
|
+
background-color: rgba(255, 255, 255, 0.6);
|
|
1719
|
+
z-index: ${zIndexCORE(2)};
|
|
1720
|
+
`;
|
|
1744
1721
|
const DisabledCSS = css`
|
|
1745
1722
|
pointer-events: none !important;
|
|
1746
1723
|
opacity: 0.4 !important;
|
|
@@ -1769,54 +1746,53 @@ Dropdown.defaultProps = {
|
|
|
1769
1746
|
required: false,
|
|
1770
1747
|
multiple: false,
|
|
1771
1748
|
allowSearch: false,
|
|
1772
|
-
closeAfterSelect: true,
|
|
1773
1749
|
inputProps: {},
|
|
1774
1750
|
formStyle: {},
|
|
1775
1751
|
dataSource: [],
|
|
1776
1752
|
onInput: null
|
|
1777
1753
|
};
|
|
1778
1754
|
Dropdown.propTypes = {
|
|
1779
|
-
/**
|
|
1755
|
+
/**The variant to use. */
|
|
1780
1756
|
viewType: PropTypes.oneOf(['underlined', 'outlined']),
|
|
1781
1757
|
|
|
1782
|
-
/**
|
|
1758
|
+
/** The mode of item when rendering. */
|
|
1783
1759
|
itemMode: PropTypes.oneOf(['normal', 'table', 'treeview']),
|
|
1784
1760
|
|
|
1785
|
-
/** Use for Chip component,
|
|
1761
|
+
/** Use for [Chip](https://core.diginet.com.vn/ui/?path=/story/chip) component, default selected item when `multiple`. */
|
|
1786
1762
|
itemMultipleSize: PropTypes.oneOf(['small', 'medium']),
|
|
1787
1763
|
|
|
1788
|
-
/**
|
|
1764
|
+
/** Class for component. */
|
|
1789
1765
|
className: PropTypes.string,
|
|
1790
1766
|
|
|
1791
|
-
/** label
|
|
1767
|
+
/** The label of the input. */
|
|
1792
1768
|
label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
1793
1769
|
|
|
1794
|
-
/**
|
|
1770
|
+
/** The short hint displayed in the input before the user select a value. */
|
|
1795
1771
|
placeholder: PropTypes.string,
|
|
1796
1772
|
|
|
1797
|
-
/**
|
|
1773
|
+
/** Error displayed below input. */
|
|
1798
1774
|
error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
|
|
1799
1775
|
|
|
1800
|
-
/** Used to identify the parent key (only used for itemMode is 'treeview') */
|
|
1776
|
+
/** Used to identify the parent key (only used for `itemMode` is 'treeview'). */
|
|
1801
1777
|
treeViewID: PropTypes.string,
|
|
1802
1778
|
|
|
1803
|
-
/**
|
|
1779
|
+
/** Used for mapping into a nested list (only used for `itemMode` is 'treeview'). */
|
|
1804
1780
|
treeViewParentID: PropTypes.string,
|
|
1805
1781
|
|
|
1806
|
-
/**
|
|
1782
|
+
/** Specifies a text string shown when there is no data. */
|
|
1807
1783
|
noDataText: PropTypes.string,
|
|
1808
1784
|
|
|
1809
|
-
/**
|
|
1785
|
+
/** The icon to display if not found the icon follow `iconExpr`. */
|
|
1810
1786
|
iconDefault: PropTypes.string,
|
|
1811
1787
|
|
|
1812
|
-
/**
|
|
1813
|
-
* Example:<br/>
|
|
1814
|
-
* string: 'icon'<br/>
|
|
1815
|
-
* object: {<br/>
|
|
1816
|
-
* key: 'icon',<br/>
|
|
1817
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1818
|
-
* suffix: '.jpg'<br/>
|
|
1819
|
-
* }
|
|
1788
|
+
/** Field name used for icon display.<br/>
|
|
1789
|
+
* Example:<br/>
|
|
1790
|
+
* string: 'icon'<br/>
|
|
1791
|
+
* object: {<br/>
|
|
1792
|
+
* key: 'icon',<br/>
|
|
1793
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1794
|
+
* suffix: '.jpg'<br/>
|
|
1795
|
+
* }
|
|
1820
1796
|
*/
|
|
1821
1797
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1822
1798
|
key: PropTypes.string,
|
|
@@ -1825,141 +1801,138 @@ Dropdown.propTypes = {
|
|
|
1825
1801
|
style: PropTypes.object
|
|
1826
1802
|
})]),
|
|
1827
1803
|
|
|
1828
|
-
/**
|
|
1804
|
+
/** Default value displayed when first render. */
|
|
1829
1805
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1830
1806
|
|
|
1831
|
-
/**
|
|
1807
|
+
/** The displayed value of component. */
|
|
1832
1808
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1833
1809
|
|
|
1834
|
-
/**
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
/** field name used for text display<br/>
|
|
1838
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1839
|
-
* Note: don't use 'id - name', return undefined
|
|
1810
|
+
/** Field name used for text display in dropdown list.<br/>
|
|
1811
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1812
|
+
* Note: don't use 'id - name', return undefined
|
|
1840
1813
|
*/
|
|
1841
1814
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1842
1815
|
|
|
1843
|
-
/**
|
|
1816
|
+
/** Display sub content. */
|
|
1844
1817
|
subText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
|
1845
1818
|
|
|
1846
|
-
/**
|
|
1819
|
+
/** The field name used for the returned result. */
|
|
1847
1820
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1848
1821
|
|
|
1849
|
-
/**
|
|
1850
|
-
*
|
|
1851
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1852
|
-
* If true
|
|
1822
|
+
/**
|
|
1823
|
+
* Duration wait enter search content on search.<br/>
|
|
1824
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1825
|
+
* If `true`, used default delayOnInput.
|
|
1853
1826
|
*/
|
|
1854
1827
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
|
|
1855
1828
|
|
|
1856
|
-
/**
|
|
1829
|
+
/** Number of items is ignored. */
|
|
1857
1830
|
skip: PropTypes.number,
|
|
1858
1831
|
|
|
1859
|
-
/**
|
|
1832
|
+
/** Number of items that are rendered each time. */
|
|
1860
1833
|
limit: PropTypes.number,
|
|
1861
1834
|
|
|
1862
|
-
/** The total number of
|
|
1835
|
+
/** The total number of items in the dropdown list. */
|
|
1863
1836
|
total: PropTypes.number,
|
|
1864
1837
|
|
|
1865
|
-
/** display
|
|
1838
|
+
/** If `true`, display clear icon.*/
|
|
1866
1839
|
clearAble: PropTypes.bool,
|
|
1867
1840
|
|
|
1868
|
-
/**
|
|
1841
|
+
/** If true, the loading indicator is shown. */
|
|
1869
1842
|
loading: PropTypes.bool,
|
|
1870
1843
|
|
|
1871
|
-
/**
|
|
1844
|
+
/** If true, the component is disabled. */
|
|
1872
1845
|
disabled: PropTypes.bool,
|
|
1873
1846
|
|
|
1874
|
-
/**
|
|
1847
|
+
/** If true, the component is read-only. */
|
|
1875
1848
|
readOnly: PropTypes.bool,
|
|
1876
1849
|
|
|
1877
|
-
/**
|
|
1850
|
+
/** If `true`, dropdown will close after select an item. */
|
|
1878
1851
|
closeAfterSelect: PropTypes.bool,
|
|
1879
1852
|
|
|
1880
|
-
/**
|
|
1853
|
+
/** If `true`, the label will indicate that the input is required. */
|
|
1881
1854
|
required: PropTypes.bool,
|
|
1882
1855
|
|
|
1883
|
-
/**
|
|
1856
|
+
/** If `true`, value must be an array and the dropdown will support multiple selections. */
|
|
1884
1857
|
multiple: PropTypes.bool,
|
|
1885
1858
|
|
|
1886
|
-
/** display input box search
|
|
1859
|
+
/** If `true`, display input box search. */
|
|
1887
1860
|
allowSearch: PropTypes.bool,
|
|
1888
1861
|
|
|
1889
|
-
/** show checkbox in each dropdown item */
|
|
1862
|
+
/** If `true`, show checkbox in each dropdown item. */
|
|
1890
1863
|
selectBox: PropTypes.bool,
|
|
1891
1864
|
|
|
1892
|
-
/**
|
|
1865
|
+
/** An object default for value (use for load more). */
|
|
1893
1866
|
valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
1894
1867
|
|
|
1895
|
-
/**
|
|
1868
|
+
/** Style inline of component. */
|
|
1896
1869
|
style: PropTypes.object,
|
|
1897
1870
|
|
|
1898
|
-
/**
|
|
1871
|
+
/** Attributes applied to the input element. */
|
|
1899
1872
|
inputProps: PropTypes.object,
|
|
1900
1873
|
|
|
1901
|
-
/**
|
|
1874
|
+
/** Style inline of input element. */
|
|
1902
1875
|
inputStyle: PropTypes.object,
|
|
1903
1876
|
|
|
1904
|
-
/**
|
|
1877
|
+
/** Style inline of box contain input and icon. */
|
|
1905
1878
|
formStyle: PropTypes.object,
|
|
1906
1879
|
|
|
1907
|
-
/**
|
|
1880
|
+
/** Style inline of label. */
|
|
1908
1881
|
labelProps: PropTypes.object,
|
|
1909
1882
|
|
|
1910
|
-
/**
|
|
1883
|
+
/** Style inline of error. */
|
|
1911
1884
|
errorStyle: PropTypes.object,
|
|
1912
1885
|
|
|
1913
|
-
/**
|
|
1886
|
+
/** Style inline of dropdown items. */
|
|
1914
1887
|
dropdownItemStyle: PropTypes.object,
|
|
1915
1888
|
|
|
1916
|
-
/** The array of elements that appear in the dropdown */
|
|
1889
|
+
/** The array of elements that appear in the dropdown list. */
|
|
1917
1890
|
dataSource: PropTypes.array,
|
|
1918
1891
|
|
|
1919
|
-
/**
|
|
1920
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1921
|
-
* --> such as: displayExpr={'name - role'}
|
|
1892
|
+
/** Function displays items by custom.<br/>
|
|
1893
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1894
|
+
* --> such as: displayExpr={'name - role'}
|
|
1922
1895
|
*/
|
|
1923
1896
|
renderItem: PropTypes.func,
|
|
1924
1897
|
|
|
1925
|
-
/**
|
|
1926
|
-
*
|
|
1898
|
+
/** Function or field name used for display selected items, example:<br/>
|
|
1899
|
+
* renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1927
1900
|
*/
|
|
1928
|
-
renderSelectedItem: PropTypes.func,
|
|
1901
|
+
renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
|
|
1929
1902
|
|
|
1930
|
-
/**
|
|
1931
|
-
* if undefined: the filter function will run (default)
|
|
1903
|
+
/** Callback fired when the input value changes.<br/>
|
|
1904
|
+
* if undefined: the filter function will run (default)
|
|
1932
1905
|
*/
|
|
1933
1906
|
onInput: PropTypes.func,
|
|
1934
1907
|
|
|
1935
|
-
/**
|
|
1908
|
+
/** Callback fired when key down input */
|
|
1936
1909
|
onKeyDown: PropTypes.func,
|
|
1937
1910
|
|
|
1938
|
-
/**
|
|
1911
|
+
/** Callback fired when the value changes. */
|
|
1939
1912
|
onChange: PropTypes.func,
|
|
1940
1913
|
|
|
1941
|
-
/**
|
|
1914
|
+
/** Callback fired when scroll near the end. */
|
|
1942
1915
|
onLoadMore: PropTypes.func,
|
|
1943
1916
|
|
|
1944
|
-
/**
|
|
1917
|
+
/** Callback fired when dropdown closed. */
|
|
1945
1918
|
onClosed: PropTypes.func,
|
|
1946
1919
|
|
|
1947
|
-
/**
|
|
1920
|
+
/** The contents in Dropdown box (Exp: TreeView). */
|
|
1948
1921
|
children: PropTypes.node,
|
|
1949
1922
|
|
|
1950
|
-
/**
|
|
1951
|
-
* ref methods
|
|
1952
|
-
*
|
|
1953
|
-
* how to get component element? ref.current
|
|
1954
|
-
*
|
|
1955
|
-
* how to call method? ref.current.instance.{method}
|
|
1956
|
-
*
|
|
1957
|
-
* * showDropdown(): Show dropdown
|
|
1958
|
-
* * closeDropdown(): Close dropdown
|
|
1959
|
-
* * onClear(): Clear selected value
|
|
1960
|
-
* * setPreviousValue(): Set value to previous value
|
|
1961
|
-
* * setValue(value): Set value of dropdown
|
|
1962
|
-
* * @param {value} - string || number || array
|
|
1923
|
+
/**
|
|
1924
|
+
* ref methods
|
|
1925
|
+
*
|
|
1926
|
+
* how to get component element? ref.current
|
|
1927
|
+
*
|
|
1928
|
+
* how to call method? ref.current.instance.{method}
|
|
1929
|
+
*
|
|
1930
|
+
* * showDropdown(): Show dropdown
|
|
1931
|
+
* * closeDropdown(): Close dropdown
|
|
1932
|
+
* * onClear(): Clear selected value
|
|
1933
|
+
* * setPreviousValue(): Set value to previous value
|
|
1934
|
+
* * setValue(value): Set value of dropdown
|
|
1935
|
+
* * @param {value} - string || number || array
|
|
1963
1936
|
*/
|
|
1964
1937
|
reference: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
|
|
1965
1938
|
current: PropTypes.instanceOf(Element)
|