@razorpay/blade 10.14.0 → 10.14.2

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.
@@ -15267,7 +15267,7 @@ var StyledInput = /*#__PURE__*/styled.input.withConfig({
15267
15267
  hasError = _ref2.hasError,
15268
15268
  hoverTokens = _ref2.hoverTokens;
15269
15269
  return _objectSpread$1w(_objectSpread$1w({}, screenReaderStyles), {}, {
15270
- '&:focus + div': {
15270
+ '&:focus-visible + div': {
15271
15271
  // TODO: Replace with focus outline token
15272
15272
  outline: "1px solid ".concat(theme.colors.surface.background.level1.lowContrast),
15273
15273
  boxShadow: "0px 0px 0px 4px ".concat(theme.colors.brand.primary[400])
@@ -16226,7 +16226,7 @@ var StyledButton = /*#__PURE__*/styled.button.withConfig({
16226
16226
  '&:hover': {
16227
16227
  color: iconColorToken.hover[contrastToken]
16228
16228
  },
16229
- '&:focus': {
16229
+ '&:focus-visible': {
16230
16230
  outline: 'none',
16231
16231
  boxShadow: "0px 0px 0px 4px ".concat(theme.colors.brand.primary[400]),
16232
16232
  color: iconColorToken.focus[contrastToken]
@@ -17105,7 +17105,7 @@ var StyledLink$1 = /*#__PURE__*/styled.button.withConfig({
17105
17105
  width: 'max-content',
17106
17106
  borderRadius: makeBorderSize(props.theme.border.radius.small)
17107
17107
  },
17108
- '&:focus': {
17108
+ '&:focus-visible': {
17109
17109
  '.content-container': {
17110
17110
  boxShadow: "0px 0px 0px 4px ".concat(props.focusRingColor)
17111
17111
  }
@@ -18905,7 +18905,7 @@ var getIndicatorButtonStyles = function getIndicatorButtonStyles(_ref) {
18905
18905
  padding: makeSize(size[10]),
18906
18906
  paddingTop: makeSize(size[20])
18907
18907
  },
18908
- '&:focus': {
18908
+ '&:focus-visible': {
18909
18909
  // TODO: refactor to use focus ring token
18910
18910
  outline: 'none',
18911
18911
  boxShadow: "0px 0px 0px 4px ".concat(theme.colors.brand.primary[400])
@@ -19049,7 +19049,7 @@ var getNavigationButtonStyles = function getNavigationButtonStyles(props) {
19049
19049
  borderColor: borderColorToken.hover,
19050
19050
  backgroundColor: backgroundColor[variant].hover
19051
19051
  },
19052
- '&:focus': {
19052
+ '&:focus-visible': {
19053
19053
  // TODO: refactor to use focus ring token
19054
19054
  outline: 'none',
19055
19055
  boxShadow: "0px 0px 0px 4px ".concat(theme.colors.brand.primary[400]),
@@ -29495,6 +29495,7 @@ var _BottomSheet = function _BottomSheet(_ref2) {
29495
29495
  var scrollRef = React__default.useRef(null);
29496
29496
  var grabHandleRef = React__default.useRef(null);
29497
29497
  var defaultInitialFocusRef = React__default.useRef(null);
29498
+ var originalFocusElement = React__default.useRef(null);
29498
29499
  var initialSnapPoint = React__default.useRef(snapPoints[1]);
29499
29500
  var totalHeight = React__default.useMemo(function () {
29500
29501
  return grabHandleHeight + headerHeight + footerHeight + contentHeight;
@@ -29559,17 +29560,43 @@ var _BottomSheet = function _BottomSheet(_ref2) {
29559
29560
  }
29560
29561
  }
29561
29562
  }, [dimensions.height, snapPoints, totalHeight]);
29563
+ var returnFocus = React__default.useCallback(function () {
29564
+ if (!originalFocusElement.current) return;
29565
+ originalFocusElement.current.focus();
29566
+ // After returning focus we will clear the original focus
29567
+ // Because if sheet can be opened up via multiple triggers
29568
+ // We want to ensure the focus returns back to the most recent triggerer
29569
+ originalFocusElement.current = null;
29570
+ }, [originalFocusElement]);
29571
+ var focusOnInitialRef = React__default.useCallback(function () {
29572
+ if (!initialFocusRef) {
29573
+ var _defaultInitialFocusR;
29574
+ // focus on close button
29575
+ (_defaultInitialFocusR = defaultInitialFocusRef.current) === null || _defaultInitialFocusR === void 0 ? void 0 : _defaultInitialFocusR.focus();
29576
+ } else {
29577
+ var _initialFocusRef$curr;
29578
+ // focus on the initialRef passed by the user
29579
+ (_initialFocusRef$curr = initialFocusRef.current) === null || _initialFocusRef$curr === void 0 ? void 0 : _initialFocusRef$curr.focus();
29580
+ }
29581
+ }, [initialFocusRef]);
29562
29582
  var handleOnOpen = React__default.useCallback(function () {
29583
+ var _originalFocusElement;
29563
29584
  setPositionY(dimensions.height * initialSnapPoint.current);
29564
29585
  scrollLockRef.current.activate();
29565
- }, [dimensions.height, scrollLockRef, setPositionY]);
29586
+ // initialize the original focused element
29587
+ // On first render it will be the activeElement, eg: the button trigger or select input
29588
+ // On Subsequent open operations it won't further update the original focus
29589
+ originalFocusElement.current = (_originalFocusElement = originalFocusElement.current) !== null && _originalFocusElement !== void 0 ? _originalFocusElement : document.activeElement;
29590
+ focusOnInitialRef();
29591
+ }, [dimensions.height, focusOnInitialRef, scrollLockRef, setPositionY]);
29566
29592
  var handleOnClose = React__default.useCallback(function () {
29567
29593
  setPositionY(0);
29568
29594
  }, [setPositionY]);
29569
29595
  var close = React__default.useCallback(function () {
29570
29596
  onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
29571
29597
  bottomSheetAndDropdownGlue === null || bottomSheetAndDropdownGlue === void 0 ? void 0 : bottomSheetAndDropdownGlue.onBottomSheetDismiss();
29572
- }, [bottomSheetAndDropdownGlue, onDismiss]);
29598
+ returnFocus();
29599
+ }, [bottomSheetAndDropdownGlue, onDismiss, returnFocus]);
29573
29600
 
29574
29601
  // sync controlled state to our actions
29575
29602
  React__default.useEffect(function () {
@@ -29776,13 +29803,6 @@ var _BottomSheet = function _BottomSheet(_ref2) {
29776
29803
  }
29777
29804
  }, [isMounted, scrollLockRef]);
29778
29805
 
29779
- // required by floating ui to handle focus
29780
- var _useFloating = useFloating({
29781
- open: isMounted
29782
- }),
29783
- refs = _useFloating.refs,
29784
- context = _useFloating.context;
29785
-
29786
29806
  // We don't want to destroy the react tree when we are rendering inside Dropdown
29787
29807
  // Because if we bail out early then ActionList won't render,
29788
29808
  // and Dropdown manages it's state based on the rendered JSX of ActionList
@@ -29791,48 +29811,39 @@ var _BottomSheet = function _BottomSheet(_ref2) {
29791
29811
  if (!isMounted && !isInsideDropdown) {
29792
29812
  return /*#__PURE__*/jsx(Fragment, {});
29793
29813
  }
29794
- return /*#__PURE__*/jsx(BottomSheetContext.Provider, {
29814
+ return /*#__PURE__*/jsxs(BottomSheetContext.Provider, {
29795
29815
  value: contextValue,
29796
- children: (isMounted || isInsideDropdown) && /*#__PURE__*/jsx(FloatingFocusManager, {
29797
- returnFocus: true,
29798
- initialFocus: initialFocusRef !== null && initialFocusRef !== void 0 ? initialFocusRef : defaultInitialFocusRef,
29799
- context: context,
29816
+ children: [/*#__PURE__*/jsx(BottomSheetBackdrop, {
29817
+ zIndex: bottomSheetZIndex
29818
+ }), /*#__PURE__*/jsx(BottomSheetSurface, _objectSpread$f(_objectSpread$f(_objectSpread$f({}, metaAttribute({
29819
+ name: MetaConstants.BottomSheet,
29820
+ testID: 'bottomsheet-surface'
29821
+ })), makeAccessible({
29800
29822
  modal: true,
29801
- children: /*#__PURE__*/jsxs(Fragment, {
29802
- children: [/*#__PURE__*/jsx(BottomSheetBackdrop, {
29803
- zIndex: bottomSheetZIndex
29804
- }), /*#__PURE__*/jsx(BottomSheetSurface, _objectSpread$f(_objectSpread$f(_objectSpread$f({}, metaAttribute({
29805
- name: MetaConstants.BottomSheet,
29806
- testID: 'bottomsheet-surface'
29807
- })), makeAccessible({
29808
- modal: true,
29809
- role: 'dialog'
29810
- })), {}, {
29811
- windowHeight: dimensions.height,
29812
- isDragging: isDragging,
29813
- style: {
29814
- opacity: isVisible ? 1 : 0,
29815
- pointerEvents: isVisible ? 'all' : 'none',
29816
- height: positionY,
29817
- bottom: 0,
29818
- top: 'auto',
29819
- zIndex: bottomSheetZIndex
29820
- },
29821
- ref: refs.setFloating,
29822
- children: /*#__PURE__*/jsxs(BaseBox, {
29823
- height: "100%",
29824
- display: "flex",
29825
- flexDirection: "column",
29826
- children: [/*#__PURE__*/jsx(BottomSheetGrabHandle, _objectSpread$f(_objectSpread$f({
29827
- ref: grabHandleRef,
29828
- isHeaderFloating: isHeaderFloating
29829
- }, metaAttribute({
29830
- name: ComponentIds.BottomSheetGrabHandle
29831
- })), bind())), children]
29832
- })
29833
- }))]
29823
+ role: 'dialog'
29824
+ })), {}, {
29825
+ windowHeight: dimensions.height,
29826
+ isDragging: isDragging,
29827
+ style: {
29828
+ opacity: isVisible ? 1 : 0,
29829
+ pointerEvents: isVisible ? 'all' : 'none',
29830
+ height: positionY,
29831
+ bottom: 0,
29832
+ top: 'auto',
29833
+ zIndex: bottomSheetZIndex
29834
+ },
29835
+ children: /*#__PURE__*/jsxs(BaseBox, {
29836
+ height: "100%",
29837
+ display: "flex",
29838
+ flexDirection: "column",
29839
+ children: [/*#__PURE__*/jsx(BottomSheetGrabHandle, _objectSpread$f(_objectSpread$f({
29840
+ ref: grabHandleRef,
29841
+ isHeaderFloating: isHeaderFloating
29842
+ }, metaAttribute({
29843
+ name: ComponentIds.BottomSheetGrabHandle
29844
+ })), bind())), children]
29834
29845
  })
29835
- })
29846
+ }))]
29836
29847
  });
29837
29848
  };
29838
29849
  var BottomSheet = /*#__PURE__*/assignWithoutSideEffects(_BottomSheet, {
@@ -29984,7 +29995,7 @@ var StyledAccordionButton = /*#__PURE__*/styled.button.withConfig({
29984
29995
  width: '100%',
29985
29996
  border: 'none',
29986
29997
  textAlign: 'left',
29987
- '&:hover, &:focus': {
29998
+ '&:hover, &:focus-visible': {
29988
29999
  backgroundColor: getBackgroundColor({
29989
30000
  theme: theme,
29990
30001
  isExpanded: isExpanded,
@@ -29994,7 +30005,7 @@ var StyledAccordionButton = /*#__PURE__*/styled.button.withConfig({
29994
30005
  '&:hover': {
29995
30006
  color: theme.colors.surface.action.icon.hover.lowContrast
29996
30007
  },
29997
- '&:focus': {
30008
+ '&:focus-visible': {
29998
30009
  outline: 'none',
29999
30010
  boxShadow: "0px 0px 0px 4px ".concat(theme.colors.brand.primary[400]),
30000
30011
  // only need border radius on the focus ring
@@ -31166,7 +31177,7 @@ var StyledPopoverInteractiveWrapper = /*#__PURE__*/styled.button.withConfig({
31166
31177
  appearance: 'none',
31167
31178
  cursor: 'pointer',
31168
31179
  lineHeight: 0,
31169
- '&:focus': {
31180
+ '&:focus-visible': {
31170
31181
  // TODO: refactor to use focus ring token
31171
31182
  outline: 'none',
31172
31183
  boxShadow: "0px 0px 0px 4px ".concat(props.theme.colors.brand.primary[400])