diginet-core-ui 1.3.66 → 1.3.67

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.
Files changed (46) hide show
  1. package/assets/storybook/avatar01.svg +9 -0
  2. package/assets/storybook/cover01.svg +9 -0
  3. package/components/accordion/css.js +6 -6
  4. package/components/accordion/details.js +13 -18
  5. package/components/accordion/group.js +16 -17
  6. package/components/accordion/index.js +17 -22
  7. package/components/accordion/summary.js +55 -32
  8. package/components/avatar/index.js +23 -28
  9. package/components/badge/index.js +9 -14
  10. package/components/button/icon.js +25 -30
  11. package/components/button/index.js +275 -280
  12. package/components/card/body.js +47 -0
  13. package/components/card/extra.js +47 -0
  14. package/components/card/footer.js +47 -0
  15. package/components/card/header.js +50 -0
  16. package/components/card/index.js +175 -37
  17. package/components/chart/Pie-v2/Sector.js +2 -2
  18. package/components/chip/attach.js +5 -5
  19. package/components/form-control/attachment/index.js +26 -24
  20. package/components/form-control/calendar/function.js +133 -123
  21. package/components/form-control/calendar/index.js +16 -16
  22. package/components/form-control/dropdown/index.js +71 -10
  23. package/components/form-control/helper-text/index.js +8 -3
  24. package/components/form-control/number-input/index.js +11 -11
  25. package/components/form-control/phone-input/index.js +7 -7
  26. package/components/grid/Container.js +110 -0
  27. package/components/grid/Row.js +1 -1
  28. package/components/grid/index.js +35 -5
  29. package/components/index.js +7 -2
  30. package/components/others/option-wrapper/index.js +21 -27
  31. package/components/paging/page-info.js +31 -40
  32. package/components/popover/index.js +29 -27
  33. package/components/progress/circular.js +12 -12
  34. package/components/transfer/index.js +3 -3
  35. package/components/tree-view/index.js +10 -6
  36. package/icons/basic.js +120 -0
  37. package/icons/effect.js +4 -9
  38. package/package.json +1 -1
  39. package/readme.md +14 -0
  40. package/styles/color-helper.js +103 -103
  41. package/styles/utils.js +17 -5
  42. package/utils/error/error.js +2 -2
  43. package/utils/renderIcon.js +5 -5
  44. package/components/card/body-card.js +0 -65
  45. package/components/card/card.js +0 -125
  46. package/components/card/context.js +0 -6
@@ -31,15 +31,15 @@ const {
31
31
  danger8,
32
32
  info8
33
33
  } = colors;
34
- /**
35
- * START STYLE
34
+ /**
35
+ * START STYLE
36
36
  */
37
37
 
38
- /**
39
- *
40
- * @param {Object} unique
41
- * @param {Boolean} boxShadow
42
- * @returns
38
+ /**
39
+ *
40
+ * @param {Object} unique
41
+ * @param {Boolean} boxShadow
42
+ * @returns
43
43
  */
44
44
 
45
45
  const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true) => css`
@@ -243,15 +243,15 @@ const generateCalendarCSS = (unique, boxShadow = true, onClickActive = true) =>
243
243
  }
244
244
  }
245
245
  `;
246
- /**
247
- * END STYLE
246
+ /**
247
+ * END STYLE
248
248
  */
249
249
 
250
- /**
251
- *
252
- * @description return props of the typography.
253
- * @param {String} className
254
- * @returns {Object} props of the typography
250
+ /**
251
+ *
252
+ * @description return props of the typography.
253
+ * @param {String} className
254
+ * @returns {Object} props of the typography
255
255
  */
256
256
 
257
257
 
@@ -272,11 +272,11 @@ const typographyProps = className => {
272
272
  type: 'h6'
273
273
  };
274
274
  };
275
- /**
276
- *
277
- * @description return props of the button icon.
278
- * @param {String} className
279
- * @returns {Object} props of the button icon
275
+ /**
276
+ *
277
+ * @description return props of the button icon.
278
+ * @param {String} className
279
+ * @returns {Object} props of the button icon
280
280
  */
281
281
 
282
282
 
@@ -290,11 +290,11 @@ const buttonIconProps = className => {
290
290
  width: 28
291
291
  };
292
292
  };
