@mmb-digital/ds-lilly 0.3.6 → 0.3.7

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 (2) hide show
  1. package/dist/ds-lilly.js +15 -9
  2. package/package.json +1 -1
package/dist/ds-lilly.js CHANGED
@@ -98331,11 +98331,11 @@ var Autocomplete2 = function (_a) {
98331
98331
  .map(function (item, index) { return (!item.isDisabled ? { category: -1, item: index } : undefined); })
98332
98332
  .filter(Boolean);
98333
98333
  }
98334
- if (emptyValueLabel && !fulltextValue) {
98334
+ if (emptyValueLabel && (fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || !value)) {
98335
98335
  return Autocomplete2_spreadArray([{ item: -1, category: -1 }], map);
98336
98336
  }
98337
98337
  return map;
98338
- }, [items, isCategorised, fulltextValue]);
98338
+ }, [items, isCategorised, fulltextValue, value, buttonValue]);
98339
98339
  var showCreatable = !!onCreateNewItem &&
98340
98340
  (itemsIndex.length === 0 || canAlwaysCreateNewItem) &&
98341
98341
  typingMode &&
@@ -98436,16 +98436,21 @@ var Autocomplete2 = function (_a) {
98436
98436
  }
98437
98437
  }, [pagingState.loading]);
98438
98438
  var scrollToItem = function (item, category, center) {
98439
- var _a, _b, _c;
98439
+ var _a, _b, _c, _d, _e, _f;
98440
98440
  if (category === void 0) { category = -1; }
98441
98441
  if (center === void 0) { center = false; }
98442
98442
  var itemElementId = isCategorised ? name + "_option-" + category + "-" + item : name + "_option-" + item;
98443
98443
  if (center) {
98444
- (_a = document
98445
- .getElementById('autocomplete_dropdown')) === null || _a === void 0 ? void 0 : _a.scrollTo(0, ((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.offsetTop) || 0);
98444
+ var dropdownHalfHeight = (((_a = document.getElementById('autocomplete_dropdown')) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
98445
+ var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
98446
+ var itemOffset = ((_c = document.getElementById(itemElementId)) === null || _c === void 0 ? void 0 : _c.offsetTop) || 0;
98447
+ if (itemOffset > dropdownHalfHeight) {
98448
+ (_d = document
98449
+ .getElementById('autocomplete_dropdown')) === null || _d === void 0 ? void 0 : _d.scrollTo(0, (((_e = document.getElementById(itemElementId)) === null || _e === void 0 ? void 0 : _e.offsetTop) || 0) - dropdownHalfHeight + itemHalfHeight);
98450
+ }
98446
98451
  }
98447
98452
  else {
98448
- (_c = document.getElementById(itemElementId)) === null || _c === void 0 ? void 0 : _c.scrollIntoView({ block: center ? 'center' : 'nearest' });
98453
+ (_f = document.getElementById(itemElementId)) === null || _f === void 0 ? void 0 : _f.scrollIntoView({ block: 'nearest' });
98449
98454
  }
98450
98455
  };
98451
98456
  var focusCreatable = function () {
@@ -98690,11 +98695,12 @@ var Autocomplete2 = function (_a) {
98690
98695
  if (key === KEYS.Enter) {
98691
98696
  event.preventDefault();
98692
98697
  if (isDropdownVisible) {
98698
+ var minItemsToAutoselect = emptyValueLabel ? 2 : 1;
98693
98699
  if (showCreatable && itemsIndex.length === 0) {
98694
98700
  handleCreateNewOption();
98695
98701
  }
98696
- else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length > 0) {
98697
- var _a = itemsIndex[0], category = _a.category, item = _a.item;
98702
+ else if (fulltextValue && fulltextValue !== (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) && itemsIndex.length >= minItemsToAutoselect) {
98703
+ var _a = itemsIndex[minItemsToAutoselect - 1], category = _a.category, item = _a.item;
98698
98704
  var selectedItem = isCategorised
98699
98705
  ? items[category].items[item]
98700
98706
  : items[item];
@@ -98839,7 +98845,7 @@ var Autocomplete2 = function (_a) {
98839
98845
  };
98840
98846
  var focusedItem = itemsIndex[currentItemPosition];
98841
98847
  var select2context = {
98842
- emptyValueLabel: !fulltextValue ? emptyValueLabel : undefined,
98848
+ emptyValueLabel: fulltextValue === (buttonValue === null || buttonValue === void 0 ? void 0 : buttonValue.label) || !value ? emptyValueLabel : undefined,
98843
98849
  focusedCategoryIndex: focusedItem ? focusedItem.category : -1,
98844
98850
  focusedItemIndex: focusedItem ? focusedItem.item : -1,
98845
98851
  items: items,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmb-digital/ds-lilly",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "MMB LILLY design system",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": false,