diginet-core-ui 1.3.70 → 1.3.71

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.
@@ -6,14 +6,13 @@ import ReactDOM from 'react-dom';
6
6
  import { createPortal } from 'react-dom';
7
7
  import PropTypes from 'prop-types';
8
8
  import { jsx, css } from '@emotion/core';
9
- import { Account } from '../../../icons';
10
- import AvatarDefault from '../../../assets/avatar/default.svg';
11
9
  import { InputBase, Chip, CircularProgress, Checkbox, TreeView, HelperText, Label, ButtonIcon, Typography } from '../../';
12
10
  import { mapParent, randomString, updatePosition } from '../../../utils';
13
11
  import { getGlobal } from '../../../global';
14
- import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, breakWord, cursorPointer, displayBlock, flexColReverse, flexRow, flexWrap, inlineFlex, justifyCenter, justifyStart, outlineNone, overflowAuto, overflowHidden, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, userSelectNone } from '../../../styles/general';
12
+ import { alignCenter, backgroundTransparent, border, borderBox, borderNone, borderRadius4px, breakWord, cursorPointer, displayBlock, flexColReverse, flexRow, flexWrap, justifyCenter, justifyStart, outlineNone, overflowAuto, overflowHidden, parseWidth, parseWidthHeight, pointerEventsNone, positionAbsolute, positionFixed, positionRelative, userSelectNone } from '../../../styles/general';
15
13
  import isMobile from '../../../utils/isMobile';
16
14
  import theme from '../../../theme/settings';
15
+ import Avatar from '../../avatar';
17
16
  const {
18
17
  colors: {
19
18
  system: {
@@ -50,6 +49,8 @@ const timing = {},
50
49
  isSearch = {},
51
50
  allValue = {};
52
51
  const separatorPattern = /\{\w+\}/g;
52
+ const regexBetween = /(?<=\{)(.*?)(?=\})/g;
53
+ const regexInclude = /{|}/g;
53
54
 
54
55
  const checkHasValue = value => {
55
56
  return Array.isArray(value) ? value.length > 0 : value === 0 || !!value;
@@ -58,7 +59,6 @@ const checkHasValue = value => {
58
59
  const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
59
60
  viewType,
60
61
  itemMode,
61
- itemMultipleSize,
62
62
  required,
63
63
  className,
64
64
  label,
@@ -103,7 +103,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
103
103
  children,
104
104
  dropdownItemStyle,
105
105
  searchExpr,
106
- searchMode
106
+ searchMode,
107
+ maximumSelectionLength
107
108
  }, reference) => {
108
109
  if (multiple && selectBox === undefined) selectBox = true;
109
110
  if (typeof searchExpr === 'string') searchExpr = [searchExpr];
@@ -119,6 +120,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
119
120
  const lastSearchRef = useRef(null);
120
121
  const timeout = useRef(null);
121
122
  const loadMoreTimer = useRef(null);
123
+ const dataChoosen = useRef([]);
122
124
  const [unique] = useState(randomString(6, {
123
125
  allowNumber: false,
124
126
  allowSymbol: false
@@ -126,12 +128,19 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
126
128
  const [openState, setOpenState] = useState(false);
127
129
  const [showClear, setShowClear] = useState(false);
128
130
  const [textValue, setTextValue] = useState('');
131
+ let valueTemp = valueProp || defaultValue || [];
132
+
133
+ if (multiple && valueTemp && !Array.isArray(valueTemp)) {
134
+ valueTemp = [valueTemp];
135
+ }
136
+
137
+ const [valueMulti, setValueMulti] = useState(valueTemp);
129
138
 
130
139
  const _isMobile = isMobile.any();
131
140
 
132
141
  const _InputCSS = InputCSS(multiple, typeof renderSelectedItem === 'function');
133
142
 
134
- const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, itemMultipleSize, typeof renderSelectedItem === 'function', disabled);
143
+ const _DropdownInputCSS = DropdownInputCSS(viewType, multiple, placeholder, typeof renderSelectedItem === 'function', disabled);
135
144
 
136
145
  const _IconCSS = IconCSS(viewType, loading, showClear);
137
146
 
@@ -265,7 +274,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
265
274
  },
266
275
  onKeyDown: pressESCHandler,
267
276
  autoFocus: true
268
- })), jsx("div", {
277
+ })), multiple && maximumSelectionLength && jsx(Typography, {
278
+ style: {
279
+ padding: spacing([2, 4])
280
+ }
281
+ }, getGlobal('selected'), " ", (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length) || 0, "/", maximumSelectionLength), jsx("div", {
269
282
  className: 'DGN-Dropdown-Box'
270
283
  }, dropdown), loading && jsx("div", {
271
284
  css: LoadingProgressCSS,
@@ -471,11 +484,13 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
471
484
  }
472
485
 
473
486
  const value = typeof data === 'object' ? data[valueExpr] : data;
474
- const itemDisabled = typeof data === 'object' ? data['disabled'] : false;
487
+ let itemDisabled = typeof data === 'object' ? data['disabled'] : false;
475
488
  const icon = getIconFromData(data);
476
489
 
477
490
  if (multiple && selectBox) {
478
- const checked = Array.isArray(currentValue[unique]) ? currentValue[unique].includes(value) : [currentValue[unique]].includes(value);
491
+ const checked = Array.isArray(valueMulti) ? valueMulti.includes(value) : valueMulti.includes(value);
492
+ const isMaximumSelection = maximumSelectionLength === (valueMulti === null || valueMulti === void 0 ? void 0 : valueMulti.length);
493
+ itemDisabled = itemDisabled || isMaximumSelection && !checked;
479
494
  items.push(jsx("div", {
480
495
  key: index,
481
496
  css: !itemDisabled ? _DropdownItemCSS : [DisabledCSS, _DropdownItemCSS],
@@ -501,9 +516,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
501
516
  value: value,
502
517
  disabled: itemDisabled,
503
518
  onChange: () => onChangeValue(displayText, value, icon, data, index)
504
- }, icon && jsx("div", {
505
- css: DropdownIconCSS
506
- }, icon), jsx("div", {
519
+ }, icon && icon, jsx("div", {
507
520
  css: DropdownTextCSS
508
521
  }, displayText))));
509
522
  } else {
@@ -521,9 +534,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
521
534
  },
522
535
  tabIndex: -1,
523
536
  style: dropdownItemStyle
524
- }, icon && jsx("div", {
525
- css: DropdownIconCSS
526
- }, icon), jsx("div", {
537
+ }, icon && icon, jsx("div", {
527
538
  css: DropdownTextCSS
528
539
  }, displayText)));