293
- /**
294
- *
295
- * @description return props of the button icon.
296
- * @param {Function} fn
297
- * @returns {Object} props of the button text
293
+ /**
294
+ *
295
+ * @description return props of the button icon.
296
+ * @param {Function} fn
297
+ * @returns {Object} props of the button text
298
298
  */
299
299
 
300
300
 
@@ -311,21 +311,21 @@ const buttonTextProps = fn => {
311
311
  }
312
312
  };
313
313
  };
314
- /**
315
- * @description detect value is a Date object
316
- * @param {String | Number | Array} value
317
- * @returns boolean
314
+ /**
315
+ * @description detect value is a Date object
316
+ * @param {String | Number | Array} value
317
+ * @returns boolean
318
318
  */
319
319
 
320
320
 
321
321
  const isValidDate = value => {
322
322
  return new Date(value) instanceof Date && !isNaN(new Date(value));
323
323
  };
324
- /**
325
- *
326
- * @description set Sunday (0) to the last day of week.
327
- * @param {Date} date
328
- * @returns number of day from 0 (Monday) to 6 (Sunday).
324
+ /**
325
+ *
326
+ * @description set Sunday (0) to the last day of week.
327
+ * @param {Date} date
328
+ * @returns number of day from 0 (Monday) to 6 (Sunday).
329
329
  */
330
330
 
331
331
 
@@ -334,26 +334,26 @@ const getDateOfWeek = date => {
334
334
  if (day === 0) day = 7;
335
335
  return day - 1;
336
336
  };
337
- /**
338
- *
339
- * @description check day is today.
340
- * @param {Date} day
341
- * @param {Date} today
342
- * @param {String} className
343
- * @returns {Boolean} is today
337
+ /**
338
+ *
339
+ * @description check day is today.
340
+ * @param {Date} day
341
+ * @param {Date} today
342
+ * @param {String} className
343
+ * @returns {Boolean} is today
344
344
  */
345
345
 
346
346
 
347
347
  const isToday = (day, today, className) => {
348
348
  return +moment(day).diff(today) === 0 ? className : '';
349
349
  };
350
- /**
351
- *
352
- * @description check day is active day.
353
- * @param {Date} day
354
- * @param {Date} active
355
- * @param {String} className
356
- * @returns {Boolean} is active day
350
+ /**
351
+ *
352
+ * @description check day is active day.
353
+ * @param {Date} day
354
+ * @param {Date} active
355
+ * @param {String} className
356
+ * @returns {Boolean} is active day
357
357
  */
358
358
 
359
359
 
@@ -370,14 +370,14 @@ const isActive = (day, active, className) => {
370
370
 
371
371
  return '';
372
372
  };
373
- /**
374
- *
375
- * @description check day is min/max day.
376
- * @param {Date} day
377
- * @param {Date} max
378
- * @param {Date} min
379
- * @param {Object} className
380
- * @returns {Boolean} is limited day
373
+ /**
374
+ *
375
+ * @description check day is min/max day.
376
+ * @param {Date} day
377
+ * @param {Date} max
378
+ * @param {Date} min
379
+ * @param {Object} className
380
+ * @returns {Boolean} is limited day
381
381
  */
382
382
 
383
383
 
@@ -408,17 +408,17 @@ const isBeforeLimit = (min, time) => {
408
408
  const isAfterLimit = (max, time) => {
409
409
  return max && isValidDate(max) && moment(time).diff(new Date(max).setHours(0, 0, 0, 0)) > 0;
410
410
  };
411
- /**
412
- *
413
- * @description return the table body of the calendar.
414
- * @param {Date} time
415
- * @param {Date} activeValue
416
- * @param {Object} className
417
- * @param {Boolean} displayAnotherMonth
418
- * @param {Function} onTableDataClick
419
- * @param {Date} min
420
- * @param {Date} max
421
- * @returns {Element}
411
+ /**
412
+ *
413
+ * @description return the table body of the calendar.
414
+ * @param {Date} time
415
+ * @param {Date} activeValue
416
+ * @param {Object} className
417
+ * @param {Boolean} displayAnotherMonth
418
+ * @param {Function} onTableDataClick
419
+ * @param {Date} min
420
+ * @param {Date} max
421
+ * @returns {Element}
422
422
  */
423
423
 
424
424
 
@@ -438,8 +438,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
438
438
  weekDateLast = getDateOfWeek(lastDay);
439
439
 
440
440
  if (activeValue && Array.isArray(activeValue) && activeValue.length === 2 && activeValue[0] !== activeValue[1]) {
441
- /**
442
- * days of previous month
441
+ /**
442
+ * days of previous month
443
443
  */
444
444
  active = activeValue;
445
445
 
@@ -455,8 +455,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
455
455
  }, jsx(Typography, { ...typographyProps(className.day.day)
456
456
  }, '')));
