@royaloperahouse/harmonic 0.18.6-b → 0.18.6-c

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.
@@ -13,5 +13,6 @@ declare const Swipe: React.ForwardRefExoticComponent<{
13
13
  onIndexChange?: ((index: number) => void) | undefined;
14
14
  onActiveChange?: ((value: boolean) => void) | undefined;
15
15
  onOverflowChange?: ((overflow: boolean) => void) | undefined;
16
+ limitDragToNavigableRange?: boolean | undefined;
16
17
  } & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<SwipeRef>>;
17
18
  export default Swipe;
@@ -3653,6 +3653,9 @@ var RotatorButtons = function RotatorButtons(_ref) {
3653
3653
  isTablet = _useViewport.isTablet,
3654
3654
  hydrated = _useViewport.hydrated;
3655
3655
  if (!hydrated) return null;
3656
+ var preventMouseFocus = function preventMouseFocus(e) {
3657
+ e.preventDefault();
3658
+ };
3656
3659
  var onClickLeftHandler = function onClickLeftHandler() {
3657
3660
  if (onClickPrev) {
3658
3661
  onClickPrev();
@@ -3705,6 +3708,7 @@ var RotatorButtons = function RotatorButtons(_ref) {
3705
3708
  className: className
3706
3709
  }, availablePrev ? (/*#__PURE__*/React__default.createElement(IconWrapper$1, {
3707
3710
  size: size,
3711
+ onMouseDown: preventMouseFocus,
3708
3712
  onClick: onClickLeftHandler,
3709
3713
  onKeyDown: onPrevKeyDownHandler,
3710
3714
  tabIndex: 0,
@@ -3714,9 +3718,12 @@ var RotatorButtons = function RotatorButtons(_ref) {
3714
3718
  role: "button"
3715
3719
  }, renderPrevIcon())) : (/*#__PURE__*/React__default.createElement(IconUnavailableWrapper, {
3716
3720
  size: size,
3717
- "data-testid": "iconprevnoavailable"
3721
+ onMouseDown: preventMouseFocus,
3722
+ "data-testid": "iconprevnoavailable",
3723
+ "aria-hidden": "true"
3718
3724
  }, renderPrevIcon())), availableNext ? (/*#__PURE__*/React__default.createElement(IconWrapper$1, {
3719
3725
  size: size,
3726
+ onMouseDown: preventMouseFocus,
3720
3727
  onClick: onClickRightHandler,
3721
3728
  onKeyDown: onNextKeyDownHandler,
3722
3729
  tabIndex: 0,
@@ -3726,9 +3733,12 @@ var RotatorButtons = function RotatorButtons(_ref) {
3726
3733
  role: "button"
3727
3734
  }, renderNextIcon())) : (/*#__PURE__*/React__default.createElement(IconUnavailableWrapper, {
3728
3735
  size: size,
3729
- "data-testid": "iconnextnoavailable"
3736
+ onMouseDown: preventMouseFocus,
3737
+ "data-testid": "iconnextnoavailable",
3738
+ "aria-hidden": "true"
3730
3739
  }, renderNextIcon())), showFullscreen && !isMobile && !isTablet && (/*#__PURE__*/React__default.createElement(FullscreenIconWrapper, {
3731
3740
  size: size,
3741
+ onMouseDown: preventMouseFocus,
3732
3742
  onClick: onClickFullscreenHandler,
3733
3743
  onKeyDown: onFullscreenKeyDownHandler,
3734
3744
  tabIndex: 0,
@@ -6617,7 +6627,7 @@ var CastFiltersComponentWrapper = /*#__PURE__*/styled__default.div(_templateObje
6617
6627
  var CastFiltersWrapper = /*#__PURE__*/styled__default.div(_templateObject2$x || (_templateObject2$x = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n gap: 32px;\n\n @media ", " {\n gap: 15px;\n }\n"])), devices.mobile);
6618
6628
  var HeadingTextWrapper = /*#__PURE__*/styled__default.div(_templateObject3$m || (_templateObject3$m = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 44px;\n display: flex;\n align-items: center;\n"])));
6619
6629
  var RotatorButtonsWrapper = /*#__PURE__*/styled__default(GridItem)(_templateObject4$j || (_templateObject4$j = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n @media ", " {\n display: none;\n }\n"])), devices.mobile);
6620
- var CastWrapper = /*#__PURE__*/styled__default.div(_templateObject5$f || (_templateObject5$f = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 20px;\n overflow-x: scroll;\n scrollbar-width: none;\n -ms-overflow-style: none;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n @media ", " {\n flex-direction: column;\n gap: 10px;\n }\n"])), devices.mobile);
6630
+ var CastWrapper = /*#__PURE__*/styled__default.div(_templateObject5$f || (_templateObject5$f = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n gap: 20px;\n overflow-x: hidden;\n scrollbar-width: none;\n -ms-overflow-style: none;\n\n ::-webkit-scrollbar {\n display: none;\n }\n\n @media ", " {\n flex-direction: column;\n gap: 10px;\n overflow-x: scroll;\n }\n"])), devices.mobile);
6621
6631
  var ActionButtons = /*#__PURE__*/styled__default.div(_templateObject6$a || (_templateObject6$a = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: row;\n align-items: baseline;\n gap: 32px;\n\n .mobile-only {\n visibility: hidden;\n\n p {\n font-size: 14px;\n line-height: 17px;\n }\n }\n\n @media ", " {\n .mobile-only {\n visibility: visible;\n padding-block: 24px;\n font-size: 17px;\n line-height: 24px;\n }\n\n flex-direction: row-reverse;\n gap: unset;\n justify-content: space-between;\n border-block-end: 2px solid var(--base-color-light-grey);\n\n :has(.mobile-only) {\n justify-content: left;\n }\n\n :not(:has(.mobile-only)) {\n padding-block: 12px;\n }\n\n a {\n width: fit-content;\n }\n }\n"])), devices.mobile);
6622
6632
  var PersonWrapper = /*#__PURE__*/styled__default.div(_templateObject7$7 || (_templateObject7$7 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 6px;\n margin-block-start: 2px;\n margin-inline: 2px;\n\n p {\n font-size: 14px;\n line-height: 17px;\n }\n\n :focus-visible {\n outline: none;\n\n & > div:first-child {\n outline: 2px solid var(--color-base-black);\n }\n }\n\n @media ", " {\n flex-direction: row;\n gap: 20px;\n margin-block-end: 2px;\n margin-inline-end: unset;\n\n p {\n font-size: 17px;\n line-height: 24px;\n }\n }\n"])), devices.mobile);
6623
6633
  var PersonToggle = /*#__PURE__*/styled__default.div(_templateObject8$4 || (_templateObject8$4 = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n display: flex;\n width: 86px;\n height: 86px;\n min-width: 86px;\n border: 4px solid;\n border-color: ", ";\n border-radius: 50%;\n background: var(--color-base-white);\n position: relative;\n box-shadow: inset 0 0 0 4px var(--color-base-white);\n"])), function (_ref) {
@@ -6707,7 +6717,7 @@ var getMovedSlides = function getMovedSlides(delta, slideWidths) {
6707
6717
  return movedSlides;
6708
6718
  };
6709
6719
 
6710
- var _excluded$h = ["children", "infinite", "onIndexChange", "slidesOffsetBefore", "slidesAriaHidden", "onActiveChange", "onOverflowChange"];
6720
+ var _excluded$h = ["children", "infinite", "onIndexChange", "slidesOffsetBefore", "slidesAriaHidden", "onActiveChange", "onOverflowChange", "limitDragToNavigableRange"];
6711
6721
  var MAX_CLONES_NUMBER = 6;
6712
6722
  var CLICK_DRAG_THRESHOLD = 10;
6713
6723
  var getClonesCount = function getClonesCount(infinite, childrenLength) {
@@ -6732,6 +6742,8 @@ var Swipe = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6732
6742
  slidesAriaHidden = _ref$slidesAriaHidden === void 0 ? false : _ref$slidesAriaHidden,
6733
6743
  onActiveChange = _ref.onActiveChange,
6734
6744
  onOverflowChange = _ref.onOverflowChange,
6745
+ _ref$limitDragToNavig = _ref.limitDragToNavigableRange,
6746
+ limitDragToNavigableRange = _ref$limitDragToNavig === void 0 ? false : _ref$limitDragToNavig,
6735
6747
  props = _objectWithoutPropertiesLoose(_ref, _excluded$h);
6736
6748
  var containerRef = React.useRef(null);
6737
6749
  var childRefs = React.useRef([]);
@@ -6837,6 +6849,39 @@ var Swipe = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6837
6849
  }, 0);
6838
6850
  return (slidesOffsetBefore || 0) - widthsBefore;
6839
6851
  };
6852
+ var canScrollRightFromIndex = function canScrollRightFromIndex(index) {
6853
+ if (infinite) return true;
6854
+ if (slideWidths.length === 0 || containerWidth === 0) return false;
6855
+ var totalContentWidth = slideWidths.reduce(function (sum, width) {
6856
+ return sum + width;
6857
+ }, 0);
6858
+ var widthBeforeCurrent = slideWidths.slice(0, index).reduce(function (sum, width) {
6859
+ return sum + width;
6860
+ }, 0);
6861
+ var visibleSpace = containerWidth - (slidesOffsetBefore || 0);
6862
+ var remainingToRight = totalContentWidth - widthBeforeCurrent - visibleSpace;
6863
+ var visible = getVisibleIndexes(index, slideWidths, containerWidth, slides.length);
6864
+ var lastVisibleIndex = visible.length ? visible[visible.length - 1] : index;
6865
+ var nextIndex = lastVisibleIndex + 1;
6866
+ if (nextIndex >= slideWidths.length) return false;
6867
+ var nextSlideWidth = typeof slideWidths[nextIndex] === 'number' ? slideWidths[nextIndex] : 0;
6868
+ if (nextSlideWidth === 0) return false;
6869
+ var EPS = 1; // pixel tolerance
6870
+ // full next slide fits
6871
+ if (remainingToRight + EPS >= nextSlideWidth) return true;
6872
+ return remainingToRight > 0;
6873
+ };
6874
+ var canMoveNext = function canMoveNext() {
6875
+ return canScrollRightFromIndex(currentIndex);
6876
+ };
6877
+ var getMaxNavigableIndex = function getMaxNavigableIndex() {
6878
+ if (infinite) return slides.length - 1;
6879
+ var index = 0;
6880
+ while (index < slides.length - 1 && canScrollRightFromIndex(index)) {
6881
+ index += 1;
6882
+ }
6883
+ return index;
6884
+ };
6840
6885
  var navigateOnSwipeEnd = function navigateOnSwipeEnd() {
6841
6886
  var delta = currentTranslate.current - getTranslateX();
6842
6887
  var direction = delta > 0 ? -1 : 1;
@@ -6844,7 +6889,8 @@ var Swipe = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6844
6889
  if (Math.abs(delta) > 20) {
6845
6890
  movedSlides = Math.max(1, movedSlides);
6846
6891
  var targetIndex = currentIndex + direction * movedSlides;
6847
- var finalIndex = infinite ? targetIndex : Math.max(0, Math.min(slides.length - 1, targetIndex));
6892
+ var maxNavigableIndex = limitDragToNavigableRange ? getMaxNavigableIndex() : slides.length - 1;
6893
+ var finalIndex = infinite ? targetIndex : Math.max(0, Math.min(maxNavigableIndex, targetIndex));
6848
6894
  if (!infinite) {
6849
6895
  currentTranslate.current = getTranslateForIndex(finalIndex);
6850
6896
  setDragTranslateX(null);
@@ -6859,28 +6905,6 @@ var Swipe = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
6859
6905
  }
6860
6906
  setDragTranslateX(null);
6861
6907
  };
6862
- var canMoveNext = function canMoveNext() {
6863
- if (infinite) return true;
6864
- if (slideWidths.length === 0 || containerWidth === 0) return false;
6865
- var totalWidth = slideWidths.reduce(function (acc, w) {
6866
- return acc + w;
6867
- }, 0);
6868
- var widthsBefore = slideWidths.slice(0, currentIndex).reduce(function (acc, w) {
6869
- return acc + w;
6870
- }, 0);
6871
- var visibleSpace = containerWidth - (slidesOffsetBefore || 0);
6872
- var remainingToRight = totalWidth - widthsBefore - visibleSpace;
6873
- var visible = getVisibleIndexes(currentIndex, slideWidths, containerWidth, slides.length);
6874
- var lastVisibleIndex = visible.length ? visible[visible.length - 1] : currentIndex;
6875
- var nextIndex = lastVisibleIndex + 1;
6876
- if (nextIndex >= slideWidths.length) return false;
6877
- var nextSlideWidth = typeof slideWidths[nextIndex] === 'number' ? slideWidths[nextIndex] : 0;
6878
- if (nextSlideWidth === 0) return false;
6879
- var EPS = 1; // pixel tolerance
6880
- // full next slide fits
6881
- if (remainingToRight + EPS >= nextSlideWidth) return true;
6882
- return remainingToRight > 0;
6883
- };
6884
6908
  var handleTransitionEnd = function handleTransitionEnd() {
6885
6909
  setTransitioning(false);
6886
6910
  if (!infinite) return;
@@ -7092,11 +7116,13 @@ var CastFilters = function CastFilters(_ref) {
7092
7116
  };
7093
7117
  var onNext = function onNext() {
7094
7118
  var _swipeRef$current4;
7095
- return (_swipeRef$current4 = swipeRef.current) == null ? void 0 : _swipeRef$current4.nextSlide();
7119
+ if (!availableNext) return;
7120
+ (_swipeRef$current4 = swipeRef.current) == null || _swipeRef$current4.nextSlide();
7096
7121
  };
7097
7122
  var onPrev = function onPrev() {
7098
7123
  var _swipeRef$current5;
7099
- return (_swipeRef$current5 = swipeRef.current) == null ? void 0 : _swipeRef$current5.prevSlide();
7124
+ if (!availablePrev) return;
7125
+ (_swipeRef$current5 = swipeRef.current) == null || _swipeRef$current5.prevSlide();
7100
7126
  };
7101
7127
  React.useEffect(function () {
7102
7128
  var el = castWrapperRef.current;
@@ -7119,15 +7145,15 @@ var CastFilters = function CastFilters(_ref) {
7119
7145
  };
7120
7146
  }, []);
7121
7147
  var handleMouseDown = React.useCallback(function (e) {
7122
- if (!castWrapperRef.current) return;
7148
+ if (!isMobile || !castWrapperRef.current) return;
7123
7149
  isDraggingRef.current = true;
7124
7150
  hasDraggedRef.current = false;
7125
7151
  startXRef.current = e.clientX;
7126
7152
  scrollStartRef.current = castWrapperRef.current.scrollLeft;
7127
7153
  if (e.target === castWrapperRef.current) e.preventDefault();
7128
- }, []);
7154
+ }, [isMobile]);
7129
7155
  var handleMouseMove = React.useCallback(function (e) {
7130
- if (!isDraggingRef.current || !castWrapperRef.current) return;
7156
+ if (!isMobile || !isDraggingRef.current || !castWrapperRef.current) return;
7131
7157
  var deltaX = e.clientX - startXRef.current;
7132
7158
  var threshold = 5;
7133
7159
  if (Math.abs(deltaX) > threshold) {
@@ -7135,17 +7161,19 @@ var CastFilters = function CastFilters(_ref) {
7135
7161
  e.preventDefault();
7136
7162
  castWrapperRef.current.scrollLeft = scrollStartRef.current - deltaX;
7137
7163
  }
7138
- }, []);
7164
+ }, [isMobile]);
7139
7165
  var handleMouseUp = React.useCallback(function () {
7166
+ if (!isMobile) return;
7140
7167
  isDraggingRef.current = false;
7141
7168
  setTimeout(function () {
7142
7169
  hasDraggedRef.current = false;
7143
7170
  }, 0);
7144
- }, []);
7171
+ }, [isMobile]);
7145
7172
  var handleMouseLeave = React.useCallback(function () {
7173
+ if (!isMobile) return;
7146
7174
  isDraggingRef.current = false;
7147
7175
  hasDraggedRef.current = false;
7148
- }, []);
7176
+ }, [isMobile]);
7149
7177
  var handleClick = React__default.useCallback(function (index, onClick) {
7150
7178
  if (hasDraggedRef.current) return;
7151
7179
  if (onSelect) onSelect(index);
@@ -7231,7 +7259,8 @@ var CastFilters = function CastFilters(_ref) {
7231
7259
  onIndexChange: onIndexChangeHandler,
7232
7260
  "data-testid": "cast-filter-swipe",
7233
7261
  ref: swipeRef,
7234
- onOverflowChange: handleOverflowChange
7262
+ onOverflowChange: handleOverflowChange,
7263
+ limitDragToNavigableRange: true
7235
7264
  }, getPersonCards())))), showActionButtonsSection && (/*#__PURE__*/React__default.createElement(ActionButtons, null, selectedIndices.length === 0 && emptySelectionText && (/*#__PURE__*/React__default.createElement(BodyCopyHarmonic, {
7236
7265
  size: "medium",
7237
7266
  className: "mobile-only"