diginet-core-ui 1.4.21 → 1.4.23-beta.1

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 (39) hide show
  1. package/assets/images/menu/dhr/MHRP39N0020.svg +9 -0
  2. package/assets/images/menu/dhr/MHRP39N0021.svg +7 -0
  3. package/assets/images/menu/eo/WEO76LIS0005.svg +6 -0
  4. package/assets/images/menu/eo/WEO76LIS0006.svg +14 -0
  5. package/assets/images/menu/eo/WEO76LIS0007.svg +19 -0
  6. package/assets/images/menu/eo/WEO76REQ0003.svg +15 -0
  7. package/components/accordion/details.js +12 -14
  8. package/components/accordion/group.js +12 -14
  9. package/components/accordion/index.js +36 -38
  10. package/components/accordion/summary.js +50 -51
  11. package/components/chip/index.js +61 -69
  12. package/components/form-control/calendar/function.js +1 -1
  13. package/components/form-control/date-input/DateField.js +189 -0
  14. package/components/form-control/date-input/index.js +301 -0
  15. package/components/form-control/date-input/useControlled.js +14 -0
  16. package/components/form-control/date-input/useDateInputState.js +132 -0
  17. package/components/form-control/date-input/useIsFocused.js +20 -0
  18. package/components/form-control/date-input/useKeyboardInputEvent.js +41 -0
  19. package/components/form-control/date-input/utils.js +286 -0
  20. package/components/form-control/date-picker/index.js +143 -422
  21. package/components/form-control/dropdown/index.js +259 -602
  22. package/components/form-control/input-base/UncontrolledInputBase.js +451 -0
  23. package/components/form-control/number-input/index2.js +4 -1
  24. package/components/form-control/time-picker/v2/index.js +792 -0
  25. package/components/image/index.js +22 -24
  26. package/components/index.js +2 -1
  27. package/components/modal/body.js +9 -11
  28. package/components/modal/footer.js +8 -10
  29. package/components/modal/header.js +27 -25
  30. package/components/modal/modal.js +33 -32
  31. package/components/tab/tab-container.js +57 -49
  32. package/components/tab/tab-header.js +72 -65
  33. package/components/tab/tab-panel.js +38 -32
  34. package/components/tab/tab.js +69 -61
  35. package/global/index.js +4 -0
  36. package/icons/effect.js +63 -58
  37. package/package.json +65 -33
  38. package/readme.md +17 -4
  39. package/theme/settings.js +78 -0
@@ -11,10 +11,7 @@ import { animation, bgColor, border, borderBottom, borderBottomColor, borderColo
11
11
  import { useTheme } from "../../../theme";
12
12
  import useThemeProps from "../../../theme/utils/useThemeProps";
13
13
  import { classNames, getProp, isMobile, randomString } from "../../../utils";
14
- const
15
- // timing = {},
16
- currentValue = {},
17
- // currentObjectDefault = {},
14
+ const currentValue = {},
18
15
  isSearch = {},
19
16
  allValue = {};
20
17
  const separatorPattern = /\{\w+\}/g;
@@ -70,8 +67,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
70
67
  clearAble,
71
68
  closeAfterSelect,
72
69
  dataSource,
73
- defaultValue,
74
- disabled,
75
70
  displayExpr: displayExprProp,
76
71
  dropdownItemStyle,
77
72
  error,
@@ -111,7 +106,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
111
106
  value: valueProp,
112
107
  valueExpr,
113
108
  valueObjectDefault,
114
- viewType
109
+ viewType,
110
+ defaultValue,
111
+ disabled
115
112
  } = props;
116
113
  const selectBox = multiple && selectBoxProp === undefined ? true : selectBoxProp;
117
114
  const searchExpr = typeof searchExprProp === 'string' ? [searchExprProp] : searchExprProp;
@@ -128,8 +125,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
128
125
  const iconRef = useRef(null);
129
126
  const dropdownListRef = useRef(null);
130
127
  const searchRef = useRef(null);
131
- // const lastSearchRef = useRef(null);
132
- // const timeout = useRef(null);
133
128
  const loadMoreTimer = useRef(null);
134
129
  const dataChosen = useRef([]);
135
130
  const popupRef = useRef(null);
@@ -166,7 +161,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
166
161
  const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
167
162
  const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, disabled, readOnly, multilineSelectedItem, theme);
168
163
  const _IconCSS = IconCSS(viewType, theme);
169
- const _DropdownFormCSS = DropdownFormCSS(viewType, multiple, disabled, readOnly, placeholder, _DropdownInputCSS.name, theme);
164
+ const _DropdownFormCSS = viewType === 'outlined' ? DropdownFormOutlinedCSS(disabled, readOnly, placeholder, theme) : DropdownFormCSS(viewType, multiple, disabled, readOnly, placeholder, _DropdownInputCSS.name, theme);
170
165
  const _DropdownListCSS = DropdownListCSS(loadingState, theme);
171
166
  const _DropdownItemCSS = DropdownItemCSS(multiple, selectBox, theme);
172
167
  const _DropdownRootCSS = DropdownRootCSS(_DropdownFormCSS.name, _DropdownInputCSS.name, theme);
@@ -192,26 +187,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
192
187
  }
193
188
  }
194
189
  };