457
457
  }
458
- /**
459
- * days of this month
458
+ /**
459
+ * days of this month
460
460
  */
461
461
 
462
462
 
@@ -470,8 +470,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
470
470
  }, jsx(Typography, { ...typographyProps(className.day.day)
471
471
  }, i + 1)));
472
472
  }
473
- /**
474
- * days of next month
473
+ /**
474
+ * days of next month
475
475
  */
476
476
 
477
477
 
@@ -488,8 +488,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
488
488
  }, '')));
489
489
  }
490
490
  } else {
491
- /**
492
- * days of previous month
491
+ /**
492
+ * days of previous month
493
493
  */
494
494
  for (let i = weekDateFirst; i > 0; i--) {
495
495
  const day = new Date(time.getFullYear(), time.getMonth() - 1, displayAnotherMonth ? prevDate - i + 1 : 1);
@@ -501,8 +501,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
501
501
  }, jsx(Typography, { ...typographyProps(className.day.day)
502
502
  }, displayAnotherMonth ? prevDate - i + 1 : '')));
503
503
  }
504
- /**
505
- * days of this month
504
+ /**
505
+ * days of this month
506
506
  */
507
507
 
508
508
 
@@ -516,8 +516,8 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
516
516
  }, jsx(Typography, { ...typographyProps(className.day.day)
517
517
  }, i + 1)));
518
518
  }
519
- /**
520
- * days of next month
519
+ /**
520
+ * days of next month
521
521
  */
522
522
 
523
523
 
@@ -547,10 +547,10 @@ const renderTableBody = (time, activeValue, className, displayAnotherMonth, onTa
547
547
 
548
548
  return tableBody;
549
549
  };
550
- /**
551
- *
552
- * @param {Object} className
553
- * @returns
550
+ /**
551
+ *
552
+ * @param {Object} className
553
+ * @returns
554
554
  */
555
555
 
556
556
 
@@ -573,15 +573,15 @@ const renderHeader = className => {
573
573
  }, tableHeader));
574
574
  return header;
575
575
  };
576
- /**
577
- *
578
- * @param {Object} className
579
- * @param {Object} refs
580
- * @param {Function} dbLeftFn
581
- * @param {Function} leftFn
582
- * @param {Function} rightFn
583
- * @param {Function} dbRightFn
584
- * @returns navigator
576
+ /**
577
+ *
578
+ * @param {Object} className
579
+ * @param {Object} refs
580
+ * @param {Function} dbLeftFn
581
+ * @param {Function} leftFn
582
+ * @param {Function} rightFn
583
+ * @param {Function} dbRightFn
584
+ * @returns navigator
585
585
  */
586
586
 
587
587
 
@@ -615,10 +615,10 @@ const renderNavigator = (className, refs, dbLeftFn, leftFn, rightFn, dbRightFn,
615
615
  onClick: dbRightFn,
616
616
  ref: refs.doubleRight
617
617
  })));
618
- /**
619
- *
620
- * @param {Date} time
621
- * @returns {String} month year
618
+ /**
619
+ *
620
+ * @param {Date} time
621
+ * @returns {String} month year
622
622
  */
623
623
 
624
624
 
@@ -627,16 +627,18 @@ const renderNavigatorContent = time => {
627
627
  const months = getGlobal(['months', 'full']);
628
628
  return [months[value.getMonth()], value.getFullYear()];
629
629
  };
630
- /**
631
- *
632
- * @param {Date} time
633
- * @param {Object} refs
634
- * @param {Date} min
635
- * @param {Date} max
630
+ /**
631
+ *
632
+ * @param {Date} time
633
+ * @param {Object} refs
634
+ * @param {Date} min
635
+ * @param {Date} max
636
636
  */
637
637
 
638
638
 
