@razorpay/blade 9.5.2 → 9.5.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.
@@ -6998,6 +6998,12 @@ declare type BottomSheetProps = {
6998
6998
  * By default the initial focus will go to the close button
6999
6999
  */
7000
7000
  initialFocusRef?: React.MutableRefObject<any>;
7001
+ /**
7002
+ * Sets the z-index of the bottom sheet
7003
+ * Note: when using stacked bottom sheet make sure all the bottom sheets have the same zIndex
7004
+ * @default 100
7005
+ */
7006
+ zIndex?: number;
7001
7007
  };
7002
7008
  declare type BottomSheetHeaderProps = Pick<BaseHeaderProps, 'title' | 'subtitle' | 'leading' | 'showBackButton' | 'onBackButtonClick'> & {
7003
7009
  /**
@@ -7032,7 +7038,7 @@ declare const BottomSheetFooter: ({ children }: BaseFooterProps) => React__defau
7032
7038
 
7033
7039
  declare const BottomSheetBody: ({ children, padding, }: BottomSheetBodyProps) => React__default.ReactElement;
7034
7040
 
7035
- declare const BottomSheet: ({ isOpen, onDismiss, children, initialFocusRef, snapPoints, }: BottomSheetProps) => React__default.ReactElement;
7041
+ declare const BottomSheet: ({ isOpen, onDismiss, children, initialFocusRef, snapPoints, zIndex, }: BottomSheetProps) => React__default.ReactElement;
7036
7042
 
7037
7043
  declare type AccordionProps = {
7038
7044
  /**
@@ -21735,16 +21735,7 @@ var StyledBaseNativeButton = /*#__PURE__*/styled.button.withConfig({
21735
21735
  displayName: "StyledBaseInputweb__StyledBaseNativeButton",
21736
21736
  componentId: "hsusrk-1"
21737
21737
  })(function (props) {
21738
- return _objectSpread$M(_objectSpread$M(_objectSpread$M({}, getWebInputStyles(props)), getTextStyles({
21739
- size: 'medium',
21740
- variant: 'body',
21741
- type: props.value ? 'subtle' : 'placeholder',
21742
- weight: 'regular',
21743
- contrast: 'low',
21744
- theme: props.theme
21745
- })), {}, {
21746
- textAlign: props.textAlign
21747
- });
21738
+ return _objectSpread$M({}, getWebInputStyles(props));
21748
21739
  });
21749
21740
  var autoCompleteSuggestionTypeMap = {
21750
21741
  none: 'off',
@@ -21833,7 +21824,12 @@ var _StyledBaseInput = function _StyledBaseInput(_ref, ref) {
21833
21824
  }
21834
21825
  }, commonProps), props), accessibilityProps), {}, {
21835
21826
  value: props.value,
21836
- children: props.value ? props.value : props.placeholder
21827
+ children: /*#__PURE__*/jsx(Text, {
21828
+ type: props.value ? 'subtle' : 'placeholder',
21829
+ truncateAfterLines: 1,
21830
+ textAlign: props.textAlign,
21831
+ children: props.value ? props.value : props.placeholder
21832
+ })
21837
21833
  })) : /*#__PURE__*/jsx(StyledBaseNativeInput // @ts-expect-error: TS doesnt understand that this will always be `input`
21838
21834
  , _objectSpread$M(_objectSpread$M(_objectSpread$M({
21839
21835
  ref: ref,
@@ -28835,7 +28831,9 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28835
28831
  children = _ref2.children,
28836
28832
  initialFocusRef = _ref2.initialFocusRef,
28837
28833
  _ref2$snapPoints = _ref2.snapPoints,
28838
- snapPoints = _ref2$snapPoints === void 0 ? [0.35, 0.5, 0.85] : _ref2$snapPoints;
28834
+ snapPoints = _ref2$snapPoints === void 0 ? [0.35, 0.5, 0.85] : _ref2$snapPoints,
28835
+ _ref2$zIndex = _ref2.zIndex,
28836
+ zIndex = _ref2$zIndex === void 0 ? 100 : _ref2$zIndex;
28839
28837
 
28840
28838
  var _useTheme = useTheme(),
28841
28839
  theme = _useTheme.theme;
@@ -28889,7 +28887,6 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28889
28887
  var preventScrollingRef = React__default.useRef(true);
28890
28888
  var scrollRef = React__default.useRef(null);
28891
28889
  var grabHandleRef = React__default.useRef(null);
28892
- var originalFocusElement = React__default.useRef(null);
28893
28890
  var defaultInitialFocusRef = React__default.useRef(null);
28894
28891
  var initialSnapPoint = React__default.useRef(snapPoints[1]);
28895
28892
  var totalHeight = React__default.useMemo(function () {
@@ -28906,7 +28903,7 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28906
28903
 
28907
28904
  var currentStackIndex = getCurrentStackIndexById(id);
28908
28905
  var isOnTopOfStack = getTopOfTheStack() === id;
28909
- var zIndex = 100 - currentStackIndex;
28906
+ var bottomSheetZIndex = zIndex - currentStackIndex;
28910
28907
  var setPositionY = React__default.useCallback(function (value) {
28911
28908
  var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
28912
28909
  var maxValue = computeMaxContent({
@@ -28950,42 +28947,13 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28950
28947
  initialSnapPoint.current = snapPoints[0];
28951
28948
  }
28952
28949
  }, [dimensions.height, snapPoints, totalHeight]);
28953
- var returnFocus = React__default.useCallback(function () {
28954
- if (!originalFocusElement.current) return;
28955
- originalFocusElement.current.focus(); // After returning focus we will clear the original focus
28956
- // Because if sheet can be opened up via multiple triggers
28957
- // We want to ensure the focus returns back to the most recent triggerer
28958
-
28959
- originalFocusElement.current = null;
28960
- }, [originalFocusElement]);
28961
- var focusOnInitialRef = React__default.useCallback(function () {
28962
- if (!initialFocusRef) {
28963
- var _defaultInitialFocusR;
28964
-
28965
- // focus on close button
28966
- (_defaultInitialFocusR = defaultInitialFocusRef.current) === null || _defaultInitialFocusR === void 0 ? void 0 : _defaultInitialFocusR.focus();
28967
- } else {
28968
- var _initialFocusRef$curr;
28969
-
28970
- // focus on the initialRef passed by the user
28971
- (_initialFocusRef$curr = initialFocusRef.current) === null || _initialFocusRef$curr === void 0 ? void 0 : _initialFocusRef$curr.focus();
28972
- }
28973
- }, [initialFocusRef]);
28974
28950
  var handleOnOpen = React__default.useCallback(function () {
28975
- var _originalFocusElement;
28976
-
28977
28951
  setPositionY(dimensions.height * initialSnapPoint.current);
28978
- scrollLockRef.current.activate(); // initialize the original focused element
28979
- // On first render it will be the activeElement, eg: the button trigger or select input
28980
- // On Subsequent open operations it won't further update the original focus
28981
-
28982
- originalFocusElement.current = (_originalFocusElement = originalFocusElement.current) !== null && _originalFocusElement !== void 0 ? _originalFocusElement : document.activeElement;
28983
- focusOnInitialRef();
28984
- }, [dimensions.height, focusOnInitialRef, scrollLockRef, setPositionY]);
28952
+ scrollLockRef.current.activate();
28953
+ }, [dimensions.height, scrollLockRef, setPositionY]);
28985
28954
  var handleOnClose = React__default.useCallback(function () {
28986
28955
  setPositionY(0);
28987
- returnFocus();
28988
- }, [returnFocus, setPositionY]);
28956
+ }, [setPositionY]);
28989
28957
  var close = React__default.useCallback(function () {
28990
28958
  onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
28991
28959
  bottomSheetAndDropdownGlue === null || bottomSheetAndDropdownGlue === void 0 ? void 0 : bottomSheetAndDropdownGlue.onBottomSheetDismiss();
@@ -29203,49 +29171,66 @@ var _BottomSheet = function _BottomSheet(_ref2) {
29203
29171
 
29204
29172
  _setPositionY(0);
29205
29173
  }
29206
- }, [isMounted, scrollLockRef]); // We don't want to destroy the react tree when we are rendering inside Dropdown
29174
+ }, [isMounted, scrollLockRef]); // required by floating ui to handle focus
29175
+
29176
+ var _useFloating = useFloating({
29177
+ open: isMounted
29178
+ }),
29179
+ refs = _useFloating.refs,
29180
+ context = _useFloating.context; // We don't want to destroy the react tree when we are rendering inside Dropdown
29207
29181
  // Because if we bail out early then ActionList won't render,
29208
29182
  // and Dropdown manages it's state based on the rendered JSX of ActionList
29209
29183
  // If we don't render ActionList Dropdown state will reset each time we open/close BottomSheet
29210
29184
 
29185
+
29211
29186
  var isInsideDropdown = Boolean(bottomSheetAndDropdownGlue);
29212
29187
 
29213
29188
  if (!isMounted && !isInsideDropdown) {
29214
29189
  return /*#__PURE__*/jsx(Fragment, {});
29215
29190
  }
29216
29191
 
29217
- return /*#__PURE__*/jsxs(BottomSheetContext.Provider, {
29192
+ return /*#__PURE__*/jsx(BottomSheetContext.Provider, {
29218
29193
  value: contextValue,
29219
- children: [/*#__PURE__*/jsx(BottomSheetBackdrop, {
29220
- zIndex: zIndex
29221
- }), /*#__PURE__*/jsx(BottomSheetSurface, _objectSpread$c(_objectSpread$c(_objectSpread$c({}, metaAttribute({
29222
- name: MetaConstants.BottomSheet
29223
- })), makeAccessible({
29194
+ children: (isMounted || isInsideDropdown) && /*#__PURE__*/jsx(FloatingFocusManager, {
29195
+ returnFocus: true,
29196
+ initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : defaultInitialFocusRef,
29197
+ context: context,
29224
29198
  modal: true,
29225
- role: 'dialog'
29226
- })), {}, {
29227
- windowHeight: dimensions.height,
29228
- isDragging: isDragging,
29229
- style: {
29230
- opacity: isVisible ? 1 : 0,
29231
- pointerEvents: isVisible ? 'all' : 'none',
29232
- height: positionY,
29233
- bottom: 0,
29234
- top: 'auto',
29235
- zIndex: zIndex
29236
- },
29237
- children: /*#__PURE__*/jsxs(BaseBox, {
29238
- height: "100%",
29239
- display: "flex",
29240
- flexDirection: "column",
29241
- children: [/*#__PURE__*/jsx(BottomSheetGrabHandle, _objectSpread$c(_objectSpread$c({
29242
- ref: grabHandleRef,
29243
- isHeaderFloating: isHeaderFloating
29244
- }, metaAttribute({
29245
- name: ComponentIds.BottomSheetGrabHandle
29246
- })), bind())), children]
29199
+ children: /*#__PURE__*/jsxs(Fragment, {
29200
+ children: [/*#__PURE__*/jsx(BottomSheetBackdrop, {
29201
+ zIndex: bottomSheetZIndex
29202
+ }), /*#__PURE__*/jsx(BottomSheetSurface, _objectSpread$c(_objectSpread$c(_objectSpread$c({}, metaAttribute({
29203
+ name: MetaConstants.BottomSheet,
29204
+ testID: 'bottomsheet-surface'
29205
+ })), makeAccessible({
29206
+ modal: true,
29207
+ role: 'dialog'
29208
+ })), {}, {
29209
+ windowHeight: dimensions.height,
29210
+ isDragging: isDragging,
29211
+ style: {
29212
+ opacity: isVisible ? 1 : 0,
29213
+ pointerEvents: isVisible ? 'all' : 'none',
29214
+ height: positionY,
29215
+ bottom: 0,
29216
+ top: 'auto',
29217
+ zIndex: bottomSheetZIndex
29218
+ },
29219
+ ref: refs.setFloating,
29220
+ children: /*#__PURE__*/jsxs(BaseBox, {
29221
+ height: "100%",
29222
+ display: "flex",
29223
+ flexDirection: "column",
29224
+ children: [/*#__PURE__*/jsx(BottomSheetGrabHandle, _objectSpread$c(_objectSpread$c({
29225
+ ref: grabHandleRef,
29226
+ isHeaderFloating: isHeaderFloating
29227
+ }, metaAttribute({
29228
+ name: ComponentIds.BottomSheetGrabHandle
29229
+ })), bind())), children]
29230
+ })
29231
+ }))]
29247
29232
  })
29248
- }))]
29233
+ })
29249
29234
  });
29250
29235
  };
29251
29236