diginet-core-ui 1.3.33 → 1.3.34
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/avatar/default.svg +2 -2
- package/assets/images/menu/dhr/ALL.svg +6 -0
- package/assets/images/menu/dhr/D00.svg +12 -0
- package/assets/images/menu/dhr/D09.svg +8 -0
- package/assets/images/menu/dhr/D13.svg +10 -0
- package/assets/images/menu/dhr/D15.svg +10 -0
- package/assets/images/menu/dhr/D21.svg +10 -0
- package/assets/images/menu/dhr/D25.svg +11 -0
- package/assets/images/menu/dhr/D29.svg +11 -0
- package/assets/images/menu/dhr/D38.svg +6 -0
- package/assets/images/menu/dhr/D39.svg +10 -0
- package/assets/images/menu/dhr/D51.svg +12 -0
- package/assets/images/menu/dhr/D52.svg +16 -0
- package/assets/images/menu/dhr/D77.svg +16 -0
- package/assets/images/menu/dhr/D84.svg +12 -0
- package/assets/images/menu/dhr/D89.svg +8 -0
- package/components/avatar/index.js +153 -204
- package/components/badge/index.js +120 -80
- package/components/button/icon.js +193 -170
- package/components/button/index.js +16 -9
- package/components/button/ripple-effect.js +2 -0
- package/components/chip/index.js +139 -137
- package/components/form-control/dropdown/index.js +337 -316
- package/components/form-control/dropdown-box/index.js +3 -3
- package/components/form-control/toggle/index.js +5 -12
- package/components/typography/index.js +92 -47
- package/icons/basic.js +74 -0
- package/icons/effect.js +51 -23
- package/package.json +1 -1
- package/readme.md +21 -0
- package/styles/colors.js +2 -2
- package/styles/general.js +15 -2
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { Fragment, memo, useState, useEffect, useMemo, useRef, useImperativeHandle, forwardRef } from 'react';
|
|
5
5
|
import ReactDOM from 'react-dom';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
6
7
|
import PropTypes from 'prop-types';
|
|
7
8
|
import { jsx, css } from '@emotion/core';
|
|
8
9
|
import { Account } from '../../../icons';
|
|
@@ -121,71 +122,71 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
121
122
|
|
|
122
123
|
|
|
123
124
|
const forInput = css`
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
${flexRow}
|
|
126
|
+
flex: 1 1 auto;
|
|
127
|
+
${!multiple && renderSelectedItem ? `width: calc(100% - 34px${clearAble ? ' - 18px' : ''})` : ''}
|
|
128
|
+
`;
|
|
128
129
|
const DropdownIcon = css`
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
${inlineFlex}
|
|
131
|
+
${alignCenter}
|
|
131
132
|
${positionRelative}
|
|
132
133
|
${overflowHidden}
|
|
133
134
|
height: inherit;
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
`;
|
|
144
145
|
const DropdownInput = css`
|
|
145
|
-
|
|
146
|
-
|
|
146
|
+
${flexRow}
|
|
147
|
+
${alignCenter}
|
|
147
148
|
${outlineNone}
|
|
148
149
|
${backgroundTransparent}
|
|
149
150
|
${paragraph1};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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}
|
|
160
161
|
/* max-height: max-content; */
|
|
161
162
|
word-break: break-word;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
${!multiple ? 'min-height: 24px; max-width: 100%; white-space: nowrap;' : ''}
|
|
164
|
+
&::after {
|
|
165
|
+
${flexRow}
|
|
166
|
+
${positionAbsolute}
|
|
166
167
|
${alignCenter}
|
|
167
168
|
${justifyCenter}
|
|
168
169
|
content: '${placeholder}';
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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 ? `
|
|
189
190
|
min-height: 24px;
|
|
190
191
|
min-width: 24px;
|
|
191
192
|
` : `
|
|
@@ -196,230 +197,230 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
196
197
|
width: 24px;
|
|
197
198
|
}
|
|
198
199
|
`}
|
|
199
|
-
|
|
200
|
-
|
|
200
|
+
}
|
|
201
|
+
`;
|
|
201
202
|
const forIcon = css`
|
|
202
|
-
|
|
203
|
-
|
|
203
|
+
${flexRow}
|
|
204
|
+
${alignCenter}
|
|
204
205
|
margin-left: 8px;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
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
|
+
`;
|
|
215
216
|
const DropdownForm = viewType !== 'outlined' ? css`
|
|
216
|
-
|
|
217
|
-
|
|
217
|
+
${flexRow}
|
|
218
|
+
${alignCenter}
|
|
218
219
|
${positionRelative}
|
|
219
220
|
${borderBox}
|
|
220
221
|
flex: 1 1 auto;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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}
|
|
271
272
|
${positionRelative}
|
|
272
273
|
${borderRadius4px}
|
|
273
274
|
${borderBox}
|
|
274
275
|
flex: 1 1 auto;
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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}
|
|
298
299
|
content: '';
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
left: -2px;
|
|
301
|
+
right: -2px;
|
|
302
|
+
top: -2px;
|
|
303
|
+
bottom: -2px;
|
|
304
|
+
border: 2px solid transparent;
|
|
305
|
+
border-radius: 4px;
|
|
306
|
+
}
|
|
307
|
+
`;
|
|
307
308
|
const DropdownBox = css`
|
|
308
|
-
|
|
309
|
-
|
|
309
|
+
${displayBlock}
|
|
310
|
+
${positionRelative}
|
|
310
311
|
${borderBox}
|
|
311
312
|
width: 100%;
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
+
`;
|
|
334
335
|
const DropdownItem = css`
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
${flexRow}
|
|
337
|
+
${positionRelative}
|
|
337
338
|
${alignCenter}
|
|
338
339
|
${justifyStart}
|
|
339
340
|
${borderBox}
|
|
340
341
|
${cursorPointer}
|
|
341
342
|
${userSelectNone}
|
|
342
343
|
min-height: 40px;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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
|
+
`;
|
|
359
360
|
const DropdownText = css`
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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
|
+
`;
|
|
372
373
|
const DropdownRoot = css`
|
|
373
|
-
|
|
374
|
-
|
|
374
|
+
${displayBlock}
|
|
375
|
+
${positionRelative}
|
|
375
376
|
margin-bottom: 20px;
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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
|
+
}
|
|
386
389
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
${pointerEventsNone}
|
|
392
|
-
${userSelectNone}
|
|
390
|
+
&.dgn-dropdown-loading,
|
|
391
|
+
&.disabled {
|
|
392
|
+
${pointerEventsNone}
|
|
393
|
+
${userSelectNone}
|
|
393
394
|
.css-${DropdownInput.name} {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
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
|
+
}
|
|
401
407
|
}
|
|
402
408
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
.css-${DropdownInput.name} {
|
|
413
|
-
.dropdown-item {
|
|
414
|
-
${pointerEventsNone}
|
|
409
|
+
&.readOnly {
|
|
410
|
+
.css-${forIcon.name} {
|
|
411
|
+
${pointerEventsNone}
|
|
412
|
+
}
|
|
413
|
+
.css-${DropdownInput.name} {
|
|
414
|
+
.dropdown-item {
|
|
415
|
+
${pointerEventsNone}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
415
418
|
}
|
|
416
|
-
|
|
417
|
-
}
|
|
418
|
-
`;
|
|
419
|
+
`;
|
|
419
420
|
const Disabled = css`
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
pointer-events: none !important;
|
|
422
|
+
opacity: 0.4 !important;
|
|
423
|
+
`;
|
|
423
424
|
/* End styled */
|
|
424
425
|
|
|
425
426
|
/* Start handler */
|
|
@@ -494,6 +495,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
494
495
|
};
|
|
495
496
|
|
|
496
497
|
const showDropdown = () => {
|
|
498
|
+
var _searchRef$current;
|
|
499
|
+
|
|
497
500
|
if (displayExpr && Array.isArray(displayExpr)) {
|
|
498
501
|
displayExpr = displayExpr.join(' - ');
|
|
499
502
|
}
|
|
@@ -524,58 +527,76 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
524
527
|
}
|
|
525
528
|
}
|
|
526
529
|
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
}
|
|
530
|
+
let dropdownStyle = {
|
|
531
|
+
position: 'fixed',
|
|
532
|
+
top: `${positionTop}px`,
|
|
533
|
+
left: `${left}px`,
|
|
534
|
+
width: `${width}px`,
|
|
535
|
+
backgroundColor: '#FFF',
|
|
536
|
+
zIndex: 9001
|
|
537
|
+
};
|
|
538
|
+
if (_isMobile && allowSearch) dropdownStyle = { ...dropdownStyle,
|
|
539
|
+
bottom: 0,
|
|
540
|
+
top: 'auto',
|
|
541
|
+
display: 'flex',
|
|
542
|
+
flexDirection: 'column-reverse',
|
|
543
|
+
height: 'max-content'
|
|
544
|
+
};
|
|
545
|
+
const loadingStyle = {
|
|
546
|
+
display: 'none',
|
|
547
|
+
justifyContent: 'center',
|
|
548
|
+
alignItems: 'center',
|
|
549
|
+
position: 'absolute',
|
|
550
|
+
top: 0,
|
|
551
|
+
width: '100%',
|
|
552
|
+
height: '100%',
|
|
553
|
+
backgroundColor: 'rgba(255, 255, 255, 0.6)',
|
|
554
|
+
borderRadius: 4,
|
|
555
|
+
zIndex: 9002
|
|
556
|
+
};
|
|
557
|
+
const defaultSearch = onInput ? (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value : '';
|
|
558
|
+
const el = jsx("div", {
|
|
559
|
+
className: `DGN-UI-Portal DGN-Dropdown-${unique}`,
|
|
560
|
+
style: dropdownStyle
|
|
561
|
+
}, (multiple || allowSearch) && itemMode === 'normal' && !children && jsx("div", {
|
|
562
|
+
className: 'DGN-Dropdown-Box-Search'
|
|
563
|
+
}, jsx(InputBase, {
|
|
564
|
+
inputRef: searchRef,
|
|
565
|
+
viewType: 'outlined',
|
|
566
|
+
defaultValue: defaultSearch,
|
|
567
|
+
onChange: onChangeInput,
|
|
568
|
+
style: {
|
|
569
|
+
backgroundColor: '#FFF',
|
|
570
|
+
marginBottom: 1
|
|
571
|
+
},
|
|
572
|
+
onKeyDown: pressESCHandler,
|
|
573
|
+
autoFocus: true
|
|
574
|
+
})), jsx("div", {
|
|
575
|
+
className: 'DGN-Dropdown-Box'
|
|
576
|
+
}, dropdown), jsx("div", {
|
|
577
|
+
className: 'DGN-Dropdown-Loading',
|
|
578
|
+
style: loadingStyle
|
|
579
|
+
}, jsx(CircularProgress, {
|
|
580
|
+
size: 'xs'
|
|
581
|
+
})));
|
|
582
|
+
|
|
583
|
+
if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
|
|
559
584
|
inputRef.current.addEventListener('keydown', pressESCHandler);
|
|
560
585
|
}
|
|
561
586
|
|
|
562
|
-
ReactDOM.render(dropdown, node.appendChild(elBox));
|
|
563
|
-
ReactDOM.render(jsx(CircularProgress, {
|
|
564
|
-
size: 'xs'
|
|
565
|
-
}), node.appendChild(elLoading));
|
|
566
587
|
document.documentElement.style.overflow = 'hidden';
|
|
567
588
|
setTimeout(() => {
|
|
568
|
-
el.style.opacity = 1;
|
|
569
589
|
window.addEventListener('resize', customizeWidthDropdown);
|
|
570
590
|
document.addEventListener('wheel', onWheelHandler);
|
|
571
|
-
document.addEventListener('
|
|
591
|
+
document.addEventListener('mousedown', onClickOutsideOfInput);
|
|
572
592
|
document.addEventListener('keydown', preventScroll);
|
|
573
|
-
boxRef.current.addEventListener('keydown', moveOnItem);
|
|
593
|
+
boxRef.current && boxRef.current.addEventListener('keydown', moveOnItem);
|
|
574
594
|
|
|
575
595
|
if (onLoadMore && dataSource.length < total) {
|
|
576
596
|
boxRef.current.addEventListener('scroll', onLoadMoreHandler);
|
|
577
597
|
}
|
|
578
598
|
}, 10);
|
|
599
|
+
return el;
|
|
579
600
|
};
|
|
580
601
|
|
|
581
602
|
const moveOnItem = e => {
|
|
@@ -587,7 +608,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
587
608
|
activeEl.focus();
|
|
588
609
|
activeEl.scrollIntoView({
|
|
589
610
|
block: 'center',
|
|
590
|
-
behavior:
|
|
611
|
+
behavior: 'smooth'
|
|
591
612
|
});
|
|
592
613
|
}
|
|
593
614
|
}
|
|
@@ -643,7 +664,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
643
664
|
boxRef.current = null;
|
|
644
665
|
}, 300);
|
|
645
666
|
setOpenState(false);
|
|
646
|
-
document.removeEventListener('
|
|
667
|
+
document.removeEventListener('mousedown', onClickOutsideOfInput);
|
|
647
668
|
window.removeEventListener('resize', customizeWidthDropdown);
|
|
648
669
|
document.removeEventListener('wheel', onWheelHandler);
|
|
649
670
|
document.removeEventListener('keydown', preventScroll);
|
|
@@ -687,7 +708,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
687
708
|
const items = [];
|
|
688
709
|
const dataSourceUsable = [...dataSource];
|
|
689
710
|
|
|
690
|
-
if (
|
|
711
|
+
if (currentObjectDefault[unique] && currentObjectDefault[unique].length) {
|
|
691
712
|
const length = currentObjectDefault[unique].length;
|
|
692
713
|
let existItemQuantity = 0;
|
|
693
714
|
|
|
@@ -729,7 +750,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
729
750
|
}
|
|
730
751
|
|
|
731
752
|
const value = typeof data === 'object' ? data[valueExpr] : data;
|
|
732
|
-
const itemDisabled = typeof data === 'object' ? data[
|
|
753
|
+
const itemDisabled = typeof data === 'object' ? data['disabled'] : data;
|
|
733
754
|
const icon = getIconFromData(data);
|
|
734
755
|
|
|
735
756
|
if (multiple && selectBox) {
|
|
@@ -787,7 +808,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
787
808
|
}, items.length ? items : jsx("div", {
|
|
788
809
|
css: DropdownItem,
|
|
789
810
|
className: 'no-data'
|
|
790
|
-
},
|
|
811
|
+
}, ' ', noDataText, ' '));
|
|
791
812
|
};
|
|
792
813
|
|
|
793
814
|
const mapTreeView = () => {
|
|
@@ -1268,7 +1289,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1268
1289
|
}
|
|
1269
1290
|
}
|
|
1270
1291
|
|
|
1271
|
-
if (
|
|
1292
|
+
if (currentObjectDefault[unique].length) {
|
|
1272
1293
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === v || valueObject === v);
|
|
1273
1294
|
|
|
1274
1295
|
if (itemOfValue) {
|
|
@@ -1286,7 +1307,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1286
1307
|
}
|
|
1287
1308
|
}
|
|
1288
1309
|
|
|
1289
|
-
if (
|
|
1310
|
+
if (currentObjectDefault[unique].length) {
|
|
1290
1311
|
const itemOfValue = currentObjectDefault[unique].find(valueObject => valueObject[valueExpr] === source || valueObject === source);
|
|
1291
1312
|
|
|
1292
1313
|
if (itemOfValue) {
|
|
@@ -1374,7 +1395,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1374
1395
|
setShowClear(clearAble && checkHasValue(valueProp) && !disabled && !readOnly && !loading);
|
|
1375
1396
|
}, [clearAble, valueProp, disabled, readOnly, loading]);
|
|
1376
1397
|
useEffect(() => {
|
|
1377
|
-
if (
|
|
1398
|
+
if (valueObjectDefault) {
|
|
1378
1399
|
if (Array.isArray(valueObjectDefault)) {
|
|
1379
1400
|
currentObjectDefault[unique] = [...valueObjectDefault];
|
|
1380
1401
|
} else if (typeof valueObjectDefault === 'object') {
|
|
@@ -1631,13 +1652,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
|
|
|
1631
1652
|
}, error), [error, valueProp, disabled, errorState]);
|
|
1632
1653
|
/* End component */
|
|
1633
1654
|
|
|
1634
|
-
return jsx("div", {
|
|
1655
|
+
return jsx(Fragment, null, jsx("div", {
|
|
1635
1656
|
ref: dropdownRef,
|
|
1636
1657
|
css: DropdownRoot,
|
|
1637
1658
|
className: ['DGN-UI-Dropdown', className, errorState && 'error', loading && 'dgn-dropdown-loading', disabled ? 'disabled' : readOnly && 'readOnly'].join(' ').trim().replace(/\s+/g, ' '),
|
|
1638
1659
|
style: style,
|
|
1639
1660
|
...props
|
|
1640
|
-
}, labelComp, inputComp, errorComp);
|
|
1661
|
+
}, labelComp, inputComp, errorComp), openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null);
|
|
1641
1662
|
}));
|
|
1642
1663
|
Dropdown.defaultProps = {
|
|
1643
1664
|
viewType: 'underlined',
|
|
@@ -1702,14 +1723,14 @@ Dropdown.propTypes = {
|
|
|
1702
1723
|
/** display this icon if not found the icon follow iconExpr */
|
|
1703
1724
|
iconDefault: PropTypes.string,
|
|
1704
1725
|
|
|
1705
|
-
/** field name used for icon display<br/>
|
|
1706
|
-
* Example:<br/>
|
|
1707
|
-
* string: 'icon'<br/>
|
|
1708
|
-
* object: {<br/>
|
|
1709
|
-
* key: 'icon',<br/>
|
|
1710
|
-
* prefix: 'https://imglink.com',<br/>
|
|
1711
|
-
* suffix: '.jpg'<br/>
|
|
1712
|
-
* }
|
|
1726
|
+
/** field name used for icon display<br/>
|
|
1727
|
+
* Example:<br/>
|
|
1728
|
+
* string: 'icon'<br/>
|
|
1729
|
+
* object: {<br/>
|
|
1730
|
+
* key: 'icon',<br/>
|
|
1731
|
+
* prefix: 'https://imglink.com',<br/>
|
|
1732
|
+
* suffix: '.jpg'<br/>
|
|
1733
|
+
* }
|
|
1713
1734
|
*/
|
|
1714
1735
|
iconExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
|
1715
1736
|
key: PropTypes.string,
|
|
@@ -1727,9 +1748,9 @@ Dropdown.propTypes = {
|
|
|
1727
1748
|
/** field name used for text display in input */
|
|
1728
1749
|
keyExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1729
1750
|
|
|
1730
|
-
/** field name used for text display<br/>
|
|
1731
|
-
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1732
|
-
* Note: don't use 'id - name', return undefined
|
|
1751
|
+
/** field name used for text display<br/>
|
|
1752
|
+
* Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
|
|
1753
|
+
* Note: don't use 'id - name', return undefined
|
|
1733
1754
|
*/
|
|
1734
1755
|
displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
|
|
1735
1756
|
|
|
@@ -1739,9 +1760,9 @@ Dropdown.propTypes = {
|
|
|
1739
1760
|
/** the field name used for the returned result */
|
|
1740
1761
|
valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1741
1762
|
|
|
1742
|
-
/**
|
|
1743
|
-
* duration wait enter search content on search<br/>
|
|
1744
|
-
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1763
|
+
/**
|
|
1764
|
+
* duration wait enter search content on search<br/>
|
|
1765
|
+
* Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
|
|
1745
1766
|
*/
|
|
1746
1767
|
searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
1747
1768
|
|
|
@@ -1811,19 +1832,19 @@ Dropdown.propTypes = {
|
|
|
1811
1832
|
/** The function to get ref of Dropdown component */
|
|
1812
1833
|
refs: PropTypes.func,
|
|
1813
1834
|
|
|
1814
|
-
/** function displays items by custom<br/>
|
|
1815
|
-
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1816
|
-
* --> such as: displayExpr={'name - role'}
|
|
1835
|
+
/** function displays items by custom<br/>
|
|
1836
|
+
* renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
|
|
1837
|
+
* --> such as: displayExpr={'name - role'}
|
|
1817
1838
|
*/
|
|
1818
1839
|
renderItem: PropTypes.func,
|
|
1819
1840
|
|
|
1820
|
-
/** function displays selected items by custom, example:<br/>
|
|
1821
|
-
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1841
|
+
/** function displays selected items by custom, example:<br/>
|
|
1842
|
+
* renderItem={(data, index) => index + ' - ' + data.name}<br/>
|
|
1822
1843
|
*/
|
|
1823
1844
|
renderSelectedItem: PropTypes.func,
|
|
1824
1845
|
|
|
1825
|
-
/** the function will run when entering input<br/>
|
|
1826
|
-
* if undefined: the filter function will run (default)
|
|
1846
|
+
/** the function will run when entering input<br/>
|
|
1847
|
+
* if undefined: the filter function will run (default)
|
|
1827
1848
|
*/
|
|
1828
1849
|
onInput: PropTypes.func,
|
|
1829
1850
|
|