@mmb-digital/ds-lilly 0.7.4 → 0.7.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.
Files changed (2) hide show
  1. package/dist/ds-lilly.js +16 -10
  2. package/package.json +1 -1
package/dist/ds-lilly.js CHANGED
@@ -107476,17 +107476,23 @@ var Select2 = function (_a) {
107476
107476
  var itemIndexPosition = getItemIndexPosition(itemIndex);
107477
107477
  setCurrentItemPosition(itemIndexPosition);
107478
107478
  }, [isDropdownVisible, getItemIndexByValue, value, getItemIndexPosition]);
107479
- var scrollToItem = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (item, category) {
107480
- var _a, _b, _c, _d, _e;
107479
+ var scrollToItem = Object(external_root_React_commonjs2_react_commonjs_react_amd_react_umd_react_["useCallback"])(function (item, category, center) {
107480
+ var _a, _b, _c, _d, _e, _f;
107481
107481
  if (category === void 0) { category = -1; }
107482
+ if (center === void 0) { center = false; }
107482
107483
  var itemElementId = isCategorised ? name + "_option-" + category + "-" + item : name + "_option-" + item;
107483
- var dropdownId = name + "_dropdown";
107484
- var dropdownHalfHeight = (((_a = document.getElementById(dropdownId)) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
107485
- var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
107486
- var itemOffset = ((_c = document.getElementById(itemElementId)) === null || _c === void 0 ? void 0 : _c.offsetTop) || 0;
107487
- if (itemOffset > dropdownHalfHeight) {
107488
- (_d = document
107489
- .getElementById(dropdownId)) === null || _d === void 0 ? void 0 : _d.scrollTo(0, (((_e = document.getElementById(itemElementId)) === null || _e === void 0 ? void 0 : _e.offsetTop) || 0) - dropdownHalfHeight + itemHalfHeight);
107484
+ if (center) {
107485
+ var dropdownId = name + "_dropdown";
107486
+ var dropdownHalfHeight = (((_a = document.getElementById(dropdownId)) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0) / 2;
107487
+ var itemHalfHeight = (((_b = document.getElementById(itemElementId)) === null || _b === void 0 ? void 0 : _b.clientHeight) || 0) / 2;
107488
+ var itemOffset = ((_c = document.getElementById(itemElementId)) === null || _c === void 0 ? void 0 : _c.offsetTop) || 0;
107489
+ if (itemOffset > dropdownHalfHeight) {
107490
+ (_d = document
107491
+ .getElementById(dropdownId)) === null || _d === void 0 ? void 0 : _d.scrollTo(0, (((_e = document.getElementById(itemElementId)) === null || _e === void 0 ? void 0 : _e.offsetTop) || 0) - dropdownHalfHeight + itemHalfHeight);
107492
+ }
107493
+ }
107494
+ else {
107495
+ (_f = document.getElementById(itemElementId)) === null || _f === void 0 ? void 0 : _f.scrollIntoView({ block: 'nearest' });
107490
107496
  }
107491
107497
  }, [isCategorised, name]);
107492
107498
  var handleComboBoxClick = function () {
@@ -107496,7 +107502,7 @@ var Select2 = function (_a) {
107496
107502
  var listElementId;
107497
107503
  if (currentItemPosition > -1) {
107498
107504
  var _b = itemsIndex[currentItemPosition], category = _b.category, item = _b.item;
107499
- scrollToItem(item, category);
107505
+ scrollToItem(item, category, true);
107500
107506
  listElementId = isCategorised ? name + "_list-" + category : name + "_list";
107501
107507
  }
107502
107508
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmb-digital/ds-lilly",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "description": "MMB LILLY design system",
5
5
  "license": "UNLICENSED",
6
6
  "sideEffects": false,