@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.
@@ -21355,16 +21355,7 @@ var StyledBaseNativeButton = /*#__PURE__*/styled.button.withConfig({
21355
21355
  displayName: "StyledBaseInputweb__StyledBaseNativeButton",
21356
21356
  componentId: "hsusrk-1"
21357
21357
  })(function (props) {
21358
- return _objectSpread$M(_objectSpread$M(_objectSpread$M({}, getWebInputStyles(props)), getTextStyles({
21359
- size: 'medium',
21360
- variant: 'body',
21361
- type: props.value ? 'subtle' : 'placeholder',
21362
- weight: 'regular',
21363
- contrast: 'low',
21364
- theme: props.theme
21365
- })), {}, {
21366
- textAlign: props.textAlign
21367
- });
21358
+ return _objectSpread$M({}, getWebInputStyles(props));
21368
21359
  });
21369
21360
  var autoCompleteSuggestionTypeMap = {
21370
21361
  none: 'off',
@@ -21453,7 +21444,12 @@ var _StyledBaseInput = function _StyledBaseInput(_ref, ref) {
21453
21444
  }
21454
21445
  }, commonProps), props), accessibilityProps), {}, {
21455
21446
  value: props.value,
21456
- children: props.value ? props.value : props.placeholder
21447
+ children: /*#__PURE__*/jsx(Text, {
21448
+ type: props.value ? 'subtle' : 'placeholder',
21449
+ truncateAfterLines: 1,
21450
+ textAlign: props.textAlign,
21451
+ children: props.value ? props.value : props.placeholder
21452
+ })
21457
21453
  })) : /*#__PURE__*/jsx(StyledBaseNativeInput // @ts-expect-error: TS doesnt understand that this will always be `input`
21458
21454
  , _objectSpread$M(_objectSpread$M(_objectSpread$M({
21459
21455
  ref: ref,
@@ -28357,7 +28353,9 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28357
28353
  children = _ref2.children,
28358
28354
  initialFocusRef = _ref2.initialFocusRef,
28359
28355
  _ref2$snapPoints = _ref2.snapPoints,
28360
- snapPoints = _ref2$snapPoints === void 0 ? [0.35, 0.5, 0.85] : _ref2$snapPoints;
28356
+ snapPoints = _ref2$snapPoints === void 0 ? [0.35, 0.5, 0.85] : _ref2$snapPoints,
28357
+ _ref2$zIndex = _ref2.zIndex,
28358
+ zIndex = _ref2$zIndex === void 0 ? 100 : _ref2$zIndex;
28361
28359
 
28362
28360
  var _useTheme = useTheme(),
28363
28361
  theme = _useTheme.theme;
@@ -28411,7 +28409,6 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28411
28409
  var preventScrollingRef = React__default.useRef(true);
28412
28410
  var scrollRef = React__default.useRef(null);
28413
28411
  var grabHandleRef = React__default.useRef(null);
28414
- var originalFocusElement = React__default.useRef(null);
28415
28412
  var defaultInitialFocusRef = React__default.useRef(null);
28416
28413
  var initialSnapPoint = React__default.useRef(snapPoints[1]);
28417
28414
  var totalHeight = React__default.useMemo(function () {
@@ -28428,7 +28425,7 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28428
28425
 
28429
28426
  var currentStackIndex = getCurrentStackIndexById(id);
28430
28427
  var isOnTopOfStack = getTopOfTheStack() === id;
28431
- var zIndex = 100 - currentStackIndex;
28428
+ var bottomSheetZIndex = zIndex - currentStackIndex;
28432
28429
  var setPositionY = React__default.useCallback(function (value) {
28433
28430
  var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
28434
28431
  var maxValue = computeMaxContent({
@@ -28472,42 +28469,13 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28472
28469
  initialSnapPoint.current = snapPoints[0];
28473
28470
  }
28474
28471
  }, [dimensions.height, snapPoints, totalHeight]);
28475
- var returnFocus = React__default.useCallback(function () {
28476
- if (!originalFocusElement.current) return;
28477
- originalFocusElement.current.focus(); // After returning focus we will clear the original focus
28478
- // Because if sheet can be opened up via multiple triggers
28479
- // We want to ensure the focus returns back to the most recent triggerer
28480
-
28481
- originalFocusElement.current = null;
28482
- }, [originalFocusElement]);
28483
- var focusOnInitialRef = React__default.useCallback(function () {
28484
- if (!initialFocusRef) {
28485
- var _defaultInitialFocusR;
28486
-
28487
- // focus on close button
28488
- (_defaultInitialFocusR = defaultInitialFocusRef.current) === null || _defaultInitialFocusR === void 0 ? void 0 : _defaultInitialFocusR.focus();
28489
- } else {
28490
- var _initialFocusRef$curr;
28491
-
28492
- // focus on the initialRef passed by the user
28493
- (_initialFocusRef$curr = initialFocusRef.current) === null || _initialFocusRef$curr === void 0 ? void 0 : _initialFocusRef$curr.focus();
28494
- }
28495
- }, [initialFocusRef]);
28496
28472
  var handleOnOpen = React__default.useCallback(function () {
28497
- var _originalFocusElement;
28498
-
28499
28473
  setPositionY(dimensions.height * initialSnapPoint.current);
28500
- scrollLockRef.current.activate(); // initialize the original focused element
28501
- // On first render it will be the activeElement, eg: the button trigger or select input
28502
- // On Subsequent open operations it won't further update the original focus
28503
-
28504
- originalFocusElement.current = (_originalFocusElement = originalFocusElement.current) !== null && _originalFocusElement !== void 0 ? _originalFocusElement : document.activeElement;
28505
- focusOnInitialRef();
28506
- }, [dimensions.height, focusOnInitialRef, scrollLockRef, setPositionY]);
28474
+ scrollLockRef.current.activate();
28475
+ }, [dimensions.height, scrollLockRef, setPositionY]);
28507
28476
  var handleOnClose = React__default.useCallback(function () {
28508
28477
  setPositionY(0);
28509
- returnFocus();
28510
- }, [returnFocus, setPositionY]);
28478
+ }, [setPositionY]);
28511
28479
  var close = React__default.useCallback(function () {
28512
28480
  onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
28513
28481
  bottomSheetAndDropdownGlue === null || bottomSheetAndDropdownGlue === void 0 ? void 0 : bottomSheetAndDropdownGlue.onBottomSheetDismiss();
@@ -28725,49 +28693,66 @@ var _BottomSheet = function _BottomSheet(_ref2) {
28725
28693
 
28726
28694
  _setPositionY(0);
28727
28695
  }
28728
- }, [isMounted, scrollLockRef]); // We don't want to destroy the react tree when we are rendering inside Dropdown
28696
+ }, [isMounted, scrollLockRef]); // required by floating ui to handle focus
28697
+
28698
+ var _useFloating = useFloating({
28699
+ open: isMounted
28700
+ }),
28701
+ refs = _useFloating.refs,
28702
+ context = _useFloating.context; // We don't want to destroy the react tree when we are rendering inside Dropdown
28729
28703
  // Because if we bail out early then ActionList won't render,
28730
28704
  // and Dropdown manages it's state based on the rendered JSX of ActionList
28731
28705
  // If we don't render ActionList Dropdown state will reset each time we open/close BottomSheet
28732
28706
 
28707
+
28733
28708
  var isInsideDropdown = Boolean(bottomSheetAndDropdownGlue);
28734
28709
 
28735
28710
  if (!isMounted && !isInsideDropdown) {
28736
28711
  return /*#__PURE__*/jsx(Fragment, {});
28737
28712
  }
28738
28713
 
28739
- return /*#__PURE__*/jsxs(BottomSheetContext.Provider, {
28714
+ return /*#__PURE__*/jsx(BottomSheetContext.Provider, {
28740
28715
  value: contextValue,
28741
- children: [/*#__PURE__*/jsx(BottomSheetBackdrop, {
28742
- zIndex: zIndex
28743
- }), /*#__PURE__*/jsx(BottomSheetSurface, _objectSpread$c(_objectSpread$c(_objectSpread$c({}, metaAttribute({
28744
- name: MetaConstants.BottomSheet
28745
- })), makeAccessible({
28716
+ children: (isMounted || isInsideDropdown) && /*#__PURE__*/jsx(FloatingFocusManager, {
28717
+ returnFocus: true,
28718
+ initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : defaultInitialFocusRef,
28719
+ context: context,
28746
28720
  modal: true,
28747
- role: 'dialog'
28748
- })), {}, {
28749
- windowHeight: dimensions.height,
28750
- isDragging: isDragging,
28751
- style: {
28752
- opacity: isVisible ? 1 : 0,
28753
- pointerEvents: isVisible ? 'all' : 'none',
28754
- height: positionY,
28755
- bottom: 0,
28756
- top: 'auto',
28757
- zIndex: zIndex
28758
- },
28759
- children: /*#__PURE__*/jsxs(BaseBox, {
28760
- height: "100%",
28761
- display: "flex",
28762
- flexDirection: "column",
28763
- children: [/*#__PURE__*/jsx(BottomSheetGrabHandle, _objectSpread$c(_objectSpread$c({
28764
- ref: grabHandleRef,
28765
- isHeaderFloating: isHeaderFloating
28766
- }, metaAttribute({
28767
- name: ComponentIds.BottomSheetGrabHandle
28768
- })), bind())), children]
28721
+ children: /*#__PURE__*/jsxs(Fragment, {
28722
+ children: [/*#__PURE__*/jsx(BottomSheetBackdrop, {
28723
+ zIndex: bottomSheetZIndex
28724
+ }), /*#__PURE__*/jsx(BottomSheetSurface, _objectSpread$c(_objectSpread$c(_objectSpread$c({}, metaAttribute({
28725
+ name: MetaConstants.BottomSheet,
28726
+ testID: 'bottomsheet-surface'
28727
+ })), makeAccessible({
28728
+ modal: true,
28729
+ role: 'dialog'
28730
+ })), {}, {
28731
+ windowHeight: dimensions.height,
28732
+ isDragging: isDragging,
28733
+ style: {
28734
+ opacity: isVisible ? 1 : 0,
28735
+ pointerEvents: isVisible ? 'all' : 'none',
28736
+ height: positionY,
28737
+ bottom: 0,
28738
+ top: 'auto',
28739
+ zIndex: bottomSheetZIndex
28740
+ },
28741
+ ref: refs.setFloating,
28742
+ children: /*#__PURE__*/jsxs(BaseBox, {
28743
+ height: "100%",
28744
+ display: "flex",
28745
+ flexDirection: "column",
28746
+ children: [/*#__PURE__*/jsx(BottomSheetGrabHandle, _objectSpread$c(_objectSpread$c({
28747
+ ref: grabHandleRef,
28748
+ isHeaderFloating: isHeaderFloating
28749
+ }, metaAttribute({
28750
+ name: ComponentIds.BottomSheetGrabHandle
28751
+ })), bind())), children]
28752
+ })
28753
+ }))]
28769
28754
  })
28770
- }))]
28755
+ })
28771
28756
  });
28772
28757
  };
28773
28758