@royaloperahouse/harmonic 0.19.0 → 0.19.1

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.
@@ -3677,6 +3677,9 @@ var RotatorButtons = function RotatorButtons(_ref) {
3677
3677
  isTablet = _useViewport.isTablet,
3678
3678
  hydrated = _useViewport.hydrated;
3679
3679
  if (!hydrated) return null;
3680
+ var preventMouseFocus = function preventMouseFocus(e) {
3681
+ e.preventDefault();
3682
+ };
3680
3683
  var onClickLeftHandler = function onClickLeftHandler() {
3681
3684
  if (onClickPrev) {
3682
3685
  onClickPrev();
@@ -3729,6 +3732,7 @@ var RotatorButtons = function RotatorButtons(_ref) {
3729
3732
  className: className
3730
3733
  }, availablePrev ? (/*#__PURE__*/React__default.createElement(IconWrapper$1, {
3731
3734
  size: size,
3735
+ onMouseDown: preventMouseFocus,
3732
3736
  onClick: onClickLeftHandler,
3733
3737
  onKeyDown: onPrevKeyDownHandler,
3734
3738
  tabIndex: 0,
@@ -3738,9 +3742,12 @@ var RotatorButtons = function RotatorButtons(_ref) {
3738
3742
  role: "button"
3739
3743
  }, renderPrevIcon())) : (/*#__PURE__*/React__default.createElement(IconUnavailableWrapper, {
3740
3744
  size: size,
3741
- "data-testid": "iconprevnoavailable"
3745
+ onMouseDown: preventMouseFocus,
3746
+ "data-testid": "iconprevnoavailable",
3747
+ "aria-hidden": "true"
3742
3748
  }, renderPrevIcon())), availableNext ? (/*#__PURE__*/React__default.createElement(IconWrapper$1, {
3743
3749
  size: size,
3750
+ onMouseDown: preventMouseFocus,
3744
3751
  onClick: onClickRightHandler,
3745
3752
  onKeyDown: onNextKeyDownHandler,
3746
3753
  tabIndex: 0,
@@ -3750,9 +3757,12 @@ var RotatorButtons = function RotatorButtons(_ref) {
3750
3757
  role: "button"
3751
3758
  }, renderNextIcon())) : (/*#__PURE__*/React__default.createElement(IconUnavailableWrapper, {
3752
3759
  size: size,
3753
- "data-testid": "iconnextnoavailable"
3760
+ onMouseDown: preventMouseFocus,
3761
+ "data-testid": "iconnextnoavailable",
3762
+ "aria-hidden": "true"
3754
3763
  }, renderNextIcon())), showFullscreen && !isMobile && !isTablet && (/*#__PURE__*/React__default.createElement(FullscreenIconWrapper, {
3755
3764
  size: size,
3765
+ onMouseDown: preventMouseFocus,
3756
3766
  onClick: onClickFullscreenHandler,
3757
3767
  onKeyDown: onFullscreenKeyDownHandler,
3758
3768
  tabIndex: 0,
@@ -6649,7 +6659,7 @@ var CastFiltersComponentWrapper = /*#__PURE__*/styled.div(_templateObject$J || (
6649
6659
  var CastFiltersWrapper = /*#__PURE__*/styled.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);
6650
6660
  var HeadingTextWrapper = /*#__PURE__*/styled.div(_templateObject3$m || (_templateObject3$m = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n height: 44px;\n display: flex;\n align-items: center;\n"])));
6651
6661
  var RotatorButtonsWrapper = /*#__PURE__*/styled(GridItem)(_templateObject4$j || (_templateObject4$j = /*#__PURE__*/_taggedTemplateLiteralLoose(["\n @media ", " {\n display: none;\n }\n"])), devices.mobile);
6652
- var CastWrapper = /*#__PURE__*/styled.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);
6662
+ var CastWrapper = /*#__PURE__*/styled.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);
6653
6663
  var ActionButtons = /*#__PURE__*/styled.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);
6654
6664
  var PersonWrapper = /*#__PURE__*/styled.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);
6655
6665
  var PersonToggle = /*#__PURE__*/styled.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) {
@@ -6739,7 +6749,7 @@ var getMovedSlides = function getMovedSlides(delta, slideWidths) {
6739
6749
  return movedSlides;
6740
6750
  };
6741
6751
 
6742
- var _excluded$h = ["children", "infinite", "onIndexChange", "slidesOffsetBefore", "slidesAriaHidden", "onActiveChange", "onOverflowChange"];
6752
+ var _excluded$h = ["children", "infinite", "onIndexChange", "slidesOffsetBefore", "slidesAriaHidden", "onActiveChange", "onOverflowChange", "limitDragToNavigableRange"];
6743
6753
  var MAX_CLONES_NUMBER = 6;
6744
6754
  var CLICK_DRAG_THRESHOLD = 10;
6745
6755
  var getClonesCount = function getClonesCount(infinite, childrenLength) {
@@ -6764,6 +6774,8 @@ var Swipe = /*#__PURE__*/forwardRef(function (_ref, ref) {
6764
6774
  slidesAriaHidden = _ref$slidesAriaHidden === void 0 ? false : _ref$slidesAriaHidden,
6765
6775
  onActiveChange = _ref.onActiveChange,
6766
6776
  onOverflowChange = _ref.onOverflowChange,
6777
+ _ref$limitDragToNavig = _ref.limitDragToNavigableRange,
6778
+ limitDragToNavigableRange = _ref$limitDragToNavig === void 0 ? false : _ref$limitDragToNavig,
6767
6779
  props = _objectWithoutPropertiesLoose(_ref, _excluded$h);
6768
6780
  var containerRef = useRef(null);
6769
6781
  var childRefs = useRef([]);
@@ -6869,6 +6881,39 @@ var Swipe = /*#__PURE__*/forwardRef(function (_ref, ref) {
6869
6881
  }, 0);
6870
6882
  return (slidesOffsetBefore || 0) - widthsBefore;
6871
6883
  };
6884
+ var canScrollRightFromIndex = function canScrollRightFromIndex(index) {
6885
+ if (infinite) return true;
6886
+ if (slideWidths.length === 0 || containerWidth === 0) return false;
6887
+ var totalContentWidth = slideWidths.reduce(function (sum, width) {
6888
+ return sum + width;
6889
+ }, 0);
6890
+ var widthBeforeCurrent = slideWidths.slice(0, index).reduce(function (sum, width) {
6891
+ return sum + width;
6892
+ }, 0);
6893
+ var visibleSpace = containerWidth - (slidesOffsetBefore || 0);
6894
+ var remainingToRight = totalContentWidth - widthBeforeCurrent - visibleSpace;
6895
+ var visible = getVisibleIndexes(index, slideWidths, containerWidth, slides.length);
6896
+ var lastVisibleIndex = visible.length ? visible[visible.length - 1] : index;
6897
+ var nextIndex = lastVisibleIndex + 1;
6898
+ if (nextIndex >= slideWidths.length) return false;
6899
+ var nextSlideWidth = typeof slideWidths[nextIndex] === 'number' ? slideWidths[nextIndex] : 0;
6900
+ if (nextSlideWidth === 0) return false;
6901
+ var EPS = 1; // pixel tolerance
6902
+ // full next slide fits
6903
+ if (remainingToRight + EPS >= nextSlideWidth) return true;
6904
+ return remainingToRight > 0;
6905
+ };
6906
+ var canMoveNext = function canMoveNext() {
6907
+ return canScrollRightFromIndex(currentIndex);
6908
+ };
6909
+ var getMaxNavigableIndex = function getMaxNavigableIndex() {
6910
+ if (infinite) return slides.length - 1;
6911
+ var index = 0;
6912
+ while (index < slides.length - 1 && canScrollRightFromIndex(index)) {
6913
+ index += 1;
6914
+ }
6915
+ return index;
6916
+ };
6872
6917
  var navigateOnSwipeEnd = function navigateOnSwipeEnd() {
6873
6918
  var delta = currentTranslate.current - getTranslateX();
6874
6919
  var direction = delta > 0 ? -1 : 1;
@@ -6876,7 +6921,8 @@ var Swipe = /*#__PURE__*/forwardRef(function (_ref, ref) {
6876
6921
  if (Math.abs(delta) > 20) {
6877
6922
  movedSlides = Math.max(1, movedSlides);
6878
6923
  var targetIndex = currentIndex + direction * movedSlides;
6879
- var finalIndex = infinite ? targetIndex : Math.max(0, Math.min(slides.length - 1, targetIndex));
6924
+ var maxNavigableIndex = limitDragToNavigableRange ? getMaxNavigableIndex() : slides.length - 1;
6925
+ var finalIndex = infinite ? targetIndex : Math.max(0, Math.min(maxNavigableIndex, targetIndex));
6880
6926
  if (!infinite) {
6881
6927
  currentTranslate.current = getTranslateForIndex(finalIndex);
6882
6928
  setDragTranslateX(null);
@@ -6891,28 +6937,6 @@ var Swipe = /*#__PURE__*/forwardRef(function (_ref, ref) {
6891
6937
  }
6892
6938
  setDragTranslateX(null);
6893
6939
  };
6894
- var canMoveNext = function canMoveNext() {
6895
- if (infinite) return true;
6896
- if (slideWidths.length === 0 || containerWidth === 0) return false;
6897
- var totalWidth = slideWidths.reduce(function (acc, w) {
6898
- return acc + w;
6899
- }, 0);
6900
- var widthsBefore = slideWidths.slice(0, currentIndex).reduce(function (acc, w) {
6901
- return acc + w;
6902
- }, 0);
6903
- var visibleSpace = containerWidth - (slidesOffsetBefore || 0);
6904
- var remainingToRight = totalWidth - widthsBefore - visibleSpace;
6905
- var visible = getVisibleIndexes(currentIndex, slideWidths, containerWidth, slides.length);
6906
- var lastVisibleIndex = visible.length ? visible[visible.length - 1] : currentIndex;
6907
- var nextIndex = lastVisibleIndex + 1;
6908
- if (nextIndex >= slideWidths.length) return false;
6909
- var nextSlideWidth = typeof slideWidths[nextIndex] === 'number' ? slideWidths[nextIndex] : 0;
6910
- if (nextSlideWidth === 0) return false;
6911
- var EPS = 1; // pixel tolerance
6912
- // full next slide fits
6913
- if (remainingToRight + EPS >= nextSlideWidth) return true;
6914
- return remainingToRight > 0;
6915
- };
6916
6940
  var handleTransitionEnd = function handleTransitionEnd() {
6917
6941
  setTransitioning(false);
6918
6942
  if (!infinite) return;
@@ -7124,11 +7148,13 @@ var CastFilters = function CastFilters(_ref) {
7124
7148
  };
7125
7149
  var onNext = function onNext() {
7126
7150
  var _swipeRef$current4;
7127
- return (_swipeRef$current4 = swipeRef.current) == null ? void 0 : _swipeRef$current4.nextSlide();
7151
+ if (!availableNext) return;
7152
+ (_swipeRef$current4 = swipeRef.current) == null || _swipeRef$current4.nextSlide();
7128
7153
  };
7129
7154
  var onPrev = function onPrev() {
7130
7155
  var _swipeRef$current5;
7131
- return (_swipeRef$current5 = swipeRef.current) == null ? void 0 : _swipeRef$current5.prevSlide();
7156
+ if (!availablePrev) return;
7157
+ (_swipeRef$current5 = swipeRef.current) == null || _swipeRef$current5.prevSlide();
7132
7158
  };
7133
7159
  useEffect(function () {
7134
7160
  var el = castWrapperRef.current;
@@ -7151,15 +7177,15 @@ var CastFilters = function CastFilters(_ref) {
7151
7177
  };
7152
7178
  }, []);
7153
7179
  var handleMouseDown = useCallback(function (e) {
7154
- if (!castWrapperRef.current) return;
7180
+ if (!isMobile || !castWrapperRef.current) return;
7155
7181
  isDraggingRef.current = true;
7156
7182
  hasDraggedRef.current = false;
7157
7183
  startXRef.current = e.clientX;
7158
7184
  scrollStartRef.current = castWrapperRef.current.scrollLeft;
7159
7185
  if (e.target === castWrapperRef.current) e.preventDefault();
7160
- }, []);
7186
+ }, [isMobile]);
7161
7187
  var handleMouseMove = useCallback(function (e) {
7162
- if (!isDraggingRef.current || !castWrapperRef.current) return;
7188
+ if (!isMobile || !isDraggingRef.current || !castWrapperRef.current) return;
7163
7189
  var deltaX = e.clientX - startXRef.current;
7164
7190
  var threshold = 5;
7165
7191
  if (Math.abs(deltaX) > threshold) {
@@ -7167,17 +7193,19 @@ var CastFilters = function CastFilters(_ref) {
7167
7193
  e.preventDefault();
7168
7194
  castWrapperRef.current.scrollLeft = scrollStartRef.current - deltaX;
7169
7195
  }
7170
- }, []);
7196
+ }, [isMobile]);
7171
7197
  var handleMouseUp = useCallback(function () {
7198
+ if (!isMobile) return;
7172
7199
  isDraggingRef.current = false;
7173
7200
  setTimeout(function () {
7174
7201
  hasDraggedRef.current = false;
7175
7202
  }, 0);
7176
- }, []);
7203
+ }, [isMobile]);
7177
7204
  var handleMouseLeave = useCallback(function () {
7205
+ if (!isMobile) return;
7178
7206
  isDraggingRef.current = false;
7179
7207
  hasDraggedRef.current = false;
7180
- }, []);
7208
+ }, [isMobile]);
7181
7209
  var handleClick = React__default.useCallback(function (index, onClick) {
7182
7210
  if (hasDraggedRef.current) return;
7183
7211
  if (onSelect) onSelect(index);
@@ -7263,7 +7291,8 @@ var CastFilters = function CastFilters(_ref) {
7263
7291
  onIndexChange: onIndexChangeHandler,
7264
7292
  "data-testid": "cast-filter-swipe",
7265
7293
  ref: swipeRef,
7266
- onOverflowChange: handleOverflowChange
7294
+ onOverflowChange: handleOverflowChange,
7295
+ limitDragToNavigableRange: true
7267
7296
  }, getPersonCards())))), showActionButtonsSection && (/*#__PURE__*/React__default.createElement(ActionButtons, null, selectedIndices.length === 0 && emptySelectionText && (/*#__PURE__*/React__default.createElement(BodyCopyHarmonic, {
7268
7297
  size: "medium",
7269
7298
  className: "mobile-only"