639
639
  const onUpdateNavigator = (time, refs, min, max) => {
640
+ var _refs$doubleLeft$curr, _refs$doubleLeft$curr2, _refs$doubleRight$cur, _refs$doubleRight$cur2, _refs$left$current, _refs$left$current$in, _refs$right$current, _refs$right$current$i;
641
+
640
642
  const el = refs.content.current;
641
643
  const vl = renderNavigatorContent(time);
642
644
  const year = locale.get() === 'vi' ? ` ${getGlobal(['year'])} ` : '';
@@ -647,45 +649,53 @@ const onUpdateNavigator = (time, refs, min, max) => {
647
649
 
648
650
  const firstDayOfMin = new Date(new Date(new Date(min).setDate(1)).setHours(0, 0, 0, 0));
649
651
  const firstDayOfMax = new Date(new Date(new Date(max).setDate(1)).setHours(0, 0, 0, 0));
650
- refs.doubleLeft.current.disabled = false;
651
- refs.doubleRight.current.disabled = false;
652
- refs.left.current.disabled = false;
653
- refs.right.current.disabled = false;
652
+ (_refs$doubleLeft$curr = refs.doubleLeft.current) === null || _refs$doubleLeft$curr === void 0 ? void 0 : (_refs$doubleLeft$curr2 = _refs$doubleLeft$curr.instance) === null || _refs$doubleLeft$curr2 === void 0 ? void 0 : _refs$doubleLeft$curr2.option('disabled', false);
653
+ (_refs$doubleRight$cur = refs.doubleRight.current) === null || _refs$doubleRight$cur === void 0 ? void 0 : (_refs$doubleRight$cur2 = _refs$doubleRight$cur.instance) === null || _refs$doubleRight$cur2 === void 0 ? void 0 : _refs$doubleRight$cur2.option('disabled', false);
654
+ (_refs$left$current = refs.left.current) === null || _refs$left$current === void 0 ? void 0 : (_refs$left$current$in = _refs$left$current.instance) === null || _refs$left$current$in === void 0 ? void 0 : _refs$left$current$in.option('disabled', false);
655
+ (_refs$right$current = refs.right.current) === null || _refs$right$current === void 0 ? void 0 : (_refs$right$current$i = _refs$right$current.instance) === null || _refs$right$current$i === void 0 ? void 0 : _refs$right$current$i.option('disabled', false);
654
656
 
655
657
  if (min && isValidDate(min)) {
656
658
  if (moment(time).diff(firstDayOfMin) < 365) {
657
- refs.doubleLeft.current.disabled = true;
659
+ var _refs$doubleLeft$curr3, _refs$doubleLeft$curr4;
660
+
661
+ (_refs$doubleLeft$curr3 = refs.doubleLeft.current) === null || _refs$doubleLeft$curr3 === void 0 ? void 0 : (_refs$doubleLeft$curr4 = _refs$doubleLeft$curr3.instance) === null || _refs$doubleLeft$curr4 === void 0 ? void 0 : _refs$doubleLeft$curr4.option('disabled', true);
658
662
  }
659
663
 
660
664
  if (moment(time).diff(firstDayOfMin) <= 28) {
661
- refs.doubleLeft.current.disabled = true;
662
- refs.left.current.disabled = true;
665
+ var _refs$doubleLeft$curr5, _refs$doubleLeft$curr6, _refs$left$current2, _refs$left$current2$i;
666
+
667
+ (_refs$doubleLeft$curr5 = refs.doubleLeft.current) === null || _refs$doubleLeft$curr5 === void 0 ? void 0 : (_refs$doubleLeft$curr6 = _refs$doubleLeft$curr5.instance) === null || _refs$doubleLeft$curr6 === void 0 ? void 0 : _refs$doubleLeft$curr6.option('disabled', true);
668
+ (_refs$left$current2 = refs.left.current) === null || _refs$left$current2 === void 0 ? void 0 : (_refs$left$current2$i = _refs$left$current2.instance) === null || _refs$left$current2$i === void 0 ? void 0 : _refs$left$current2$i.option('disabled', true);
663
669
  }
664
670
  }
665
671
 
666
672
  if (max && isValidDate(max)) {
667
673
  if (moment(time).diff(firstDayOfMax) > -334) {
668
- refs.doubleRight.current.disabled = true;
674
+ var _refs$doubleRight$cur3, _refs$doubleRight$cur4;
675
+
676
+ (_refs$doubleRight$cur3 = refs.doubleRight.current) === null || _refs$doubleRight$cur3 === void 0 ? void 0 : (_refs$doubleRight$cur4 = _refs$doubleRight$cur3.instance) === null || _refs$doubleRight$cur4 === void 0 ? void 0 : _refs$doubleRight$cur4.option('disabled', true);
669
677
  }
670
678
 
671
679
  if (moment(time).diff(firstDayOfMax) > -1) {
672
- refs.doubleRight.current.disabled = true;
673
- refs.right.current.disabled = true;
680
+ var _refs$doubleRight$cur5, _refs$doubleRight$cur6, _refs$right$current2, _refs$right$current2$;
681
+
682
+ (_refs$doubleRight$cur5 = refs.doubleRight.current) === null || _refs$doubleRight$cur5 === void 0 ? void 0 : (_refs$doubleRight$cur6 = _refs$doubleRight$cur5.instance) === null || _refs$doubleRight$cur6 === void 0 ? void 0 : _refs$doubleRight$cur6.option('disabled', true);
683
+ (_refs$right$current2 = refs.right.current) === null || _refs$right$current2 === void 0 ? void 0 : (_refs$right$current2$ = _refs$right$current2.instance) === null || _refs$right$current2$ === void 0 ? void 0 : _refs$right$current2$.option('disabled', true);
674
684
  }
675
685
  }
676
686
  };
677
- /**
678
- *
679
- * @param {Date} time
680
- * @param {Object} navigatorRefs
681
- * @param {Date} min
682
- * @param {Date} max
683
- * @param {Element} table
684
- * @param {Date} activeValue
685
- * @param {Object} className
686
- * @param {Boolean} displayAnotherMonth
687
- * @param {Function} onTableDataClick
688
- * @param {Function} onUpdateNavigatorValue
687
+ /**
688
+ *
689
+ * @param {Date} time
690
+ * @param {Object} navigatorRefs
691
+ * @param {Date} min
692
+ * @param {Date} max
693
+ * @param {Element} table
694
+ * @param {Date} activeValue
695
+ * @param {Object} className
696
+ * @param {Boolean} displayAnotherMonth
697
+ * @param {Function} onTableDataClick
698
+ * @param {Function} onUpdateNavigatorValue
689
699
  */
690
700
 
691
701
 
@@ -41,8 +41,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
41
41
  limit: 'DGN-UI-Calendar-Day-limit'
42
42
  }
