@luminati-io/uikit 6.3.112 → 6.3.114

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 = {
@@ -47203,7 +47234,7 @@ __webpack_require__.r(__webpack_exports__);
47203
47234
  /*jslint react:true*/
47204
47235
  var _excluded = ["onChange", "disabledDays", "isRange", "defaultMonth", "month", "onMonthChange", "renderPopover", "format", "size", "value", "popoverPlacement", "captionLayout", "hideOnChange", "isOpen", "pickerProps"],
47205
47236
  _excluded2 = ["popoverPlacement", "popoverProps", "size", "placeholder", "onOpenChange", "isOpen", "inputEditable", "onChange"],
47206
- _excluded3 = ["mode", "selected", "onChange", "renderPopover", "hidePopover", "captionLayout", "hideOnChange", "isOpen", "pickerProps"],
47237
+ _excluded3 = ["mode", "selected", "onChange", "renderPopover", "hidePopover", "captionLayout", "hideOnChange", "isOpen", "pickerProps", "onMonthChange"],
47207
47238
  _excluded4 = ["options"],
47208
47239
  _excluded5 = ["modifiers", "tabIndex"];
47209
47240
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
@@ -47442,6 +47473,11 @@ var PickerField = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().forw
47442
47473
  })));
47443
47474
  });
47444
47475
  PickerField.displayName = 'PickerField';
47476
+ function clampToMonthDay(day, year, monthIndex) {
47477
+ var daysInMonth = new Date(year, monthIndex + 1, 0).getDate();
47478
+ var d = Math.min(day, daysInMonth);
47479
+ return new Date(year, monthIndex, d);
47480
+ }
47445
47481
  var PickerPopover = function PickerPopover(_ref) {
47446
47482
  var mode = _ref.mode,
47447
47483
  selected = _ref.selected,
@@ -47452,6 +47488,7 @@ var PickerPopover = function PickerPopover(_ref) {
47452
47488
  hideOnChange = _ref.hideOnChange,
47453
47489
  isOpen = _ref.isOpen,
47454
47490
  pickerProps = _ref.pickerProps,
47491
+ onMonthChange = _ref.onMonthChange,
47455
47492
  rest = _objectWithoutProperties(_ref, _excluded3);
47456
47493
  var onSelect = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function (_, day, modifiers) {
47457
47494
  if (modifiers.disabled) return;
@@ -47473,6 +47510,13 @@ var PickerPopover = function PickerPopover(_ref) {
47473
47510
  onChange(value);
47474
47511
  if (hideOnChange && (mode != 'range' || value.from && value.to)) hidePopover();
47475
47512
  }, [mode, selected]);
47513
+ var _onMonthChange = (0,react__WEBPACK_IMPORTED_MODULE_1__.useCallback)(function (_m) {
47514
+ onMonthChange === null || onMonthChange === void 0 || onMonthChange(_m);
47515
+ if (mode == 'range') return;
47516
+ if (selected) {
47517
+ onChange(clampToMonthDay(selected.getDate(), _m.getFullYear(), _m.getMonth()));
47518
+ }
47519
+ }, [onMonthChange, selected, mode, onChange]);
47476
47520
  var render = typeof renderPopover == 'function' ? renderPopover : function (_ref2) {
47477
47521
  var picker = _ref2.picker;
47478
47522
  return picker;
@@ -47485,6 +47529,7 @@ var PickerPopover = function PickerPopover(_ref) {
47485
47529
  }, render({
47486
47530
  picker: /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_1___default().createElement(StyledDayPicker, _extends({}, rest, pickerProps, {
47487
47531
  captionLayout: captionLayout,
47532
+ onMonthChange: _onMonthChange,
47488
47533
  onSelect: onSelect,
47489
47534
  mode: mode,
47490
47535
  selected: selected