@razorpay/blade 10.19.0 → 10.20.0

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.
@@ -2,11 +2,11 @@ import _defineProperty$1 from '@babel/runtime/helpers/defineProperty';
2
2
  import * as React from 'react';
3
3
  import React__default, { useMemo, useCallback, useState, useRef, useEffect, useContext, createContext, Fragment as Fragment$1, useImperativeHandle, forwardRef, Children, cloneElement } from 'react';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
- import styled, { ThemeProvider, css as css$1, keyframes } from 'styled-components';
5
+ import styled, { ThemeProvider, StyleSheetManager, css as css$1, keyframes } from 'styled-components';
6
6
  import _objectWithoutProperties$1 from '@babel/runtime/helpers/objectWithoutProperties';
7
7
  import { FloatingDelayGroup, useFloating, offset, flip, size as size$1, autoUpdate, useTransitionStyles, FloatingOverlay, FloatingPortal, FloatingFocusManager, CompositeItem, Composite, FloatingArrow, shift, arrow, useDelayGroup, useDelayGroupContext, useHover, useFocus, useRole, useInteractions, useClick, useDismiss } from '@floating-ui/react';
8
8
  import '@babel/runtime/helpers/typeof';
9
- import _toConsumableArray$1 from '@babel/runtime/helpers/toConsumableArray';
9
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
10
10
  import { jsx as jsx$1, jsxs, Fragment } from 'react/jsx-runtime';
11
11
  import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
12
12
  import _createClass from '@babel/runtime/helpers/createClass';
@@ -3004,6 +3004,16 @@ var getBaseBoxStyles = function getBaseBoxStyles(props) {
3004
3004
  return _objectSpread$6y(_objectSpread$6y({}, getAllProps(props)), getAllMediaQueries(props));
3005
3005
  };
3006
3006
 
