diginet-core-ui 1.4.48-beta.3 → 1.4.48-beta.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.
@@ -61,6 +61,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
61
61
  });
62
62
  const {
63
63
  action = {},
64
+ allowInput,
64
65
  allowSearch,
65
66
  children,
66
67
  className,
@@ -256,6 +257,19 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
256
257
  } else if (e.key === 'ArrowDown' && dropdownListRef.current) {
257
258
  e.preventDefault();
258
259
  dropdownListRef.current.firstChild.focus();
260
+ } else if (!!allowInput && txtSearch && multiple && e.key === 'Enter') {
261
+ if (!Array.isArray(currentValue[unique])) currentValue[unique] = [];
262
+ const newValueArrState = [...valueMulti];
263
+ if (!newValueArrState.some(v => JSON.stringify(v) === JSON.stringify(txtSearch))) {
264
+ newValueArrState.push(txtSearch);
265
+ }
266
+ setValueMulti(newValueArrState);
267
+ !!onChange && onChange({
268
+ value: newValueArrState,
269
+ data: {
270
+ [valueExpr]: txtSearch
271
+ }
272
+ });
259
273
  }
260
274
  };
261
275
  const closeDropdown = (event, reason, value) => {
@@ -635,7 +649,7 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
635
649
  scrollHeight,
636
650
  offsetHeight
637
651
  } = e.target;
638
- if (scrollHeight === Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
652
+ if (scrollHeight <= Math.ceil(scrollTop) + offsetHeight && dropdownListRef.current) {
639
653
  var _dropdownListRef$curr;
640
654
  const length = ((_dropdownListRef$curr = dropdownListRef.current.children) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.length) - ((vlObjDefaultState === null || vlObjDefaultState === void 0 ? void 0 : vlObjDefaultState.length) || 0);
641
655
  // dropdownListRef.current.removeEventListener('scroll', onLoadMoreHandler);
@@ -1158,6 +1172,27 @@ const Dropdown = /*#__PURE__*/memo( /*#__PURE__*/forwardRef((inProps, reference)
1158
1172
  });
1159
1173
  }
1160
1174
  items.push(item);
1175
+ } else if (allowInput && multiple) {
1176
+ const displayText = vl;
1177
+ let item;
1178
+ if (typeof renderSelectedItem === 'function') {
1179
+ item = renderSelectedItem({
1180
+ data,
1181
+ index
1182
+ });
1183
+ } else {
1184
+ item = jsx(Chip, {
1185
+ css: [parseWidth('100%'), parseMaxWidth('max-content')],
1186
+ key: index,
1187
+ startIcon: getIconFromData(data, true),
1188
+ label: displayText,
1189
+ size: 'medium',
1190
+ disabled: disabled,
1191
+ clearAble: !readOnly && !disabled,
1192
+ onRemove: e => onRemove(e, vl)
1193
+ });
1194
+ }
1195
+ items.push(item);
1161
1196
  }
1162
1197
  });
1163
1198
  }
@@ -1656,6 +1691,8 @@ Dropdown.propTypes = {
1656
1691
  }),
1657
1692
  /** If `true`, the input box for searching will be displayed. */
1658
1693
  allowSearch: PropTypes.bool,
1694
+ /** If `true`, the input value will be added when user hit Enter. */
1695
+ allowInput: PropTypes.bool,
1659
1696
  /** The content to be displayed inside the Dropdown box, such as TreeView. */
1660
1697
  children: PropTypes.node,
1661
1698
  /** The CSS class for the component. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.48-beta.3",
3
+ "version": "1.4.48-beta.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",