43
43
  };
44
- /**
45
- * START REFERENCE
44
+ /**
45
+ * START REFERENCE
46
46
  */
47
47
 
48
48
  const ref = useRef(null);
@@ -61,12 +61,12 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
61
61
  };
62
62
  const firstDayOfMax = new Date(new Date(max).setDate(1)).setHours(0, 0, 0, 0);
63
63
  const firstDayOfMin = new Date(new Date(min).setDate(1)).setHours(0, 0, 0, 0);
64
- /**
65
- * END REFERENCE
64
+ /**
65
+ * END REFERENCE
66
66
  */
67
67
 
68
- /**
69
- * START FUNCTION
68
+ /**
69
+ * START FUNCTION
70
70
  */
71
71
 
72
72
  const onUpdateNavigatorValue = useCallback(value => {
@@ -152,12 +152,12 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
152
152
  onUpdateCalendar(time, navigatorRefs, min, max, tableRef.current, activeValue.current, unique, displayAnotherMonth, onDayClick, onUpdateNavigatorValue);
153
153
  }
154
154
  };
155
- /**
156
- * END FUNCTION
155
+ /**
156
+ * END FUNCTION
157
157
  */
158
158
 
159
- /**
160
- * START EFFECT
159
+ /**
160
+ * START EFFECT
161
161
  */
162
162
 
163
163
 
@@ -198,12 +198,12 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
198
198
  onUpdate(activeValue.current);
199
199
  }
200
200
  }, [onClick, min, max]);
201
- /**
202
- * END FUNCTION
201
+ /**
202
+ * END FUNCTION
203
203
  */
204
204
 
205
- /**
206
- * START COMPONENT
205
+ /**
206
+ * START COMPONENT
207
207
  */
208
208
 
209
209
  const tableMemo = jsx("div", {
@@ -212,8 +212,8 @@ const Calendar = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
212
212
  className: unique.table.table,
213
213
  ref: tableRef
214
214
  }, renderHeader(unique), jsx("tbody", null)));
215
- /**
216
- * END COMPONENT
215
+ /**
216
+ * END COMPONENT
217
217
  */
218
218
 