195
-
196
- // const onClickOutsideOfInput = event => {
197
- // if (
198
- // inputRef.current &&
199
- // !inputRef.current?.contains(event?.target) &&
200
- // iconRef.current &&
201
- // !iconRef.current?.contains(event?.target) &&
202
- // dropdownListRef.current &&
203
- // !dropdownListRef.current?.parentNode?.parentNode?.contains(event?.target)
204
- // ) {
205
- // closeDropdown();
206
- // triggerBlur(false);
207
- // }
208
- // };
209
-
210
190
  const showDropdown = () => {
211
- // if (displayExpr && Array.isArray(displayExpr)) {
212
- // displayExpr = displayExpr.join(' - ');
213
- // }
214
- // const keyArr = displayExpr?.match(separatorPattern);
215
191
  const dropdown = children ? jsx("div", {
216
192
  css: _DropdownListCSS,
217
193
  ref: dropdownListRef,
@@ -220,33 +196,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
220
196
  onScroll: onLoadMoreHandler,
221
197
  tabIndex: -1
222
198
  }, dataSourceState !== null && dataSourceState !== void 0 && dataSourceState.length ? children : EmptyDataText) : itemMode === 'normal' ? mapDropdown() : mapTreeView();
223
- // const { innerHeight } = window;
224
- // const { top, left, height, width } = formRef.current.getBoundingClientRect();
225
-
226
- // Calculate to set position of Dropdown box
227
- // const dropdownHeight =
228
- // Math.min(
229
- // Math.max(
230
- // 1,
231
- // (itemMode === 'normal'
232
- // ? dropdown.props.children
233
- // : mapParent(dataSource, treeViewID, treeViewParentID)
234
- // ).length || 1
235
- // ),
236
- // 7
237
- // ) *
238
- // 40 +
239
- // (multiple ? 43 : 0);
240
- // let positionTop = top + height + 4;
241
- // if (top + height + 4 + dropdownHeight + (allowSearch ? 40 : 0) > innerHeight) {
242
- // if (top - dropdownHeight > 0) {
243
- // positionTop = top - dropdownHeight;
244
- // } else {
245
- // positionTop = innerHeight - dropdownHeight;
246
- // }
247
- // }
248
- // const _DropdownCSS = DropdownCSS(positionTop, left, width, _isMobile, allowSearch);
249
- const el = jsx(Fragment, null, (multiple || allowSearch) && itemMode === 'normal' && !children ? jsx("div", {
199
+ return jsx(Fragment, null, (multiple || allowSearch) && itemMode === 'normal' && !children ? jsx("div", {
250
200
  className: 'DGN-Dropdown-Search'
251
201
  }, jsx(InputBase, {
252
202
  inputRef: searchRef,
@@ -272,20 +222,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
272
222
  }, jsx(CircularProgress, {
273
223
  size: 24
274
224
  })) : null);
275
- // if (!((multiple || allowSearch) && itemMode === 'normal' && !children)) {
276
- // inputRef.current.addEventListener('keydown', pressESCHandler);
277
- // }
278
- // document.documentElement.style.overflow = 'hidden';
279
- // setTimeout(() => {
280
- // window.addEventListener('resize', customizeWidthDropdown);
281
- // document.addEventListener('wheel', onWheelHandler);
282
- // document.addEventListener('mousedown', onClickOutsideOfInput);
283
- // if (onLoadMore && dataSourceState.length < totalState) {
284
- // dropdownListRef.current &&
285
- // dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
286
- // }
287
- // }, 10);
288
- return el;
289
225
  };
290
226
  const moveOnItem = e => {
291
227
  if (e.key === 'Escape' || e.key === 'Tab') {
@@ -313,55 +249,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
313
249
  dropdownListRef.current.firstChild.focus();
314
250
  }
315
251
  };
316
-
317
- // const onWheelHandler = e => {
318
- // if (!dropdownRef.current) {
319
- // document.removeEventListener('wheel', onWheelHandler);
320
- // return;
321
- // }
322
- // if (!dropdownRef.current?.contains(e.target)) {
323
- // closeDropdown();
324
- // triggerBlur();
325
- // }
326
- // };
327
-
328
252
  const closeDropdown = () => {
329
253
  var _searchRef$current;
330
254
  if (dropdownRef.current) {
331
255
  setOpenState(false);
332
- // document.removeEventListener('mousedown', onClickOutsideOfInput);
333
- // window.removeEventListener('resize', customizeWidthDropdown);
334
- // document.removeEventListener('wheel', onWheelHandler);
335
- // if (onLoadMore && dropdownListRef.current) {
336
- // dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
337
- // dropdownListRef.current = null;
338
- // }
339
- }
340
- // document.documentElement.style.overflow = 'auto';
341
- // setTxtSearch('');
256
+ }
342
257
  onClosed === null || onClosed === void 0 ? void 0 : onClosed({
343
258
  recentSearch: (_searchRef$current = searchRef.current) === null || _searchRef$current === void 0 ? void 0 : _searchRef$current.value
344
259
  });
345
260
  };
346
261
 
347
- // const renderDropdown = pattern => {
348
- // const keyArr = displayExpr?.match(separatorPattern);
349
- // const dropdown = mapDropdown(pattern, keyArr);
350
- // const el = document.createElement('div');
351
- // el.className = `DGN-Dropdown-Box`;
352
- // if (dropdownRef.current) {
353
- // dropdownRef.current.querySelector('.DGN-Dropdown-Box')?.remove();
354
- // ReactDOM.render(dropdown, dropdownRef.current.appendChild(el));
355
- // setTimeout(() => {
356
- // if (onLoadMore && dataSource.length < total) {
357
- // dropdownListRef.current &&
358
- // dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
359
- // }
360
- // updatePositionDropdown();
361
- // }, 0);
362
- // }
363
- // };
364
-
365
262
  /**
366
263
  * So sánh text đầu vào cáo map với txtSearch
367
264
  * @param text
@@ -427,11 +324,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
427
324
  if (++existItemQuantity > limit) {
428
325
  continue;
429
326
  }
430
- // currentObjectDefault[unique].splice(index, 1);
431
327
  }
432
328
  }
433
329
  }
434
-
435
330
  const length = (_dataSourceUsable2 = dataSourceUsable) === null || _dataSourceUsable2 === void 0 ? void 0 : _dataSourceUsable2.length;
436
331
  for (let index = 0; index < length; index++) {
437
332
  const data = dataSourceUsable[index];
@@ -439,11 +334,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
439
334
  const itemHidden = typeof data === 'object' ? data['hidden'] : false;
440
335
  if (itemHidden) continue;
441
336
  let displayText = displayValue(data);
442
-
443
- // if (searchExpr?.length > 0 && pattern) {
444
- // if (handleRenderBySearch(data, pattern)) continue;
445
- // } else if (pattern && !new RegExp(pattern).test(displayText.normalize())) continue;
446
-
447
337
  if (subText) {
448
338
  displayText = jsx(Fragment, null, jsx(Typography, {
449
339
  className: 'DGN-UI-Dropdown-PrimaryText',
@@ -473,19 +363,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
473
363
  items.push(jsx("div", {
474
364
  key: index,
475
365
  css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
476
- className: 'DGN-UI-Dropdown-Item'
477
- // onClick={() => {
478
- // if (itemDisabled) return;
479
- // onChangeValueWithCheckbox(e) & onChangeValue(displayText, value, icon, data, index);
480
- // onChangeValue(displayText, value, icon, data, index);
481
- // }}
482
- ,
366
+ className: 'DGN-UI-Dropdown-Item',
483
367
  onKeyDown: e => {
484
368
  if (itemDisabled) return;
485
369
  if (e.key === 'Enter') e.currentTarget.firstChild.click();
486
- // if (e.key === 'Enter') onChangeValue(displayText, value, icon, data, index);
487
370
  },
488
-
489
371
  tabIndex: -1
490
372
  }, jsx(Checkbox, {
491
373
  css: _CheckBoxCSS,
@@ -632,22 +514,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
632
514
  }
633
515
  }
634
516
  };
635
-
636
- // const renderData = (data, keyArr) => {
637
- // const pattern = keyArr.join('|').replace(/([{}])/g, '\\$1');
638
- // const separatorArr = displayExpr.split(new RegExp(pattern));
639
- // let str = '';
640
- // let i = 0;
641
- // for (i; i < keyArr.length; i++) {
642
- // str +=
643
- // separatorArr[i] +
644
- // (data[keyArr[i].replace(/\W/g, '')] !== undefined
645
- // ? data[keyArr[i].replace(/\W/g, '')]
646
- // : keyArr[i]);
647
- // }
648
- // return str + separatorArr[i];
649
- // };
650
-
651
517
  const getIconFromData = (data, insideChip = false) => {
652
518
  if (!data || !iconExpr || iconExpr === 'none') return null;
653
519
  let _src;
@@ -674,18 +540,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
674
540
  });
675
541
  };
676
542
  const customizeWidthDropdown = () => {
677
- // if (dropdownListRef.current && _isMobile)
678
- // dropdownListRef.current.style.maxHeight = `${
679
- // Math.min(280, window.innerHeight) - (allowSearch ? 40 : 0)
680
- // }px`;
681
543
  if (timer.current) {
682
544
  clearTimeout(timer.current);
683
545
  }
684
546
  timer.current = setTimeout(() => {
685
- // if (!ref.current) {
686
- // window.removeEventListener('resize', customizeWidthDropdown);
687
- // return;
688
- // } else {
689
547
  if (ref.current) {
690
548
  const {
691
549
  width
@@ -693,23 +551,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
693
551
  setPopoverWidth(width);
694
552
  }
695
553
  }, 300);
696
-
697
- // if (dropdownRef.current) {
698
- // dropdownRef.current.style.width = width + 'px';
699
- // }
700
- // updatePositionDropdown();
701
554
  };
702
-
703
- // const updatePositionDropdown = () => {
704
- // if (!formRef.current || !dropdownRef.current) {
705
- // // document.removeEventListener('wheel', onWheelHandler);
706
- // return;
707
- // }
708
- // _isMobile
709
- // ? updatePosition(formRef.current, dropdownRef.current, null)
710
- // : updatePosition(formRef.current, dropdownRef.current, closeDropdown);
711
- // };
712
-
713
555
  const handleActionLoadData = isReset => {
714
556
  const {
715
557
  skip,
@@ -805,50 +647,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
805
647
  var _e$target$value;
806
648
  if (!dropdownRef.current) return; // Kiểm tra nếu dropdown đóng trước searchDelayTime thì không chạy
807
649
  setTxtSearch((_e$target$value = e.target.value) !== null && _e$target$value !== void 0 ? _e$target$value : '');
808
- // if (searchRef.current) lastSearchRef.current = searchRef.current.value;
809
- // const dataFilter = getData();
810
- // dataChosen.current = [...dataFilter].filter(i => [...valueMulti].includes(i?.[valueExpr]));
811
650
  if (onInput) {
812
- // isSearch[unique] = true;
813
- // const valueInput = e.target.value;
814
- // const text = (valueInput || e.target.textContent).normalize();
815
- // if (timeout.current) {
816
- // if (timing[unique]) {
817
- // clearTimeout(timing[unique]);
818
- // }
819
- // timing[unique] = setTimeout(() => {
820
- // e.target.value = text;
821
651
  onInput(e);
822
- // e.target.value = valueInput;
823
- // }, timeout.current || searchDelayTime);
824
- // } else {
825
- // e.target.value = text;
826
- // onInput(e);
827
- // e.target.value = valueInput;
828
- // }
829
- // return;
830
652
  }
831
-
832
653
  if (action !== null && action !== void 0 && action.loadData && !!onLoadMore) {
833
654
  filter.current.strSearch = e.target.value;
834
655
  handleActionLoadData(true);
835
656
  }
836
- // const value = e.target.value || e.target.textContent;
837
- // if (
838
- // typeof renderSelectedItem === 'function' &&
839
- // e.target.childNodes &&
840
- // Array.from(e.target.childNodes).some(node => node.toString() !== '[object Text]')
841
- // ) {
842
- // const cursor = document.getSelection().anchorOffset;
843
- // e.target.innerHTML = value;
844
- // document.getSelection().collapse(e.target, cursor);
845
- // }
846
- // if (timing[unique]) clearTimeout(timing[unique]);
847
- // timing[unique] = setTimeout(() => {
848
- // renderDropdown(searchExpr?.length > 0 ? value.normalize() : new RegExp(value.normalize(), 'gim'));
849
- // }, timeout.current || searchDelayTime);
850
657
  };
851
-
852
658
  const onChangeValue = (displayText, value, icon, data) => {
853
659
  if (itemMode === 'treeview') {
854
660
  if (valueProp === undefined) {
@@ -859,9 +665,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
859
665
  !!onChange && onChange({
860
666
  value
861
667
  });
862
- // setTimeout(() => {
863
- // updatePositionDropdown();
864
- // }, 0);
865
668
  } else if (multiple) {
866
669
  if (!Array.isArray(currentValue[unique])) currentValue[unique] = [];
867
670
  // const newValueArr = [...currentValue[unique]];
@@ -869,46 +672,15 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
869
672
  if (!newValueArrState.some(v => JSON.stringify(v) === JSON.stringify(value))) {
870
673
  // newValueArr.push(value);
871
674
  newValueArrState.push(value);
872
- // if (valueProp === undefined) {
873
- // let item = null;
874
- // if (typeof renderSelectedItem === 'function') {
875
- // item = renderSelextedItem({ data, index });
876
- // } else {
877
- // item = (
878
- // <Chip
879
- // startIcon={icon}
880
- // label={displayText}
881
- // size={itemMultipleSize}
882
- // disabled={disabled}
883
- // clearAble
884
- // onRemove={e => onRemove(e, value)}
885
- // style={{ margin: '3px 0', width: '100%' }}
886
- // />
887
- // );
888
- // }
889
- // const el = document.createElement('div');
890
- // el.className = 'dropdown-item';
891
- // el.style.display = 'flex';
892
- // ReactDOM.render(item, inputRef.current.appendChild(el));
893
- // }
894
675
  } else {
895
676
  const index = newValueArrState.indexOf(value);
896
- // newValueArr.splice(index, 1);
897
677
  newValueArrState.splice(index, 1);
898
- // if (valueProp === undefined) {
899
- // const nodes = inputRef.current.querySelectorAll('.dropdown-item');
900
- // nodes[index]?.remove();
901
- // }
902
678
  }
903
-
904
679
  setValueMulti(newValueArrState);
905
680
  !!onChange && onChange({
906
681
  value: newValueArrState,
907
682
  data
908
683
  });
909
- // setTimeout(() => {
910
- // updatePositionDropdown();
911
- // }, 0);
912
684
  } else {
913
685
  const isChanged = currentValue[unique] !== value;
914
686
  if (isChanged) {
@@ -929,39 +701,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
929
701
  if (closeAfterSelect === true || closeAfterSelect === undefined && !multiple) {
930
702
  closeDropdown();
931
703
  }
932
- // else {
933
- // setTimeout(() => {
934
- // updatePositionDropdown();
935
- // }, 0);
936
- // }
937
704
  };
938
-
939
- // const onChangeValueWithCheckbox = e => {
940
- // const firstChild = e.currentTarget.firstChild;
941
- // if (!firstChild.contains(e.target)) {
942
- // firstChild.click();
943
- // }
944
- // };
945
-
946
705
  const onRemove = (e, value) => {
947
706
  var _ref;
948
707
  if (readOnly || disabled) return;
949
708
  const index = currentValue[unique].findIndex(v => JSON.stringify(v) === JSON.stringify(value));
950
709
  if (index !== -1) {
951
710
  currentValue[unique].splice(index, 1);
952
- // setTimeout(() => {
953
- // if (dropdownListRef.current && multiple && selectBox && !children) {
954
- // const input = dropdownListRef.current.querySelector(`input[value="${value}"]`);
955
- // if (input) {
956
- // input.checked = false;
957
- // }
958
- // }
959
- // e?.parentNode?.remove();
960
- // }, 0);
961
- // }, 0);
962
- // }, 0);
963
- // setValueMulti([...valueMulti]?.filter(i=>i!==value) || []);
964
- // !!onChange && onChange({ value: currentValue[unique], removed: value });
965
711
  }
966
712
 
967
713
  // logic mới
@@ -977,18 +723,12 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
977
723
  currentValue[unique] = multiple ? [] : '';
978
724
  if (multiple) {
979
725
  setValueMulti([]);
980
- // inputRef.current.innerHTML = '';
981
- // if (dropdownListRef.current) {
982
- // dropdownListRef.current.querySelectorAll('input').forEach(input => (input.checked = false));
983
- // }
984
726
  } else {
985
727
  setValueSingle('');
986
728
  }
987
- // onChangeValue('', '');
988
729
  setValueMulti([]);
989
730
  setShowClear(false);
990
731
  e && e.target && e.target.blur();
991
- // updatePositionDropdown();
992
732
  onInput === null || onInput === void 0 ? void 0 : onInput({
993
733
  ...(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current),
994
734
  target: {
@@ -1007,17 +747,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1007
747
  const setValueIntoInput = source => {
1008
748
  if (!source && source !== 0) {
1009
749
  if (multiple) {
1010
- // inputRef.current.innerHTML = '';
1011
750
  currentValue[unique] = [];
1012
751
  } else {
1013
- // if (
1014
- // typeof renderSelectedItem === 'function' ||
1015
- // (iconExpr && iconExpr !== 'none' && !isSearch[unique])
1016
- // ) {
1017
- // inputRef.current.innerHTML = '';
1018
- // } else if (!isSearch[unique]) {
1019
- // inputRef.current.value = '';
1020
- // }
1021
752
  currentValue[unique] = '';
1022
753
  setValueSingle('');
1023
754
  }
@@ -1036,7 +767,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1036
767
  }
1037
768
  valueArr = [...new Set(valueArr)];
1038
769
  currentValue[unique] = [];
1039
- // inputRef.current.innerHTML = '';
1040
770
  valueArr.forEach(v => {
1041
771
  for (let i = 0; i < length; i++) {
1042
772
  if (!dataSourceState[i]) continue;
@@ -1068,34 +798,9 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1068
798
  return;
1069
799
  }
1070
800
  }
1071
- if (!isSearch[unique]) {
1072
- // inputRef.current.value = source;
1073
- }
1074
801
  }
1075
802
  };
1076
803
  const setMultipleValueHandler = (data, value) => {
1077
- // let item = null;
1078
- // if (typeof renderSelectedItem === 'function') {
1079
- // item = renderSelectedItem({ data, index });
1080
- // } else {
1081
- // const icon = getIconFromData(data);
1082
- // const text = keyArr ? renderData(data, keyArr) : data[renderSelectedItem || displayExpr];
1083
- // item = (
1084
- // <Chip
1085
- // startIcon={icon}
1086
- // label={text}
1087
- // size={itemMultipleSize}
1088
- // disabled={disabled}
1089
- // clearAble
1090
- // onRemove={e => onRemove(e, value)}
1091
- // style={{ margin: '3px 0', width: '100%' }}
1092
- // />
1093
- // );
1094
- // }
1095
- // const el = document.createElement('div');
1096
- // el.className = 'dropdown-item';
1097
- // el.style.display = 'flex';
1098
- // ReactDOM.render(item, inputRef.current.appendChild(el));
1099
804
  currentValue[unique].push(value);
1100
805
  };
1101
806
  const setSingleValueHandler = (data, keyArr) => {
@@ -1106,33 +811,21 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1106
811
  hoverTooltip: !_isMobile
1107
812
  }, content);
1108
813
  if (typeof renderSelectedItem === 'function') {
1109
- // inputRef.current.innerHTML = '';
1110
814
  const item = renderSelectedItem({
1111
815
  data
1112
816
  });
1113
- // const el = document.createElement('div');
1114
- // el.style.display = 'flex';
1115
- // el.style.width = '100%';
1116
- // el.style.minHeight = '24px';
1117
- // if (!multilineSelectedItem) el.style.maxHeight = '24px';
1118
817
  const el = jsx("div", {
1119
818
  css: [displayFlex, parseWidth('100%'), parseMinHeight(24), !multilineSelectedItem && parseMaxHeight(24)]
1120
819
  }, item);
1121
820
  setValueSingle(el);
1122
- // ReactDOM.render(item, inputRef.current.appendChild(el));
1123
821
  } else if (iconExpr && iconExpr !== 'none') {
1124
- // inputRef.current.innerHTML = '';
1125
822
  const icon = getIconFromData(data);
1126
823
  const valueWithIcon = jsx(Fragment, null, icon && icon, renderContent(text));
1127
- // const el = document.createElement('div');
1128
- // el.style.cssText = 'display: flex; align-items: center; min-height:24px;';
1129
824
  const el = jsx("div", {
1130
825
  css: [displayFlex, itemsCenter, parseMinHeight(24)]
1131
826
  }, valueWithIcon);
1132
827
  setValueSingle(el);
1133
- // ReactDOM.render(valueWithIcon, inputRef.current.appendChild(el));
1134
828
  } else {
1135
- // inputRef.current.value = text;
1136
829
  setValueSingle(text);
1137
830
  }
1138
831
  };
@@ -1200,51 +893,26 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1200
893
  }
1201
894
  if (valueObjectDefault) {
1202
895
  if (Array.isArray(valueObjectDefault)) {
1203
- // currentObjectDefault[unique] = [...valueObjectDefault];
1204
896
  setVlObjDefaultState([...dataChosen.current, ...valueObjectDefault]);
1205
897
  } else if (typeof valueObjectDefault === 'object') {
1206
898
  var _Object$keys;
1207
- // currentObjectDefault[unique] =
1208
- // Object.keys(valueObjectDefault).length !== 0 ? [valueObjectDefault] : [];
1209
899
  setVlObjDefaultState(((_Object$keys = Object.keys(valueObjectDefault)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length) !== 0 ? [...dataChosen.current, valueObjectDefault] : [...dataChosen.current]);
1210
900
  }
1211
901
  } else {
1212
- // currentObjectDefault[unique] = [];
1213
902
  setVlObjDefaultState([...dataChosen.current]);
1214
903
  }
1215
904
  }, [valueObjectDefault, valueMulti]);
1216
905
  useEffect(() => {
1217
906
  allValue[unique] = [];
1218
- if (defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
907
+ if (action !== null && action !== void 0 && action.loadData) handleActionLoadData(true);else if (defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
1219
908
  setValueIntoInput(defaultValue);
1220
909
  setShowClear(clearAble && checkHasValue(defaultValue) && !disabled && !readOnly && !loadingState);
1221
910
  }
1222
- if (action !== null && action !== void 0 && action.loadData) handleActionLoadData();
1223
911
  return () => {
1224
912
  allValue[unique] = null;
1225
913
  closeDropdown();
1226
914
  };
1227
915
  }, []);
1228
-
1229
- // useEffect(() => {
1230
- // if (searchDelayTime) {
1231
- // if (searchDelayTime === true) searchDelayTime = getGlobal('delayOnInput');
1232
- // const units = {
1233
- // m: 60000,
1234
- // s: 1000,
1235
- // ms: 1,
1236
- // };
1237
- // timeout.current =
1238
- // typeof searchDelayTime === 'number'
1239
- // ? searchDelayTime
1240
- // : (searchDelayTime.match(/[^a-z]+/i)?.[0] || 1) *
1241
- // units[searchDelayTime.match(/ms|s|m/i)?.[0] || 's'];
1242
- // return () => {
1243
- // timeout.current = null;
1244
- // };
1245
- // }
1246
- // }, [searchDelayTime]);
1247
-
1248
916
  useEffect(() => {
1249
917
  var _allValue$unique4;
1250
918
  if (allValue[unique][((_allValue$unique4 = allValue[unique]) === null || _allValue$unique4 === void 0 ? void 0 : _allValue$unique4.length) - 1] !== valueProp) {
@@ -1265,11 +933,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1265
933
  }, [valueProp, dataSourceState, vlObjDefaultState]);
1266
934
  useEffect(() => {
1267
935
  inputRef.current.readOnly = readOnly || inputProps.readOnly;
1268
- // if (!readOnly && !disabled) {
1269
- // !!onLoadMore &&
1270
- // dropdownListRef.current &&
1271
- // dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
1272
- // }
1273
936
  if (disabled || readOnly || children) {
1274
937
  inputRef.current.addEventListener('keydown', onPreventKeyDownHandler);
1275
938
  } else {
@@ -1309,9 +972,6 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1309
972
  const length = (_dropdownListRef$curr2 = dropdownListRef.current) === null || _dropdownListRef$curr2 === void 0 ? void 0 : (_dropdownListRef$curr3 = _dropdownListRef$curr2.children) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.length;
1310
973
  if (length < (dataSourceState === null || dataSourceState === void 0 ? void 0 : dataSourceState.length) + (vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) && !isSearch[unique]) {
1311
974
  loadMoreItemsDropdown(length);
1312
- // !!onLoadMore &&
1313
- // dataSourceState.length < totalState &&
1314
- // dropdownListRef.current.addEventListener('scroll', onLoadMoreHandler);
1315
975
  } else {
1316
976
  isSearch[unique] = false;
1317
977
  }
@@ -1320,13 +980,16 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1320
980
  inputRef.current.addEventListener('input', onChangeInput);
1321
981
  }
1322
982
  }
983
+ // Fix set defaultValue before action loadData
984
+ if (action !== null && action !== void 0 && action.loadData && (!valueSingle || (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) === 0) && defaultValue !== undefined && JSON.stringify(defaultValue) !== '[]') {
985
+ setValueIntoInput(defaultValue);
986
+ setShowClear(clearAble && checkHasValue(defaultValue) && !disabled && !readOnly && !loadingState);
987
+ }
1323
988
  return () => {
1324
989
  if (inputRef.current) {
1325
990
  inputRef.current.removeEventListener('input', onChangeInput);
1326
991
  inputRef.current.removeEventListener('click', onClickInput);
1327
992
  }
1328
- // !!dropdownListRef.current &&
1329
- // dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
1330
993
  };
1331
994
  }, [dataSourceState]);
1332
995
  useEffect(() => {
@@ -1360,121 +1023,111 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1360
1023
  }, label) : null, [label, required, disabled, labelProps]);
1361
1024
  const getData = () => {
1362
1025
  let dataFilter = JSON.parse(JSON.stringify(dataSourceState));
1363
- // dataFilter = [...dataFilter, ...dataChosen.current];
1364
- // if (Array.isArray(valueObjectDefault)) {
1365
- // dataFilter = [...dataFilter, ...vlObjDefaultState];
1366
- // } else if (typeof valueObjectDefault === 'object') {
1367
- // dataFilter = [...dataFilter, { ...vlObjDefaultState }];
1368
- // }
1369
1026
  dataFilter = uniqBy([...vlObjDefaultState, ...dataFilter], data => data === null || data === void 0 ? void 0 : data[valueExpr]);
1370
1027
  return dataFilter;
1371
1028
  };
1372
- const InputView = useMemo(() => {
1373
- return jsx("div", {
1374
- css: _DropdownFormCSS,
1375
- ref: formRef,
1376
- className: classNames('DGN-UI-Dropdown-Form', openState && 'dropdown-showing')
1377
- }, jsx("div", {
1378
- css: _InputCSS,
1379
- className: 'DGN-UI-Dropdown-Form-Input'
1380
- }, multiple && valueMulti !== null && valueMulti !== void 0 && valueMulti.length ? jsx("div", {
1381
- ...inputProps,
1382
- style: inputStyle,
1383
- ref: inputRef,
1384
- css: [_DropdownInputCSS],
1385
- className: classNames('dgn-dropdown-multiple', inputProps.className),
1386
- onChange: e => {
1029
+ const InputView = jsx("div", {
1030
+ css: _DropdownFormCSS,
1031
+ ref: formRef,
1032
+ className: classNames('DGN-UI-Dropdown-Form', openState && 'dropdown-showing')
1033
+ }, jsx("div", {
1034
+ css: _InputCSS,
1035
+ className: 'DGN-UI-Dropdown-Form-Input'
1036
+ }, multiple && valueMulti !== null && valueMulti !== void 0 && valueMulti.length ? jsx("div", {
1037
+ ...inputProps,
1038
+ style: inputStyle,
1039
+ ref: inputRef,
1040
+ css: [_DropdownInputCSS],
1041
+ className: classNames('dgn-dropdown-multiple', inputProps.className),
1042
+ onChange: e => {
1043
+ e.preventDefault();
1044
+ return false;
1045
+ }
1046
+ }, valueMulti.map((vl, index) => {
1047
+ const dataFilter = getData();
1048
+ const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1049
+ if (data) {
1050
+ const displayText = displayValue(data);
1051
+ let item;
1052
+ if (typeof renderSelectedItem === 'function') {
1053
+ item = renderSelectedItem({
1054
+ data,
1055
+ index
1056
+ });
1057
+ } else {
1058
+ item = jsx(Chip, {
1059
+ css: [parseWidth('100%'), parseMaxWidth('max-content')],
1060
+ key: index,
1061
+ startIcon: getIconFromData(data, true),
1062
+ label: displayText,
1063
+ size: 'medium',
1064
+ disabled: disabled,
1065
+ clearAble: !readOnly && !disabled,
1066
+ onRemove: e => onRemove(e, vl)
1067
+ });
1068
+ }
1069
+ return item;
1070
+ }
1071
+ })) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", {
1072
+ ...inputProps,
1073
+ style: inputStyle,
1074
+ ref: inputRef,
1075
+ css: _DropdownInputCSS,
1076
+ className: classNames('dgn-dropdown-multiple', inputProps.className),
1077
+ onKeyDown: e => {
1078
+ if (e.key === 'Enter') {
1387
1079
  e.preventDefault();
1388
1080
  return false;
1389
1081
  }
1390
- }, valueMulti.map((vl, index) => {
1391
- const dataFilter = getData();
1392
- const data = dataFilter.find(v => v[valueExpr] === vl || v === vl);
1393
- if (data) {
1394
- const displayText = displayValue(data);
1395
- let item;
1396
- if (typeof renderSelectedItem === 'function') {
1397
- item = renderSelectedItem({
1398
- data,
1399
- index
1400
- });
1401
- } else {
1402
- item = jsx(Chip, {
1403
- css: [parseWidth('100%'), parseMaxWidth('max-content')],
1404
- key: index,
1405
- startIcon: getIconFromData(data, true),
1406
- label: displayText,
1407
- size: 'medium',
1408
- disabled: disabled,
1409
- clearAble: !readOnly && !disabled,
1410
- onRemove: e => onRemove(e, vl)
1411
- });
1412
- }
1413
- return item;
1414
- }
1415
- })) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", {
1416
- ...inputProps,
1417
- style: inputStyle,
1418
- ref: inputRef,
1419
- css: _DropdownInputCSS,
1420
- className: classNames('dgn-dropdown-multiple', inputProps.className),
1421
- onKeyDown: e => {
1422
- if (e.key === 'Enter') {
1423
- e.preventDefault();
1424
- return false;
1425
- }
1426
- }
1427
- }, valueSingle) : jsx("div", {
1428
- css: _DropdownInputCSS,
1429
- onClick: onClickInput
1430
- }, jsx(Typography, {
1431
- ref: inputRef,
1432
- hoverTooltip: true,
1433
- lineClamp: multilineSelectedItem ? undefined : 1,
1434
- type: 'p1',
1435
- style: {
1436
- lineHeight: multiple ? '30px' : '24px'
1437
- },
1438
- tabIndex: -1
1439
- }, valueSingle))), jsx("div", {
1440
- ref: iconRef,
1441
- css: _IconCSS,
1442
- className: 'DGN-UI-Dropdown-Icon'
1443
- }, loadingState ? jsx(CircularProgress, {
1444
- size: 24
1445
- }) : null, showClear ? jsx(ButtonIcon, {
1446
- css: css`
1447
- margin-right: ${spacing([1])};
1448
- `,
1449
- viewType: 'ghost',
1450
- name: 'Close',
1451
- onClick: onClear
1452
- }) : null, !loadingState ? jsx(ButtonIcon, {
1453
- key: openState,
1454
- css: animation,
1455
- viewType: 'ghost',
1456
- name: openState ? 'ArrowUp' : 'ArrowDown',
1457
- onClick: setShowDropdown,
1458
- disabled: disabled || readOnly
1459
- }) : null));
1460
- }, [openState, showClear, valueSingle, valueMulti, loadingState, dataSourceState, vlObjDefaultState, clearAble, dataSource, disabled, displayExpr, inputProps, inputStyle, multilineSelectedItem, multiple, onChange, placeholder, readOnly, renderSelectedItem, valueExpr, valueObjectDefault, viewType, theme]);
1082
+ }
1083
+ }, valueSingle) : jsx("div", {
1084
+ css: _DropdownInputCSS,
1085
+ onClick: onClickInput
1086
+ }, jsx(Typography, {
1087
+ ref: inputRef,
1088
+ hoverTooltip: true,
1089
+ lineClamp: multilineSelectedItem ? undefined : 1,
1090
+ type: 'p1',
1091
+ style: {
1092
+ lineHeight: multiple ? '30px' : '24px'
1093
+ },
1094
+ tabIndex: -1
1095
+ }, valueSingle))), jsx("div", {
1096
+ ref: iconRef,
1097
+ css: _IconCSS,
1098
+ className: 'DGN-UI-Dropdown-Icon'
1099
+ }, loadingState ? jsx(CircularProgress, {
1100
+ size: 24
1101
+ }) : null, showClear ? jsx(ButtonIcon, {
1102
+ css: css`
1103
+ margin-right: ${spacing([1])};
1104
+ `,
1105
+ viewType: 'ghost',
1106
+ name: 'Close',
1107
+ onClick: onClear
1108
+ }) : null, !loadingState ? jsx(ButtonIcon, {
1109
+ key: openState,
1110
+ css: animation,
1111
+ viewType: 'ghost',
1112
+ name: openState ? 'ArrowUp' : 'ArrowDown',
1113
+ onClick: setShowDropdown,
1114
+ disabled: disabled || readOnly
1115
+ }) : null));
1461
1116
  const ErrorView = useMemo(() => {
1462
1117
  return error ? jsx(HelperText, {
1463
1118
  ...helperTextProps,
1464
1119
  disabled: disabled
1465
1120
  }, error) : null;
1466
1121
  }, [disabled, error, helperTextProps]);
1467
- const DropdownView = useMemo(() => {
1468
- return jsx(Popover, {
1469
- css: PopoverCSS(theme),
1470
- ref: dropdownRef,
1471
- open: openState,
1472
- anchor: ref.current,
1473
- width: popoverWidth,
1474
- onClose: closeDropdown
1475
- }, showDropdown());
1476
- // return openState ? createPortal(showDropdown(), document.body) : null;
1477
- }, [openState, popoverWidth, valueMulti, loadingState, dataSourceState, dataSource, maximumSelectionLength, multilineSelectedItem, multiple, selectBox, txtSearch, theme]);
1122
+ const DropdownView = jsx(Popover, {
1123
+ css: PopoverCSS(theme),
1124
+ ref: dropdownRef,
1125
+ open: openState,
1126
+ anchor: ref.current,
1127
+ width: popoverWidth,
1128
+ onClose: closeDropdown
1129
+ }, showDropdown());
1130
+
1478
1131
  /* End component */
1479
1132
 
1480
1133
  return jsx(Fragment, null, jsx("div", {
@@ -1567,111 +1220,115 @@ const IconCSS = (viewType, {
1567
1220
  margin-left: ${spacing([2])};
1568
1221
  margin-right: ${spacing([viewType !== 'outlined' ? 0 : 4])};
1569
1222
  `;
1223
+ const DropdownFormOutlinedCSS = (disabled, readOnly, placeholder, {
1224
+ colors,
1225
+ spacing
1226
+ }) => css`
1227
+ ${displayFlex};
1228
+ ${flexRow};
1229
+ ${itemsCenter};
1230
+ ${positionRelative};
1231
+ ${borderRadius(4)};
1232
+ ${boxBorder};
1233
+ ${border(1, disabled ? getProp(colors, 'system/disabled') : getProp(colors, 'system/rest'))};
1234
+ ${parseWidth('100%')};
1235
+ ${parseMinHeight(40)};
1236
+ margin-top: ${spacing([0.5])};
1237
+ ${!disabled && !readOnly && css`
1238
+ &:not(:focus-within):hover {
1239
+ ${bgColor(getProp(colors, 'fill/hover'))};
1240
+ ${borderColor(getProp(colors, 'system/active'))};
1241
+ input {
1242
+ ${bgColor(getProp(colors, 'fill/hover'))};
1243
+ }
1244
+ }
1245
+ `}
1246
+ &:focus-within {
1247
+ ${borderColor(getProp(colors, 'line/focus'))};
1248
+ }
1249
+ span:empty:before {
1250
+ content: '${placeholder}';
1251
+ ${parseHeight('100%')};
1252
+ ${overflowHidden};
1253
+ ${textColor(getProp(colors, 'text/sub'))};
1254
+ display: -webkit-box;
1255
+ -webkit-line-clamp: 1;
1256
+ -webkit-box-orient: vertical;
1257
+ }
1258
+ &::placeholder {
1259
+ ${textColor(getProp(colors, 'text/sub'))};
1260
+ }
1261
+ &::after {
1262
+ ${positionAbsolute};
1263
+ ${pointerEventsNone};
1264
+ ${borderRadius(4)};
1265
+ ${border(2, 'transparent')};
1266
+ ${inset(-2)};
1267
+ content: '';
1268
+ }
1269
+ `;
1570
1270
  const DropdownFormCSS = (viewType, multiple, disabled, readOnly, placeholder, DropdownInputCSSName, {
1571
1271
  colors,
1572
1272
  spacing
1573
- }) => viewType !== 'outlined' ? css`
1574
- ${displayFlex};
1575
- ${flexRow};
1576
- ${itemsCenter};
1577
- ${positionRelative};
1578
- ${boxBorder};
1579
- ${parseWidth('100%')};
1580
- padding-top: ${spacing([multiple ? 0.25 : 1])};
1581
- padding-bottom: ${spacing([multiple ? 0.25 : 1])};
1582
- ${!disabled && !readOnly && css`
1583
- &:not(:focus-within):hover {
1584
- &::before {
1585
- ${borderBottomColor(getProp(colors, 'system/active'))};
1586
- }
1587
- .css-${DropdownInputCSSName} {
1588
- ${textColor(getProp(colors, 'system/active'))};
1589
- }
1590
- }
1591
- `}
1592
- &:focus-within {
1593
- ${borderBottomColor(getProp(colors, 'line/focus'))};
1594
- &::after {
1595
- ${borderBottomColor('inherit')};
1596
- transform: scaleX(1);
1597
- }
1598
- .css-${DropdownInputCSSName} {
1599
- ${textColor(getProp(colors, 'system/active'))};
1600
- }
1601
- }
1602
- span:empty:before {
1603
- content: '${placeholder}';
1604
- ${parseHeight('100%')};
1605
- ${overflowHidden};
1606
- ${textColor(getProp(colors, 'text/sub'))};
1607
- display: -webkit-box;
1608
- -webkit-line-clamp: 1;
1609
- -webkit-box-orient: vertical;
1610
- }
1611
- &::placeholder {
1612
- ${textColor(getProp(colors, 'text/sub'))};
1613
- }
1614
- &::before {
1615
- ${positionAbsolute};
1616
- content: '';
1617
- ${insetX(0)};
1618
- ${bottom(0)};
1619
- ${viewType === 'underlined' && borderBottom(1, disabled ? getProp(colors, 'system/disabled') : getProp(colors, 'system/rest'))}
1620
- }
1621
- &::after {
1622
- ${positionAbsolute};
1623
- content: '';
1624
- ${insetX(0)};
1625
- ${bottom(-1)};
1626
- ${borderBottom(2, 'transparent')};
1627
- transform: scaleX(0);
1628
- transform-origin: center;
1629
- transition: all 0.2s ease;
1630
- }
1631
- ` : css`
1632
- ${displayFlex};
1633
- ${flexRow};
1634
- ${itemsCenter};
1635
- ${positionRelative};
1636
- ${borderRadius(4)};
1637
- ${boxBorder};
1638
- ${border(1, disabled ? getProp(colors, 'system/disabled') : getProp(colors, 'system/rest'))};
1639
- ${parseWidth('100%')};
1640
- ${parseMinHeight(40)};
1641
- margin-top: ${spacing([0.5])};
1642
- ${!disabled && !readOnly && css`
1643
- &:not(:focus-within):hover {
1644
- ${bgColor(getProp(colors, 'fill/hover'))};
1645
- ${borderColor(getProp(colors, 'system/active'))};
1646
- input {
1647
- ${bgColor(getProp(colors, 'fill/hover'))};
1648
- }
1649
- }
1650
- `}
1651
- &:focus-within {
1652
- ${borderColor(getProp(colors, 'line/focus'))};
1653
- }
1654
- span:empty:before {
1655
- content: '${placeholder}';
1656
- ${parseHeight('100%')};
1657
- ${overflowHidden};
1658
- ${textColor(getProp(colors, 'text/sub'))};
1659
- display: -webkit-box;
1660
- -webkit-line-clamp: 1;
1661
- -webkit-box-orient: vertical;
1662
- }
1663
- &::placeholder {
1664
- ${textColor(getProp(colors, 'text/sub'))};
1665
- }
1666
- &::after {
1667
- ${positionAbsolute};
1668
- ${pointerEventsNone};
1669
- ${borderRadius(4)};
1670
- ${border(2, 'transparent')};
1671
- ${inset(-2)};
1672
- content: '';
1673
- }
1674
- `;
1273
+ }) => css`
1274
+ ${displayFlex};
1275
+ ${flexRow};
1276
+ ${itemsCenter};
1277
+ ${positionRelative};
1278
+ ${boxBorder};
1279
+ ${parseWidth('100%')};
1280
+ padding-top: ${spacing([multiple ? 0.25 : 1])};
1281
+ padding-bottom: ${spacing([multiple ? 0.25 : 1])};
1282
+ ${!disabled && !readOnly && css`
1283
+ &:not(:focus-within):hover {
1284
+ &::before {
1285
+ ${borderBottomColor(getProp(colors, 'system/active'))};
1286
+ }
1287
+ .css-${DropdownInputCSSName} {
1288
+ ${textColor(getProp(colors, 'system/active'))};
1289
+ }
1290
+ }
1291
+ `}
1292
+ &:focus-within {
1293
+ ${borderBottomColor(getProp(colors, 'line/focus'))};
1294
+ &::after {
1295
+ ${borderBottomColor('inherit')};
1296
+ transform: scaleX(1);
1297
+ }
1298
+ .css-${DropdownInputCSSName} {
1299
+ ${textColor(getProp(colors, 'system/active'))};
1300
+ }
1301
+ }
1302
+ span:empty:before {
1303
+ content: '${placeholder}';
1304
+ ${parseHeight('100%')};
1305
+ ${overflowHidden};
1306
+ ${textColor(getProp(colors, 'text/sub'))};
1307
+ display: -webkit-box;
1308
+ -webkit-line-clamp: 1;
1309
+ -webkit-box-orient: vertical;
1310
+ }
1311
+ &::placeholder {
1312
+ ${textColor(getProp(colors, 'text/sub'))};
1313
+ }
1314
+ &::before {
1315
+ ${positionAbsolute};
1316
+ content: '';
1317
+ ${insetX(0)};
1318
+ ${bottom(0)};
1319
+ ${viewType === 'underlined' && borderBottom(1, disabled ? getProp(colors, 'system/disabled') : getProp(colors, 'system/rest'))}
1320
+ }
1321
+ &::after {
1322
+ ${positionAbsolute};
1323
+ content: '';
1324
+ ${insetX(0)};
1325
+ ${bottom(-1)};
1326
+ ${borderBottom(2, 'transparent')};
1327
+ transform: scaleX(0);
1328
+ transform-origin: center;
1329
+ transition: all 0.2s ease;
1330
+ }
1331
+ `;
1675
1332
  const DropdownListCSS = (loading, {
1676
1333
  colors,
1677
1334
  spacing
@@ -1823,34 +1480,34 @@ Dropdown.propTypes = {
1823
1480
  action: PropTypes.shape({
1824
1481
  loadData: PropTypes.func
1825
1482
  }),
1826
- /** If `true`, display input box search. */
1483
+ /** If `true`, the input box for searching will be displayed. */
1827
1484
  allowSearch: PropTypes.bool,
1828
- /** The contents in Dropdown box (Exp: TreeView). */
1485
+ /** The content to be displayed inside the Dropdown box, such as TreeView. */
1829
1486
  children: PropTypes.node,
1830
- /** Class for component. */
1487
+ /** The CSS class for the component. */
1831
1488
  className: PropTypes.string,
1832
- /** If `true`, display clear icon.*/
1489
+ /** If `true`, the clear button will be displayed. */
1833
1490
  clearAble: PropTypes.bool,
1834
- /** If `true`, dropdown will close after select an item. */
1491
+ /** If `true`, the dropdown will automatically close after selecting an item. */
1835
1492
  closeAfterSelect: PropTypes.bool,
1836
1493
  /** The array of elements that appear in the dropdown list. */
1837
1494
  dataSource: PropTypes.array,
1838
- /** Default value displayed when first render. */
1495
+ /** The default value to be displayed when the Dropdown first renders. */
1839
1496
  defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1840
1497
  /** If `true`, the component is disabled. */
1841
1498
  disabled: PropTypes.bool,
1842
- /** Field name used for text display in dropdown list.<br/>
1843
- * Example: 'name', '{id} - {name}', '{age} age(s)'<br/>
1844
- * Note: don't use 'id - name', return undefined
1499
+ /** The field name used for displaying text in the dropdown list.<br/>
1500
+ * Examples: 'name', '{id} - {name}', '{age} age(s)'<br/>
1501
+ * Note: Do not use 'id - name', as it will return undefined.
1845
1502
  */
1846
1503
  displayExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1847
- /** Style inline of dropdown items. */
1504
+ /** Inline style for dropdown items. */
1848
1505
  dropdownItemStyle: PropTypes.object,
1849
- /** Error displayed below input. */
1506
+ /** Error message displayed below the input. */
1850
1507
  error: PropTypes.oneOfType([PropTypes.bool, PropTypes.string]),
1851
1508
  /** Props applied to the [HelperText](https://core.diginet.com.vn/ui/?path=/story/form-control-text-helpertext) element. */
1852
1509
  helperTextProps: PropTypes.object,
1853
- /** Field name used for icon display.<br/>
1510
+ /** The field name used for displaying icons.<br/>
1854
1511
  * Example:<br/>
1855
1512
  * &nbsp;&nbsp;string: 'icon'<br/>
1856
1513
  * &nbsp;&nbsp;object: {<br/>
@@ -1867,82 +1524,82 @@ Dropdown.propTypes = {
1867
1524
  })]),
1868
1525
  /** Attributes applied to the input element. */
1869
1526
  inputProps: PropTypes.object,
1870
- /** Style inline of input element. */
1527
+ /** Inline style for the input element. */
1871
1528
  inputStyle: PropTypes.object,
1872
- /** The mode of item when rendering. */
1529
+ /** The mode of rendering for items. */
1873
1530
  itemMode: PropTypes.oneOf(['normal', 'table', 'treeview']),
1874
- /** The label of the input. */
1531
+ /** The label for the input. */
1875
1532
  label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
1876
- /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) of label. */
1533
+ /** [Props](https://core.diginet.com.vn/ui/?path=/docs/form-control-text-label--simple) applied to the label element. */
1877
1534
  labelProps: PropTypes.object,
1878
- /** Number of items that are rendered each time. */
1535
+ /** Number of items to render at a time. */
1879
1536
  limit: PropTypes.number,
1880
- /** If `true`, the loading indicator is shown. */
1537
+ /** If `true`, a loading indicator is shown. */
1881
1538
  loading: PropTypes.bool,
1882
- /** Set restrictions regarding the maximum number of options that can be selected. (Use with prop `multiple`) */
1539
+ /** Maximum number of options that can be selected (used with `multiple` prop).*/
1883
1540
  maximumSelectionLength: PropTypes.number,
1884
- /** If `true`, show multi-line selected item(s). */
1541
+ /** If `true`, multi-line selected item(s) will be shown. */
1885
1542
  multilineSelectedItem: PropTypes.bool,
1886
- /** If `true`, value must be an array and the dropdown will support multiple selections. */
1543
+ /** If `true`, the Dropdown supports multiple selections (value must be an array). */
1887
1544
  multiple: PropTypes.bool,
1888
- /** Specifies a text string shown when there is no data. */
1545
+ /** Text shown when there is no data. */
1889
1546
  noDataText: PropTypes.string,
1890
- /** Callback fired when the value changes. */
1547
+ /** Callback function fired when the value changes. */
1891
1548
  onChange: PropTypes.func,
1892
- /** Callback fired when dropdown closed. */
1549
+ /** Callback function fired when the dropdown is closed. */
1893
1550
  onClosed: PropTypes.func,
1894
- /** Callback fired when the input value changes.<br/>
1895
- * if undefined: the filter function will run (default)
1551
+ /** Callback function fired when the input value changes.<br/>
1552
+ * If undefined, the filter function will run (default behavior).
1896
1553
  */
1897
1554
  onInput: PropTypes.func,
1898
- /** Callback fired when key down input */
1555
+ /** Callback function fired when a key is pressed down in the input. */
1899
1556
  onKeyDown: PropTypes.func,
1900
- /** Callback fired when scroll near the end. */
1557
+ /** Callback function fired when scrolling near the end of the dropdown. */
1901
1558
  onLoadMore: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
1902
- /** The short hint displayed in the input before the user select a value. */
1559
+ /** The short hint displayed in the input before the user selects a value. */
1903
1560
  placeholder: PropTypes.string,
1904
1561
  /** If `true`, the component is read-only. */
1905
1562
  readOnly: PropTypes.bool,
1906
- /** Function displays items by custom.<br/>
1907
- * renderItem={(data, index) => data.name + ' - ' + data.role}<br/>
1908
- * --> such as: displayExpr={'name - role'}
1563
+ /** Function used for custom rendering of items.<br/>
1564
+ * Example: `(data, index) => data.name + ' - ' + data.role`<br/>
1565
+ * This can be used as an alternative to `displayExpr`
1909
1566
  */
1910
1567
  renderItem: PropTypes.func,
1911
- /** Function or field name used for display selected items, example:<br/>
1912
- * renderSelectedItem={(data, index) => index + ' - ' + data.name}<br/>
1568
+ /** Function or field name used to display selected items.<br/>
1569
+ * Example: `(data, index) => index + ' - ' + data.name`<br/>
1913
1570
  */
1914
1571
  renderSelectedItem: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
1915
1572
  /** If `true`, the label will indicate that the input is required. */
1916
1573
  required: PropTypes.bool,
1917
1574
  /**
1918
- * Duration wait enter search content on search.<br/>
1575
+ * Duration to wait after entering search content before triggering a search.<br/>
1919
1576
  * Example: 700 -> 700ms, '700ms' -> 700ms, '0.7s' -> 700ms, '1m' -> 60000ms
1920
- * If `true`, used default delayOnInput.
1577
+ * If `true`, the default delayOnInput will be used.
1921
1578
  */
1922
1579
  searchDelayTime: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.bool]),
1923
- /** Specifies a data object's field name or an expression whose value is compared to the search string. */
1580
+ /** Specifies the field name or expression used to compare values with the search string. */
1924
1581
  searchExpr: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
1925
- /** Specifies a comparison operation used to search items. */
1582
+ /** Specifies the comparison operation used to search items. */
1926
1583
  searchMode: PropTypes.oneOf(['contains', 'startswith', 'equals']),
1927
- /** If `true`, show checkbox in each dropdown item. */
1584
+ /** If `true`, checkboxes will be shown next to each dropdown item. */
1928
1585
  selectBox: PropTypes.bool,
1929
- /** Style inline of component. */
1586
+ /** Inline style for the component. */
1930
1587
  style: PropTypes.object,
1931
- /** Display sub content. */
1588
+ /** Sub content to display. */
1932
1589
  subText: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
1933
1590
  /** The total number of items in the dropdown list. */
1934
1591
  total: PropTypes.number,
1935
- /** Used to identify the parent key (only used for `itemMode` is 'treeview'). */
1592
+ /** Used to identify the parent key (only used when `itemMode` is 'treeview'). */
1936
1593
  treeViewID: PropTypes.string,
1937
- /** Used for mapping into a nested list (only used for `itemMode` is 'treeview'). */
1594
+ /** Used for mapping into a nested list (only used when `itemMode` is 'treeview'). */
1938
1595
  treeViewParentID: PropTypes.string,
1939
- /** The displayed value of component. */
1596
+ /** The displayed value of the component. */
1940
1597
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.array]),
1941
1598
  /** The field name used for the returned result. */
1942
1599
  valueExpr: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
1943
- /** An object default for value (use for load more). */
1600
+ /** An object default for value (used for load more). */
1944
1601
  valueObjectDefault: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
1945
- /**The variant to use. */
1602
+ /** The variant to use. */
1946
1603
  viewType: PropTypes.oneOf(['underlined', 'outlined', 'none'])
1947
1604
  /**
1948
1605
  * ref methods