@razorpay/blade 5.4.2 → 5.4.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.
@@ -7046,6 +7046,20 @@ var useVerifyInsideCard = function useVerifyInsideCard(componentName) {
7046
7046
 
7047
7047
  return true;
7048
7048
  };
7049
+ /**
7050
+ * Verify if the passed childrens are only of allowedComponents list
7051
+ */
7052
+
7053
+
7054
+ var useVerifyAllowedComponents = function useVerifyAllowedComponents(children, componentName, allowedComponents) {
7055
+ React__default.Children.forEach(children, function (child) {
7056
+ var isValidChild = child && allowedComponents.includes(getComponentId(child));
7057
+
7058
+ if (!isValidChild) {
7059
+ throw new Error("[Blade Card]: Only one of `".concat(allowedComponents.join(', '), "` component is accepted as ").concat(componentName, " children"));
7060
+ }
7061
+ });
7062
+ };
7049
7063
 
7050
7064
  var CardProvider = function CardProvider(_ref) {
7051
7065
  var children = _ref.children;
@@ -7058,11 +7072,27 @@ var CardProvider = function CardProvider(_ref) {
7058
7072
  function ownKeys$o(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7059
7073
 
7060
7074
  function _objectSpread$o(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$o(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$o(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7075
+ var ComponentIds = {
7076
+ CardHeader: 'CardHeader',
7077
+ CardHeaderTrailing: 'CardHeaderTrailing',
7078
+ CardHeaderLeading: 'CardHeaderLeading',
7079
+ CardFooter: 'CardFooter',
7080
+ CardFooterTrailing: 'CardFooterTrailing',
7081
+ CardFooterLeading: 'CardFooterLeading',
7082
+ CardBody: 'CardBody',
7083
+ CardHeaderIcon: 'CardHeaderIcon',
7084
+ CardHeaderCounter: 'CardHeaderCounter',
7085
+ CardHeaderBadge: 'CardHeaderBadge',
7086
+ CardHeaderText: 'CardHeaderText',
7087
+ CardHeaderLink: 'CardHeaderLink',
7088
+ CardHeaderIconButton: 'CardHeaderIconButton'
7089
+ };
7061
7090
 
7062
7091
  var Card = function Card(_ref) {
7063
7092
  var children = _ref.children,
7064
7093
  _ref$surfaceLevel = _ref.surfaceLevel,
7065
7094
  surfaceLevel = _ref$surfaceLevel === void 0 ? 3 : _ref$surfaceLevel;
7095
+ useVerifyAllowedComponents(children, 'Card', [ComponentIds.CardHeader, ComponentIds.CardBody, ComponentIds.CardFooter]);
7066
7096
  return /*#__PURE__*/jsx(CardProvider, {
7067
7097
  children: /*#__PURE__*/jsx(CardSurface, _objectSpread$o(_objectSpread$o({}, metaAttribute(MetaConstants.Component, MetaConstants.Card)), {}, {
7068
7098
  paddingLeft: "spacing.7",
@@ -7084,6 +7114,8 @@ var CardBody = function CardBody(_ref2) {
7084
7114
  }));
7085
7115
  };
7086
7116
 
7117
+ CardBody.componentId = ComponentIds.CardBody;
7118
+
7087
7119
  function ownKeys$n(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7088
7120
 
7089
7121
  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; }
@@ -7301,14 +7333,6 @@ var Counter = function Counter(_ref2) {
7301
7333
  function ownKeys$j(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7302
7334
 
7303
7335
  function _objectSpread$j(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$j(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$j(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7304
- var ComponentIds = {
7305
- CardHeaderIcon: 'CardHeaderIcon',
7306
- CardHeaderCounter: 'CardHeaderCounter',
7307
- CardHeaderBadge: 'CardHeaderBadge',
7308
- CardHeaderText: 'CardHeaderText',
7309
- CardHeaderLink: 'CardHeaderLink',
7310
- CardHeaderIconButton: 'CardHeaderIconButton'
7311
- };
7312
7336
 
7313
7337
  var CardHeaderIcon = function CardHeaderIcon(_ref) {
7314
7338
  var Icon = _ref.icon;
@@ -7367,6 +7391,7 @@ CardHeaderIconButton.componentId = ComponentIds.CardHeaderIconButton;
7367
7391
  var CardHeader = function CardHeader(_ref2) {
7368
7392
  var children = _ref2.children;
7369
7393
  useVerifyInsideCard('CardHeader');
7394
+ useVerifyAllowedComponents(children, 'CardHeader', [ComponentIds.CardHeaderLeading, ComponentIds.CardHeaderTrailing]);
7370
7395
  return /*#__PURE__*/jsxs(Box, _objectSpread$j(_objectSpread$j({
7371
7396
  marginBottom: "spacing.7"
7372
7397
  }, metaAttribute(MetaConstants.Component, MetaConstants.CardHeader)), {}, {
@@ -7380,6 +7405,8 @@ var CardHeader = function CardHeader(_ref2) {
7380
7405
  }));
7381
7406
  };
7382
7407
 
7408
+ CardHeader.componentId = ComponentIds.CardHeader;
7409
+
7383
7410
  var CardHeaderLeading = function CardHeaderLeading(_ref3) {
7384
7411
  var title = _ref3.title,
7385
7412
  subtitle = _ref3.subtitle,
@@ -7429,6 +7456,7 @@ var CardHeaderLeading = function CardHeaderLeading(_ref3) {
7429
7456
  });
7430
7457
  };
7431
7458
 
7459
+ CardHeaderLeading.componentId = ComponentIds.CardHeaderLeading;
7432
7460
  var headerTrailingAllowedComponents = [ComponentIds.CardHeaderLink, ComponentIds.CardHeaderText, ComponentIds.CardHeaderIconButton, ComponentIds.CardHeaderBadge];
7433
7461
 
7434
7462
  var CardHeaderTrailing = function CardHeaderTrailing(_ref4) {
@@ -7445,6 +7473,8 @@ var CardHeaderTrailing = function CardHeaderTrailing(_ref4) {
7445
7473
  });
7446
7474
  };
7447
7475
 
7476
+ CardHeaderTrailing.componentId = ComponentIds.CardHeaderTrailing;
7477
+
7448
7478
  function ownKeys$i(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
7449
7479
 
7450
7480
  function _objectSpread$i(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$i(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$i(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -7465,6 +7495,7 @@ var CardFooter = function CardFooter(_ref) {
7465
7495
  var children = _ref.children;
7466
7496
  var isMobile = useIsMobile();
7467
7497
  useVerifyInsideCard('CardFooter');
7498
+ useVerifyAllowedComponents(children, 'CardFooter', [ComponentIds.CardFooterLeading, ComponentIds.CardFooterTrailing]);
7468
7499
  return /*#__PURE__*/jsxs(Box, _objectSpread$i(_objectSpread$i({
7469
7500
  marginTop: "auto"
7470
7501
  }, metaAttribute(MetaConstants.Component, MetaConstants.CardFooter)), {}, {
@@ -7481,6 +7512,8 @@ var CardFooter = function CardFooter(_ref) {
7481
7512
  }));
7482
7513
  };
7483
7514
 
7515
+ CardFooter.componentId = ComponentIds.CardFooter;
7516
+
7484
7517
  var CardFooterLeading = function CardFooterLeading(_ref2) {
7485
7518
  var title = _ref2.title,
7486
7519
  subtitle = _ref2.subtitle;
@@ -7500,6 +7533,8 @@ var CardFooterLeading = function CardFooterLeading(_ref2) {
7500
7533
  });
7501
7534
  };
7502
7535
 
7536
+ CardFooterLeading.componentId = ComponentIds.CardFooterLeading;
7537
+
7503
7538
  var CardFooterTrailing = function CardFooterTrailing(_ref3) {
7504
7539
  var actions = _ref3.actions;
7505
7540
  var isMobile = useIsMobile();
@@ -7533,6 +7568,8 @@ var CardFooterTrailing = function CardFooterTrailing(_ref3) {
7533
7568
  });
7534
7569
  };
7535
7570
 
7571
+ CardFooterTrailing.componentId = ComponentIds.CardFooterTrailing;
7572
+
7536
7573
  /**
7537
7574
  * Checks if `value` is `undefined`.
7538
7575
  *
@@ -11599,5 +11636,5 @@ var SkipNavContent = function SkipNavContent(_ref3) {
11599
11636
  }, testID('skipnav-content')), metaAttribute(MetaConstants.Component, MetaConstants.SkipNav)));
11600
11637
  };
11601
11638
 
11602
- export { Alert, AlertTriangleIcon as AlertOctagonIcon, AlertTriangleIcon$1 as AlertTriangleIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, ArrowUpRightIcon, Badge, BladeProvider, Button, Card, CardBody, CardFooter, CardFooterLeading, CardFooterTrailing, CardHeader, CardHeaderBadge, CardHeaderCounter, CardHeaderIcon, CardHeaderIconButton, CardHeaderLeading, CardHeaderLink, CardHeaderText, CardHeaderTrailing, CheckCircleIcon, CheckIcon, Checkbox, CheckboxGroup, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, Code, Counter, CreditCardIcon, DollarIcon, DownloadIcon, EditIcon, ExternalLinkIcon, EyeIcon, EyeOffIcon, FileTextIcon, Heading, HelpCircleIcon, HistoryIcon, HomeIcon, IconButton, Indicator, InfoIcon, Link, LinkIcon, LockIcon, MailIcon, MinusIcon, OTPInput, PasswordInput, PauseIcon, PlusIcon, ProgressBar, Radio, RadioGroup, RefreshLeftIcon, RotateCounterClockWiseIcon, RupeeIcon, SearchIcon, SettingsIcon, SkipNavContent, SkipNavLink, SlashIcon, Spinner, Text, TextArea, TextInput, Title, TrashIcon, TrendingDownIcon, TrendingUpIcon, UsersIcon, VisuallyHidden, announce, clearAnnouncer, destroyAnnouncer, getTextProps, screenReaderStyles, useTheme };
11639
+ export { Alert, AlertTriangleIcon as AlertOctagonIcon, AlertTriangleIcon$1 as AlertTriangleIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, ArrowUpRightIcon, Badge, BladeProvider, Button, Card, CardBody, CardFooter, CardFooterLeading, CardFooterTrailing, CardHeader, CardHeaderBadge, CardHeaderCounter, CardHeaderIcon, CardHeaderIconButton, CardHeaderLeading, CardHeaderLink, CardHeaderText, CardHeaderTrailing, CheckCircleIcon, CheckIcon, Checkbox, CheckboxGroup, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, Code, ComponentIds, Counter, CreditCardIcon, DollarIcon, DownloadIcon, EditIcon, ExternalLinkIcon, EyeIcon, EyeOffIcon, FileTextIcon, Heading, HelpCircleIcon, HistoryIcon, HomeIcon, IconButton, Indicator, InfoIcon, Link, LinkIcon, LockIcon, MailIcon, MinusIcon, OTPInput, PasswordInput, PauseIcon, PlusIcon, ProgressBar, Radio, RadioGroup, RefreshLeftIcon, RotateCounterClockWiseIcon, RupeeIcon, SearchIcon, SettingsIcon, SkipNavContent, SkipNavLink, SlashIcon, Spinner, Text, TextArea, TextInput, Title, TrashIcon, TrendingDownIcon, TrendingUpIcon, UsersIcon, VisuallyHidden, announce, clearAnnouncer, destroyAnnouncer, getTextProps, screenReaderStyles, useTheme };
11603
11640
  //# sourceMappingURL=index.web.js.map