219
219
  return jsx("div", { ...props,
@@ -101,9 +101,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
101
101
  labelProps,
102
102
  errorStyle,
103
103
  children,
104
- dropdownItemStyle
104
+ dropdownItemStyle,
105
+ searchExpr,
106
+ searchMode
105
107
  }, reference) => {
106
108
  if (multiple && selectBox === undefined) selectBox = true;
109
+ if (typeof searchExpr === 'string') searchExpr = [searchExpr];
107
110
  const ref = useRef(null);
108
111
  const dropdownRef = useRef(null);
109
112
  const loadingProgressRef = useRef(null);
@@ -122,6 +125,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
122
125
  }));
123
126
  const [openState, setOpenState] = useState(false);
124
127
  const [showClear, setShowClear] = useState(false);
128
+ const [textValue, setTextValue] = useState('');
125
129
 
126
130
  const _isMobile = isMobile.any();
127
131
 
@@ -169,6 +173,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
169
173
  };
170
174
 
171
175
  const onClickInput = e => {
176
+ if (disabled || readOnly || loading) return;
177
+
172
178
  if (!dropdownListRef.current) {
173
179
  if (!multiple || !Array.from(inputRef.current.querySelectorAll('.DGN-UI-Chip')).some(item => item.contains(e === null || e === void 0 ? void 0 : e.target))) {
174
180
  if ((typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none') && !multiple) {
@@ -231,7 +237,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
231
237
  const dropdownHeight = Math.min(Math.max(1, (itemMode === 'normal' ? dropdown.props.children : mapParent(dataSource, treeViewID, treeViewParentID)).length || 1), 7) * 40 + (multiple ? 43 : 0);
232
238
  let positionTop = top + height + 4;
233
239
 
234
- if (top + height + 4 + dropdownHeight > innerHeight) {
240
+ if (top + height + 4 + dropdownHeight + (allowSearch ? 40 : 0) > innerHeight) {
235
241
  if (top - dropdownHeight > 0) {
236
242
  positionTop = top - dropdownHeight;
237
243
  } else {
@@ -387,6 +393,29 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
387
393
  }
388
394
  };
389
395
 
396
+ const handleRenderBySearch = (data, searchValue) => {
397
+ let existExpr = [];
398
+ typeof data === 'object' ? existExpr = searchExpr.filter(value => Object.keys(data).includes(value)) : existExpr = [data];
399
+ return existExpr.every(key => {
400
+ // return searchByMode(data?.[key] || key.toString(), searchValue);
401
+ const _data = (data === null || data === void 0 ? void 0 : data[key]) || key.toString();
402
+
403
+ if (searchMode === 'contains') {
404
+ if (_data.indexOf(searchValue) !== -1) return false;
405
+ }
406
+
407
+ if (searchMode === 'startswith') {
408
+ if (_data.lastIndexOf(searchValue) === 0) return false;
409
+ }
410
+
411
+ if (searchMode === 'equals') {
412
+ if (_data == searchValue) return false;
413
+ }
414
+
415
+ return true;
416
+ });
417
+ };
418
+
390
419
  const mapDropdown = (pattern, keyArr) => {
391
420
  var _currentObjectDefault;
392
421
 
@@ -414,9 +443,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
414
443
  const length = dataSourceUsable.length;
415
444
 
416
445
  for (let index = 0; index < length; index++) {
446
+ var _searchExpr;
447
+
417
448
  const data = dataSourceUsable[index];
449
+ const itemHidden = typeof data === 'object' ? data['hidden'] : false;
450
+ if (itemHidden) continue;
418
451
  let displayText = typeof data === 'object' ? keyArr ? renderData(data, keyArr) : data[displayExpr] || data[valueExpr] : data;
419
- if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
452
+
453
+ if (((_searchExpr = searchExpr) === null || _searchExpr === void 0 ? void 0 : _searchExpr.length) > 0 && pattern) {
454
+ if (handleRenderBySearch(data, pattern)) continue;
455
+ } else if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
420
456
 
421
457
  if (renderItem && typeof renderItem === 'function') {
422
458
  displayText = renderItem({
@@ -785,11 +821,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
785
821
 
786
822
  if (timing[unique]) clearTimeout(timing[unique]);
787
823
  timing[unique] = setTimeout(() => {
824
+ var _searchExpr2;
825
+
788
826
  // if (timerRef.current) {
789
827
  // clearTimeout(timerRef.current);
790
828
  // timerRef.current = null;
791
829
  // }
792
- renderDropdown(new RegExp(value.normalize(), 'gim'));
830
+ renderDropdown(((_searchExpr2 = searchExpr) === null || _searchExpr2 === void 0 ? void 0 : _searchExpr2.length) > 0 ? value.normalize() : new RegExp(value.normalize(), 'gim'));
793
831
  }, timeout.current || searchDelayTime);
794
832
  };
795
833
 
@@ -931,6 +969,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
931
969
  }
932
970
  } else {
933
971
  inputRef.current.value = '';
972
+ setTextValue('');
934
973
  } // onChangeValue('', '');
935
974
 
936
975
 
@@ -962,6 +1001,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
962
1001
  inputRef.current.innerHTML = '';
963
1002
  } else if (!isSearch[unique]) {
964
1003
  inputRef.current.value = '';
1004
+ setTextValue('');
965
1005
  }
966
1006
 
967
1007
  currentValue[unique] = '';
@@ -1093,6 +1133,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1093
1133
  ReactDOM.render(valueWithIcon, inputRef.current.appendChild(el));
1094
1134
  } else {
1095
1135
  inputRef.current.value = text;
1136
+ setTextValue(text);
1096
1137
  }
1097
1138
  };
1098
1139
 
@@ -1325,14 +1366,26 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1325
1366
  return false;
1326
1367
  }
1327
1368
  }
1328
- }) : jsx("input", { ...inputProps,
1329
- style: inputStyle,
1369
+ }) : jsx(Fragment, null, jsx("input", { ...inputProps,
1370
+ style: openState || !textValue ? inputStyle : { ...inputStyle,
1371
+ visibility: 'hidden'
1372
+ },
1330
1373
  ref: inputRef,
1331
1374
  css: _DropdownInputCSS,
1332
1375
  type: "text",
1333
1376
  placeholder: placeholder,
1334
- disabled: disabled || openState && allowSearch
1335
- })), jsx("div", {
1377
+ disabled: disabled || allowSearch
1378
+ }), !openState && textValue && jsx(Typography, {
1379
+ hoverTooltip: true,
1380
+ lineClamp: 1,
1381
+ type: 'p1',
1382
+ css: _DropdownInputCSS,
1383
+ style: {
1384
+ position: 'absolute',
1385
+ lineHeight: '24px'
1386
+ },
1387
+ onClick: onClickInput
1388
+ }, textValue))), jsx("div", {
1336
1389
  ref: iconRef,
1337
1390
  css: _IconCSS,
1338
1391
  className: 'DGN-UI-Dropdown-Icon'
@@ -1356,7 +1409,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1356
1409
  },
1357
1410
  disabled: disabled || readOnly
1358
1411
  })));
