@razorpay/blade 5.1.4 → 5.2.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.
@@ -3361,7 +3361,7 @@ var useBreakpoint = function useBreakpoint(_ref) {
3361
3361
  var _window;
3362
3362
 
3363
3363
  var breakpoints = _ref.breakpoints;
3364
- var supportsMatchMedia = typeof document !== 'undefined' && typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.matchMedia) === 'function';
3364
+ var supportsMatchMedia = typeof document !== 'undefined' && typeof window !== 'undefined' && typeof ((_window = window) === null || _window === void 0 ? void 0 : _window.matchMedia) === 'function';
3365
3365
  var breakpointsTokenAndQueryCollection = useMemo(function () {
3366
3366
  return supportsMatchMedia ? Object.entries(breakpoints).map(function (_ref2, index, breakpointsArray) {
3367
3367
  var _ref3 = _slicedToArray(_ref2, 2),
@@ -3635,22 +3635,19 @@ var getCommonStyles = function getCommonStyles(props) {
3635
3635
  contrastType = props.contrastType,
3636
3636
  intent = props.intent,
3637
3637
  isFullWidth = props.isFullWidth,
3638
- isBorderless = props.isBorderless; // a borderless alert is automatically set to full width
3639
-
3640
- var _isFullWidth = isFullWidth || isBorderless;
3641
-
3638
+ isDesktop = props.isDesktop;
3642
3639
  var feedbackColors = theme.colors.feedback;
3643
3640
  return {
3644
3641
  background: feedbackColors.background[intent][contrastType],
3645
- padding: isBorderless ? "".concat(makeSpace(theme.spacing[4]), " ").concat(makeSpace(theme.spacing[5])) : "".concat(makeSpace(theme.spacing[3]), " ").concat(makeSpace(theme.spacing[3]), " ").concat(makeSpace(theme.spacing[4]), " ").concat(makeSpace(theme.spacing[3])),
3646
- borderRadius: makeBorderSize(isBorderless ? theme.border.radius.none : theme.border.radius.medium),
3642
+ padding: isFullWidth ? "".concat(makeSpace(theme.spacing[4]), " ").concat(makeSpace(theme.spacing[5])) : "".concat(makeSpace(theme.spacing[3]), " ").concat(makeSpace(theme.spacing[3]), " ").concat(makeSpace(theme.spacing[4]), " ").concat(makeSpace(theme.spacing[3])),
3643
+ borderRadius: makeBorderSize(isFullWidth ? theme.border.radius.none : theme.border.radius.medium),
3647
3644
  borderColor: feedbackColors.border[intent][contrastType],
3648
- borderWidth: makeBorderSize(isBorderless ? theme.border.width.none : theme.border.width.thin),
3645
+ borderWidth: makeBorderSize(isFullWidth ? theme.border.width.none : theme.border.width.thin),
3649
3646
  borderStyle: 'solid',
3650
3647
  display: 'flex',
3651
3648
  flexDirection: 'row',
3652
- maxWidth: _isFullWidth ? 'auto' : makeSize(MAX_WIDTH),
3653
- alignItems: 'flex-start'
3649
+ maxWidth: isFullWidth ? 'auto' : makeSize(MAX_WIDTH),
3650
+ alignItems: isFullWidth && isDesktop ? 'center' : 'flex-start'
3654
3651
  };
3655
3652
  };
3656
3653
 
@@ -6655,7 +6652,6 @@ function ownKeys$n(object, enumerableOnly) { var keys = Object.keys(object); if
6655
6652
  function _objectSpread$n(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$n(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$n(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6656
6653
  var isReactNative$3 = getPlatformType() === 'react-native'; // Need extra wrappers on React Native only for alignment
6657
6654
 
6658
- var SecondaryActionWrapper = isReactNative$3 ? Box : Fragment;
6659
6655
  var CloseButtonWrapper = isReactNative$3 ? Box : Fragment;
6660
6656
  var intentIconMap = {
6661
6657
  positive: CheckCircleIcon,
@@ -6677,8 +6673,6 @@ var Alert = function Alert(_ref) {
6677
6673
  isFullWidth = _ref$isFullWidth === void 0 ? false : _ref$isFullWidth,
6678
6674
  _ref$intent = _ref.intent,
6679
6675
  intent = _ref$intent === void 0 ? 'neutral' : _ref$intent,
6680
- _ref$isBorderless = _ref.isBorderless,
6681
- isBorderless = _ref$isBorderless === void 0 ? false : _ref$isBorderless,
6682
6676
  actions = _ref.actions;
6683
6677
 
6684
6678
  if (!(actions !== null && actions !== void 0 && actions.primary) && actions !== null && actions !== void 0 && actions.secondary) {
@@ -6693,7 +6687,8 @@ var Alert = function Alert(_ref) {
6693
6687
  }),
6694
6688
  matchedDeviceType = _useBreakpoint.matchedDeviceType;
6695
6689
 
6696
- var isMobile = matchedDeviceType === 'mobile';
6690
+ var isDesktop = matchedDeviceType === 'desktop';
6691
+ var isMobile = !isDesktop;
6697
6692
 
6698
6693
  var _useState = useState(true),
6699
6694
  _useState2 = _slicedToArray(_useState, 2),
@@ -6701,25 +6696,27 @@ var Alert = function Alert(_ref) {
6701
6696
  setIsVisible = _useState2[1];
6702
6697
 
6703
6698
  var contrastType = "".concat(contrast, "Contrast");
6704
- var iconSize = isBorderless ? 'large' : 'medium';
6705
- var textSize = isBorderless ? 'medium' : 'small';
6699
+ var iconSize = isFullWidth ? 'large' : 'medium';
6700
+ var textSize = isFullWidth ? 'medium' : 'small';
6706
6701
  var Icon = intentIconMap[intent];
6707
6702
  var iconOffset = 'spacing.1'; // certain special cases below needs special care for near perfect alignment
6708
6703
 
6709
6704
  if (isReactNative$3) {
6710
- if (isBorderless && !title) {
6705
+ if (isFullWidth && !title) {
6711
6706
  iconOffset = 'spacing.1';
6712
- } else if (!isBorderless && !title) {
6707
+ } else if (!isFullWidth && !title) {
6713
6708
  iconOffset = 'spacing.0';
6714
- } else if (!isBorderless && title) {
6709
+ } else if (!isFullWidth && title) {
6715
6710
  iconOffset = 'spacing.2';
6716
6711
  }
6717
6712
  } else if (isMobile) {
6718
- if (!isBorderless && title) {
6713
+ if (!isFullWidth && title) {
6719
6714
  iconOffset = 'spacing.2';
6720
- } else if (isBorderless && !title) {
6715
+ } else if (isFullWidth && !title) {
6721
6716
  iconOffset = 'spacing.2';
6722
6717
  }
6718
+ } else if (isFullWidth) {
6719
+ iconOffset = 'spacing.0';
6723
6720
  }
6724
6721
 
6725
6722
  var icon = /*#__PURE__*/jsx(Box, {
@@ -6733,7 +6730,7 @@ var Alert = function Alert(_ref) {
6733
6730
 
6734
6731
  var _title = title ? /*#__PURE__*/jsx(Box, {
6735
6732
  marginBottom: "spacing.2",
6736
- children: isBorderless ? /*#__PURE__*/jsx(Heading, {
6733
+ children: isFullWidth ? /*#__PURE__*/jsx(Heading, {
6737
6734
  size: "small",
6738
6735
  contrast: contrast,
6739
6736
  children: title
@@ -6780,7 +6777,9 @@ var Alert = function Alert(_ref) {
6780
6777
  secondaryActionParams.rel = actions.secondary.rel;
6781
6778
  }
6782
6779
 
6783
- var secondaryAction = actions !== null && actions !== void 0 && actions.secondary ? /*#__PURE__*/jsx(SecondaryActionWrapper, {
6780
+ var secondaryAction = actions !== null && actions !== void 0 && actions.secondary ? /*#__PURE__*/jsx(Box, {
6781
+ marginRight: "spacing.4",
6782
+ display: isReactNative$3 ? 'flex' : 'inline-flex',
6784
6783
  children: /*#__PURE__*/jsx(BaseLink, _objectSpread$n(_objectSpread$n({
6785
6784
  size: textSize,
6786
6785
  contrast: contrast,
@@ -6788,9 +6787,15 @@ var Alert = function Alert(_ref) {
6788
6787
  }, secondaryActionParams), {}, {
6789
6788
  children: actions.secondary.text
6790
6789
  }))
6791
- }) : null;
6790
+ }) : null; // For certain cases we wish to render actions inline with text content
6792
6791
 
6793
- var _actions = primaryAction || secondaryAction ? /*#__PURE__*/jsxs(Box, {
6792
+ var showActionsHorizontal = isFullWidth && isDesktop;
6793
+ var actionsHorizontal = showActionsHorizontal && (primaryAction || secondaryAction) ? /*#__PURE__*/jsxs(Box, {
6794
+ flexDirection: "row",
6795
+ alignItems: "center",
6796
+ children: [primaryAction, secondaryAction]
6797
+ }) : null;
6798
+ var actionsVertical = !showActionsHorizontal && (primaryAction || secondaryAction) ? /*#__PURE__*/jsxs(Box, {
6794
6799
  marginTop: "spacing.4",
6795
6800
  flexDirection: "row",
6796
6801
  alignItems: "center",
@@ -6829,14 +6834,14 @@ var Alert = function Alert(_ref) {
6829
6834
  intent: intent,
6830
6835
  contrastType: contrastType,
6831
6836
  isFullWidth: isFullWidth,
6832
- isBorderless: isBorderless
6837
+ isDesktop: isDesktop
6833
6838
  }, a11yProps), metaAttribute(MetaConstants.Component, MetaConstants.Alert)), {}, {
6834
6839
  children: [icon, /*#__PURE__*/jsxs(Box, {
6835
6840
  flex: 1,
6836
- paddingLeft: isBorderless ? 'spacing.4' : 'spacing.3',
6837
- paddingRight: "spacing.2",
6838
- children: [_title, _description, _actions]
6839
- }), closeButton]
6841
+ paddingLeft: isFullWidth ? 'spacing.4' : 'spacing.3',
6842
+ paddingRight: showActionsHorizontal ? 'spacing.4' : 'spacing.2',
6843
+ children: [_title, _description, actionsVertical]
6844
+ }), actionsHorizontal, closeButton]
6840
6845
  }));
6841
6846
  };
6842
6847
 
@@ -9704,7 +9709,8 @@ var OTPInput = function OTPInput(_ref) {
9704
9709
  placeholder = _ref.placeholder,
9705
9710
  successText = _ref.successText,
9706
9711
  validationState = _ref.validationState,
9707
- inputValue = _ref.value;
9712
+ inputValue = _ref.value,
9713
+ isMasked = _ref.isMasked;
9708
9714
  var inputRefs = [];
9709
9715
 
9710
9716
  var _useState = useState(otpToArray(inputValue)),
@@ -9924,7 +9930,8 @@ var OTPInput = function OTPInput(_ref) {
9924
9930
  successText: successText,
9925
9931
  errorText: errorText,
9926
9932
  helpText: helpText,
9927
- hideFormHint: true
9933
+ hideFormHint: true,
9934
+ type: isMasked ? 'password' : undefined
9928
9935
  })
9929
9936
  }, "".concat(inputId, "-").concat(index)));
9930
9937
  };