diginet-core-ui 1.3.34 → 1.3.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/images/menu/dhr/MHRP09N0032.svg +7 -0
- package/components/avatar/index.js +19 -19
- package/components/badge/index.js +61 -64
- package/components/button/icon.js +21 -21
- package/components/button/index.js +180 -180
- package/components/button/ripple-effect.js +23 -23
- package/components/chart/Pie-v2/index.js +40 -42
- package/components/chip/index.js +129 -134
- package/components/form-control/attachment/index.js +431 -435
- package/components/form-control/calendar/function.js +69 -46
- package/components/form-control/calendar/index.js +12 -3
- package/components/form-control/control/index.js +35 -23
- package/components/form-control/date-picker/index.js +36 -36
- package/components/form-control/date-range-picker/index.js +84 -86
- package/components/form-control/dropdown/index.js +462 -431
- package/components/form-control/dropdown-box/index.js +53 -53
- package/components/form-control/label/index.js +16 -15
- package/components/form-control/money-input/index.js +106 -7
- package/components/form-control/radio/index.js +129 -132
- package/components/form-control/text-input/index.js +25 -28
- package/components/form-control/toggle/index.js +106 -107
- package/components/modal/modal.js +43 -46
- package/components/popover/index.js +27 -29
- package/components/popup/index.js +73 -77
- package/components/popup/proposals_popup.js +46 -48
- package/components/popup/v2/index.js +108 -110
- package/components/progress/circular.js +65 -66
- package/components/tab/tab-container.js +32 -14
- package/components/tab/tab-header.js +81 -56
- package/components/tab/tab-panel.js +46 -17
- package/components/tab/tab.js +105 -87
- package/components/tooltip/index.js +24 -26
- package/components/typography/index.js +10 -10
- package/icons/basic.js +148 -27
- package/icons/effect.js +26 -26
- package/package.json +1 -1
- package/readme.md +17 -0
- package/theme/settings.js +7 -5
- package/utils/number.js +11 -12
|
@@ -7,12 +7,13 @@ import { createPortal } from 'react-dom';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { jsx, css } from '@emotion/core';
|
|
9
9
|
import { Account } from '../../../icons';
|
|
10
|
+
import AvatarDefault from '../../../assets/avatar/default.svg';
|
|
10
11
|
import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon } from '../../';
|
|
11
12
|
import { mapParent, randomString, updatePosition } from '../../../utils';
|
|
12
13
|
import { getGlobal } from '../../../global';
|
|
13
14
|
import { color as colors } from '../../../styles/colors';
|
|
14
15
|
import { typography } from '../../../styles/typography';
|
|
15
|
-
import { alignCenter, backgroundTransparent, borderBox, borderRadius4px, cursorPointer, displayBlock, flexRow, flexWrap, inlineFlex, justifyCenter, justifyStart, outlineNone, overflowHidden, pointerEventsNone, positionAbsolute, positionRelative, userSelectNone } from '../../../styles/general';
|
|
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';
|
|
16
17
|
import isMobile from '../../../utils/isMobile';
|
|
17
18
|
const {
|
|
18
19
|
paragraph1,
|
|
@@ -22,7 +23,8 @@ const {
|
|
|
22
23
|
system: {
|
|
23
24
|
active,
|
|
24
25
|
disabled: systemDisabled,
|
|
25
|
-
rest
|
|
26
|
+
rest,
|
|
27
|
+
white
|
|
26
28
|
},
|
|
27
29
|
semantic: {
|
|
28
30
|
danger
|
|
@@ -60,7 +62,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
60
62
|
defaultValue,
|
|
61
63
|
value: valueProp,
|
|
62
64
|
searchDelayTime,
|
|
63
|
-
skip,
|
|
64
65
|
limit,
|
|
65
66
|
total,
|
|
66
67
|
placeholder,
|
|
@@ -98,333 +99,29 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
98
99
|
errorStyle,
|
|
99
100
|
refs,
|
|
100
101
|
children,
|
|
101
|
-
dropdownItemStyle
|
|
102
|
-
...props
|
|
102
|
+
dropdownItemStyle
|
|
103
103
|
}, ref) => {
|
|
104
104
|
const dropdownRef = useRef(null);
|
|
105
|
+
const timerRef = useRef(null);
|
|
106
|
+
const formRef = useRef(null);
|
|
107
|
+
const inputRef = useRef(null);
|
|
108
|
+
const iconRef = useRef(null);
|
|
109
|
+
const boxRef = useRef(null);
|
|
110
|
+
const searchRef = useRef(null);
|
|
111
|
+
const lastSearchRef = useRef(null);
|
|
112
|
+
const timeout = useRef(null);
|
|
105
113
|
const [unique] = useState(randomString(6, {
|
|
106
114
|
allowNumber: false,
|
|
107
115
|
allowSymbol: false
|
|
108
|
-
}))
|
|
109
|
-
timerRef = useRef(null),
|
|
110
|
-
formRef = useRef(null),
|
|
111
|
-
inputRef = useRef(null),
|
|
112
|
-
iconRef = useRef(null),
|
|
113
|
-
boxRef = useRef(null),
|
|
114
|
-
searchRef = useRef(null),
|
|
115
|
-
timeout = useRef(null);
|
|
116
|
+
}));
|
|
116
117
|
const [openState, setOpenState] = useState(false);
|
|
117
118
|
const [errorState, setErrorState] = useState(error && !valueProp && valueProp !== 0);
|
|
118
119
|
const [showClear, setShowClear] = useState(false);
|
|
119
120
|
|
|
120
121
|
const _isMobile = isMobile.any();
|
|
121
|
-
/* Start styled */
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const forInput = css`
|
|
125
|
-
${flexRow}
|
|
126
|
-
flex: 1 1 auto;
|
|
127
|
-
${!multiple && renderSelectedItem ? `width: calc(100% - 34px${clearAble ? ' - 18px' : ''})` : ''}
|
|
128
|
-
`;
|
|
129
|
-
const DropdownIcon = css`
|
|
130
|
-
${inlineFlex}
|
|
131
|
-
${alignCenter}
|
|
132
|
-
${positionRelative}
|
|
133
|
-
${overflowHidden}
|
|
134
|
-
height: inherit;
|
|
135
|
-
margin-right: 8px;
|
|
136
|
-
height: 32px;
|
|
137
|
-
width: 32px;
|
|
138
|
-
border-radius: 16px;
|
|
139
|
-
img {
|
|
140
|
-
height: 32px;
|
|
141
|
-
width: 32px;
|
|
142
|
-
object-fit: cover;
|
|
143
|
-
}
|
|
144
|
-
`;
|
|
145
|
-
const DropdownInput = css`
|
|
146
|
-
${flexRow}
|
|
147
|
-
${alignCenter}
|
|
148
|
-
${outlineNone}
|
|
149
|
-
${backgroundTransparent}
|
|
150
|
-
${paragraph1};
|
|
151
|
-
width: 100%;
|
|
152
|
-
border: none;
|
|
153
|
-
color: ${main};
|
|
154
|
-
padding-top: 0;
|
|
155
|
-
padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
|
|
156
|
-
padding-left: ${viewType !== 'outlined' ? 0 : '16px'};
|
|
157
|
-
min-height: ${multiple ? 30 : 24}px;
|
|
158
|
-
&.dgn-dropdown-multiple {
|
|
159
|
-
${flexWrap}
|
|
160
|
-
${overflowHidden}
|
|
161
|
-
/* max-height: max-content; */
|
|
162
|
-
word-break: break-word;
|
|
163
|
-
${!multiple ? 'min-height: 24px; max-width: 100%; white-space: nowrap;' : ''}
|
|
164
|
-
&::after {
|
|
165
|
-
${flexRow}
|
|
166
|
-
${positionAbsolute}
|
|
167
|
-
${alignCenter}
|
|
168
|
-
${justifyCenter}
|
|
169
|
-
content: '${placeholder}';
|
|
170
|
-
color: ${sub};
|
|
171
|
-
}
|
|
172
|
-
&:not(:empty)::after {
|
|
173
|
-
visibility: hidden;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
&:focus {
|
|
177
|
-
${backgroundTransparent}
|
|
178
|
-
}
|
|
179
|
-
.dropdown-item {
|
|
180
|
-
&:not(:last-child) {
|
|
181
|
-
margin-right: 5px;
|
|
182
|
-
}
|
|
183
|
-
svg {
|
|
184
|
-
${borderBox}
|
|
185
|
-
padding: ${itemMultipleSize === 'medium' ? 2 : 1}px;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
.css-${DropdownIcon.name} {
|
|
189
|
-
${renderSelectedItem ? `
|
|
190
|
-
min-height: 24px;
|
|
191
|
-
min-width: 24px;
|
|
192
|
-
` : `
|
|
193
|
-
height: 24px;
|
|
194
|
-
width: 24px;
|
|
195
|
-
img {
|
|
196
|
-
height: 24px;
|
|
197
|
-
width: 24px;
|
|
198
|
-
}
|
|
199
|
-
`}
|
|
200
|
-
}
|
|
201
|
-
`;
|
|
202
|
-
const forIcon = css`
|
|
203
|
-
${flexRow}
|
|
204
|
-
${alignCenter}
|
|
205
|
-
margin-left: 8px;
|
|
206
|
-
margin-right: ${viewType !== 'outlined' ? 2 : 16}px;
|
|
207
|
-
color: inherit;
|
|
208
|
-
.icon-close {
|
|
209
|
-
display: ${showClear ? 'flex' : 'none'};
|
|
210
|
-
margin-right: 4px;
|
|
211
|
-
}
|
|
212
|
-
.dgn-dropdown-loading {
|
|
213
|
-
display: ${loading ? 'flex' : 'none'};
|
|
214
|
-
}
|
|
215
|
-
`;
|
|
216
|
-
const DropdownForm = viewType !== 'outlined' ? css`
|
|
217
|
-
${flexRow}
|
|
218
|
-
${alignCenter}
|
|
219
|
-
${positionRelative}
|
|
220
|
-
${borderBox}
|
|
221
|
-
flex: 1 1 auto;
|
|
222
|
-
padding-bottom: ${multiple ? 1 : 4}px;
|
|
223
|
-
padding-top: ${multiple ? 1 : 4}px;
|
|
224
|
-
&:not(:focus-within):hover {
|
|
225
|
-
&::before {
|
|
226
|
-
border-bottom-color: ${active};
|
|
227
|
-
}
|
|
228
|
-
.css-${DropdownInput.name} {
|
|
229
|
-
color: ${active};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
&:focus-within {
|
|
233
|
-
border-bottom-color: ${focus};
|
|
234
|
-
&::after {
|
|
235
|
-
border-bottom-color: inherit;
|
|
236
|
-
transform: scaleX(1);
|
|
237
|
-
}
|
|
238
|
-
.css-${DropdownInput.name} {
|
|
239
|
-
color: ${active};
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
&.dropdown-showing {
|
|
243
|
-
.icon-dropdown {
|
|
244
|
-
transform: rotateX(180deg);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
&::placeholder {
|
|
248
|
-
color: ${sub};
|
|
249
|
-
}
|
|
250
|
-
&::before {
|
|
251
|
-
${positionAbsolute}
|
|
252
|
-
content: '';
|
|
253
|
-
left: 0;
|
|
254
|
-
right: 0;
|
|
255
|
-
bottom: 0;
|
|
256
|
-
border-bottom: 1px solid ${rest};
|
|
257
|
-
}
|
|
258
|
-
&::after {
|
|
259
|
-
${positionAbsolute}
|
|
260
|
-
content: '';
|
|
261
|
-
left: 0px;
|
|
262
|
-
right: 0px;
|
|
263
|
-
bottom: -1px;
|
|
264
|
-
border-bottom: 2px solid transparent;
|
|
265
|
-
transform: scaleX(0);
|
|
266
|
-
transform-origin: center;
|
|
267
|
-
transition: all 0.2s ease;
|
|
268
|
-
}
|
|
269
|
-
` : css`
|
|
270
|
-
${flexRow}
|
|
271
|
-
${alignCenter}
|
|
272
|
-
${positionRelative}
|
|
273
|
-
${borderRadius4px}
|
|
274
|
-
${borderBox}
|
|
275
|
-
flex: 1 1 auto;
|
|
276
|
-
border: 1px solid ${rest};
|
|
277
|
-
min-height: 40px;
|
|
278
|
-
&:not(:focus-within):hover {
|
|
279
|
-
background-color: ${hover};
|
|
280
|
-
border-color: ${active};
|
|
281
|
-
input {
|
|
282
|
-
background-color: ${hover};
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
&:focus-within {
|
|
286
|
-
border-color: ${focus};
|
|
287
|
-
}
|
|
288
|
-
&.dropdown-showing {
|
|
289
|
-
.icon-dropdown {
|
|
290
|
-
transform: rotateX(180deg);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
&::placeholder {
|
|
294
|
-
color: ${sub};
|
|
295
|
-
}
|
|
296
|
-
&::after {
|
|
297
|
-
${positionAbsolute}
|
|
298
|
-
${pointerEventsNone}
|
|
299
|
-
content: '';
|
|
300
|
-
left: -2px;
|
|
301
|
-
right: -2px;
|
|
302
|
-
top: -2px;
|
|
303
|
-
bottom: -2px;
|
|
304
|
-
border: 2px solid transparent;
|
|
305
|
-
border-radius: 4px;
|
|
306
|
-
}
|
|
307
|
-
`;
|
|
308
|
-
const DropdownBox = css`
|
|
309
|
-
${displayBlock}
|
|
310
|
-
${positionRelative}
|
|
311
|
-
${borderBox}
|
|
312
|
-
width: 100%;
|
|
313
|
-
max-height: 280px;
|
|
314
|
-
overflow: auto;
|
|
315
|
-
background-color: #fff;
|
|
316
|
-
border-radius: 4px;
|
|
317
|
-
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
318
|
-
z-index: 9001;
|
|
319
|
-
&::-webkit-scrollbar {
|
|
320
|
-
width: 24px;
|
|
321
|
-
background-color: #fff !important;
|
|
322
|
-
border-radius: 4px;
|
|
323
|
-
}
|
|
324
|
-
&::-webkit-scrollbar-thumb {
|
|
325
|
-
border-radius: 24px;
|
|
326
|
-
border: 8px solid transparent;
|
|
327
|
-
mix-blend-mode: normal;
|
|
328
|
-
background-color: ${scrollbar} !important;
|
|
329
|
-
background-clip: content-box;
|
|
330
|
-
}
|
|
331
|
-
.DGN-UI-TreeView {
|
|
332
|
-
padding: 1px;
|
|
333
|
-
}
|
|
334
|
-
`;
|
|
335
|
-
const DropdownItem = css`
|
|
336
|
-
${flexRow}
|
|
337
|
-
${positionRelative}
|
|
338
|
-
${alignCenter}
|
|
339
|
-
${justifyStart}
|
|
340
|
-
${borderBox}
|
|
341
|
-
${cursorPointer}
|
|
342
|
-
${userSelectNone}
|
|
343
|
-
min-height: 40px;
|
|
344
|
-
width: 100%;
|
|
345
|
-
background-color: #fff;
|
|
346
|
-
padding: 8px ${multiple && selectBox ? 0 : '16px'};
|
|
347
|
-
color: ${main};
|
|
348
|
-
&.no-data {
|
|
349
|
-
font-style: italic;
|
|
350
|
-
justify-content: center;
|
|
351
|
-
cursor: initial;
|
|
352
|
-
}
|
|
353
|
-
&:not(.no-data):hover,
|
|
354
|
-
&:not(.no-data):focus {
|
|
355
|
-
background-color: ${hover};
|
|
356
|
-
color: ${active};
|
|
357
|
-
outline: none;
|
|
358
|
-
}
|
|
359
|
-
`;
|
|
360
|
-
const DropdownText = css`
|
|
361
|
-
${paragraph1};
|
|
362
|
-
color: inherit;
|
|
363
|
-
.DGN-UI-Dropdown-PrimaryText {
|
|
364
|
-
${paragraph1};
|
|
365
|
-
${displayBlock}
|
|
366
|
-
}
|
|
367
|
-
.DGN-UI-Dropdown-SubText {
|
|
368
|
-
${paragraph3};
|
|
369
|
-
${displayBlock}
|
|
370
|
-
color: ${sub};
|
|
371
|
-
}
|
|
372
|
-
`;
|
|
373
|
-
const DropdownRoot = css`
|
|
374
|
-
${displayBlock}
|
|
375
|
-
${positionRelative}
|
|
376
|
-
margin-bottom: 20px;
|
|
377
|
-
min-width: 150px;
|
|
378
|
-
height: max-content;
|
|
379
|
-
&.error {
|
|
380
|
-
.css-${DropdownForm.name} {
|
|
381
|
-
border-color: ${danger};
|
|
382
|
-
path {
|
|
383
|
-
fill: ${danger};
|
|
384
|
-
}
|
|
385
|
-
&::before {
|
|
386
|
-
border-color: ${danger};
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
&.dgn-dropdown-loading,
|
|
391
|
-
&.disabled {
|
|
392
|
-
${pointerEventsNone}
|
|
393
|
-
${userSelectNone}
|
|
394
|
-
.css-${DropdownInput.name} {
|
|
395
|
-
//color: ${systemDisabled} !important;
|
|
396
|
-
}
|
|
397
|
-
.css-${DropdownForm.name} {
|
|
398
|
-
border-color: ${systemDisabled};
|
|
399
|
-
.css-${forIcon.name} {
|
|
400
|
-
path {
|
|
401
|
-
fill: transparent;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
&::before {
|
|
405
|
-
border-color: ${systemDisabled};
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
&.readOnly {
|
|
410
|
-
.css-${forIcon.name} {
|
|
411
|
-
${pointerEventsNone}
|
|
412
|
-
}
|
|
413
|
-
.css-${DropdownInput.name} {
|
|
414
|
-
.dropdown-item {
|
|
415
|
-
${pointerEventsNone}
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
`;
|
|
420
|
-
const Disabled = css`
|
|
421
|
-
pointer-events: none !important;
|
|
422
|
-
opacity: 0.4 !important;
|
|
423
|
-
`;
|
|
424
|
-
/* End styled */
|
|
425
|
-
|
|
426
122
|
/* Start handler */
|
|
427
123
|
|
|
124
|
+
|
|
428
125
|
const triggerInput = e => {
|
|
429
126
|
const target = e.currentTarget;
|
|
430
127
|
target.style.pointerEvents = 'none';
|
|
@@ -495,15 +192,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
495
192
|
};
|
|
496
193
|
|
|
497
194
|
const showDropdown = () => {
|
|
498
|
-
var _searchRef$current;
|
|
195
|
+
var _displayExpr, _searchRef$current;
|
|
499
196
|
|
|
500
197
|
if (displayExpr && Array.isArray(displayExpr)) {
|
|
501
198
|
displayExpr = displayExpr.join(' - ');
|
|
502
199
|
}
|
|
503
200
|
|
|
504
|
-
const keyArr = displayExpr.match(separatorPattern);
|
|
201
|
+
const keyArr = (_displayExpr = displayExpr) === null || _displayExpr === void 0 ? void 0 : _displayExpr.match(separatorPattern);
|
|
505
202
|
const dropdown = children ? jsx("div", {
|
|
506
|
-
css:
|
|
203
|
+
css: DropdownBoxCSS,
|
|
507
204
|
ref: boxRef
|
|
508
205
|
}, children) : itemMode === 'normal' ? mapDropdown(null, keyArr) : mapTreeView();
|
|
509
206
|
const {
|
|
@@ -554,7 +251,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
554
251
|
borderRadius: 4,
|
|
555
252
|
zIndex: 9002
|
|
556
253
|
};
|
|
557
|
-
const defaultSearch = onInput ? (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value : '';
|
|
254
|
+
const defaultSearch = lastSearchRef.current || (onInput ? (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value : '');
|
|
558
255
|
const el = jsx("div", {
|
|
559
256
|
className: `DGN-UI-Portal DGN-Dropdown-${unique}`,
|
|
560
257
|
style: dropdownStyle
|
|
@@ -593,7 +290,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
593
290
|
boxRef.current && boxRef.current.addEventListener('keydown', moveOnItem);
|
|
594
291
|
|
|
595
292
|
if (onLoadMore && dataSource.length < total) {
|
|
596
|
-
boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
293
|
+
boxRef.current && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
597
294
|
}
|
|
598
295
|
}, 10);
|
|
599
296
|
return el;
|
|
@@ -683,7 +380,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
683
380
|
};
|
|
684
381
|
|
|
685
382
|
const renderDropdown = pattern => {
|
|
686
|
-
|
|
383
|
+
var _displayExpr2;
|
|
384
|
+
|
|
385
|
+
const keyArr = (_displayExpr2 = displayExpr) === null || _displayExpr2 === void 0 ? void 0 : _displayExpr2.match(separatorPattern);
|
|
687
386
|
const dropdown = mapDropdown(pattern, keyArr);
|
|
688
387
|
const el = document.createElement('div');
|
|
689
388
|
el.className = `DGN-Dropdown-Box`;
|
|
@@ -693,10 +392,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
693
392
|
node.querySelector('.DGN-Dropdown-Box').remove();
|
|
694
393
|
ReactDOM.render(dropdown, node.appendChild(el));
|
|
695
394
|
setTimeout(() => {
|
|
696
|
-
boxRef.current.addEventListener('keydown', moveOnItem);
|
|
395
|
+
boxRef.current && boxRef.current.addEventListener('keydown', moveOnItem);
|
|
697
396
|
|
|
698
397
|
if (onLoadMore && dataSource.length < total) {
|
|
699
|
-
boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
398
|
+
boxRef.current && boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
700
399
|
}
|
|
701
400
|
|
|
702
401
|
updatePositionDropdown();
|
|
@@ -708,6 +407,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
708
407
|
const items = [];
|
|
709
408
|
const dataSourceUsable = [...dataSource];
|
|
710
409
|
|
|
410
|
+
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
411
|
+
|
|
711
412
|
if (currentObjectDefault[unique] && currentObjectDefault[unique].length) {
|
|
712
413
|
const length = currentObjectDefault[unique].length;
|
|
713
414
|
let existItemQuantity = 0;
|
|
@@ -730,7 +431,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
730
431
|
|
|
731
432
|
for (let index = 0; index < length; index++) {
|
|
732
433
|
const data = dataSourceUsable[index];
|
|
733
|
-
let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] : data;
|
|
434
|
+
let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] || data[valueExpr] : data;
|
|
734
435
|
if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
|
|
735
436
|
|
|
736
437
|
if (renderItem && typeof renderItem === 'function') {
|
|
@@ -750,16 +451,20 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
750
451
|
}
|
|
751
452
|
|
|
752
453
|
const value = typeof data === 'object' ? data[valueExpr] : data;
|
|
753
|
-
const itemDisabled = typeof data === 'object' ? data['disabled'] :
|
|
454
|
+
const itemDisabled = typeof data === 'object' ? data['disabled'] : false;
|
|
754
455
|
const icon = getIconFromData(data);
|
|
755
456
|
|
|
756
457
|
if (multiple && selectBox) {
|
|
757
458
|
const checked = currentValue[unique].includes(value);
|
|
758
459
|
items.push(jsx("div", {
|
|
759
460
|
key: index,
|
|
760
|
-
css: !itemDisabled ?
|
|
761
|
-
onClick: e =>
|
|
461
|
+
css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
|
|
462
|
+
onClick: e => {
|
|
463
|
+
if (itemDisabled) return;
|
|
464
|
+
onChangeValueWithCheckbox(e) & onChangeValue(displayText, value, icon, data, index);
|
|
465
|
+
},
|
|
762
466
|
onKeyPress: e => {
|
|
467
|
+
if (itemDisabled) return;
|
|
763
468
|
if (e.key === 'Enter') e.currentTarget.firstChild.click();
|
|
764
469
|
},
|
|
765
470
|
tabIndex: -1
|
|
@@ -770,27 +475,32 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
770
475
|
height: '100%',
|
|
771
476
|
padding: '0 16px'
|
|
772
477
|
},
|
|
773
|
-
value: value
|
|
478
|
+
value: value,
|
|
479
|
+
disabled: itemDisabled
|
|
774
480
|
}, icon && jsx("div", {
|
|
775
|
-
css:
|
|
481
|
+
css: DropdownIconCSS
|
|
776
482
|
}, icon), jsx("div", {
|
|
777
|
-
css:
|
|
483
|
+
css: DropdownTextCSS
|
|
778
484
|
}, displayText))));
|
|
779
485
|
} else {
|
|
780
486
|
items.push(jsx("div", {
|
|
781
487
|
key: index,
|
|
782
|
-
css: !itemDisabled ?
|
|
488
|
+
css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
|
|
783
489
|
className: 'DGN-UI-Dropdown-Item',
|
|
784
|
-
onClick: () =>
|
|
490
|
+
onClick: () => {
|
|
491
|
+
if (itemDisabled) return;
|
|
492
|
+
onChangeValue(displayText, value, icon, data, index);
|
|
493
|
+
},
|
|
785
494
|
onKeyPress: e => {
|
|
495
|
+
if (itemDisabled) return;
|
|
786
496
|
if (e.key === 'Enter') onChangeValue(displayText, value, icon, data, index);
|
|
787
497
|
},
|
|
788
498
|
tabIndex: -1,
|
|
789
499
|
style: dropdownItemStyle
|
|
790
500
|
}, icon && jsx("div", {
|
|
791
|
-
css:
|
|
501
|
+
css: DropdownIconCSS
|
|
792
502
|
}, icon), jsx("div", {
|
|
793
|
-
css:
|
|
503
|
+
css: DropdownTextCSS
|
|
794
504
|
}, displayText)));
|
|
795
505
|
}
|
|
796
506
|
|
|
@@ -803,10 +513,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
803
513
|
}
|
|
804
514
|
|
|
805
515
|
return jsx("div", {
|
|
806
|
-
css:
|
|
516
|
+
css: DropdownBoxCSS,
|
|
807
517
|
ref: boxRef
|
|
808
518
|
}, items.length ? items : jsx("div", {
|
|
809
|
-
css:
|
|
519
|
+
css: _DropdownItemCSS,
|
|
810
520
|
className: 'no-data'
|
|
811
521
|
}, ' ', noDataText, ' '));
|
|
812
522
|
};
|
|
@@ -814,7 +524,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
814
524
|
const mapTreeView = () => {
|
|
815
525
|
// if (!treeView[unique]) {
|
|
816
526
|
return jsx("div", {
|
|
817
|
-
css:
|
|
527
|
+
css: DropdownBoxCSS,
|
|
818
528
|
ref: boxRef
|
|
819
529
|
}, jsx(TreeView, {
|
|
820
530
|
dataSource: dataSource,
|
|
@@ -838,6 +548,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
838
548
|
};
|
|
839
549
|
|
|
840
550
|
const loadMoreItemsDropdown = (i = 0, pattern) => {
|
|
551
|
+
var _displayExpr3;
|
|
552
|
+
|
|
841
553
|
const dataSourceUsable = [...dataSource]; // Nếu có load more thì đẩy đội tượng mặc định lên đầu
|
|
842
554
|
|
|
843
555
|
let notExistItem = 0;
|
|
@@ -860,14 +572,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
860
572
|
displayExpr = displayExpr.join(' - ');
|
|
861
573
|
}
|
|
862
574
|
|
|
863
|
-
const keyArr = displayExpr.match(separatorPattern);
|
|
575
|
+
const keyArr = (_displayExpr3 = displayExpr) === null || _displayExpr3 === void 0 ? void 0 : _displayExpr3.match(separatorPattern);
|
|
576
|
+
|
|
577
|
+
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
864
578
|
|
|
865
579
|
for (i; i < length; i++) {
|
|
866
580
|
const data = { ...dataSourceUsable[i]
|
|
867
581
|
}; // Nếu đối tượng đã được hiển thị ở trên rồi thì không hiển thị ra nữa
|
|
868
582
|
|
|
869
583
|
if (onLoadMore && i > notExistItem && currentObjectDefault[unique].some(valueObject => valueObject[valueExpr] === data[valueExpr])) continue;
|
|
870
|
-
let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] : data;
|
|
584
|
+
let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] || data[valueExpr] : data;
|
|
871
585
|
if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
|
|
872
586
|
const value = typeof data === 'object' ? data[valueExpr] : data;
|
|
873
587
|
const icon = getIconFromData(data);
|
|
@@ -889,7 +603,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
889
603
|
}
|
|
890
604
|
|
|
891
605
|
const dropdownItem = document.createElement('div');
|
|
892
|
-
dropdownItem.className = `css-${
|
|
606
|
+
dropdownItem.className = `css-${_DropdownItemCSS.name}`;
|
|
893
607
|
dropdownItem.tabIndex = -1;
|
|
894
608
|
dropdownItem.addEventListener('click', () => onChangeValue(displayText, value, icon, data, i));
|
|
895
609
|
dropdownItem.addEventListener('keypress', e => {
|
|
@@ -907,15 +621,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
907
621
|
padding: '0 16px'
|
|
908
622
|
}
|
|
909
623
|
}, icon && jsx("div", {
|
|
910
|
-
css:
|
|
624
|
+
css: DropdownIconCSS
|
|
911
625
|
}, icon), jsx("div", {
|
|
912
|
-
css:
|
|
626
|
+
css: DropdownTextCSS
|
|
913
627
|
}, displayText));
|
|
914
628
|
} else {
|
|
915
629
|
item = jsx(Fragment, null, icon && jsx("div", {
|
|
916
|
-
css:
|
|
630
|
+
css: DropdownIconCSS
|
|
917
631
|
}, icon), jsx("div", {
|
|
918
|
-
css:
|
|
632
|
+
css: DropdownTextCSS
|
|
919
633
|
}, displayText));
|
|
920
634
|
}
|
|
921
635
|
|
|
@@ -935,7 +649,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
935
649
|
};
|
|
936
650
|
|
|
937
651
|
const renderData = (data, keyArr) => {
|
|
938
|
-
const pattern = keyArr.join('|').replace(/([
|
|
652
|
+
const pattern = keyArr.join('|').replace(/([{}])/g, '\\$1');
|
|
939
653
|
const separatorArr = displayExpr.split(new RegExp(pattern));
|
|
940
654
|
let str = '';
|
|
941
655
|
let i = 0;
|
|
@@ -988,15 +702,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
988
702
|
};
|
|
989
703
|
|
|
990
704
|
const onErrorRenderIcon = e => {
|
|
991
|
-
|
|
992
|
-
e.target.src = iconDefault;
|
|
993
|
-
} else {
|
|
994
|
-
const parent = e.target.parentNode;
|
|
995
|
-
e.target.remove();
|
|
996
|
-
parent.innerHTML = `<svg width="32" height="32" viewBox="0 0 20 20" fill="none">
|
|
997
|
-
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 0C4.47998 0 0 4.48 0 10C0 15.52 4.47998 20 10 20C15.52 20 20 15.52 20 10C20 4.48 15.52 0 10 0ZM10 3C11.66 3 13 4.34 13 6C13 7.66 11.66 9 10 9C8.34003 9 7 7.66 7 6C7 4.34 8.34003 3 10 3ZM4 13.98C5.28998 15.92 7.5 17.2 10 17.2C12.5 17.2 14.71 15.92 16 13.98C15.97 11.99 11.99 10.9 10 10.9C8 10.9 4.03003 11.99 4 13.98Z" fill="#7F828E"/>
|
|
998
|
-
</svg>`;
|
|
999
|
-
}
|
|
705
|
+
e.target.src = iconDefault ? iconDefault : AvatarDefault;
|
|
1000
706
|
};
|
|
1001
707
|
|
|
1002
708
|
const customizeWidthDropdown = () => {
|
|
@@ -1036,8 +742,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1036
742
|
offsetHeight
|
|
1037
743
|
} = e.target;
|
|
1038
744
|
|
|
745
|
+
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
746
|
+
|
|
1039
747
|
if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && boxRef.current) {
|
|
1040
|
-
const length = boxRef.current.querySelectorAll(`.css-${
|
|
748
|
+
const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
|
|
1041
749
|
boxRef.current.removeEventListener('scroll', onLoadMoreHandler);
|
|
1042
750
|
!!onLoadMore && onLoadMore({
|
|
1043
751
|
skip: length,
|
|
@@ -1052,6 +760,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1052
760
|
};
|
|
1053
761
|
|
|
1054
762
|
const onChangeInput = e => {
|
|
763
|
+
if (searchRef.current) lastSearchRef.current = searchRef.current.value;
|
|
764
|
+
|
|
1055
765
|
if (onInput) {
|
|
1056
766
|
isSearch[unique] = true;
|
|
1057
767
|
const valueInput = e.target.value;
|
|
@@ -1151,8 +861,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1151
861
|
newValueArr.splice(index, 1);
|
|
1152
862
|
|
|
1153
863
|
if (valueProp === undefined) {
|
|
864
|
+
var _nodes$index;
|
|
865
|
+
|
|
1154
866
|
const nodes = inputRef.current.querySelectorAll('.dropdown-item');
|
|
1155
|
-
nodes[index].remove();
|
|
867
|
+
(_nodes$index = nodes[index]) === null || _nodes$index === void 0 ? void 0 : _nodes$index.remove();
|
|
1156
868
|
}
|
|
1157
869
|
|
|
1158
870
|
!!onChange && onChange({
|
|
@@ -1165,7 +877,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1165
877
|
updatePositionDropdown();
|
|
1166
878
|
}, 0);
|
|
1167
879
|
} else {
|
|
1168
|
-
const isChanged = currentValue[unique] !== value
|
|
880
|
+
const isChanged = currentValue[unique] !== value;
|
|
1169
881
|
|
|
1170
882
|
if (isChanged) {
|
|
1171
883
|
if (valueProp === undefined) {
|
|
@@ -1269,7 +981,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1269
981
|
displayExpr = displayExpr.join(' - ');
|
|
1270
982
|
}
|
|
1271
983
|
|
|
1272
|
-
const keyArr = displayKey.match(separatorPattern);
|
|
984
|
+
const keyArr = displayKey === null || displayKey === void 0 ? void 0 : displayKey.match(separatorPattern);
|
|
1273
985
|
|
|
1274
986
|
if (multiple) {
|
|
1275
987
|
let valueArr = source;
|
|
@@ -1353,6 +1065,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1353
1065
|
};
|
|
1354
1066
|
|
|
1355
1067
|
const setSingleValueHandler = (data, keyArr) => {
|
|
1068
|
+
const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr] || data[valueExpr] || data;
|
|
1069
|
+
|
|
1356
1070
|
if (renderSelectedItem && typeof renderSelectedItem === 'function') {
|
|
1357
1071
|
inputRef.current.innerHTML = '';
|
|
1358
1072
|
const item = renderSelectedItem({
|
|
@@ -1365,17 +1079,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1365
1079
|
} else if (iconExpr && iconExpr !== 'none') {
|
|
1366
1080
|
inputRef.current.innerHTML = '';
|
|
1367
1081
|
const icon = getIconFromData(data);
|
|
1368
|
-
const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr] || data;
|
|
1369
1082
|
const valueWithIcon = jsx(Fragment, null, icon && jsx("div", {
|
|
1370
|
-
css:
|
|
1083
|
+
css: DropdownIconCSS
|
|
1371
1084
|
}, icon), jsx("div", {
|
|
1372
|
-
css:
|
|
1085
|
+
css: DropdownTextCSS
|
|
1373
1086
|
}, text));
|
|
1374
1087
|
const el = document.createElement('div');
|
|
1375
1088
|
el.style.cssText = 'display: flex; align-items: center; min-height:24px;';
|
|
1376
1089
|
ReactDOM.render(valueWithIcon, inputRef.current.appendChild(el));
|
|
1377
1090
|
} else {
|
|
1378
|
-
const text = keyArr ? renderData(data, keyArr) : data[keyExpr || displayExpr] || data;
|
|
1379
1091
|
inputRef.current.value = text;
|
|
1380
1092
|
}
|
|
1381
1093
|
};
|
|
@@ -1545,7 +1257,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1545
1257
|
inputRef.current.addEventListener('input', onChangeInput);
|
|
1546
1258
|
}
|
|
1547
1259
|
|
|
1548
|
-
const
|
|
1260
|
+
const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox);
|
|
1261
|
+
|
|
1262
|
+
const length = boxRef.current.querySelectorAll(`.css-${_DropdownItemCSS.name}`).length;
|
|
1549
1263
|
|
|
1550
1264
|
if (length < dataSource.length + currentObjectDefault[unique].length && !isSearch[unique]) {
|
|
1551
1265
|
loadMoreItemsDropdown(length);
|
|
@@ -1577,70 +1291,78 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1577
1291
|
required: required,
|
|
1578
1292
|
disabled: disabled,
|
|
1579
1293
|
...labelProps
|
|
1580
|
-
}, label) : null, [label, required, disabled]);
|
|
1581
|
-
const inputComp = useMemo(() =>
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
css: DropdownInput,
|
|
1606
|
-
className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
|
|
1607
|
-
type: "text",
|
|
1608
|
-
onKeyDown: e => {
|
|
1609
|
-
if (e.key === 'Enter') {
|
|
1294
|
+
}, label) : null, [label, required, disabled, labelProps]);
|
|
1295
|
+
const inputComp = useMemo(() => {
|
|
1296
|
+
const _InputCSS = InputCSS(multiple, renderSelectedItem, clearAble);
|
|
1297
|
+
|
|
1298
|
+
const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
|
|
1299
|
+
|
|
1300
|
+
const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem);
|
|
1301
|
+
|
|
1302
|
+
return jsx("div", {
|
|
1303
|
+
css: _DropdownFormCSS,
|
|
1304
|
+
ref: formRef,
|
|
1305
|
+
className: ['DGN-UI-Dropdown-Form', openState && 'dropdown-showing'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1306
|
+
style: formStyle
|
|
1307
|
+
}, jsx("div", {
|
|
1308
|
+
css: _InputCSS
|
|
1309
|
+
}, multiple ? jsx("div", { ...inputProps,
|
|
1310
|
+
style: {
|
|
1311
|
+
cursor: 'text',
|
|
1312
|
+
...inputStyle
|
|
1313
|
+
},
|
|
1314
|
+
ref: inputRef,
|
|
1315
|
+
css: _DropdownInputCSS,
|
|
1316
|
+
className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
|
|
1317
|
+
type: "text",
|
|
1318
|
+
onChange: e => {
|
|
1610
1319
|
e.preventDefault();
|
|
1611
1320
|
return false;
|
|
1612
1321
|
}
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
},
|
|
1642
|
-
|
|
1643
|
-
|
|
1322
|
+
}) : renderSelectedItem || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
|
|
1323
|
+
contentEditable: true,
|
|
1324
|
+
style: inputStyle,
|
|
1325
|
+
ref: inputRef,
|
|
1326
|
+
css: _DropdownInputCSS,
|
|
1327
|
+
className: 'dgn-dropdown-multiple ' + (inputProps.className || ''),
|
|
1328
|
+
type: "text",
|
|
1329
|
+
onKeyDown: e => {
|
|
1330
|
+
if (e.key === 'Enter') {
|
|
1331
|
+
e.preventDefault();
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}) : jsx("input", { ...inputProps,
|
|
1336
|
+
style: inputStyle,
|
|
1337
|
+
ref: inputRef,
|
|
1338
|
+
css: _DropdownInputCSS,
|
|
1339
|
+
type: "text",
|
|
1340
|
+
placeholder: placeholder
|
|
1341
|
+
})), jsx("div", {
|
|
1342
|
+
ref: iconRef,
|
|
1343
|
+
css: IconCSS(viewType, loading, showClear),
|
|
1344
|
+
className: 'DGN-UI-Dropdown-Icon'
|
|
1345
|
+
}, jsx("span", {
|
|
1346
|
+
className: 'dgn-dropdown-loading'
|
|
1347
|
+
}, jsx(CircularProgress, {
|
|
1348
|
+
width: 24,
|
|
1349
|
+
strokeWidth: 2
|
|
1350
|
+
})), jsx(ButtonIcon, {
|
|
1351
|
+
viewType: 'ghost',
|
|
1352
|
+
name: 'Close',
|
|
1353
|
+
className: 'icon-close',
|
|
1354
|
+
onClick: onClear
|
|
1355
|
+
}), !loading && jsx(ButtonIcon, {
|
|
1356
|
+
viewType: 'ghost',
|
|
1357
|
+
name: 'ArrowDown',
|
|
1358
|
+
className: 'icon-dropdown',
|
|
1359
|
+
onClick: triggerInput,
|
|
1360
|
+
style: {
|
|
1361
|
+
transition: 'transform 0.5s'
|
|
1362
|
+
},
|
|
1363
|
+
disabled: disabled || readOnly
|
|
1364
|
+
})));
|
|
1365
|
+
}, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear]);
|
|
1644
1366
|
const errorComp = useMemo(() => errorState && jsx(HelperText, {
|
|
1645
1367
|
disabled: disabled,
|
|
1646
1368
|
style: {
|
|
@@ -1649,17 +1371,326 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1649
1371
|
top: '100%',
|
|
1650
1372
|
...errorStyle
|
|
1651
1373
|
}
|
|
1652
|
-
}, error), [error, valueProp, disabled, errorState]);
|
|
1374
|
+
}, error), [error, valueProp, disabled, errorStyle, errorState]);
|
|
1653
1375
|
/* End component */
|
|
1654
1376
|
|
|
1655
1377
|
return jsx(Fragment, null, jsx("div", {
|
|
1656
1378
|
ref: dropdownRef,
|
|
1657
|
-
css:
|
|
1379
|
+
css: DropdownRootCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear),
|
|
1658
1380
|
className: ['DGN-UI-Dropdown', className, errorState && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1659
|
-
style: style
|
|
1660
|
-
...props
|
|
1381
|
+
style: style
|
|
1661
1382
|
}, labelComp, inputComp, errorComp), openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null);
|
|
1662
1383
|
}));
|
|
1384
|
+
/* Start styled */
|
|
1385
|
+
|
|
1386
|
+
const InputCSS = (multiple, renderSelectedItem, clearAble) => css`
|
|
1387
|
+
${flexRow};
|
|
1388
|
+
flex: 1 1 auto;
|
|
1389
|
+
${!multiple && renderSelectedItem ? `width: calc(100% - 34px${clearAble ? ' - 18px' : ''})` : ''}
|
|
1390
|
+
`;
|
|
1391
|
+
|
|
1392
|
+
const DropdownIconCSS = css`
|
|
1393
|
+
${inlineFlex};
|
|
1394
|
+
${alignCenter};
|
|
1395
|
+
${positionRelative};
|
|
1396
|
+
${overflowHidden};
|
|
1397
|
+
height: inherit;
|
|
1398
|
+
margin-right: 8px;
|
|
1399
|
+
height: 32px;
|
|
1400
|
+
width: 32px;
|
|
1401
|
+
border-radius: 16px;
|
|
1402
|
+
img {
|
|
1403
|
+
height: 32px;
|
|
1404
|
+
width: 32px;
|
|
1405
|
+
object-fit: cover;
|
|
1406
|
+
}
|
|
1407
|
+
`;
|
|
1408
|
+
|
|
1409
|
+
const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem) => css`
|
|
1410
|
+
${flexRow};
|
|
1411
|
+
${alignCenter};
|
|
1412
|
+
${outlineNone};
|
|
1413
|
+
${backgroundTransparent};
|
|
1414
|
+
${borderNone};
|
|
1415
|
+
${paragraph1};
|
|
1416
|
+
width: 100%;
|
|
1417
|
+
color: ${main};
|
|
1418
|
+
padding-top: 0;
|
|
1419
|
+
padding-bottom: ${viewType !== 'outlined' ? 0 : 'inherit'};
|
|
1420
|
+
padding-left: ${viewType !== 'outlined' ? 0 : '16px'};
|
|
1421
|
+
min-height: ${multiple ? 30 : 24}px;
|
|
1422
|
+
&.dgn-dropdown-multiple {
|
|
1423
|
+
${flexWrap};
|
|
1424
|
+
${overflowHidden};
|
|
1425
|
+
${breakWord};
|
|
1426
|
+
/* max-height: max-content; */
|
|
1427
|
+
${!multiple ? 'min-height: 24px; max-width: 100%; white-space: nowrap;' : ''}
|
|
1428
|
+
&::after {
|
|
1429
|
+
${flexRow};
|
|
1430
|
+
${positionAbsolute};
|
|
1431
|
+
${alignCenter};
|
|
1432
|
+
${justifyCenter};
|
|
1433
|
+
content: '${placeholder}';
|
|
1434
|
+
color: ${sub};
|
|
1435
|
+
}
|
|
1436
|
+
&:not(:empty)::after {
|
|
1437
|
+
visibility: hidden;
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
&:focus {
|
|
1441
|
+
${backgroundTransparent};
|
|
1442
|
+
}
|
|
1443
|
+
.dropdown-item {
|
|
1444
|
+
&:not(:last-child) {
|
|
1445
|
+
margin-right: 5px;
|
|
1446
|
+
}
|
|
1447
|
+
svg {
|
|
1448
|
+
${borderBox};
|
|
1449
|
+
padding: ${itemMultipleSize === 'medium' ? 2 : 1}px;
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
.css-${DropdownIconCSS.name} {
|
|
1453
|
+
${renderSelectedItem ? `
|
|
1454
|
+
min-height: 24px;
|
|
1455
|
+
min-width: 24px;
|
|
1456
|
+
` : `
|
|
1457
|
+
height: 24px;
|
|
1458
|
+
width: 24px;
|
|
1459
|
+
img {
|
|
1460
|
+
height: 24px;
|
|
1461
|
+
width: 24px;
|
|
1462
|
+
}
|
|
1463
|
+
`}
|
|
1464
|
+
}
|
|
1465
|
+
`;
|
|
1466
|
+
|
|
1467
|
+
const IconCSS = (viewType, loading, showClear) => css`
|
|
1468
|
+
${flexRow};
|
|
1469
|
+
${alignCenter};
|
|
1470
|
+
margin-left: 8px;
|
|
1471
|
+
margin-right: ${viewType !== 'outlined' ? 2 : 16}px;
|
|
1472
|
+
color: inherit;
|
|
1473
|
+
.icon-close {
|
|
1474
|
+
display: ${showClear ? 'flex' : 'none'};
|
|
1475
|
+
margin-right: 4px;
|
|
1476
|
+
}
|
|
1477
|
+
.dgn-dropdown-loading {
|
|
1478
|
+
display: ${loading ? 'flex' : 'none'};
|
|
1479
|
+
}
|
|
1480
|
+
`;
|
|
1481
|
+
|
|
1482
|
+
const DropdownFormCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem) => viewType !== 'outlined' ? css`
|
|
1483
|
+
${flexRow};
|
|
1484
|
+
${alignCenter};
|
|
1485
|
+
${positionRelative};
|
|
1486
|
+
${borderBox};
|
|
1487
|
+
flex: 1 1 auto;
|
|
1488
|
+
padding-bottom: ${multiple ? 1 : 4}px;
|
|
1489
|
+
padding-top: ${multiple ? 1 : 4}px;
|
|
1490
|
+
&:not(:focus-within):hover {
|
|
1491
|
+
&::before {
|
|
1492
|
+
border-bottom-color: ${active};
|
|
1493
|
+
}
|
|
1494
|
+
.css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1495
|
+
color: ${active};
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
&:focus-within {
|
|
1499
|
+
border-bottom-color: ${focus};
|
|
1500
|
+
&::after {
|
|
1501
|
+
border-bottom-color: inherit;
|
|
1502
|
+
transform: scaleX(1);
|
|
1503
|
+
}
|
|
1504
|
+
.css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1505
|
+
color: ${active};
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
1508
|
+
&.dropdown-showing {
|
|
1509
|
+
.icon-dropdown {
|
|
1510
|
+
transform: rotateX(180deg);
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
1513
|
+
&::placeholder {
|
|
1514
|
+
color: ${sub};
|
|
1515
|
+
}
|
|
1516
|
+
&::before {
|
|
1517
|
+
${positionAbsolute};
|
|
1518
|
+
content: '';
|
|
1519
|
+
left: 0;
|
|
1520
|
+
right: 0;
|
|
1521
|
+
bottom: 0;
|
|
1522
|
+
border-bottom: 1px solid ${rest};
|
|
1523
|
+
}
|
|
1524
|
+
&::after {
|
|
1525
|
+
${positionAbsolute};
|
|
1526
|
+
content: '';
|
|
1527
|
+
left: 0px;
|
|
1528
|
+
right: 0px;
|
|
1529
|
+
bottom: -1px;
|
|
1530
|
+
border-bottom: 2px solid transparent;
|
|
1531
|
+
transform: scaleX(0);
|
|
1532
|
+
transform-origin: center;
|
|
1533
|
+
transition: all 0.2s ease;
|
|
1534
|
+
}
|
|
1535
|
+
` : css`
|
|
1536
|
+
${flexRow};
|
|
1537
|
+
${alignCenter};
|
|
1538
|
+
${positionRelative};
|
|
1539
|
+
${borderRadius4px};
|
|
1540
|
+
${borderBox};
|
|
1541
|
+
${border(1, rest)};
|
|
1542
|
+
flex: 1 1 auto;
|
|
1543
|
+
min-height: 40px;
|
|
1544
|
+
&:not(:focus-within):hover {
|
|
1545
|
+
background-color: ${hover};
|
|
1546
|
+
border-color: ${active};
|
|
1547
|
+
input {
|
|
1548
|
+
background-color: ${hover};
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1551
|
+
&:focus-within {
|
|
1552
|
+
border-color: ${focus};
|
|
1553
|
+
}
|
|
1554
|
+
&.dropdown-showing {
|
|
1555
|
+
.icon-dropdown {
|
|
1556
|
+
transform: rotateX(180deg);
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
&::placeholder {
|
|
1560
|
+
color: ${sub};
|
|
1561
|
+
}
|
|
1562
|
+
&::after {
|
|
1563
|
+
${positionAbsolute};
|
|
1564
|
+
${pointerEventsNone};
|
|
1565
|
+
${borderRadius4px};
|
|
1566
|
+
content: '';
|
|
1567
|
+
left: -2px;
|
|
1568
|
+
right: -2px;
|
|
1569
|
+
top: -2px;
|
|
1570
|
+
bottom: -2px;
|
|
1571
|
+
border: 2px solid transparent;
|
|
1572
|
+
}
|
|
1573
|
+
`;
|
|
1574
|
+
|
|
1575
|
+
const DropdownBoxCSS = css`
|
|
1576
|
+
${displayBlock};
|
|
1577
|
+
${positionRelative};
|
|
1578
|
+
${borderBox};
|
|
1579
|
+
${borderRadius4px};
|
|
1580
|
+
width: 100%;
|
|
1581
|
+
max-height: 280px;
|
|
1582
|
+
overflow: auto;
|
|
1583
|
+
background-color: ${white};
|
|
1584
|
+
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);
|
|
1585
|
+
z-index: 9001;
|
|
1586
|
+
&::-webkit-scrollbar {
|
|
1587
|
+
${borderRadius4px};
|
|
1588
|
+
width: 24px;
|
|
1589
|
+
background-color: ${white} !important;
|
|
1590
|
+
}
|
|
1591
|
+
&::-webkit-scrollbar-thumb {
|
|
1592
|
+
border-radius: 24px;
|
|
1593
|
+
border: 8px solid transparent;
|
|
1594
|
+
mix-blend-mode: normal;
|
|
1595
|
+
background-color: ${scrollbar} !important;
|
|
1596
|
+
background-clip: content-box;
|
|
1597
|
+
}
|
|
1598
|
+
.DGN-UI-TreeView {
|
|
1599
|
+
padding: 1px;
|
|
1600
|
+
}
|
|
1601
|
+
`;
|
|
1602
|
+
|
|
1603
|
+
const DropdownItemCSS = (multiple, selectBox) => css`
|
|
1604
|
+
${flexRow};
|
|
1605
|
+
${positionRelative};
|
|
1606
|
+
${alignCenter};
|
|
1607
|
+
${justifyStart};
|
|
1608
|
+
${borderBox};
|
|
1609
|
+
${cursorPointer};
|
|
1610
|
+
${userSelectNone};
|
|
1611
|
+
min-height: 40px;
|
|
1612
|
+
width: 100%;
|
|
1613
|
+
background-color: ${white};
|
|
1614
|
+
padding: 8px ${multiple && selectBox ? 0 : '16px'};
|
|
1615
|
+
color: ${main};
|
|
1616
|
+
&.no-data {
|
|
1617
|
+
${justifyCenter};
|
|
1618
|
+
font-style: italic;
|
|
1619
|
+
cursor: initial;
|
|
1620
|
+
}
|
|
1621
|
+
&:not(.no-data):hover,
|
|
1622
|
+
&:not(.no-data):focus {
|
|
1623
|
+
${outlineNone};
|
|
1624
|
+
background-color: ${hover};
|
|
1625
|
+
color: ${active};
|
|
1626
|
+
}
|
|
1627
|
+
`;
|
|
1628
|
+
|
|
1629
|
+
const DropdownTextCSS = css`
|
|
1630
|
+
${paragraph1};
|
|
1631
|
+
color: inherit;
|
|
1632
|
+
.DGN-UI-Dropdown-PrimaryText {
|
|
1633
|
+
${paragraph1};
|
|
1634
|
+
${displayBlock};
|
|
1635
|
+
}
|
|
1636
|
+
.DGN-UI-Dropdown-SubText {
|
|
1637
|
+
${paragraph3};
|
|
1638
|
+
${displayBlock};
|
|
1639
|
+
color: ${sub};
|
|
1640
|
+
}
|
|
1641
|
+
`;
|
|
1642
|
+
|
|
1643
|
+
const DropdownRootCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, loading, showClear) => css`
|
|
1644
|
+
${displayBlock};
|
|
1645
|
+
${positionRelative};
|
|
1646
|
+
margin-bottom: 20px;
|
|
1647
|
+
/* min-width: 150px; */
|
|
1648
|
+
height: max-content;
|
|
1649
|
+
&.error {
|
|
1650
|
+
.css-${DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1651
|
+
border-color: ${danger};
|
|
1652
|
+
path {
|
|
1653
|
+
fill: ${danger};
|
|
1654
|
+
}
|
|
1655
|
+
&::before {
|
|
1656
|
+
border-color: ${danger};
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
&.dgn-dropdown-loading,
|
|
1661
|
+
&.disabled {
|
|
1662
|
+
${pointerEventsNone};
|
|
1663
|
+
${userSelectNone};
|
|
1664
|
+
.css-${DropdownFormCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1665
|
+
border-color: ${systemDisabled};
|
|
1666
|
+
.css-${IconCSS(viewType, loading, showClear).name} {
|
|
1667
|
+
path {
|
|
1668
|
+
fill: transparent;
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1671
|
+
&::before {
|
|
1672
|
+
border-color: ${systemDisabled};
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
&.readOnly {
|
|
1677
|
+
.css-${IconCSS(viewType, loading, showClear).name} {
|
|
1678
|
+
${pointerEventsNone};
|
|
1679
|
+
}
|
|
1680
|
+
.css-${DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem).name} {
|
|
1681
|
+
.dropdown-item {
|
|
1682
|
+
${pointerEventsNone};
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
`;
|
|
1687
|
+
|
|
1688
|
+
const DisabledCSS = css`
|
|
1689
|
+
pointer-events: none !important;
|
|
1690
|
+
opacity: 0.4 !important;
|
|
1691
|
+
`;
|
|
1692
|
+
/* End styled */
|
|
1693
|
+
|
|
1663
1694
|
Dropdown.defaultProps = {
|
|
1664
1695
|
viewType: 'underlined',
|
|
1665
1696
|
itemMode: 'normal',
|