3007
+ function createStylisCSSHigherSpecificityPlugin() {
3008
+ var stylisCSSHigherSpecificity = function stylisCSSHigherSpecificity(context, _, selectors) {
3009
+ if (context !== -1) return;
3010
+ var _selectors = _slicedToArray(selectors, 1),
3011
+ selector = _selectors[0];
3012
+ selectors[0] = "".concat(selector.repeat(5));
3013
+ };
3014
+ return stylisCSSHigherSpecificity;
3015
+ }
3016
+
3007
3017
  function ownKeys$6y(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3008
3018
  function _objectSpread$6x(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6y(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6y(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3009
3019
  /**
@@ -3063,12 +3073,12 @@ var BottomSheetStackProvider = function BottomSheetStackProvider(_ref) {
3063
3073
  }, [stack]);
3064
3074
  var addBottomSheetToStack = React__default.useCallback(function (id) {
3065
3075
  setStack(function (prev) {
3066
- return [id].concat(_toConsumableArray$1(prev));
3076
+ return [id].concat(_toConsumableArray(prev));
3067
3077
  });
3068
3078
  }, []);
3069
3079
  var removeBottomSheetFromStack = React__default.useCallback(function (id) {
3070
3080
  setStack(function (prev) {
3071
- var newStack = _toConsumableArray$1(prev);
3081
+ var newStack = _toConsumableArray(prev);
3072
3082
  var popped = newStack.shift();
3073
3083
  // only pop the stack if the passed in id is matched to the top of the stack
3074
3084
  if (popped === id) return newStack;
@@ -3119,8 +3129,11 @@ var BladeProvider = function BladeProvider(_ref) {
3119
3129
  delay: tooltipDelays,
3120
3130
  children: /*#__PURE__*/jsx$1(ThemeProvider, {
3121
3131
  theme: theme,
3122
- children: /*#__PURE__*/jsx$1(BottomSheetStackProvider, {
3123
- children: children
3132
+ children: /*#__PURE__*/jsx$1(StyleSheetManager, {
3133
+ stylisPlugins: [createStylisCSSHigherSpecificityPlugin()],
3134
+ children: /*#__PURE__*/jsx$1(BottomSheetStackProvider, {
3135
+ children: children
3136
+ })
3124
3137
  })
3125
3138
  })
3126
3139
  })
@@ -12854,6 +12867,7 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
12854
12867
  _ref$textDecorationLi = _ref.textDecorationLine,
12855
12868
  textDecorationLine = _ref$textDecorationLi === void 0 ? 'none' : _ref$textDecorationLi,
12856
12869
  numberOfLines = _ref.numberOfLines,
12870
+ wordBreak = _ref.wordBreak,
12857
12871
  _ref$lineHeight = _ref.lineHeight,
12858
12872
  lineHeight = _ref$lineHeight === void 0 ? 100 : _ref$lineHeight,
12859
12873
  textAlign = _ref.textAlign,
@@ -12864,6 +12878,7 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
12864
12878
  var themeFontWeight = theme.typography.fonts.weight[fontWeight];
12865
12879
  var themeLineHeight = makeTypographySize(theme.typography.lineHeights[lineHeight]);
12866
12880
  var truncateStyles = {};
12881
+ var wordBreakStyles = {};
12867
12882
  if (numberOfLines !== undefined) {
12868
12883
  if (isReactNative$4()) {
12869
12884
  truncateStyles = {};
@@ -12877,7 +12892,16 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
12877
12892
  };
12878
12893
  }
12879
12894
  }
12880
- return _objectSpread$21(_objectSpread$21({
12895
+ if (wordBreak !== undefined) {
12896
+ if (isReactNative$4()) {
12897
+ wordBreakStyles = {};
12898
+ } else {
12899
+ wordBreakStyles = {
12900
+ wordBreak: wordBreak
12901
+ };
12902
+ }
12903
+ }
12904
+ return _objectSpread$21(_objectSpread$21(_objectSpread$21({
12881
12905
  color: textColor,
12882
12906
  fontFamily: themeFontFamily,
12883
12907
  fontSize: themeFontSize,
@@ -12891,11 +12915,11 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
12891
12915
  textAlign: textAlign,
12892
12916
  margin: 0,
12893
12917
  padding: 0
12894
- }, truncateStyles);
12918
+ }, truncateStyles), wordBreakStyles);
12895
12919
  };
12896
12920
 
12897
- var _excluded$R = ["color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "numberOfLines", "lineHeight", "textAlign"],
12898
- _excluded2$1 = ["id", "color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "lineHeight", "as", "textAlign", "children", "truncateAfterLines", "className", "style", "accessibilityProps", "componentName", "testID"];
12921
+ var _excluded$R = ["color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "numberOfLines", "lineHeight", "textAlign", "wordBreak"],
12922
+ _excluded2$1 = ["id", "color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "lineHeight", "as", "textAlign", "children", "truncateAfterLines", "wordBreak", "className", "style", "accessibilityProps", "componentName", "testID"];
12899
12923
  function ownKeys$21(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12900
12924
  function _objectSpread$20(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$21(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$21(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12901
12925
  var StyledBaseText = /*#__PURE__*/styled.div.withConfig({
@@ -12911,6 +12935,7 @@ var StyledBaseText = /*#__PURE__*/styled.div.withConfig({
12911
12935
  numberOfLines = _ref.numberOfLines,
12912
12936
  lineHeight = _ref.lineHeight,
12913
12937
  textAlign = _ref.textAlign,
12938
+ wordBreak = _ref.wordBreak,
12914
12939
  props = _objectWithoutProperties$1(_ref, _excluded$R);
12915
12940
  var styledPropsCSSObject = useStyledProps(props);
12916
12941
  return _objectSpread$20(_objectSpread$20({}, getBaseTextStyles({
@@ -12923,6 +12948,7 @@ var StyledBaseText = /*#__PURE__*/styled.div.withConfig({
12923
12948
  numberOfLines: numberOfLines,
12924
12949
  lineHeight: lineHeight,
12925
12950
  textAlign: textAlign,
12951
+ wordBreak: wordBreak,
12926
12952
  theme: props.theme
12927
12953
  })), styledPropsCSSObject);
12928
12954
  });
@@ -12939,6 +12965,7 @@ var BaseText = function BaseText(_ref2) {
12939
12965
  textAlign = _ref2.textAlign,
12940
12966
  children = _ref2.children,
12941
12967
  truncateAfterLines = _ref2.truncateAfterLines,
12968
+ wordBreak = _ref2.wordBreak,
12942
12969
  className = _ref2.className,
12943
12970
  style = _ref2.style,
12944
12971
  _ref2$accessibilityPr = _ref2.accessibilityProps,
@@ -12958,6 +12985,7 @@ var BaseText = function BaseText(_ref2) {
12958
12985
  as: as,
12959
12986
  textAlign: textAlign,
12960
12987
  numberOfLines: truncateAfterLines,
12988
+ wordBreak: wordBreak,
12961
12989
  className: className,
12962
12990
  style: style,
12963
12991
  id: id
@@ -13157,7 +13185,7 @@ var Heading = function Heading(_ref2) {
13157
13185
  }));
13158
13186
  };
13159
13187
 
13160
- var _excluded$O = ["as", "variant", "weight", "size", "type", "contrast", "truncateAfterLines", "children", "color", "testID", "textAlign", "textDecorationLine"];
13188
+ var _excluded$O = ["as", "variant", "weight", "size", "type", "contrast", "truncateAfterLines", "children", "color", "testID", "textAlign", "textDecorationLine", "wordBreak"];
13161
13189
  function ownKeys$1_(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13162
13190
  function _objectSpread$1Z(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1_(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1_(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13163
13191
  var validAsValues$1 = ['p', 'span', 'div', 'abbr', 'figcaption', 'cite', 'q'];
@@ -13236,10 +13264,12 @@ var _Text = function _Text(_ref2) {
13236
13264
  testID = _ref2.testID,
13237
13265
  textAlign = _ref2.textAlign,
13238
13266
  textDecorationLine = _ref2.textDecorationLine,
13267
+ wordBreak = _ref2.wordBreak,
13239
13268
  styledProps = _objectWithoutProperties$1(_ref2, _excluded$O);
13240
13269
  var props = _objectSpread$1Z({
13241
13270
  as: as,
13242
- truncateAfterLines: truncateAfterLines
13271
+ truncateAfterLines: truncateAfterLines,
13272
+ wordBreak: wordBreak
13243
13273
  }, getTextProps({
13244
13274
  variant: variant,
13245
13275
  type: type,
@@ -13574,7 +13604,7 @@ function getActionFromKey(e, isOpen, dropdownTriggerer) {
13574
13604
  **/
13575
13605
  function getIndexByLetter(options, filter) {
13576
13606
  var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
13577
- var orderedOptions = [].concat(_toConsumableArray$1(options.slice(startIndex)), _toConsumableArray$1(options.slice(0, startIndex)));
13607
+ var orderedOptions = [].concat(_toConsumableArray(options.slice(startIndex)), _toConsumableArray(options.slice(0, startIndex)));
13578
13608
  var firstMatch = filterOptions(orderedOptions, filter)[0];
13579
13609
  var allSameLetter = function allSameLetter(array) {
13580
13610
  return array.every(function (letter) {
@@ -13836,7 +13866,7 @@ var useDropdown = function useDropdown() {
13836
13866
  if (existingItemIndex < 0) {
13837
13867
  return;
13838
13868
  }
13839
- setIndices([].concat(_toConsumableArray$1(selectedIndices.slice(0, existingItemIndex)), _toConsumableArray$1(selectedIndices.slice(existingItemIndex + 1))));
13869
+ setIndices([].concat(_toConsumableArray(selectedIndices.slice(0, existingItemIndex)), _toConsumableArray(selectedIndices.slice(existingItemIndex + 1))));
13840
13870
  };
13841
13871
 
13842
13872
  /**
@@ -13858,7 +13888,7 @@ var useDropdown = function useDropdown() {
13858
13888
  removeOption(index);
13859
13889
  isSelected = false;
13860
13890
  } else {
13861
- setIndices([].concat(_toConsumableArray$1(selectedIndices), [index]));
13891
+ setIndices([].concat(_toConsumableArray(selectedIndices), [index]));
13862
13892
  isSelected = true;
13863
13893
  }
13864
13894
  } else {
@@ -14931,6 +14961,7 @@ var FormLabel = function FormLabel(_ref) {
14931
14961
  size: isLabelLeftPositioned ? 'medium' : 'small',
14932
14962
  truncateAfterLines: 2,
14933
14963
  weight: "bold",
14964
+ wordBreak: isLabelLeftPositioned ? 'break-word' : undefined,
14934
14965
  children: children
14935
14966
  }), computedAccessibilityNode, necessityLabel]
14936
14967
  });
@@ -32288,7 +32319,7 @@ var _TableRow = function _TableRow(_ref8) {
32288
32319
  useEffect(function () {
32289
32320
  if (isDisabled) {
32290
32321
  setDisabledRows(function (prev) {
32291
- return [].concat(_toConsumableArray$1(prev), [item.id]);
32322
+ return [].concat(_toConsumableArray(prev), [item.id]);
32292
32323
  });
32293
32324
  }
32294
32325
  }, [isDisabled, item.id, setDisabledRows]);
@@ -34928,281 +34959,237 @@ function useDrag(handler, config) {
34928
34959
  }, config || {}, 'drag');
34929
34960
  }
34930
34961
 
34931
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
34932
-
34933
- // Older browsers don't support event options, feature detect it.
34934
-
34935
- // Adopted and modified solution from Bohdan Didukh (2017)
34936
- // https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi
34937
-
34938
- var hasPassiveEvents = false;
34939
- if (typeof window !== 'undefined') {
34940
- var passiveTestOptions = {
34962
+ /**
34963
+ * name: body-scroll-lock-upgrade
34964
+ * version: v1.1.0
34965
+ * author: Rick.li
34966
+ */
34967
+ let hasPassiveEvents = false;
34968
+ if (typeof window !== "undefined") {
34969
+ const passiveTestOptions = {
34941
34970
  get passive() {
34942
34971
  hasPassiveEvents = true;
34943
- return undefined;
34972
+ return void 0;
34944
34973
  }
34945
34974
  };
34946
- window.addEventListener('testPassive', null, passiveTestOptions);
34947
- window.removeEventListener('testPassive', null, passiveTestOptions);
34975
+ window.addEventListener("testPassive", null, passiveTestOptions);
34976
+ window.removeEventListener("testPassive", null, passiveTestOptions);
34948
34977
  }
34949
-
34950
- var isIosDevice = typeof window !== 'undefined' && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === 'MacIntel' && window.navigator.maxTouchPoints > 1);
34951
-
34952
-
34953
- var locks = [];
34954
- var documentListenerAdded = false;
34955
- var initialClientY = -1;
34956
- var previousBodyOverflowSetting = void 0;
34957
- var previousBodyPosition = void 0;
34958
- var previousBodyPaddingRight = void 0;
34959
-
34960
- // returns true if `el` should be allowed to receive touchmove events.
34961
- var allowTouchMove = function allowTouchMove(el) {
34962
- return locks.some(function (lock) {
34963
- if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
34964
- return true;
34965
- }
34966
-
34967
- return false;
34968
- });
34969
- };
34970
-
34971
- var preventDefault = function preventDefault(rawEvent) {
34972
- var e = rawEvent || window.event;
34973
-
34974
- // For the case whereby consumers adds a touchmove event listener to document.
34975
- // Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })
34976
- // in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then
34977
- // the touchmove event on document will break.
34978
+ const isIosDevice = typeof window !== "undefined" && window.navigator && window.navigator.platform && (/iP(ad|hone|od)/.test(window.navigator.platform) || window.navigator.platform === "MacIntel" && window.navigator.maxTouchPoints > 1);
34979
+ let locks = [];
34980
+ let locksIndex = /* @__PURE__ */ new Map();
34981
+ let documentListenerAdded = false;
34982
+ let initialClientY = -1;
34983
+ let previousBodyOverflowSetting;
34984
+ let htmlStyle;
34985
+ let bodyStyle;
34986
+ let previousBodyPaddingRight;
34987
+ const allowTouchMove = (el) => locks.some((lock) => {
34988
+ if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
34989
+ return true;
34990
+ }
34991
+ return false;
34992
+ });
34993
+ const preventDefault = (rawEvent) => {
34994
+ const e = rawEvent || window.event;
34978
34995
  if (allowTouchMove(e.target)) {
34979
34996
  return true;
34980
34997
  }
34981
-
34982
- // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
34983
- if (e.touches.length > 1) return true;
34984
-
34985
- if (e.preventDefault) e.preventDefault();
34986
-
34998
+ if (e.touches.length > 1)
34999
+ return true;
35000
+ if (e.preventDefault)
35001
+ e.preventDefault();
34987
35002
  return false;
34988
35003
  };
34989
-
34990
- var setOverflowHidden = function setOverflowHidden(options) {
34991
- // If previousBodyPaddingRight is already set, don't set it again.
34992
- if (previousBodyPaddingRight === undefined) {
34993
- var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
34994
- var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
34995
-
34996
- if (_reserveScrollBarGap && scrollBarGap > 0) {
34997
- var computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'), 10);
35004
+ const setOverflowHidden = (options) => {
35005
+ if (previousBodyPaddingRight === void 0) {
35006
+ const reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
35007
+ const scrollBarGap = window.innerWidth - document.documentElement.getBoundingClientRect().width;
35008
+ if (reserveScrollBarGap && scrollBarGap > 0) {
35009
+ const computedBodyPaddingRight = parseInt(
35010
+ window.getComputedStyle(document.body).getPropertyValue("padding-right"),
35011
+ 10
35012
+ );
34998
35013
  previousBodyPaddingRight = document.body.style.paddingRight;
34999
- document.body.style.paddingRight = computedBodyPaddingRight + scrollBarGap + 'px';
35014
+ document.body.style.paddingRight = `${computedBodyPaddingRight + scrollBarGap}px`;
35000
35015
  }
35001
35016
  }
35002
-
35003
- // If previousBodyOverflowSetting is already set, don't set it again.
35004
- if (previousBodyOverflowSetting === undefined) {
35017
+ if (previousBodyOverflowSetting === void 0) {
35005
35018
  previousBodyOverflowSetting = document.body.style.overflow;
35006
- document.body.style.overflow = 'hidden';
35019
+ document.body.style.overflow = "hidden";
35007
35020
  }
35008
35021
  };
35009
-
35010
- var restoreOverflowSetting = function restoreOverflowSetting() {
35011
- if (previousBodyPaddingRight !== undefined) {
35022
+ const restoreOverflowSetting = () => {
35023
+ if (previousBodyPaddingRight !== void 0) {
35012
35024
  document.body.style.paddingRight = previousBodyPaddingRight;
35013
-
35014
- // Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it
35015
- // can be set again.
35016
- previousBodyPaddingRight = undefined;
35025
+ previousBodyPaddingRight = void 0;
35017
35026
  }
35018
-
35019
- if (previousBodyOverflowSetting !== undefined) {
35027
+ if (previousBodyOverflowSetting !== void 0) {
35020
35028
  document.body.style.overflow = previousBodyOverflowSetting;
35021
-
35022
- // Restore previousBodyOverflowSetting to undefined
35023
- // so setOverflowHidden knows it can be set again.
35024
- previousBodyOverflowSetting = undefined;
35029
+ previousBodyOverflowSetting = void 0;
35030
+ }
35031
+ };
35032
+ const setPositionFixed = () => window.requestAnimationFrame(() => {
35033
+ const $html = document.documentElement;
35034
+ const $body = document.body;
35035
+ if (bodyStyle === void 0) {
35036
+ htmlStyle = { ...$html.style };
35037
+ bodyStyle = { ...$body.style };
35038
+ const { scrollY, scrollX, innerHeight } = window;
35039
+ $html.style.height = "100%";
35040
+ $html.style.overflow = "hidden";
35041
+ $body.style.position = "fixed";
35042
+ $body.style.top = `${-scrollY}px`;
35043
+ $body.style.left = `${-scrollX}px`;
35044
+ $body.style.width = "100%";
35045
+ $body.style.height = "auto";
35046
+ $body.style.overflow = "hidden";
35047
+ setTimeout(
35048
+ () => window.requestAnimationFrame(() => {
35049
+ const bottomBarHeight = innerHeight - window.innerHeight;
35050
+ if (bottomBarHeight && scrollY >= innerHeight) {
35051
+ $body.style.top = -(scrollY + bottomBarHeight) + "px";
35052
+ }
35053
+ }),
35054
+ 300
35055
+ );
35025
35056
  }
35026
- };
35027
-
35028
- var setPositionFixed = function setPositionFixed() {
35029
- return window.requestAnimationFrame(function () {
35030
- // If previousBodyPosition is already set, don't set it again.
35031
- if (previousBodyPosition === undefined) {
35032
- previousBodyPosition = {
35033
- position: document.body.style.position,
35034
- top: document.body.style.top,
35035
- left: document.body.style.left
35036
- };
35037
-
35038
- // Update the dom inside an animation frame
35039
- var _window = window,
35040
- scrollY = _window.scrollY,
35041
- scrollX = _window.scrollX,
35042
- innerHeight = _window.innerHeight;
35043
-
35044
- document.body.style.position = 'fixed';
35045
- document.body.style.top = -scrollY;
35046
- document.body.style.left = -scrollX;
35047
-
35048
- setTimeout(function () {
35049
- return window.requestAnimationFrame(function () {
35050
- // Attempt to check if the bottom bar appeared due to the position change
35051
- var bottomBarHeight = innerHeight - window.innerHeight;
35052
- if (bottomBarHeight && scrollY >= innerHeight) {
35053
- // Move the content further up so that the bottom bar doesn't hide it
35054
- document.body.style.top = -(scrollY + bottomBarHeight);
35055
- }
35056
- });
35057
- }, 300);
35058
- }
35059
- });
35060
- };
35061
-
35062
- var restorePositionSetting = function restorePositionSetting() {
35063
- if (previousBodyPosition !== undefined) {
35064
- // Convert the position from "px" to Int
35065
- var y = -parseInt(document.body.style.top, 10);
35066
- var x = -parseInt(document.body.style.left, 10);
35067
-
35068
- // Restore styles
35069
- document.body.style.position = previousBodyPosition.position;
35070
- document.body.style.top = previousBodyPosition.top;
35071
- document.body.style.left = previousBodyPosition.left;
35072
-
35073
- // Restore scroll
35057
+ });
35058
+ const restorePositionSetting = () => {
35059
+ if (bodyStyle !== void 0) {
35060
+ const y = -parseInt(document.body.style.top, 10);
35061
+ const x = -parseInt(document.body.style.left, 10);
35062
+ const $html = document.documentElement;
35063
+ const $body = document.body;
35064
+ $html.style.height = (htmlStyle == null ? void 0 : htmlStyle.height) || "";
35065
+ $html.style.overflow = (htmlStyle == null ? void 0 : htmlStyle.overflow) || "";
35066
+ $body.style.position = bodyStyle.position || "";
35067
+ $body.style.top = bodyStyle.top || "";
35068
+ $body.style.left = bodyStyle.left || "";
35069
+ $body.style.width = bodyStyle.width || "";
35070
+ $body.style.height = bodyStyle.height || "";
35071
+ $body.style.overflow = bodyStyle.overflow || "";
35074
35072
  window.scrollTo(x, y);
35075
-
35076
- previousBodyPosition = undefined;
35073
+ bodyStyle = void 0;
35077
35074
  }
35078
35075
  };
35079
-
35080
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
35081
- var isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {
35082
- return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
35083
- };
35084
-
35085
- var handleScroll = function handleScroll(event, targetElement) {
35086
- var clientY = event.targetTouches[0].clientY - initialClientY;
35087
-
35076
+ const isTargetElementTotallyScrolled = (targetElement) => targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
35077
+ const handleScroll = (event, targetElement) => {
35078
+ const clientY = event.targetTouches[0].clientY - initialClientY;
35088
35079
  if (allowTouchMove(event.target)) {
35089
35080
  return false;
35090
35081
  }
35091
-
35092
35082
  if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {
35093
- // element is at the top of its scroll.
35094
35083
  return preventDefault(event);
35095
35084
  }
35096
-
35097
35085
  if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {
35098
- // element is at the bottom of its scroll.
35099
35086
  return preventDefault(event);
35100
35087
  }
35101
-
35102
35088
  event.stopPropagation();
35103
35089
  return true;
35104
35090
  };
35105
-
35106
- var disableBodyScroll = function disableBodyScroll(targetElement, options) {
35107
- // targetElement must be provided
35091
+ const disableBodyScroll = (targetElement, options) => {
35108
35092
  if (!targetElement) {
35109
- // eslint-disable-next-line no-console
35110
- console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');
35093
+ console.error(
35094
+ "disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices."
35095
+ );
35111
35096
  return;
35112
35097
  }
35113
-
35114
- // disableBodyScroll must not have been called on this targetElement before
35115
- if (locks.some(function (lock) {
35116
- return lock.targetElement === targetElement;
35117
- })) {
35098
+ locksIndex.set(
35099
+ targetElement,
35100
+ (locksIndex == null ? void 0 : locksIndex.get(targetElement)) ? (locksIndex == null ? void 0 : locksIndex.get(targetElement)) + 1 : 1
35101
+ );
35102
+ if (locks.some((lock2) => lock2.targetElement === targetElement)) {
35118
35103
  return;
35119
35104
  }
35120
-
35121
- var lock = {
35122
- targetElement: targetElement,
35105
+ const lock = {
35106
+ targetElement,
35123
35107
  options: options || {}
35124
35108
  };
35125
-
35126
- locks = [].concat(_toConsumableArray(locks), [lock]);
35127
-
35109
+ locks = [...locks, lock];
35128
35110
  if (isIosDevice) {
35129
35111
  setPositionFixed();
35130
35112
  } else {
35131
35113
  setOverflowHidden(options);
35132
35114
  }
35133
-
35134
35115
  if (isIosDevice) {
35135
- targetElement.ontouchstart = function (event) {
35116
+ targetElement.ontouchstart = (event) => {
35136
35117
  if (event.targetTouches.length === 1) {
35137
- // detect single touch.
35138
35118
  initialClientY = event.targetTouches[0].clientY;
35139
35119
  }
35140
35120
  };
35141
- targetElement.ontouchmove = function (event) {
35121
+ targetElement.ontouchmove = (event) => {
35142
35122
  if (event.targetTouches.length === 1) {
35143
- // detect single touch.
35144
35123
  handleScroll(event, targetElement);
35145
35124
  }
35146
35125
  };
35147
-
35148
35126
  if (!documentListenerAdded) {
35149
- document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
35127
+ document.addEventListener(
35128
+ "touchmove",
35129
+ preventDefault,
35130
+ hasPassiveEvents ? { passive: false } : void 0
35131
+ );
35150
35132
  documentListenerAdded = true;
35151
35133
  }
35152
35134
  }
35153
35135
  };
35154
-
35155
- var clearAllBodyScrollLocks = function clearAllBodyScrollLocks() {
35136
+ const clearAllBodyScrollLocks = () => {
35156
35137
  if (isIosDevice) {
35157
- // Clear all locks ontouchstart/ontouchmove handlers, and the references.
35158
- locks.forEach(function (lock) {
35138
+ locks.forEach((lock) => {
35159
35139
  lock.targetElement.ontouchstart = null;
35160
35140
  lock.targetElement.ontouchmove = null;
35161
35141
  });
35162
-
35163
35142
  if (documentListenerAdded) {
35164
- document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
35143
+ document.removeEventListener(
35144
+ "touchmove",
35145
+ preventDefault,
35146
+ hasPassiveEvents ? { passive: false } : void 0
35147
+ );
35165
35148
  documentListenerAdded = false;
35166
35149
  }
35167
-
35168
- // Reset initial clientY.
35169
35150
  initialClientY = -1;
35170
35151
  }
35171
-
35172
35152
  if (isIosDevice) {
35173
35153
  restorePositionSetting();
35174
35154
  } else {
35175
35155
  restoreOverflowSetting();
35176
35156
  }
35177
-
35178
35157
  locks = [];
35158
+ locksIndex.clear();
35179
35159
  };
35180
-
35181
- var enableBodyScroll = function enableBodyScroll(targetElement) {
35160
+ const enableBodyScroll = (targetElement) => {
35182
35161
  if (!targetElement) {
35183
- // eslint-disable-next-line no-console
35184
- console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.');
35162
+ console.error(
35163
+ "enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices."
35164
+ );
35185
35165
  return;
35186
35166
  }
35187
-
35188
- locks = locks.filter(function (lock) {
35189
- return lock.targetElement !== targetElement;
35190
- });
35191
-
35167
+ locksIndex.set(
35168
+ targetElement,
35169
+ (locksIndex == null ? void 0 : locksIndex.get(targetElement)) ? (locksIndex == null ? void 0 : locksIndex.get(targetElement)) - 1 : 0
35170
+ );
35171
+ if ((locksIndex == null ? void 0 : locksIndex.get(targetElement)) === 0) {
35172
+ locks = locks.filter((lock) => lock.targetElement !== targetElement);
35173
+ locksIndex == null ? void 0 : locksIndex.delete(targetElement);
35174
+ }
35192
35175
  if (isIosDevice) {
35193
35176
  targetElement.ontouchstart = null;
35194
35177
  targetElement.ontouchmove = null;
35195
-
35196
35178
  if (documentListenerAdded && locks.length === 0) {
35197
- document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
35179
+ document.removeEventListener(
35180
+ "touchmove",
35181
+ preventDefault,
35182
+ hasPassiveEvents ? { passive: false } : void 0
35183
+ );
35198
35184
  documentListenerAdded = false;
35199
35185
  }
35200
35186
  }
35201
-
35202
- if (isIosDevice) {
35203
- restorePositionSetting();
35204
- } else {
35205
- restoreOverflowSetting();
35187
+ if (locks.length === 0) {
35188
+ if (isIosDevice) {
35189
+ restorePositionSetting();
35190
+ } else {
35191
+ restoreOverflowSetting();
35192
+ }
35206
35193
  }
35207
35194
  };
35208
35195
 
@@ -37522,9 +37509,8 @@ var TourPopover = function TourPopover(_ref) {
37522
37509
  var click = useClick(context, {
37523
37510
  enabled: !isControlled
37524
37511
  });
37525
- var dismiss = useDismiss(context);
37526
37512
  var role = useRole(context);
37527
- var _useInteractions = useInteractions([click, dismiss, role]),
37513
+ var _useInteractions = useInteractions([click, role]),
37528
37514
  getFloatingProps = _useInteractions.getFloatingProps;
37529
37515
  var contextValue = React__default.useMemo(function () {
37530
37516
  return {
@@ -37600,17 +37586,21 @@ function useDelayedState(initialState, delay) {
37600
37586
  var _React$useState = React__default.useState(initialState),
37601
37587
  _React$useState2 = _slicedToArray(_React$useState, 2),
37602
37588
  delayedState = _React$useState2[0],
37603
- setDelayedState = _React$useState2[1];
37589
+ _setDelayedState = _React$useState2[1];
37604
37590
  var timeoutRef = React__default.useRef(undefined);
37605
37591
  React__default.useEffect(function () {
37606
37592
  timeoutRef.current = window.setTimeout(function () {
37607
- setDelayedState(initialState);
37593
+ _setDelayedState(initialState);
37608
37594
  }, delay);
37609
37595
  return function () {
37610
37596
  window.clearTimeout(timeoutRef.current);
37611
37597
  };
37612
37598
  }, [delay, initialState]);
37613
- return delayedState;
37599
+ var setDelayedState = React__default.useCallback(function (newState) {
37600
+ _setDelayedState(newState);
37601
+ window.clearTimeout(timeoutRef.current);
37602
+ }, []);
37603
+ return [delayedState, setDelayedState];
37614
37604
  }
37615
37605
 
37616
37606
  /**
@@ -37874,10 +37864,19 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
37874
37864
  setSize = _useState4[1];
37875
37865
 
37876
37866
  // delayed state is used to let the transition finish before reacting to the state changes
37877
- var delayedActiveStep = useDelayedState(activeStep, transitionDelay);
37878
- var delayedSize = useDelayedState(size, transitionDelay);
37867
+ var _useDelayedState = useDelayedState(activeStep, transitionDelay),
37868
+ _useDelayedState2 = _slicedToArray(_useDelayedState, 1),
37869
+ delayedActiveStep = _useDelayedState2[0];
37870
+ var _useDelayedState3 = useDelayedState(size, transitionDelay),
37871
+ _useDelayedState4 = _slicedToArray(_useDelayedState3, 2),
37872
+ delayedSize = _useDelayedState4[0],
37873
+ setDelayedSize = _useDelayedState4[1];
37879
37874
  // keep track of when we are transitioning between steps
37880
37875
  var isTransitioning = useIsTransitioningBetweenSteps(activeStep, transitionDelay);
37876
+ var _useState5 = useState(false),
37877
+ _useState6 = _slicedToArray(_useState5, 2),
37878
+ isScrolling = _useState6[0],
37879
+ setIsScrolling = _useState6[1];
37881
37880
  var currentStepRef = refIdMap.get((_steps$activeStep = steps[activeStep]) === null || _steps$activeStep === void 0 ? void 0 : _steps$activeStep.name);
37882
37881
  var intersection = useIntersectionObserver(currentStepRef, {
37883
37882
  threshold: 0.5
@@ -37924,6 +37923,7 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
37924
37923
  }, []);
37925
37924
  var updateMaskSize = useCallback(function () {
37926
37925
  var _steps$activeStep2;
37926
+ var shouldSkipDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
37927
37927
  var ref = refIdMap.get((_steps$activeStep2 = steps[activeStep]) === null || _steps$activeStep2 === void 0 ? void 0 : _steps$activeStep2.name);
37928
37928
  if (!(ref !== null && ref !== void 0 && ref.current)) return;
37929
37929
  var rect = ref.current.getBoundingClientRect();
@@ -37933,7 +37933,15 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
37933
37933
  width: rect.width,
37934
37934
  height: rect.height
37935
37935
  });
37936
- }, [activeStep, refIdMap, steps]);
37936
+ if (shouldSkipDelay) {
37937
+ setDelayedSize({
37938
+ x: rect.x,
37939
+ y: rect.y,
37940
+ width: rect.width,
37941
+ height: rect.height
37942
+ });
37943
+ }
37944
+ }, [activeStep, refIdMap, setDelayedSize, steps]);
37937
37945
  var scrollToStep = useCallback(function () {
37938
37946
  var _steps$delayedActiveS;
37939
37947
  var ref = refIdMap.get((_steps$delayedActiveS = steps[delayedActiveStep]) === null || _steps$delayedActiveS === void 0 ? void 0 : _steps$delayedActiveS.name);
@@ -37941,36 +37949,42 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
37941
37949
 
37942
37950
  // If the element is already in view, don't scroll
37943
37951
  if (intersection !== null && intersection !== void 0 && intersection.isIntersecting) return;
37952
+ setIsScrolling(true);
37944
37953
  smoothScroll(ref.current, {
37945
37954
  behavior: 'smooth',
37946
37955
  block: 'center',
37947
37956
  inline: 'center'
37948
37957
  }).then(function () {
37949
- updateMaskSize();
37958
+ // wait for the scroll to finish before updating the mask size
37959
+ // We also don't want to delay the size update since its already delayed by the scroll
37960
+ updateMaskSize(true);
37950
37961
  })["finally"](function () {
37951
- // do nothing
37962
+ setIsScrolling(false);
37952
37963
  });
37953
37964
  }, [delayedActiveStep, refIdMap, steps, updateMaskSize, intersection === null || intersection === void 0 ? void 0 : intersection.isIntersecting]);
37954
37965
 
37955
37966
  // Update the size of the mask when the active step changes
37956
37967
  useIsomorphicLayoutEffect(function () {
37957
37968
  updateMaskSize();
37958
- }, [isOpen, activeStep, refIdMap, steps, updateMaskSize]);
37969
+ }, [activeStep, updateMaskSize]);
37959
37970
 
37960
37971
  // Scroll into view when the active step changes
37961
37972
  useIsomorphicLayoutEffect(function () {
37973
+ // We need to wait for the transition to finish before scrolling
37974
+ // Otherwise the browser sometimes interrupts the scroll
37975
+ var scrollDelay = 100;
37962
37976
  setTimeout(function () {
37963
37977
  if (!isOpen) return;
37964
37978
  if (isTransitioning) return;
37965
37979
  scrollToStep();
37966
- }, transitionDelay);
37980
+ }, scrollDelay);
37967
37981
  }, [isOpen, scrollToStep, isTransitioning]);
37968
- useLockBodyScroll(isOpen);
37969
37982
 
37970
37983
  // reset the mask size when the tour is closed
37971
- React__default.useEffect(function () {
37984
+ useIsomorphicLayoutEffect(function () {
37972
37985
  if (isOpen) {
37973
- updateMaskSize();
37986
+ // on initial mount, we don't want to delay the size update
37987
+ updateMaskSize(true);
37974
37988
  onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange({
37975
37989
  isOpen: isOpen
37976
37990
  });
@@ -37985,6 +37999,7 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
37985
37999
  }
37986
38000
  // eslint-disable-next-line react-hooks/exhaustive-deps
37987
38001
  }, [isOpen]);
38002
+ useLockBodyScroll(isOpen);
37988
38003
  var contextValue = useMemo(function () {
37989
38004
  return {
37990
38005
  attachStep: attachStep,
@@ -37995,7 +38010,7 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
37995
38010
  value: contextValue,
37996
38011
  children: [/*#__PURE__*/jsx$1(FloatingPortal, {
37997
38012
  children: isOpen ? /*#__PURE__*/jsx$1(SpotlightPopoverTourMask, {
37998
- isTransitioning: isTransitioning,
38013
+ isTransitioning: isTransitioning || isScrolling,
37999
38014
  padding: theme.spacing[4],
38000
38015
  size: delayedSize
38001
38016
  }) : null