@luminati-io/uikit 6.3.112 → 6.3.113

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.
@@ -40894,7 +40894,6 @@ var Breadcrumbs = function Breadcrumbs(props) {
40894
40894
  activeIndex = _useState2[0],
40895
40895
  setActiveIndex = _useState2[1];
40896
40896
  var containerRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
40897
- var lastItemRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
40898
40897
  var moreRef = (0,react__WEBPACK_IMPORTED_MODULE_1__.useRef)(null);
40899
40898
  var _useState3 = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(items),
40900
40899
  _useState4 = _slicedToArray(_useState3, 2),
@@ -40909,33 +40908,60 @@ var Breadcrumbs = function Breadcrumbs(props) {
40909
40908
  recalculationRender = _useState8[0],
40910
40909
  setRecalculationRender = _useState8[1];
40911
40910
  var calculateVisibleItems = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function () {
40912
- var _lastItemRef$current, _moreRef$current;
40913
- var lastItem = items[items.length - 1];
40914
- var tempVisibleItems = [];
40915
- var tempHiddenItems = [];
40916
- var containerWidth = containerRef.current.offsetWidth;
40917
- var containerChild = Array.from(containerRef.current.children);
40918
- var containerChildrenWidth = containerChild.reduce(function (acc, child) {
40919
- return acc + child.offsetWidth;
40911
+ var container = containerRef.current;
40912
+ if (!container) return {
40913
+ visible: items,
40914
+ hidden: []
40915
+ };
40916
+ var containerWidth = container.offsetWidth;
40917
+ var moreButton = moreRef.current;
40918
+ var itemElements = Array.from(container.children).filter(function (child) {
40919
+ return child !== moreButton;
40920
+ });
40921
+ var itemWidths = itemElements.map(function (el) {
40922
+ return el.offsetWidth;
40923
+ });
40924
+ var totalWidth = itemWidths.reduce(function (sum, width) {
40925
+ return sum + width;
40920
40926
  }, 0);
40921
- var lastItemWidth = ((_lastItemRef$current = lastItemRef.current) === null || _lastItemRef$current === void 0 ? void 0 : _lastItemRef$current.offsetWidth) || 0;
40922
- var moreRefWidth = ((_moreRef$current = moreRef.current) === null || _moreRef$current === void 0 ? void 0 : _moreRef$current.offsetWidth) || 0;
40923
- if (containerWidth < containerChildrenWidth - moreRefWidth) {
40924
- var stopWidth = 0;
40925
- containerChild.splice(-2);
40926
- containerChild.forEach(function (item, index) {
40927
- stopWidth += item.offsetWidth;
40928
- if (containerWidth - lastItemWidth - moreRefWidth >= stopWidth) tempVisibleItems.push(items[index]);else tempHiddenItems.push(items[index]);
40929
- });
40930
- tempVisibleItems.push(lastItem);
40927
+ if (containerWidth >= totalWidth) return {
40928
+ visible: items,
40929
+ hidden: []
40930
+ };
40931
+ if (items.length === 0) return {
40932
+ visible: [],
40933
+ hidden: []
40934
+ };
40935
+ var availableWidth = Math.max(0, containerWidth - ((moreButton === null || moreButton === void 0 ? void 0 : moreButton.offsetWidth) || 0));
40936
+ var lastIndex = items.length - 1;
40937
+ var lastWidth = itemWidths[lastIndex];
40938
+ var firstWidth = itemWidths[0];
40939
+ if (lastWidth > availableWidth) {
40931
40940
  return {
40932
- visible: tempVisibleItems,
40933
- hidden: tempHiddenItems
40941
+ visible: [items[lastIndex]],
40942
+ hidden: items.slice(0, lastIndex)
40934
40943
  };
40935
40944
  }
40945
+ var visibleIndices = new Set([lastIndex]);
40946
+ var usedWidth = lastWidth;
40947
+ if (firstWidth <= availableWidth - usedWidth) {
40948
+ visibleIndices.add(0);
40949
+ usedWidth += firstWidth;
40950
+ for (var i = lastIndex - 1; i >= 1; i--) {
40951
+ var width = itemWidths[i];
40952
+ if (usedWidth + width <= availableWidth) {
40953
+ visibleIndices.add(i);
40954
+ usedWidth += width;
40955
+ }
40956
+ }
40957
+ }
40936
40958
  return {
40937
- visible: items,
40938
- hidden: []
40959
+ visible: items.filter(function (_, idx) {
40960
+ return visibleIndices.has(idx);
40961
+ }),
40962
+ hidden: items.filter(function (_, idx) {
40963
+ return !visibleIndices.has(idx);
40964
+ })
40939
40965
  };
40940
40966
  }, [items]);
40941
40967
  (0,react__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect)(function () {
@@ -41002,10 +41028,12 @@ var Breadcrumbs = function Breadcrumbs(props) {
41002
41028
  isLastItem: visibleItems.length - 1 == index,
41003
41029
  minItemWidth: minItemWidth,
41004
41030
  maxItemWidth: maxItemWidth,
41005
- ref: visibleItems.length - 1 == index ? lastItemRef : null,
41006
41031
  isCompactMode: visibleItems.length <= 1
41007
41032
  });
41008
41033
  });
41034
+ var firstIsHidden = hiddenItems.some(function (h) {
41035
+ return h === items[0];
41036
+ });
41009
41037
  return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(BreadcrumbsContainer, _extends({
41010
41038
  ref: containerRef
41011
41039
  }, (0,_util__WEBPACK_IMPORTED_MODULE_4__.pickAttrs)(rest), {
@@ -41021,10 +41049,13 @@ var Breadcrumbs = function Breadcrumbs(props) {
41021
41049
  isCompactMode: visibleItems.length <= 1,
41022
41050
  active: activeIndex === 0,
41023
41051
  item: items[0]
41024
- }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, itemsList.slice(0, -1), (recalculationRender || hiddenItems.length > 0) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_collapsed_items__WEBPACK_IMPORTED_MODULE_8__.CollapsedItems, {
41052
+ }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement((react__WEBPACK_IMPORTED_MODULE_1___default().Fragment), null, firstIsHidden && (recalculationRender || hiddenItems.length > 0) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_collapsed_items__WEBPACK_IMPORTED_MODULE_8__.CollapsedItems, {
41053
+ ref: moreRef,
41054
+ items: hiddenItems
41055
+ }), !firstIsHidden && itemsList[0], !firstIsHidden && (recalculationRender || hiddenItems.length > 0) && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(_collapsed_items__WEBPACK_IMPORTED_MODULE_8__.CollapsedItems, {
41025
41056
  ref: moreRef,
41026
41057
  items: hiddenItems
41027
- }), itemsList.slice(-1)));
41058
+ }), firstIsHidden ? itemsList : itemsList.slice(1)));
41028
41059
  };
41029
41060
  Breadcrumbs.displayName = 'Breadcrumbs';
41030
41061
  Breadcrumbs.defaultValues = {