@razorpay/blade 10.19.1 → 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.
- package/build/components/index.d.ts +3 -1
- package/build/components/index.development.web.js +191 -204
- package/build/components/index.development.web.js.map +1 -1
- package/build/components/index.native.d.ts +3 -1
- package/build/components/index.native.js +3 -3
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.production.web.js +191 -204
- package/build/components/index.production.web.js.map +1 -1
- package/build/css/bankingThemeDarkDesktop.css +1 -1
- package/build/css/bankingThemeDarkMobile.css +1 -1
- package/build/css/bankingThemeLightDesktop.css +1 -1
- package/build/css/bankingThemeLightMobile.css +1 -1
- package/build/css/paymentThemeDarkDesktop.css +1 -1
- package/build/css/paymentThemeDarkMobile.css +1 -1
- package/build/css/paymentThemeLightDesktop.css +1 -1
- package/build/css/paymentThemeLightMobile.css +1 -1
- package/package.json +2 -2
|
@@ -3134,6 +3134,7 @@ declare type BaseTextProps = {
|
|
|
3134
3134
|
fontStyle?: 'italic' | 'normal';
|
|
3135
3135
|
textDecorationLine?: 'line-through' | 'none' | 'underline';
|
|
3136
3136
|
lineHeight?: keyof Theme['typography']['lineHeights'];
|
|
3137
|
+
wordBreak?: 'normal' | 'break-all' | 'keep-all' | 'break-word';
|
|
3137
3138
|
/**
|
|
3138
3139
|
* Web only
|
|
3139
3140
|
*/
|
|
@@ -3493,6 +3494,7 @@ declare type TextCommonProps = {
|
|
|
3493
3494
|
color?: BaseTextProps['color'];
|
|
3494
3495
|
textAlign?: BaseTextProps['textAlign'];
|
|
3495
3496
|
textDecorationLine?: BaseTextProps['textDecorationLine'];
|
|
3497
|
+
wordBreak?: BaseTextProps['wordBreak'];
|
|
3496
3498
|
} & TestID & StyledPropsBlade;
|
|
3497
3499
|
declare type TextVariant = 'body' | 'caption';
|
|
3498
3500
|
declare type TextBodyVariant = TextCommonProps & {
|
|
@@ -3519,7 +3521,7 @@ declare const getTextProps: <T extends {
|
|
|
3519
3521
|
}>({ variant, type, weight, size, color, contrast, testID, textAlign, textDecorationLine, }: GetTextProps<T>) => GetTextPropsReturn;
|
|
3520
3522
|
declare const Text: <T extends {
|
|
3521
3523
|
variant: TextVariant;
|
|
3522
|
-
}>({ as, variant, weight, size, type, contrast, truncateAfterLines, children, color, testID, textAlign, textDecorationLine, ...styledProps }: TextProps<T>) => ReactElement;
|
|
3524
|
+
}>({ as, variant, weight, size, type, contrast, truncateAfterLines, children, color, testID, textAlign, textDecorationLine, wordBreak, ...styledProps }: TextProps<T>) => ReactElement;
|
|
3523
3525
|
|
|
3524
3526
|
declare type CodeCommonProps = {
|
|
3525
3527
|
/**
|
|
@@ -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
|
|
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
|
|
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
|
|
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(
|
|
3222
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
35428
|
-
|
|
35429
|
-
|
|
35430
|
-
|
|
35431
|
-
|
|
35432
|
-
|
|
35433
|
-
|
|
35434
|
-
|
|
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
|
|
35468
|
+
return void 0;
|
|
35440
35469
|
}
|
|
35441
35470
|
};
|
|
35442
|
-
window.addEventListener(
|
|
35443
|
-
window.removeEventListener(
|
|
35471
|
+
window.addEventListener("testPassive", null, passiveTestOptions);
|
|
35472
|
+
window.removeEventListener("testPassive", null, passiveTestOptions);
|
|
35444
35473
|
}
|
|
35445
|
-
|
|
35446
|
-
|
|
35447
|
-
|
|
35448
|
-
|
|
35449
|
-
|
|
35450
|
-
|
|
35451
|
-
|
|
35452
|
-
|
|
35453
|
-
|
|
35454
|
-
|
|
35455
|
-
|
|
35456
|
-
|
|
35457
|
-
|
|
35458
|
-
return
|
|
35459
|
-
|
|
35460
|
-
|
|
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
|
-
|
|
35479
|
-
if (e.
|
|
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
|
-
|
|
35487
|
-
|
|
35488
|
-
|
|
35489
|
-
|
|
35490
|
-
|
|
35491
|
-
|
|
35492
|
-
|
|
35493
|
-
|
|
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
|
|
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 =
|
|
35515
|
+
document.body.style.overflow = "hidden";
|
|
35503
35516
|
}
|
|
35504
35517
|
};
|
|
35505
|
-
|
|
35506
|
-
|
|
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
|
-
|
|
35519
|
-
|
|
35520
|
-
|
|
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
|
-
|
|
35525
|
-
|
|
35526
|
-
|
|
35527
|
-
|
|
35528
|
-
|
|
35529
|
-
|
|
35530
|
-
|
|
35531
|
-
|
|
35532
|
-
|
|
35533
|
-
|
|
35534
|
-
|
|
35535
|
-
|
|
35536
|
-
|
|
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
|
-
|
|
35577
|
-
|
|
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
|
-
|
|
35606
|
-
|
|
35589
|
+
console.error(
|
|
35590
|
+
"disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices."
|
|
35591
|
+
);
|
|
35607
35592
|
return;
|
|
35608
35593
|
}
|
|
35609
|
-
|
|
35610
|
-
|
|
35611
|
-
|
|
35612
|
-
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
35680
|
-
|
|
35658
|
+
console.error(
|
|
35659
|
+
"enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices."
|
|
35660
|
+
);
|
|
35681
35661
|
return;
|
|
35682
35662
|
}
|
|
35683
|
-
|
|
35684
|
-
|
|
35685
|
-
|
|
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(
|
|
35675
|
+
document.removeEventListener(
|
|
35676
|
+
"touchmove",
|
|
35677
|
+
preventDefault,
|
|
35678
|
+
hasPassiveEvents ? { passive: false } : void 0
|
|
35679
|
+
);
|
|
35694
35680
|
documentListenerAdded = false;
|
|
35695
35681
|
}
|
|
35696
35682
|
}
|
|
35697
|
-
|
|
35698
|
-
|
|
35699
|
-
|
|
35700
|
-
|
|
35701
|
-
|
|
35683
|
+
if (locks.length === 0) {
|
|
35684
|
+
if (isIosDevice) {
|
|
35685
|
+
restorePositionSetting();
|
|
35686
|
+
} else {
|
|
35687
|
+
restoreOverflowSetting();
|
|
35688
|
+
}
|
|
35702
35689
|
}
|
|
35703
35690
|
};
|
|
35704
35691
|
|