@razorpay/blade 5.1.5 → 5.2.1

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
 
@@ -7812,13 +7817,13 @@ var FormLabel = function FormLabel(_ref) {
7812
7817
  flexDirection: "row",
7813
7818
  alignItems: "center",
7814
7819
  flexWrap: "wrap",
7815
- children: [/*#__PURE__*/jsxs(Text, {
7820
+ children: [/*#__PURE__*/jsx(Text, {
7816
7821
  type: "subdued",
7817
7822
  variant: "body",
7818
7823
  size: isLabelLeftPositioned ? 'medium' : 'small',
7819
7824
  weight: "bold",
7820
- children: [children, computedAccessibilityNode]
7821
- }), necessityLabel]
7825
+ children: children
7826
+ }), computedAccessibilityNode, necessityLabel]
7822
7827
  }); // What harm can it do?
7823
7828
 
7824
7829
 
@@ -9256,7 +9261,7 @@ var getKeyboardAndAutocompleteProps = function getKeyboardAndAutocompleteProps(_
9256
9261
  keyboardReturnKeyType: 'go',
9257
9262
  autoCompleteSuggestionType: 'none'
9258
9263
  },
9259
- numeric: {
9264
+ number: {
9260
9265
  keyboardType: 'decimal',
9261
9266
  keyboardReturnKeyType: 'done',
9262
9267
  autoCompleteSuggestionType: 'none'
@@ -9272,7 +9277,7 @@ var getKeyboardAndAutocompleteProps = function getKeyboardAndAutocompleteProps(_
9272
9277
  keyboardAndAutocompleteProps.keyboardReturnKeyType = keyboardReturnKeyType !== null && keyboardReturnKeyType !== void 0 ? keyboardReturnKeyType : keyboardConfig.keyboardReturnKeyType;
9273
9278
  keyboardAndAutocompleteProps.autoCompleteSuggestionType = autoCompleteSuggestionType !== null && autoCompleteSuggestionType !== void 0 ? autoCompleteSuggestionType : keyboardConfig.autoCompleteSuggestionType;
9274
9279
 
9275
- if (type === 'numeric') {
9280
+ if (type === 'number') {
9276
9281
  /* the default keyboardType:numeric shows alphanumeric keyboard on iOS but number pad on android. making it type:text and keyboardType:decimal fixes this on all platforms.
9277
9282
  * source: https://css-tricks.com/everything-you-ever-wanted-to-know-about-keyboardType/#aa-decimal
9278
9283
  */