@razorpay/blade 10.15.0 → 10.15.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.
package/README.md CHANGED
@@ -1,39 +1,41 @@
1
- <h1 align="center">
2
- Blade
3
- </h1>
1
+ <br/>
4
2
  <p align="center">
5
- <a href="https://github.com/styled-components/styled-components">
6
- <img src="https://img.shields.io/badge/style-%F0%9F%92%85%20styled--components-orange.svg?colorB=daa357&colorA=db748e" alt="Blade is styled with styled-components" />
7
- </a>
8
- <a href="https://github.com/facebook/jest">
9
- <img src="https://jestjs.io/img/jest-badge.svg" alt="Blade is tested with jest" />
10
- </a>
11
- <a href="https://github.com/razorpay/blade/blob/master/LICENSE.md">
12
- <img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="Blade is released under the MIT license." />
13
- </a>
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="./branding/blade-original-dark-mode.min.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="./branding/blade-original.min.svg">
6
+ <img width="450px" alt="Blade Design System Logo" src="./branding/blade-original.min.svg">
7
+ </picture>
14
8
  </p>
15
9
 
10
+ <br/>
11
+
16
12
  <p align="center">
17
- The Design System that powers Razorpay
18
- <p align="center">
13
+ <a href="https://npmjs.org/package/@razorpay/blade"><img alt="Blade Latest Version" src="https://img.shields.io/github/package-json/v/razorpay/blade?style=for-the-badge&labelColor=322&logo=npm&label=@razorpay/Blade&color=darkred&filename=packages%2Fblade%2Fpackage.json"></a> &nbsp;<a href="https://blade.razorpay.com/"><img alt="Documentation blade.razorpay.com" src="https://img.shields.io/badge/Documentation-blade.razorpay.com-0648EF?style=for-the-badge&labelColor=0012AD&logo=readthedocs&logoColor=eee"/></a> &nbsp;<a href="https://github.com/razorpay/blade/tree/master/CONTRIBUTING.md"><img alt="Discord Join Chat" src="https://img.shields.io/badge/Contributions-Open-333333?style=for-the-badge&logo=github&logoColor=ffffff&labelColor=111111"/></a></p>
14
+
15
+ <h1 aria-hidden="true"></h1>
19
16
 
20
- ### [`@razorpay/blade`](https://github.com/razorpay/blade/tree/master/packages/blade)
17
+ <br/>
21
18
 
