@razorpay/blade 3.7.1 → 3.8.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.
- package/CHANGELOG.md +9 -0
- package/build/components/index.d.ts +7 -4
- package/build/components/index.native.d.ts +7 -4
- package/build/components/index.native.js +11 -5
- package/build/components/index.native.js.map +1 -1
- package/build/components/index.web.js +178 -81
- package/build/components/index.web.js.map +1 -1
- package/build/css/bankingThemeDarkDesktop.css +1 -1
- package/build/css/bankingThemeDarkMobile.css +1 -1
- package/build/css/bankingThemeLightDesktop.css +1 -1
- package/build/css/bankingThemeLightMobile.css +1 -1
- package/build/css/paymentThemeDarkDesktop.css +1 -1
- package/build/css/paymentThemeDarkMobile.css +1 -1
- package/build/css/paymentThemeLightDesktop.css +1 -1
- package/build/css/paymentThemeLightMobile.css +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1125,7 +1125,7 @@ declare type CounterProps = {
|
|
|
1125
1125
|
*
|
|
1126
1126
|
* @default 'medium'
|
|
1127
1127
|
*/
|
|
1128
|
-
size?: 'small' | 'medium';
|
|
1128
|
+
size?: 'small' | 'medium' | 'large';
|
|
1129
1129
|
};
|
|
1130
1130
|
declare const Counter: ({ value, max, intent, contrast, size, }: CounterProps) => React.ReactElement;
|
|
1131
1131
|
|
|
@@ -2007,16 +2007,19 @@ declare type TextCommonProps = {
|
|
|
2007
2007
|
contrast?: ColorContrastTypes;
|
|
2008
2008
|
truncateAfterLines?: number;
|
|
2009
2009
|
children: React.ReactNode;
|
|
2010
|
+
weight?: keyof Theme$1['typography']['fonts']['weight'];
|
|
2011
|
+
/**
|
|
2012
|
+
* **For Internal use only**: Sets the color of the Text component
|
|
2013
|
+
*/
|
|
2014
|
+
color?: BaseTextProps['color'];
|
|
2010
2015
|
};
|
|
2011
2016
|
declare type TextVariant = 'body' | 'caption';
|
|
2012
2017
|
declare type TextBodyVariant = TextCommonProps & {
|
|
2013
2018
|
variant?: Extract<TextVariant, 'body'>;
|
|
2014
|
-
weight?: keyof Theme$1['typography']['fonts']['weight'];
|
|
2015
2019
|
size?: 'small' | 'medium';
|
|
2016
2020
|
};
|
|
2017
2021
|
declare type TextCaptionVariant = TextCommonProps & {
|
|
2018
2022
|
variant?: Extract<TextVariant, 'caption'>;
|
|
2019
|
-
weight?: keyof Pick<Theme$1['typography']['fonts']['weight'], 'regular'>;
|
|
2020
2023
|
size?: 'medium';
|
|
2021
2024
|
};
|
|
2022
2025
|
/**
|
|
@@ -2034,7 +2037,7 @@ declare const getTextProps: <T extends {
|
|
|
2034
2037
|
}>({ variant, type, weight, size, contrast, }: Pick<TextProps<T>, "type" | "size" | "contrast" | "weight" | "variant">) => Omit<BaseTextProps, 'children'> & TextForwardedAs;
|
|
2035
2038
|
declare const Text: <T extends {
|
|
2036
2039
|
variant: TextVariant;
|
|
2037
|
-
}>({ variant, weight, size, type, contrast, truncateAfterLines, children, }: TextProps<T>) => ReactElement;
|
|
2040
|
+
}>({ variant, weight, size, type, contrast, truncateAfterLines, children, color, }: TextProps<T>) => ReactElement;
|
|
2038
2041
|
|
|
2039
2042
|
declare type CodeProps = {
|
|
2040
2043
|
children: string;
|
|
@@ -1125,7 +1125,7 @@ declare type CounterProps = {
|
|
|
1125
1125
|
*
|
|
1126
1126
|
* @default 'medium'
|
|
1127
1127
|
*/
|
|
1128
|
-
size?: 'small' | 'medium';
|
|
1128
|
+
size?: 'small' | 'medium' | 'large';
|
|
1129
1129
|
};
|
|
1130
1130
|
declare const Counter: ({ value, max, intent, contrast, size, }: CounterProps) => React.ReactElement;
|
|
1131
1131
|
|
|
@@ -1995,16 +1995,19 @@ declare type TextCommonProps = {
|
|
|
1995
1995
|
contrast?: ColorContrastTypes;
|
|
1996
1996
|
truncateAfterLines?: number;
|
|
1997
1997
|
children: React.ReactNode;
|
|
1998
|
+
weight?: keyof Theme$1['typography']['fonts']['weight'];
|
|
1999
|
+
/**
|
|
2000
|
+
* **For Internal use only**: Sets the color of the Text component
|
|
2001
|
+
*/
|
|
2002
|
+
color?: BaseTextProps['color'];
|
|
1998
2003
|
};
|
|
1999
2004
|
declare type TextVariant = 'body' | 'caption';
|
|
2000
2005
|
declare type TextBodyVariant = TextCommonProps & {
|
|
2001
2006
|
variant?: Extract<TextVariant, 'body'>;
|
|
2002
|
-
weight?: keyof Theme$1['typography']['fonts']['weight'];
|
|
2003
2007
|
size?: 'small' | 'medium';
|
|
2004
2008
|
};
|
|
2005
2009
|
declare type TextCaptionVariant = TextCommonProps & {
|
|
2006
2010
|
variant?: Extract<TextVariant, 'caption'>;
|
|
2007
|
-
weight?: keyof Pick<Theme$1['typography']['fonts']['weight'], 'regular'>;
|
|
2008
2011
|
size?: 'medium';
|
|
2009
2012
|
};
|
|
2010
2013
|
/**
|
|
@@ -2022,7 +2025,7 @@ declare const getTextProps: <T extends {
|
|
|
2022
2025
|
}>({ variant, type, weight, size, contrast, }: Pick<TextProps<T>, "type" | "size" | "weight" | "contrast" | "variant">) => Omit<BaseTextProps, 'children'> & TextForwardedAs;
|
|
2023
2026
|
declare const Text: <T extends {
|
|
2024
2027
|
variant: TextVariant;
|
|
2025
|
-
}>({ variant, weight, size, type, contrast, truncateAfterLines, children, }: TextProps<T>) => ReactElement;
|
|
2028
|
+
}>({ variant, weight, size, type, contrast, truncateAfterLines, children, color, }: TextProps<T>) => ReactElement;
|
|
2026
2029
|
|
|
2027
2030
|
declare type CodeProps = {
|
|
2028
2031
|
children: string;
|
|
@@ -3323,7 +3323,7 @@ var getProps$3=function getProps(_ref){var size=_ref.size,type=_ref.type,contras
|
|
|
3323
3323
|
|
|
3324
3324
|
var getProps$2=function getProps(_ref){var variant=_ref.variant,size=_ref.size,type=_ref.type,weight=_ref.weight,contrast=_ref.contrast;var isPlatformWeb=getPlatformType()==='browser'||getPlatformType()==='node';var colorContrast=contrast?contrast+"Contrast":'lowContrast';var props={color:"surface.text."+(type!=null?type:'normal')+"."+colorContrast,fontSize:200,fontWeight:weight!=null?weight:'bold',fontStyle:'normal',lineHeight:'xl',fontFamily:'text',accessibilityProps:isPlatformWeb?{}:{role:'heading'}};if(variant==='regular'){if(!size||size==='small'){props.fontSize=200;props.lineHeight='2xl';props.as=isPlatformWeb?'h6':undefined;}else if(size==='medium'){props.fontSize=300;props.lineHeight='3xl';props.as=isPlatformWeb?'h5':undefined;}else if(size==='large'){props.fontSize=400;props.lineHeight='3xl';props.as=isPlatformWeb?'h4':undefined;}}else if(variant==='subheading'){if(weight==='regular'){throw new Error("[Blade: Heading]: weight cannot be 'regular' when variant is 'subheading'");}if(size){throw new Error("[Blade: Heading]: size prop cannot be added when variant is 'subheading'. Use variant 'regular' or remove size prop");}props.fontSize=75;props.lineHeight='s';props.as=isPlatformWeb?'h6':undefined;}return props;};var Heading=function Heading(_ref2){var _ref2$variant=_ref2.variant,variant=_ref2$variant===void 0?'regular':_ref2$variant,size=_ref2.size,_ref2$type=_ref2.type,type=_ref2$type===void 0?'normal':_ref2$type,_ref2$weight=_ref2.weight,weight=_ref2$weight===void 0?'bold':_ref2$weight,_ref2$contrast=_ref2.contrast,contrast=_ref2$contrast===void 0?'low':_ref2$contrast,children=_ref2.children;var props=getProps$2({variant:variant,size:size,type:type,weight:weight,contrast:contrast});return jsx(BaseText,_extends({},props,{children:children}));};
|
|
3325
3325
|
|
|
3326
|
-
var getTextProps=function getTextProps(_ref){var variant=_ref.variant,type=_ref.type,weight=_ref.weight,size=_ref.size,contrast=_ref.contrast;var isPlatformWeb=getPlatformType()==='browser'||getPlatformType()==='node';var colorContrast=contrast?contrast+"Contrast":'lowContrast';var props={color:"surface.text."+(type!=null?type:'normal')+"."+colorContrast,fontSize:100,fontWeight:weight!=null?weight:'regular',fontStyle:'normal',lineHeight:'l',fontFamily:'text',forwardedAs:isPlatformWeb?'p':undefined};if(variant==='body'){if(size==='small'){props.fontSize=75;props.lineHeight='s';}}else if(variant==='caption'){if(weight==='bold'){throw new Error("[Blade: Text]: weight cannot be 'bold' when variant is 'caption'");}if(size==='small'){throw new Error("[Blade: Text]: size cannot be 'small' when variant is 'caption'");}props.fontSize=50;props.lineHeight='s';props.fontStyle='italic';}return props;};var StyledText=styled(BaseText)(function(_ref2){var truncateAfterLines=_ref2.truncateAfterLines;if(truncateAfterLines){if(getPlatformType()==='react-native'){return
|
|
3326
|
+
var getTextProps=function getTextProps(_ref){var variant=_ref.variant,type=_ref.type,weight=_ref.weight,size=_ref.size,contrast=_ref.contrast;var isPlatformWeb=getPlatformType()==='browser'||getPlatformType()==='node';var colorContrast=contrast?contrast+"Contrast":'lowContrast';var props={color:"surface.text."+(type!=null?type:'normal')+"."+colorContrast,fontSize:100,fontWeight:weight!=null?weight:'regular',fontStyle:'normal',lineHeight:'l',fontFamily:'text',forwardedAs:isPlatformWeb?'p':undefined};if(variant==='body'){if(size==='small'){props.fontSize=75;props.lineHeight='s';}}else if(variant==='caption'){if(weight==='bold'){throw new Error("[Blade: Text]: weight cannot be 'bold' when variant is 'caption'");}if(size==='small'){throw new Error("[Blade: Text]: size cannot be 'small' when variant is 'caption'");}props.fontSize=50;props.lineHeight='s';props.fontStyle='italic';}return props;};var StyledText=styled(BaseText)(function(_ref2){var truncateAfterLines=_ref2.truncateAfterLines;if(truncateAfterLines){if(getPlatformType()==='react-native'){return null;}return {overflow:'hidden',display:'-webkit-box','line-clamp':""+truncateAfterLines,'-webkit-line-clamp':""+truncateAfterLines,'-webkit-box-orient':'vertical'};}return {};});var Text=function Text(_ref3){var _ref3$variant=_ref3.variant,variant=_ref3$variant===void 0?'body':_ref3$variant,_ref3$weight=_ref3.weight,weight=_ref3$weight===void 0?'regular':_ref3$weight,_ref3$size=_ref3.size,size=_ref3$size===void 0?'medium':_ref3$size,_ref3$type=_ref3.type,type=_ref3$type===void 0?'normal':_ref3$type,_ref3$contrast=_ref3.contrast,contrast=_ref3$contrast===void 0?'low':_ref3$contrast,truncateAfterLines=_ref3.truncateAfterLines,children=_ref3.children,color=_ref3.color;var props=_extends({truncateAfterLines:truncateAfterLines},getTextProps({variant:variant,type:type,weight:weight,size:size,contrast:contrast}),color?{color:color}:{});return jsx(StyledText,_extends({},props,{children:children}));};
|
|
3327
3327
|
|
|
3328
3328
|
var platformType=getPlatformType();var isPlatformWeb=platformType==='browser'||platformType==='node';var getCodeFontSize=function getCodeFontSize(size){switch(size){case'medium':return 100;default:return 75;}};var CodeContainer=styled(Box)(function(props){var padding=makeSpace(props.theme.spacing[0])+" "+makeSpace(props.theme.spacing[2]);return {padding:padding,backgroundColor:props.theme.colors.brand.gray[400].lowContrast,borderRadius:props.theme.border.radius.medium,display:isPlatformWeb?'inline-block':undefined,lineHeight:makeTypographySize(props.theme.typography.lineHeights.s)};});var Code=function Code(_ref){var children=_ref.children,_ref$size=_ref.size,size=_ref$size===void 0?'small':_ref$size;return jsx(CodeContainer,{size:size,as:isPlatformWeb?'span':undefined,children:jsx(BaseText,{color:"surface.text.subtle.lowContrast",fontFamily:"code",fontSize:getCodeFontSize(size),as:isPlatformWeb?'code':undefined,children:children})});};
|
|
3329
3329
|
|
|
@@ -3355,17 +3355,23 @@ var _excluded$2=["currentInteraction","setCurrentInteraction"];var getColorToken
|
|
|
3355
3355
|
|
|
3356
3356
|
var isReactNative$3=getPlatformType()==='react-native';var SecondaryActionWrapper=isReactNative$3?Box:Fragment;var CloseButtonWrapper=isReactNative$3?Box:Fragment;var intentIconMap={positive:CheckCircleIcon,negative:AlertTriangleIcon,information:AlertTriangleIcon,notice:AlertTriangleIcon$1};var Alert=function Alert(_ref){var description=_ref.description,title=_ref.title,_ref$isDismissable=_ref.isDismissable,isDismissable=_ref$isDismissable===void 0?true:_ref$isDismissable,onDismiss=_ref.onDismiss,_ref$contrast=_ref.contrast,contrast=_ref$contrast===void 0?'low':_ref$contrast,_ref$isFullWidth=_ref.isFullWidth,isFullWidth=_ref$isFullWidth===void 0?false:_ref$isFullWidth,_ref$intent=_ref.intent,intent=_ref$intent===void 0?'information':_ref$intent,_ref$isBorderless=_ref.isBorderless,isBorderless=_ref$isBorderless===void 0?false:_ref$isBorderless,actions=_ref.actions;if(!(actions!=null&&actions.primary)&&actions!=null&&actions.secondary){throw new Error('[Blade: Alert]: SecondaryAction is allowed only when PrimaryAction is defined.');}var _useState=useState(true),_useState2=_slicedToArray(_useState,2),isVisible=_useState2[0],setIsVisible=_useState2[1];var contrastType=contrast+"Contrast";var Icon=intentIconMap[intent];var icon=jsx(Icon,{color:"feedback.icon."+intent+"."+contrastType,size:"large"});var _title=title?jsx(Box,{marginBottom:"spacing.2",children:jsx(Heading,{size:"small",contrast:contrast,children:title})}):null;var _description=jsx(Text,{contrast:contrast,children:description});var primaryAction=actions!=null&&actions.primary?jsx(Box,{marginRight:"spacing.5",display:isReactNative$3?'flex':'inline-flex',children:jsx(BaseButton,{onClick:actions.primary.onClick,intent:intent,contrast:contrast,children:actions.primary.text})}):null;var secondaryActionParams=actions!=null&&actions.secondary?{onClick:actions.secondary.onClick}:null;if(actions!=null&&actions.secondary&&secondaryActionParams&&'href'in actions.secondary){secondaryActionParams.href=actions.secondary.href;secondaryActionParams.target=actions.secondary.target;secondaryActionParams.rel=actions.secondary.rel;}var secondaryAction=actions!=null&&actions.secondary?jsx(SecondaryActionWrapper,{children:jsx(BaseLink,_extends({contrast:contrast,intent:intent},secondaryActionParams,{children:actions.secondary.text}))}):null;var _actions=primaryAction||secondaryAction?jsxs(Box,{marginTop:"spacing.4",flexDirection:"row",alignItems:"center",children:[primaryAction,secondaryAction]}):null;var onClickDismiss=function onClickDismiss(){if(onDismiss){onDismiss();}setIsVisible(false);};var closeButton=isDismissable?jsx(CloseButtonWrapper,{children:jsx(IconButton,{accessibilityLabel:"Dismiss alert",onClick:onClickDismiss,contrast:contrast,size:"large",icon:CloseIcon})}):null;var a11yProps=makeAccessible(_extends({role:isReactNative$3||intent==='negative'||intent==='notice'?'alert':'status'},intent==='notice'&&{liveRegion:'polite'}));if(!isVisible){return null;}return jsxs(StyledAlert,_extends({intent:intent,contrastType:contrastType,isFullWidth:isFullWidth,isBorderless:isBorderless},a11yProps,{children:[icon,jsxs(Box,{flex:1,paddingLeft:"spacing.4",paddingRight:"spacing.2",children:[_title,_description,_actions]}),closeButton]}));};
|
|
3357
3357
|
|
|
3358
|
-
var minHeight={small:20,medium:24};var maxWidth={onMobile:100,onDesktop:120};
|
|
3358
|
+
var minHeight={small:20,medium:24};var maxWidth$1={onMobile:100,onDesktop:120};
|
|
3359
3359
|
|
|
3360
|
-
var getStyledBadgeStyles=function getStyledBadgeStyles(_ref){var theme=_ref.theme,size=_ref.size,platform=_ref.platform,backgroundColor=_ref.backgroundColor;return {backgroundColor:get_1(theme.colors,backgroundColor),minHeight:makeSize(minHeight[size]),borderRadius:makeBorderSize(theme.border.radius.max),maxWidth:makeSize(maxWidth[platform]),display:'flex',flexWrap:'nowrap'};};
|
|
3360
|
+
var getStyledBadgeStyles=function getStyledBadgeStyles(_ref){var theme=_ref.theme,size=_ref.size,platform=_ref.platform,backgroundColor=_ref.backgroundColor;return {backgroundColor:get_1(theme.colors,backgroundColor),minHeight:makeSize(minHeight[size]),borderRadius:makeBorderSize(theme.border.radius.max),maxWidth:makeSize(maxWidth$1[platform]),display:'flex',flexWrap:'nowrap'};};
|
|
3361
3361
|
|
|
3362
3362
|
var StyledBadge=styled.View(function(props){return _extends({},getStyledBadgeStyles(props),{alignSelf:'center'});});
|
|
3363
3363
|
|
|
3364
|
-
var isFeedbackVariant=function isFeedbackVariant(variant){var feedbackVariants=['information','negative','neutral','notice','positive'];return feedbackVariants.includes(variant);};var getColorProps=function getColorProps(_ref){var variant=_ref.variant,contrast=_ref.contrast;var props={iconColor:'feedback.icon.neutral.lowContrast',textColor:'feedback.text.neutral.lowContrast',backgroundColor:'feedback.background.neutral.lowContrast'};if(isFeedbackVariant(variant)){props.iconColor="feedback.icon."+variant+"."+contrast+"Contrast";props.textColor="feedback.text."+variant+"."+contrast+"Contrast";props.backgroundColor="feedback.background."+variant+"."+contrast+"Contrast";}else {props.iconColor="badge.icon."+variant+"."+contrast+"Contrast";props.textColor="badge.text."+variant+"."+contrast+"Contrast";props.backgroundColor="badge.background."+variant+"."+contrast+"Contrast";}return props;};var StyledBaseText=styled(BaseText)(function(){if(getPlatformType()!=='react-native'){return {whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'};}return {};});var Badge=function Badge(_ref2){var children=_ref2.children,_ref2$contrast=_ref2.contrast,contrast=_ref2$contrast===void 0?'low':_ref2$contrast,_ref2$fontWeight=_ref2.fontWeight,fontWeight=_ref2$fontWeight===void 0?'regular':_ref2$fontWeight,Icon=_ref2.icon,_ref2$size=_ref2.size,size=_ref2$size===void 0?'medium':_ref2$size,_ref2$variant=_ref2.variant,variant=_ref2$variant===void 0?'neutral':_ref2$variant;if(!(children!=null&&children.trim())){throw new Error('[Blade: Badge]: Text as children is required for Badge.');}var _useTheme=useTheme(),platform=_useTheme.platform;var _getColorProps=getColorProps({variant:variant,contrast:contrast}),backgroundColor=_getColorProps.backgroundColor,iconColor=_getColorProps.iconColor,textColor=_getColorProps.textColor;return jsx(StyledBadge,{backgroundColor:backgroundColor,size:size,platform:platform,children:jsxs(Box,{paddingRight:"spacing.3",paddingLeft:"spacing.3",display:"flex",flex:1,flexDirection:"row",justifyContent:"center",alignItems:"center",overflow:"hidden",children:[Icon?jsx(Box,{paddingRight:Boolean(Icon)?'spacing.2':'spacing.0',display:"flex",children:jsx(Icon,{color:iconColor,size:"small"})}):null,jsx(StyledBaseText,{fontSize:75,fontWeight:fontWeight,lineHeight:"s",color:textColor,textAlign:"center",truncateAfterLines:1,children:children})]})});};
|
|
3364
|
+
var isFeedbackVariant=function isFeedbackVariant(variant){var feedbackVariants=['information','negative','neutral','notice','positive'];return feedbackVariants.includes(variant);};var getColorProps$1=function getColorProps(_ref){var variant=_ref.variant,contrast=_ref.contrast;var props={iconColor:'feedback.icon.neutral.lowContrast',textColor:'feedback.text.neutral.lowContrast',backgroundColor:'feedback.background.neutral.lowContrast'};if(isFeedbackVariant(variant)){props.iconColor="feedback.icon."+variant+"."+contrast+"Contrast";props.textColor="feedback.text."+variant+"."+contrast+"Contrast";props.backgroundColor="feedback.background."+variant+"."+contrast+"Contrast";}else {props.iconColor="badge.icon."+variant+"."+contrast+"Contrast";props.textColor="badge.text."+variant+"."+contrast+"Contrast";props.backgroundColor="badge.background."+variant+"."+contrast+"Contrast";}return props;};var StyledBaseText=styled(BaseText)(function(){if(getPlatformType()!=='react-native'){return {whiteSpace:'nowrap',overflow:'hidden',textOverflow:'ellipsis'};}return {};});var Badge=function Badge(_ref2){var children=_ref2.children,_ref2$contrast=_ref2.contrast,contrast=_ref2$contrast===void 0?'low':_ref2$contrast,_ref2$fontWeight=_ref2.fontWeight,fontWeight=_ref2$fontWeight===void 0?'regular':_ref2$fontWeight,Icon=_ref2.icon,_ref2$size=_ref2.size,size=_ref2$size===void 0?'medium':_ref2$size,_ref2$variant=_ref2.variant,variant=_ref2$variant===void 0?'neutral':_ref2$variant;if(!(children!=null&&children.trim())){throw new Error('[Blade: Badge]: Text as children is required for Badge.');}var _useTheme=useTheme(),platform=_useTheme.platform;var _getColorProps=getColorProps$1({variant:variant,contrast:contrast}),backgroundColor=_getColorProps.backgroundColor,iconColor=_getColorProps.iconColor,textColor=_getColorProps.textColor;return jsx(StyledBadge,{backgroundColor:backgroundColor,size:size,platform:platform,children:jsxs(Box,{paddingRight:"spacing.3",paddingLeft:"spacing.3",display:"flex",flex:1,flexDirection:"row",justifyContent:"center",alignItems:"center",overflow:"hidden",children:[Icon?jsx(Box,{paddingRight:Boolean(Icon)?'spacing.2':'spacing.0',display:"flex",children:jsx(Icon,{color:iconColor,size:"small"})}):null,jsx(StyledBaseText,{fontSize:75,fontWeight:fontWeight,lineHeight:"s",color:textColor,textAlign:"center",truncateAfterLines:1,children:children})]})});};
|
|
3365
3365
|
|
|
3366
3366
|
var Button=function Button(_ref){var children=_ref.children,icon=_ref.icon,_ref$iconPosition=_ref.iconPosition,iconPosition=_ref$iconPosition===void 0?'left':_ref$iconPosition,_ref$isDisabled=_ref.isDisabled,isDisabled=_ref$isDisabled===void 0?false:_ref$isDisabled,_ref$isFullWidth=_ref.isFullWidth,isFullWidth=_ref$isFullWidth===void 0?false:_ref$isFullWidth,_ref$isLoading=_ref.isLoading,isLoading=_ref$isLoading===void 0?false:_ref$isLoading,onClick=_ref.onClick,_ref$size=_ref.size,size=_ref$size===void 0?'medium':_ref$size,_ref$type=_ref.type,type=_ref$type===void 0?'button':_ref$type,_ref$variant=_ref.variant,variant=_ref$variant===void 0?'primary':_ref$variant,accessibilityLabel=_ref.accessibilityLabel;return jsx(BaseButton,_extends({},icon?{icon:icon,children:children}:{children:children},{accessibilityLabel:accessibilityLabel,iconPosition:iconPosition,isDisabled:isDisabled,isFullWidth:isFullWidth,onClick:onClick,size:size,type:type,variant:variant,isLoading:isLoading}));};
|
|
3367
3367
|
|
|
3368
|
-
var
|
|
3368
|
+
var verticalPadding={small:'spacing.0',medium:'spacing.1',large:'spacing.1'};var horizontalPadding={small:'spacing.2',medium:'spacing.3',large:'spacing.3'};var maxWidth={onMobile:100,onDesktop:120};
|
|
3369
|
+
|
|
3370
|
+
var getStyledCounterStyles=function getStyledCounterStyles(_ref){var theme=_ref.theme,platform=_ref.platform,backgroundColor=_ref.backgroundColor;return {backgroundColor:get_1(theme.colors,backgroundColor),borderRadius:makeBorderSize(theme.border.radius.max),maxWidth:makeSize(maxWidth[platform]),display:'flex',flexWrap:'nowrap'};};
|
|
3371
|
+
|
|
3372
|
+
var StyledCounter=styled.View(function(props){return _extends({},getStyledCounterStyles(props),{alignSelf:'center'});});
|
|
3373
|
+
|
|
3374
|
+
var getColorProps=function getColorProps(_ref){var _ref$intent=_ref.intent,intent=_ref$intent===void 0?'neutral':_ref$intent,_ref$contrast=_ref.contrast,contrast=_ref$contrast===void 0?'low':_ref$contrast;var props={textColor:"feedback.text."+intent+"."+contrast+"Contrast",backgroundColor:"feedback.background."+intent+"."+contrast+"Contrast"};return props;};var Counter=function Counter(_ref2){var value=_ref2.value,max=_ref2.max,_ref2$intent=_ref2.intent,intent=_ref2$intent===void 0?'neutral':_ref2$intent,_ref2$contrast=_ref2.contrast,contrast=_ref2$contrast===void 0?'low':_ref2$contrast,_ref2$size=_ref2.size,size=_ref2$size===void 0?'medium':_ref2$size;var content=""+value;if(max&&value>max){content=max+"+";}var _useTheme=useTheme(),platform=_useTheme.platform;var _getColorProps=getColorProps({intent:intent,contrast:contrast}),backgroundColor=_getColorProps.backgroundColor,textColor=_getColorProps.textColor;var textSizes={small:{variant:'caption'},medium:{variant:'body',size:'small'},large:{variant:'body',size:'medium'}};return jsx(StyledCounter,{backgroundColor:backgroundColor,size:size,platform:platform,children:jsx(Box,{paddingRight:horizontalPadding[size],paddingLeft:horizontalPadding[size],paddingTop:verticalPadding[size],paddingBottom:verticalPadding[size],display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",overflow:"hidden",children:jsx(Text,_extends({},textSizes[size],{type:"normal",weight:"regular",truncateAfterLines:1,color:textColor,children:content}))})});};
|
|
3369
3375
|
|
|
3370
3376
|
/**
|
|
3371
3377
|
* Checks if `value` is `undefined`.
|