@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 _typeof from '@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';
@@ -3089,6 +3089,16 @@ var getBaseBoxStyles = function getBaseBoxStyles(props) {
3089
3089
  return _objectSpread$6y(_objectSpread$6y({}, getAllProps(props)), getAllMediaQueries(props));
3090
3090
  };
3091
3091
 
3092
+ function createStylisCSSHigherSpecificityPlugin() {
3093
+ var stylisCSSHigherSpecificity = function stylisCSSHigherSpecificity(context, _, selectors) {
3094
+ if (context !== -1) return;
3095
+ var _selectors = _slicedToArray(selectors, 1),
3096
+ selector = _selectors[0];
3097
+ selectors[0] = "".concat(selector.repeat(5));
3098
+ };
3099
+ return stylisCSSHigherSpecificity;
3100
+ }
3101
+
3092
3102
  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; }
3093
3103
  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; }
3094
3104
  /**
@@ -3162,12 +3172,12 @@ var BottomSheetStackProvider = function BottomSheetStackProvider(_ref) {
3162
3172
  }, [stack]);
3163
3173
  var addBottomSheetToStack = React__default.useCallback(function (id) {
3164
3174
  setStack(function (prev) {
3165
- return [id].concat(_toConsumableArray$1(prev));
3175
+ return [id].concat(_toConsumableArray(prev));
3166
3176
  });
3167
3177
  }, []);
3168
3178
  var removeBottomSheetFromStack = React__default.useCallback(function (id) {
3169
3179
  setStack(function (prev) {
3170
- var newStack = _toConsumableArray$1(prev);
3180
+ var newStack = _toConsumableArray(prev);
3171
3181
  var popped = newStack.shift();
3172
3182
  // only pop the stack if the passed in id is matched to the top of the stack
3173
3183
  if (popped === id) return newStack;
@@ -3218,8 +3228,11 @@ var BladeProvider = function BladeProvider(_ref) {
3218
3228
  delay: tooltipDelays,
3219
3229
  children: /*#__PURE__*/jsx$1(ThemeProvider, {
3220
3230
  theme: theme,
3221
- children: /*#__PURE__*/jsx$1(BottomSheetStackProvider, {
3222
- children: children
3231
+ children: /*#__PURE__*/jsx$1(StyleSheetManager, {
3232
+ stylisPlugins: [createStylisCSSHigherSpecificityPlugin()],
3233
+ children: /*#__PURE__*/jsx$1(BottomSheetStackProvider, {
3234
+ children: children
3235
+ })
3223
3236
  })
3224
3237
  })
3225
3238
  })
@@ -13013,6 +13026,7 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
13013
13026
  _ref$textDecorationLi = _ref.textDecorationLine,
13014
13027
  textDecorationLine = _ref$textDecorationLi === void 0 ? 'none' : _ref$textDecorationLi,
13015
13028
  numberOfLines = _ref.numberOfLines,
13029
+ wordBreak = _ref.wordBreak,
13016
13030
  _ref$lineHeight = _ref.lineHeight,
13017
13031
  lineHeight = _ref$lineHeight === void 0 ? 100 : _ref$lineHeight,
13018
13032
  textAlign = _ref.textAlign,
@@ -13023,6 +13037,7 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
13023
13037
  var themeFontWeight = theme.typography.fonts.weight[fontWeight];
13024
13038
  var themeLineHeight = makeTypographySize(theme.typography.lineHeights[lineHeight]);
13025
13039
  var truncateStyles = {};
13040
+ var wordBreakStyles = {};
13026
13041
  if (numberOfLines !== undefined) {
13027
13042
  if (isReactNative$4()) {
13028
13043
  truncateStyles = {};
@@ -13036,7 +13051,16 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
13036
13051
  };
13037
13052
  }
13038
13053
  }
