@razorpay/blade 11.1.1 → 11.2.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/build/lib/native/components/Amount/Amount.js +4 -3
- package/build/lib/native/components/Amount/Amount.js.map +1 -1
- package/build/lib/native/components/Amount/amountTokens.js +2 -2
- package/build/lib/native/components/Amount/amountTokens.js.map +1 -1
- package/build/lib/web/development/components/Amount/Amount.js +107 -106
- package/build/lib/web/development/components/Amount/Amount.js.map +1 -1
- package/build/lib/web/development/components/Amount/amountTokens.js +1 -415
- package/build/lib/web/development/components/Amount/amountTokens.js.map +1 -1
- package/build/lib/web/production/components/Amount/Amount.js +107 -106
- package/build/lib/web/production/components/Amount/Amount.js.map +1 -1
- package/build/lib/web/production/components/Amount/amountTokens.js +1 -415
- package/build/lib/web/production/components/Amount/amountTokens.js.map +1 -1
- package/build/types/components/index.d.ts +4 -384
- package/build/types/components/index.native.d.ts +4 -384
- package/package.json +6 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { formatNumberByParts, formatNumber } from '@razorpay/i18nify-js/currency';
|
|
4
|
+
import { subtleFontSizes, normalAmountSizes, amountLineHeights } from './amountTokens.js';
|
|
4
5
|
import { BaseBox } from '../Box/BaseBox/BaseBox.native.js';
|
|
5
6
|
import 'react-native';
|
|
6
7
|
import { getPlatformType } from '../../utils/getPlatformType/getPlatformType.js';
|
|
@@ -20,7 +21,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
20
21
|
import { Text } from '../Typography/Text/Text.js';
|
|
21
22
|
import '../Typography/Code/Code.js';
|
|
22
23
|
|
|
23
|
-
var _excluded=["value","suffix","type","size","weight","isAffixSubtle","isStrikethrough","color","currencyIndicator","currency","testID"];var getTextColorProps=function getTextColorProps(_ref){var color=_ref.color;var props={amountValueColor:'surface.text.gray.normal'};if(!color)return props;props.amountValueColor=color;return props;};var AmountValue=function AmountValue(_ref2){var
|
|
24
|
+
var _excluded=["value","suffix","type","size","weight","isAffixSubtle","isStrikethrough","color","currencyIndicator","currency","testID"];var getTextColorProps=function getTextColorProps(_ref){var color=_ref.color;var props={amountValueColor:'surface.text.gray.normal'};if(!color)return props;props.amountValueColor=color;return props;};var AmountValue=function AmountValue(_ref2){var amount=_ref2.amount,_ref2$size=_ref2.size,size=_ref2$size===void 0?'medium':_ref2$size,_ref2$type=_ref2.type,type=_ref2$type===void 0?'body':_ref2$type,_ref2$weight=_ref2.weight,weight=_ref2$weight===void 0?'regular':_ref2$weight,amountValueColor=_ref2.amountValueColor,isAffixSubtle=_ref2.isAffixSubtle,suffix=_ref2.suffix;var isReactNative=getPlatformType()==='react-native';var affixFontSize=isAffixSubtle?subtleFontSizes[type][size]:normalAmountSizes[type][size];var numberFontFamily=type==='body'?'text':'heading';if(suffix==='decimals'&&isAffixSubtle){var AmountWrapper=isReactNative?Text:React__default.Fragment;return jsxs(AmountWrapper,{children:[jsx(BaseText,{fontSize:normalAmountSizes[type][size],fontWeight:weight,lineHeight:amountLineHeights[type][size],color:amountValueColor,fontFamily:numberFontFamily,as:isReactNative?undefined:'span',children:amount.integer}),jsxs(BaseText,{fontWeight:weight,fontSize:affixFontSize,fontFamily:numberFontFamily,color:amountValueColor,as:isReactNative?undefined:'span',opacity:isAffixSubtle?opacity[8]:1,children:[amount.decimal,amount.fraction]})]});}return jsx(BaseText,{fontSize:normalAmountSizes[type][size],fontWeight:weight,fontFamily:numberFontFamily,color:amountValueColor,lineHeight:amountLineHeights[type][size],children:amount.formatted});};var formatAmountWithSuffix=function formatAmountWithSuffix(_ref3){var suffix=_ref3.suffix,value=_ref3.value;try{switch(suffix){case'decimals':{var options={intlOptions:{maximumFractionDigits:2,minimumFractionDigits:2}};return Object.assign({},formatNumberByParts(value,options),{formatted:formatNumber(value,options)});}case'humanize':{var formatted=formatNumber(value,{intlOptions:{notation:'compact'}});return {formatted:formatted};}default:{var _formatted=formatNumber(value,{intlOptions:{maximumFractionDigits:0,roundingMode:'floor'}});return {formatted:_formatted};}}}catch(err){return {formatted:`${value}`};}};var _Amount=function _Amount(_ref4){var value=_ref4.value,_ref4$suffix=_ref4.suffix,suffix=_ref4$suffix===void 0?'decimals':_ref4$suffix,_ref4$type=_ref4.type,type=_ref4$type===void 0?'body':_ref4$type,_ref4$size=_ref4.size,size=_ref4$size===void 0?'medium':_ref4$size,_ref4$weight=_ref4.weight,weight=_ref4$weight===void 0?'regular':_ref4$weight,_ref4$isAffixSubtle=_ref4.isAffixSubtle,isAffixSubtle=_ref4$isAffixSubtle===void 0?true:_ref4$isAffixSubtle,_ref4$isStrikethrough=_ref4.isStrikethrough,isStrikethrough=_ref4$isStrikethrough===void 0?false:_ref4$isStrikethrough,color=_ref4.color,_ref4$currencyIndicat=_ref4.currencyIndicator,currencyIndicator=_ref4$currencyIndicat===void 0?'currency-symbol':_ref4$currencyIndicat,_ref4$currency=_ref4.currency,currency=_ref4$currency===void 0?'INR':_ref4$currency,testID=_ref4.testID,styledProps=_objectWithoutProperties(_ref4,_excluded);if(__DEV__){if(typeof value!=='number'){throwBladeError({message:'`value` prop must be of type `number` for Amount.',moduleName:'Amount'});}if(color==='neutral'){throwBladeError({message:'`neutral` color is not supported.',moduleName:'Amount'});}var bodySizes=objectKeysWithType(normalAmountSizes.body);if((type==='body'||!type)&&!bodySizes.includes(size)){throwBladeError({message:`size="${size}" is not allowed with type="body"`,moduleName:'Amount'});}var displaySizes=objectKeysWithType(normalAmountSizes.display);if(type==='display'&&!displaySizes.includes(size)){throwBladeError({message:`size="${size}" is not allowed with type="display"`,moduleName:'Amount'});}var headingSizes=objectKeysWithType(normalAmountSizes.heading);if(type==='heading'&&!headingSizes.includes(size)){throwBladeError({message:`size="${size}" is not allowed with type="heading"`,moduleName:'Amount'});}}var _getTextColorProps=getTextColorProps({color:color}),amountValueColor=_getTextColorProps.amountValueColor;var isPrefixSymbol,currencySymbol;try{var byParts=formatNumberByParts(value,{currency:currency});isPrefixSymbol=byParts.isPrefixSymbol;currencySymbol=byParts.currency;}catch(err){isPrefixSymbol=true;currencySymbol=currency;}var currencyPosition=isPrefixSymbol?'left':'right';var renderedValue=formatAmountWithSuffix({suffix:suffix,value:value});var currencySymbolOrCode=currencyIndicator==='currency-symbol'?currencySymbol:currency;var currencyFontSize=isAffixSubtle?subtleFontSizes[type][size]:normalAmountSizes[type][size];var isReactNative=getPlatformType()==='react-native';return jsx(BaseBox,Object.assign({display:isReactNative?'flex':'inline-flex',flexDirection:"row"},metaAttribute({name:MetaConstants.Amount,testID:testID}),getStyledProps(styledProps),{children:jsxs(BaseBox,{display:isReactNative?'flex':'inline-flex',alignItems:"baseline",flexDirection:"row",position:"relative",children:[currencyPosition==='left'&&jsx(BaseText,{marginRight:"spacing.1",fontWeight:weight,fontSize:currencyFontSize,color:amountValueColor,as:isReactNative?undefined:'span',opacity:isAffixSubtle?opacity[8]:1,children:currencySymbolOrCode}),jsx(AmountValue,{amount:renderedValue,amountValueColor:amountValueColor,type:type,weight:weight,size:size,isAffixSubtle:isAffixSubtle,suffix:suffix,currency:currency}),currencyPosition==='right'&&jsx(BaseText,{marginLeft:"spacing.1",fontWeight:weight,fontSize:currencyFontSize,color:amountValueColor,as:isReactNative?undefined:'span',opacity:isAffixSubtle?opacity[8]:1,children:currencySymbolOrCode}),isStrikethrough&&jsx(BaseBox,{borderBottomColor:amountValueColor,borderBottomWidth:type==='body'?'thin':'thicker',borderBottomStyle:"solid",position:"absolute",width:"100%",top:"50%"})]})}));};var Amount=assignWithoutSideEffects(_Amount,{displayName:'Amount',componentId:'Amount'});
|
|
24
25
|
|
|
25
|
-
export { Amount,
|
|
26
|
+
export { Amount, formatAmountWithSuffix };
|
|
26
27
|
//# sourceMappingURL=Amount.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Amount.js","sources":["../../../../../src/components/Amount/Amount.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React from 'react';\nimport type { AmountTypeProps, Currency } from './amountTokens';\nimport {\n normalAmountSizes,\n getCurrencyAbbreviations,\n currencyIndicatorMapping,\n subtleFontSizes,\n amountLineHeights,\n currencyPositionMapping,\n} from './amountTokens';\nimport type { BaseTextProps } from '~components/Typography/BaseText/types';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { TestID } from '~utils/types';\nimport { getPlatformType } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { objectKeysWithType } from '~utils/objectKeysWithType';\nimport { BaseText } from '~components/Typography/BaseText';\nimport { Text } from '~components/Typography';\nimport { opacity } from '~tokens/global';\nimport type { FontFamily } from '~tokens/global';\n\ntype AmountCommonProps = {\n /**\n * The value to be rendered within the component.\n *\n */\n value: number;\n /**\n * Sets the color of the amount.\n *\n * @default undefined\n */\n color?: BaseTextProps['color'];\n /**\n * Indicates what the suffix of amount should be\n *\n * @default 'decimals'\n */\n suffix?: 'decimals' | 'none' | 'humanize';\n /**\n * Makes the currency indicator(currency symbol/code) and decimal digits small and faded\n *\n * @default true\n */\n isAffixSubtle?: true | false;\n /**\n * Determines the visual representation of the currency, choose between displaying the currency symbol or code.\n *\n * @default 'currency-symbol'\n */\n currencyIndicator?: 'currency-symbol' | 'currency-code';\n /**\n * The currency of the amount. Note that this component\n * only displays the provided value in the specified currency, it does not perform any currency conversion.\n *\n * @default 'INR'\n * */\n currency?: Currency;\n /**\n * If true, the amount text will have a line through it.\n *\n * @default false\n */\n isStrikethrough?: boolean;\n} & TestID &\n StyledPropsBlade;\n\ntype ColorProps = {\n amountValueColor: BaseTextProps['color'];\n};\n\ntype AmountProps = AmountTypeProps & AmountCommonProps;\n\nconst getTextColorProps = ({ color }: { color: AmountProps['color'] }): ColorProps => {\n const props: ColorProps = {\n amountValueColor: 'surface.text.gray.normal',\n };\n if (!color) return props;\n props.amountValueColor = color;\n return props;\n};\n\ninterface AmountValue extends Omit<AmountProps, 'value'> {\n amountValueColor: BaseTextProps['color'];\n value: string;\n size: Exclude<AmountProps['size'], undefined>;\n}\n\nconst AmountValue = ({\n value,\n size = 'medium',\n type = 'body',\n weight = 'regular',\n amountValueColor,\n isAffixSubtle,\n suffix,\n}: AmountValue): ReactElement => {\n const isReactNative = getPlatformType() === 'react-native';\n const affixFontSize = isAffixSubtle ? subtleFontSizes[type][size] : normalAmountSizes[type][size];\n const numberFontFamily: keyof FontFamily = type === 'body' ? 'text' : 'heading';\n if (suffix === 'decimals' && isAffixSubtle) {\n const integer = value.split('.')[0];\n const decimal = value.split('.')[1];\n\n // Native does not support alignItems of Text inside a div, instead we need to wrap is in a Text\n const AmountWrapper = isReactNative ? Text : React.Fragment;\n\n return (\n <AmountWrapper>\n <BaseText\n fontSize={normalAmountSizes[type][size]}\n fontWeight={weight}\n lineHeight={amountLineHeights[type][size]}\n color={amountValueColor}\n fontFamily={numberFontFamily}\n as={isReactNative ? undefined : 'span'}\n >\n {integer}\n </BaseText>\n <BaseText\n fontWeight={weight}\n fontSize={affixFontSize}\n fontFamily={numberFontFamily}\n color={amountValueColor}\n as={isReactNative ? undefined : 'span'}\n opacity={isAffixSubtle ? opacity[8] : 1}\n >\n .{decimal || '00'}\n </BaseText>\n </AmountWrapper>\n );\n }\n return (\n <BaseText\n fontSize={normalAmountSizes[type][size]}\n fontWeight={weight}\n fontFamily={numberFontFamily}\n color={amountValueColor}\n lineHeight={amountLineHeights[type][size]}\n >\n {value}\n </BaseText>\n );\n};\n\n// This function rounds a number to a specified number of decimal places\n// and floors the result.\nexport const getFlooredFixed = (value: number, decimalPlaces: number): number => {\n const factor = 100 ** decimalPlaces;\n const roundedValue = Math.floor(value * factor) / factor;\n return Number(roundedValue.toFixed(decimalPlaces));\n};\n\nexport const addCommas = (amountValue: number, currency: Currency, decimalPlaces = 0): string => {\n // If the currency is 'INR', set the locale to 'en-IN' (Indian English).\n // Otherwise, set the locale to 'en-US' (U.S. English).\n const locale = currency === 'INR' ? 'en-IN' : 'en-US';\n return amountValue.toLocaleString(locale, { minimumFractionDigits: decimalPlaces });\n};\n/**\n * This function returns the humanized amount\n * ie: for INR 2000 => 2K\n * for MYR 2000000 => 2M\n */\nexport const getHumanizedAmount = ({\n value,\n currency,\n denominationPosition = 'right',\n}: {\n value: number;\n currency: Currency;\n denominationPosition?: 'left' | 'right';\n}): string => {\n let amountValue = value;\n const abbreviations = getCurrencyAbbreviations(currency);\n const abbreviation = abbreviations.find((abbr) => amountValue >= abbr.value);\n\n if (abbreviation) {\n amountValue = amountValue / abbreviation.value;\n const formattedAmountValue = getFlooredFixed(amountValue, 2);\n\n if (denominationPosition === 'right') {\n return `${addCommas(formattedAmountValue, currency)}${abbreviation.symbol}`;\n }\n\n return `${abbreviation.symbol}${addCommas(formattedAmountValue, currency)}`;\n }\n\n return amountValue.toString();\n};\n\ntype FormatAmountWithSuffixType = {\n suffix: AmountProps['suffix'];\n value: number;\n currency: Currency;\n denominationPosition?: 'left' | 'right';\n};\n\nexport const formatAmountWithSuffix = ({\n suffix,\n value,\n currency,\n denominationPosition,\n}: FormatAmountWithSuffixType): string => {\n switch (suffix) {\n case 'decimals': {\n const decimalNumber = getFlooredFixed(value, 2);\n return addCommas(decimalNumber, currency, 2);\n }\n case 'humanize': {\n return getHumanizedAmount({ value, currency, denominationPosition });\n }\n case 'none': {\n return addCommas(getFlooredFixed(value, 0), currency);\n }\n default:\n return addCommas(getFlooredFixed(value, 0), currency);\n }\n};\n\nconst _Amount = ({\n value,\n suffix = 'decimals',\n type = 'body',\n size = 'medium',\n weight = 'regular',\n isAffixSubtle = true,\n isStrikethrough = false,\n color,\n currencyIndicator = 'currency-symbol',\n currency = 'INR',\n testID,\n ...styledProps\n}: AmountProps): ReactElement => {\n if (__DEV__) {\n if (typeof value !== 'number') {\n throwBladeError({\n message: '`value` prop must be of type `number` for Amount.',\n moduleName: 'Amount',\n });\n }\n // @ts-expect-error neutral color should throw error\n if (color === 'neutral') {\n throwBladeError({\n message: '`neutral` color is not supported.',\n moduleName: 'Amount',\n });\n }\n\n const bodySizes = objectKeysWithType(normalAmountSizes.body);\n if ((type === 'body' || !type) && !bodySizes.includes(size)) {\n throwBladeError({\n message: `size=\"${size}\" is not allowed with type=\"body\"`,\n moduleName: 'Amount',\n });\n }\n\n const displaySizes = objectKeysWithType(normalAmountSizes.display);\n if (type === 'display' && !displaySizes.includes(size)) {\n throwBladeError({\n message: `size=\"${size}\" is not allowed with type=\"display\"`,\n moduleName: 'Amount',\n });\n }\n\n const headingSizes = objectKeysWithType(normalAmountSizes.heading);\n if (type === 'heading' && !headingSizes.includes(size)) {\n throwBladeError({\n message: `size=\"${size}\" is not allowed with type=\"heading\"`,\n moduleName: 'Amount',\n });\n }\n }\n\n const currencySymbolOrCode = currencyIndicatorMapping[currency][currencyIndicator];\n const currencyPosition = currencyPositionMapping[currency] || 'left';\n const denominationPosition = currencyPosition === 'left' ? 'right' : 'left';\n const renderedValue = formatAmountWithSuffix({ suffix, value, currency, denominationPosition });\n const { amountValueColor } = getTextColorProps({\n color,\n });\n\n const currencyFontSize = isAffixSubtle\n ? subtleFontSizes[type][size]\n : normalAmountSizes[type][size];\n const isReactNative = getPlatformType() === 'react-native';\n\n return (\n <BaseBox\n display={(isReactNative ? 'flex' : 'inline-flex') as never}\n flexDirection=\"row\"\n {...metaAttribute({ name: MetaConstants.Amount, testID })}\n {...getStyledProps(styledProps)}\n >\n <BaseBox\n display={(isReactNative ? 'flex' : 'inline-flex') as never}\n alignItems=\"baseline\"\n flexDirection=\"row\"\n position=\"relative\"\n >\n {currencyPosition === 'left' && (\n <BaseText\n marginRight=\"spacing.1\"\n fontWeight={weight}\n fontSize={currencyFontSize}\n color={amountValueColor}\n as={isReactNative ? undefined : 'span'}\n opacity={isAffixSubtle ? opacity[8] : 1}\n >\n {currencySymbolOrCode}\n </BaseText>\n )}\n <AmountValue\n value={renderedValue}\n amountValueColor={amountValueColor}\n type={type}\n weight={weight}\n size={size}\n isAffixSubtle={isAffixSubtle}\n suffix={suffix}\n />\n {currencyPosition === 'right' && (\n <BaseText\n marginLeft=\"spacing.1\"\n fontWeight={weight}\n fontSize={currencyFontSize}\n color={amountValueColor}\n as={isReactNative ? undefined : 'span'}\n opacity={isAffixSubtle ? opacity[8] : 1}\n >\n {currencySymbolOrCode}\n </BaseText>\n )}\n {isStrikethrough && (\n <BaseBox\n // @ts-expect-error - intentionally setting the border color to the color prop for this hacky strikethrough\n borderBottomColor={amountValueColor}\n borderBottomWidth={type === 'body' ? 'thin' : 'thicker'}\n borderBottomStyle=\"solid\"\n position=\"absolute\"\n width=\"100%\"\n top=\"50%\"\n />\n )}\n </BaseBox>\n </BaseBox>\n );\n};\n\nconst Amount = assignWithoutSideEffects(_Amount, {\n displayName: 'Amount',\n componentId: 'Amount',\n});\n\nexport type { AmountProps };\nexport { Amount };\n"],"names":["getTextColorProps","_ref","color","props","amountValueColor","AmountValue","_ref2","value","_ref2$size","size","_ref2$type","type","_ref2$weight","weight","isAffixSubtle","suffix","isReactNative","getPlatformType","affixFontSize","subtleFontSizes","normalAmountSizes","numberFontFamily","integer","split","decimal","AmountWrapper","Text","React","Fragment","_jsxs","children","_jsx","BaseText","fontSize","fontWeight","lineHeight","amountLineHeights","fontFamily","as","undefined","opacity","getFlooredFixed","decimalPlaces","factor","roundedValue","Math","floor","Number","toFixed","addCommas","amountValue","currency","arguments","length","locale","toLocaleString","minimumFractionDigits","getHumanizedAmount","_ref3","_ref3$denominationPos","denominationPosition","abbreviations","getCurrencyAbbreviations","abbreviation","find","abbr","formattedAmountValue","symbol","toString","formatAmountWithSuffix","_ref4","decimalNumber","_Amount","_ref5","_ref5$suffix","_ref5$type","_ref5$size","_ref5$weight","_ref5$isAffixSubtle","_ref5$isStrikethrough","isStrikethrough","_ref5$currencyIndicat","currencyIndicator","_ref5$currency","testID","styledProps","_objectWithoutProperties","_excluded","__DEV__","throwBladeError","message","moduleName","bodySizes","objectKeysWithType","body","includes","displaySizes","display","headingSizes","heading","currencySymbolOrCode","currencyIndicatorMapping","currencyPosition","currencyPositionMapping","renderedValue","_getTextColorProps","currencyFontSize","BaseBox","Object","assign","flexDirection","metaAttribute","name","MetaConstants","Amount","getStyledProps","alignItems","position","marginRight","marginLeft","borderBottomColor","borderBottomWidth","borderBottomStyle","width","top","assignWithoutSideEffects","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,MAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA,CAAA,iBAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,UAAA,CAAA,QAAA,CAAA,CA6EA,IAAMA,iBAAiB,CAAG,SAApBA,iBAAiBA,CAAAC,IAAA,CAA+D,CAAA,IAAzDC,KAAK,CAAAD,IAAA,CAALC,KAAK,CAChC,IAAMC,KAAiB,CAAG,CACxBC,gBAAgB,CAAE,0BACpB,CAAC,CACD,GAAI,CAACF,KAAK,CAAE,OAAOC,KAAK,CACxBA,KAAK,CAACC,gBAAgB,CAAGF,KAAK,CAC9B,OAAOC,KAAK,CACd,CAAC,CAQD,IAAME,WAAW,CAAG,SAAdA,WAAWA,CAAAC,KAAA,CAQgB,KAP/BC,KAAK,CAAAD,KAAA,CAALC,KAAK,CAAAC,UAAA,CAAAF,KAAA,CACLG,IAAI,CAAJA,IAAI,CAAAD,UAAA,GAAA,KAAA,CAAA,CAAG,QAAQ,CAAAA,UAAA,CAAAE,UAAA,CAAAJ,KAAA,CACfK,IAAI,CAAJA,IAAI,CAAAD,UAAA,GAAG,KAAA,CAAA,CAAA,MAAM,CAAAA,UAAA,CAAAE,YAAA,CAAAN,KAAA,CACbO,MAAM,CAANA,MAAM,CAAAD,YAAA,UAAG,SAAS,CAAAA,YAAA,C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iB,CAAE9G,IAAI,GAAK,MAAM,CAAG,MAAM,CAAG,SAAU,CACxD+G,iBAAiB,CAAC,OAAO,CACzBL,QAAQ,CAAC,UAAU,CACnBM,KAAK,CAAC,MAAM,CACZC,GAAG,CAAC,KAAK,CACV,CACF,CACM,CAAA,CAAC,EACH,CAAC,CAEd,CAAC,CAEK,IAAAV,MAAM,CAAGW,wBAAwB,CAACrD,OAAO,CAAE,CAC/CsD,WAAW,CAAE,QAAQ,CACrBC,WAAW,CAAE,QACf,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"Amount.js","sources":["../../../../../src/components/Amount/Amount.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport React from 'react';\nimport type { CurrencyCodeType } from '@razorpay/i18nify-js/currency';\nimport { formatNumber, formatNumberByParts } from '@razorpay/i18nify-js/currency';\nimport type { AmountTypeProps } from './amountTokens';\nimport { normalAmountSizes, subtleFontSizes, amountLineHeights } from './amountTokens';\nimport type { BaseTextProps } from '~components/Typography/BaseText/types';\nimport BaseBox from '~components/Box/BaseBox';\nimport type { TestID } from '~utils/types';\nimport { getPlatformType } from '~utils';\nimport { metaAttribute, MetaConstants } from '~utils/metaAttribute';\nimport { getStyledProps } from '~components/Box/styledProps';\nimport type { StyledPropsBlade } from '~components/Box/styledProps';\nimport { assignWithoutSideEffects } from '~utils/assignWithoutSideEffects';\nimport { throwBladeError } from '~utils/logger';\nimport { objectKeysWithType } from '~utils/objectKeysWithType';\nimport { BaseText } from '~components/Typography/BaseText';\nimport { Text } from '~components/Typography';\nimport { opacity } from '~tokens/global';\nimport type { FontFamily } from '~tokens/global';\n\ntype AmountCommonProps = {\n /**\n * The value to be rendered within the component.\n *\n */\n value: number;\n /**\n * Sets the color of the amount.\n *\n * @default undefined\n */\n color?: BaseTextProps['color'];\n /**\n * Indicates what the suffix of amount should be\n *\n * @default 'decimals'\n */\n suffix?: 'decimals' | 'none' | 'humanize';\n /**\n * Makes the currency indicator(currency symbol/code) and decimal digits small and faded\n *\n * @default true\n */\n isAffixSubtle?: true | false;\n /**\n * Determines the visual representation of the currency, choose between displaying the currency symbol or code.\n *\n * Note: Currency symbol and code is determined by the locale set in user's browser or set via @razorpay/i18nify-react library.\n *\n * @default 'currency-symbol'\n */\n currencyIndicator?: 'currency-symbol' | 'currency-code';\n /**\n * The currency of the amount. Note that this component\n * only displays the provided value in the specified currency, it does not perform any currency conversion.\n *\n * @default 'INR'\n * */\n currency?: CurrencyCodeType;\n /**\n * If true, the amount text will have a line through it.\n *\n * @default false\n */\n isStrikethrough?: boolean;\n} & TestID &\n StyledPropsBlade;\n\ntype ColorProps = {\n amountValueColor: BaseTextProps['color'];\n};\n\ntype AmountProps = AmountTypeProps & AmountCommonProps;\n\nconst getTextColorProps = ({ color }: { color: AmountProps['color'] }): ColorProps => {\n const props: ColorProps = {\n amountValueColor: 'surface.text.gray.normal',\n };\n if (!color) return props;\n props.amountValueColor = color;\n return props;\n};\n\ntype AmountType = Partial<ReturnType<typeof formatNumberByParts>> & { formatted: string };\n\ninterface AmountValue extends Omit<AmountProps, 'value'> {\n amountValueColor: BaseTextProps['color'];\n amount: AmountType;\n size: Exclude<AmountProps['size'], undefined>;\n}\n\nconst AmountValue = ({\n amount,\n size = 'medium',\n type = 'body',\n weight = 'regular',\n amountValueColor,\n isAffixSubtle,\n suffix,\n}: AmountValue): ReactElement => {\n const isReactNative = getPlatformType() === 'react-native';\n const affixFontSize = isAffixSubtle ? subtleFontSizes[type][size] : normalAmountSizes[type][size];\n const numberFontFamily: keyof FontFamily = type === 'body' ? 'text' : 'heading';\n if (suffix === 'decimals' && isAffixSubtle) {\n // Native does not support alignItems of Text inside a div, instead we need to wrap is in a Text\n const AmountWrapper = isReactNative ? Text : React.Fragment;\n\n return (\n <AmountWrapper>\n <BaseText\n fontSize={normalAmountSizes[type][size]}\n fontWeight={weight}\n lineHeight={amountLineHeights[type][size]}\n color={amountValueColor}\n fontFamily={numberFontFamily}\n as={isReactNative ? undefined : 'span'}\n >\n {amount.integer}\n </BaseText>\n <BaseText\n fontWeight={weight}\n fontSize={affixFontSize}\n fontFamily={numberFontFamily}\n color={amountValueColor}\n as={isReactNative ? undefined : 'span'}\n opacity={isAffixSubtle ? opacity[8] : 1}\n >\n {amount.decimal}\n {amount.fraction}\n </BaseText>\n </AmountWrapper>\n );\n }\n\n return (\n <BaseText\n fontSize={normalAmountSizes[type][size]}\n fontWeight={weight}\n fontFamily={numberFontFamily}\n color={amountValueColor}\n lineHeight={amountLineHeights[type][size]}\n >\n {amount.formatted}\n </BaseText>\n );\n};\n\ntype FormatAmountWithSuffixType = {\n suffix: AmountProps['suffix'];\n value: number;\n};\n\n/**\n * Returns a parsed object based on the suffix passed in parameters\n * === Logic ===\n * value = 12500.45 \n * if suffix === 'decimals' => {\n \"formatted\": \"12,500.45\",\n \"integer\": \"12,500\",\n \"decimal\": \".\",\n \"fraction\": \"45\",\n \"isPrefixSymbol\": false,\n \"rawParts\": [{\"type\": \"integer\",\"value\": \"12\"},{\"type\": \"group\",\"value\": \",\"},{\"type\": \"integer\",\"value\": \"500\"},{\"type\": \"decimal\",\"value\": \".\"},{\"type\": \"fraction\",\"value\": \"45\"}]\n}\n * else if suffix === 'humanize' => { formatted: \"1.2T\" }\n * else => { formatted: \"1,23,456\" }\n * @returns {AmountType}\n */\nexport const formatAmountWithSuffix = ({\n suffix,\n value,\n}: FormatAmountWithSuffixType): AmountType => {\n try {\n switch (suffix) {\n case 'decimals': {\n const options = {\n intlOptions: {\n maximumFractionDigits: 2,\n minimumFractionDigits: 2,\n },\n };\n return {\n ...formatNumberByParts(value, options),\n formatted: formatNumber(value, options),\n };\n }\n case 'humanize': {\n const formatted = formatNumber(value, {\n intlOptions: {\n notation: 'compact',\n },\n });\n return {\n formatted,\n };\n }\n\n default: {\n const formatted = formatNumber(value, {\n intlOptions: {\n maximumFractionDigits: 0,\n roundingMode: 'floor',\n },\n });\n return {\n formatted,\n };\n }\n }\n } catch (err: unknown) {\n return {\n formatted: `${value}`,\n };\n }\n};\n\nconst _Amount = ({\n value,\n suffix = 'decimals',\n type = 'body',\n size = 'medium',\n weight = 'regular',\n isAffixSubtle = true,\n isStrikethrough = false,\n color,\n currencyIndicator = 'currency-symbol',\n currency = 'INR',\n testID,\n ...styledProps\n}: AmountProps): ReactElement => {\n if (__DEV__) {\n if (typeof value !== 'number') {\n throwBladeError({\n message: '`value` prop must be of type `number` for Amount.',\n moduleName: 'Amount',\n });\n }\n // @ts-expect-error neutral color should throw error\n if (color === 'neutral') {\n throwBladeError({\n message: '`neutral` color is not supported.',\n moduleName: 'Amount',\n });\n }\n\n const bodySizes = objectKeysWithType(normalAmountSizes.body);\n if ((type === 'body' || !type) && !bodySizes.includes(size)) {\n throwBladeError({\n message: `size=\"${size}\" is not allowed with type=\"body\"`,\n moduleName: 'Amount',\n });\n }\n\n const displaySizes = objectKeysWithType(normalAmountSizes.display);\n if (type === 'display' && !displaySizes.includes(size)) {\n throwBladeError({\n message: `size=\"${size}\" is not allowed with type=\"display\"`,\n moduleName: 'Amount',\n });\n }\n\n const headingSizes = objectKeysWithType(normalAmountSizes.heading);\n if (type === 'heading' && !headingSizes.includes(size)) {\n throwBladeError({\n message: `size=\"${size}\" is not allowed with type=\"heading\"`,\n moduleName: 'Amount',\n });\n }\n }\n\n const { amountValueColor } = getTextColorProps({\n color,\n });\n\n let isPrefixSymbol, currencySymbol;\n try {\n const byParts = formatNumberByParts(value, {\n currency,\n });\n isPrefixSymbol = byParts.isPrefixSymbol;\n currencySymbol = byParts.currency;\n } catch (err: unknown) {\n isPrefixSymbol = true;\n currencySymbol = currency;\n }\n\n const currencyPosition = isPrefixSymbol ? 'left' : 'right';\n const renderedValue = formatAmountWithSuffix({ suffix, value });\n const currencySymbolOrCode = currencyIndicator === 'currency-symbol' ? currencySymbol : currency;\n\n const currencyFontSize = isAffixSubtle\n ? subtleFontSizes[type][size]\n : normalAmountSizes[type][size];\n const isReactNative = getPlatformType() === 'react-native';\n\n return (\n <BaseBox\n display={(isReactNative ? 'flex' : 'inline-flex') as never}\n flexDirection=\"row\"\n {...metaAttribute({ name: MetaConstants.Amount, testID })}\n {...getStyledProps(styledProps)}\n >\n <BaseBox\n display={(isReactNative ? 'flex' : 'inline-flex') as never}\n alignItems=\"baseline\"\n flexDirection=\"row\"\n position=\"relative\"\n >\n {currencyPosition === 'left' && (\n <BaseText\n marginRight=\"spacing.1\"\n fontWeight={weight}\n fontSize={currencyFontSize}\n color={amountValueColor}\n as={isReactNative ? undefined : 'span'}\n opacity={isAffixSubtle ? opacity[8] : 1}\n >\n {currencySymbolOrCode}\n </BaseText>\n )}\n <AmountValue\n amount={renderedValue}\n amountValueColor={amountValueColor}\n type={type}\n weight={weight}\n size={size}\n isAffixSubtle={isAffixSubtle}\n suffix={suffix}\n currency={currency}\n />\n {currencyPosition === 'right' && (\n <BaseText\n marginLeft=\"spacing.1\"\n fontWeight={weight}\n fontSize={currencyFontSize}\n color={amountValueColor}\n as={isReactNative ? undefined : 'span'}\n opacity={isAffixSubtle ? opacity[8] : 1}\n >\n {currencySymbolOrCode}\n </BaseText>\n )}\n {isStrikethrough && (\n <BaseBox\n // @ts-expect-error - intentionally setting the border color to the color prop for this hacky strikethrough\n borderBottomColor={amountValueColor}\n borderBottomWidth={type === 'body' ? 'thin' : 'thicker'}\n borderBottomStyle=\"solid\"\n position=\"absolute\"\n width=\"100%\"\n top=\"50%\"\n />\n )}\n </BaseBox>\n </BaseBox>\n );\n};\n\nconst Amount = assignWithoutSideEffects(_Amount, {\n displayName: 'Amount',\n componentId: 'Amount',\n});\n\nexport type { AmountProps };\nexport { Amount };\n"],"names":["getTextColorProps","_ref","color","props","amountValueColor","AmountValue","_ref2","amount","_ref2$size","size","_ref2$type","type","_ref2$weight","weight","isAffixSubtle","suffix","isReactNative","getPlatformType","affixFontSize","subtleFontSizes","normalAmountSizes","numberFontFamily","AmountWrapper","Text","React","Fragment","_jsxs","children","_jsx","BaseText","fontSize","fontWeight","lineHeight","amountLineHeights","fontFamily","as","undefined","integer","opacity","decimal","fraction","formatted","formatAmountWithSuffix","_ref3","value","options","intlOptions","maximumFractionDigits","minimumFractionDigits","Object","assign","formatNumberByParts","formatNumber","notation","roundingMode","err","_Amount","_ref4","_ref4$suffix","_ref4$type","_ref4$size","_ref4$weight","_ref4$isAffixSubtle","_ref4$isStrikethrough","isStrikethrough","_ref4$currencyIndicat","currencyIndicator","_ref4$currency","currency","testID","styledProps","_objectWithoutProperties","_excluded","__DEV__","throwBladeError","message","moduleName","bodySizes","objectKeysWithType","body","includes","displaySizes","display","headingSizes","heading","_getTextColorProps","isPrefixSymbol","currencySymbol","byParts","currencyPosition","renderedValue","currencySymbolOrCode","currencyFontSize","BaseBox","flexDirection","metaAttribute","name","MetaConstants","Amount","getStyledProps","alignItems","position","marginRight","marginLeft","borderBottomColor","borderBottomWidth","borderBottomStyle","width","top","assignWithoutSideEffects","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA,IAAA,SAAA,CAAA,CAAA,OAAA,CAAA,QAAA,CAAA,MAAA,CAAA,MAAA,CAAA,QAAA,CAAA,eAAA,CAAA,iBAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,UAAA,CAAA,QAAA,CAAA,CA0EA,IAAMA,iBAAiB,CAAG,SAApBA,iBAAiBA,CAAAC,IAAA,CAA+D,CAAzD,IAAAC,KAAK,CAAAD,IAAA,CAALC,KAAK,CAChC,IAAMC,KAAiB,CAAG,CACxBC,gBAAgB,CAAE,0BACpB,CAAC,CACD,GAAI,CAACF,KAAK,CAAE,OAAOC,KAAK,CACxBA,KAAK,CAACC,gBAAgB,CAAGF,KAAK,CAC9B,OAAOC,KAAK,CACd,CAAC,CAUD,IAAME,WAAW,CAAG,SAAdA,WAAWA,CAAAC,KAAA,CAQgB,CAAA,IAP/BC,MAAM,CAAAD,KAAA,CAANC,MAAM,CAAAC,UAAA,CAAAF,KAAA,CACNG,IAAI,CAAJA,IAAI,CAAAD,UAAA,GAAA,KAAA,CAAA,CAAG,QA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AExB,aAAa,CAAGwB,OAAO,CAAC,CAAC,CAAC,CAAG,CAAE,CAAAX,QAAA,CAEvCgE,oBAAoB,CACb,CACX,CACA3B,eAAe,EACdpC,GAAA,CAACiE,OAAO,CAAA,CAENW,iBAAiB,CAAEpG,gBAAiB,CACpCqG,iBAAiB,CAAE9F,IAAI,GAAK,MAAM,CAAG,MAAM,CAAG,SAAU,CACxD+F,iBAAiB,CAAC,OAAO,CACzBL,QAAQ,CAAC,UAAU,CACnBM,KAAK,CAAC,MAAM,CACZC,GAAG,CAAC,KAAK,CACV,CACF,EACM,CAAC,CAAA,CACH,CAAC,CAEd,CAAC,CAEK,IAAAV,MAAM,CAAGW,wBAAwB,CAACrD,OAAO,CAAE,CAC/CsD,WAAW,CAAE,QAAQ,CACrBC,WAAW,CAAE,QACf,CAAC;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var normalAmountSizes={body:{xsmall:25,small:75,medium:100,large:200},heading:{small:300,medium:400,large:500,xlarge:600,'2xlarge':700},display:{small:800,medium:900,large:1000,xlarge:1100}};var subtleFontSizes={body:{xsmall:normalAmountSizes.body.xsmall,small:normalAmountSizes.body.xsmall,medium:normalAmountSizes.body.xsmall,large:normalAmountSizes.body.small},heading:{small:normalAmountSizes.body.small,medium:normalAmountSizes.body.medium,large:normalAmountSizes.body.large,xlarge:normalAmountSizes.heading.medium,'2xlarge':normalAmountSizes.heading.large},display:{small:normalAmountSizes.heading.xlarge,medium:normalAmountSizes.heading['2xlarge'],large:normalAmountSizes.heading['2xlarge'],xlarge:normalAmountSizes.display.small}};var amountLineHeights={body:{xsmall:25,small:75,medium:100,large:200},heading:{small:300,medium:400,large:500,xlarge:600,'2xlarge':700},display:{small:800,medium:900,large:1000,xlarge:1100}};
|
|
1
|
+
var normalAmountSizes={body:{xsmall:25,small:75,medium:100,large:200},heading:{small:300,medium:400,large:500,xlarge:600,'2xlarge':700},display:{small:800,medium:900,large:1000,xlarge:1100}};var subtleFontSizes={body:{xsmall:normalAmountSizes.body.xsmall,small:normalAmountSizes.body.xsmall,medium:normalAmountSizes.body.xsmall,large:normalAmountSizes.body.small},heading:{small:normalAmountSizes.body.small,medium:normalAmountSizes.body.medium,large:normalAmountSizes.body.large,xlarge:normalAmountSizes.heading.medium,'2xlarge':normalAmountSizes.heading.large},display:{small:normalAmountSizes.heading.xlarge,medium:normalAmountSizes.heading['2xlarge'],large:normalAmountSizes.heading['2xlarge'],xlarge:normalAmountSizes.display.small}};var amountLineHeights={body:{xsmall:25,small:75,medium:100,large:200},heading:{small:300,medium:400,large:500,xlarge:600,'2xlarge':700},display:{small:800,medium:900,large:1000,xlarge:1100}};
|
|
2
2
|
|
|
3
|
-
export { amountLineHeights,
|
|
3
|
+
export { amountLineHeights, normalAmountSizes, subtleFontSizes };
|
|
4
4
|
//# sourceMappingURL=amountTokens.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amountTokens.js","sources":["../../../../../src/components/Amount/amountTokens.ts"],"sourcesContent":["import type { FontSize, Typography } from '~tokens/global';\nimport type { BaseTextProps } from '~components/Typography/BaseText/types';\n\ntype AmountSizes = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | '2xlarge';\n\ntype AmountDisplayProps = {\n type?: 'display';\n size?: Extract<AmountSizes, 'small' | 'medium' | 'large' | 'xlarge'>;\n weight?: Extract<BaseTextProps['fontWeight'], 'regular' | 'medium' | 'semibold'>;\n};\n\ntype AmountHeadingProps = {\n type?: 'heading';\n size?: Extract<AmountSizes, 'small' | 'medium' | 'large' | 'xlarge' | '2xlarge'>;\n weight?: Extract<BaseTextProps['fontWeight'], 'regular' | 'semibold'>;\n};\n\ntype AmountBodyProps = {\n type?: 'body';\n size?: Extract<AmountSizes, 'xsmall' | 'small' | 'medium' | 'large'>;\n weight?: Extract<BaseTextProps['fontWeight'], 'regular' | 'medium' | 'semibold'>;\n};\n\ntype AmountTypeProps = AmountDisplayProps | AmountHeadingProps | AmountBodyProps;\n\nconst normalAmountSizes: Record<\n 'body' | 'heading' | 'display',\n Partial<Record<NonNullable<AmountTypeProps['size']>, keyof FontSize>>\n> = {\n body: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n heading: {\n small: 300,\n medium: 400,\n large: 500,\n xlarge: 600,\n '2xlarge': 700,\n },\n display: {\n small: 800,\n medium: 900,\n large: 1000,\n xlarge: 1100,\n },\n};\n\nconst subtleFontSizes: Record<\n 'body' | 'heading' | 'display',\n Partial<Record<NonNullable<AmountTypeProps['size']>, keyof FontSize>>\n> = {\n body: {\n xsmall: normalAmountSizes.body.xsmall,\n small: normalAmountSizes.body.xsmall,\n medium: normalAmountSizes.body.xsmall,\n large: normalAmountSizes.body.small,\n },\n heading: {\n small: normalAmountSizes.body.small,\n medium: normalAmountSizes.body.medium,\n large: normalAmountSizes.body.large,\n xlarge: normalAmountSizes.heading.medium,\n '2xlarge': normalAmountSizes.heading.large,\n },\n display: {\n small: normalAmountSizes.heading.xlarge,\n medium: normalAmountSizes.heading['2xlarge'],\n large: normalAmountSizes.heading['2xlarge'],\n xlarge: normalAmountSizes.display.small,\n },\n};\n\nconst amountLineHeights: Record<\n 'body' | 'heading' | 'display',\n Partial<Record<NonNullable<AmountTypeProps['size']>, keyof Typography['lineHeights']>>\n> = {\n body: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n heading: {\n small: 300,\n medium: 400,\n large: 500,\n xlarge: 600,\n '2xlarge': 700,\n },\n display: {\n small: 800,\n medium: 900,\n large: 1000,\n xlarge: 1100,\n },\n};\n\n// All the supported currency codes are taken from Razorpay's Merchant Dashboard codebase\nconst currencyIndicatorMapping = {\n AED: { 'currency-symbol': 'د.إ', 'currency-code': 'AED' },\n ALL: { 'currency-symbol': 'Lek', 'currency-code': 'ALL' },\n AMD: { 'currency-symbol': '֏', 'currency-code': 'AMD' },\n ARS: { 'currency-symbol': 'ARS', 'currency-code': 'ARS' },\n AUD: { 'currency-symbol': 'A$', 'currency-code': 'AUD' },\n AWG: { 'currency-symbol': 'Afl.', 'currency-code': 'AWG' },\n BBD: { 'currency-symbol': '$', 'currency-code': 'BBD' },\n BDT: { 'currency-symbol': '৳', 'currency-code': 'BDT' },\n BMD: { 'currency-symbol': '$', 'currency-code': 'BMD' },\n BND: { 'currency-symbol': 'BND', 'currency-code': 'BND' },\n BOB: { 'currency-symbol': 'Bs', 'currency-code': 'BOB' },\n BSD: { 'currency-symbol': 'B$', 'currency-code': 'BSD' },\n BWP: { 'currency-symbol': 'P', 'currency-code': 'BWP' },\n BZD: { 'currency-symbol': 'BZ$', 'currency-code': 'BZD' },\n CAD: { 'currency-symbol': 'C$', 'currency-code': 'CAD' },\n CHF: { 'currency-symbol': 'CHf', 'currency-code': 'CHF' },\n CNY: { 'currency-symbol': '¥', 'currency-code': 'CNY' },\n COP: { 'currency-symbol': 'COL$', 'currency-code': 'COP' },\n CRC: { 'currency-symbol': '₡', 'currency-code': 'CRC' },\n CUP: { 'currency-symbol': '$MN', 'currency-code': 'CUP' },\n CZK: { 'currency-symbol': 'Kč', 'currency-code': 'CZK' },\n DKK: { 'currency-symbol': 'DKK', 'currency-code': 'DKK' },\n DOP: { 'currency-symbol': 'RD$', 'currency-code': 'DOP' },\n DZD: { 'currency-symbol': 'د.ج', 'currency-code': 'DZD' },\n EGP: { 'currency-symbol': 'E£', 'currency-code': 'EGP' },\n ETB: { 'currency-symbol': 'ብር', 'currency-code': 'ETB' },\n EUR: { 'currency-symbol': '€', 'currency-code': 'EUR' },\n FJD: { 'currency-symbol': 'FJ$', 'currency-code': 'FJD' },\n GBP: { 'currency-symbol': '£', 'currency-code': 'GBP' },\n GHS: { 'currency-symbol': 'GH₵', 'currency-code': 'GHS' },\n GIP: { 'currency-symbol': 'GIP', 'currency-code': 'GIP' },\n GMD: { 'currency-symbol': 'D', 'currency-code': 'GMD' },\n GTQ: { 'currency-symbol': 'Q', 'currency-code': 'GTQ' },\n GYD: { 'currency-symbol': 'G$', 'currency-code': 'GYD' },\n HKD: { 'currency-symbol': 'HK$', 'currency-code': 'HKD' },\n HNL: { 'currency-symbol': 'HNL', 'currency-code': 'HNL' },\n HRK: { 'currency-symbol': 'kn', 'currency-code': 'HRK' },\n HTG: { 'currency-symbol': 'G', 'currency-code': 'HTG' },\n HUF: { 'currency-symbol': 'Ft', 'currency-code': 'HUF' },\n IDR: { 'currency-symbol': 'Rp', 'currency-code': 'IDR' },\n ILS: { 'currency-symbol': '₪', 'currency-code': 'ILS' },\n INR: { 'currency-symbol': '₹', 'currency-code': 'INR' },\n JMD: { 'currency-symbol': 'J$', 'currency-code': 'JMD' },\n KES: { 'currency-symbol': 'Ksh', 'currency-code': 'KES' },\n KGS: { 'currency-symbol': 'Лв', 'currency-code': 'KGS' },\n KHR: { 'currency-symbol': '៛', 'currency-code': 'KHR' },\n KYD: { 'currency-symbol': 'CI$', 'currency-code': 'KYD' },\n KZT: { 'currency-symbol': '₸', 'currency-code': 'KZT' },\n LAK: { 'currency-symbol': '₭', 'currency-code': 'LAK' },\n LKR: { 'currency-symbol': 'රු', 'currency-code': 'LKR' },\n LRD: { 'currency-symbol': 'L$', 'currency-code': 'LRD' },\n LSL: { 'currency-symbol': 'LSL', 'currency-code': 'LSL' },\n MAD: { 'currency-symbol': 'د.م.', 'currency-code': 'MAD' },\n MDL: { 'currency-symbol': 'MDL', 'currency-code': 'MDL' },\n MKD: { 'currency-symbol': 'ден', 'currency-code': 'MKD' },\n MMK: { 'currency-symbol': 'MMK', 'currency-code': 'MMK' },\n MNT: { 'currency-symbol': '₮', 'currency-code': 'MNT' },\n MOP: { 'currency-symbol': 'MOP$', 'currency-code': 'MOP' },\n MUR: { 'currency-symbol': '₨', 'currency-code': 'MUR' },\n MVR: { 'currency-symbol': 'Rf', 'currency-code': 'MVR' },\n MWK: { 'currency-symbol': 'MK', 'currency-code': 'MWK' },\n MXN: { 'currency-symbol': 'Mex$', 'currency-code': 'MXN' },\n MYR: { 'currency-symbol': 'RM', 'currency-code': 'MYR' },\n NAD: { 'currency-symbol': 'N$', 'currency-code': 'NAD' },\n NGN: { 'currency-symbol': '₦', 'currency-code': 'NGN' },\n NIO: { 'currency-symbol': 'NIO', 'currency-code': 'NIO' },\n NOK: { 'currency-symbol': 'NOK', 'currency-code': 'NOK' },\n NPR: { 'currency-symbol': 'रू', 'currency-code': 'NPR' },\n NZD: { 'currency-symbol': 'NZ$', 'currency-code': 'NZD' },\n PEN: { 'currency-symbol': 'S/', 'currency-code': 'PEN' },\n PGK: { 'currency-symbol': 'PGK', 'currency-code': 'PGK' },\n PHP: { 'currency-symbol': '₱', 'currency-code': 'PHP' },\n PKR: { 'currency-symbol': '₨', 'currency-code': 'PKR' },\n QAR: { 'currency-symbol': 'QR', 'currency-code': 'QAR' },\n RUB: { 'currency-symbol': '₽', 'currency-code': 'RUB' },\n SAR: { 'currency-symbol': 'SR', 'currency-code': 'SAR' },\n SCR: { 'currency-symbol': 'SRe', 'currency-code': 'SCR' },\n SEK: { 'currency-symbol': 'SEK', 'currency-code': 'SEK' },\n SGD: { 'currency-symbol': 'S$', 'currency-code': 'SGD' },\n SLL: { 'currency-symbol': 'Le', 'currency-code': 'SLL' },\n SOS: { 'currency-symbol': 'Sh.so.', 'currency-code': 'SOS' },\n SSP: { 'currency-symbol': 'SS£', 'currency-code': 'SSP' },\n SVC: { 'currency-symbol': '₡', 'currency-code': 'SVC' },\n SZL: { 'currency-symbol': 'E', 'currency-code': 'SZL' },\n THB: { 'currency-symbol': '฿', 'currency-code': 'THB' },\n TTD: { 'currency-symbol': 'TT$', 'currency-code': 'TTD' },\n TZS: { 'currency-symbol': 'Sh', 'currency-code': 'TZS' },\n USD: { 'currency-symbol': '$', 'currency-code': 'USD' },\n UYU: { 'currency-symbol': '$U', 'currency-code': 'UYU' },\n UZS: { 'currency-symbol': \"so'm\", 'currency-code': 'UZS' },\n YER: { 'currency-symbol': '﷼', 'currency-code': 'YER' },\n ZAR: { 'currency-symbol': 'R', 'currency-code': 'ZAR' },\n KWD: { 'currency-symbol': 'د.ك', 'currency-code': 'KWD' },\n BHD: { 'currency-symbol': 'د.ب.', 'currency-code': 'BHD' },\n OMR: { 'currency-symbol': 'ر.ع.', 'currency-code': 'OMR' },\n};\n\ntype CurrencyAbbreviation = {\n value: number;\n symbol: string;\n};\n\ntype Currency = keyof typeof currencyIndicatorMapping;\n\nconst getCurrencyAbbreviations = (currency: Currency): CurrencyAbbreviation[] => {\n if (currency === 'INR') {\n return [\n { value: 1e7, symbol: 'Cr' },\n { value: 1e5, symbol: 'L' },\n { value: 1e3, symbol: 'k' },\n ];\n }\n\n return [\n { value: 1e9, symbol: 'B' },\n { value: 1e6, symbol: 'M' },\n { value: 1e3, symbol: 'K' },\n ];\n};\n\nconst currencyPositionMapping: Record<string, string> = {\n DZD: 'right',\n BHD: 'right',\n OMR: 'right',\n KWD: 'right',\n};\n\nexport {\n subtleFontSizes,\n normalAmountSizes,\n amountLineHeights,\n currencyPositionMapping,\n currencyIndicatorMapping,\n getCurrencyAbbreviations,\n};\n\nexport type { Currency, AmountBodyProps, AmountDisplayProps, AmountHeadingProps, AmountTypeProps };\n"],"names":["normalAmountSizes","body","xsmall","small","medium","large","heading","xlarge","display","subtleFontSizes","amountLineHeights","currencyIndicatorMapping","AED","ALL","AMD","ARS","AUD","AWG","BBD","BDT","BMD","BND","BOB","BSD","BWP","BZD","CAD","CHF","CNY","COP","CRC","CUP","CZK","DKK","DOP","DZD","EGP","ETB","EUR","FJD","GBP","GHS","GIP","GMD","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","INR","JMD","KES","KGS","KHR","KYD","KZT","LAK","LKR","LRD","LSL","MAD","MDL","MKD","MMK","MNT","MOP","MUR","MVR","MWK","MXN","MYR","NAD","NGN","NIO","NOK","NPR","NZD","PEN","PGK","PHP","PKR","QAR","RUB","SAR","SCR","SEK","SGD","SLL","SOS","SSP","SVC","SZL","THB","TTD","TZS","USD","UYU","UZS","YER","ZAR","KWD","BHD","OMR","getCurrencyAbbreviations","currency","value","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,eAAe,CAAE,KAAM,CAAC,CACvDC,GAAG,CAAE,CAAE,iBAAiB,CAAE,KAAK,CAAE,eAAe,CAAE,KAAM,CAAC,CACzDC,GAAG,CAAE,CAAE,iBAAiB,CAAE,MAAM,CAAE,eAAe,CAAE,KAAM,CAAC,CAC1DC,GAAG,CAAE,CAAE,iBAAiB,CAAE,MAAM,CAAE,eAAe,CAAE,KAAM,CAC3D,EASM,IAAAC,wBAAwB,CAAG,SAA3BA,wBAAwBA,CAAIC,QAAkB,CAA6B,CAC/E,GAAIA,QAAQ,GAAK,KAAK,CAAE,CACtB,OAAO,CACL,CAAEC,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,IAAK,CAAC,CAC5B,CAAED,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,GAAI,CAAC,CAC3B,CAAED,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,GAAI,CAAC,CAC5B,CACH,CAEA,OAAO,CACL,CAAED,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,GAAI,CAAC,CAC3B,CAAED,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,GAAI,CAAC,CAC3B,CAAED,KAAK,CAAE,GAAG,CAAEC,MAAM,CAAE,GAAI,CAAC,CAC5B,CACH,EAEM,IAAAC,uBAA+C,CAAG,CACtD5E,GAAG,CAAE,OAAO,CACZsE,GAAG,CAAE,OAAO,CACZC,GAAG,CAAE,OAAO,CACZF,GAAG,CAAE,OACP;;;;"}
|
|
1
|
+
{"version":3,"file":"amountTokens.js","sources":["../../../../../src/components/Amount/amountTokens.ts"],"sourcesContent":["import type { FontSize, Typography } from '~tokens/global';\nimport type { BaseTextProps } from '~components/Typography/BaseText/types';\n\ntype AmountSizes = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | '2xlarge';\n\ntype AmountDisplayProps = {\n type?: 'display';\n size?: Extract<AmountSizes, 'small' | 'medium' | 'large' | 'xlarge'>;\n weight?: Extract<BaseTextProps['fontWeight'], 'regular' | 'medium' | 'semibold'>;\n};\n\ntype AmountHeadingProps = {\n type?: 'heading';\n size?: Extract<AmountSizes, 'small' | 'medium' | 'large' | 'xlarge' | '2xlarge'>;\n weight?: Extract<BaseTextProps['fontWeight'], 'regular' | 'semibold'>;\n};\n\ntype AmountBodyProps = {\n type?: 'body';\n size?: Extract<AmountSizes, 'xsmall' | 'small' | 'medium' | 'large'>;\n weight?: Extract<BaseTextProps['fontWeight'], 'regular' | 'medium' | 'semibold'>;\n};\n\ntype AmountTypeProps = AmountDisplayProps | AmountHeadingProps | AmountBodyProps;\n\nconst normalAmountSizes: Record<\n 'body' | 'heading' | 'display',\n Partial<Record<NonNullable<AmountTypeProps['size']>, keyof FontSize>>\n> = {\n body: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n heading: {\n small: 300,\n medium: 400,\n large: 500,\n xlarge: 600,\n '2xlarge': 700,\n },\n display: {\n small: 800,\n medium: 900,\n large: 1000,\n xlarge: 1100,\n },\n};\n\nconst subtleFontSizes: Record<\n 'body' | 'heading' | 'display',\n Partial<Record<NonNullable<AmountTypeProps['size']>, keyof FontSize>>\n> = {\n body: {\n xsmall: normalAmountSizes.body.xsmall,\n small: normalAmountSizes.body.xsmall,\n medium: normalAmountSizes.body.xsmall,\n large: normalAmountSizes.body.small,\n },\n heading: {\n small: normalAmountSizes.body.small,\n medium: normalAmountSizes.body.medium,\n large: normalAmountSizes.body.large,\n xlarge: normalAmountSizes.heading.medium,\n '2xlarge': normalAmountSizes.heading.large,\n },\n display: {\n small: normalAmountSizes.heading.xlarge,\n medium: normalAmountSizes.heading['2xlarge'],\n large: normalAmountSizes.heading['2xlarge'],\n xlarge: normalAmountSizes.display.small,\n },\n};\n\nconst amountLineHeights: Record<\n 'body' | 'heading' | 'display',\n Partial<Record<NonNullable<AmountTypeProps['size']>, keyof Typography['lineHeights']>>\n> = {\n body: {\n xsmall: 25,\n small: 75,\n medium: 100,\n large: 200,\n },\n heading: {\n small: 300,\n medium: 400,\n large: 500,\n xlarge: 600,\n '2xlarge': 700,\n },\n display: {\n small: 800,\n medium: 900,\n large: 1000,\n xlarge: 1100,\n },\n};\n\nexport { subtleFontSizes, normalAmountSizes, amountLineHeights };\n\nexport type { AmountBodyProps, AmountDisplayProps, AmountHeadingProps, AmountTypeProps };\n"],"names":["normalAmountSizes","body","xsmall","small","medium","large","heading","xlarge","display","subtleFontSizes","amountLineHeights"],"mappings":"AAyBM,IAAAA,iBAGL,CAAG,CACFC,IAAI,CAAE,CACJC,MAAM,CAAE,EAAE,CACVC,KAAK,CAAE,EAAE,CACTC,MAAM,CAAE,GAAG,CACXC,KAAK,CAAE,GACT,CAAC,CACDC,OAAO,CAAE,CACPH,KAAK,CAAE,GAAG,CACVC,MAAM,CAAE,GAAG,CACXC,KAAK,CAAE,GAAG,CACVE,MAAM,CAAE,GAAG,CACX,SAAS,CAAE,GACb,CAAC,CACDC,OAAO,CAAE,CACPL,KAAK,CAAE,GAAG,CACVC,MAAM,CAAE,GAAG,CACXC,KAAK,CAAE,IAAI,CACXE,MAAM,CAAE,IACV,CACF,EAEM,IAAAE,eAGL,CAAG,CACFR,IAAI,CAAE,CACJC,MAAM,CAAEF,iBAAiB,CAACC,IAAI,CAACC,MAAM,CACrCC,KAAK,CAAEH,iBAAiB,CAACC,IAAI,CAACC,MAAM,CACpCE,MAAM,CAAEJ,iBAAiB,CAACC,IAAI,CAACC,MAAM,CACrCG,KAAK,CAAEL,iBAAiB,CAACC,IAAI,CAACE,KAChC,CAAC,CACDG,OAAO,CAAE,CACPH,KAAK,CAAEH,iBAAiB,CAACC,IAAI,CAACE,KAAK,CACnCC,MAAM,CAAEJ,iBAAiB,CAACC,IAAI,CAACG,MAAM,CACrCC,KAAK,CAAEL,iBAAiB,CAACC,IAAI,CAACI,KAAK,CACnCE,MAAM,CAAEP,iBAAiB,CAACM,OAAO,CAACF,MAAM,CACxC,SAAS,CAAEJ,iBAAiB,CAACM,OAAO,CAACD,KACvC,CAAC,CACDG,OAAO,CAAE,CACPL,KAAK,CAAEH,iBAAiB,CAACM,OAAO,CAACC,MAAM,CACvCH,MAAM,CAAEJ,iBAAiB,CAACM,OAAO,CAAC,SAAS,CAAC,CAC5CD,KAAK,CAAEL,iBAAiB,CAACM,OAAO,CAAC,SAAS,CAAC,CAC3CC,MAAM,CAAEP,iBAAiB,CAACQ,OAAO,CAACL,KACpC,CACF,EAEM,IAAAO,iBAGL,CAAG,CACFT,IAAI,CAAE,CACJC,MAAM,CAAE,EAAE,CACVC,KAAK,CAAE,EAAE,CACTC,MAAM,CAAE,GAAG,CACXC,KAAK,CAAE,GACT,CAAC,CACDC,OAAO,CAAE,CACPH,KAAK,CAAE,GAAG,CACVC,MAAM,CAAE,GAAG,CACXC,KAAK,CAAE,GAAG,CACVE,MAAM,CAAE,GAAG,CACX,SAAS,CAAE,GACb,CAAC,CACDC,OAAO,CAAE,CACPL,KAAK,CAAE,GAAG,CACVC,MAAM,CAAE,GAAG,CACXC,KAAK,CAAE,IAAI,CACXE,MAAM,CAAE,IACV,CACF;;;;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
1
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
2
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import React__default from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { formatNumber, formatNumberByParts } from '@razorpay/i18nify-js/currency';
|
|
5
|
+
import { subtleFontSizes, normalAmountSizes, amountLineHeights } from './amountTokens.js';
|
|
5
6
|
import '../Box/BaseBox/index.js';
|
|
6
7
|
import '../../utils/index.js';
|
|
7
8
|
import '../../utils/metaAttribute/index.js';
|
|
@@ -37,7 +38,7 @@ var getTextColorProps = function getTextColorProps(_ref) {
|
|
|
37
38
|
return props;
|
|
38
39
|
};
|
|
39
40
|
var AmountValue = function AmountValue(_ref2) {
|
|
40
|
-
var
|
|
41
|
+
var amount = _ref2.amount,
|
|
41
42
|
_ref2$size = _ref2.size,
|
|
42
43
|
size = _ref2$size === void 0 ? 'medium' : _ref2$size,
|
|
43
44
|
_ref2$type = _ref2.type,
|
|
@@ -51,9 +52,6 @@ var AmountValue = function AmountValue(_ref2) {
|
|
|
51
52
|
var affixFontSize = isAffixSubtle ? subtleFontSizes[type][size] : normalAmountSizes[type][size];
|
|
52
53
|
var numberFontFamily = type === 'body' ? 'text' : 'heading';
|
|
53
54
|
if (suffix === 'decimals' && isAffixSubtle) {
|
|
54
|
-
var integer = value.split('.')[0];
|
|
55
|
-
var decimal = value.split('.')[1];
|
|
56
|
-
|
|
57
55
|
// Native does not support alignItems of Text inside a div, instead we need to wrap is in a Text
|
|
58
56
|
var AmountWrapper = isReactNative ? Text : React__default.Fragment;
|
|
59
57
|
return /*#__PURE__*/jsxs(AmountWrapper, {
|
|
@@ -64,7 +62,7 @@ var AmountValue = function AmountValue(_ref2) {
|
|
|
64
62
|
color: amountValueColor,
|
|
65
63
|
fontFamily: numberFontFamily,
|
|
66
64
|
as: isReactNative ? undefined : 'span',
|
|
67
|
-
children: integer
|
|
65
|
+
children: amount.integer
|
|
68
66
|
}), /*#__PURE__*/jsxs(BaseText, {
|
|
69
67
|
fontWeight: weight,
|
|
70
68
|
fontSize: affixFontSize,
|
|
@@ -72,7 +70,7 @@ var AmountValue = function AmountValue(_ref2) {
|
|
|
72
70
|
color: amountValueColor,
|
|
73
71
|
as: isReactNative ? undefined : 'span',
|
|
74
72
|
opacity: isAffixSubtle ? opacity[8] : 1,
|
|
75
|
-
children: [
|
|
73
|
+
children: [amount.decimal, amount.fraction]
|
|
76
74
|
})]
|
|
77
75
|
});
|
|
78
76
|
}
|
|
@@ -82,99 +80,93 @@ var AmountValue = function AmountValue(_ref2) {
|
|
|
82
80
|
fontFamily: numberFontFamily,
|
|
83
81
|
color: amountValueColor,
|
|
84
82
|
lineHeight: amountLineHeights[type][size],
|
|
85
|
-
children:
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// This function rounds a number to a specified number of decimal places
|
|
90
|
-
// and floors the result.
|
|
91
|
-
var getFlooredFixed = function getFlooredFixed(value, decimalPlaces) {
|
|
92
|
-
var factor = Math.pow(100, decimalPlaces);
|
|
93
|
-
var roundedValue = Math.floor(value * factor) / factor;
|
|
94
|
-
return Number(roundedValue.toFixed(decimalPlaces));
|
|
95
|
-
};
|
|
96
|
-
var addCommas = function addCommas(amountValue, currency) {
|
|
97
|
-
var decimalPlaces = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
98
|
-
// If the currency is 'INR', set the locale to 'en-IN' (Indian English).
|
|
99
|
-
// Otherwise, set the locale to 'en-US' (U.S. English).
|
|
100
|
-
var locale = currency === 'INR' ? 'en-IN' : 'en-US';
|
|
101
|
-
return amountValue.toLocaleString(locale, {
|
|
102
|
-
minimumFractionDigits: decimalPlaces
|
|
83
|
+
children: amount.formatted
|
|
103
84
|
});
|
|
104
85
|
};
|
|
105
86
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
87
|
+
* Returns a parsed object based on the suffix passed in parameters
|
|
88
|
+
* === Logic ===
|
|
89
|
+
* value = 12500.45
|
|
90
|
+
* if suffix === 'decimals' => {
|
|
91
|
+
"formatted": "12,500.45",
|
|
92
|
+
"integer": "12,500",
|
|
93
|
+
"decimal": ".",
|
|
94
|
+
"fraction": "45",
|
|
95
|
+
"isPrefixSymbol": false,
|
|
96
|
+
"rawParts": [{"type": "integer","value": "12"},{"type": "group","value": ","},{"type": "integer","value": "500"},{"type": "decimal","value": "."},{"type": "fraction","value": "45"}]
|
|
97
|
+
}
|
|
98
|
+
* else if suffix === 'humanize' => { formatted: "1.2T" }
|
|
99
|
+
* else => { formatted: "1,23,456" }
|
|
100
|
+
* @returns {AmountType}
|
|
109
101
|
*/
|
|
110
|
-
var
|
|
111
|
-
var
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
var formatAmountWithSuffix = function formatAmountWithSuffix(_ref3) {
|
|
103
|
+
var suffix = _ref3.suffix,
|
|
104
|
+
value = _ref3.value;
|
|
105
|
+
try {
|
|
106
|
+
switch (suffix) {
|
|
107
|
+
case 'decimals':
|
|
108
|
+
{
|
|
109
|
+
var options = {
|
|
110
|
+
intlOptions: {
|
|
111
|
+
maximumFractionDigits: 2,
|
|
112
|
+
minimumFractionDigits: 2
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return _objectSpread(_objectSpread({}, formatNumberByParts(value, options)), {}, {
|
|
116
|
+
formatted: formatNumber(value, options)
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
case 'humanize':
|
|
120
|
+
{
|
|
121
|
+
var formatted = formatNumber(value, {
|
|
122
|
+
intlOptions: {
|
|
123
|
+
notation: 'compact'
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
formatted: formatted
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
default:
|
|
131
|
+
{
|
|
132
|
+
var _formatted = formatNumber(value, {
|
|
133
|
+
intlOptions: {
|
|
134
|
+
maximumFractionDigits: 0,
|
|
135
|
+
roundingMode: 'floor'
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
formatted: _formatted
|
|
140
|
+
};
|
|
141
|
+
}
|
|
125
142
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
};
|
|
130
|
-
var formatAmountWithSuffix = function formatAmountWithSuffix(_ref4) {
|
|
131
|
-
var suffix = _ref4.suffix,
|
|
132
|
-
value = _ref4.value,
|
|
133
|
-
currency = _ref4.currency,
|
|
134
|
-
denominationPosition = _ref4.denominationPosition;
|
|
135
|
-
switch (suffix) {
|
|
136
|
-
case 'decimals':
|
|
137
|
-
{
|
|
138
|
-
var decimalNumber = getFlooredFixed(value, 2);
|
|
139
|
-
return addCommas(decimalNumber, currency, 2);
|
|
140
|
-
}
|
|
141
|
-
case 'humanize':
|
|
142
|
-
{
|
|
143
|
-
return getHumanizedAmount({
|
|
144
|
-
value: value,
|
|
145
|
-
currency: currency,
|
|
146
|
-
denominationPosition: denominationPosition
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
case 'none':
|
|
150
|
-
{
|
|
151
|
-
return addCommas(getFlooredFixed(value, 0), currency);
|
|
152
|
-
}
|
|
153
|
-
default:
|
|
154
|
-
return addCommas(getFlooredFixed(value, 0), currency);
|
|
143
|
+
} catch (err) {
|
|
144
|
+
return {
|
|
145
|
+
formatted: "".concat(value)
|
|
146
|
+
};
|
|
155
147
|
}
|
|
156
148
|
};
|
|
157
|
-
var _Amount = function _Amount(
|
|
158
|
-
var value =
|
|
159
|
-
|
|
160
|
-
suffix =
|
|
161
|
-
|
|
162
|
-
type =
|
|
163
|
-
|
|
164
|
-
size =
|
|
165
|
-
|
|
166
|
-
weight =
|
|
167
|
-
|
|
168
|
-
isAffixSubtle =
|
|
169
|
-
|
|
170
|
-
isStrikethrough =
|
|
171
|
-
color =
|
|
172
|
-
|
|
173
|
-
currencyIndicator =
|
|
174
|
-
|
|
175
|
-
currency =
|
|
176
|
-
testID =
|
|
177
|
-
styledProps = _objectWithoutProperties(
|
|
149
|
+
var _Amount = function _Amount(_ref4) {
|
|
150
|
+
var value = _ref4.value,
|
|
151
|
+
_ref4$suffix = _ref4.suffix,
|
|
152
|
+
suffix = _ref4$suffix === void 0 ? 'decimals' : _ref4$suffix,
|
|
153
|
+
_ref4$type = _ref4.type,
|
|
154
|
+
type = _ref4$type === void 0 ? 'body' : _ref4$type,
|
|
155
|
+
_ref4$size = _ref4.size,
|
|
156
|
+
size = _ref4$size === void 0 ? 'medium' : _ref4$size,
|
|
157
|
+
_ref4$weight = _ref4.weight,
|
|
158
|
+
weight = _ref4$weight === void 0 ? 'regular' : _ref4$weight,
|
|
159
|
+
_ref4$isAffixSubtle = _ref4.isAffixSubtle,
|
|
160
|
+
isAffixSubtle = _ref4$isAffixSubtle === void 0 ? true : _ref4$isAffixSubtle,
|
|
161
|
+
_ref4$isStrikethrough = _ref4.isStrikethrough,
|
|
162
|
+
isStrikethrough = _ref4$isStrikethrough === void 0 ? false : _ref4$isStrikethrough,
|
|
163
|
+
color = _ref4.color,
|
|
164
|
+
_ref4$currencyIndicat = _ref4.currencyIndicator,
|
|
165
|
+
currencyIndicator = _ref4$currencyIndicat === void 0 ? 'currency-symbol' : _ref4$currencyIndicat,
|
|
166
|
+
_ref4$currency = _ref4.currency,
|
|
167
|
+
currency = _ref4$currency === void 0 ? 'INR' : _ref4$currency,
|
|
168
|
+
testID = _ref4.testID,
|
|
169
|
+
styledProps = _objectWithoutProperties(_ref4, _excluded);
|
|
178
170
|
if (true) {
|
|
179
171
|
if (typeof value !== 'number') {
|
|
180
172
|
throwBladeError({
|
|
@@ -211,19 +203,27 @@ var _Amount = function _Amount(_ref5) {
|
|
|
211
203
|
});
|
|
212
204
|
}
|
|
213
205
|
}
|
|
214
|
-
var currencySymbolOrCode = currencyIndicatorMapping[currency][currencyIndicator];
|
|
215
|
-
var currencyPosition = currencyPositionMapping[currency] || 'left';
|
|
216
|
-
var denominationPosition = currencyPosition === 'left' ? 'right' : 'left';
|
|
217
|
-
var renderedValue = formatAmountWithSuffix({
|
|
218
|
-
suffix: suffix,
|
|
219
|
-
value: value,
|
|
220
|
-
currency: currency,
|
|
221
|
-
denominationPosition: denominationPosition
|
|
222
|
-
});
|
|
223
206
|
var _getTextColorProps = getTextColorProps({
|
|
224
207
|
color: color
|
|
225
208
|
}),
|
|
226
209
|
amountValueColor = _getTextColorProps.amountValueColor;
|
|
210
|
+
var isPrefixSymbol, currencySymbol;
|
|
211
|
+
try {
|
|
212
|
+
var byParts = formatNumberByParts(value, {
|
|
213
|
+
currency: currency
|
|
214
|
+
});
|
|
215
|
+
isPrefixSymbol = byParts.isPrefixSymbol;
|
|
216
|
+
currencySymbol = byParts.currency;
|
|
217
|
+
} catch (err) {
|
|
218
|
+
isPrefixSymbol = true;
|
|
219
|
+
currencySymbol = currency;
|
|
220
|
+
}
|
|
221
|
+
var currencyPosition = isPrefixSymbol ? 'left' : 'right';
|
|
222
|
+
var renderedValue = formatAmountWithSuffix({
|
|
223
|
+
suffix: suffix,
|
|
224
|
+
value: value
|
|
225
|
+
});
|
|
226
|
+
var currencySymbolOrCode = currencyIndicator === 'currency-symbol' ? currencySymbol : currency;
|
|
227
227
|
var currencyFontSize = isAffixSubtle ? subtleFontSizes[type][size] : normalAmountSizes[type][size];
|
|
228
228
|
var isReactNative = getPlatformType() === 'react-native';
|
|
229
229
|
return /*#__PURE__*/jsx(BaseBox, _objectSpread(_objectSpread(_objectSpread({
|
|
@@ -247,13 +247,14 @@ var _Amount = function _Amount(_ref5) {
|
|
|
247
247
|
opacity: isAffixSubtle ? opacity[8] : 1,
|
|
248
248
|
children: currencySymbolOrCode
|
|
249
249
|
}), /*#__PURE__*/jsx(AmountValue, {
|
|
250
|
-
|
|
250
|
+
amount: renderedValue,
|
|
251
251
|
amountValueColor: amountValueColor,
|
|
252
252
|
type: type,
|
|
253
253
|
weight: weight,
|
|
254
254
|
size: size,
|
|
255
255
|
isAffixSubtle: isAffixSubtle,
|
|
256
|
-
suffix: suffix
|
|
256
|
+
suffix: suffix,
|
|
257
|
+
currency: currency
|
|
257
258
|
}), currencyPosition === 'right' && /*#__PURE__*/jsx(BaseText, {
|
|
258
259
|
marginLeft: "spacing.1",
|
|
259
260
|
fontWeight: weight,
|
|
@@ -280,5 +281,5 @@ var Amount = /*#__PURE__*/assignWithoutSideEffects(_Amount, {
|
|
|
280
281
|
componentId: 'Amount'
|
|
281
282
|
});
|
|
282
283
|
|
|
283
|
-
export { Amount,
|
|
284
|
+
export { Amount, formatAmountWithSuffix };
|
|
284
285
|
//# sourceMappingURL=Amount.js.map
|