1359
- }, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear]);
1412
+ }, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear, textValue]);
1360
1413
  const ErrorView = useMemo(() => error && jsx(HelperText, {
1361
1414
  disabled: disabled,
1362
1415
  style: {
@@ -1382,6 +1435,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1382
1435
 
1383
1436
  const InputCSS = (multiple, renderSelectedItem) => css`
1384
1437
  ${flexRow};
1438
+ ${positionRelative};
1385
1439
  width: 100%;
1386
1440
  ${!multiple && renderSelectedItem ? `width: calc(100% - 34px)` : ''}
1387
1441
  `;
@@ -1757,7 +1811,8 @@ Dropdown.defaultProps = {
1757
1811
  inputProps: {},
1758
1812
  formStyle: {},
1759
1813
  dataSource: [],
1760
- onInput: null
1814
+ onInput: null,
1815
+ searchMode: 'contains'
1761
1816
  };
1762
1817
  Dropdown.propTypes = {
1763
1818
  /**The variant to use. */
@@ -1928,6 +1983,12 @@ Dropdown.propTypes = {
1928
1983
  /** The contents in Dropdown box (Exp: TreeView). */
1929
1984
  children: PropTypes.node,
1930
1985
 
1986
+ /** Specifies a data object's field name or an expression whose value is compared to the search string. */
1987
+ searchExpr: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
1988
+
1989
+ /** Specifies a comparison operation used to search items. */
1990
+ searchMode: PropTypes.oneOf(['contains', 'startswith', 'equals']),
1991
+
1931
1992
  /**
1932
1993
  * ref methods
1933
1994
  *