@razorpay/blade 8.10.3 → 8.11.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 +7 -4
- package/build/components/index.native.d.ts +7 -4
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.web.js +5 -62
- 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, autoUpdate, useTransitionStyles, useDelayGroup, useDelayGroupContext, useHover, useFocus, useRole, useInteractions,
|
|
8
|
+
import { FloatingDelayGroup, detectOverflow, useFloating, FloatingOverlay, FloatingPortal, FloatingFocusManager, shift, flip, offset, arrow, autoUpdate, 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
|
|
|
@@ -25083,25 +25082,6 @@ isVisible, opts) {
|
|
|
25083
25082
|
};
|
|
25084
25083
|
}
|
|
25085
25084
|
|
|
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
25085
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
25106
25086
|
var ModalContext = /*#__PURE__*/React__default.createContext({
|
|
25107
25087
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
@@ -25520,48 +25500,9 @@ var Modal = function Modal(_ref2) {
|
|
|
25520
25500
|
open: isMounted
|
|
25521
25501
|
}),
|
|
25522
25502
|
refs = _useFloating.refs,
|
|
25523
|
-
context = _useFloating.context;
|
|
25524
|
-
|
|
25503
|
+
context = _useFloating.context;
|
|
25525
25504
|
|
|
25526
25505
|
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
25506
|
var modalContext = React__default.useMemo(function () {
|
|
25566
25507
|
return {
|
|
25567
25508
|
isOpen: isOpen,
|
|
@@ -25586,10 +25527,12 @@ var Modal = function Modal(_ref2) {
|
|
|
25586
25527
|
throw new Error('[Blade Modal] Modal only accepts ModalHeader, ModalBody and ModalFooter as children');
|
|
25587
25528
|
}
|
|
25588
25529
|
});
|
|
25589
|
-
return /*#__PURE__*/jsx(
|
|
25530
|
+
return /*#__PURE__*/jsx(FloatingPortal, {
|
|
25590
25531
|
children: /*#__PURE__*/jsx(ModalContext.Provider, {
|
|
25591
25532
|
value: modalContext,
|
|
25592
25533
|
children: isMounted ? /*#__PURE__*/jsx(FloatingFocusManager, {
|
|
25534
|
+
returnFocus: true,
|
|
25535
|
+
initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : defaultInitialFocusRef,
|
|
25593
25536
|
context: context,
|
|
25594
25537
|
modal: true,
|
|
25595
25538
|
children: /*#__PURE__*/jsxs(Box, {
|