@razorpay/blade 5.2.1 → 5.4.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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import * as React$1 from 'react';
3
- import React__default, { ReactChild, ReactElement, ReactNode, KeyboardEvent, SyntheticEvent } from 'react';
3
+ import React__default, { ReactChild, ReactElement, ReactNode, SyntheticEvent, KeyboardEvent } from 'react';
4
4
  import { AccessibilityRole, GestureResponderEvent } from 'react-native';
5
5
  import { CSSObject } from 'styled-components';
6
6
 
@@ -240,6 +240,16 @@ type DotNotationColorStringToken<TokenType> = {
240
240
  : DotNotationColorStringToken<TokenType[K]>}`;
241
241
  }[keyof TokenType];
242
242
 
243
+ /* eslint-disable @typescript-eslint/no-explicit-any */
244
+
245
+
246
+ /**
247
+ * A type defining React component with additional static prop `componentId`
248
+ */
249
+ type WithComponentId<Props> = ((props: Props) => React__default.ReactElement) & {
250
+ componentId: string;
251
+ };
252
+
243
253
  // All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
244
254
  type AriaRoles =
245
255
  | Exclude<AccessibilityRole, 'header' | 'adjustable' | 'image' | 'none' | 'summary'>
@@ -280,6 +290,7 @@ type AriaRoles =
280
290
  | 'menuitem'
281
291
  | 'menuitemcheckbox'
282
292
  | 'menuitemradio'
293
+ | 'meter'
283
294
  | 'navigation'
284
295
  | 'none'
285
296
  | 'note'
@@ -1039,6 +1050,75 @@ declare type Theme = {
1039
1050
  typography: Typography;
1040
1051
  };
1041
1052
 
1053
+ declare type CardProps = {
1054
+ /**
1055
+ * Card contents
1056
+ */
1057
+ children: React__default.ReactNode;
1058
+ /**
1059
+ * Sets the background color of the Card according to the surface level tokens
1060
+ *
1061
+ * eg: `theme.colors.surface.background.level1`
1062
+ *
1063
+ * **Description:**
1064
+ *
1065
+ * - 2: Used in layouts which are on top of the main background
1066
+ * - 3: Used over the cards template or as a text input backgrounds.
1067
+ *
1068
+ * **Links:**
1069
+ * - Docs: https://blade.razorpay.com/?path=/docs/tokens-colors--page#-theme-tokens
1070
+ * - Figma: https://shorturl.at/fsvwK
1071
+ */
1072
+ surfaceLevel: 2 | 3;
1073
+ };
1074
+ declare const Card: ({ children, surfaceLevel }: CardProps) => React__default.ReactElement;
1075
+ declare type CardBodyProps = {
1076
+ children: React__default.ReactNode;
1077
+ };
1078
+ declare const CardBody: ({ children }: CardBodyProps) => React__default.ReactElement;
1079
+
1080
+ declare type LinkCommonProps = {
1081
+ variant?: 'anchor' | 'button';
1082
+ icon?: IconComponent$1;
1083
+ iconPosition?: 'left' | 'right';
1084
+ isDisabled?: boolean;
1085
+ onClick?: (event: SyntheticEvent) => void;
1086
+ href?: string;
1087
+ target?: string;
1088
+ accessibilityLabel?: string;
1089
+ /**
1090
+ * Sets the size of the link
1091
+ *
1092
+ * @default medium
1093
+ */
1094
+ size?: 'small' | 'medium';
1095
+ };
1096
+ declare type LinkWithoutIconProps = LinkCommonProps & {
1097
+ icon?: undefined;
1098
+ children: string;
1099
+ };
1100
+ declare type LinkWithIconProps = LinkCommonProps & {
1101
+ icon: IconComponent$1;
1102
+ children?: string;
1103
+ };
1104
+ declare type LinkPropsWithOrWithoutIcon = LinkWithIconProps | LinkWithoutIconProps;
1105
+ declare type LinkAnchorVariantProps = LinkPropsWithOrWithoutIcon & {
1106
+ variant?: 'anchor';
1107
+ href?: string;
1108
+ target?: string;
1109
+ rel?: string;
1110
+ isDisabled?: undefined;
1111
+ };
1112
+ declare type LinkButtonVariantProps = LinkPropsWithOrWithoutIcon & {
1113
+ variant?: 'button';
1114
+ isDisabled?: boolean;
1115
+ href?: undefined;
1116
+ target?: undefined;
1117
+ rel?: undefined;
1118
+ };
1119
+ declare type LinkProps = LinkAnchorVariantProps | LinkButtonVariantProps;
1120
+ declare const Link: ({ children, icon, iconPosition, isDisabled, onClick, variant, href, target, rel, accessibilityLabel, size, }: LinkProps) => ReactElement;
1121
+
1042
1122
  declare type ButtonCommonProps = {
1043
1123
  variant?: 'primary' | 'secondary' | 'tertiary';
1044
1124
  size?: 'xsmall' | 'small' | 'medium' | 'large';
@@ -1064,6 +1144,181 @@ declare type ButtonWithIconProps = ButtonCommonProps & {
1064
1144
  declare type ButtonProps = ButtonWithoutIconProps | ButtonWithIconProps;
1065
1145
  declare const Button: ({ children, icon, iconPosition, isDisabled, isFullWidth, isLoading, onClick, size, type, variant, accessibilityLabel, }: ButtonProps) => React.ReactElement;
1066
1146
 
1147
+ type FeedbackColors$1 = `feedback.text.${DotNotationColorStringToken<
1148
+ Theme$1['colors']['feedback']['text']
1149
+ >}`;
1150
+ type FeedbackActionColors$1 = `feedback.${Feedback}.action.text.${DotNotationColorStringToken<
1151
+ Theme$1['colors']['feedback'][Feedback]['action']['text']
1152
+ >}`;
1153
+ type SurfaceColors$1 = `surface.text.${DotNotationColorStringToken<
1154
+ Theme$1['colors']['surface']['text']
1155
+ >}`;
1156
+ type ActionColors$1 = `action.text.${DotNotationColorStringToken<Theme$1['colors']['action']['text']>}`;
1157
+ type BadgeTextColors$1 = `badge.text.${DotNotationColorStringToken<
1158
+ Theme$1['colors']['badge']['text']
1159
+ >}`;
1160
+
1161
+ type BaseTextProps$1 = {
1162
+ id?: string;
1163
+ color?: ActionColors$1 | FeedbackColors$1 | SurfaceColors$1 | FeedbackActionColors$1 | BadgeTextColors$1;
1164
+ fontFamily?: keyof Theme$1['typography']['fonts']['family'];
1165
+ fontSize?: keyof Theme$1['typography']['fonts']['size'];
1166
+ fontWeight?: keyof Theme$1['typography']['fonts']['weight'];
1167
+ fontStyle?: 'italic' | 'normal';
1168
+ textDecorationLine?: 'line-through' | 'none' | 'underline';
1169
+ lineHeight?: keyof Theme$1['typography']['lineHeights'];
1170
+ /**
1171
+ * Web only
1172
+ */
1173
+ as?: 'code' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'span';
1174
+ textAlign?: 'center' | 'justify' | 'left' | 'right';
1175
+ truncateAfterLines?: number;
1176
+ className?: string;
1177
+ style?: React.CSSProperties;
1178
+ children: React.ReactNode;
1179
+ accessibilityProps?: Partial<AccessibilityProps>;
1180
+ /**
1181
+ * React Native only
1182
+ */
1183
+ numberOfLines?: number;
1184
+ componentName?: 'text' | 'title' | 'heading' | 'code';
1185
+ };
1186
+
1187
+ /* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
1188
+
1189
+
1190
+ type TextCommonProps$1 = {
1191
+ type?: TextTypes;
1192
+ contrast?: ColorContrastTypes;
1193
+ truncateAfterLines?: number;
1194
+ children: React.ReactNode;
1195
+ weight?: keyof Theme$1['typography']['fonts']['weight'];
1196
+ /**
1197
+ * **For Internal use only**: Sets the color of the Text component
1198
+ */
1199
+ color?: BaseTextProps$1['color'];
1200
+ };
1201
+
1202
+ type TextVariant$1 = 'body' | 'caption';
1203
+
1204
+ type TextBodyVariant$1 = TextCommonProps$1 & {
1205
+ variant?: Extract<TextVariant$1, 'body'>;
1206
+ size?: 'small' | 'medium';
1207
+ };
1208
+
1209
+ type TextCaptionVariant$1 = TextCommonProps$1 & {
1210
+ variant?: Extract<TextVariant$1, 'caption'>;
1211
+ size?: 'medium';
1212
+ };
1213
+
1214
+ /**
1215
+ * Conditionally changing props based on variant.
1216
+ * Overloads or union gives wrong intellisense.
1217
+ */
1218
+ type TextProps$1<T> = T extends {
1219
+ variant: infer Variant;
1220
+ }
1221
+ ? Variant extends 'caption'
1222
+ ? TextCaptionVariant$1
1223
+ : Variant extends 'body'
1224
+ ? TextBodyVariant$1
1225
+ : T
1226
+ : T;
1227
+
1228
+ type CounterProps$1 = {
1229
+ /**
1230
+ * Sets the value for the counter.
1231
+ */
1232
+ value: number;
1233
+ /**
1234
+ * Sets the max value for the counter.
1235
+ * If value exceedes `max` it will render `value+`
1236
+ */
1237
+ max?: number;
1238
+ /**
1239
+ * Sets the intent of the counter.
1240
+ *
1241
+ * @default 'neutral'
1242
+ */
1243
+ intent?: Feedback;
1244
+ /**
1245
+ * Sets the contrast of the counter.
1246
+ *
1247
+ * @default 'low'
1248
+ */
1249
+ contrast?: 'high' | 'low';
1250
+ /**
1251
+ * Sets the size of the counter.
1252
+ *
1253
+ * @default 'medium'
1254
+ */
1255
+ size?: 'small' | 'medium' | 'large';
1256
+ };
1257
+
1258
+ declare const CardHeaderIcon: WithComponentId<{
1259
+ icon: IconComponent$1;
1260
+ }>;
1261
+ declare const CardHeaderCounter: WithComponentId<CounterProps$1>;
1262
+ declare const CardHeaderBadge: WithComponentId<BadgeProps>;
1263
+ declare const CardHeaderText: WithComponentId<TextProps$1<{
1264
+ variant: TextVariant$1;
1265
+ }>>;
1266
+ declare const CardHeaderLink: WithComponentId<LinkProps>;
1267
+ declare type CardHeaderIconButtonProps = Omit<ButtonProps, 'variant' | 'size' | 'iconPosition' | 'isFullWidth' | 'children'> & {
1268
+ icon: IconComponent$1;
1269
+ };
1270
+ declare const CardHeaderIconButton: WithComponentId<CardHeaderIconButtonProps>;
1271
+ declare type CardHeaderProps = {
1272
+ children?: React__default.ReactNode;
1273
+ };
1274
+ declare const CardHeader: ({ children }: CardHeaderProps) => React__default.ReactElement;
1275
+ declare type CardHeaderLeadingProps = {
1276
+ title: string;
1277
+ subtitle?: string;
1278
+ /**
1279
+ * prefix element of Card
1280
+ *
1281
+ * Accepts: `CardHeaderIcon` component
1282
+ */
1283
+ prefix?: React__default.ReactNode;
1284
+ /**
1285
+ * suffix element of Card
1286
+ *
1287
+ * Accepts: `CardHeaderCounter` component
1288
+ */
1289
+ suffix?: React__default.ReactNode;
1290
+ };
1291
+ declare const CardHeaderLeading: ({ title, subtitle, prefix, suffix, }: CardHeaderLeadingProps) => React__default.ReactElement;
1292
+ declare type CardHeaderTrailingProps = {
1293
+ /**
1294
+ * Renders a visual ornament in card header trailing section
1295
+ *
1296
+ * Accepts: `CardHeaderLink`, `CardHeaderText`, `CardHeaderIconButton`, `CardHeaderBadge`
1297
+ */
1298
+ visual?: React__default.ReactNode;
1299
+ };
1300
+ declare const CardHeaderTrailing: ({ visual }: CardHeaderTrailingProps) => React__default.ReactElement;
1301
+
1302
+ declare type CardFooterAction = Pick<ButtonProps, 'type' | 'accessibilityLabel' | 'isLoading' | 'isDisabled' | 'icon' | 'iconPosition' | 'onClick'> & {
1303
+ text: ButtonProps['children'];
1304
+ };
1305
+ declare type CardFooterProps = {
1306
+ children?: React.ReactNode;
1307
+ };
1308
+ declare const CardFooter: ({ children }: CardFooterProps) => React.ReactElement;
1309
+ declare type CardFooterLeadingProps = {
1310
+ title?: string;
1311
+ subtitle?: string;
1312
+ };
1313
+ declare const CardFooterLeading: ({ title, subtitle }: CardFooterLeadingProps) => React.ReactElement;
1314
+ declare type CardFooterTrailingProps = {
1315
+ actions?: {
1316
+ primary?: CardFooterAction;
1317
+ secondary?: CardFooterAction;
1318
+ };
1319
+ };
1320
+ declare const CardFooterTrailing: ({ actions }: CardFooterTrailingProps) => React.ReactElement;
1321
+
1067
1322
  declare type IconButtonProps = {
1068
1323
  /**
1069
1324
  * Icon component to be rendered, eg. `CloseIcon`
@@ -1740,53 +1995,88 @@ declare type IndicatorWithA11yLabel = {
1740
1995
  declare type IndicatorProps = IndicatorCommonProps & (IndicatorWithA11yLabel | IndicatorWithoutA11yLabel);
1741
1996
  declare const Indicator: ({ accessibilityLabel, children, size, intent, }: IndicatorProps) => ReactElement;
1742
1997
 
1743
- declare type LinkCommonProps = {
1744
- variant?: 'anchor' | 'button';
1745
- icon?: IconComponent$1;
1746
- iconPosition?: 'left' | 'right';
1747
- isDisabled?: boolean;
1748
- onClick?: (event: SyntheticEvent) => void;
1749
- href?: string;
1750
- target?: string;
1998
+ declare type Assertiveness = AriaAttributes['liveRegion'];
1999
+
2000
+ declare function announce(message: string, _assertiveness?: Assertiveness): void;
2001
+ declare function clearAnnouncer(_assertiveness: Assertiveness): void;
2002
+ declare function destroyAnnouncer(): void;
2003
+
2004
+ declare type ProgressBarCommonProps = {
2005
+ /**
2006
+ * Sets aria-label to help users know what the progress bar is for. Default value is the same as the `label` passed.
2007
+ */
1751
2008
  accessibilityLabel?: string;
1752
2009
  /**
1753
- * Sets the size of the link
1754
- *
1755
- * @default medium
2010
+ * Sets the contrast for the progress bar
2011
+ * @default 'low'
2012
+ */
2013
+ contrast?: ColorContrastTypes;
2014
+ /**
2015
+ * Sets the intent of the progress bar which changes the feedback color.
2016
+ */
2017
+ intent?: Feedback;
2018
+ /**
2019
+ * Sets the label to be rendered for the progress bar. This value will also be used as default for `accessibilityLabel`.
2020
+ */
2021
+ label?: string;
2022
+ /**
2023
+ * Sets the size of the progress bar.
2024
+ * @default 'small'
1756
2025
  */
1757
2026
  size?: 'small' | 'medium';
2027
+ /**
2028
+ * Sets the progress value of the progress bar.
2029
+ * @default 'small'
2030
+ */
2031
+ value?: number;
2032
+ /**
2033
+ * Sets the minimum value for the progress bar.
2034
+ * @default 0
2035
+ */
2036
+ min?: number;
2037
+ /**
2038
+ * Sets the maximum value for the progress bar.
2039
+ * @default 100
2040
+ */
2041
+ max?: number;
1758
2042
  };
1759
- declare type LinkWithoutIconProps = LinkCommonProps & {
1760
- icon?: undefined;
1761
- children: string;
1762
- };
1763
- declare type LinkWithIconProps = LinkCommonProps & {
1764
- icon: IconComponent$1;
1765
- children?: string;
1766
- };
1767
- declare type LinkPropsWithOrWithoutIcon = LinkWithIconProps | LinkWithoutIconProps;
1768
- declare type LinkAnchorVariantProps = LinkPropsWithOrWithoutIcon & {
1769
- variant?: 'anchor';
1770
- href?: string;
1771
- target?: string;
1772
- rel?: string;
1773
- isDisabled?: undefined;
2043
+ declare type ProgressBarVariant = 'progress' | 'meter';
2044
+ declare type ProgressBarProgressProps = ProgressBarCommonProps & {
2045
+ /**
2046
+ * Sets the variant to be rendered for the progress bar.
2047
+ * @default 'progress'
2048
+ */
2049
+ variant?: Extract<ProgressBarVariant, 'progress'>;
2050
+ /**
2051
+ * Sets whether the progress bar is in an indeterminate state.
2052
+ * @default false
2053
+ */
2054
+ isIndeterminate?: boolean;
2055
+ /**
2056
+ * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.
2057
+ * @default true
2058
+ */
2059
+ showPercentage?: boolean;
1774
2060
  };
1775
- declare type LinkButtonVariantProps = LinkPropsWithOrWithoutIcon & {
1776
- variant?: 'button';
1777
- isDisabled?: boolean;
1778
- href?: undefined;
1779
- target?: undefined;
1780
- rel?: undefined;
2061
+ declare type ProgressBarMeterProps = ProgressBarCommonProps & {
2062
+ /**
2063
+ * Sets the variant to be rendered for thr progress bar.
2064
+ * @default 'progress'
2065
+ */
2066
+ variant?: Extract<ProgressBarVariant, 'meter'>;
2067
+ /**
2068
+ * Sets whether the progress bar is in an indeterminate state.
2069
+ * @default false
2070
+ */
2071
+ isIndeterminate?: undefined;
2072
+ /**
2073
+ * Sets whether or not to show the progress percentage for the progress bar. Percentage is hidden by default for the `meter` variant.
2074
+ * @default false
2075
+ */
2076
+ showPercentage?: undefined;
1781
2077
  };
1782
- declare type LinkProps = LinkAnchorVariantProps | LinkButtonVariantProps;
1783
- declare const Link: ({ children, icon, iconPosition, isDisabled, onClick, variant, href, target, rel, accessibilityLabel, size, }: LinkProps) => ReactElement;
1784
-
1785
- declare type Assertiveness = AriaAttributes['liveRegion'];
1786
-
1787
- declare function announce(message: string, _assertiveness?: Assertiveness): void;
1788
- declare function clearAnnouncer(_assertiveness: Assertiveness): void;
1789
- declare function destroyAnnouncer(): void;
2078
+ declare type ProgressBarProps = ProgressBarProgressProps | ProgressBarMeterProps;
2079
+ declare const ProgressBar: ({ accessibilityLabel, contrast, intent, isIndeterminate, label, showPercentage, size, value, variant, min, max, }: ProgressBarProps) => ReactElement;
1790
2080
 
1791
2081
  declare type RadioProps = {
1792
2082
  /**
@@ -2091,4 +2381,4 @@ declare const VisuallyHidden: ({ children }: VisuallyHiddenProps) => JSX.Element
2091
2381
 
2092
2382
  declare const screenReaderStyles: CSSObject;
2093
2383
 
2094
- export { Alert, AlertTriangleIcon as AlertOctagonIcon, AlertProps, AlertTriangleIcon$1 as AlertTriangleIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, ArrowUpRightIcon, Badge, BadgeProps, BladeProvider, BladeProviderProps, Button, ButtonProps, CheckCircleIcon, CheckIcon, Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, Code, CodeProps, Counter, CounterProps, CreditCardIcon, DollarIcon, DownloadIcon, EditIcon, ExternalLinkIcon, EyeIcon, EyeOffIcon, FileTextIcon, Heading, HeadingProps, HelpCircleIcon, HistoryIcon, HomeIcon, IconButton, IconButtonProps, IconComponent, IconProps, IconSize, Indicator, IndicatorProps, InfoIcon, Link, LinkIcon, LinkProps, LockIcon, MailIcon, MinusIcon, OTPInput, OTPInputProps, PasswordInput, PasswordInputProps, PauseIcon, PlusIcon, Radio, RadioGroup, RadioGroupProps, RadioProps, RefreshLeftIcon, RotateCounterClockWiseIcon, RupeeIcon, SearchIcon, SettingsIcon, SkipNavContent, SkipNavLink, SlashIcon, Spinner, SpinnerProps, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, TextVariant, Theme, Title, TitleProps, TrashIcon, TrendingDownIcon, TrendingUpIcon, UsersIcon, VisuallyHidden, VisuallyHiddenProps, announce, clearAnnouncer, destroyAnnouncer, getTextProps, screenReaderStyles, useTheme };
2384
+ export { Alert, AlertTriangleIcon as AlertOctagonIcon, AlertProps, AlertTriangleIcon$1 as AlertTriangleIcon, ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon, ArrowUpRightIcon, Badge, BadgeProps, BladeProvider, BladeProviderProps, Button, ButtonProps, Card, CardBody, CardFooter, CardFooterAction, CardFooterLeading, CardFooterTrailing, CardHeader, CardHeaderBadge, CardHeaderCounter, CardHeaderIcon, CardHeaderIconButton, CardHeaderLeading, CardHeaderLink, CardHeaderText, CardHeaderTrailing, CardProps, CheckCircleIcon, CheckIcon, Checkbox, CheckboxGroup, CheckboxGroupProps, CheckboxProps, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon, CloseIcon, Code, CodeProps, Counter, CounterProps, CreditCardIcon, DollarIcon, DownloadIcon, EditIcon, ExternalLinkIcon, EyeIcon, EyeOffIcon, FileTextIcon, Heading, HeadingProps, HelpCircleIcon, HistoryIcon, HomeIcon, IconButton, IconButtonProps, IconComponent, IconProps, IconSize, Indicator, IndicatorProps, InfoIcon, Link, LinkIcon, LinkProps, LockIcon, MailIcon, MinusIcon, OTPInput, OTPInputProps, PasswordInput, PasswordInputProps, PauseIcon, PlusIcon, ProgressBar, ProgressBarProps, ProgressBarVariant, Radio, RadioGroup, RadioGroupProps, RadioProps, RefreshLeftIcon, RotateCounterClockWiseIcon, RupeeIcon, SearchIcon, SettingsIcon, SkipNavContent, SkipNavLink, SlashIcon, Spinner, SpinnerProps, Text, TextArea, TextAreaProps, TextInput, TextInputProps, TextProps, TextVariant, Theme, Title, TitleProps, TrashIcon, TrendingDownIcon, TrendingUpIcon, UsersIcon, VisuallyHidden, VisuallyHiddenProps, announce, clearAnnouncer, destroyAnnouncer, getTextProps, screenReaderStyles, useTheme };