13039
- return _objectSpread$21(_objectSpread$21({
13054
+ if (wordBreak !== undefined) {
13055
+ if (isReactNative$4()) {
13056
+ wordBreakStyles = {};
13057
+ } else {
13058
+ wordBreakStyles = {
13059
+ wordBreak: wordBreak
13060
+ };
13061
+ }
13062
+ }
13063
+ return _objectSpread$21(_objectSpread$21(_objectSpread$21({
13040
13064
  color: textColor,
13041
13065
  fontFamily: themeFontFamily,
13042
13066
  fontSize: themeFontSize,
@@ -13050,11 +13074,11 @@ var getBaseTextStyles = function getBaseTextStyles(_ref) {
13050
13074
  textAlign: textAlign,
13051
13075
  margin: 0,
13052
13076
  padding: 0
13053
- }, truncateStyles);
13077
+ }, truncateStyles), wordBreakStyles);
13054
13078
  };
13055
13079
 
13056
- var _excluded$R = ["color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "numberOfLines", "lineHeight", "textAlign"],
13057
- _excluded2$1 = ["id", "color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "lineHeight", "as", "textAlign", "children", "truncateAfterLines", "className", "style", "accessibilityProps", "componentName", "testID"];
13080
+ var _excluded$R = ["color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "numberOfLines", "lineHeight", "textAlign", "wordBreak"],
13081
+ _excluded2$1 = ["id", "color", "fontFamily", "fontSize", "fontWeight", "fontStyle", "textDecorationLine", "lineHeight", "as", "textAlign", "children", "truncateAfterLines", "wordBreak", "className", "style", "accessibilityProps", "componentName", "testID"];
13058
13082
  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; }
13059
13083
  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; }
13060
13084
  var StyledBaseText = /*#__PURE__*/styled.div.withConfig({
@@ -13070,6 +13094,7 @@ var StyledBaseText = /*#__PURE__*/styled.div.withConfig({
13070
13094
  numberOfLines = _ref.numberOfLines,
13071
13095
  lineHeight = _ref.lineHeight,
13072
13096
  textAlign = _ref.textAlign,
13097
+ wordBreak = _ref.wordBreak,
13073
13098
  props = _objectWithoutProperties$1(_ref, _excluded$R);
13074
13099
  var styledPropsCSSObject = useStyledProps(props);
13075
13100
  return _objectSpread$20(_objectSpread$20({}, getBaseTextStyles({
@@ -13082,6 +13107,7 @@ var StyledBaseText = /*#__PURE__*/styled.div.withConfig({
13082
13107
  numberOfLines: numberOfLines,
13083
13108
  lineHeight: lineHeight,
13084
13109
  textAlign: textAlign,
13110
+ wordBreak: wordBreak,
13085
13111
  theme: props.theme
13086
13112
  })), styledPropsCSSObject);
13087
13113
  });
@@ -13098,6 +13124,7 @@ var BaseText = function BaseText(_ref2) {
13098
13124
  textAlign = _ref2.textAlign,
13099
13125
  children = _ref2.children,
13100
13126
  truncateAfterLines = _ref2.truncateAfterLines,
13127
+ wordBreak = _ref2.wordBreak,
13101
13128
  className = _ref2.className,
13102
13129
  style = _ref2.style,
13103
13130
  _ref2$accessibilityPr = _ref2.accessibilityProps,
@@ -13117,6 +13144,7 @@ var BaseText = function BaseText(_ref2) {
13117
13144
  as: as,
13118
13145
  textAlign: textAlign,
13119
13146
  numberOfLines: truncateAfterLines,
13147
+ wordBreak: wordBreak,
13120
13148
  className: className,
13121
13149
  style: style,
13122
13150
  id: id
@@ -13338,7 +13366,7 @@ var Heading = function Heading(_ref2) {
13338
13366
  }));
13339
13367
  };
13340
13368
 
13341
- var _excluded$O = ["as", "variant", "weight", "size", "type", "contrast", "truncateAfterLines", "children", "color", "testID", "textAlign", "textDecorationLine"];
13369
+ var _excluded$O = ["as", "variant", "weight", "size", "type", "contrast", "truncateAfterLines", "children", "color", "testID", "textAlign", "textDecorationLine", "wordBreak"];
13342
13370
  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; }
13343
13371
  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; }
13344
13372
  var validAsValues$1 = ['p', 'span', 'div', 'abbr', 'figcaption', 'cite', 'q'];
@@ -13422,10 +13450,12 @@ var _Text = function _Text(_ref2) {
13422
13450
  testID = _ref2.testID,
13423
13451
  textAlign = _ref2.textAlign,
13424
13452
  textDecorationLine = _ref2.textDecorationLine,
13453
+ wordBreak = _ref2.wordBreak,
13425
13454
  styledProps = _objectWithoutProperties$1(_ref2, _excluded$O);
13426
13455
  var props = _objectSpread$1Z({
13427
13456
  as: as,
13428
- truncateAfterLines: truncateAfterLines
13457
+ truncateAfterLines: truncateAfterLines,
13458
+ wordBreak: wordBreak
13429
13459
  }, getTextProps({
13430
13460
  variant: variant,
13431
13461
  type: type,
@@ -13774,7 +13804,7 @@ function getActionFromKey(e, isOpen, dropdownTriggerer) {
13774
13804
  **/
13775
13805
  function getIndexByLetter(options, filter) {
13776
13806
  var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
13777
- var orderedOptions = [].concat(_toConsumableArray$1(options.slice(startIndex)), _toConsumableArray$1(options.slice(0, startIndex)));
13807
+ var orderedOptions = [].concat(_toConsumableArray(options.slice(startIndex)), _toConsumableArray(options.slice(0, startIndex)));
13778
13808
  var firstMatch = filterOptions(orderedOptions, filter)[0];
13779
13809
  var allSameLetter = function allSameLetter(array) {
13780
13810
  return array.every(function (letter) {
@@ -14036,7 +14066,7 @@ var useDropdown = function useDropdown() {
14036
14066
  if (existingItemIndex < 0) {
14037
14067
  return;
14038
14068
  }
14039
- setIndices([].concat(_toConsumableArray$1(selectedIndices.slice(0, existingItemIndex)), _toConsumableArray$1(selectedIndices.slice(existingItemIndex + 1))));
14069
+ setIndices([].concat(_toConsumableArray(selectedIndices.slice(0, existingItemIndex)), _toConsumableArray(selectedIndices.slice(existingItemIndex + 1))));
14040
14070
  };
14041
14071
 
14042
14072
  /**
@@ -14058,7 +14088,7 @@ var useDropdown = function useDropdown() {
14058
14088
  removeOption(index);
14059
14089
  isSelected = false;
14060
14090
  } else {
14061
- setIndices([].concat(_toConsumableArray$1(selectedIndices), [index]));
14091
+ setIndices([].concat(_toConsumableArray(selectedIndices), [index]));
14062
14092
  isSelected = true;
14063
14093
  }
14064
14094
  } else {
@@ -15147,6 +15177,7 @@ var FormLabel = function FormLabel(_ref) {
15147
15177
  size: isLabelLeftPositioned ? 'medium' : 'small',
15148
15178
  truncateAfterLines: 2,
15149
15179
  weight: "bold",
15180
+ wordBreak: isLabelLeftPositioned ? 'break-word' : undefined,
15150
15181
  children: children
15151
15182
  }), computedAccessibilityNode, necessityLabel]
15152
15183
  });
@@ -32769,7 +32800,7 @@ var _TableRow = function _TableRow(_ref8) {
32769
32800
  useEffect(function () {
32770
32801
  if (isDisabled) {
32771
32802
  setDisabledRows(function (prev) {
32772
- return [].concat(_toConsumableArray$1(prev), [item.id]);
32803
+ return [].concat(_toConsumableArray(prev), [item.id]);
32773
32804
  });
32774
32805
  }
32775
32806
  }, [isDisabled, item.id, setDisabledRows]);
@@ -35424,281 +35455,237 @@ function useDrag(handler, config) {
35424
35455
  }, config || {}, 'drag');
35425
35456
  }
35426
35457
 
35427
- 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); } }
35428
-
35429
- // Older browsers don't support event options, feature detect it.
35430
-
35431
- // Adopted and modified solution from Bohdan Didukh (2017)
35432
- // https://stackoverflow.com/questions/41594997/ios-10-safari-prevent-scrolling-behind-a-fixed-overlay-and-maintain-scroll-posi
35433
-
35434
- var hasPassiveEvents = false;
35435
- if (typeof window !== 'undefined') {
35436
- var passiveTestOptions = {
35458
+ /**
35459
+ * name: body-scroll-lock-upgrade
35460
+ * version: v1.1.0
35461
+ * author: Rick.li
35462
+ */
35463
+ let hasPassiveEvents = false;
35464
+ if (typeof window !== "undefined") {
35465
+ const passiveTestOptions = {
35437
35466
  get passive() {
35438
35467
  hasPassiveEvents = true;
35439
- return undefined;
35468
+ return void 0;
35440
35469
  }
35441
35470
  };
35442
- window.addEventListener('testPassive', null, passiveTestOptions);
35443
- window.removeEventListener('testPassive', null, passiveTestOptions);
35471
+ window.addEventListener("testPassive", null, passiveTestOptions);
35472
+ window.removeEventListener("testPassive", null, passiveTestOptions);
35444
35473
  }
35445
-
35446
- 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);
35447
-
35448
-
35449
- var locks = [];
35450
- var documentListenerAdded = false;
35451
- var initialClientY = -1;
35452
- var previousBodyOverflowSetting = void 0;
35453
- var previousBodyPosition = void 0;
35454
- var previousBodyPaddingRight = void 0;
35455
-
35456
- // returns true if `el` should be allowed to receive touchmove events.
35457
- var allowTouchMove = function allowTouchMove(el) {
35458
- return locks.some(function (lock) {
35459
- if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
35460
- return true;
35461
- }
35462
-
35463
- return false;
35464
- });
35465
- };
35466
-
35467
- var preventDefault = function preventDefault(rawEvent) {
35468
- var e = rawEvent || window.event;
35469
-
35470
- // For the case whereby consumers adds a touchmove event listener to document.
35471
- // Recall that we do document.addEventListener('touchmove', preventDefault, { passive: false })
35472
- // in disableBodyScroll - so if we provide this opportunity to allowTouchMove, then
35473
- // the touchmove event on document will break.
35474
+ 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);
35475
+ let locks = [];
35476
+ let locksIndex = /* @__PURE__ */ new Map();
35477
+ let documentListenerAdded = false;
35478
+ let initialClientY = -1;
35479
+ let previousBodyOverflowSetting;
35480
+ let htmlStyle;
35481
+ let bodyStyle;
35482
+ let previousBodyPaddingRight;
35483
+ const allowTouchMove = (el) => locks.some((lock) => {
35484
+ if (lock.options.allowTouchMove && lock.options.allowTouchMove(el)) {
35485
+ return true;
35486
+ }
35487
+ return false;
35488
+ });
35489
+ const preventDefault = (rawEvent) => {
35490
+ const e = rawEvent || window.event;
35474
35491
  if (allowTouchMove(e.target)) {
35475
35492
  return true;
35476
35493
  }
35477
-
35478
- // Do not prevent if the event has more than one touch (usually meaning this is a multi touch gesture like pinch to zoom).
35479
- if (e.touches.length > 1) return true;
35480
-
35481
- if (e.preventDefault) e.preventDefault();
35482
-
35494
+ if (e.touches.length > 1)
35495
+ return true;
35496
+ if (e.preventDefault)
35497
+ e.preventDefault();
35483
35498
  return false;
35484
35499
  };
35485
-
35486
- var setOverflowHidden = function setOverflowHidden(options) {
35487
- // If previousBodyPaddingRight is already set, don't set it again.
35488
- if (previousBodyPaddingRight === undefined) {
35489
- var _reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
35490
- var scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
35491
-
35492
- if (_reserveScrollBarGap && scrollBarGap > 0) {
35493
- var computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'), 10);
35500
+ const setOverflowHidden = (options) => {
35501
+ if (previousBodyPaddingRight === void 0) {
35502
+ const reserveScrollBarGap = !!options && options.reserveScrollBarGap === true;
35503
+ const scrollBarGap = window.innerWidth - document.documentElement.getBoundingClientRect().width;
35504
+ if (reserveScrollBarGap && scrollBarGap > 0) {
35505
+ const computedBodyPaddingRight = parseInt(
35506
+ window.getComputedStyle(document.body).getPropertyValue("padding-right"),
35507
+ 10
35508
+ );
35494
35509
  previousBodyPaddingRight = document.body.style.paddingRight;
35495
- document.body.style.paddingRight = computedBodyPaddingRight + scrollBarGap + 'px';
35510
+ document.body.style.paddingRight = `${computedBodyPaddingRight + scrollBarGap}px`;
35496
35511
  }
35497
35512
  }
35498
-
35499
- // If previousBodyOverflowSetting is already set, don't set it again.
35500
- if (previousBodyOverflowSetting === undefined) {
35513
+ if (previousBodyOverflowSetting === void 0) {
35501
35514
  previousBodyOverflowSetting = document.body.style.overflow;
35502
- document.body.style.overflow = 'hidden';
35515
+ document.body.style.overflow = "hidden";
35503
35516
  }
35504
35517
  };
35505
-
35506
- var restoreOverflowSetting = function restoreOverflowSetting() {
35507
- if (previousBodyPaddingRight !== undefined) {
35518
+ const restoreOverflowSetting = () => {
35519
+ if (previousBodyPaddingRight !== void 0) {
35508
35520
  document.body.style.paddingRight = previousBodyPaddingRight;
35509
-
35510
- // Restore previousBodyPaddingRight to undefined so setOverflowHidden knows it
35511
- // can be set again.
35512
- previousBodyPaddingRight = undefined;
35521
+ previousBodyPaddingRight = void 0;
35513
35522
  }
35514
-
35515
- if (previousBodyOverflowSetting !== undefined) {
35523
+ if (previousBodyOverflowSetting !== void 0) {
35516
35524
  document.body.style.overflow = previousBodyOverflowSetting;
35517
-
35518
- // Restore previousBodyOverflowSetting to undefined
35519
- // so setOverflowHidden knows it can be set again.
35520
- previousBodyOverflowSetting = undefined;
35525
+ previousBodyOverflowSetting = void 0;
35526
+ }
35527
+ };
35528
+ const setPositionFixed = () => window.requestAnimationFrame(() => {
35529
+ const $html = document.documentElement;
35530
+ const $body = document.body;
35531
+ if (bodyStyle === void 0) {
35532
+ htmlStyle = { ...$html.style };
35533
+ bodyStyle = { ...$body.style };
35534
+ const { scrollY, scrollX, innerHeight } = window;
35535
+ $html.style.height = "100%";
35536
+ $html.style.overflow = "hidden";
35537
+ $body.style.position = "fixed";
35538
+ $body.style.top = `${-scrollY}px`;
35539
+ $body.style.left = `${-scrollX}px`;
35540
+ $body.style.width = "100%";
35541
+ $body.style.height = "auto";
35542
+ $body.style.overflow = "hidden";
35543
+ setTimeout(
35544
+ () => window.requestAnimationFrame(() => {
35545
+ const bottomBarHeight = innerHeight - window.innerHeight;
35546
+ if (bottomBarHeight && scrollY >= innerHeight) {
35547
+ $body.style.top = -(scrollY + bottomBarHeight) + "px";
35548
+ }
35549
+ }),
35550
+ 300
35551
+ );
35521
35552
  }
35522
- };
35523
-
35524
- var setPositionFixed = function setPositionFixed() {
35525
- return window.requestAnimationFrame(function () {
35526
- // If previousBodyPosition is already set, don't set it again.
35527
- if (previousBodyPosition === undefined) {
35528
- previousBodyPosition = {
35529
- position: document.body.style.position,
35530
- top: document.body.style.top,
35531
- left: document.body.style.left
35532
- };
35533
-
35534
- // Update the dom inside an animation frame
35535
- var _window = window,
35536
- scrollY = _window.scrollY,
35537
- scrollX = _window.scrollX,
35538
- innerHeight = _window.innerHeight;
35539
-
35540
- document.body.style.position = 'fixed';
35541
- document.body.style.top = -scrollY;
35542
- document.body.style.left = -scrollX;
35543
-
35544
- setTimeout(function () {
35545
- return window.requestAnimationFrame(function () {
35546
- // Attempt to check if the bottom bar appeared due to the position change
35547
- var bottomBarHeight = innerHeight - window.innerHeight;
35548
- if (bottomBarHeight && scrollY >= innerHeight) {
35549
- // Move the content further up so that the bottom bar doesn't hide it
35550
- document.body.style.top = -(scrollY + bottomBarHeight);
35551
- }
35552
- });
35553
- }, 300);
35554
- }
35555
- });
35556
- };
35557
-
35558
- var restorePositionSetting = function restorePositionSetting() {
35559
- if (previousBodyPosition !== undefined) {
35560
- // Convert the position from "px" to Int
35561
- var y = -parseInt(document.body.style.top, 10);
35562
- var x = -parseInt(document.body.style.left, 10);
35563
-
35564
- // Restore styles
35565
- document.body.style.position = previousBodyPosition.position;
35566
- document.body.style.top = previousBodyPosition.top;
35567
- document.body.style.left = previousBodyPosition.left;
35568
-
35569
- // Restore scroll
35553
+ });
35554
+ const restorePositionSetting = () => {
35555
+ if (bodyStyle !== void 0) {
35556
+ const y = -parseInt(document.body.style.top, 10);
35557
+ const x = -parseInt(document.body.style.left, 10);
35558
+ const $html = document.documentElement;
35559
+ const $body = document.body;
35560
+ $html.style.height = (htmlStyle == null ? void 0 : htmlStyle.height) || "";
35561
+ $html.style.overflow = (htmlStyle == null ? void 0 : htmlStyle.overflow) || "";
35562
+ $body.style.position = bodyStyle.position || "";
35563
+ $body.style.top = bodyStyle.top || "";
35564
+ $body.style.left = bodyStyle.left || "";
35565
+ $body.style.width = bodyStyle.width || "";
35566
+ $body.style.height = bodyStyle.height || "";
35567
+ $body.style.overflow = bodyStyle.overflow || "";
35570
35568
  window.scrollTo(x, y);
35571
-
35572
- previousBodyPosition = undefined;
35569
+ bodyStyle = void 0;
35573
35570
  }
35574
35571
  };
35575
-
35576
- // https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight#Problems_and_solutions
35577
- var isTargetElementTotallyScrolled = function isTargetElementTotallyScrolled(targetElement) {
35578
- return targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
35579
- };
35580
-
35581
- var handleScroll = function handleScroll(event, targetElement) {
35582
- var clientY = event.targetTouches[0].clientY - initialClientY;
35583
-
35572
+ const isTargetElementTotallyScrolled = (targetElement) => targetElement ? targetElement.scrollHeight - targetElement.scrollTop <= targetElement.clientHeight : false;
35573
+ const handleScroll = (event, targetElement) => {
35574
+ const clientY = event.targetTouches[0].clientY - initialClientY;
35584
35575
  if (allowTouchMove(event.target)) {
35585
35576
  return false;
35586
35577
  }
35587
-
35588
35578
  if (targetElement && targetElement.scrollTop === 0 && clientY > 0) {
35589
- // element is at the top of its scroll.
35590
35579
  return preventDefault(event);
35591
35580
  }
35592
-
35593
35581
  if (isTargetElementTotallyScrolled(targetElement) && clientY < 0) {
35594
- // element is at the bottom of its scroll.
35595
35582
  return preventDefault(event);
35596
35583
  }
35597
-
35598
35584
  event.stopPropagation();
35599
35585
  return true;
35600
35586
  };
35601
-
35602
- var disableBodyScroll = function disableBodyScroll(targetElement, options) {
35603
- // targetElement must be provided
35587
+ const disableBodyScroll = (targetElement, options) => {
35604
35588
  if (!targetElement) {
35605
- // eslint-disable-next-line no-console
35606
- console.error('disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.');
35589
+ console.error(
35590
+ "disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices."
35591
+ );
35607
35592
  return;
35608
35593
  }
35609
-
35610
- // disableBodyScroll must not have been called on this targetElement before
35611
- if (locks.some(function (lock) {
35612
- return lock.targetElement === targetElement;
35613
- })) {
35594
+ locksIndex.set(
35595
+ targetElement,
35596
+ (locksIndex == null ? void 0 : locksIndex.get(targetElement)) ? (locksIndex == null ? void 0 : locksIndex.get(targetElement)) + 1 : 1
35597
+ );
35598
+ if (locks.some((lock2) => lock2.targetElement === targetElement)) {
35614
35599
  return;
35615
35600
  }
35616
-
35617
- var lock = {
35618
- targetElement: targetElement,
35601
+ const lock = {
35602
+ targetElement,
35619
35603
  options: options || {}
35620
35604
  };
35621
-
35622
- locks = [].concat(_toConsumableArray(locks), [lock]);
35623
-
35605
+ locks = [...locks, lock];
35624
35606
  if (isIosDevice) {
35625
35607
  setPositionFixed();
35626
35608
  } else {
35627
35609
  setOverflowHidden(options);
35628
35610
  }
35629
-
35630
35611
  if (isIosDevice) {
35631
- targetElement.ontouchstart = function (event) {
35612
+ targetElement.ontouchstart = (event) => {
35632
35613
  if (event.targetTouches.length === 1) {
35633
- // detect single touch.
35634
35614
  initialClientY = event.targetTouches[0].clientY;
35635
35615
  }
35636
35616
  };
35637
- targetElement.ontouchmove = function (event) {
35617
+ targetElement.ontouchmove = (event) => {
35638
35618
  if (event.targetTouches.length === 1) {
35639
- // detect single touch.
35640
35619
  handleScroll(event, targetElement);
35641
35620
  }
35642
35621
  };
35643
-
35644
35622
  if (!documentListenerAdded) {
35645
- document.addEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
35623
+ document.addEventListener(
35624
+ "touchmove",
35625
+ preventDefault,
35626
+ hasPassiveEvents ? { passive: false } : void 0
35627
+ );
35646
35628
  documentListenerAdded = true;
35647
35629
  }
35648
35630
  }
35649
35631
  };
35650
-
35651
- var clearAllBodyScrollLocks = function clearAllBodyScrollLocks() {
35632
+ const clearAllBodyScrollLocks = () => {
35652
35633
  if (isIosDevice) {
35653
- // Clear all locks ontouchstart/ontouchmove handlers, and the references.
35654
- locks.forEach(function (lock) {
35634
+ locks.forEach((lock) => {
35655
35635
  lock.targetElement.ontouchstart = null;
35656
35636
  lock.targetElement.ontouchmove = null;
35657
35637
  });
35658
-
35659
35638
  if (documentListenerAdded) {
35660
- document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
35639
+ document.removeEventListener(
35640
+ "touchmove",
35641
+ preventDefault,
35642
+ hasPassiveEvents ? { passive: false } : void 0
35643
+ );
35661
35644
  documentListenerAdded = false;
35662
35645
  }
35663
-
35664
- // Reset initial clientY.
35665
35646
  initialClientY = -1;
35666
35647
  }
35667
-
35668
35648
  if (isIosDevice) {
35669
35649
  restorePositionSetting();
35670
35650
  } else {
35671
35651
  restoreOverflowSetting();
35672
35652
  }
35673
-
35674
35653
  locks = [];
35654
+ locksIndex.clear();
35675
35655
  };
35676
-
35677
- var enableBodyScroll = function enableBodyScroll(targetElement) {
35656
+ const enableBodyScroll = (targetElement) => {
35678
35657
  if (!targetElement) {
35679
- // eslint-disable-next-line no-console
35680
- console.error('enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.');
35658
+ console.error(
35659
+ "enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices."
35660
+ );
35681
35661
  return;
35682
35662
  }
35683
-
35684
- locks = locks.filter(function (lock) {
35685
- return lock.targetElement !== targetElement;
35686
- });
35687
-
35663
+ locksIndex.set(
35664
+ targetElement,
35665
+ (locksIndex == null ? void 0 : locksIndex.get(targetElement)) ? (locksIndex == null ? void 0 : locksIndex.get(targetElement)) - 1 : 0
35666
+ );
35667
+ if ((locksIndex == null ? void 0 : locksIndex.get(targetElement)) === 0) {
35668
+ locks = locks.filter((lock) => lock.targetElement !== targetElement);
35669
+ locksIndex == null ? void 0 : locksIndex.delete(targetElement);
35670
+ }
35688
35671
  if (isIosDevice) {
35689
35672
  targetElement.ontouchstart = null;
35690
35673
  targetElement.ontouchmove = null;
35691
-
35692
35674
  if (documentListenerAdded && locks.length === 0) {
35693
- document.removeEventListener('touchmove', preventDefault, hasPassiveEvents ? { passive: false } : undefined);
35675
+ document.removeEventListener(
35676
+ "touchmove",
35677
+ preventDefault,
35678
+ hasPassiveEvents ? { passive: false } : void 0
35679
+ );
35694
35680
  documentListenerAdded = false;
35695
35681
  }
35696
35682
  }
35697
-
35698
- if (isIosDevice) {
35699
- restorePositionSetting();
35700
- } else {
35701
- restoreOverflowSetting();
35683
+ if (locks.length === 0) {
35684
+ if (isIosDevice) {
35685
+ restorePositionSetting();
35686
+ } else {
35687
+ restoreOverflowSetting();
35688
+ }
35702
35689
  }
35703
35690
  };
35704
35691
 
@@ -38068,9 +38055,8 @@ var TourPopover = function TourPopover(_ref) {
38068
38055
  var click = useClick(context, {
38069
38056
  enabled: !isControlled
38070
38057
  });
38071
- var dismiss = useDismiss(context);
38072
38058
  var role = useRole(context);
38073
- var _useInteractions = useInteractions([click, dismiss, role]),
38059
+ var _useInteractions = useInteractions([click, role]),
38074
38060
  getFloatingProps = _useInteractions.getFloatingProps;
38075
38061
  var contextValue = React__default.useMemo(function () {
38076
38062
  return {
@@ -38146,17 +38132,21 @@ function useDelayedState(initialState, delay) {
38146
38132
  var _React$useState = React__default.useState(initialState),
38147
38133
  _React$useState2 = _slicedToArray(_React$useState, 2),
38148
38134
  delayedState = _React$useState2[0],
38149
- setDelayedState = _React$useState2[1];
38135
+ _setDelayedState = _React$useState2[1];
38150
38136
  var timeoutRef = React__default.useRef(undefined);
38151
38137
  React__default.useEffect(function () {
38152
38138
  timeoutRef.current = window.setTimeout(function () {
38153
- setDelayedState(initialState);
38139
+ _setDelayedState(initialState);
38154
38140
  }, delay);
38155
38141
  return function () {
38156
38142
  window.clearTimeout(timeoutRef.current);
38157
38143
  };
38158
38144
  }, [delay, initialState]);
38159
- return delayedState;
38145
+ var setDelayedState = React__default.useCallback(function (newState) {
38146
+ _setDelayedState(newState);
38147
+ window.clearTimeout(timeoutRef.current);
38148
+ }, []);
38149
+ return [delayedState, setDelayedState];
38160
38150
  }
38161
38151
 
38162
38152
  /**
@@ -38428,10 +38418,19 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
38428
38418
  setSize = _useState4[1];
38429
38419
 
38430
38420
  // delayed state is used to let the transition finish before reacting to the state changes
38431
- var delayedActiveStep = useDelayedState(activeStep, transitionDelay);
38432
- var delayedSize = useDelayedState(size, transitionDelay);
38421
+ var _useDelayedState = useDelayedState(activeStep, transitionDelay),
38422
+ _useDelayedState2 = _slicedToArray(_useDelayedState, 1),
38423
+ delayedActiveStep = _useDelayedState2[0];
38424
+ var _useDelayedState3 = useDelayedState(size, transitionDelay),
38425
+ _useDelayedState4 = _slicedToArray(_useDelayedState3, 2),
38426
+ delayedSize = _useDelayedState4[0],
38427
+ setDelayedSize = _useDelayedState4[1];
38433
38428
  // keep track of when we are transitioning between steps
38434
38429
  var isTransitioning = useIsTransitioningBetweenSteps(activeStep, transitionDelay);
38430
+ var _useState5 = useState(false),
38431
+ _useState6 = _slicedToArray(_useState5, 2),
38432
+ isScrolling = _useState6[0],
38433
+ setIsScrolling = _useState6[1];
38435
38434
  var currentStepRef = refIdMap.get((_steps$activeStep = steps[activeStep]) === null || _steps$activeStep === void 0 ? void 0 : _steps$activeStep.name);
38436
38435
  var intersection = useIntersectionObserver(currentStepRef, {
38437
38436
  threshold: 0.5
@@ -38478,6 +38477,7 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
38478
38477
  }, []);
38479
38478
  var updateMaskSize = useCallback(function () {
38480
38479
  var _steps$activeStep2;
38480
+ var shouldSkipDelay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
38481
38481
  var ref = refIdMap.get((_steps$activeStep2 = steps[activeStep]) === null || _steps$activeStep2 === void 0 ? void 0 : _steps$activeStep2.name);
38482
38482
  if (!(ref !== null && ref !== void 0 && ref.current)) return;
38483
38483
  var rect = ref.current.getBoundingClientRect();
@@ -38487,7 +38487,15 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
38487
38487
  width: rect.width,
38488
38488
  height: rect.height
38489
38489
  });
38490
- }, [activeStep, refIdMap, steps]);
38490
+ if (shouldSkipDelay) {
38491
+ setDelayedSize({
38492
+ x: rect.x,
38493
+ y: rect.y,
38494
+ width: rect.width,
38495
+ height: rect.height
38496
+ });
38497
+ }
38498
+ }, [activeStep, refIdMap, setDelayedSize, steps]);
38491
38499
  var scrollToStep = useCallback(function () {
38492
38500
  var _steps$delayedActiveS;
38493
38501
  var ref = refIdMap.get((_steps$delayedActiveS = steps[delayedActiveStep]) === null || _steps$delayedActiveS === void 0 ? void 0 : _steps$delayedActiveS.name);
@@ -38495,36 +38503,42 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
38495
38503
 
38496
38504
  // If the element is already in view, don't scroll
38497
38505
  if (intersection !== null && intersection !== void 0 && intersection.isIntersecting) return;
38506
+ setIsScrolling(true);
38498
38507
  smoothScroll(ref.current, {
38499
38508
  behavior: 'smooth',
38500
38509
  block: 'center',
38501
38510
  inline: 'center'
38502
38511
  }).then(function () {
38503
- updateMaskSize();
38512
+ // wait for the scroll to finish before updating the mask size
38513
+ // We also don't want to delay the size update since its already delayed by the scroll
38514
+ updateMaskSize(true);
38504
38515
  })["finally"](function () {
38505
- // do nothing
38516
+ setIsScrolling(false);
38506
38517
  });
38507
38518
  }, [delayedActiveStep, refIdMap, steps, updateMaskSize, intersection === null || intersection === void 0 ? void 0 : intersection.isIntersecting]);
38508
38519
 
38509
38520
  // Update the size of the mask when the active step changes
38510
38521
  useIsomorphicLayoutEffect(function () {
38511
38522
  updateMaskSize();
38512
- }, [isOpen, activeStep, refIdMap, steps, updateMaskSize]);
38523
+ }, [activeStep, updateMaskSize]);
38513
38524
 
38514
38525
  // Scroll into view when the active step changes
38515
38526
  useIsomorphicLayoutEffect(function () {
38527
+ // We need to wait for the transition to finish before scrolling
38528
+ // Otherwise the browser sometimes interrupts the scroll
38529
+ var scrollDelay = 100;
38516
38530
  setTimeout(function () {
38517
38531
  if (!isOpen) return;
38518
38532
  if (isTransitioning) return;
38519
38533
  scrollToStep();
38520
- }, transitionDelay);
38534
+ }, scrollDelay);
38521
38535
  }, [isOpen, scrollToStep, isTransitioning]);
38522
- useLockBodyScroll(isOpen);
38523
38536
 
38524
38537
  // reset the mask size when the tour is closed
38525
- React__default.useEffect(function () {
38538
+ useIsomorphicLayoutEffect(function () {
38526
38539
  if (isOpen) {
38527
- updateMaskSize();
38540
+ // on initial mount, we don't want to delay the size update
38541
+ updateMaskSize(true);
38528
38542
  onOpenChange === null || onOpenChange === void 0 ? void 0 : onOpenChange({
38529
38543
  isOpen: isOpen
38530
38544
  });
@@ -38539,6 +38553,7 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
38539
38553
  }
38540
38554
  // eslint-disable-next-line react-hooks/exhaustive-deps
38541
38555
  }, [isOpen]);
38556
+ useLockBodyScroll(isOpen);
38542
38557
  var contextValue = useMemo(function () {
38543
38558
  return {
38544
38559
  attachStep: attachStep,
@@ -38549,7 +38564,7 @@ var SpotlightPopoverTour = function SpotlightPopoverTour(_ref) {
38549
38564
  value: contextValue,
38550
38565
  children: [/*#__PURE__*/jsx$1(FloatingPortal, {
38551
38566
  children: isOpen ? /*#__PURE__*/jsx$1(SpotlightPopoverTourMask, {
38552
- isTransitioning: isTransitioning,
38567
+ isTransitioning: isTransitioning || isScrolling,
38553
38568
  padding: theme.spacing[4],
38554
38569
  size: delayedSize
38555
38570
  }) : null