22
- This package is under active development.
19
+ Blade is the Design System that powers [Razorpay](https://razorpay.com/).
23
20
 
24
- - [Documentation](https://master--61c19ee8d3d282003ac1d81c.chromatic.com)
25
- - [Installation Guide](https://master--61c19ee8d3d282003ac1d81c.chromatic.com/?path=/docs/guides-installation--page)
26
- - [Contributing guidelines](https://github.com/razorpay/blade/blob/master/CONTRIBUTING.md)
21
+ ## 🔗 Links
27
22
 
28
- ---
23
+ - [Docs](https://blade.razorpay.com)
24
+ - [Installation](https://blade.razorpay.com/?path=/docs/guides-installation--page)
25
+ - [@razorpay/blade-old](https://github.com/razorpay/blade-old) (Deprecated, Private)
29
26
 
30
- > **Note**
31
- >
32
- > The blade-old package has been moved to it's own repo.
33
- > [github.com/razorpay/blade-old](https://github.com/razorpay/blade-old) (Only accessible to Razorpay employees)
34
- >
35
- > It is under **maintenance** and it won't have any major releases.
27
+ ## ✨ Features
28
+ - Cross-Platform (Works Natively on [React Web](https://blade.razorpay.com/?path=/docs/guides-installation--page#%EF%B8%8F-installation) and [React Native](https://blade.razorpay.com/?path=/docs/guides-installation--page#react-native-projects))
29
+ - [White Labelling](https://blade.razorpay.com/?path=/docs/guides-theming-theme-playground--page)
30
+ - [CSS Variables for non-React Projects](https://blade.razorpay.com/?path=/docs/tokens-css-variables--page)
31
+ - [Accessible](https://github.com/razorpay/blade/blob/master/rfcs/2022-04-09-accessibility.md#manual-testing)
32
+ - Documented [RFCs](https://github.com/razorpay/blade/tree/docs/make-docs-pretty/rfcs) and [API Decisions](https://github.com/razorpay/blade/blob/master/packages/blade/src/components/Alert/_decisions/decisions.md)
36
33
 
37
34
  ## 📝 License
38
35
 
39
36
  Licensed under the [MIT License](https://github.com/razorpay/blade/blob/master/LICENSE.md).
37
+
38
+ <h1 aria-hidden="true"></h1>
39
+
40
+ <p align="center">Interested in working with us? Checkout our <a href="https://razorpay.com/jobs">Jobs Page</a> for open roles 🤗</p>
41
+
@@ -3122,10 +3122,11 @@ declare type ActionColors = `action.text.${DotNotationColorStringToken<Theme['co
3122
3122
  declare type BadgeTextColors = `badge.text.${DotNotationColorStringToken<Theme['colors']['badge']['text']>}`;
3123
3123
  declare type WhiteTextColors = `white.action.text.${DotNotationColorStringToken<Theme['colors']['white']['action']['text']>}`;
3124
3124
  declare type BrandPrimaryColors = `brand.primary.${keyof Theme['colors']['brand']['primary']}`;
3125
+ declare type BrandSecondaryColors = `brand.secondary.${keyof Theme['colors']['brand']['secondary']}`;
3125
3126
  declare type As = 'code' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span' | 'abbr' | 'q' | 'cite' | 'figcaption' | 'div';
3126
3127
  declare type BaseTextProps = {
3127
3128
  id?: string;
3128
- color?: BrandPrimaryColors | ActionColors | FeedbackColors | SurfaceColors | FeedbackActionColors | WhiteTextColors | BadgeTextColors;
3129
+ color?: BrandPrimaryColors | BrandSecondaryColors | ActionColors | FeedbackColors | SurfaceColors | FeedbackActionColors | WhiteTextColors | BadgeTextColors;
3129
3130
  fontFamily?: keyof Theme['typography']['fonts']['family'];
3130
3131
  fontSize?: keyof Theme['typography']['fonts']['size'];
3131
3132
  fontWeight?: keyof Theme['typography']['fonts']['weight'];
@@ -14525,6 +14525,7 @@ var getCheckboxIconWrapperStyles = function getCheckboxIconWrapperStyles(_ref) {
14525
14525
  display: 'flex',
14526
14526
  alignItems: 'center',
14527
14527
  justifyContent: 'center',
14528
+ flexShrink: 0,
14528
14529
  width: makeSpace(checkboxSizes.icon[size].width),
14529
14530
  height: makeSpace(checkboxSizes.icon[size].height),
14530
14531
  borderWidth: makeBorderSize(theme.border.width.thick),
@@ -15427,7 +15428,6 @@ var _Checkbox = function _Checkbox(_ref, ref) {
15427
15428
  flexDirection: "column",
15428
15429
  children: [/*#__PURE__*/jsxs(BaseBox, {
15429
15430
  display: "flex",
15430
- alignItems: "center",
15431
15431
  flexDirection: "row",
15432
15432
  children: [/*#__PURE__*/jsx(SelectorInput, {
15433
15433
  hoverTokens: checkboxHoverTokens,
@@ -15966,14 +15966,6 @@ var _ActionListItemText = function _ActionListItemText(_ref4) {
15966
15966
  var ActionListItemText = /*#__PURE__*/assignWithoutSideEffects(_ActionListItemText, {
15967
15967
  componentId: componentIds.ActionListItemText
15968
15968
  });
15969
- var ActionListCheckboxWrapper = /*#__PURE__*/styled(BaseBox).withConfig({
15970
- displayName: "ActionListItem__ActionListCheckboxWrapper",
15971
- componentId: "m6qdwa-1"
15972
- })(function (_props) {
15973
- return {
15974
- pointerEvents: 'none'
15975
- };
15976
- });
15977
15969
  var makeActionListItemClickable = function makeActionListItemClickable(clickHandler) {
15978
15970
  if (isReactNative$4()) {
15979
15971
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
@@ -16010,8 +16002,9 @@ var _ActionListItemBody = function _ActionListItemBody(_ref5) {
16010
16002
  children: selectionType === 'multiple' ?
16011
16003
  /*#__PURE__*/
16012
16004
  // Adding aria-hidden because the listbox item in multiselect in itself explains the behaviour so announcing checkbox is unneccesary and just a nice UI tweak for us
16013
- jsx(ActionListCheckboxWrapper, _objectSpread$1q(_objectSpread$1q({
16014
- hasDescription: Boolean(description)
16005
+ jsx(BaseBox, _objectSpread$1q(_objectSpread$1q({
16006
+ pointerEvents: "none",
16007
+ paddingRight: "spacing.2"
16015
16008
  }, makeAccessible({
16016
16009
  hidden: true
16017
16010
  })), {}, {
@@ -16206,15 +16199,15 @@ var MAX_WIDTH$2 = size[584];
16206
16199
  var getCommonStyles = function getCommonStyles(props) {
16207
16200
  var theme = props.theme,
16208
16201
  contrastType = props.contrastType,
16209
- intent = props.intent,
16202
+ color = props.color,
16210
16203
  isFullWidth = props.isFullWidth,
16211
16204
  isDesktop = props.isDesktop;
16212
16205
  var feedbackColors = theme.colors.feedback;
16213
16206
  return {
16214
- background: feedbackColors.background[intent][contrastType],
16207
+ background: feedbackColors.background[color][contrastType],
16215
16208
  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])),
16216
16209
  borderRadius: makeBorderSize(isFullWidth ? theme.border.radius.none : theme.border.radius.medium),
16217
- borderColor: feedbackColors.border[intent][contrastType],
16210
+ borderColor: feedbackColors.border[color][contrastType],
16218
16211
  borderWidth: makeBorderSize(isFullWidth ? theme.border.width.none : theme.border.width.thin),
16219
16212
  borderStyle: 'solid',
16220
16213
  display: 'flex',
@@ -17497,7 +17490,8 @@ var Alert = function Alert(_ref) {
17497
17490
  var contrastType = "".concat(contrast, "Contrast");
17498
17491
  var iconSize = isFullWidth ? 'large' : 'medium';
17499
17492
  var textSize = isFullWidth ? 'medium' : 'small';
17500
- var Icon = intentIconMap[intent];
17493
+ var alertColor = color !== null && color !== void 0 ? color : intent;
17494
+ var Icon = intentIconMap[alertColor];
17501
17495
  var iconOffset = 'spacing.1';
17502
17496
 
17503
17497
  // certain special cases below needs special care for near perfect alignment
@@ -17522,7 +17516,7 @@ var Alert = function Alert(_ref) {
17522
17516
  marginTop: iconOffset,
17523
17517
  display: "flex",
17524
17518
  children: /*#__PURE__*/jsx(Icon, {
17525
- color: "feedback.icon.".concat(intent, ".").concat(contrastType),
17519
+ color: "feedback.icon.".concat(alertColor, ".").concat(contrastType),
17526
17520
  size: iconSize
17527
17521
  })
17528
17522
  });
@@ -17555,7 +17549,7 @@ var Alert = function Alert(_ref) {
17555
17549
  children: /*#__PURE__*/jsx(BaseButton, {
17556
17550
  size: textSize,
17557
17551
  onClick: actions.primary.onClick,
17558
- color: color || intent,
17552
+ color: alertColor,
17559
17553
  variant: contrast === 'high' ? 'primary' : 'secondary',
17560
17554
  children: actions.primary.text
17561
17555
  })
@@ -17580,7 +17574,7 @@ var Alert = function Alert(_ref) {
17580
17574
  display: isReactNative$3 ? castNativeType('flex') : castWebType('inline-flex'),
17581
17575
  children: /*#__PURE__*/jsx(BaseLink, _objectSpread$1j(_objectSpread$1j({
17582
17576
  size: textSize,
17583
- color: contrast === 'high' ? 'white' : intent
17577
+ color: contrast === 'high' ? 'white' : alertColor
17584
17578
  }, secondaryActionParams), {}, {
17585
17579
  children: actions.secondary.text
17586
17580
  }))
@@ -17616,8 +17610,8 @@ var Alert = function Alert(_ref) {
17616
17610
  }) : null;
17617
17611
  var a11yProps = makeAccessible(_objectSpread$1j({
17618
17612
  // React Native doesn't has status as role
17619
- role: isReactNative$3 || intent === 'negative' || intent === 'notice' ? 'alert' : 'status'
17620
- }, intent === 'notice' && {
17613
+ role: isReactNative$3 || alertColor === 'negative' || alertColor === 'notice' ? 'alert' : 'status'
17614
+ }, alertColor === 'notice' && {
17621
17615
  liveRegion: 'polite'
17622
17616
  }));
17623
17617
  if (!isVisible) {
@@ -17628,7 +17622,7 @@ var Alert = function Alert(_ref) {
17628
17622
  testID: testID
17629
17623
  })), getStyledProps(styledProps)), {}, {
17630
17624
  children: /*#__PURE__*/jsxs(StyledAlert, {
17631
- intent: intent,
17625
+ color: alertColor,
17632
17626
  contrastType: contrastType,
17633
17627
  isFullWidth: isFullWidth,
17634
17628
  isDesktop: isDesktop,
@@ -21698,7 +21692,7 @@ var _StyledBaseInput = function _StyledBaseInput(_ref, ref) {
21698
21692
  }, commonProps), props), accessibilityProps), {}, {
21699
21693
  value: props.value,
21700
21694
  children: /*#__PURE__*/jsx(Text, {
21701
- type: props.value ? 'subtle' : 'placeholder',
21695
+ type: props.value && !isDisabled ? 'subtle' : 'placeholder',
21702
21696
  truncateAfterLines: 1,
21703
21697
  textAlign: props.textAlign,
21704
21698
  children: props.value ? props.value : props.placeholder
@@ -21971,7 +21965,8 @@ var BaseInputTagSlot = function BaseInputTagSlot(_ref3) {
21971
21965
  handleOnInputClick = _ref3.handleOnInputClick,
21972
21966
  isDropdownTrigger = _ref3.isDropdownTrigger,
21973
21967
  visibleTagsCountRef = _ref3.visibleTagsCountRef,
21974
- labelPrefix = _ref3.labelPrefix;
21968
+ labelPrefix = _ref3.labelPrefix,
21969
+ isDisabled = _ref3.isDisabled;
21975
21970
  var hasTags = tags && tags.length > 0;
21976
21971
  var slotRef = React__default.useRef(null);
21977
21972
  var visibleTagsCount = useVisibleTagsCount({
@@ -22040,6 +22035,7 @@ var BaseInputTagSlot = function BaseInputTagSlot(_ref3) {
22040
22035
  setShouldIgnoreBlurAnimation === null || setShouldIgnoreBlurAnimation === void 0 ? void 0 : setShouldIgnoreBlurAnimation(false);
22041
22036
  },
22042
22037
  children: [visibleTags, tags && !showAllTags && invisibleTagsCount ? /*#__PURE__*/jsx(Text, {
22038
+ type: isDisabled ? 'placeholder' : 'normal',
22043
22039
  alignSelf: "center",
22044
22040
  marginY: "spacing.2",
22045
22041
  marginRight: "spacing.4",
@@ -22490,6 +22486,7 @@ var BaseInput = /*#__PURE__*/React__default.forwardRef(function (_ref11, ref) {
22490
22486
  }), /*#__PURE__*/jsx(BaseInputTagSlot, {
22491
22487
  renderAs: as,
22492
22488
  tags: tags,
22489
+ isDisabled: isDisabled,
22493
22490
  showAllTags: showAllTagsWithAnimation,
22494
22491
  setFocusOnInput: function setFocusOnInput() {
22495
22492
  if (ref && !isReactNative && 'current' in ref) {
@@ -23430,22 +23427,32 @@ var _OTPInput = function _OTPInput(_ref, incomingRef) {
23430
23427
  };
23431
23428
  var OTPInput = /*#__PURE__*/React__default.forwardRef(_OTPInput);
23432
23429
 
23430
+ var Chevron = function Chevron(props) {
23431
+ var iconColor = "surface.text.".concat(props.isDisabled ? 'placeholder' : 'normal', ".lowContrast");
23432
+ return /*#__PURE__*/jsxs(Fragment, {
23433
+ children: [/*#__PURE__*/jsx(ChevronDownIcon, {
23434
+ display: props.isOpen ? 'none' : 'flex',
23435
+ size: "medium",
23436
+ color: iconColor
23437
+ }), /*#__PURE__*/jsx(ChevronUpIcon, {
23438
+ display: props.isOpen ? 'flex' : 'none',
23439
+ size: "medium",
23440
+ color: iconColor
23441
+ })]
23442
+ });
23443
+ };
23444
+
23433
23445
  var InputChevronIcon = function InputChevronIcon(props) {
23434
- return /*#__PURE__*/jsxs(BaseBox, {
23446
+ return /*#__PURE__*/jsx(BaseBox, {
23435
23447
  display: "flex",
23436
23448
  height: "100%",
23437
23449
  justifyContent: "center",
23438
23450
  alignItems: "center",
23439
23451
  onClick: props.onClick,
23440
- children: [/*#__PURE__*/jsx(ChevronDownIcon, {
23441
- display: props.isOpen ? 'none' : 'flex',
23442
- color: "surface.text.normal.lowContrast",
23443
- size: "medium"
23444
- }), /*#__PURE__*/jsx(ChevronUpIcon, {
23445
- display: props.isOpen ? 'flex' : 'none',
23446
- color: "surface.text.normal.lowContrast",
23447
- size: "medium"
23448
- })]
23452
+ children: /*#__PURE__*/jsx(Chevron, {
23453
+ isOpen: props.isOpen,
23454
+ isDisabled: props.isDisabled
23455
+ })
23449
23456
  });
23450
23457
  };
23451
23458
 
@@ -23595,6 +23602,7 @@ var AnimatedTagContainer = /*#__PURE__*/styled(BaseBox).withConfig({
23595
23602
  var AnimatedTag = function AnimatedTag(_ref) {
23596
23603
  var children = _ref.children,
23597
23604
  currentTagIndex = _ref.currentTagIndex,
23605
+ isDisabled = _ref.isDisabled,
23598
23606
  activeTagIndex = _ref.activeTagIndex,
23599
23607
  onDismiss = _ref.onDismiss;
23600
23608
  var _React$useState = React__default.useState(true),
@@ -23624,6 +23632,7 @@ var AnimatedTag = function AnimatedTag(_ref) {
23624
23632
  },
23625
23633
  marginRight: "spacing.3",
23626
23634
  marginY: "spacing.2",
23635
+ isDisabled: isDisabled,
23627
23636
  children: children
23628
23637
  })
23629
23638
  });
@@ -23632,6 +23641,7 @@ var AnimatedTag = function AnimatedTag(_ref) {
23632
23641
  var getTagsGroup = function getTagsGroup(_ref) {
23633
23642
  var tags = _ref.tags,
23634
23643
  activeTagIndex = _ref.activeTagIndex,
23644
+ isDisabled = _ref.isDisabled,
23635
23645
  onDismiss = _ref.onDismiss;
23636
23646
  return tags.map(function (tagName, tagIndex) {
23637
23647
  return /*#__PURE__*/jsx(AnimatedTag, {
@@ -23639,6 +23649,7 @@ var getTagsGroup = function getTagsGroup(_ref) {
23639
23649
  onDismiss: onDismiss,
23640
23650
  currentTagIndex: tagIndex,
23641
23651
  tagsLength: tags.length,
23652
+ isDisabled: isDisabled,
23642
23653
  children: tagName
23643
23654
  }, tagName);
23644
23655
  });
@@ -23818,9 +23829,11 @@ var _BaseDropdownInputTrigger = function _BaseDropdownInputTrigger(props, ref) {
23818
23829
  }
23819
23830
  return getTagsGroup({
23820
23831
  tags: selectedIndices.map(function (selectedIndex) {
23821
- return options[selectedIndex].title;
23832
+ var _options$selectedInde;
23833
+ return (_options$selectedInde = options[selectedIndex]) === null || _options$selectedInde === void 0 ? void 0 : _options$selectedInde.title;
23822
23834
  }),
23823
23835
  activeTagIndex: activeTagIndex,
23836
+ isDisabled: props.isDisabled,
23824
23837
  onDismiss: function onDismiss(_ref) {
23825
23838
  var tagIndex = _ref.tagIndex;
23826
23839
  if (isTagDismissedRef.current) {
@@ -23886,7 +23899,13 @@ var _BaseDropdownInputTrigger = function _BaseDropdownInputTrigger(props, ref) {
23886
23899
  autoFocus: props.autoFocus // eslint-disable-line jsx-a11y/no-autofocus
23887
23900
  ,
23888
23901
  value: getValue(),
23889
- onClick: props.onTriggerClick,
23902
+ onClick: function onClick(e) {
23903
+ var _props$onTriggerClick;
23904
+ if (props.isDisabled) {
23905
+ return;
23906
+ }
23907
+ (_props$onTriggerClick = props.onTriggerClick) === null || _props$onTriggerClick === void 0 ? void 0 : _props$onTriggerClick.call(props, e);
23908
+ },
23890
23909
  onFocus: props.onFocus,
23891
23910
  onBlur: function onBlur(_ref2) {
23892
23911
  var _props$onBlur;
@@ -23924,6 +23943,7 @@ var _BaseDropdownInputTrigger = function _BaseDropdownInputTrigger(props, ref) {
23924
23943
  onTriggerClick();
23925
23944
  }
23926
23945
  },
23946
+ isDisabled: props.isDisabled,
23927
23947
  isOpen: isOpen
23928
23948
  })
23929
23949
  });
@@ -24125,7 +24145,10 @@ var useAutoComplete = function useAutoComplete(_ref) {
24125
24145
  name: props.name,
24126
24146
  value: displayText
24127
24147
  });
24128
- setInputValue(displayText !== null && displayText !== void 0 ? displayText : '');
24148
+ // Use displayText as inputValue only if its not controlled by user
24149
+ if (typeof props.value === 'undefined') {
24150
+ setInputValue(displayText !== null && displayText !== void 0 ? displayText : '');
24151
+ }
24129
24152
  }
24130
24153
  (_props$onChange = props.onChange) === null || _props$onChange === void 0 ? void 0 : _props$onChange.call(props, {
24131
24154
  name: props.name,