529
540
  } // if (items?.length === limit) {
@@ -644,15 +655,11 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
644
655
  height: '100%',
645
656
  padding: '0 16px'
646
657
  }
647
- }, icon && jsx("div", {
648
- css: DropdownIconCSS
649
- }, icon), jsx("div", {
658
+ }, icon && icon, jsx("div", {
650
659
  css: DropdownTextCSS
651
660
  }, displayText));
652
661
  } else {
653
- item = jsx(Fragment, null, icon && jsx("div", {
654
- css: DropdownIconCSS
655
- }, icon), jsx("div", {
662
+ item = jsx(Fragment, null, icon && icon, jsx("div", {
656
663
  css: DropdownTextCSS
657
664
  }, displayText));
658
665
  }
@@ -685,50 +692,31 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
685
692
  return str + separatorArr[i];
686
693
  };
687
694
 
688
- const getIconFromData = data => {
695
+ const getIconFromData = (data, insideChip = false) => {
689
696
  if (!iconExpr || iconExpr === 'none') return null;
697
+ let _src = iconDefault;
698
+ if (typeof iconExpr === 'string') _src = data[iconExpr];else {
699
+ let prefix = iconExpr.prefix || '';
700
+ const suffix = iconExpr.suffix || '';
701
+ const url = data[iconExpr.key];
702
+
703
+ if (prefix && /^http/i.test(prefix) && /^http/i.test(url)) {
704
+ prefix = '';
705
+ }
690
706
 
691
- if (typeof iconExpr === 'string') {
692
- return data[iconExpr] ? jsx("img", {
693
- src: data[iconExpr],
694
- alt: data[valueExpr]
695
- }) : iconDefault ? jsx("img", {
696
- src: iconDefault,
697
- alt: data[valueExpr],
698
- style: iconExpr.style
699
- }) : jsx(Account, {
700
- width: 32,
701
- height: 32
702
- });
703
- }
704
-
705
- let prefix = iconExpr.prefix || '';
706
- const suffix = iconExpr.suffix || '';
707
- const url = data[iconExpr.key];
708
-
709
- if (prefix && /^http/i.test(prefix) && /^http/i.test(url)) {
710
- prefix = '';
707
+ _src = prefix + url + suffix;
711
708
  }
712
-
713
- return url ? jsx("img", {
714
- src: prefix + url + suffix,
715
- alt: data[valueExpr],
716
- style: iconExpr.style,
717
- onError: onErrorRenderIcon
718
- }) : iconDefault ? jsx("img", {
719
- src: iconDefault,
720
- alt: data[valueExpr],
721
- style: iconExpr.style
722
- }) : jsx(Account, {
723
- width: 32,
724
- height: 32
709
+ return jsx(Avatar, {
710
+ disabled: true,
711
+ src: _src,
712
+ width: insideChip ? 20 : 24,
713
+ height: insideChip ? 20 : 24,
714
+ style: { ...iconExpr.style,
715
+ marginRight: spacing([insideChip ? 0 : 2])
716
+ }
725
717
  });
726
718
  };
727
719
 
728
- const onErrorRenderIcon = e => {
729
- e.target.src = iconDefault ? iconDefault : AvatarDefault;
730
- };
731
-
732
720
  const customizeWidthDropdown = () => {
733
721
  if (dropdownListRef.current && _isMobile) dropdownListRef.current.style.maxHeight = `${Math.min(280, window.innerHeight) - (allowSearch ? 40 : 0)}px`;
734
722
 
@@ -789,6 +777,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
789
777
 
790
778
  const onChangeInput = e => {
791
779
  if (searchRef.current) lastSearchRef.current = searchRef.current.value;
780
+ const dataFilter = getData();
781
+ dataChoosen.current = [...dataFilter].filter(i => [...valueMulti].includes(i === null || i === void 0 ? void 0 : i[valueExpr]));
792
782
 
793
783
  if (onInput) {
794
784
  isSearch[unique] = true; // const valueInput = e.target.value;
@@ -831,9 +821,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
831
821
  }, timeout.current || searchDelayTime);
832
822
  };
833
823
 
834
- const onChangeValue = (displayText, value, icon, data, index) => {
824
+ const onChangeValue = (displayText, value, icon, data) => {
835
825
  if (itemMode === 'treeview') {
836
826
  if (valueProp === undefined) {
827
+ setValueMulti(value);
837
828
  setValueIntoInput(value);
838
829
  setShowClear(clearAble && checkHasValue(value) && !disabled && !readOnly && !loading);
839
830
  }
@@ -847,60 +838,46 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
847
838
  } else if (multiple) {
848
839
  if (!Array.isArray(currentValue[unique])) currentValue[unique] = [];
849
840
  const newValueArr = [...currentValue[unique]];
841
+ const newValueArrState = [...valueMulti];
850
842
 
851
843
  if (!currentValue[unique].some(v => JSON.stringify(v) === JSON.stringify(value))) {
852
844
  newValueArr.push(value);
853
-
854
- if (valueProp === undefined) {
855
- let item = null;
856
-
857
- if (typeof renderSelectedItem === 'function') {
858
- item = renderSelectedItem({
859
- data,
860
- index
861
- });
862
- } else {
863
- item = jsx(Chip, {
864
- startIcon: icon,
865
- label: displayText,
866
- size: itemMultipleSize,
867
- disabled: disabled,
868
- clearAble: true,
869
- onRemove: e => onRemove(e, value),
870
- style: {
871
- margin: '3px 0',
872
- width: '100%'
873
- }
874
- });
875
- }
876
-
877
- const el = document.createElement('div');
878
- el.className = 'dropdown-item';
879
- el.style.display = 'flex';
880
- ReactDOM.render(item, inputRef.current.appendChild(el));
881
- }
882
-
883
- !!onChange && onChange({
884
- value: newValueArr,
885
- data
886
- });
845
+ newValueArrState.push(value); // if (valueProp === undefined) {
846
+ // let item = null;
847
+ // if (typeof renderSelectedItem === 'function') {
848
+ // item = renderSelextedItem({ data, index });
849
+ // } else {
850
+ // item = (
851
+ // <Chip
852
+ // startIcon={icon}
853
+ // label={displayText}
854
+ // size={itemMultipleSize}
855
+ // disabled={disabled}
856
+ // clearAble
857
+ // onRemove={e => onRemove(e, value)}
858
+ // style={{ margin: '3px 0', width: '100%' }}
859
+ // />
860
+ // );
861
+ // }
862
+ // const el = document.createElement('div');
863
+ // el.className = 'dropdown-item';
864
+ // el.style.display = 'flex';
865
+ // ReactDOM.render(item, inputRef.current.appendChild(el));
866
+ // }
887
867
  } else {
888
868
  const index = newValueArr.indexOf(value);
889
869
  newValueArr.splice(index, 1);
890
-
891
- if (valueProp === undefined) {
892
- var _nodes$index;
893
-
894
- const nodes = inputRef.current.querySelectorAll('.dropdown-item');
895
- (_nodes$index = nodes[index]) === null || _nodes$index === void 0 ? void 0 : _nodes$index.remove();
896
- }
897
-
898
- !!onChange && onChange({
899
- value: newValueArr,
900
- data
901
- });
870
+ newValueArrState.splice(index, 1); // if (valueProp === undefined) {
871
+ // const nodes = inputRef.current.querySelectorAll('.dropdown-item');
872
+ // nodes[index]?.remove();
873
+ // }
902
874
  }
903
875
 
876
+ setValueMulti(newValueArrState);
877
+ !!onChange && onChange({
878
+ value: newValueArrState,
879
+ data
880
+ });
904
881
  setTimeout(() => {
905
882
  updatePositionDropdown();
906
883
  }, 0);
@@ -933,46 +910,50 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
933
910
 
934
911
 
935
912
  const onRemove = (e, value) => {
913
+ var _ref;
914
+
936
915
  const index = currentValue[unique].findIndex(v => JSON.stringify(v) === JSON.stringify(value));
937
916
 
938
917
  if (index !== -1) {
939
- currentValue[unique].splice(index, 1);
940
- setTimeout(() => {
941
- var _e$parentNode;
942
-
943
- if (dropdownListRef.current && multiple && selectBox && !children) {
944
- const input = dropdownListRef.current.querySelector(`input[value="${value}"]`);
945
-
946
- if (input) {
947
- input.checked = false;
948
- }
949
- }
950
-
951
- e === null || e === void 0 ? void 0 : (_e$parentNode = e.parentNode) === null || _e$parentNode === void 0 ? void 0 : _e$parentNode.remove();
952
- }, 0);
953
- !!onChange && onChange({
954
- value: currentValue[unique],
955
- removed: value
956
- });
957
- }
918
+ currentValue[unique].splice(index, 1); // setTimeout(() => {
919
+ // if (dropdownListRef.current && multiple && selectBox && !children) {
920
+ // const input = dropdownListRef.current.querySelector(`input[value="${value}"]`);
921
+ // if (input) {
922
+ // input.checked = false;
923
+ // }
924
+ // }
925
+ // e?.parentNode?.remove();
926
+ // }, 0);
927
+ // }, 0);
928
+ // }, 0);
929
+ // setValueMulti([...valueMulti]?.filter(i=>i!==value) || []);
930
+ // !!onChange && onChange({ value: currentValue[unique], removed: value });
931
+ } // logic mới
932
+
933
+
934
+ const newValueArrState = ((_ref = [...valueMulti]) === null || _ref === void 0 ? void 0 : _ref.filter(i => i !== value)) || [];
935
+ setValueMulti(newValueArrState);
936
+ !!onChange && onChange({
937
+ value: newValueArrState,
938
+ removed: value
939
+ });
958
940
  };
959
941
 
960
942
  const onClear = e => {
961
943
  if (disabled || readOnly || loading || !clearAble) return;
962
944
  currentValue[unique] = multiple ? [] : '';
963
945
 
964
- if (inputRef.current.tagName.toLowerCase() === 'div') {
965
- inputRef.current.innerHTML = '';
966
-
967
- if (dropdownListRef.current) {
968
- dropdownListRef.current.querySelectorAll('input').forEach(input => input.checked = false);
969
- }
946
+ if (inputRef.current.tagName.toLowerCase() === 'div') {// inputRef.current.innerHTML = '';
947
+ // if (dropdownListRef.current) {
948
+ // dropdownListRef.current.querySelectorAll('input').forEach(input => (input.checked = false));
949
+ // }
970
950
  } else {
971
951
  inputRef.current.value = '';
972
952
  setTextValue('');
973
953
  } // onChangeValue('', '');
974
954
 
975
955
 
956
+ setValueMulti([]);
976
957
  setShowClear(false);
977
958
  e && e.target && e.target.blur();
978
959
  updatePositionDropdown();
@@ -994,7 +975,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
994
975
  const setValueIntoInput = source => {
995
976
  if (!source && source !== 0) {
996
977
  if (multiple) {
997
- inputRef.current.innerHTML = '';
978
+ // inputRef.current.innerHTML = '';
998
979
  currentValue[unique] = [];
999
980
  } else {
1000
981
  if (typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
@@ -1027,8 +1008,8 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1027
1008
  }
1028
1009
 
1029
1010
  valueArr = [...new Set(valueArr)];
1030
- currentValue[unique] = [];
1031
- inputRef.current.innerHTML = '';
1011
+ currentValue[unique] = []; // inputRef.current.innerHTML = '';
1012
+
1032
1013
  valueArr.forEach(v => {
1033
1014
  var _currentObjectDefault4;
1034
1015
 
@@ -1074,35 +1055,29 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1074
1055
  }
1075
1056
  };
1076
1057
 
1077
- const setMultipleValueHandler = (data, value, keyArr, index) => {
1078
- let item = null;
1079
-
1080
- if (typeof renderSelectedItem === 'function') {
1081
- item = renderSelectedItem({
1082
- data,
1083
- index
1084
- });
1085
- } else {
1086
- const icon = getIconFromData(data);
1087
- const text = keyArr ? renderData(data, keyArr) : data[renderSelectedItem || displayExpr];
1088
- item = jsx(Chip, {
1089
- startIcon: icon,
1090
- label: text,
1091
- size: itemMultipleSize,
1092
- disabled: disabled,
1093
- clearAble: true,
1094
- onRemove: e => onRemove(e, value),
1095
- style: {
1096
- margin: '3px 0',
1097
- width: '100%'
1098
- }
1099
- });
1100
- }
1101
-
1102
- const el = document.createElement('div');
1103
- el.className = 'dropdown-item';
1104
- el.style.display = 'flex';
1105
- ReactDOM.render(item, inputRef.current.appendChild(el));
1058
+ const setMultipleValueHandler = (data, value) => {
1059
+ // let item = null;
1060
+ // if (typeof renderSelectedItem === 'function') {
1061
+ // item = renderSelectedItem({ data, index });
1062
+ // } else {
1063
+ // const icon = getIconFromData(data);
1064
+ // const text = keyArr ? renderData(data, keyArr) : data[renderSelectedItem || displayExpr];
1065
+ // item = (
1066
+ // <Chip
1067
+ // startIcon={icon}
1068
+ // label={text}
1069
+ // size={itemMultipleSize}
1070
+ // disabled={disabled}
1071
+ // clearAble
1072
+ // onRemove={e => onRemove(e, value)}
1073
+ // style={{ margin: '3px 0', width: '100%' }}
1074
+ // />
1075
+ // );
1076
+ // }
1077
+ // const el = document.createElement('div');
1078
+ // el.className = 'dropdown-item';
1079
+ // el.style.display = 'flex';
1080
+ // ReactDOM.render(item, inputRef.current.appendChild(el));
1106
1081
  currentValue[unique].push(value);
1107
1082
  };
1108
1083
 
@@ -1121,9 +1096,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1121
1096
  } else if (iconExpr && iconExpr !== 'none') {
1122
1097
  inputRef.current.innerHTML = '';
1123
1098
  const icon = getIconFromData(data);
1124
- const valueWithIcon = jsx(Fragment, null, icon && jsx("div", {
1125
- css: DropdownIconCSS
1126
- }, icon), jsx(Typography, {
1099
+ const valueWithIcon = jsx(Fragment, null, icon && icon, jsx(Typography, {
1127
1100
  type: 'p1',
1128
1101
  lineClamp: 1,
1129
1102
  hoverTooltip: !_isMobile
@@ -1230,6 +1203,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1230
1203
  if (allValue[unique][allValue[unique].length - 1] !== valueProp) {
1231
1204
  allValue[unique].push(valueProp);
1232
1205
  }
1206
+
1207
+ if (multiple && valueProp) {
1208
+ setValueMulti(!Array.isArray(valueProp) ? [valueProp] : valueProp);
1209
+ }
1233
1210
  }, [valueProp]);
1234
1211
  useEffect(() => {
1235
1212
  if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
@@ -1333,6 +1310,20 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1333
1310
  disabled: disabled,
1334
1311
  ...labelProps
1335
1312
  }, label) : null, [label, required, disabled, labelProps]);
1313
+
1314
+ const getData = () => {
1315
+ let dataFilter = JSON.parse(JSON.stringify(dataSource));
1316
+
1317
+ if (Array.isArray(valueObjectDefault)) {
1318
+ dataFilter = [...dataFilter, ...dataChoosen.current, ...valueObjectDefault];
1319
+ } else if (typeof valueObjectDefault === 'object') {
1320
+ dataFilter = [...dataFilter, ...dataChoosen.current, { ...valueObjectDefault
1321
+ }];
1322
+ }
1323
+
1324
+ return dataFilter;
1325
+ };
1326
+
1336
1327
  const InputView = useMemo(() => {
1337
1328
  return jsx("div", {
1338
1329
  css: _DropdownFormCSS,
@@ -1342,9 +1333,10 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1342
1333
  }, jsx("div", {
1343
1334
  css: _InputCSS,
1344
1335
  className: 'DGN-UI-Dropdown-Form-Input'
1345
- }, multiple ? jsx("div", { ...inputProps,
1336
+ }, multiple && valueMulti !== null && valueMulti !== void 0 && valueMulti.length ? jsx("div", { ...inputProps,
1346
1337
  style: {
1347
1338
  cursor: 'text',
1339
+ gap: spacing(0.5),
1348
1340
  ...inputStyle
1349
1341
  },
1350
1342
  ref: inputRef,
@@ -1354,7 +1346,39 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1354
1346
  e.preventDefault();
1355
1347
  return false;
1356
1348
  }
1357
- }) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
1349
+ }, valueMulti.map((vl, index) => {
1350
+ let dataFilter = getData();
1351
+ const data = dataFilter.find(v => v[valueExpr] === vl);
1352
+ let text = '';
1353
+
1354
+ if (data) {
1355
+ var _displayExpr4;
1356
+
1357
+ const mask = (_displayExpr4 = displayExpr) === null || _displayExpr4 === void 0 ? void 0 : _displayExpr4.replace(regexBetween, _ => data[_]);
1358
+ text = mask === null || mask === void 0 ? void 0 : mask.replace(regexInclude, '');
1359
+ }
1360
+
1361
+ let item = null;
1362
+
1363
+ if (typeof renderSelectedItem === 'function') {
1364
+ item = renderSelectedItem({
1365
+ data,
1366
+ index
1367
+ });
1368
+ } else {
1369
+ item = jsx(Chip, {
1370
+ key: index,
1371
+ startIcon: getIconFromData(data, true),
1372
+ label: text,
1373
+ size: 'medium',
1374
+ disabled: disabled,
1375
+ clearAble: true,
1376
+ onRemove: e => onRemove(e, vl)
1377
+ });
1378
+ }
1379
+
1380
+ return item;
1381
+ })) : typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' ? jsx("div", { ...inputProps,
1358
1382
  contentEditable: !disabled && !allowSearch,
1359
1383
  style: inputStyle,
1360
1384
  ref: inputRef,
@@ -1409,7 +1433,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1409
1433
  },
1410
1434
  disabled: disabled || readOnly
1411
1435
  })));
1412
- }, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, itemMultipleSize, openState, showClear, textValue]);
1436
+ }, [viewType, inputProps, inputStyle, multiple, clearAble, onChange, disabled, readOnly, loading, renderSelectedItem, placeholder, dataSource, valueObjectDefault, valueExpr, displayExpr, openState, showClear, textValue, valueMulti]);
1413
1437
  const ErrorView = useMemo(() => error && jsx(HelperText, {
1414
1438
  disabled: disabled,
1415
1439
  style: {
@@ -1421,7 +1445,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1421
1445
  }, error), [error, disabled, errorStyle]);
1422
1446
  const DropdownView = useMemo(() => {
1423
1447
  return openState ? /*#__PURE__*/createPortal(showDropdown(), document.body) : null;
1424
- }, [openState, dataSource, loading, multiple, selectBox]);
1448
+ }, [openState, valueMulti, dataSource, loading, multiple, selectBox, maximumSelectionLength]);
1425
1449
  /* End component */
1426
1450
 
1427
1451
  return jsx(Fragment, null, jsx("div", {
@@ -1440,25 +1464,7 @@ const InputCSS = (multiple, renderSelectedItem) => css`
1440
1464
  ${!multiple && renderSelectedItem ? `width: calc(100% - 34px)` : ''}
1441
1465
  `;
1442
1466
 
1443
- const DropdownIconCSS = css`
1444
- ${inlineFlex};
1445
- ${alignCenter};
1446
- ${positionRelative};
1447
- ${overflowHidden};
1448
- ${parseWidthHeight(32)};
1449
- margin-right: ${spacing([2])};
1450
- min-height: 32px;
1451
- min-width: 32px;
1452
- border-radius: 16px;
1453
- img {
1454
- ${parseWidthHeight(32)};
1455
- min-height: 32px;
1456
- min-width: 32px;
1457
- object-fit: cover;
1458
- }
1459
- `;
1460
-
1461
- const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, renderSelectedItem, disabled) => css`
1467
+ const DropdownInputCSS = (viewType, multiple, placeholder, renderSelectedItem, disabled) => css`
1462
1468
  ${flexRow};
1463
1469
  ${alignCenter};
1464
1470
  ${outlineNone};
@@ -1497,7 +1503,7 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
1497
1503
  }
1498
1504
  svg {
1499
1505
  ${borderBox};
1500
- padding: ${itemMultipleSize === 'medium' ? 2 : 1}px;
1506
+ padding: 2px;
1501
1507
  }
1502
1508
  }
1503
1509
  .DGN-UI-Typography {
@@ -1505,30 +1511,6 @@ const DropdownInputCSS = (viewType, multiple, placeholder, itemMultipleSize, ren
1505
1511
  color: ${systemDisabled}
1506
1512
  `}
1507
1513
  }
1508
- .css-${DropdownIconCSS.name} {
1509
- ${disabled && `
1510
- svg {
1511
- path {
1512
- fill: ${systemDisabled};
1513
- }
1514
- }
1515
- `}
1516
- ${renderSelectedItem ? `
1517
- min-height: 24px;
1518
- min-width: 24px;
1519
- ` : `
1520
- height: 24px;
1521
- min-height: 24px;
1522
- width: 24px;
1523
- min-width: 24px;
1524
- img {
1525
- height: 24px;
1526
- min-height: 24px;
1527
- width: 24px;
1528
- min-width: 24px;
1529
- }
1530
- `}
1531
- }
1532
1514
  `;
1533
1515
 
1534
1516
  const IconCSS = (viewType, loading, showClear) => css`
@@ -1789,7 +1771,6 @@ const DisabledCSS = css`
1789
1771
  Dropdown.defaultProps = {
1790
1772
  viewType: 'underlined',
1791
1773
  itemMode: 'normal',
1792
- itemMultipleSize: 'medium',
1793
1774
  className: '',
1794
1775
  label: '',
1795
1776
  placeholder: getGlobal('dropdownPlaceholder'),
@@ -1821,9 +1802,6 @@ Dropdown.propTypes = {
1821
1802
  /** The mode of item when rendering. */
1822
1803
  itemMode: PropTypes.oneOf(['normal', 'table', 'treeview']),
1823
1804
 
1824
- /** Use for [Chip](https://core.diginet.com.vn/ui/?path=/story/chip) component, default selected item when `multiple`. */
1825
- itemMultipleSize: PropTypes.oneOf(['small', 'medium']),
1826
-
1827
1805
  /** Class for component. */
1828
1806
  className: PropTypes.string,
1829
1807
 
@@ -1989,6 +1967,9 @@ Dropdown.propTypes = {
1989
1967
  /** Specifies a comparison operation used to search items. */
1990
1968
  searchMode: PropTypes.oneOf(['contains', 'startswith', 'equals']),
1991
1969
 
1970
+ /** Set restrictions regarding the maximum number of options that can be selected. (Use with prop `multiple`) */
1971
+ maximumSelectionLength: PropTypes.number,
1972
+
1992
1973
  /**
1993
1974
  * ref methods
1994
1975
  *