@transferwise/components 46.134.0 → 46.135.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/accordion/AccordionItem/AccordionItem.js +1 -0
- package/build/accordion/AccordionItem/AccordionItem.js.map +1 -1
- package/build/accordion/AccordionItem/AccordionItem.mjs +1 -0
- package/build/accordion/AccordionItem/AccordionItem.mjs.map +1 -1
- package/build/actionButton/ActionButton.js +1 -0
- package/build/actionButton/ActionButton.js.map +1 -1
- package/build/actionButton/ActionButton.mjs +1 -0
- package/build/actionButton/ActionButton.mjs.map +1 -1
- package/build/actionOption/ActionOption.js +1 -0
- package/build/actionOption/ActionOption.js.map +1 -1
- package/build/actionOption/ActionOption.mjs +1 -0
- package/build/actionOption/ActionOption.mjs.map +1 -1
- package/build/alert/Alert.js +1 -0
- package/build/alert/Alert.js.map +1 -1
- package/build/alert/Alert.mjs +1 -0
- package/build/alert/Alert.mjs.map +1 -1
- package/build/alert/inlineMarkdown/InlineMarkdown.js +1 -0
- package/build/alert/inlineMarkdown/InlineMarkdown.js.map +1 -1
- package/build/alert/inlineMarkdown/InlineMarkdown.mjs +1 -0
- package/build/alert/inlineMarkdown/InlineMarkdown.mjs.map +1 -1
- package/build/avatar/Avatar.js +1 -0
- package/build/avatar/Avatar.js.map +1 -1
- package/build/avatar/Avatar.mjs +1 -0
- package/build/avatar/Avatar.mjs.map +1 -1
- package/build/avatarView/AvatarView.js +1 -0
- package/build/avatarView/AvatarView.js.map +1 -1
- package/build/avatarView/AvatarView.mjs +1 -0
- package/build/avatarView/AvatarView.mjs.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.js +1 -0
- package/build/avatarWrapper/AvatarWrapper.js.map +1 -1
- package/build/avatarWrapper/AvatarWrapper.mjs +1 -0
- package/build/avatarWrapper/AvatarWrapper.mjs.map +1 -1
- package/build/badge/Badge.js +1 -0
- package/build/badge/Badge.js.map +1 -1
- package/build/badge/Badge.mjs +1 -0
- package/build/badge/Badge.mjs.map +1 -1
- package/build/button/Button.js +1 -0
- package/build/button/Button.js.map +1 -1
- package/build/button/Button.mjs +1 -0
- package/build/button/Button.mjs.map +1 -1
- package/build/button/LegacyButton.js +1 -0
- package/build/button/LegacyButton.js.map +1 -1
- package/build/button/LegacyButton.mjs +1 -0
- package/build/button/LegacyButton.mjs.map +1 -1
- package/build/button/classMap.js +1 -0
- package/build/button/classMap.js.map +1 -1
- package/build/button/classMap.mjs +1 -0
- package/build/button/classMap.mjs.map +1 -1
- package/build/button/legacyUtils/legacyUtils.js +1 -0
- package/build/button/legacyUtils/legacyUtils.js.map +1 -1
- package/build/button/legacyUtils/legacyUtils.mjs +1 -0
- package/build/button/legacyUtils/legacyUtils.mjs.map +1 -1
- package/build/card/Card.js +1 -0
- package/build/card/Card.js.map +1 -1
- package/build/card/Card.mjs +1 -0
- package/build/card/Card.mjs.map +1 -1
- package/build/checkbox/Checkbox.js +1 -0
- package/build/checkbox/Checkbox.js.map +1 -1
- package/build/checkbox/Checkbox.mjs +1 -0
- package/build/checkbox/Checkbox.mjs.map +1 -1
- package/build/chevron/Chevron.js +1 -0
- package/build/chevron/Chevron.js.map +1 -1
- package/build/chevron/Chevron.mjs +1 -0
- package/build/chevron/Chevron.mjs.map +1 -1
- package/build/chips/Chip.js +1 -0
- package/build/chips/Chip.js.map +1 -1
- package/build/chips/Chip.mjs +1 -0
- package/build/chips/Chip.mjs.map +1 -1
- package/build/circularButton/CircularButton.js +1 -0
- package/build/circularButton/CircularButton.js.map +1 -1
- package/build/circularButton/CircularButton.mjs +1 -0
- package/build/circularButton/CircularButton.mjs.map +1 -1
- package/build/common/locale/index.js +9 -4
- package/build/common/locale/index.js.map +1 -1
- package/build/common/locale/index.mjs +9 -4
- package/build/common/locale/index.mjs.map +1 -1
- package/build/common/panel/Panel.js +1 -0
- package/build/common/panel/Panel.js.map +1 -1
- package/build/common/panel/Panel.mjs +1 -0
- package/build/common/panel/Panel.mjs.map +1 -1
- package/build/common/responsivePanel/ResponsivePanel.js +1 -0
- package/build/common/responsivePanel/ResponsivePanel.js.map +1 -1
- package/build/common/responsivePanel/ResponsivePanel.mjs +1 -0
- package/build/common/responsivePanel/ResponsivePanel.mjs.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.js +1 -0
- package/build/criticalBanner/CriticalCommsBanner.js.map +1 -1
- package/build/criticalBanner/CriticalCommsBanner.mjs +1 -0
- package/build/criticalBanner/CriticalCommsBanner.mjs.map +1 -1
- package/build/dateInput/DateInput.js +1 -1
- package/build/dateInput/DateInput.mjs +1 -1
- package/build/dateLookup/DateLookup.js +1 -1
- package/build/dateLookup/DateLookup.mjs +1 -1
- package/build/dateLookup/dateHeader/DateHeader.js +1 -0
- package/build/dateLookup/dateHeader/DateHeader.js.map +1 -1
- package/build/dateLookup/dateHeader/DateHeader.mjs +1 -0
- package/build/dateLookup/dateHeader/DateHeader.mjs.map +1 -1
- package/build/decision/Decision.js +1 -0
- package/build/decision/Decision.js.map +1 -1
- package/build/decision/Decision.mjs +1 -0
- package/build/decision/Decision.mjs.map +1 -1
- package/build/definitionList/DefinitionList.js +1 -0
- package/build/definitionList/DefinitionList.js.map +1 -1
- package/build/definitionList/DefinitionList.mjs +1 -0
- package/build/definitionList/DefinitionList.mjs.map +1 -1
- package/build/dimmer/Dimmer.js +1 -0
- package/build/dimmer/Dimmer.js.map +1 -1
- package/build/dimmer/Dimmer.mjs +1 -0
- package/build/dimmer/Dimmer.mjs.map +1 -1
- package/build/display/Display.js +1 -0
- package/build/display/Display.js.map +1 -1
- package/build/display/Display.mjs +1 -0
- package/build/display/Display.mjs.map +1 -1
- package/build/drawer/Drawer.js +1 -0
- package/build/drawer/Drawer.js.map +1 -1
- package/build/drawer/Drawer.mjs +1 -0
- package/build/drawer/Drawer.mjs.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js +4 -3
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.js.map +1 -1
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs +4 -3
- package/build/expressiveMoneyInput/currencySelector/CurrencySelector.mjs.map +1 -1
- package/build/field/Field.js +1 -0
- package/build/field/Field.js.map +1 -1
- package/build/field/Field.mjs +1 -0
- package/build/field/Field.mjs.map +1 -1
- package/build/flowNavigation/FlowNavigation.js +1 -0
- package/build/flowNavigation/FlowNavigation.js.map +1 -1
- package/build/flowNavigation/FlowNavigation.mjs +1 -0
- package/build/flowNavigation/FlowNavigation.mjs.map +1 -1
- package/build/header/Header.js +1 -0
- package/build/header/Header.js.map +1 -1
- package/build/header/Header.mjs +1 -0
- package/build/header/Header.mjs.map +1 -1
- package/build/info/Info.js +1 -0
- package/build/info/Info.js.map +1 -1
- package/build/info/Info.mjs +1 -0
- package/build/info/Info.mjs.map +1 -1
- package/build/inlineAlert/InlineAlert.js +1 -0
- package/build/inlineAlert/InlineAlert.js.map +1 -1
- package/build/inlineAlert/InlineAlert.mjs +1 -0
- package/build/inlineAlert/InlineAlert.mjs.map +1 -1
- package/build/inputs/SearchInput.js +1 -0
- package/build/inputs/SearchInput.js.map +1 -1
- package/build/inputs/SearchInput.mjs +1 -0
- package/build/inputs/SearchInput.mjs.map +1 -1
- package/build/instructionsList/InstructionsList.js +1 -0
- package/build/instructionsList/InstructionsList.js.map +1 -1
- package/build/instructionsList/InstructionsList.mjs +1 -0
- package/build/instructionsList/InstructionsList.mjs.map +1 -1
- package/build/link/Link.js +1 -0
- package/build/link/Link.js.map +1 -1
- package/build/link/Link.mjs +1 -0
- package/build/link/Link.mjs.map +1 -1
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js +1 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.js.map +1 -1
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs +1 -0
- package/build/listItem/AdditionalInfo/ListItemAdditionalInfo.mjs.map +1 -1
- package/build/listItem/ListItem.js +1 -0
- package/build/listItem/ListItem.js.map +1 -1
- package/build/listItem/ListItem.mjs +1 -0
- package/build/listItem/ListItem.mjs.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.js +1 -0
- package/build/listItem/Prompt/ListItemPrompt.js.map +1 -1
- package/build/listItem/Prompt/ListItemPrompt.mjs +1 -0
- package/build/listItem/Prompt/ListItemPrompt.mjs.map +1 -1
- package/build/loader/Loader.js +1 -0
- package/build/loader/Loader.js.map +1 -1
- package/build/loader/Loader.mjs +1 -0
- package/build/loader/Loader.mjs.map +1 -1
- package/build/main.css +22 -22
- package/build/markdown/Markdown.js +1 -0
- package/build/markdown/Markdown.js.map +1 -1
- package/build/markdown/Markdown.mjs +1 -0
- package/build/markdown/Markdown.mjs.map +1 -1
- package/build/modal/Modal.js +1 -0
- package/build/modal/Modal.js.map +1 -1
- package/build/modal/Modal.mjs +1 -0
- package/build/modal/Modal.mjs.map +1 -1
- package/build/navigationOption/NavigationOption.js +1 -0
- package/build/navigationOption/NavigationOption.js.map +1 -1
- package/build/navigationOption/NavigationOption.mjs +1 -0
- package/build/navigationOption/NavigationOption.mjs.map +1 -1
- package/build/nudge/Nudge.js +1 -0
- package/build/nudge/Nudge.js.map +1 -1
- package/build/nudge/Nudge.mjs +1 -0
- package/build/nudge/Nudge.mjs.map +1 -1
- package/build/overlayHeader/OverlayHeader.js +1 -0
- package/build/overlayHeader/OverlayHeader.js.map +1 -1
- package/build/overlayHeader/OverlayHeader.mjs +1 -0
- package/build/overlayHeader/OverlayHeader.mjs.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.js +1 -0
- package/build/phoneNumberInput/PhoneNumberInput.js.map +1 -1
- package/build/phoneNumberInput/PhoneNumberInput.mjs +1 -0
- package/build/phoneNumberInput/PhoneNumberInput.mjs.map +1 -1
- package/build/popover/Popover.js +1 -0
- package/build/popover/Popover.js.map +1 -1
- package/build/popover/Popover.mjs +1 -0
- package/build/popover/Popover.mjs.map +1 -1
- package/build/processIndicator/ProcessIndicator.js +1 -0
- package/build/processIndicator/ProcessIndicator.js.map +1 -1
- package/build/processIndicator/ProcessIndicator.mjs +1 -0
- package/build/processIndicator/ProcessIndicator.mjs.map +1 -1
- package/build/progressBar/ProgressBar.js +1 -0
- package/build/progressBar/ProgressBar.js.map +1 -1
- package/build/progressBar/ProgressBar.mjs +1 -0
- package/build/progressBar/ProgressBar.mjs.map +1 -1
- package/build/promoCard/PromoCard.js +1 -0
- package/build/promoCard/PromoCard.js.map +1 -1
- package/build/promoCard/PromoCard.mjs +1 -0
- package/build/promoCard/PromoCard.mjs.map +1 -1
- package/build/promoCard/PromoCardIndicator.js +1 -0
- package/build/promoCard/PromoCardIndicator.js.map +1 -1
- package/build/promoCard/PromoCardIndicator.mjs +1 -0
- package/build/promoCard/PromoCardIndicator.mjs.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.js +1 -0
- package/build/prompt/ActionPrompt/ActionPrompt.js.map +1 -1
- package/build/prompt/ActionPrompt/ActionPrompt.mjs +1 -0
- package/build/prompt/ActionPrompt/ActionPrompt.mjs.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.js +1 -0
- package/build/prompt/InfoPrompt/InfoPrompt.js.map +1 -1
- package/build/prompt/InfoPrompt/InfoPrompt.mjs +1 -0
- package/build/prompt/InfoPrompt/InfoPrompt.mjs.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.js +1 -0
- package/build/prompt/InlinePrompt/InlinePrompt.js.map +1 -1
- package/build/prompt/InlinePrompt/InlinePrompt.mjs +1 -0
- package/build/prompt/InlinePrompt/InlinePrompt.mjs.map +1 -1
- package/build/radio/Radio.js +1 -0
- package/build/radio/Radio.js.map +1 -1
- package/build/radio/Radio.mjs +1 -0
- package/build/radio/Radio.mjs.map +1 -1
- package/build/segmentedControl/SegmentedControl.js +1 -0
- package/build/segmentedControl/SegmentedControl.js.map +1 -1
- package/build/segmentedControl/SegmentedControl.mjs +1 -0
- package/build/segmentedControl/SegmentedControl.mjs.map +1 -1
- package/build/select/Select.js +1 -0
- package/build/select/Select.js.map +1 -1
- package/build/select/Select.mjs +1 -0
- package/build/select/Select.mjs.map +1 -1
- package/build/select/option/Option.js +1 -0
- package/build/select/option/Option.js.map +1 -1
- package/build/select/option/Option.mjs +1 -0
- package/build/select/option/Option.mjs.map +1 -1
- package/build/statusIcon/StatusIcon.js +1 -0
- package/build/statusIcon/StatusIcon.js.map +1 -1
- package/build/statusIcon/StatusIcon.mjs +1 -0
- package/build/statusIcon/StatusIcon.mjs.map +1 -1
- package/build/stepper/Stepper.js +1 -0
- package/build/stepper/Stepper.js.map +1 -1
- package/build/stepper/Stepper.mjs +1 -0
- package/build/stepper/Stepper.mjs.map +1 -1
- package/build/sticky/Sticky.js +1 -0
- package/build/sticky/Sticky.js.map +1 -1
- package/build/sticky/Sticky.mjs +1 -0
- package/build/sticky/Sticky.mjs.map +1 -1
- package/build/styles/css/neptune.css +22 -22
- package/build/styles/less/neptune-tokens.less +4 -4
- package/build/styles/main.css +22 -22
- package/build/styles/props/neptune-tokens.css +2 -2
- package/build/styles/styles/less/neptune.css +22 -22
- package/build/summary/Summary.js +1 -0
- package/build/summary/Summary.js.map +1 -1
- package/build/summary/Summary.mjs +1 -0
- package/build/summary/Summary.mjs.map +1 -1
- package/build/table/Table.js +1 -0
- package/build/table/Table.js.map +1 -1
- package/build/table/Table.mjs +1 -0
- package/build/table/Table.mjs.map +1 -1
- package/build/table/TableRow.js +1 -0
- package/build/table/TableRow.js.map +1 -1
- package/build/table/TableRow.mjs +1 -0
- package/build/table/TableRow.mjs.map +1 -1
- package/build/table/TableStatusText.js +1 -0
- package/build/table/TableStatusText.js.map +1 -1
- package/build/table/TableStatusText.mjs +1 -0
- package/build/table/TableStatusText.mjs.map +1 -1
- package/build/tabs/Tabs.js +1 -0
- package/build/tabs/Tabs.js.map +1 -1
- package/build/tabs/Tabs.mjs +1 -0
- package/build/tabs/Tabs.mjs.map +1 -1
- package/build/tile/Tile.js +1 -0
- package/build/tile/Tile.js.map +1 -1
- package/build/tile/Tile.mjs +1 -0
- package/build/tile/Tile.mjs.map +1 -1
- package/build/title/Title.js +1 -0
- package/build/title/Title.js.map +1 -1
- package/build/title/Title.mjs +1 -0
- package/build/title/Title.mjs.map +1 -1
- package/build/tooltip/Tooltip.js +1 -0
- package/build/tooltip/Tooltip.js.map +1 -1
- package/build/tooltip/Tooltip.mjs +1 -0
- package/build/tooltip/Tooltip.mjs.map +1 -1
- package/build/typeahead/Typeahead.js +1 -0
- package/build/typeahead/Typeahead.js.map +1 -1
- package/build/typeahead/Typeahead.mjs +1 -0
- package/build/typeahead/Typeahead.mjs.map +1 -1
- package/build/types/common/locale/index.d.ts +1 -1
- package/build/types/common/locale/index.d.ts.map +1 -1
- package/build/types/expressiveMoneyInput/currencySelector/CurrencySelector.d.ts.map +1 -1
- package/build/upload/Upload.js +1 -0
- package/build/upload/Upload.js.map +1 -1
- package/build/upload/Upload.mjs +1 -0
- package/build/upload/Upload.mjs.map +1 -1
- package/build/upload/steps/completeStep/completeStep.js +1 -0
- package/build/upload/steps/completeStep/completeStep.js.map +1 -1
- package/build/upload/steps/completeStep/completeStep.mjs +1 -0
- package/build/upload/steps/completeStep/completeStep.mjs.map +1 -1
- package/build/upload/steps/processingStep/processingStep.js +1 -0
- package/build/upload/steps/processingStep/processingStep.js.map +1 -1
- package/build/upload/steps/processingStep/processingStep.mjs +1 -0
- package/build/upload/steps/processingStep/processingStep.mjs.map +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.js +1 -0
- package/build/upload/steps/uploadImageStep/uploadImageStep.js.map +1 -1
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs +1 -0
- package/build/upload/steps/uploadImageStep/uploadImageStep.mjs.map +1 -1
- package/build/uploadInput/UploadInput.js +1 -0
- package/build/uploadInput/UploadInput.js.map +1 -1
- package/build/uploadInput/UploadInput.mjs +1 -0
- package/build/uploadInput/UploadInput.mjs.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.js +1 -0
- package/build/uploadInput/uploadButton/UploadButton.js.map +1 -1
- package/build/uploadInput/uploadButton/UploadButton.mjs +1 -0
- package/build/uploadInput/uploadButton/UploadButton.mjs.map +1 -1
- package/build/uploadInput/uploadButton/defaults.js +1 -0
- package/build/uploadInput/uploadButton/defaults.js.map +1 -1
- package/build/uploadInput/uploadButton/defaults.mjs +1 -0
- package/build/uploadInput/uploadButton/defaults.mjs.map +1 -1
- package/build/uploadInput/uploadItem/UploadItem.js +1 -0
- package/build/uploadInput/uploadItem/UploadItem.js.map +1 -1
- package/build/uploadInput/uploadItem/UploadItem.mjs +1 -0
- package/build/uploadInput/uploadItem/UploadItem.mjs.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.js +1 -0
- package/build/withDisplayFormat/WithDisplayFormat.js.map +1 -1
- package/build/withDisplayFormat/WithDisplayFormat.mjs +1 -0
- package/build/withDisplayFormat/WithDisplayFormat.mjs.map +1 -1
- package/package.json +14 -14
- package/src/common/locale/index.test.ts +13 -4
- package/src/common/locale/index.ts +9 -3
- package/src/expressiveMoneyInput/ExpressiveMoneyInput.story.tsx +18 -0
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.test.tsx +119 -1
- package/src/expressiveMoneyInput/currencySelector/CurrencySelector.tsx +4 -3
- package/src/main.css +22 -22
- package/src/styles/less/neptune.css +22 -22
|
@@ -120,12 +120,12 @@ describe('locale utils', () => {
|
|
|
120
120
|
const result = getLocaleCurrencyName(intl, 'USD');
|
|
121
121
|
expect(intl.formatDisplayName).toHaveBeenCalledWith('USD', {
|
|
122
122
|
type: 'currency',
|
|
123
|
-
fallback: '
|
|
123
|
+
fallback: 'none',
|
|
124
124
|
});
|
|
125
125
|
expect(result).toBe('US Dollar');
|
|
126
126
|
});
|
|
127
127
|
|
|
128
|
-
it('should return the
|
|
128
|
+
it('should return the formatted currency code if Intl.DisplayNames is not supported', () => {
|
|
129
129
|
const intl = {
|
|
130
130
|
formatDisplayName: jest.fn().mockReturnValue('US Dollar'),
|
|
131
131
|
} as unknown as IntlShape;
|
|
@@ -134,8 +134,17 @@ describe('locale utils', () => {
|
|
|
134
134
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
135
135
|
(Intl as any).DisplayNames = undefined;
|
|
136
136
|
|
|
137
|
-
const result = getLocaleCurrencyName(intl, '
|
|
138
|
-
expect(result).toBe('
|
|
137
|
+
const result = getLocaleCurrencyName(intl, 'USC');
|
|
138
|
+
expect(result).toBe('USDC');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should return the formatted code when formatDisplayName does not support the currency code', () => {
|
|
142
|
+
const intl = {
|
|
143
|
+
formatDisplayName: jest.fn().mockReturnValue(undefined),
|
|
144
|
+
} as unknown as IntlShape;
|
|
145
|
+
|
|
146
|
+
const result = getLocaleCurrencyName(intl, 'USC');
|
|
147
|
+
expect(result).toBe('USDC');
|
|
139
148
|
});
|
|
140
149
|
});
|
|
141
150
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IntlShape } from 'react-intl/src/types';
|
|
2
|
+
import { formatCurrencyCode } from '@transferwise/formatting';
|
|
2
3
|
import { Direction } from '../direction';
|
|
3
4
|
|
|
4
5
|
export const DEFAULT_LANG = 'en';
|
|
@@ -105,7 +106,12 @@ export function getDirectionFromLocale(locale: string) {
|
|
|
105
106
|
* @returns The localized currency name if Intl.DisplayNames is supported supported, otherwise returns the original currency code.
|
|
106
107
|
*/
|
|
107
108
|
export function getLocaleCurrencyName(intl: IntlShape, currencyCode: string) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
if (typeof Intl.DisplayNames === 'function') {
|
|
110
|
+
const localisedName = intl.formatDisplayName(currencyCode, {
|
|
111
|
+
type: 'currency',
|
|
112
|
+
fallback: 'none',
|
|
113
|
+
});
|
|
114
|
+
return localisedName != null ? localisedName : formatCurrencyCode(currencyCode);
|
|
115
|
+
}
|
|
116
|
+
return formatCurrencyCode(currencyCode);
|
|
111
117
|
}
|
|
@@ -161,6 +161,24 @@ export const WithInlinePromptSentiment = {
|
|
|
161
161
|
},
|
|
162
162
|
};
|
|
163
163
|
|
|
164
|
+
export const WithFormattedCurrencyCode = {
|
|
165
|
+
args: {
|
|
166
|
+
currency: 'USC',
|
|
167
|
+
currencySelector: {
|
|
168
|
+
...getCurrencySelectorProps({ logEvents: true }),
|
|
169
|
+
options: [
|
|
170
|
+
{
|
|
171
|
+
title: 'Popular',
|
|
172
|
+
currencies: [
|
|
173
|
+
{ code: 'USC', label: 'Digital Dollar', keywords: ['USDC', 'Digital Dollar'] },
|
|
174
|
+
{ code: 'USD', label: 'US Dollar', keywords: ['dollar', 'us'] },
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
164
182
|
export const WithSecondaryCurrencySelectorAvatar = {
|
|
165
183
|
args: {
|
|
166
184
|
currencySelector: getCurrencySelectorProps({ logEvents: true, secondAvatar: true }),
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
mockMatchMedia,
|
|
3
|
+
mockResizeObserver,
|
|
4
|
+
render,
|
|
5
|
+
screen,
|
|
6
|
+
userEvent,
|
|
7
|
+
waitFor,
|
|
8
|
+
} from '../../test-utils';
|
|
2
9
|
|
|
3
10
|
import { CurrencySelector } from './CurrencySelector';
|
|
4
11
|
|
|
@@ -92,6 +99,112 @@ describe('CurrencySelector', () => {
|
|
|
92
99
|
expect(screen.getByRole('combobox')).toBeDisabled();
|
|
93
100
|
});
|
|
94
101
|
|
|
102
|
+
it('displays formatted currency code when the currency is selected', () => {
|
|
103
|
+
render(<CurrencySelector options={mockCurrencies} id="id" currency="USC" labelId="labelId" />);
|
|
104
|
+
|
|
105
|
+
expect(screen.getByRole('combobox', { name: 'Select currency' })).toHaveTextContent('USDC');
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('displays formatted currency code in the selected option content', async () => {
|
|
109
|
+
render(
|
|
110
|
+
<CurrencySelector
|
|
111
|
+
options={[
|
|
112
|
+
{
|
|
113
|
+
title: 'All',
|
|
114
|
+
currencies: [
|
|
115
|
+
{ code: 'USC', label: 'USDC', keywords: ['USDC'] },
|
|
116
|
+
{ code: 'EUR', label: 'Euro', keywords: ['EUR'] },
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
]}
|
|
120
|
+
id="id"
|
|
121
|
+
currency="USC"
|
|
122
|
+
labelId="labelId"
|
|
123
|
+
onChange={jest.fn()}
|
|
124
|
+
/>,
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
await userEvent.click(screen.getByRole('combobox'));
|
|
128
|
+
|
|
129
|
+
expect(screen.getByRole('option', { name: /^usdc/iu })).toHaveTextContent('USDC');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('fires onChange with the raw currency code when selecting a formatted currency', async () => {
|
|
133
|
+
const onChange = jest.fn();
|
|
134
|
+
render(
|
|
135
|
+
<CurrencySelector
|
|
136
|
+
options={[
|
|
137
|
+
{
|
|
138
|
+
title: 'All',
|
|
139
|
+
currencies: [
|
|
140
|
+
{ code: 'USC', label: 'USDC', keywords: ['USC'] },
|
|
141
|
+
{ code: 'EUR', label: 'Euro', keywords: ['EUR'] },
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
]}
|
|
145
|
+
id="id"
|
|
146
|
+
currency="EUR"
|
|
147
|
+
labelId="labelId"
|
|
148
|
+
onChange={onChange}
|
|
149
|
+
/>,
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
await userEvent.click(screen.getByRole('combobox'));
|
|
153
|
+
await userEvent.click(screen.getByRole('option', { name: /^usdc/iu }));
|
|
154
|
+
|
|
155
|
+
expect(onChange).toHaveBeenCalledWith('USC');
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('returns USC option when searching by the formatted code USDC', async () => {
|
|
159
|
+
render(
|
|
160
|
+
<CurrencySelector
|
|
161
|
+
options={mockCurrencies}
|
|
162
|
+
id="id"
|
|
163
|
+
currency="USD"
|
|
164
|
+
labelId="labelId"
|
|
165
|
+
onChange={jest.fn()}
|
|
166
|
+
/>,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
await userEvent.click(screen.getByRole('combobox', { name: 'Select currency' }));
|
|
170
|
+
|
|
171
|
+
await userEvent.type(
|
|
172
|
+
screen.getByRole('combobox', {
|
|
173
|
+
name: /type a currency \/ country/iu,
|
|
174
|
+
}),
|
|
175
|
+
'USDC',
|
|
176
|
+
);
|
|
177
|
+
|
|
178
|
+
await waitFor(() => {
|
|
179
|
+
expect(screen.getByRole('option', { name: /usdc/iu })).toBeInTheDocument();
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('does not return USDC option when searching by the raw code USC', async () => {
|
|
184
|
+
render(
|
|
185
|
+
<CurrencySelector
|
|
186
|
+
options={mockCurrencies}
|
|
187
|
+
id="id"
|
|
188
|
+
currency="USD"
|
|
189
|
+
labelId="labelId"
|
|
190
|
+
onChange={jest.fn()}
|
|
191
|
+
/>,
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
await userEvent.click(screen.getByRole('combobox', { name: 'Select currency' }));
|
|
195
|
+
|
|
196
|
+
await userEvent.type(
|
|
197
|
+
screen.getByRole('combobox', {
|
|
198
|
+
name: /type a currency \/ country/iu,
|
|
199
|
+
}),
|
|
200
|
+
'USC',
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
await waitFor(() => {
|
|
204
|
+
expect(screen.queryByRole('option')).not.toBeInTheDocument();
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
95
208
|
it('deduplicates currencies while searching', async () => {
|
|
96
209
|
render(
|
|
97
210
|
<CurrencySelector
|
|
@@ -155,6 +268,11 @@ const mockCurrencies = [
|
|
|
155
268
|
label: 'Australian Dollar',
|
|
156
269
|
keywords: ['AUD', 'australia'],
|
|
157
270
|
},
|
|
271
|
+
{
|
|
272
|
+
code: 'USC',
|
|
273
|
+
label: 'Digital Dollar',
|
|
274
|
+
keywords: ['USDC', 'Digital Dollar'],
|
|
275
|
+
},
|
|
158
276
|
],
|
|
159
277
|
},
|
|
160
278
|
];
|
|
@@ -19,6 +19,7 @@ import { useIntl } from 'react-intl';
|
|
|
19
19
|
|
|
20
20
|
import messages from '../ExpressiveMoneyInput.messages';
|
|
21
21
|
import { getLocaleCurrencyName } from '../../common';
|
|
22
|
+
import { formatCurrencyCode } from '@transferwise/formatting';
|
|
22
23
|
|
|
23
24
|
export interface CurrencyOption {
|
|
24
25
|
label?: string;
|
|
@@ -99,7 +100,7 @@ export const CurrencySelector = ({
|
|
|
99
100
|
renderValue={({ code, label }) => {
|
|
100
101
|
return (
|
|
101
102
|
<SelectInputOptionContent
|
|
102
|
-
title={code}
|
|
103
|
+
title={formatCurrencyCode(code)}
|
|
103
104
|
note={label}
|
|
104
105
|
icon={<Flag code={code} intrinsicSize={24} />}
|
|
105
106
|
/>
|
|
@@ -128,7 +129,7 @@ export const CurrencySelector = ({
|
|
|
128
129
|
onClick={(event) => handleTriggerClick(event)}
|
|
129
130
|
>
|
|
130
131
|
<>
|
|
131
|
-
<span aria-hidden>{currency}</span>
|
|
132
|
+
<span aria-hidden>{formatCurrencyCode(currency)}</span>
|
|
132
133
|
<span className="sr-only">{getLocaleCurrencyName(intl, currency)}</span>
|
|
133
134
|
</>
|
|
134
135
|
</SelectInputTriggerButton>
|
|
@@ -203,7 +204,7 @@ const filterAndSortCurrenciesForQuery = (
|
|
|
203
204
|
currencies
|
|
204
205
|
.filter((currency) => {
|
|
205
206
|
return (
|
|
206
|
-
currency.code.toLowerCase().includes(query) ||
|
|
207
|
+
formatCurrencyCode(currency.code).toLowerCase().includes(query) ||
|
|
207
208
|
(currency.label ?? '').toLowerCase().includes(query) ||
|
|
208
209
|
currency.keywords?.some((keyword) => keyword.toLowerCase().includes(query))
|
|
209
210
|
);
|
package/src/main.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Do not edit directly
|
|
3
|
-
* Generated on
|
|
2
|
+
* Do not edit directly, this file was auto-generated.
|
|
3
|
+
* Generated on Tue, 31 Mar 2026 13:02:10 GMT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
:root {
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Do not edit directly
|
|
146
|
-
* Generated on
|
|
145
|
+
* Do not edit directly, this file was auto-generated.
|
|
146
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
149
|
.np-theme-personal {
|
|
@@ -391,8 +391,8 @@
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
|
-
* Do not edit directly
|
|
395
|
-
* Generated on
|
|
394
|
+
* Do not edit directly, this file was auto-generated.
|
|
395
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
396
396
|
*/
|
|
397
397
|
|
|
398
398
|
.np-theme-personal--forest-green {
|
|
@@ -640,8 +640,8 @@
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
|
-
* Do not edit directly
|
|
644
|
-
* Generated on
|
|
643
|
+
* Do not edit directly, this file was auto-generated.
|
|
644
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
645
645
|
*/
|
|
646
646
|
|
|
647
647
|
.np-theme-personal--bright-green {
|
|
@@ -889,8 +889,8 @@
|
|
|
889
889
|
}
|
|
890
890
|
|
|
891
891
|
/**
|
|
892
|
-
* Do not edit directly
|
|
893
|
-
* Generated on
|
|
892
|
+
* Do not edit directly, this file was auto-generated.
|
|
893
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
894
894
|
*/
|
|
895
895
|
|
|
896
896
|
.np-theme-personal--dark {
|
|
@@ -1138,8 +1138,8 @@
|
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
1140
|
/**
|
|
1141
|
-
* Do not edit directly
|
|
1142
|
-
* Generated on
|
|
1141
|
+
* Do not edit directly, this file was auto-generated.
|
|
1142
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1143
1143
|
*/
|
|
1144
1144
|
|
|
1145
1145
|
.np-theme-platform {
|
|
@@ -1321,8 +1321,8 @@
|
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
1323
|
/**
|
|
1324
|
-
* Do not edit directly
|
|
1325
|
-
* Generated on
|
|
1324
|
+
* Do not edit directly, this file was auto-generated.
|
|
1325
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1326
1326
|
*/
|
|
1327
1327
|
|
|
1328
1328
|
.np-theme-platform--forest-green {
|
|
@@ -1504,8 +1504,8 @@
|
|
|
1504
1504
|
}
|
|
1505
1505
|
|
|
1506
1506
|
/**
|
|
1507
|
-
* Do not edit directly
|
|
1508
|
-
* Generated on
|
|
1507
|
+
* Do not edit directly, this file was auto-generated.
|
|
1508
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1509
1509
|
*/
|
|
1510
1510
|
|
|
1511
1511
|
.np-theme-business {
|
|
@@ -1688,8 +1688,8 @@
|
|
|
1688
1688
|
}
|
|
1689
1689
|
|
|
1690
1690
|
/**
|
|
1691
|
-
* Do not edit directly
|
|
1692
|
-
* Generated on
|
|
1691
|
+
* Do not edit directly, this file was auto-generated.
|
|
1692
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1693
1693
|
*/
|
|
1694
1694
|
|
|
1695
1695
|
.np-theme-business--dark {
|
|
@@ -1872,8 +1872,8 @@
|
|
|
1872
1872
|
}
|
|
1873
1873
|
|
|
1874
1874
|
/**
|
|
1875
|
-
* Do not edit directly
|
|
1876
|
-
* Generated on
|
|
1875
|
+
* Do not edit directly, this file was auto-generated.
|
|
1876
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1877
1877
|
*/
|
|
1878
1878
|
|
|
1879
1879
|
.np-theme-business--forest-green {
|
|
@@ -2056,8 +2056,8 @@
|
|
|
2056
2056
|
}
|
|
2057
2057
|
|
|
2058
2058
|
/**
|
|
2059
|
-
* Do not edit directly
|
|
2060
|
-
* Generated on
|
|
2059
|
+
* Do not edit directly, this file was auto-generated.
|
|
2060
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
2061
2061
|
*/
|
|
2062
2062
|
|
|
2063
2063
|
.np-theme-business--bright-green {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Do not edit directly
|
|
3
|
-
* Generated on
|
|
2
|
+
* Do not edit directly, this file was auto-generated.
|
|
3
|
+
* Generated on Tue, 31 Mar 2026 13:02:10 GMT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
:root {
|
|
@@ -142,8 +142,8 @@
|
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
/**
|
|
145
|
-
* Do not edit directly
|
|
146
|
-
* Generated on
|
|
145
|
+
* Do not edit directly, this file was auto-generated.
|
|
146
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
147
147
|
*/
|
|
148
148
|
|
|
149
149
|
.np-theme-personal {
|
|
@@ -391,8 +391,8 @@
|
|
|
391
391
|
}
|
|
392
392
|
|
|
393
393
|
/**
|
|
394
|
-
* Do not edit directly
|
|
395
|
-
* Generated on
|
|
394
|
+
* Do not edit directly, this file was auto-generated.
|
|
395
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
396
396
|
*/
|
|
397
397
|
|
|
398
398
|
.np-theme-personal--forest-green {
|
|
@@ -640,8 +640,8 @@
|
|
|
640
640
|
}
|
|
641
641
|
|
|
642
642
|
/**
|
|
643
|
-
* Do not edit directly
|
|
644
|
-
* Generated on
|
|
643
|
+
* Do not edit directly, this file was auto-generated.
|
|
644
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
645
645
|
*/
|
|
646
646
|
|
|
647
647
|
.np-theme-personal--bright-green {
|
|
@@ -889,8 +889,8 @@
|
|
|
889
889
|
}
|
|
890
890
|
|
|
891
891
|
/**
|
|
892
|
-
* Do not edit directly
|
|
893
|
-
* Generated on
|
|
892
|
+
* Do not edit directly, this file was auto-generated.
|
|
893
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
894
894
|
*/
|
|
895
895
|
|
|
896
896
|
.np-theme-personal--dark {
|
|
@@ -1138,8 +1138,8 @@
|
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
1140
|
/**
|
|
1141
|
-
* Do not edit directly
|
|
1142
|
-
* Generated on
|
|
1141
|
+
* Do not edit directly, this file was auto-generated.
|
|
1142
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1143
1143
|
*/
|
|
1144
1144
|
|
|
1145
1145
|
.np-theme-platform {
|
|
@@ -1321,8 +1321,8 @@
|
|
|
1321
1321
|
}
|
|
1322
1322
|
|
|
1323
1323
|
/**
|
|
1324
|
-
* Do not edit directly
|
|
1325
|
-
* Generated on
|
|
1324
|
+
* Do not edit directly, this file was auto-generated.
|
|
1325
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1326
1326
|
*/
|
|
1327
1327
|
|
|
1328
1328
|
.np-theme-platform--forest-green {
|
|
@@ -1504,8 +1504,8 @@
|
|
|
1504
1504
|
}
|
|
1505
1505
|
|
|
1506
1506
|
/**
|
|
1507
|
-
* Do not edit directly
|
|
1508
|
-
* Generated on
|
|
1507
|
+
* Do not edit directly, this file was auto-generated.
|
|
1508
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1509
1509
|
*/
|
|
1510
1510
|
|
|
1511
1511
|
.np-theme-business {
|
|
@@ -1688,8 +1688,8 @@
|
|
|
1688
1688
|
}
|
|
1689
1689
|
|
|
1690
1690
|
/**
|
|
1691
|
-
* Do not edit directly
|
|
1692
|
-
* Generated on
|
|
1691
|
+
* Do not edit directly, this file was auto-generated.
|
|
1692
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1693
1693
|
*/
|
|
1694
1694
|
|
|
1695
1695
|
.np-theme-business--dark {
|
|
@@ -1872,8 +1872,8 @@
|
|
|
1872
1872
|
}
|
|
1873
1873
|
|
|
1874
1874
|
/**
|
|
1875
|
-
* Do not edit directly
|
|
1876
|
-
* Generated on
|
|
1875
|
+
* Do not edit directly, this file was auto-generated.
|
|
1876
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
1877
1877
|
*/
|
|
1878
1878
|
|
|
1879
1879
|
.np-theme-business--forest-green {
|
|
@@ -2056,8 +2056,8 @@
|
|
|
2056
2056
|
}
|
|
2057
2057
|
|
|
2058
2058
|
/**
|
|
2059
|
-
* Do not edit directly
|
|
2060
|
-
* Generated on
|
|
2059
|
+
* Do not edit directly, this file was auto-generated.
|
|
2060
|
+
* Generated on Tue, 31 Mar 2026 13:02:11 GMT
|
|
2061
2061
|
*/
|
|
2062
2062
|
|
|
2063
2063
|
.np-theme-business--bright-green {
|