diginet-core-ui 1.4.4 → 1.4.5

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.
@@ -122,7 +122,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
122
122
  }));
123
123
  const [openState, setOpenState] = useState(false);
124
124
  const [showClear, setShowClear] = useState(false);
125
- const [textValue, setTextValue] = useState('');
125
+ const [valueSingle, setValueSingle] = useState('');
126
126
  const [txtSearch, setTxtSearch] = useState('');
127
127
  const [popoverWidth, setPopoverWidth] = useState(0);
128
128
  const [loadingState, setLoadingState] = useState(loading);
@@ -937,7 +937,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
937
937
  // dropdownListRef.current.querySelectorAll('input').forEach(input => (input.checked = false));
938
938
  // }
939
939
  } else {
940
- setTextValue('');
940
+ setValueSingle('');
941
941
  }
942
942
  // onChangeValue('', '');
943
943
  setValueMulti([]);
@@ -964,12 +964,14 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
964
964
  // inputRef.current.innerHTML = '';
965
965
  currentValue[unique] = [];
966
966
  } else {
967
- if (typeof renderSelectedItem === 'function' || iconExpr && iconExpr !== 'none' && !isSearch[unique]) {
968
- // inputRef.current.innerHTML = '';
969
- } else if (!isSearch[unique]) {
970
- inputRef.current.value = '';
971
- setTextValue('');
972
- }
967
+ // if (
968
+ // typeof renderSelectedItem === 'function' ||
969
+ // (iconExpr && iconExpr !== 'none' && !isSearch[unique])
970
+ // ) {
971
+ // inputRef.current.innerHTML = '';
972
+ // } else if (!isSearch[unique]) {
973
+ // inputRef.current.value = '';
974
+ // }
973
975
  currentValue[unique] = '';
974
976
  }
975
977
  return;
@@ -1022,7 +1024,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1022
1024
  }
1023
1025
  }
1024
1026
  if (!isSearch[unique]) {
1025
- inputRef.current.value = source;
1027
+ // inputRef.current.value = source;
1026
1028
  }
1027
1029
  }
1028
1030
  };
@@ -1059,26 +1061,34 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1059
1061
  hoverTooltip: !_isMobile
1060
1062
  }, content);
1061
1063
  if (typeof renderSelectedItem === 'function') {
1062
- inputRef.current.innerHTML = '';
1064
+ // inputRef.current.innerHTML = '';
1063
1065
  const item = renderSelectedItem({
1064
1066
  data
1065
1067
  });
1066
- const el = document.createElement('div');
1067
- el.style.display = 'flex';
1068
- el.style.width = '100%';
1069
- el.style.minHeight = '24px';
1070
- if (!multilineSelectedItem) el.style.maxHeight = '24px';
1071
- ReactDOM.render(item, inputRef.current.appendChild(el));
1068
+ // const el = document.createElement('div');
1069
+ // el.style.display = 'flex';
1070
+ // el.style.width = '100%';
1071
+ // el.style.minHeight = '24px';
1072
+ // if (!multilineSelectedItem) el.style.maxHeight = '24px';
1073
+ const el = jsx("div", {
1074
+ css: [displayFlex, parseWidth('100%'), parseMinHeight(24), !multilineSelectedItem && parseMaxHeight(24)]
1075
+ }, item);
1076
+ setValueSingle(el);
1077
+ // ReactDOM.render(item, inputRef.current.appendChild(el));
1072
1078
  } else if (iconExpr && iconExpr !== 'none') {
1073
- inputRef.current.innerHTML = '';
1079
+ // inputRef.current.innerHTML = '';
1074
1080
  const icon = getIconFromData(data);
1075
1081
  const valueWithIcon = jsx(Fragment, null, icon && icon, renderContent(text));
1076
- const el = document.createElement('div');
1077
- el.style.cssText = 'display: flex; align-items: center; min-height:24px;';
1078
- ReactDOM.render(valueWithIcon, inputRef.current.appendChild(el));
1082
+ // const el = document.createElement('div');
1083
+ // el.style.cssText = 'display: flex; align-items: center; min-height:24px;';
1084
+ const el = jsx("div", {
1085
+ css: [displayFlex, itemsCenter, parseMinHeight(24)]
1086
+ }, valueWithIcon);
1087
+ setValueSingle(el);
1088
+ // ReactDOM.render(valueWithIcon, inputRef.current.appendChild(el));
1079
1089
  } else {
1080
- inputRef.current.value = text;
1081
- setTextValue(text);
1090
+ // inputRef.current.value = text;
1091
+ setValueSingle(text);
1082
1092
  }
1083
1093
  };
1084
1094
  useImperativeHandle(reference, () => {
@@ -1187,9 +1197,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1187
1197
  }
1188
1198
  }, [valueProp]);
1189
1199
  useEffect(() => {
1190
- if (
1191
- // valueProp !== undefined &&
1192
- !dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique])) {
1200
+ if (valueProp !== undefined && (!dropdownListRef.current || children || JSON.stringify(valueProp) !== JSON.stringify(currentValue[unique]))) {
1193
1201
  setValueIntoInput(valueProp);
1194
1202
  }
1195
1203
  }, [valueProp, dataSourceState]);
@@ -1355,7 +1363,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1355
1363
  return false;
1356
1364
  }
1357
1365
  }
1358
- }) : jsx("div", {
1366
+ }, valueSingle) : jsx("div", {
1359
1367
  css: _DropdownInputCSS,
1360
1368
  onClick: onClickInput
1361
1369
  }, jsx(Typography, {
@@ -1367,7 +1375,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1367
1375
  lineHeight: multiple ? '30px' : '24px'
1368
1376
  },
1369
1377
  tabIndex: -1
1370
- }, textValue))), jsx("div", {
1378
+ }, valueSingle))), jsx("div", {
1371
1379
  ref: iconRef,
1372
1380
  css: _IconCSS,
1373
1381
  className: 'DGN-UI-Dropdown-Icon'
@@ -1386,7 +1394,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(({
1386
1394
  onClick: setShowDropdown,
1387
1395
  disabled: disabled || readOnly
1388
1396
  }) : null));
1389
- }, [openState, showClear, textValue, valueMulti, loadingState, dataSourceState, clearAble, dataSource, disabled, displayExpr, inputProps, inputStyle, multilineSelectedItem, multiple, onChange, placeholder, readOnly, renderSelectedItem, valueExpr, valueObjectDefault, viewType]);
1397
+ }, [openState, showClear, valueSingle, valueMulti, loadingState, dataSourceState, clearAble, dataSource, disabled, displayExpr, inputProps, inputStyle, multilineSelectedItem, multiple, onChange, placeholder, readOnly, renderSelectedItem, valueExpr, valueObjectDefault, viewType]);
1390
1398
  const ErrorView = useMemo(() => {
1391
1399
  return error ? jsx(HelperText, {
1392
1400
  ...helperTextProps,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "The DigiNet core ui",
5
5
  "homepage": "https://diginet.com.vn",
6
6
  "main": "index.js",
package/readme.md CHANGED
@@ -38,6 +38,10 @@ npm test
38
38
  ```
39
39
 
40
40
  ## Changelog
41
+ ## 1.4.5
42
+ - \[Changed\]: Dropdown – Optimize code remove innerHTML = ''
43
+ - \[Fixed\]: Dropdown – Fix bug not show value
44
+
41
45
  ## 1.4.4
42
46
  - \[Fixed\]: Dropdown – Fix bug blank selected item when use renderSelectedItem
43
47