@razorpay/blade 11.1.1 → 11.2.1
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/native/components/Dropdown/Dropdown.js +1 -1
- package/build/lib/native/components/Dropdown/Dropdown.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/development/components/Dropdown/Dropdown.js +1 -1
- package/build/lib/web/development/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/development/components/Input/BaseInput/BaseInputTagSlot.web.js +15 -1
- package/build/lib/web/development/components/Input/BaseInput/BaseInputTagSlot.web.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/lib/web/production/components/Dropdown/Dropdown.js +1 -1
- package/build/lib/web/production/components/Dropdown/Dropdown.js.map +1 -1
- package/build/lib/web/production/components/Input/BaseInput/BaseInputTagSlot.web.js +15 -1
- package/build/lib/web/production/components/Input/BaseInput/BaseInputTagSlot.web.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseInputTagSlot.web.js","sources":["../../../../../../../src/components/Input/BaseInput/BaseInputTagSlot.web.tsx"],"sourcesContent":["import React from 'react';\nimport type { BaseInputTagSlotProps } from './types';\nimport { BASEINPUT_DEFAULT_HEIGHT } from './baseInputConfig';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { castWebType, makeSize } from '~utils';\nimport { useIsomorphicLayoutEffect } from '~utils/useIsomorphicLayoutEffect';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { size } from '~tokens/global';\n\nconst MINUMUM_INPUT_SPACE = 30;\nconst PLUS_X_MORE_TEXT_WIDTH = 60;\nconst TAG_MAX_WIDTH: number = size['140'];\n\nconst useVisibleTagsCount = ({\n slotRef,\n tags,\n maxTagRows,\n visibleTagsCountRef,\n showAllTags,\n labelPrefix,\n}: {\n slotRef: React.RefObject<HTMLDivElement>;\n tags: BaseInputTagSlotProps['tags'];\n maxTagRows: BaseInputTagSlotProps['maxTagRows'];\n visibleTagsCountRef: BaseInputTagSlotProps['visibleTagsCountRef'];\n showAllTags: BaseInputTagSlotProps['showAllTags'];\n labelPrefix: BaseInputTagSlotProps['labelPrefix'];\n}): number => {\n const [visibleTagsCount, setVisibleTagsCount] = React.useState(0);\n const visibleTagsCountStateRef = React.useRef<number>(0);\n\n useIsomorphicLayoutEffect(() => {\n if (!tags || labelPrefix) {\n setVisibleTagsCount(0);\n return;\n }\n\n if (maxTagRows === 'multiple' || showAllTags) {\n visibleTagsCountRef.current = tags.length;\n setVisibleTagsCount(tags.length);\n return;\n }\n\n const inputTagsSlotWidth = slotRef.current?.clientWidth;\n visibleTagsCountStateRef.current = 0;\n let totalTagsWidth = 0;\n\n if (!inputTagsSlotWidth) {\n return;\n }\n\n const allTagsEl = slotRef.current?.querySelectorAll(\n `[data-blade-component=\"${MetaConstants.Tag}\"]`,\n );\n\n const totalAvailableSpaceForTags =\n inputTagsSlotWidth - (MINUMUM_INPUT_SPACE + PLUS_X_MORE_TEXT_WIDTH);\n\n if (allTagsEl.length !== tags.length) {\n // some weird edge cases in controlled select where tags are not rendered in children\n // we assume 140px (max-width of tag as width of all tags)\n const tagsCount = Math.floor((totalAvailableSpaceForTags / TAG_MAX_WIDTH) * tags.length);\n visibleTagsCountRef.current = tagsCount;\n setVisibleTagsCount(tagsCount);\n return;\n }\n\n for (const tagEl of allTagsEl) {\n totalTagsWidth += tagEl.clientWidth;\n if (totalTagsWidth >= totalAvailableSpaceForTags) {\n break;\n } else {\n visibleTagsCountStateRef.current++;\n }\n }\n\n visibleTagsCountRef.current = visibleTagsCountStateRef.current;\n setVisibleTagsCount(visibleTagsCountStateRef.current);\n }, [tags?.length, showAllTags]);\n\n return visibleTagsCount;\n};\n\nconst getSelectedTextWithoutTags = ({\n items,\n labelPrefix,\n}: {\n items: number;\n labelPrefix?: string;\n}): string => {\n if (labelPrefix) {\n return `${labelPrefix} (${items} Selected)`;\n }\n\n return `${items} Selected`;\n};\n\nconst BaseInputTagSlot = ({\n renderAs,\n children,\n tags,\n maxTagRows,\n showAllTags,\n setShouldIgnoreBlurAnimation,\n handleOnInputClick,\n isDropdownTrigger,\n visibleTagsCountRef,\n labelPrefix,\n isDisabled,\n}: BaseInputTagSlotProps): React.ReactElement => {\n const hasTags = tags && tags.length > 0;\n const slotRef = React.useRef<HTMLDivElement>(null);\n const visibleTagsCount = useVisibleTagsCount({\n slotRef,\n tags,\n maxTagRows,\n visibleTagsCountRef,\n showAllTags,\n labelPrefix,\n });\n\n React.useEffect(() => {\n slotRef.current?.scrollTo?.({\n top:\n maxTagRows === 'multiple' || maxTagRows === 'expandable' ? slotRef.current.scrollHeight : 0,\n left: maxTagRows === 'single' ? slotRef.current.scrollWidth : 0,\n behavior: 'smooth',\n });\n }, [tags?.length, maxTagRows]);\n\n React.useEffect(() => {\n if (!showAllTags) {\n slotRef.current?.scrollTo?.({\n top: 0,\n left: 0,\n behavior: 'smooth',\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showAllTags]);\n\n const visibleTags = React.useMemo(() => {\n return showAllTags ? tags : tags?.slice(0, visibleTagsCount);\n }, [showAllTags, tags, visibleTagsCount]);\n\n const invisibleTagsCount = React.useMemo(() => {\n if (tags && visibleTags) {\n return tags.length - visibleTags.length;\n }\n\n return 0;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tags?.length, visibleTags?.length]);\n\n const isMobile = useIsMobile();\n\n if (!isDropdownTrigger) {\n // If its not dropdown trigger, we don't need to render tag containers\n return children;\n }\n\n // tag height changes in mobile and desktop so we keep different paddings to make it look as expected\n const paddingYWithTags = isMobile ? 'spacing.1' : 'spacing.2';\n\n return (\n <BaseBox\n ref={slotRef}\n className=\"tags-slot\"\n paddingY={paddingYWithTags}\n paddingLeft=\"spacing.4\"\n display=\"flex\"\n flex=\"1\"\n flexWrap={maxTagRows === 'single' ? 'nowrap' : 'wrap'}\n overflowX=\"auto\"\n overflowY={showAllTags || maxTagRows === 'multiple' ? 'auto' : 'hidden'}\n minHeight={makeSize(BASEINPUT_DEFAULT_HEIGHT)}\n onMouseDown={() => {\n setShouldIgnoreBlurAnimation?.(true);\n }}\n onClick={(e) => {\n handleOnInputClick(castWebType(e));\n }}\n onMouseUp={() => {\n setShouldIgnoreBlurAnimation?.(false);\n }}\n >\n {visibleTags}\n {tags && !showAllTags && invisibleTagsCount ? (\n <Text\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.subtle'}\n alignSelf=\"center\"\n marginY=\"spacing.2\"\n marginRight=\"spacing.4\"\n variant=\"body\"\n size=\"small\"\n weight=\"regular\"\n >\n <BaseBox as=\"span\" whiteSpace=\"nowrap\">\n {visibleTags?.length === 0\n ? getSelectedTextWithoutTags({\n items: invisibleTagsCount,\n labelPrefix,\n })\n : `+${invisibleTagsCount} More`}\n </BaseBox>\n </Text>\n ) : null}\n <BaseBox\n marginTop=\"-4px\"\n minWidth={hasTags && renderAs === 'button' ? undefined : makeSize(MINUMUM_INPUT_SPACE)}\n width={hasTags && renderAs === 'button' ? makeSize(size['1']) : '100%'}\n >\n {children}\n </BaseBox>\n </BaseBox>\n );\n};\n\nexport { BaseInputTagSlot };\n"],"names":["MINUMUM_INPUT_SPACE","PLUS_X_MORE_TEXT_WIDTH","TAG_MAX_WIDTH","size","useVisibleTagsCount","_ref","slotRef","tags","maxTagRows","visibleTagsCountRef","showAllTags","labelPrefix","_React$useState","React","useState","_React$useState2","_slicedToArray","visibleTagsCount","setVisibleTagsCount","visibleTagsCountStateRef","useRef","useIsomorphicLayoutEffect","_slotRef$current","_slotRef$current2","current","length","inputTagsSlotWidth","clientWidth","totalTagsWidth","allTagsEl","querySelectorAll","concat","MetaConstants","Tag","totalAvailableSpaceForTags","tagsCount","Math","floor","_iterator","_createForOfIteratorHelper","_step","s","n","done","tagEl","value","err","e","f","getSelectedTextWithoutTags","_ref2","items","BaseInputTagSlot","_ref3","renderAs","children","setShouldIgnoreBlurAnimation","handleOnInputClick","isDropdownTrigger","isDisabled","hasTags","useEffect","_slotRef$current3","_slotRef$current3$scr","scrollTo","call","top","scrollHeight","left","scrollWidth","behavior","_slotRef$current4","_slotRef$current4$scr","visibleTags","useMemo","slice","invisibleTagsCount","isMobile","useIsMobile","paddingYWithTags","_jsxs","BaseBox","ref","className","paddingY","paddingLeft","display","flex","flexWrap","overflowX","overflowY","minHeight","makeSize","BASEINPUT_DEFAULT_HEIGHT","onMouseDown","onClick","castWebType","onMouseUp","_jsx","Text","color","alignSelf","marginY","marginRight","variant","weight","as","whiteSpace","marginTop","minWidth","undefined","width"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAWA,IAAMA,mBAAmB,GAAG,EAAE,CAAA;AAC9B,IAAMC,sBAAsB,GAAG,EAAE,CAAA;AACjC,IAAMC,aAAqB,GAAGC,IAAI,CAAC,KAAK,CAAC,CAAA;AAEzC,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAAC,IAAA,EAcX;AAAA,EAAA,IAbZC,OAAO,GAAAD,IAAA,CAAPC,OAAO;IACPC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IACJC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,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AEd;;;;"}
|
|
1
|
+
{"version":3,"file":"BaseInputTagSlot.web.js","sources":["../../../../../../../src/components/Input/BaseInput/BaseInputTagSlot.web.tsx"],"sourcesContent":["import React from 'react';\nimport styled from 'styled-components';\nimport type { BaseInputTagSlotProps } from './types';\nimport { BASEINPUT_DEFAULT_HEIGHT } from './baseInputConfig';\nimport BaseBox from '~components/Box/BaseBox';\nimport { Text } from '~components/Typography';\nimport { castWebType, makeSize } from '~utils';\nimport { useIsomorphicLayoutEffect } from '~utils/useIsomorphicLayoutEffect';\nimport { useIsMobile } from '~utils/useIsMobile';\nimport { MetaConstants } from '~utils/metaAttribute';\nimport { size } from '~tokens/global';\n\nconst MINUMUM_INPUT_SPACE = 30;\nconst PLUS_X_MORE_TEXT_WIDTH = 60;\nconst TAG_MAX_WIDTH: number = size['140'];\n\nconst useVisibleTagsCount = ({\n slotRef,\n tags,\n maxTagRows,\n visibleTagsCountRef,\n showAllTags,\n labelPrefix,\n}: {\n slotRef: React.RefObject<HTMLDivElement>;\n tags: BaseInputTagSlotProps['tags'];\n maxTagRows: BaseInputTagSlotProps['maxTagRows'];\n visibleTagsCountRef: BaseInputTagSlotProps['visibleTagsCountRef'];\n showAllTags: BaseInputTagSlotProps['showAllTags'];\n labelPrefix: BaseInputTagSlotProps['labelPrefix'];\n}): number => {\n const [visibleTagsCount, setVisibleTagsCount] = React.useState(0);\n const visibleTagsCountStateRef = React.useRef<number>(0);\n\n useIsomorphicLayoutEffect(() => {\n if (!tags || labelPrefix) {\n setVisibleTagsCount(0);\n return;\n }\n\n if (maxTagRows === 'multiple' || showAllTags) {\n visibleTagsCountRef.current = tags.length;\n setVisibleTagsCount(tags.length);\n return;\n }\n\n const inputTagsSlotWidth = slotRef.current?.clientWidth;\n visibleTagsCountStateRef.current = 0;\n let totalTagsWidth = 0;\n\n if (!inputTagsSlotWidth) {\n return;\n }\n\n const allTagsEl = slotRef.current?.querySelectorAll(\n `[data-blade-component=\"${MetaConstants.Tag}\"]`,\n );\n\n const totalAvailableSpaceForTags =\n inputTagsSlotWidth - (MINUMUM_INPUT_SPACE + PLUS_X_MORE_TEXT_WIDTH);\n\n if (allTagsEl.length !== tags.length) {\n // some weird edge cases in controlled select where tags are not rendered in children\n // we assume 140px (max-width of tag as width of all tags)\n const tagsCount = Math.floor((totalAvailableSpaceForTags / TAG_MAX_WIDTH) * tags.length);\n visibleTagsCountRef.current = tagsCount;\n setVisibleTagsCount(tagsCount);\n return;\n }\n\n for (const tagEl of allTagsEl) {\n totalTagsWidth += tagEl.clientWidth;\n if (totalTagsWidth >= totalAvailableSpaceForTags) {\n break;\n } else {\n visibleTagsCountStateRef.current++;\n }\n }\n\n visibleTagsCountRef.current = visibleTagsCountStateRef.current;\n setVisibleTagsCount(visibleTagsCountStateRef.current);\n }, [tags?.length, showAllTags]);\n\n return visibleTagsCount;\n};\n\nconst getSelectedTextWithoutTags = ({\n items,\n labelPrefix,\n}: {\n items: number;\n labelPrefix?: string;\n}): string => {\n if (labelPrefix) {\n return `${labelPrefix} (${items} Selected)`;\n }\n\n return `${items} Selected`;\n};\n\nconst TagSlotContainer = styled(BaseBox)(() => {\n return {\n // hides the scrollbar of tagslot\n '::-webkit-scrollbar': {\n display: 'none',\n },\n '-ms-overflow-style': 'none',\n 'scrollbar-width': 'none',\n };\n});\n\nconst BaseInputTagSlot = ({\n renderAs,\n children,\n tags,\n maxTagRows,\n showAllTags,\n setShouldIgnoreBlurAnimation,\n handleOnInputClick,\n isDropdownTrigger,\n visibleTagsCountRef,\n labelPrefix,\n isDisabled,\n}: BaseInputTagSlotProps): React.ReactElement => {\n const hasTags = tags && tags.length > 0;\n const slotRef = React.useRef<HTMLDivElement>(null);\n const visibleTagsCount = useVisibleTagsCount({\n slotRef,\n tags,\n maxTagRows,\n visibleTagsCountRef,\n showAllTags,\n labelPrefix,\n });\n\n React.useEffect(() => {\n slotRef.current?.scrollTo?.({\n top:\n maxTagRows === 'multiple' || maxTagRows === 'expandable' ? slotRef.current.scrollHeight : 0,\n left: maxTagRows === 'single' ? slotRef.current.scrollWidth : 0,\n behavior: 'smooth',\n });\n }, [tags?.length, maxTagRows]);\n\n React.useEffect(() => {\n if (!showAllTags) {\n slotRef.current?.scrollTo?.({\n top: 0,\n left: 0,\n behavior: 'smooth',\n });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [showAllTags]);\n\n const visibleTags = React.useMemo(() => {\n return showAllTags ? tags : tags?.slice(0, visibleTagsCount);\n }, [showAllTags, tags, visibleTagsCount]);\n\n const invisibleTagsCount = React.useMemo(() => {\n if (tags && visibleTags) {\n return tags.length - visibleTags.length;\n }\n\n return 0;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [tags?.length, visibleTags?.length]);\n\n const isMobile = useIsMobile();\n\n if (!isDropdownTrigger) {\n // If its not dropdown trigger, we don't need to render tag containers\n return children;\n }\n\n // tag height changes in mobile and desktop so we keep different paddings to make it look as expected\n const paddingYWithTags = isMobile ? 'spacing.1' : 'spacing.2';\n\n return (\n <TagSlotContainer\n ref={slotRef}\n className=\"tags-slot\"\n paddingY={paddingYWithTags}\n paddingLeft=\"spacing.4\"\n display=\"flex\"\n flex=\"1\"\n flexWrap={maxTagRows === 'single' ? 'nowrap' : 'wrap'}\n overflowX=\"auto\"\n overflowY={showAllTags || maxTagRows === 'multiple' ? 'auto' : 'hidden'}\n minHeight={makeSize(BASEINPUT_DEFAULT_HEIGHT)}\n onMouseDown={() => {\n setShouldIgnoreBlurAnimation?.(true);\n }}\n onClick={(e) => {\n handleOnInputClick(castWebType(e));\n }}\n onMouseUp={() => {\n setShouldIgnoreBlurAnimation?.(false);\n }}\n >\n {visibleTags}\n {tags && !showAllTags && invisibleTagsCount ? (\n <Text\n color={isDisabled ? 'surface.text.gray.disabled' : 'surface.text.gray.subtle'}\n alignSelf=\"center\"\n marginY=\"spacing.2\"\n marginRight=\"spacing.4\"\n variant=\"body\"\n size=\"small\"\n weight=\"regular\"\n >\n <BaseBox as=\"span\" whiteSpace=\"nowrap\">\n {visibleTags?.length === 0\n ? getSelectedTextWithoutTags({\n items: invisibleTagsCount,\n labelPrefix,\n })\n : `+${invisibleTagsCount} More`}\n </BaseBox>\n </Text>\n ) : null}\n <BaseBox\n marginTop=\"-4px\"\n minWidth={hasTags && renderAs === 'button' ? undefined : makeSize(MINUMUM_INPUT_SPACE)}\n width={hasTags && renderAs === 'button' ? makeSize(size['1']) : '100%'}\n >\n {children}\n </BaseBox>\n </TagSlotContainer>\n );\n};\n\nexport { BaseInputTagSlot };\n"],"names":["MINUMUM_INPUT_SPACE","PLUS_X_MORE_TEXT_WIDTH","TAG_MAX_WIDTH","size","useVisibleTagsCount","_ref","slotRef","tags","maxTagRows","visibleTagsCountRef","showAllTags","labelPrefix","_React$useState","React","useState","_React$useState2","_slicedToArray","visibleTagsCount","setVisibleTagsCount","visibleTagsCountStateRef","useRef","useIsomorphicLayoutEffect","_slotRef$current","_slotRef$current2","current","length","inputTagsSlotWidth","clientWidth","totalTagsWidth","allTagsEl","querySelectorAll","concat","MetaConstants","Tag","totalAvailableSpaceForTags","tagsCount","Math","floor","_iterator","_createForOfIteratorHelper","_step","s","n","done","tagEl","value","err","e","f","getSelectedTextWithoutTags","_ref2","items","TagSlotContainer","styled","BaseBox","withConfig","displayName","componentId","display","BaseInputTagSlot","_ref3","renderAs","children","setShouldIgnoreBlurAnimation","handleOnInputClick","isDropdownTrigger","isDisabled","hasTags","useEffect","_slotRef$current3","_slotRef$current3$scr","scrollTo","call","top","scrollHeight","left","scrollWidth","behavior","_slotRef$current4","_slotRef$current4$scr","visibleTags","useMemo","slice","invisibleTagsCount","isMobile","useIsMobile","paddingYWithTags","_jsxs","ref","className","paddingY","paddingLeft","flex","flexWrap","overflowX","overflowY","minHeight","makeSize","BASEINPUT_DEFAULT_HEIGHT","onMouseDown","onClick","castWebType","onMouseUp","_jsx","Text","color","alignSelf","marginY","marginRight","variant","weight","as","whiteSpace","marginTop","minWidth","undefined","width"],"mappings":";;;;;;;;;;;;;;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,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAXA,WAAW,CAAEvD,MAAM,MAAK,CAAC,GACtBwB,0BAA0B,CAAC;AACzBE,UAAAA,KAAK,EAAEgC,kBAAkB;AACzBxE,UAAAA,WAAW,EAAXA,WAAAA;AACF,SAAC,CAAC,GAAA,GAAA,CAAAoB,MAAA,CACEoD,kBAAkB,EAAA,OAAA,CAAA;OACnB,CAAA;AAAC,KACN,CAAC,GACL,IAAI,eACRoB,GAAA,CAACjD,OAAO,EAAA;AACN2D,MAAAA,SAAS,EAAC,MAAM;AAChBC,MAAAA,QAAQ,EAAE/C,OAAO,IAAIN,QAAQ,KAAK,QAAQ,GAAGsD,SAAS,GAAGlB,QAAQ,CAACjG,mBAAmB,CAAE;AACvFoH,MAAAA,KAAK,EAAEjD,OAAO,IAAIN,QAAQ,KAAK,QAAQ,GAAGoC,QAAQ,CAAC9F,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,MAAO;AAAA2D,MAAAA,QAAA,EAEtEA,QAAAA;AAAQ,KACF,CAAC,CAAA;AAAA,GACM,CAAC,CAAA;AAEvB;;;;"}
|
|
@@ -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 (false) {
|
|
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
|
|
@@ -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","Math","pow","roundedValue","floor","Number","toFixed","addCommas","amountValue","currency","arguments","length","locale","toLocaleString","minimumFractionDigits","getHumanizedAmount","_ref3","_ref3$denominationPos","denominationPosition","abbreviations","getCurrencyAbbreviations","abbreviation","find","abbr","formattedAmountValue","concat","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","throwBladeError","message","moduleName","bodySizes","objectKeysWithType","body","includes","displaySizes","display","headingSizes","heading","currencySymbolOrCode","currencyIndicatorMapping","currencyPosition","currencyPositionMapping","renderedValue","_getTextColorProps","currencyFontSize","BaseBox","_objectSpread","flexDirection","metaAttribute","name","MetaConstants","Amount","getStyledProps","alignItems","position","marginRight","marginLeft","borderBottomColor","borderBottomWidth","borderBottomStyle","width","top","assignWithoutSideEffects","displayName","componentId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8EA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAiBA,CAAAC,IAAA,EAA+D;AAAA,EAAA,IAAzDC,KAAK,GAAAD,IAAA,CAALC,KAAK,CAAA;AAChC,EAAA,IAAMC,KAAiB,GAAG;AACxBC,IAAAA,gBAAgB,EAAE,0BAAA;GACnB,CAAA;AACD,EAAA,IAAI,CAACF,KAAK,EAAE,OAAOC,KAAK,CAAA;EACxBA,KAAK,CAACC,gBAAgB,GAAGF,KAAK,CAAA;AAC9B,EAAA,OAAOC,KAAK,CAAA;AACd,CAAC,CAAA;AAQD,IAAME,WAAW,GAAG,SAAdA,WAAWA,CAAAC,KAAA,EAQgB;AAAA,EAAA,IAP/BC,KAAK,GAAAD,KAAA,CAALC,KAAK;IAAAC,UAAA,GAAAF,KAAA,CACLG,IAAI;AAAJA,IAAAA,IAAI,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,QAAQ,GAAAA,UAAA;IAAAE,UAAA,GAAAJ,KAAA,CACfK,IAAI;AAAJA,IAAAA,IAAI,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,MAAM,GAAAA,UAAA;IAAAE,YAAA,GAAAN,K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EACDwF,gBAAgB,KAAK,OAAO,iBAC3BxE,GAAA,CAACC,QAAQ,EAAA;AACPuF,QAAAA,UAAU,EAAC,WAAW;AACtBrF,QAAAA,UAAU,EAAErB,MAAO;AACnBoB,QAAAA,QAAQ,EAAE0E,gBAAiB;AAC3BzG,QAAAA,KAAK,EAAEE,gBAAiB;AACxBkC,QAAAA,EAAE,EAAEtB,aAAa,GAAGuB,SAAS,GAAG,MAAO;QACvCC,OAAO,EAAE1B,aAAa,GAAG0B,OAAO,CAAC,CAAC,CAAC,GAAG,CAAE;AAAAV,QAAAA,QAAA,EAEvCuE,oBAAAA;AAAoB,OACb,CACX,EACAnB,eAAe,iBACdnD,GAAA,CAAC6E,OAAAA;AACC;AAAA,QAAA;AACAY,QAAAA,iBAAiB,EAAEpH,gBAAiB;AACpCqH,QAAAA,iBAAiB,EAAE9G,IAAI,KAAK,MAAM,GAAG,MAAM,GAAG,SAAU;AACxD+G,QAAAA,iBAAiB,EAAC,OAAO;AACzBL,QAAAA,QAAQ,EAAC,UAAU;AACnBM,QAAAA,KAAK,EAAC,MAAM;AACZC,QAAAA,GAAG,EAAC,KAAA;AAAK,OACV,CACF,CAAA;KACM,CAAA;AAAC,GAAA,CACH,CAAC,CAAA;AAEd,CAAC,CAAA;AAED,IAAMV,MAAM,gBAAGW,wBAAwB,CAACnD,OAAO,EAAE;AAC/CoD,EAAAA,WAAW,EAAE,QAAQ;AACrBC,EAAAA,WAAW,EAAE,QAAA;AACf,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","_objectSpread","formatNumberByParts","formatNumber","notation","roundingMode","err","concat","_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","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA,IAAMA,iBAAiB,GAAG,SAApBA,iBAAi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