@razorpay/blade 8.10.2 → 8.10.3
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 +4 -3
- package/build/components/index.native.d.ts +4 -3
- package/build/components/index.native.js +2 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.web.js +147 -33
- 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 +3 -3
|
@@ -5,9 +5,11 @@ 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,
|
|
8
|
+
import { FloatingDelayGroup, detectOverflow, useFloating, FloatingOverlay, FloatingFocusManager, shift, flip, offset, arrow, autoUpdate, useTransitionStyles, useDelayGroup, useDelayGroupContext, useHover, useFocus, useRole, useInteractions, FloatingPortal, 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
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
12
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
11
13
|
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
12
14
|
import _createClass from '@babel/runtime/helpers/createClass';
|
|
13
15
|
import { createPortal } from 'react-dom';
|
|
@@ -4806,14 +4808,6 @@ var ActionListBox = /*#__PURE__*/assignWithoutSideEffects(_ActionListBox, {
|
|
|
4806
4808
|
displayName: 'ActionListBox'
|
|
4807
4809
|
});
|
|
4808
4810
|
|
|
4809
|
-
/*
|
|
4810
|
-
* This content is licensed according to the W3C Software License at
|
|
4811
|
-
* https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document
|
|
4812
|
-
*
|
|
4813
|
-
* This software or document includes material copied from or derived from
|
|
4814
|
-
* https://www.w3.org/WAI/ARIA/apg/example-index/combobox/combobox-select-only.html.
|
|
4815
|
-
* Copyright © 2022 W3C® (MIT, ERCIM, Keio, Beihang)
|
|
4816
|
-
*/
|
|
4817
4811
|
var componentIds = {
|
|
4818
4812
|
DropdownOverlay: 'DropdownOverlay',
|
|
4819
4813
|
Dropdown: 'Dropdown',
|
|
@@ -5100,6 +5094,96 @@ var makeInputDisplayValue = function makeInputDisplayValue(selectedIndices, opti
|
|
|
5100
5094
|
return "".concat(selectedIndices.length, " items selected");
|
|
5101
5095
|
};
|
|
5102
5096
|
|
|
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
|
+
/**
|
|
5108
|
+
* This function calculates the position of dropdown overlay with respect to dropdown trigger element.
|
|
5109
|
+
* For non-menus (e.g SelectInput), position is flipped if overflow is on bottom.
|
|
5110
|
+
* For menus (e.g. DropdownButton), position is flipped if overflow is on right or bottom.
|
|
5111
|
+
* Additional spacing is added to clientHeight to provide spacing above the dropdown trigger.
|
|
5112
|
+
*/
|
|
5113
|
+
|
|
5114
|
+
var getDropdownOverlayPosition = function getDropdownOverlayPosition(_ref) {
|
|
5115
|
+
var position = _ref.overflow,
|
|
5116
|
+
isMenu = _ref.isMenu,
|
|
5117
|
+
triggererEl = _ref.triggererEl;
|
|
5118
|
+
var zeroSpacing = 'spacing.0';
|
|
5119
|
+
var bottom = position.bottom,
|
|
5120
|
+
right = position.right;
|
|
5121
|
+
var newPosition = {
|
|
5122
|
+
left: zeroSpacing
|
|
5123
|
+
};
|
|
5124
|
+
|
|
5125
|
+
if (!isMenu) {
|
|
5126
|
+
if (bottom > POSITION_THRESHOLDS.bottom) {
|
|
5127
|
+
newPosition.bottom = "".concat(Number(triggererEl === null || triggererEl === void 0 ? void 0 : triggererEl.clientHeight) + Number(size[32]), "px");
|
|
5128
|
+
}
|
|
5129
|
+
|
|
5130
|
+
console.log({
|
|
5131
|
+
newPosition: newPosition
|
|
5132
|
+
});
|
|
5133
|
+
return newPosition;
|
|
5134
|
+
}
|
|
5135
|
+
|
|
5136
|
+
if (right > POSITION_THRESHOLDS.right) {
|
|
5137
|
+
newPosition.right = zeroSpacing;
|
|
5138
|
+
newPosition.left = undefined;
|
|
5139
|
+
}
|
|
5140
|
+
|
|
5141
|
+
if (bottom > POSITION_THRESHOLDS.bottom) {
|
|
5142
|
+
newPosition.bottom = "".concat(Number(triggererEl === null || triggererEl === void 0 ? void 0 : triggererEl.clientHeight) + Number(size[20]), "px");
|
|
5143
|
+
newPosition.top = undefined;
|
|
5144
|
+
}
|
|
5145
|
+
|
|
5146
|
+
return newPosition;
|
|
5147
|
+
};
|
|
5148
|
+
var getDropdownOverflowMiddleware = function getDropdownOverflowMiddleware(_ref2) {
|
|
5149
|
+
var isMenu = _ref2.isMenu,
|
|
5150
|
+
triggererRef = _ref2.triggererRef,
|
|
5151
|
+
setDropdownPosition = _ref2.setDropdownPosition;
|
|
5152
|
+
return {
|
|
5153
|
+
name: 'detectOverflowMiddleware',
|
|
5154
|
+
fn: function fn(state) {
|
|
5155
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
5156
|
+
var overflow, position;
|
|
5157
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
5158
|
+
while (1) {
|
|
5159
|
+
switch (_context.prev = _context.next) {
|
|
5160
|
+
case 0:
|
|
5161
|
+
_context.next = 2;
|
|
5162
|
+
return detectOverflow(state, {
|
|
5163
|
+
elementContext: 'reference'
|
|
5164
|
+
});
|
|
5165
|
+
|
|
5166
|
+
case 2:
|
|
5167
|
+
overflow = _context.sent;
|
|
5168
|
+
position = getDropdownOverlayPosition({
|
|
5169
|
+
overflow: overflow,
|
|
5170
|
+
isMenu: isMenu,
|
|
5171
|
+
triggererEl: triggererRef.current
|
|
5172
|
+
});
|
|
5173
|
+
setDropdownPosition(position);
|
|
5174
|
+
return _context.abrupt("return", {});
|
|
5175
|
+
|
|
5176
|
+
case 6:
|
|
5177
|
+
case "end":
|
|
5178
|
+
return _context.stop();
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
}, _callee);
|
|
5182
|
+
}))();
|
|
5183
|
+
}
|
|
5184
|
+
};
|
|
5185
|
+
};
|
|
5186
|
+
|
|
5103
5187
|
var _excluded$4R = ["isOpen", "setIsOpen", "close", "selectedIndices", "setSelectedIndices", "activeIndex", "setActiveIndex", "shouldIgnoreBlur", "setShouldIgnoreBlur", "isKeydownPressed", "setIsKeydownPressed", "options", "selectionType", "changeCallbackTriggerer", "setChangeCallbackTriggerer", "isControlled", "setControlledValueIndices"];
|
|
5104
5188
|
|
|
5105
5189
|
function ownKeys$5I(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; }
|
|
@@ -17494,7 +17578,8 @@ var useBladeInnerRef = function useBladeInnerRef(targetRef, handlers) {
|
|
|
17494
17578
|
},
|
|
17495
17579
|
getBoundingClientRect: function getBoundingClientRect() {
|
|
17496
17580
|
return element === null || element === void 0 ? void 0 : element.getBoundingClientRect();
|
|
17497
|
-
}
|
|
17581
|
+
},
|
|
17582
|
+
clientHeight: element.clientHeight
|
|
17498
17583
|
};
|
|
17499
17584
|
}, [innerRef, handlers]);
|
|
17500
17585
|
return innerRef;
|
|
@@ -21735,7 +21820,8 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21735
21820
|
isOpen = _useDropdown.isOpen,
|
|
21736
21821
|
triggererRef = _useDropdown.triggererRef,
|
|
21737
21822
|
hasLabelOnLeft = _useDropdown.hasLabelOnLeft,
|
|
21738
|
-
dropdownTriggerer = _useDropdown.dropdownTriggerer
|
|
21823
|
+
dropdownTriggerer = _useDropdown.dropdownTriggerer,
|
|
21824
|
+
setIsOpen = _useDropdown.setIsOpen;
|
|
21739
21825
|
|
|
21740
21826
|
var _useTheme = useTheme(),
|
|
21741
21827
|
theme = _useTheme.theme;
|
|
@@ -21750,7 +21836,29 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21750
21836
|
width = _React$useState4[0],
|
|
21751
21837
|
setWidth = _React$useState4[1];
|
|
21752
21838
|
|
|
21839
|
+
var _useState = useState({}),
|
|
21840
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21841
|
+
dropdownPosition = _useState2[0],
|
|
21842
|
+
setDropdownPosition = _useState2[1];
|
|
21843
|
+
|
|
21753
21844
|
var isMenu = dropdownTriggerer !== 'SelectInput';
|
|
21845
|
+
|
|
21846
|
+
var _useFloating = useFloating({
|
|
21847
|
+
open: isOpen,
|
|
21848
|
+
onOpenChange: setIsOpen,
|
|
21849
|
+
strategy: 'absolute',
|
|
21850
|
+
placement: 'bottom-start',
|
|
21851
|
+
elements: {
|
|
21852
|
+
reference: triggererRef.current
|
|
21853
|
+
},
|
|
21854
|
+
middleware: [getDropdownOverflowMiddleware({
|
|
21855
|
+
isMenu: isMenu,
|
|
21856
|
+
triggererRef: triggererRef,
|
|
21857
|
+
setDropdownPosition: setDropdownPosition
|
|
21858
|
+
})]
|
|
21859
|
+
}),
|
|
21860
|
+
refs = _useFloating.refs;
|
|
21861
|
+
|
|
21754
21862
|
var fadeIn = /*#__PURE__*/css(["animation:", " ", " ", ";"], dropdownFadeIn, makeMotionTime(theme.motion.duration.quick), String(theme.motion.easing.entrance.revealing));
|
|
21755
21863
|
var fadeOut = /*#__PURE__*/css(["animation:", " ", " ", ";"], dropdownFadeOut, makeMotionTime(theme.motion.duration.quick), String(theme.motion.easing.entrance.revealing));
|
|
21756
21864
|
React__default.useEffect(function () {
|
|
@@ -21806,28 +21914,34 @@ var _DropdownOverlay = function _DropdownOverlay(_ref) {
|
|
|
21806
21914
|
opacity: isOpen ? 1 : 0
|
|
21807
21915
|
};
|
|
21808
21916
|
}, [isOpen]);
|
|
21809
|
-
return
|
|
21810
|
-
|
|
21811
|
-
|
|
21812
|
-
|
|
21813
|
-
,
|
|
21814
|
-
|
|
21815
|
-
,
|
|
21816
|
-
|
|
21817
|
-
|
|
21818
|
-
|
|
21819
|
-
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
|
|
21827
|
-
|
|
21828
|
-
|
|
21829
|
-
|
|
21830
|
-
|
|
21917
|
+
return (
|
|
21918
|
+
/*#__PURE__*/
|
|
21919
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21920
|
+
jsx(BaseBox, {
|
|
21921
|
+
position: "relative",
|
|
21922
|
+
ref: refs.setFloating,
|
|
21923
|
+
children: /*#__PURE__*/jsx(StyledDropdownOverlay, _objectSpread$Q(_objectSpread$Q({
|
|
21924
|
+
width: isMenu ? 'max-content' : width // In SelectInput, Overlay should always take width of Input
|
|
21925
|
+
,
|
|
21926
|
+
minWidth: isMenu ? '240px' : undefined // in SelectInput, we don't want to set maxWidth because it takes width according to the trigger
|
|
21927
|
+
,
|
|
21928
|
+
maxWidth: isMenu ? '400px' : undefined,
|
|
21929
|
+
left: dropdownPosition.left,
|
|
21930
|
+
right: dropdownPosition.right,
|
|
21931
|
+
bottom: dropdownPosition.bottom,
|
|
21932
|
+
style: styles,
|
|
21933
|
+
display: castWebType(display),
|
|
21934
|
+
position: "absolute",
|
|
21935
|
+
transition: isOpen ? fadeIn : fadeOut,
|
|
21936
|
+
onAnimationEnd: onAnimationEnd
|
|
21937
|
+
}, metaAttribute({
|
|
21938
|
+
name: MetaConstants.DropdownOverlay,
|
|
21939
|
+
testID: testID
|
|
21940
|
+
})), {}, {
|
|
21941
|
+
children: children
|
|
21942
|
+
}))
|
|
21943
|
+
})
|
|
21944
|
+
);
|
|
21831
21945
|
};
|
|
21832
21946
|
|
|
21833
21947
|
var DropdownOverlay = /*#__PURE__*/assignWithoutSideEffects(_DropdownOverlay, {
|