@razorpay/blade 8.10.3 → 8.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/index.d.ts +8 -5
- package/build/components/index.native.d.ts +8 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.web.js +50 -97
- package/build/components/index.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 +1 -1
|
@@ -5,14 +5,13 @@ import _typeof from '@babel/runtime/helpers/typeof';
|
|
|
5
5
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
6
6
|
import styled, { ThemeProvider, css, keyframes } from 'styled-components';
|
|
7
7
|
import _objectWithoutProperties$1 from '@babel/runtime/helpers/objectWithoutProperties';
|
|
8
|
-
import { FloatingDelayGroup, detectOverflow, useFloating, FloatingOverlay, FloatingFocusManager, shift, flip, offset, arrow,
|
|
8
|
+
import { FloatingDelayGroup, detectOverflow, useFloating, autoUpdate, FloatingOverlay, FloatingPortal, FloatingFocusManager, shift, flip, offset, arrow, useTransitionStyles, useDelayGroup, useDelayGroupContext, useHover, useFocus, useRole, useInteractions, FloatingArrow } from '@floating-ui/react';
|
|
9
9
|
import _toConsumableArray$1 from '@babel/runtime/helpers/toConsumableArray';
|
|
10
10
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
11
11
|
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
12
12
|
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
13
13
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
14
14
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
15
|
-
import { createPortal } from 'react-dom';
|
|
16
15
|
|
|
17
16
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
18
17
|
|
|
@@ -5094,60 +5093,66 @@ var makeInputDisplayValue = function makeInputDisplayValue(selectedIndices, opti
|
|
|
5094
5093
|
return "".concat(selectedIndices.length, " items selected");
|
|
5095
5094
|
};
|
|
5096
5095
|
|
|
5097
|
-
/**
|
|
5098
|
-
* This object is used for calculating overflows in dropdown overlay.
|
|
5099
|
-
* 400 is used since max-width of dropdown overlay is 400px.
|
|
5100
|
-
*/
|
|
5101
|
-
var POSITION_THRESHOLDS = {
|
|
5102
|
-
top: -400,
|
|
5103
|
-
bottom: -300,
|
|
5104
|
-
left: -400,
|
|
5105
|
-
right: -400
|
|
5106
|
-
};
|
|
5107
5096
|
/**
|
|
5108
5097
|
* This function calculates the position of dropdown overlay with respect to dropdown trigger element.
|
|
5109
5098
|
* For non-menus (e.g SelectInput), position is flipped if overflow is on bottom.
|
|
5110
5099
|
* For menus (e.g. DropdownButton), position is flipped if overflow is on right or bottom.
|
|
5111
5100
|
* Additional spacing is added to clientHeight to provide spacing above the dropdown trigger.
|
|
5112
5101
|
*/
|
|
5113
|
-
|
|
5114
5102
|
var getDropdownOverlayPosition = function getDropdownOverlayPosition(_ref) {
|
|
5115
5103
|
var position = _ref.overflow,
|
|
5116
5104
|
isMenu = _ref.isMenu,
|
|
5117
|
-
triggererEl = _ref.triggererEl
|
|
5105
|
+
triggererEl = _ref.triggererEl,
|
|
5106
|
+
actionListItemEl = _ref.actionListItemEl;
|
|
5118
5107
|
var zeroSpacing = 'spacing.0';
|
|
5119
|
-
var
|
|
5108
|
+
var top = position.top,
|
|
5109
|
+
bottom = position.bottom,
|
|
5120
5110
|
right = position.right;
|
|
5121
5111
|
var newPosition = {
|
|
5122
5112
|
left: zeroSpacing
|
|
5123
5113
|
};
|
|
5114
|
+
/**
|
|
5115
|
+
* Calculating thresholds using the height & width of action list element with offset of 16px
|
|
5116
|
+
*/
|
|
5117
|
+
|
|
5118
|
+
var WIDTH_THRESHOLD = (Number(actionListItemEl === null || actionListItemEl === void 0 ? void 0 : actionListItemEl.clientWidth) + Number(size[16])) * -1;
|
|
5119
|
+
var HEIGHT_THRESHOLD = (Number(actionListItemEl === null || actionListItemEl === void 0 ? void 0 : actionListItemEl.clientHeight) + Number(size[16])) * -1;
|
|
5124
5120
|
|
|
5125
5121
|
if (!isMenu) {
|
|
5126
|
-
if (bottom >
|
|
5122
|
+
if (bottom > HEIGHT_THRESHOLD) {
|
|
5127
5123
|
newPosition.bottom = "".concat(Number(triggererEl === null || triggererEl === void 0 ? void 0 : triggererEl.clientHeight) + Number(size[32]), "px");
|
|
5124
|
+
newPosition.top = undefined;
|
|
5125
|
+
}
|
|
5126
|
+
|
|
5127
|
+
if (top > HEIGHT_THRESHOLD) {
|
|
5128
|
+
newPosition.top = zeroSpacing;
|
|
5129
|
+
newPosition.bottom = undefined;
|
|
5128
5130
|
}
|
|
5129
5131
|
|
|
5130
|
-
console.log({
|
|
5131
|
-
newPosition: newPosition
|
|
5132
|
-
});
|
|
5133
5132
|
return newPosition;
|
|
5134
5133
|
}
|
|
5135
5134
|
|
|
5136
|
-
if (right >
|
|
5135
|
+
if (right > WIDTH_THRESHOLD) {
|
|
5137
5136
|
newPosition.right = zeroSpacing;
|
|
5138
5137
|
newPosition.left = undefined;
|
|
5139
5138
|
}
|
|
5140
5139
|
|
|
5141
|
-
if (bottom >
|
|
5140
|
+
if (bottom > HEIGHT_THRESHOLD) {
|
|
5142
5141
|
newPosition.bottom = "".concat(Number(triggererEl === null || triggererEl === void 0 ? void 0 : triggererEl.clientHeight) + Number(size[20]), "px");
|
|
5143
5142
|
newPosition.top = undefined;
|
|
5144
5143
|
}
|
|
5145
5144
|
|
|
5145
|
+
if (top > HEIGHT_THRESHOLD) {
|
|
5146
|
+
newPosition.top = zeroSpacing;
|
|
5147
|
+
newPosition.bottom = undefined;
|
|
5148
|
+
}
|
|
5149
|
+
|
|
5146
5150
|
return newPosition;
|
|
5147
5151
|
};
|
|
5148
5152
|
var getDropdownOverflowMiddleware = function getDropdownOverflowMiddleware(_ref2) {
|
|
5149
5153
|
var isMenu = _ref2.isMenu,
|
|
5150
5154
|
triggererRef = _ref2.triggererRef,
|
|
5155
|
+
actionListItemRef = _ref2.actionListItemRef,
|
|
5151
5156
|
setDropdownPosition = _ref2.setDropdownPosition;
|
|
5152
5157
|
return {
|
|
5153
5158
|
name: 'detectOverflowMiddleware',
|
|
@@ -5168,7 +5173,8 @@ var getDropdownOverflowMiddleware = function getDropdownOverflowMiddleware(_ref2
|
|
|
5168
5173
|
position = getDropdownOverlayPosition({
|
|
5169
5174
|
overflow: overflow,
|
|
5170
5175
|
isMenu: isMenu,
|
|
5171
|
-
triggererEl: triggererRef.current
|
|
5176
|
+
triggererEl: triggererRef.current,
|
|
5177
|
+
actionListItemEl: actionListItemRef.current
|
|
5172
5178
|
});
|
|
5173
5179
|
setDropdownPosition(position);
|
|
5174
5180
|
return _context.abrupt("return", {});
|
|
@@ -21804,7 +21810,7 @@ var StyledDropdownOverlay = /*#__PURE__*/styled(BaseBox).withConfig({
|
|
|
21804
21810
|
displayName: "DropdownOverlayweb__StyledDropdownOverlay",
|
|
21805
21811
|
componentId: "sc-9pwxtx-0"
|
|
21806
21812
|
})(function (props) {
|
|
21807
|
-
return css(["", " transform:translateY(", ");opacity:0;z-index:99;"], props.transition, makeSize(props.theme.spacing[3]));
|
|
21813
|
+
return css(["", " transform:translateY(", ");opacity:0;z-index:99;pointer-events:", ";"], props.transition, makeSize(props.theme.spacing[3]), props.isOpen ? 'all' : 'none');
|
|
21808
21814
|
});
|
|
21809
21815
|
|
|
21810
21816
|
/**
|
|
@@ -21821,25 +21827,26 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21821
21827
|
triggererRef = _useDropdown.triggererRef,
|
|
21822
21828
|
hasLabelOnLeft = _useDropdown.hasLabelOnLeft,
|
|
21823
21829
|
dropdownTriggerer = _useDropdown.dropdownTriggerer,
|
|
21824
|
-
setIsOpen = _useDropdown.setIsOpen
|
|
21830
|
+
setIsOpen = _useDropdown.setIsOpen,
|
|
21831
|
+
actionListItemRef = _useDropdown.actionListItemRef;
|
|
21825
21832
|
|
|
21826
21833
|
var _useTheme = useTheme(),
|
|
21827
21834
|
theme = _useTheme.theme;
|
|
21828
21835
|
|
|
21829
|
-
var _React$useState = React__default.useState(
|
|
21836
|
+
var _React$useState = React__default.useState(false),
|
|
21830
21837
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
21831
|
-
|
|
21832
|
-
|
|
21838
|
+
showFadeOutAnimation = _React$useState2[0],
|
|
21839
|
+
setShowFadeOutAnimation = _React$useState2[1];
|
|
21833
21840
|
|
|
21834
21841
|
var _React$useState3 = React__default.useState('100%'),
|
|
21835
21842
|
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
21836
21843
|
width = _React$useState4[0],
|
|
21837
21844
|
setWidth = _React$useState4[1];
|
|
21838
21845
|
|
|
21839
|
-
var
|
|
21840
|
-
|
|
21841
|
-
dropdownPosition =
|
|
21842
|
-
setDropdownPosition =
|
|
21846
|
+
var _React$useState5 = React__default.useState({}),
|
|
21847
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
21848
|
+
dropdownPosition = _React$useState6[0],
|
|
21849
|
+
setDropdownPosition = _React$useState6[1];
|
|
21843
21850
|
|
|
21844
21851
|
var isMenu = dropdownTriggerer !== 'SelectInput';
|
|
21845
21852
|
|
|
@@ -21854,20 +21861,22 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21854
21861
|
middleware: [getDropdownOverflowMiddleware({
|
|
21855
21862
|
isMenu: isMenu,
|
|
21856
21863
|
triggererRef: triggererRef,
|
|
21864
|
+
actionListItemRef: actionListItemRef,
|
|
21857
21865
|
setDropdownPosition: setDropdownPosition
|
|
21858
|
-
})]
|
|
21866
|
+
})],
|
|
21867
|
+
whileElementsMounted: autoUpdate
|
|
21859
21868
|
}),
|
|
21860
21869
|
refs = _useFloating.refs;
|
|
21861
21870
|
|
|
21862
21871
|
var fadeIn = /*#__PURE__*/css(["animation:", " ", " ", ";"], dropdownFadeIn, makeMotionTime(theme.motion.duration.quick), String(theme.motion.easing.entrance.revealing));
|
|
21863
21872
|
var fadeOut = /*#__PURE__*/css(["animation:", " ", " ", ";"], dropdownFadeOut, makeMotionTime(theme.motion.duration.quick), String(theme.motion.easing.entrance.revealing));
|
|
21873
|
+
var noAnimation = /*#__PURE__*/css(["animation:none;"]);
|
|
21864
21874
|
React__default.useEffect(function () {
|
|
21865
21875
|
if (isOpen) {
|
|
21866
21876
|
var _triggererRef$current;
|
|
21867
21877
|
|
|
21868
21878
|
// On Safari clicking on a non input element doesn't focuses it https://bugs.webkit.org/show_bug.cgi?id=22261
|
|
21869
21879
|
(_triggererRef$current = triggererRef.current) === null || _triggererRef$current === void 0 ? void 0 : _triggererRef$current.focus();
|
|
21870
|
-
setDisplay('block');
|
|
21871
21880
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21872
21881
|
|
|
21873
21882
|
}, [isOpen]); // We want to set width of overlay as per width of the SelectInput
|
|
@@ -21904,9 +21913,9 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21904
21913
|
}, [setWidth, triggererRef, hasLabelOnLeft]);
|
|
21905
21914
|
var onAnimationEnd = React__default.useCallback(function () {
|
|
21906
21915
|
if (isOpen) {
|
|
21907
|
-
|
|
21916
|
+
setShowFadeOutAnimation(true);
|
|
21908
21917
|
} else {
|
|
21909
|
-
|
|
21918
|
+
setShowFadeOutAnimation(false);
|
|
21910
21919
|
}
|
|
21911
21920
|
}, [isOpen]);
|
|
21912
21921
|
var styles = React__default.useMemo(function () {
|
|
@@ -21930,9 +21939,9 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21930
21939
|
right: dropdownPosition.right,
|
|
21931
21940
|
bottom: dropdownPosition.bottom,
|
|
21932
21941
|
style: styles,
|
|
21933
|
-
|
|
21942
|
+
isOpen: isOpen,
|
|
21934
21943
|
position: "absolute",
|
|
21935
|
-
transition: isOpen ? fadeIn : fadeOut,
|
|
21944
|
+
transition: isOpen ? fadeIn : showFadeOutAnimation ? fadeOut : noAnimation,
|
|
21936
21945
|
onAnimationEnd: onAnimationEnd
|
|
21937
21946
|
}, metaAttribute({
|
|
21938
21947
|
name: MetaConstants.DropdownOverlay,
|
|
@@ -25083,25 +25092,6 @@ isVisible, opts) {
|
|
|
25083
25092
|
};
|
|
25084
25093
|
}
|
|
25085
25094
|
|
|
25086
|
-
var createModalRootWrapper = function createModalRootWrapper(id) {
|
|
25087
|
-
var element = document.createElement('div');
|
|
25088
|
-
element.setAttribute('id', id);
|
|
25089
|
-
document.body.appendChild(element);
|
|
25090
|
-
return element;
|
|
25091
|
-
};
|
|
25092
|
-
|
|
25093
|
-
var ModalPortal = function ModalPortal(_ref) {
|
|
25094
|
-
var children = _ref.children;
|
|
25095
|
-
var wrapperID = 'blade-modal-root-portal';
|
|
25096
|
-
var element = document.getElementById(wrapperID);
|
|
25097
|
-
|
|
25098
|
-
if (!element) {
|
|
25099
|
-
element = createModalRootWrapper(wrapperID);
|
|
25100
|
-
}
|
|
25101
|
-
|
|
25102
|
-
return /*#__PURE__*/createPortal(children, element);
|
|
25103
|
-
};
|
|
25104
|
-
|
|
25105
25095
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
25106
25096
|
var ModalContext = /*#__PURE__*/React__default.createContext({
|
|
25107
25097
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -25520,48 +25510,9 @@ var Modal = function Modal(_ref2) {
|
|
|
25520
25510
|
open: isMounted
|
|
25521
25511
|
}),
|
|
25522
25512
|
refs = _useFloating.refs,
|
|
25523
|
-
context = _useFloating.context;
|
|
25524
|
-
|
|
25513
|
+
context = _useFloating.context;
|
|
25525
25514
|
|
|
25526
25515
|
var defaultInitialFocusRef = React__default.useRef(null);
|
|
25527
|
-
var originalFocusElement = React__default.useRef(null);
|
|
25528
|
-
var returnFocus = React__default.useCallback(function () {
|
|
25529
|
-
if (!originalFocusElement.current) return;
|
|
25530
|
-
originalFocusElement.current.focus(); // After returning focus we will clear the original focus
|
|
25531
|
-
// Because if modal can be opened up via multiple triggers
|
|
25532
|
-
// We want to ensure the focus returns back to the most recent triggerer
|
|
25533
|
-
|
|
25534
|
-
originalFocusElement.current = null;
|
|
25535
|
-
}, [originalFocusElement]);
|
|
25536
|
-
var focusOnInitialRef = React__default.useCallback(function () {
|
|
25537
|
-
if (!initialFocusRef) {
|
|
25538
|
-
var _defaultInitialFocusR;
|
|
25539
|
-
|
|
25540
|
-
// focus on close button
|
|
25541
|
-
(_defaultInitialFocusR = defaultInitialFocusRef.current) === null || _defaultInitialFocusR === void 0 ? void 0 : _defaultInitialFocusR.focus();
|
|
25542
|
-
} else {
|
|
25543
|
-
var _initialFocusRef$curr;
|
|
25544
|
-
|
|
25545
|
-
// focus on the initialRef passed by the user
|
|
25546
|
-
(_initialFocusRef$curr = initialFocusRef.current) === null || _initialFocusRef$curr === void 0 ? void 0 : _initialFocusRef$curr.focus();
|
|
25547
|
-
}
|
|
25548
|
-
}, [initialFocusRef]);
|
|
25549
|
-
React__default.useEffect(function () {
|
|
25550
|
-
if (isMounted) {
|
|
25551
|
-
var _originalFocusElement;
|
|
25552
|
-
|
|
25553
|
-
// set the original focus element where the focus will return to after closing the modal
|
|
25554
|
-
originalFocusElement.current = (_originalFocusElement = originalFocusElement.current) !== null && _originalFocusElement !== void 0 ? _originalFocusElement : document.activeElement; // focus on an element on Modal, if initialFocusRef is not passed, focus on the close button
|
|
25555
|
-
|
|
25556
|
-
focusOnInitialRef();
|
|
25557
|
-
}
|
|
25558
|
-
}, [isMounted, focusOnInitialRef]);
|
|
25559
|
-
React__default.useEffect(function () {
|
|
25560
|
-
// Return focus to the element that originally had it
|
|
25561
|
-
if (!isOpen) {
|
|
25562
|
-
returnFocus();
|
|
25563
|
-
}
|
|
25564
|
-
}, [isOpen, returnFocus]);
|
|
25565
25516
|
var modalContext = React__default.useMemo(function () {
|
|
25566
25517
|
return {
|
|
25567
25518
|
isOpen: isOpen,
|
|
@@ -25586,10 +25537,12 @@ var Modal = function Modal(_ref2) {
|
|
|
25586
25537
|
throw new Error('[Blade Modal] Modal only accepts ModalHeader, ModalBody and ModalFooter as children');
|
|
25587
25538
|
}
|
|
25588
25539
|
});
|
|
25589
|
-
return /*#__PURE__*/jsx(
|
|
25540
|
+
return /*#__PURE__*/jsx(FloatingPortal, {
|
|
25590
25541
|
children: /*#__PURE__*/jsx(ModalContext.Provider, {
|
|
25591
25542
|
value: modalContext,
|
|
25592
25543
|
children: isMounted ? /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
25544
|
+
returnFocus: true,
|
|
25545
|
+
initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : defaultInitialFocusRef,
|
|
25593
25546
|
context: context,
|
|
25594
25547
|
modal: true,
|
|
25595
25548
|
children: /*#__PURE__*/jsxs(Box, {
|