@transferwise/components 0.0.0-experimental-400b45a → 0.0.0-experimental-8cc553f
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/moneyInput/MoneyInput.js +12 -28
- package/build/moneyInput/MoneyInput.js.map +1 -1
- package/build/moneyInput/MoneyInput.mjs +14 -30
- package/build/moneyInput/MoneyInput.mjs.map +1 -1
- package/build/moneyInput/currencyFormatting.js +2 -8
- package/build/moneyInput/currencyFormatting.js.map +1 -1
- package/build/moneyInput/currencyFormatting.mjs +4 -5
- package/build/moneyInput/currencyFormatting.mjs.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +0 -6
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/moneyInput/currencyFormatting.d.ts +3 -4
- package/build/types/moneyInput/currencyFormatting.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/moneyInput/MoneyInput.story.tsx +1 -10
- package/src/moneyInput/MoneyInput.test.story.tsx +1 -141
- package/src/moneyInput/MoneyInput.test.tsx +0 -45
- package/src/moneyInput/MoneyInput.tsx +3 -27
- package/src/moneyInput/currencyFormatting.ts +5 -11
|
@@ -50,24 +50,16 @@ const isNumberOrNull = v => neptuneValidation.isNumber(v) || neptuneValidation.i
|
|
|
50
50
|
const formatAmountIfSet = ({
|
|
51
51
|
amount,
|
|
52
52
|
currency,
|
|
53
|
-
locale
|
|
54
|
-
decimals
|
|
53
|
+
locale
|
|
55
54
|
}) => {
|
|
56
|
-
|
|
57
|
-
return '';
|
|
58
|
-
}
|
|
59
|
-
if (decimals != null && currencyFormatting.getCurrencyDecimals(currency) !== 0) {
|
|
60
|
-
return formatting.formatNumber(amount, locale, decimals);
|
|
61
|
-
}
|
|
62
|
-
return formatting.formatAmount(amount, currency, locale);
|
|
55
|
+
return typeof amount === 'number' ? formatting.formatAmount(amount, currency, locale) : '';
|
|
63
56
|
};
|
|
64
57
|
const parseNumber = ({
|
|
65
58
|
amount,
|
|
66
59
|
currency,
|
|
67
|
-
locale
|
|
68
|
-
decimals
|
|
60
|
+
locale
|
|
69
61
|
}) => {
|
|
70
|
-
return currencyFormatting.parseAmount(amount, currency, locale
|
|
62
|
+
return currencyFormatting.parseAmount(amount, currency, locale);
|
|
71
63
|
};
|
|
72
64
|
const allowedInputKeys = new Set(['Backspace', 'Delete', ',', '.', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight', 'Enter', 'Escape', 'Tab']);
|
|
73
65
|
class MoneyInput extends React.Component {
|
|
@@ -84,8 +76,7 @@ class MoneyInput extends React.Component {
|
|
|
84
76
|
formattedAmount: formatAmountIfSet({
|
|
85
77
|
amount: props.amount,
|
|
86
78
|
currency: props.selectedCurrency.currency,
|
|
87
|
-
locale: props.intl.locale
|
|
88
|
-
decimals: props.decimals
|
|
79
|
+
locale: props.intl.locale
|
|
89
80
|
}),
|
|
90
81
|
locale: props.intl.locale
|
|
91
82
|
};
|
|
@@ -99,8 +90,7 @@ class MoneyInput extends React.Component {
|
|
|
99
90
|
formattedAmount: formatAmountIfSet({
|
|
100
91
|
amount: nextProps.amount,
|
|
101
92
|
currency: nextProps.selectedCurrency.currency,
|
|
102
|
-
locale: nextProps.intl.locale
|
|
103
|
-
decimals: nextProps.decimals
|
|
93
|
+
locale: nextProps.intl.locale
|
|
104
94
|
})
|
|
105
95
|
});
|
|
106
96
|
}
|
|
@@ -127,16 +117,14 @@ class MoneyInput extends React.Component {
|
|
|
127
117
|
const parsed = neptuneValidation.isEmpty(paste) ? null : parseNumber({
|
|
128
118
|
amount: paste,
|
|
129
119
|
currency: this.props.selectedCurrency.currency,
|
|
130
|
-
locale
|
|
131
|
-
decimals: this.props.decimals
|
|
120
|
+
locale
|
|
132
121
|
});
|
|
133
122
|
if (isNumberOrNull(parsed)) {
|
|
134
123
|
this.setState({
|
|
135
124
|
formattedAmount: formatAmountIfSet({
|
|
136
125
|
amount: parsed,
|
|
137
126
|
currency: this.props.selectedCurrency.currency,
|
|
138
|
-
locale
|
|
139
|
-
decimals: this.props.decimals
|
|
127
|
+
locale
|
|
140
128
|
})
|
|
141
129
|
});
|
|
142
130
|
this.props.onAmountChange?.(parsed);
|
|
@@ -153,8 +141,7 @@ class MoneyInput extends React.Component {
|
|
|
153
141
|
const parsed = neptuneValidation.isEmpty(value) ? null : parseNumber({
|
|
154
142
|
amount: value,
|
|
155
143
|
currency: this.props.selectedCurrency.currency,
|
|
156
|
-
locale: this.state.locale
|
|
157
|
-
decimals: this.props.decimals
|
|
144
|
+
locale: this.state.locale
|
|
158
145
|
});
|
|
159
146
|
if (isNumberOrNull(parsed)) {
|
|
160
147
|
this.props.onAmountChange?.(parsed);
|
|
@@ -194,8 +181,7 @@ class MoneyInput extends React.Component {
|
|
|
194
181
|
const parsed = parseNumber({
|
|
195
182
|
amount: previousState.formattedAmount,
|
|
196
183
|
currency: this.props.selectedCurrency.currency,
|
|
197
|
-
locale: previousState.locale
|
|
198
|
-
decimals: this.props.decimals
|
|
184
|
+
locale: previousState.locale
|
|
199
185
|
});
|
|
200
186
|
if (!isNumberOrNull(parsed)) {
|
|
201
187
|
return {
|
|
@@ -206,8 +192,7 @@ class MoneyInput extends React.Component {
|
|
|
206
192
|
formattedAmount: formatAmountIfSet({
|
|
207
193
|
amount: parsed,
|
|
208
194
|
currency: this.props.selectedCurrency.currency,
|
|
209
|
-
locale: previousState.locale
|
|
210
|
-
decimals: this.props.decimals
|
|
195
|
+
locale: previousState.locale
|
|
211
196
|
})
|
|
212
197
|
};
|
|
213
198
|
});
|
|
@@ -272,8 +257,7 @@ class MoneyInput extends React.Component {
|
|
|
272
257
|
placeholder: formatAmountIfSet({
|
|
273
258
|
amount: this.props.placeholder,
|
|
274
259
|
currency: this.props.selectedCurrency.currency,
|
|
275
|
-
locale: this.state.locale
|
|
276
|
-
decimals: this.props.decimals
|
|
260
|
+
locale: this.state.locale
|
|
277
261
|
}),
|
|
278
262
|
autoComplete: "off",
|
|
279
263
|
"aria-describedby": selectedCurrencyElementId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.js","sources":["../../src/moneyInput/MoneyInput.tsx"],"sourcesContent":["import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';\nimport { Flag } from '@wise/art';\nimport { clsx } from 'clsx';\nimport { Component } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport {\n Typography,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n getLocaleCurrencyName,\n} from '../common';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputItem,\n SelectInputOptionContent,\n SelectInputOptionItem,\n SelectInputProps,\n} from '../inputs/SelectInput';\nimport Title from '../title';\n\nimport messages from './MoneyInput.messages';\nimport { formatAmount, formatNumber, getCurrencyDecimals, parseAmount } from './currencyFormatting';\nimport withId from '../withId';\n\nexport interface CurrencyOptionItem {\n header?: never;\n value: string;\n label: string;\n currency: string;\n note?: string;\n searchable?: string;\n}\n\nexport interface CurrencyHeaderItem {\n header: string;\n}\n\nexport type CurrencyItem = CurrencyOptionItem | CurrencyHeaderItem;\n\nconst isNumberOrNull = (v: unknown): v is number | null => isNumber(v) || isNull(v);\n\nconst formatAmountIfSet = ({\n amount,\n currency,\n locale,\n decimals,\n}: {\n amount: number | null | undefined;\n currency: string;\n locale: string;\n decimals?: number;\n}) => {\n if (typeof amount !== 'number') {\n return '';\n }\n if (decimals != null && getCurrencyDecimals(currency) !== 0) {\n return formatNumber(amount, locale, decimals);\n }\n return formatAmount(amount, currency, locale);\n};\n\nconst parseNumber = ({\n amount,\n currency,\n locale,\n decimals,\n}: {\n amount: string;\n currency: string;\n locale: string;\n decimals?: number;\n}) => {\n return parseAmount(amount, currency, locale, decimals);\n};\n\nconst allowedInputKeys = new Set([\n 'Backspace',\n 'Delete',\n ',',\n '.',\n 'ArrowDown',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n 'Escape',\n 'Tab',\n]);\n\nexport interface MoneyInputProps extends WrappedComponentProps {\n id?: string;\n 'aria-labelledby'?: string;\n currencies: readonly CurrencyItem[];\n selectedCurrency: CurrencyOptionItem;\n onCurrencyChange?: (value: CurrencyOptionItem) => void;\n placeholder?: number;\n amount: number | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n onAmountChange?: (value: number | null) => void;\n addon?: React.ReactNode;\n searchPlaceholder?: string;\n /**\n * Allows the consumer to react to searching, while the search itself is handled internally.\n */\n onSearchChange?: (value: { searchQuery: string; filteredOptions: CurrencyItem[] }) => void;\n customActionLabel?: React.ReactNode;\n onCustomAction?: () => void;\n classNames?: Record<string, string>;\n selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;\n /**\n * Specify the number of decimal places to format the amount. When not specified, the number of\n * decimals is determined by the selected currency (e.g. 2 for EUR, 0 for JPY, 3 for BHD).\n * This override is ignored for zero-decimal currencies (e.g. JPY, KRW, HUF), which always use 0.\n */\n decimals?: number;\n}\n\nexport type MoneyInputPropsWithInputAttributes = MoneyInputProps &\n Partial<WithInputAttributesProps>;\n\ninterface MoneyInputState {\n searchQuery: string;\n formattedAmount: string;\n locale: string;\n}\n\nclass MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInputState> {\n declare props: MoneyInputPropsWithInputAttributes &\n Required<Pick<MoneyInputPropsWithInputAttributes, keyof typeof MoneyInput.defaultProps>>;\n\n static defaultProps = {\n size: Size.LARGE,\n classNames: {},\n selectProps: {},\n } satisfies Partial<MoneyInputPropsWithInputAttributes>;\n\n amountFocused = false;\n\n constructor(props: MoneyInputProps) {\n super(props);\n this.state = {\n searchQuery: '',\n formattedAmount: formatAmountIfSet({\n amount: props.amount,\n currency: props.selectedCurrency.currency,\n locale: props.intl.locale,\n decimals: props.decimals,\n }),\n locale: props.intl.locale,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MoneyInputProps) {\n this.setState({ locale: nextProps.intl.locale });\n\n if (!this.amountFocused) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: nextProps.amount,\n currency: nextProps.selectedCurrency.currency,\n locale: nextProps.intl.locale,\n decimals: nextProps.decimals,\n }),\n });\n }\n }\n\n isInputAllowedForKeyEvent = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { metaKey, key, ctrlKey } = event;\n const isNumberKey = isNumber(Number.parseInt(key, 10));\n\n return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);\n };\n\n handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n if (!this.isInputAllowedForKeyEvent(event)) {\n event.preventDefault();\n }\n };\n\n handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const paste = event.clipboardData.getData('text');\n const { locale } = this.state;\n const parsed = isEmpty(paste)\n ? null\n : parseNumber({\n amount: paste,\n currency: this.props.selectedCurrency.currency,\n locale,\n decimals: this.props.decimals,\n });\n\n if (isNumberOrNull(parsed)) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale,\n decimals: this.props.decimals,\n }),\n });\n this.props.onAmountChange?.(parsed);\n }\n\n event.preventDefault();\n };\n\n onAmountChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n this.setState({\n formattedAmount: value,\n });\n const parsed = isEmpty(value)\n ? null\n : parseNumber({\n amount: value,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n decimals: this.props.decimals,\n });\n if (isNumberOrNull(parsed)) {\n this.props.onAmountChange?.(parsed);\n }\n };\n\n onAmountBlur = () => {\n this.amountFocused = false;\n this.setAmount();\n };\n\n onAmountFocus = () => {\n this.amountFocused = true;\n };\n\n getSelectOptions() {\n const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);\n\n const formattedOptions: SelectInputItem<CurrencyOptionItem>[] = [];\n let currentGroupOptions: SelectInputOptionItem<CurrencyOptionItem>[] | undefined;\n\n selectOptions.forEach((item) => {\n if (item.header != null) {\n currentGroupOptions = [];\n formattedOptions.push({\n type: 'group',\n label: item.header,\n options: currentGroupOptions,\n });\n } else {\n (currentGroupOptions ?? formattedOptions).push({\n type: 'option',\n value: item,\n filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? ''],\n });\n }\n });\n\n return formattedOptions;\n }\n\n setAmount() {\n this.setState((previousState) => {\n const parsed = parseNumber({\n amount: previousState.formattedAmount,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n decimals: this.props.decimals,\n });\n if (!isNumberOrNull(parsed)) {\n return {\n formattedAmount: previousState.formattedAmount,\n };\n }\n return {\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n decimals: this.props.decimals,\n }),\n };\n });\n }\n\n handleSelectChange = (value: CurrencyOptionItem) => {\n this.handleSearchChange('');\n this.props.onCurrencyChange?.(value);\n };\n\n handleSearchChange = (searchQuery: string) => {\n this.setState({ searchQuery });\n this.props.onSearchChange?.({\n searchQuery,\n filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery),\n });\n };\n\n style = (className: string) => this.props.classNames[className] || className;\n\n render() {\n const {\n inputAttributes,\n id: amountInputId,\n 'aria-labelledby': ariaLabelledByProp,\n selectedCurrency,\n onCurrencyChange,\n size,\n addon,\n selectProps,\n } = this.props;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n const selectOptions = this.getSelectOptions();\n\n const hasSingleCurrency = () => {\n if (selectOptions.length !== 0) {\n const firstItem = selectOptions[0];\n\n if (selectOptions.length === 1) {\n if (firstItem.type === 'option') {\n return firstItem.value.currency === selectedCurrency.currency;\n }\n if (firstItem.type === 'group') {\n return (\n firstItem.options.length === 1 &&\n !(this.props.onCustomAction && this.props.customActionLabel)\n );\n }\n }\n } else if (selectedCurrency?.currency) {\n return true;\n }\n\n return false;\n };\n\n const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;\n const disabled = !this.props.onAmountChange;\n const selectedCurrencyElementId = `${inputAttributes?.id ?? amountInputId}SelectedCurrency`;\n\n return (\n <fieldset\n aria-invalid={inputAttributes?.['aria-invalid']}\n aria-describedby={inputAttributes?.['aria-describedby']}\n aria-labelledby={inputAttributes?.id ?? amountInputId}\n className={clsx(\n this.style('tw-money-input'),\n this.style('input-group'),\n this.style(`input-group-${size}`),\n )}\n >\n <Input\n id={inputAttributes?.id ?? amountInputId}\n aria-labelledby={ariaLabelledBy}\n value={this.state.formattedAmount}\n inputMode=\"decimal\"\n disabled={disabled}\n placeholder={formatAmountIfSet({\n amount: this.props.placeholder,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n decimals: this.props.decimals,\n })}\n autoComplete=\"off\"\n aria-describedby={selectedCurrencyElementId}\n onKeyDown={this.handleKeyDown}\n onChange={this.onAmountChange}\n onFocus={this.onAmountFocus}\n onBlur={this.onAmountBlur}\n onPaste={this.handlePaste}\n />\n {addon && (\n <span\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n disabled ? this.style('disabled') : '',\n )}\n >\n {addon}\n </span>\n )}\n {isFixedCurrency ? (\n <div\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n this.style('tw-money-input__fixed-currency'),\n disabled ? this.style('disabled') : '',\n )}\n id={selectedCurrencyElementId}\n >\n {(size === 'lg' || size === 'md') && (\n <span className={clsx(this.style('money-input-currency-flag'), this.style('m-r-2'))}>\n <Flag code={selectedCurrency.currency.toLowerCase()} intrinsicSize={24} />\n </span>\n )}\n <Title\n as=\"span\"\n type={Typography.TITLE_SUBSECTION}\n className={size === 'lg' ? this.style('m-r-1') : ''}\n aria-label={getLocaleCurrencyName(this.props.intl, selectedCurrency.currency)}\n >\n {selectedCurrency.currency.toUpperCase()}\n </Title>\n </div>\n ) : (\n <div\n translate=\"no\"\n className={clsx(\n this.style('input-group-btn'),\n this.style('amount-currency-select-btn'),\n )}\n >\n <SelectInput\n UNSAFE_triggerButtonProps={{\n id: undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': ariaLabelledBy,\n 'aria-invalid': undefined,\n 'aria-label': this.props.intl.formatMessage(messages.selectCurrencyLabel),\n }}\n id={selectedCurrencyElementId}\n items={selectOptions}\n value={selectedCurrency}\n compareValues=\"currency\"\n renderValue={(currency, withinTrigger) => {\n return (\n <SelectInputOptionContent\n title={\n withinTrigger ? (\n <span\n aria-label={getLocaleCurrencyName(this.props.intl, currency.currency)}\n >\n {currency.currency.toUpperCase()}\n </span>\n ) : (\n currency.label\n )\n }\n note={withinTrigger ? undefined : currency.note}\n icon={<Flag code={currency.currency} intrinsicSize={24} />}\n />\n );\n }}\n renderFooter={\n this.props.onCustomAction\n ? () => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div role=\"button\" tabIndex={0} onClick={this.props.onCustomAction}>\n {this.props.customActionLabel}\n </div>\n )\n : undefined\n }\n placeholder={this.props.intl.formatMessage(messages.selectPlaceholder)}\n filterable\n filterPlaceholder={\n this.props.searchPlaceholder ||\n this.props.intl.formatMessage(messages.searchPlaceholder)\n }\n disabled={disabled}\n size={size}\n onChange={this.handleSelectChange}\n onFilterChange={({ queryNormalized }) => {\n this.handleSearchChange(queryNormalized ?? '');\n }}\n {...selectProps}\n />\n </div>\n )}\n </fieldset>\n );\n }\n}\n\nfunction filterCurrenciesForQuery(\n currencies: readonly CurrencyItem[],\n query: string,\n): CurrencyItem[] {\n if (!query) {\n return [...currencies];\n }\n\n const options = currencies.filter(\n (option): option is CurrencyOptionItem => option.header == null,\n );\n const filteredOptions = removeDuplicateValueOptions(options).filter((option) =>\n currencyOptionFitsQuery(option, query),\n );\n\n return sortOptionsLabelsToFirst(filteredOptions, query);\n}\n\nfunction removeDuplicateValueOptions(options: readonly CurrencyOptionItem[]) {\n const uniqueValues = new Set<string>();\n return options.filter((option) => {\n if (!uniqueValues.has(option.value)) {\n uniqueValues.add(option.value);\n return true;\n }\n return false;\n });\n}\n\nfunction currencyOptionFitsQuery(option: CurrencyOptionItem, query: string) {\n if (!option.value) {\n return false;\n }\n\n return (\n contains(option.label, query) ||\n contains(option.searchable, query) ||\n contains(option.note, query)\n );\n}\n\nfunction contains(property: string | undefined, query: string) {\n return property?.toLowerCase().includes(query.toLowerCase());\n}\n\nfunction sortOptionsLabelsToFirst(options: readonly CurrencyOptionItem[], query: string) {\n return [...options].sort((first, second) => {\n const firstContains = contains(first.label, query);\n const secondContains = contains(second.label, query);\n\n if (firstContains && secondContains) {\n return 0;\n }\n if (firstContains) {\n return -1;\n }\n if (secondContains) {\n return 1;\n }\n return 0;\n });\n}\n\nexport default injectIntl(withId(withInputAttributes(MoneyInput, { nonLabelable: true })));\n"],"names":["isNumberOrNull","v","isNumber","isNull","formatAmountIfSet","amount","currency","locale","decimals","getCurrencyDecimals","formatNumber","formatAmount","parseNumber","parseAmount","allowedInputKeys","Set","MoneyInput","Component","defaultProps","size","Size","LARGE","classNames","selectProps","amountFocused","constructor","props","state","searchQuery","formattedAmount","selectedCurrency","intl","UNSAFE_componentWillReceiveProps","nextProps","setState","isInputAllowedForKeyEvent","event","metaKey","key","ctrlKey","isNumberKey","Number","parseInt","has","handleKeyDown","preventDefault","handlePaste","paste","clipboardData","getData","parsed","isEmpty","onAmountChange","value","target","onAmountBlur","setAmount","onAmountFocus","getSelectOptions","selectOptions","filterCurrenciesForQuery","currencies","formattedOptions","currentGroupOptions","forEach","item","header","push","type","label","options","filterMatchers","note","searchable","previousState","handleSelectChange","handleSearchChange","onCurrencyChange","onSearchChange","filteredOptions","style","className","render","inputAttributes","id","amountInputId","ariaLabelledByProp","addon","ariaLabelledBy","hasSingleCurrency","length","firstItem","onCustomAction","customActionLabel","isFixedCurrency","disabled","selectedCurrencyElementId","_jsxs","clsx","children","_jsx","Input","inputMode","placeholder","autoComplete","onKeyDown","onChange","onFocus","onBlur","onPaste","Flag","code","toLowerCase","intrinsicSize","Title","as","Typography","TITLE_SUBSECTION","getLocaleCurrencyName","toUpperCase","translate","SelectInput","UNSAFE_triggerButtonProps","undefined","formatMessage","messages","selectCurrencyLabel","items","compareValues","renderValue","withinTrigger","SelectInputOptionContent","title","icon","renderFooter","role","tabIndex","onClick","selectPlaceholder","filterable","filterPlaceholder","searchPlaceholder","onFilterChange","queryNormalized","query","filter","option","removeDuplicateValueOptions","currencyOptionFitsQuery","sortOptionsLabelsToFirst","uniqueValues","add","contains","property","includes","sort","first","second","firstContains","secondContains","injectIntl","withId","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,cAAc,GAAIC,CAAU,IAAyBC,0BAAQ,CAACD,CAAC,CAAC,IAAIE,wBAAM,CAACF,CAAC,CAAC;AAEnF,MAAMG,iBAAiB,GAAGA,CAAC;EACzBC,MAAM;EACNC,QAAQ;EACRC,MAAM;AACNC,EAAAA;AAAQ,CAMT,KAAI;AACH,EAAA,IAAI,OAAOH,MAAM,KAAK,QAAQ,EAAE;AAC9B,IAAA,OAAO,EAAE;AACX,EAAA;EACA,IAAIG,QAAQ,IAAI,IAAI,IAAIC,sCAAmB,CAACH,QAAQ,CAAC,KAAK,CAAC,EAAE;AAC3D,IAAA,OAAOI,uBAAY,CAACL,MAAM,EAAEE,MAAM,EAAEC,QAAQ,CAAC;AAC/C,EAAA;AACA,EAAA,OAAOG,uBAAY,CAACN,MAAM,EAAEC,QAAQ,EAAEC,MAAM,CAAC;AAC/C,CAAC;AAED,MAAMK,WAAW,GAAGA,CAAC;EACnBP,MAAM;EACNC,QAAQ;EACRC,MAAM;AACNC,EAAAA;AAAQ,CAMT,KAAI;EACH,OAAOK,8BAAW,CAACR,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,QAAQ,CAAC;AACxD,CAAC;AAED,MAAMM,gBAAgB,GAAG,IAAIC,GAAG,CAAC,CAC/B,WAAW,EACX,QAAQ,EACR,GAAG,EAC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,KAAK,EAAE2E,KAAK,CAAC;IAClD,MAAMe,cAAc,GAAGP,QAAQ,CAACK,MAAM,CAACxF,KAAK,EAAE2E,KAAK,CAAC;IAEpD,IAAIc,aAAa,IAAIC,cAAc,EAAE;AACnC,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,IAAID,aAAa,EAAE;AACjB,MAAA,OAAO,EAAE;AACX,IAAA;AACA,IAAA,IAAIC,cAAc,EAAE;AAClB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO,CAAC;AACV,EAAA,CAAC,CAAC;AACJ;AAEA,yBAAeC,oBAAU,CAACC,cAAM,CAACC,4BAAmB,CAAClJ,UAAU,EAAE;AAAEmJ,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MoneyInput.js","sources":["../../src/moneyInput/MoneyInput.tsx"],"sourcesContent":["import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';\nimport { Flag } from '@wise/art';\nimport { clsx } from 'clsx';\nimport { Component } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport {\n Typography,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n getLocaleCurrencyName,\n} from '../common';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputItem,\n SelectInputOptionContent,\n SelectInputOptionItem,\n SelectInputProps,\n} from '../inputs/SelectInput';\nimport Title from '../title';\n\nimport messages from './MoneyInput.messages';\nimport { formatAmount, parseAmount } from './currencyFormatting';\nimport withId from '../withId';\n\nexport interface CurrencyOptionItem {\n header?: never;\n value: string;\n label: string;\n currency: string;\n note?: string;\n searchable?: string;\n}\n\nexport interface CurrencyHeaderItem {\n header: string;\n}\n\nexport type CurrencyItem = CurrencyOptionItem | CurrencyHeaderItem;\n\nconst isNumberOrNull = (v: unknown): v is number | null => isNumber(v) || isNull(v);\n\nconst formatAmountIfSet = ({\n amount,\n currency,\n locale,\n}: {\n amount: number | null | undefined;\n currency: string;\n locale: string;\n}) => {\n return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';\n};\n\nconst parseNumber = ({\n amount,\n currency,\n locale,\n}: {\n amount: string;\n currency: string;\n locale: string;\n}) => {\n return parseAmount(amount, currency, locale);\n};\n\nconst allowedInputKeys = new Set([\n 'Backspace',\n 'Delete',\n ',',\n '.',\n 'ArrowDown',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n 'Escape',\n 'Tab',\n]);\n\nexport interface MoneyInputProps extends WrappedComponentProps {\n id?: string;\n 'aria-labelledby'?: string;\n currencies: readonly CurrencyItem[];\n selectedCurrency: CurrencyOptionItem;\n onCurrencyChange?: (value: CurrencyOptionItem) => void;\n placeholder?: number;\n amount: number | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n onAmountChange?: (value: number | null) => void;\n addon?: React.ReactNode;\n searchPlaceholder?: string;\n /**\n * Allows the consumer to react to searching, while the search itself is handled internally.\n */\n onSearchChange?: (value: { searchQuery: string; filteredOptions: CurrencyItem[] }) => void;\n customActionLabel?: React.ReactNode;\n onCustomAction?: () => void;\n classNames?: Record<string, string>;\n selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;\n}\n\nexport type MoneyInputPropsWithInputAttributes = MoneyInputProps &\n Partial<WithInputAttributesProps>;\n\ninterface MoneyInputState {\n searchQuery: string;\n formattedAmount: string;\n locale: string;\n}\n\nclass MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInputState> {\n declare props: MoneyInputPropsWithInputAttributes &\n Required<Pick<MoneyInputPropsWithInputAttributes, keyof typeof MoneyInput.defaultProps>>;\n\n static defaultProps = {\n size: Size.LARGE,\n classNames: {},\n selectProps: {},\n } satisfies Partial<MoneyInputPropsWithInputAttributes>;\n\n amountFocused = false;\n\n constructor(props: MoneyInputProps) {\n super(props);\n this.state = {\n searchQuery: '',\n formattedAmount: formatAmountIfSet({\n amount: props.amount,\n currency: props.selectedCurrency.currency,\n locale: props.intl.locale,\n }),\n locale: props.intl.locale,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MoneyInputProps) {\n this.setState({ locale: nextProps.intl.locale });\n\n if (!this.amountFocused) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: nextProps.amount,\n currency: nextProps.selectedCurrency.currency,\n locale: nextProps.intl.locale,\n }),\n });\n }\n }\n\n isInputAllowedForKeyEvent = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { metaKey, key, ctrlKey } = event;\n const isNumberKey = isNumber(Number.parseInt(key, 10));\n\n return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);\n };\n\n handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n if (!this.isInputAllowedForKeyEvent(event)) {\n event.preventDefault();\n }\n };\n\n handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const paste = event.clipboardData.getData('text');\n const { locale } = this.state;\n const parsed = isEmpty(paste)\n ? null\n : parseNumber({\n amount: paste,\n currency: this.props.selectedCurrency.currency,\n locale,\n });\n\n if (isNumberOrNull(parsed)) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale,\n }),\n });\n this.props.onAmountChange?.(parsed);\n }\n\n event.preventDefault();\n };\n\n onAmountChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n this.setState({\n formattedAmount: value,\n });\n const parsed = isEmpty(value)\n ? null\n : parseNumber({\n amount: value,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n });\n if (isNumberOrNull(parsed)) {\n this.props.onAmountChange?.(parsed);\n }\n };\n\n onAmountBlur = () => {\n this.amountFocused = false;\n this.setAmount();\n };\n\n onAmountFocus = () => {\n this.amountFocused = true;\n };\n\n getSelectOptions() {\n const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);\n\n const formattedOptions: SelectInputItem<CurrencyOptionItem>[] = [];\n let currentGroupOptions: SelectInputOptionItem<CurrencyOptionItem>[] | undefined;\n\n selectOptions.forEach((item) => {\n if (item.header != null) {\n currentGroupOptions = [];\n formattedOptions.push({\n type: 'group',\n label: item.header,\n options: currentGroupOptions,\n });\n } else {\n (currentGroupOptions ?? formattedOptions).push({\n type: 'option',\n value: item,\n filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? ''],\n });\n }\n });\n\n return formattedOptions;\n }\n\n setAmount() {\n this.setState((previousState) => {\n const parsed = parseNumber({\n amount: previousState.formattedAmount,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n });\n if (!isNumberOrNull(parsed)) {\n return {\n formattedAmount: previousState.formattedAmount,\n };\n }\n return {\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n }),\n };\n });\n }\n\n handleSelectChange = (value: CurrencyOptionItem) => {\n this.handleSearchChange('');\n this.props.onCurrencyChange?.(value);\n };\n\n handleSearchChange = (searchQuery: string) => {\n this.setState({ searchQuery });\n this.props.onSearchChange?.({\n searchQuery,\n filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery),\n });\n };\n\n style = (className: string) => this.props.classNames[className] || className;\n\n render() {\n const {\n inputAttributes,\n id: amountInputId,\n 'aria-labelledby': ariaLabelledByProp,\n selectedCurrency,\n onCurrencyChange,\n size,\n addon,\n selectProps,\n } = this.props;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n const selectOptions = this.getSelectOptions();\n\n const hasSingleCurrency = () => {\n if (selectOptions.length !== 0) {\n const firstItem = selectOptions[0];\n\n if (selectOptions.length === 1) {\n if (firstItem.type === 'option') {\n return firstItem.value.currency === selectedCurrency.currency;\n }\n if (firstItem.type === 'group') {\n return (\n firstItem.options.length === 1 &&\n !(this.props.onCustomAction && this.props.customActionLabel)\n );\n }\n }\n } else if (selectedCurrency?.currency) {\n return true;\n }\n\n return false;\n };\n\n const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;\n const disabled = !this.props.onAmountChange;\n const selectedCurrencyElementId = `${inputAttributes?.id ?? amountInputId}SelectedCurrency`;\n\n return (\n <fieldset\n aria-invalid={inputAttributes?.['aria-invalid']}\n aria-describedby={inputAttributes?.['aria-describedby']}\n aria-labelledby={inputAttributes?.id ?? amountInputId}\n className={clsx(\n this.style('tw-money-input'),\n this.style('input-group'),\n this.style(`input-group-${size}`),\n )}\n >\n <Input\n id={inputAttributes?.id ?? amountInputId}\n aria-labelledby={ariaLabelledBy}\n value={this.state.formattedAmount}\n inputMode=\"decimal\"\n disabled={disabled}\n placeholder={formatAmountIfSet({\n amount: this.props.placeholder,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n })}\n autoComplete=\"off\"\n aria-describedby={selectedCurrencyElementId}\n onKeyDown={this.handleKeyDown}\n onChange={this.onAmountChange}\n onFocus={this.onAmountFocus}\n onBlur={this.onAmountBlur}\n onPaste={this.handlePaste}\n />\n {addon && (\n <span\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n disabled ? this.style('disabled') : '',\n )}\n >\n {addon}\n </span>\n )}\n {isFixedCurrency ? (\n <div\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n this.style('tw-money-input__fixed-currency'),\n disabled ? this.style('disabled') : '',\n )}\n id={selectedCurrencyElementId}\n >\n {(size === 'lg' || size === 'md') && (\n <span className={clsx(this.style('money-input-currency-flag'), this.style('m-r-2'))}>\n <Flag code={selectedCurrency.currency.toLowerCase()} intrinsicSize={24} />\n </span>\n )}\n <Title\n as=\"span\"\n type={Typography.TITLE_SUBSECTION}\n className={size === 'lg' ? this.style('m-r-1') : ''}\n aria-label={getLocaleCurrencyName(this.props.intl, selectedCurrency.currency)}\n >\n {selectedCurrency.currency.toUpperCase()}\n </Title>\n </div>\n ) : (\n <div\n translate=\"no\"\n className={clsx(\n this.style('input-group-btn'),\n this.style('amount-currency-select-btn'),\n )}\n >\n <SelectInput\n UNSAFE_triggerButtonProps={{\n id: undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': ariaLabelledBy,\n 'aria-invalid': undefined,\n 'aria-label': this.props.intl.formatMessage(messages.selectCurrencyLabel),\n }}\n id={selectedCurrencyElementId}\n items={selectOptions}\n value={selectedCurrency}\n compareValues=\"currency\"\n renderValue={(currency, withinTrigger) => {\n return (\n <SelectInputOptionContent\n title={\n withinTrigger ? (\n <span\n aria-label={getLocaleCurrencyName(this.props.intl, currency.currency)}\n >\n {currency.currency.toUpperCase()}\n </span>\n ) : (\n currency.label\n )\n }\n note={withinTrigger ? undefined : currency.note}\n icon={<Flag code={currency.currency} intrinsicSize={24} />}\n />\n );\n }}\n renderFooter={\n this.props.onCustomAction\n ? () => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div role=\"button\" tabIndex={0} onClick={this.props.onCustomAction}>\n {this.props.customActionLabel}\n </div>\n )\n : undefined\n }\n placeholder={this.props.intl.formatMessage(messages.selectPlaceholder)}\n filterable\n filterPlaceholder={\n this.props.searchPlaceholder ||\n this.props.intl.formatMessage(messages.searchPlaceholder)\n }\n disabled={disabled}\n size={size}\n onChange={this.handleSelectChange}\n onFilterChange={({ queryNormalized }) => {\n this.handleSearchChange(queryNormalized ?? '');\n }}\n {...selectProps}\n />\n </div>\n )}\n </fieldset>\n );\n }\n}\n\nfunction filterCurrenciesForQuery(\n currencies: readonly CurrencyItem[],\n query: string,\n): CurrencyItem[] {\n if (!query) {\n return [...currencies];\n }\n\n const options = currencies.filter(\n (option): option is CurrencyOptionItem => option.header == null,\n );\n const filteredOptions = removeDuplicateValueOptions(options).filter((option) =>\n currencyOptionFitsQuery(option, query),\n );\n\n return sortOptionsLabelsToFirst(filteredOptions, query);\n}\n\nfunction removeDuplicateValueOptions(options: readonly CurrencyOptionItem[]) {\n const uniqueValues = new Set<string>();\n return options.filter((option) => {\n if (!uniqueValues.has(option.value)) {\n uniqueValues.add(option.value);\n return true;\n }\n return false;\n });\n}\n\nfunction currencyOptionFitsQuery(option: CurrencyOptionItem, query: string) {\n if (!option.value) {\n return false;\n }\n\n return (\n contains(option.label, query) ||\n contains(option.searchable, query) ||\n contains(option.note, query)\n );\n}\n\nfunction contains(property: string | undefined, query: string) {\n return property?.toLowerCase().includes(query.toLowerCase());\n}\n\nfunction sortOptionsLabelsToFirst(options: readonly CurrencyOptionItem[], query: string) {\n return [...options].sort((first, second) => {\n const firstContains = contains(first.label, query);\n const secondContains = contains(second.label, query);\n\n if (firstContains && secondContains) {\n return 0;\n }\n if (firstContains) {\n return -1;\n }\n if (secondContains) {\n return 1;\n }\n return 0;\n });\n}\n\nexport default injectIntl(withId(withInputAttributes(MoneyInput, { nonLabelable: true })));\n"],"names":["isNumberOrNull","v","isNumber","isNull","formatAmountIfSet","amount","currency","locale","formatAmount","parseNumber","parseAmount","allowedInputKeys","Set","MoneyInput","Component","defaultProps","size","Size","LARGE","classNames","selectProps","amountFocused","constructor","props","state","searchQuery","formattedAmount","selectedCurrency","intl","UNSAFE_componentWillReceiveProps","nextProps","setState","isInputAllowedForKeyEvent","event","metaKey","key","ctrlKey","isNumberKey","Number","parseInt","has","handleKeyDown","preventDefault","handlePaste","paste","clipboardData","getData","parsed","isEmpty","onAmountChange","value","target","onAmountBlur","setAmount","onAmountFocus","getSelectOptions","selectOptions","filterCurrenciesForQuery","currencies","formattedOptions","currentGroupOptions","forEach","item","header","push","type","label","options","filterMatchers","note","searchable","previousState","handleSelectChange","handleSearchChange","onCurrencyChange","onSearchChange","filteredOptions","style","className","render","inputAttributes","id","amountInputId","ariaLabelledByProp","addon","ariaLabelledBy","hasSingleCurrency","length","firstItem","onCustomAction","customActionLabel","isFixedCurrency","disabled","selectedCurrencyElementId","_jsxs","clsx","children","_jsx","Input","inputMode","placeholder","autoComplete","onKeyDown","onChange","onFocus","onBlur","onPaste","Flag","code","toLowerCase","intrinsicSize","Title","as","Typography","TITLE_SUBSECTION","getLocaleCurrencyName","toUpperCase","translate","SelectInput","UNSAFE_triggerButtonProps","undefined","formatMessage","messages","selectCurrencyLabel","items","compareValues","renderValue","withinTrigger","SelectInputOptionContent","title","icon","renderFooter","role","tabIndex","onClick","selectPlaceholder","filterable","filterPlaceholder","searchPlaceholder","onFilterChange","queryNormalized","query","filter","option","removeDuplicateValueOptions","currencyOptionFitsQuery","sortOptionsLabelsToFirst","uniqueValues","add","contains","property","includes","sort","first","second","firstContains","secondContains","injectIntl","withId","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,cAAc,GAAIC,CAAU,IAAyBC,0BAAQ,CAACD,CAAC,CAAC,IAAIE,wBAAM,CAACF,CAAC,CAAC;AAEnF,MAAMG,iBAAiB,GAAGA,CAAC;EACzBC,MAAM;EACNC,QAAQ;AACRC,EAAAA;AAAM,CAKP,KAAI;AACH,EAAA,OAAO,OAAOF,MAAM,KAAK,QAAQ,GAAGG,uBAAY,CAACH,MAAM,EAAEC,QAAQ,EAAEC,MAAM,CAAC,GAAG,EAAE;AACjF,CAAC;AAED,MAAME,WAAW,GAAGA,CAAC;EACnBJ,MAAM;EACNC,QAAQ;AACRC,EAAAA;AAAM,CAKP,KAAI;AACH,EAAA,OAAOG,8BAAW,CAACL,MAAM,EAAEC,QAAQ,EAAEC,MAAM,CAAC;AAC9C,CAAC;AAED,MAAMI,gBAAgB,GAAG,IAAIC,GAAG,CAAC,CAC/B,WAAW,EACX,QAAQ,EACR,GAAG,EACH,GAAG,EACH,WAAW,EACX,SAAS,EACT,WAAW,EACX,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,KAAK,CACN,CAAC;AAiCF,MAAMC,UAAW,SAAQC,eAA8D,CAAA;AAIrF,EAAA,OAAOC,YAAY,GAAG;IACpBC,IAAI,EAAEC,SAAI,CAACC,KAAK;IAChBC,UAAU,EAAE,EA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AACd,EAAA;EAEA,OACEmG,QAAQ,CAACN,MAAM,CAAC7E,KAAK,EAAE2E,KAAK,CAAC,IAC7BQ,QAAQ,CAACN,MAAM,CAACzE,UAAU,EAAEuE,KAAK,CAAC,IAClCQ,QAAQ,CAACN,MAAM,CAAC1E,IAAI,EAAEwE,KAAK,CAAC;AAEhC;AAEA,SAASQ,QAAQA,CAACC,QAA4B,EAAET,KAAa,EAAA;AAC3D,EAAA,OAAOS,QAAQ,EAAEzC,WAAW,EAAE,CAAC0C,QAAQ,CAACV,KAAK,CAAChC,WAAW,EAAE,CAAC;AAC9D;AAEA,SAASqC,wBAAwBA,CAAC/E,OAAsC,EAAE0E,KAAa,EAAA;EACrF,OAAO,CAAC,GAAG1E,OAAO,CAAC,CAACqF,IAAI,CAAC,CAACC,KAAK,EAAEC,MAAM,KAAI;IACzC,MAAMC,aAAa,GAAGN,QAAQ,CAACI,KAAK,CAACvF,KAAK,EAAE2E,KAAK,CAAC;IAClD,MAAMe,cAAc,GAAGP,QAAQ,CAACK,MAAM,CAACxF,KAAK,EAAE2E,KAAK,CAAC;IAEpD,IAAIc,aAAa,IAAIC,cAAc,EAAE;AACnC,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,IAAID,aAAa,EAAE;AACjB,MAAA,OAAO,EAAE;AACX,IAAA;AACA,IAAA,IAAIC,cAAc,EAAE;AAClB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO,CAAC;AACV,EAAA,CAAC,CAAC;AACJ;AAEA,yBAAeC,oBAAU,CAACC,cAAM,CAACC,4BAAmB,CAAClJ,UAAU,EAAE;AAAEmJ,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -38,32 +38,24 @@ import 'virtua';
|
|
|
38
38
|
import '../inputs/SelectInput/SelectInput.messages.mjs';
|
|
39
39
|
import Title from '../title/Title.mjs';
|
|
40
40
|
import messages from './MoneyInput.messages.mjs';
|
|
41
|
-
import {
|
|
41
|
+
import { parseAmount } from './currencyFormatting.mjs';
|
|
42
42
|
import withId from '../withId/withId.mjs';
|
|
43
|
-
import {
|
|
43
|
+
import { formatAmount } from '@transferwise/formatting';
|
|
44
44
|
|
|
45
45
|
const isNumberOrNull = v => isNumber(v) || isNull(v);
|
|
46
46
|
const formatAmountIfSet = ({
|
|
47
47
|
amount,
|
|
48
48
|
currency,
|
|
49
|
-
locale
|
|
50
|
-
decimals
|
|
49
|
+
locale
|
|
51
50
|
}) => {
|
|
52
|
-
|
|
53
|
-
return '';
|
|
54
|
-
}
|
|
55
|
-
if (decimals != null && getCurrencyDecimals(currency) !== 0) {
|
|
56
|
-
return formatNumber(amount, locale, decimals);
|
|
57
|
-
}
|
|
58
|
-
return formatAmount(amount, currency, locale);
|
|
51
|
+
return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';
|
|
59
52
|
};
|
|
60
53
|
const parseNumber = ({
|
|
61
54
|
amount,
|
|
62
55
|
currency,
|
|
63
|
-
locale
|
|
64
|
-
decimals
|
|
56
|
+
locale
|
|
65
57
|
}) => {
|
|
66
|
-
return parseAmount(amount, currency, locale
|
|
58
|
+
return parseAmount(amount, currency, locale);
|
|
67
59
|
};
|
|
68
60
|
const allowedInputKeys = new Set(['Backspace', 'Delete', ',', '.', 'ArrowDown', 'ArrowUp', 'ArrowLeft', 'ArrowRight', 'Enter', 'Escape', 'Tab']);
|
|
69
61
|
class MoneyInput extends Component {
|
|
@@ -80,8 +72,7 @@ class MoneyInput extends Component {
|
|
|
80
72
|
formattedAmount: formatAmountIfSet({
|
|
81
73
|
amount: props.amount,
|
|
82
74
|
currency: props.selectedCurrency.currency,
|
|
83
|
-
locale: props.intl.locale
|
|
84
|
-
decimals: props.decimals
|
|
75
|
+
locale: props.intl.locale
|
|
85
76
|
}),
|
|
86
77
|
locale: props.intl.locale
|
|
87
78
|
};
|
|
@@ -95,8 +86,7 @@ class MoneyInput extends Component {
|
|
|
95
86
|
formattedAmount: formatAmountIfSet({
|
|
96
87
|
amount: nextProps.amount,
|
|
97
88
|
currency: nextProps.selectedCurrency.currency,
|
|
98
|
-
locale: nextProps.intl.locale
|
|
99
|
-
decimals: nextProps.decimals
|
|
89
|
+
locale: nextProps.intl.locale
|
|
100
90
|
})
|
|
101
91
|
});
|
|
102
92
|
}
|
|
@@ -123,16 +113,14 @@ class MoneyInput extends Component {
|
|
|
123
113
|
const parsed = isEmpty(paste) ? null : parseNumber({
|
|
124
114
|
amount: paste,
|
|
125
115
|
currency: this.props.selectedCurrency.currency,
|
|
126
|
-
locale
|
|
127
|
-
decimals: this.props.decimals
|
|
116
|
+
locale
|
|
128
117
|
});
|
|
129
118
|
if (isNumberOrNull(parsed)) {
|
|
130
119
|
this.setState({
|
|
131
120
|
formattedAmount: formatAmountIfSet({
|
|
132
121
|
amount: parsed,
|
|
133
122
|
currency: this.props.selectedCurrency.currency,
|
|
134
|
-
locale
|
|
135
|
-
decimals: this.props.decimals
|
|
123
|
+
locale
|
|
136
124
|
})
|
|
137
125
|
});
|
|
138
126
|
this.props.onAmountChange?.(parsed);
|
|
@@ -149,8 +137,7 @@ class MoneyInput extends Component {
|
|
|
149
137
|
const parsed = isEmpty(value) ? null : parseNumber({
|
|
150
138
|
amount: value,
|
|
151
139
|
currency: this.props.selectedCurrency.currency,
|
|
152
|
-
locale: this.state.locale
|
|
153
|
-
decimals: this.props.decimals
|
|
140
|
+
locale: this.state.locale
|
|
154
141
|
});
|
|
155
142
|
if (isNumberOrNull(parsed)) {
|
|
156
143
|
this.props.onAmountChange?.(parsed);
|
|
@@ -190,8 +177,7 @@ class MoneyInput extends Component {
|
|
|
190
177
|
const parsed = parseNumber({
|
|
191
178
|
amount: previousState.formattedAmount,
|
|
192
179
|
currency: this.props.selectedCurrency.currency,
|
|
193
|
-
locale: previousState.locale
|
|
194
|
-
decimals: this.props.decimals
|
|
180
|
+
locale: previousState.locale
|
|
195
181
|
});
|
|
196
182
|
if (!isNumberOrNull(parsed)) {
|
|
197
183
|
return {
|
|
@@ -202,8 +188,7 @@ class MoneyInput extends Component {
|
|
|
202
188
|
formattedAmount: formatAmountIfSet({
|
|
203
189
|
amount: parsed,
|
|
204
190
|
currency: this.props.selectedCurrency.currency,
|
|
205
|
-
locale: previousState.locale
|
|
206
|
-
decimals: this.props.decimals
|
|
191
|
+
locale: previousState.locale
|
|
207
192
|
})
|
|
208
193
|
};
|
|
209
194
|
});
|
|
@@ -268,8 +253,7 @@ class MoneyInput extends Component {
|
|
|
268
253
|
placeholder: formatAmountIfSet({
|
|
269
254
|
amount: this.props.placeholder,
|
|
270
255
|
currency: this.props.selectedCurrency.currency,
|
|
271
|
-
locale: this.state.locale
|
|
272
|
-
decimals: this.props.decimals
|
|
256
|
+
locale: this.state.locale
|
|
273
257
|
}),
|
|
274
258
|
autoComplete: "off",
|
|
275
259
|
"aria-describedby": selectedCurrencyElementId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.mjs","sources":["../../src/moneyInput/MoneyInput.tsx"],"sourcesContent":["import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';\nimport { Flag } from '@wise/art';\nimport { clsx } from 'clsx';\nimport { Component } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport {\n Typography,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n getLocaleCurrencyName,\n} from '../common';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputItem,\n SelectInputOptionContent,\n SelectInputOptionItem,\n SelectInputProps,\n} from '../inputs/SelectInput';\nimport Title from '../title';\n\nimport messages from './MoneyInput.messages';\nimport { formatAmount, formatNumber, getCurrencyDecimals, parseAmount } from './currencyFormatting';\nimport withId from '../withId';\n\nexport interface CurrencyOptionItem {\n header?: never;\n value: string;\n label: string;\n currency: string;\n note?: string;\n searchable?: string;\n}\n\nexport interface CurrencyHeaderItem {\n header: string;\n}\n\nexport type CurrencyItem = CurrencyOptionItem | CurrencyHeaderItem;\n\nconst isNumberOrNull = (v: unknown): v is number | null => isNumber(v) || isNull(v);\n\nconst formatAmountIfSet = ({\n amount,\n currency,\n locale,\n decimals,\n}: {\n amount: number | null | undefined;\n currency: string;\n locale: string;\n decimals?: number;\n}) => {\n if (typeof amount !== 'number') {\n return '';\n }\n if (decimals != null && getCurrencyDecimals(currency) !== 0) {\n return formatNumber(amount, locale, decimals);\n }\n return formatAmount(amount, currency, locale);\n};\n\nconst parseNumber = ({\n amount,\n currency,\n locale,\n decimals,\n}: {\n amount: string;\n currency: string;\n locale: string;\n decimals?: number;\n}) => {\n return parseAmount(amount, currency, locale, decimals);\n};\n\nconst allowedInputKeys = new Set([\n 'Backspace',\n 'Delete',\n ',',\n '.',\n 'ArrowDown',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n 'Escape',\n 'Tab',\n]);\n\nexport interface MoneyInputProps extends WrappedComponentProps {\n id?: string;\n 'aria-labelledby'?: string;\n currencies: readonly CurrencyItem[];\n selectedCurrency: CurrencyOptionItem;\n onCurrencyChange?: (value: CurrencyOptionItem) => void;\n placeholder?: number;\n amount: number | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n onAmountChange?: (value: number | null) => void;\n addon?: React.ReactNode;\n searchPlaceholder?: string;\n /**\n * Allows the consumer to react to searching, while the search itself is handled internally.\n */\n onSearchChange?: (value: { searchQuery: string; filteredOptions: CurrencyItem[] }) => void;\n customActionLabel?: React.ReactNode;\n onCustomAction?: () => void;\n classNames?: Record<string, string>;\n selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;\n /**\n * Specify the number of decimal places to format the amount. When not specified, the number of\n * decimals is determined by the selected currency (e.g. 2 for EUR, 0 for JPY, 3 for BHD).\n * This override is ignored for zero-decimal currencies (e.g. JPY, KRW, HUF), which always use 0.\n */\n decimals?: number;\n}\n\nexport type MoneyInputPropsWithInputAttributes = MoneyInputProps &\n Partial<WithInputAttributesProps>;\n\ninterface MoneyInputState {\n searchQuery: string;\n formattedAmount: string;\n locale: string;\n}\n\nclass MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInputState> {\n declare props: MoneyInputPropsWithInputAttributes &\n Required<Pick<MoneyInputPropsWithInputAttributes, keyof typeof MoneyInput.defaultProps>>;\n\n static defaultProps = {\n size: Size.LARGE,\n classNames: {},\n selectProps: {},\n } satisfies Partial<MoneyInputPropsWithInputAttributes>;\n\n amountFocused = false;\n\n constructor(props: MoneyInputProps) {\n super(props);\n this.state = {\n searchQuery: '',\n formattedAmount: formatAmountIfSet({\n amount: props.amount,\n currency: props.selectedCurrency.currency,\n locale: props.intl.locale,\n decimals: props.decimals,\n }),\n locale: props.intl.locale,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MoneyInputProps) {\n this.setState({ locale: nextProps.intl.locale });\n\n if (!this.amountFocused) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: nextProps.amount,\n currency: nextProps.selectedCurrency.currency,\n locale: nextProps.intl.locale,\n decimals: nextProps.decimals,\n }),\n });\n }\n }\n\n isInputAllowedForKeyEvent = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { metaKey, key, ctrlKey } = event;\n const isNumberKey = isNumber(Number.parseInt(key, 10));\n\n return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);\n };\n\n handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n if (!this.isInputAllowedForKeyEvent(event)) {\n event.preventDefault();\n }\n };\n\n handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const paste = event.clipboardData.getData('text');\n const { locale } = this.state;\n const parsed = isEmpty(paste)\n ? null\n : parseNumber({\n amount: paste,\n currency: this.props.selectedCurrency.currency,\n locale,\n decimals: this.props.decimals,\n });\n\n if (isNumberOrNull(parsed)) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale,\n decimals: this.props.decimals,\n }),\n });\n this.props.onAmountChange?.(parsed);\n }\n\n event.preventDefault();\n };\n\n onAmountChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n this.setState({\n formattedAmount: value,\n });\n const parsed = isEmpty(value)\n ? null\n : parseNumber({\n amount: value,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n decimals: this.props.decimals,\n });\n if (isNumberOrNull(parsed)) {\n this.props.onAmountChange?.(parsed);\n }\n };\n\n onAmountBlur = () => {\n this.amountFocused = false;\n this.setAmount();\n };\n\n onAmountFocus = () => {\n this.amountFocused = true;\n };\n\n getSelectOptions() {\n const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);\n\n const formattedOptions: SelectInputItem<CurrencyOptionItem>[] = [];\n let currentGroupOptions: SelectInputOptionItem<CurrencyOptionItem>[] | undefined;\n\n selectOptions.forEach((item) => {\n if (item.header != null) {\n currentGroupOptions = [];\n formattedOptions.push({\n type: 'group',\n label: item.header,\n options: currentGroupOptions,\n });\n } else {\n (currentGroupOptions ?? formattedOptions).push({\n type: 'option',\n value: item,\n filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? ''],\n });\n }\n });\n\n return formattedOptions;\n }\n\n setAmount() {\n this.setState((previousState) => {\n const parsed = parseNumber({\n amount: previousState.formattedAmount,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n decimals: this.props.decimals,\n });\n if (!isNumberOrNull(parsed)) {\n return {\n formattedAmount: previousState.formattedAmount,\n };\n }\n return {\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n decimals: this.props.decimals,\n }),\n };\n });\n }\n\n handleSelectChange = (value: CurrencyOptionItem) => {\n this.handleSearchChange('');\n this.props.onCurrencyChange?.(value);\n };\n\n handleSearchChange = (searchQuery: string) => {\n this.setState({ searchQuery });\n this.props.onSearchChange?.({\n searchQuery,\n filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery),\n });\n };\n\n style = (className: string) => this.props.classNames[className] || className;\n\n render() {\n const {\n inputAttributes,\n id: amountInputId,\n 'aria-labelledby': ariaLabelledByProp,\n selectedCurrency,\n onCurrencyChange,\n size,\n addon,\n selectProps,\n } = this.props;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n const selectOptions = this.getSelectOptions();\n\n const hasSingleCurrency = () => {\n if (selectOptions.length !== 0) {\n const firstItem = selectOptions[0];\n\n if (selectOptions.length === 1) {\n if (firstItem.type === 'option') {\n return firstItem.value.currency === selectedCurrency.currency;\n }\n if (firstItem.type === 'group') {\n return (\n firstItem.options.length === 1 &&\n !(this.props.onCustomAction && this.props.customActionLabel)\n );\n }\n }\n } else if (selectedCurrency?.currency) {\n return true;\n }\n\n return false;\n };\n\n const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;\n const disabled = !this.props.onAmountChange;\n const selectedCurrencyElementId = `${inputAttributes?.id ?? amountInputId}SelectedCurrency`;\n\n return (\n <fieldset\n aria-invalid={inputAttributes?.['aria-invalid']}\n aria-describedby={inputAttributes?.['aria-describedby']}\n aria-labelledby={inputAttributes?.id ?? amountInputId}\n className={clsx(\n this.style('tw-money-input'),\n this.style('input-group'),\n this.style(`input-group-${size}`),\n )}\n >\n <Input\n id={inputAttributes?.id ?? amountInputId}\n aria-labelledby={ariaLabelledBy}\n value={this.state.formattedAmount}\n inputMode=\"decimal\"\n disabled={disabled}\n placeholder={formatAmountIfSet({\n amount: this.props.placeholder,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n decimals: this.props.decimals,\n })}\n autoComplete=\"off\"\n aria-describedby={selectedCurrencyElementId}\n onKeyDown={this.handleKeyDown}\n onChange={this.onAmountChange}\n onFocus={this.onAmountFocus}\n onBlur={this.onAmountBlur}\n onPaste={this.handlePaste}\n />\n {addon && (\n <span\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n disabled ? this.style('disabled') : '',\n )}\n >\n {addon}\n </span>\n )}\n {isFixedCurrency ? (\n <div\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n this.style('tw-money-input__fixed-currency'),\n disabled ? this.style('disabled') : '',\n )}\n id={selectedCurrencyElementId}\n >\n {(size === 'lg' || size === 'md') && (\n <span className={clsx(this.style('money-input-currency-flag'), this.style('m-r-2'))}>\n <Flag code={selectedCurrency.currency.toLowerCase()} intrinsicSize={24} />\n </span>\n )}\n <Title\n as=\"span\"\n type={Typography.TITLE_SUBSECTION}\n className={size === 'lg' ? this.style('m-r-1') : ''}\n aria-label={getLocaleCurrencyName(this.props.intl, selectedCurrency.currency)}\n >\n {selectedCurrency.currency.toUpperCase()}\n </Title>\n </div>\n ) : (\n <div\n translate=\"no\"\n className={clsx(\n this.style('input-group-btn'),\n this.style('amount-currency-select-btn'),\n )}\n >\n <SelectInput\n UNSAFE_triggerButtonProps={{\n id: undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': ariaLabelledBy,\n 'aria-invalid': undefined,\n 'aria-label': this.props.intl.formatMessage(messages.selectCurrencyLabel),\n }}\n id={selectedCurrencyElementId}\n items={selectOptions}\n value={selectedCurrency}\n compareValues=\"currency\"\n renderValue={(currency, withinTrigger) => {\n return (\n <SelectInputOptionContent\n title={\n withinTrigger ? (\n <span\n aria-label={getLocaleCurrencyName(this.props.intl, currency.currency)}\n >\n {currency.currency.toUpperCase()}\n </span>\n ) : (\n currency.label\n )\n }\n note={withinTrigger ? undefined : currency.note}\n icon={<Flag code={currency.currency} intrinsicSize={24} />}\n />\n );\n }}\n renderFooter={\n this.props.onCustomAction\n ? () => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div role=\"button\" tabIndex={0} onClick={this.props.onCustomAction}>\n {this.props.customActionLabel}\n </div>\n )\n : undefined\n }\n placeholder={this.props.intl.formatMessage(messages.selectPlaceholder)}\n filterable\n filterPlaceholder={\n this.props.searchPlaceholder ||\n this.props.intl.formatMessage(messages.searchPlaceholder)\n }\n disabled={disabled}\n size={size}\n onChange={this.handleSelectChange}\n onFilterChange={({ queryNormalized }) => {\n this.handleSearchChange(queryNormalized ?? '');\n }}\n {...selectProps}\n />\n </div>\n )}\n </fieldset>\n );\n }\n}\n\nfunction filterCurrenciesForQuery(\n currencies: readonly CurrencyItem[],\n query: string,\n): CurrencyItem[] {\n if (!query) {\n return [...currencies];\n }\n\n const options = currencies.filter(\n (option): option is CurrencyOptionItem => option.header == null,\n );\n const filteredOptions = removeDuplicateValueOptions(options).filter((option) =>\n currencyOptionFitsQuery(option, query),\n );\n\n return sortOptionsLabelsToFirst(filteredOptions, query);\n}\n\nfunction removeDuplicateValueOptions(options: readonly CurrencyOptionItem[]) {\n const uniqueValues = new Set<string>();\n return options.filter((option) => {\n if (!uniqueValues.has(option.value)) {\n uniqueValues.add(option.value);\n return true;\n }\n return false;\n });\n}\n\nfunction currencyOptionFitsQuery(option: CurrencyOptionItem, query: string) {\n if (!option.value) {\n return false;\n }\n\n return (\n contains(option.label, query) ||\n contains(option.searchable, query) ||\n contains(option.note, query)\n );\n}\n\nfunction contains(property: string | undefined, query: string) {\n return property?.toLowerCase().includes(query.toLowerCase());\n}\n\nfunction sortOptionsLabelsToFirst(options: readonly CurrencyOptionItem[], query: string) {\n return [...options].sort((first, second) => {\n const firstContains = contains(first.label, query);\n const secondContains = contains(second.label, query);\n\n if (firstContains && secondContains) {\n return 0;\n }\n if (firstContains) {\n return -1;\n }\n if (secondContains) {\n return 1;\n }\n return 0;\n });\n}\n\nexport default injectIntl(withId(withInputAttributes(MoneyInput, { nonLabelable: true })));\n"],"names":["isNumberOrNull","v","isNumber","isNull","formatAmountIfSet","amount","currency","locale","decimals","getCurrencyDecimals","formatNumber","formatAmount","parseNumber","parseAmount","allowedInputKeys","Set","MoneyInput","Component","defaultProps","size","Size","LARGE","classNames","selectProps","amountFocused","constructor","props","state","searchQuery","formattedAmount","selectedCurrency","intl","UNSAFE_componentWillReceiveProps","nextProps","setState","isInputAllowedForKeyEvent","event","metaKey","key","ctrlKey","isNumberKey","Number","parseInt","has","handleKeyDown","preventDefault","handlePaste","paste","clipboardData","getData","parsed","isEmpty","onAmountChange","value","target","onAmountBlur","setAmount","onAmountFocus","getSelectOptions","selectOptions","filterCurrenciesForQuery","currencies","formattedOptions","currentGroupOptions","forEach","item","header","push","type","label","options","filterMatchers","note","searchable","previousState","handleSelectChange","handleSearchChange","onCurrencyChange","onSearchChange","filteredOptions","style","className","render","inputAttributes","id","amountInputId","ariaLabelledByProp","addon","ariaLabelledBy","hasSingleCurrency","length","firstItem","onCustomAction","customActionLabel","isFixedCurrency","disabled","selectedCurrencyElementId","_jsxs","clsx","children","_jsx","Input","inputMode","placeholder","autoComplete","onKeyDown","onChange","onFocus","onBlur","onPaste","Flag","code","toLowerCase","intrinsicSize","Title","as","Typography","TITLE_SUBSECTION","getLocaleCurrencyName","toUpperCase","translate","SelectInput","UNSAFE_triggerButtonProps","undefined","formatMessage","messages","selectCurrencyLabel","items","compareValues","renderValue","withinTrigger","SelectInputOptionContent","title","icon","renderFooter","role","tabIndex","onClick","selectPlaceholder","filterable","filterPlaceholder","searchPlaceholder","onFilterChange","queryNormalized","query","filter","option","removeDuplicateValueOptions","currencyOptionFitsQuery","sortOptionsLabelsToFirst","uniqueValues","add","contains","property","includes","sort","first","second","firstContains","secondContains","injectIntl","withId","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,cAAc,GAAIC,CAAU,IAAyBC,QAAQ,CAACD,CAAC,CAAC,IAAIE,MAAM,CAACF,CAAC,CAAC;AAEnF,MAAMG,iBAAiB,GAAGA,CAAC;EACzBC,MAAM;EACNC,QAAQ;EACRC,MAAM;AACNC,EAAAA;AAAQ,CAMT,KAAI;AACH,EAAA,IAAI,OAAOH,MAAM,KAAK,QAAQ,EAAE;AAC9B,IAAA,OAAO,EAAE;AACX,EAAA;EACA,IAAIG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E2E,KAAK,CAAC,IAC7BQ,QAAQ,CAACN,MAAM,CAACzE,UAAU,EAAEuE,KAAK,CAAC,IAClCQ,QAAQ,CAACN,MAAM,CAAC1E,IAAI,EAAEwE,KAAK,CAAC;AAEhC;AAEA,SAASQ,QAAQA,CAACC,QAA4B,EAAET,KAAa,EAAA;AAC3D,EAAA,OAAOS,QAAQ,EAAEzC,WAAW,EAAE,CAAC0C,QAAQ,CAACV,KAAK,CAAChC,WAAW,EAAE,CAAC;AAC9D;AAEA,SAASqC,wBAAwBA,CAAC/E,OAAsC,EAAE0E,KAAa,EAAA;EACrF,OAAO,CAAC,GAAG1E,OAAO,CAAC,CAACqF,IAAI,CAAC,CAACC,KAAK,EAAEC,MAAM,KAAI;IACzC,MAAMC,aAAa,GAAGN,QAAQ,CAACI,KAAK,CAACvF,KAAK,EAAE2E,KAAK,CAAC;IAClD,MAAMe,cAAc,GAAGP,QAAQ,CAACK,MAAM,CAACxF,KAAK,EAAE2E,KAAK,CAAC;IAEpD,IAAIc,aAAa,IAAIC,cAAc,EAAE;AACnC,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,IAAID,aAAa,EAAE;AACjB,MAAA,OAAO,EAAE;AACX,IAAA;AACA,IAAA,IAAIC,cAAc,EAAE;AAClB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO,CAAC;AACV,EAAA,CAAC,CAAC;AACJ;AAEA,yBAAeC,UAAU,CAACC,MAAM,CAACC,mBAAmB,CAAClJ,UAAU,EAAE;AAAEmJ,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"MoneyInput.mjs","sources":["../../src/moneyInput/MoneyInput.tsx"],"sourcesContent":["import { isEmpty, isNumber, isNull } from '@transferwise/neptune-validation';\nimport { Flag } from '@wise/art';\nimport { clsx } from 'clsx';\nimport { Component } from 'react';\nimport { injectIntl, WrappedComponentProps } from 'react-intl';\n\nimport {\n Typography,\n Size,\n SizeLarge,\n SizeMedium,\n SizeSmall,\n getLocaleCurrencyName,\n} from '../common';\nimport { withInputAttributes, WithInputAttributesProps } from '../inputs/contexts';\nimport { Input } from '../inputs/Input';\nimport {\n SelectInput,\n SelectInputItem,\n SelectInputOptionContent,\n SelectInputOptionItem,\n SelectInputProps,\n} from '../inputs/SelectInput';\nimport Title from '../title';\n\nimport messages from './MoneyInput.messages';\nimport { formatAmount, parseAmount } from './currencyFormatting';\nimport withId from '../withId';\n\nexport interface CurrencyOptionItem {\n header?: never;\n value: string;\n label: string;\n currency: string;\n note?: string;\n searchable?: string;\n}\n\nexport interface CurrencyHeaderItem {\n header: string;\n}\n\nexport type CurrencyItem = CurrencyOptionItem | CurrencyHeaderItem;\n\nconst isNumberOrNull = (v: unknown): v is number | null => isNumber(v) || isNull(v);\n\nconst formatAmountIfSet = ({\n amount,\n currency,\n locale,\n}: {\n amount: number | null | undefined;\n currency: string;\n locale: string;\n}) => {\n return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';\n};\n\nconst parseNumber = ({\n amount,\n currency,\n locale,\n}: {\n amount: string;\n currency: string;\n locale: string;\n}) => {\n return parseAmount(amount, currency, locale);\n};\n\nconst allowedInputKeys = new Set([\n 'Backspace',\n 'Delete',\n ',',\n '.',\n 'ArrowDown',\n 'ArrowUp',\n 'ArrowLeft',\n 'ArrowRight',\n 'Enter',\n 'Escape',\n 'Tab',\n]);\n\nexport interface MoneyInputProps extends WrappedComponentProps {\n id?: string;\n 'aria-labelledby'?: string;\n currencies: readonly CurrencyItem[];\n selectedCurrency: CurrencyOptionItem;\n onCurrencyChange?: (value: CurrencyOptionItem) => void;\n placeholder?: number;\n amount: number | null;\n size?: SizeSmall | SizeMedium | SizeLarge;\n onAmountChange?: (value: number | null) => void;\n addon?: React.ReactNode;\n searchPlaceholder?: string;\n /**\n * Allows the consumer to react to searching, while the search itself is handled internally.\n */\n onSearchChange?: (value: { searchQuery: string; filteredOptions: CurrencyItem[] }) => void;\n customActionLabel?: React.ReactNode;\n onCustomAction?: () => void;\n classNames?: Record<string, string>;\n selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;\n}\n\nexport type MoneyInputPropsWithInputAttributes = MoneyInputProps &\n Partial<WithInputAttributesProps>;\n\ninterface MoneyInputState {\n searchQuery: string;\n formattedAmount: string;\n locale: string;\n}\n\nclass MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInputState> {\n declare props: MoneyInputPropsWithInputAttributes &\n Required<Pick<MoneyInputPropsWithInputAttributes, keyof typeof MoneyInput.defaultProps>>;\n\n static defaultProps = {\n size: Size.LARGE,\n classNames: {},\n selectProps: {},\n } satisfies Partial<MoneyInputPropsWithInputAttributes>;\n\n amountFocused = false;\n\n constructor(props: MoneyInputProps) {\n super(props);\n this.state = {\n searchQuery: '',\n formattedAmount: formatAmountIfSet({\n amount: props.amount,\n currency: props.selectedCurrency.currency,\n locale: props.intl.locale,\n }),\n locale: props.intl.locale,\n };\n }\n\n UNSAFE_componentWillReceiveProps(nextProps: MoneyInputProps) {\n this.setState({ locale: nextProps.intl.locale });\n\n if (!this.amountFocused) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: nextProps.amount,\n currency: nextProps.selectedCurrency.currency,\n locale: nextProps.intl.locale,\n }),\n });\n }\n }\n\n isInputAllowedForKeyEvent = (event: React.KeyboardEvent<HTMLInputElement>) => {\n const { metaKey, key, ctrlKey } = event;\n const isNumberKey = isNumber(Number.parseInt(key, 10));\n\n return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);\n };\n\n handleKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (event) => {\n if (!this.isInputAllowedForKeyEvent(event)) {\n event.preventDefault();\n }\n };\n\n handlePaste: React.ClipboardEventHandler<HTMLInputElement> = (event) => {\n const paste = event.clipboardData.getData('text');\n const { locale } = this.state;\n const parsed = isEmpty(paste)\n ? null\n : parseNumber({\n amount: paste,\n currency: this.props.selectedCurrency.currency,\n locale,\n });\n\n if (isNumberOrNull(parsed)) {\n this.setState({\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale,\n }),\n });\n this.props.onAmountChange?.(parsed);\n }\n\n event.preventDefault();\n };\n\n onAmountChange: React.ChangeEventHandler<HTMLInputElement> = (event) => {\n const { value } = event.target;\n this.setState({\n formattedAmount: value,\n });\n const parsed = isEmpty(value)\n ? null\n : parseNumber({\n amount: value,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n });\n if (isNumberOrNull(parsed)) {\n this.props.onAmountChange?.(parsed);\n }\n };\n\n onAmountBlur = () => {\n this.amountFocused = false;\n this.setAmount();\n };\n\n onAmountFocus = () => {\n this.amountFocused = true;\n };\n\n getSelectOptions() {\n const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);\n\n const formattedOptions: SelectInputItem<CurrencyOptionItem>[] = [];\n let currentGroupOptions: SelectInputOptionItem<CurrencyOptionItem>[] | undefined;\n\n selectOptions.forEach((item) => {\n if (item.header != null) {\n currentGroupOptions = [];\n formattedOptions.push({\n type: 'group',\n label: item.header,\n options: currentGroupOptions,\n });\n } else {\n (currentGroupOptions ?? formattedOptions).push({\n type: 'option',\n value: item,\n filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? ''],\n });\n }\n });\n\n return formattedOptions;\n }\n\n setAmount() {\n this.setState((previousState) => {\n const parsed = parseNumber({\n amount: previousState.formattedAmount,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n });\n if (!isNumberOrNull(parsed)) {\n return {\n formattedAmount: previousState.formattedAmount,\n };\n }\n return {\n formattedAmount: formatAmountIfSet({\n amount: parsed,\n currency: this.props.selectedCurrency.currency,\n locale: previousState.locale,\n }),\n };\n });\n }\n\n handleSelectChange = (value: CurrencyOptionItem) => {\n this.handleSearchChange('');\n this.props.onCurrencyChange?.(value);\n };\n\n handleSearchChange = (searchQuery: string) => {\n this.setState({ searchQuery });\n this.props.onSearchChange?.({\n searchQuery,\n filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery),\n });\n };\n\n style = (className: string) => this.props.classNames[className] || className;\n\n render() {\n const {\n inputAttributes,\n id: amountInputId,\n 'aria-labelledby': ariaLabelledByProp,\n selectedCurrency,\n onCurrencyChange,\n size,\n addon,\n selectProps,\n } = this.props;\n const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];\n const selectOptions = this.getSelectOptions();\n\n const hasSingleCurrency = () => {\n if (selectOptions.length !== 0) {\n const firstItem = selectOptions[0];\n\n if (selectOptions.length === 1) {\n if (firstItem.type === 'option') {\n return firstItem.value.currency === selectedCurrency.currency;\n }\n if (firstItem.type === 'group') {\n return (\n firstItem.options.length === 1 &&\n !(this.props.onCustomAction && this.props.customActionLabel)\n );\n }\n }\n } else if (selectedCurrency?.currency) {\n return true;\n }\n\n return false;\n };\n\n const isFixedCurrency = (!this.state.searchQuery && hasSingleCurrency()) || !onCurrencyChange;\n const disabled = !this.props.onAmountChange;\n const selectedCurrencyElementId = `${inputAttributes?.id ?? amountInputId}SelectedCurrency`;\n\n return (\n <fieldset\n aria-invalid={inputAttributes?.['aria-invalid']}\n aria-describedby={inputAttributes?.['aria-describedby']}\n aria-labelledby={inputAttributes?.id ?? amountInputId}\n className={clsx(\n this.style('tw-money-input'),\n this.style('input-group'),\n this.style(`input-group-${size}`),\n )}\n >\n <Input\n id={inputAttributes?.id ?? amountInputId}\n aria-labelledby={ariaLabelledBy}\n value={this.state.formattedAmount}\n inputMode=\"decimal\"\n disabled={disabled}\n placeholder={formatAmountIfSet({\n amount: this.props.placeholder,\n currency: this.props.selectedCurrency.currency,\n locale: this.state.locale,\n })}\n autoComplete=\"off\"\n aria-describedby={selectedCurrencyElementId}\n onKeyDown={this.handleKeyDown}\n onChange={this.onAmountChange}\n onFocus={this.onAmountFocus}\n onBlur={this.onAmountBlur}\n onPaste={this.handlePaste}\n />\n {addon && (\n <span\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n disabled ? this.style('disabled') : '',\n )}\n >\n {addon}\n </span>\n )}\n {isFixedCurrency ? (\n <div\n className={clsx(\n this.style('input-group-addon'),\n this.style(`input-${size}`),\n this.style('tw-money-input__fixed-currency'),\n disabled ? this.style('disabled') : '',\n )}\n id={selectedCurrencyElementId}\n >\n {(size === 'lg' || size === 'md') && (\n <span className={clsx(this.style('money-input-currency-flag'), this.style('m-r-2'))}>\n <Flag code={selectedCurrency.currency.toLowerCase()} intrinsicSize={24} />\n </span>\n )}\n <Title\n as=\"span\"\n type={Typography.TITLE_SUBSECTION}\n className={size === 'lg' ? this.style('m-r-1') : ''}\n aria-label={getLocaleCurrencyName(this.props.intl, selectedCurrency.currency)}\n >\n {selectedCurrency.currency.toUpperCase()}\n </Title>\n </div>\n ) : (\n <div\n translate=\"no\"\n className={clsx(\n this.style('input-group-btn'),\n this.style('amount-currency-select-btn'),\n )}\n >\n <SelectInput\n UNSAFE_triggerButtonProps={{\n id: undefined,\n 'aria-labelledby': undefined,\n 'aria-describedby': ariaLabelledBy,\n 'aria-invalid': undefined,\n 'aria-label': this.props.intl.formatMessage(messages.selectCurrencyLabel),\n }}\n id={selectedCurrencyElementId}\n items={selectOptions}\n value={selectedCurrency}\n compareValues=\"currency\"\n renderValue={(currency, withinTrigger) => {\n return (\n <SelectInputOptionContent\n title={\n withinTrigger ? (\n <span\n aria-label={getLocaleCurrencyName(this.props.intl, currency.currency)}\n >\n {currency.currency.toUpperCase()}\n </span>\n ) : (\n currency.label\n )\n }\n note={withinTrigger ? undefined : currency.note}\n icon={<Flag code={currency.currency} intrinsicSize={24} />}\n />\n );\n }}\n renderFooter={\n this.props.onCustomAction\n ? () => (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div role=\"button\" tabIndex={0} onClick={this.props.onCustomAction}>\n {this.props.customActionLabel}\n </div>\n )\n : undefined\n }\n placeholder={this.props.intl.formatMessage(messages.selectPlaceholder)}\n filterable\n filterPlaceholder={\n this.props.searchPlaceholder ||\n this.props.intl.formatMessage(messages.searchPlaceholder)\n }\n disabled={disabled}\n size={size}\n onChange={this.handleSelectChange}\n onFilterChange={({ queryNormalized }) => {\n this.handleSearchChange(queryNormalized ?? '');\n }}\n {...selectProps}\n />\n </div>\n )}\n </fieldset>\n );\n }\n}\n\nfunction filterCurrenciesForQuery(\n currencies: readonly CurrencyItem[],\n query: string,\n): CurrencyItem[] {\n if (!query) {\n return [...currencies];\n }\n\n const options = currencies.filter(\n (option): option is CurrencyOptionItem => option.header == null,\n );\n const filteredOptions = removeDuplicateValueOptions(options).filter((option) =>\n currencyOptionFitsQuery(option, query),\n );\n\n return sortOptionsLabelsToFirst(filteredOptions, query);\n}\n\nfunction removeDuplicateValueOptions(options: readonly CurrencyOptionItem[]) {\n const uniqueValues = new Set<string>();\n return options.filter((option) => {\n if (!uniqueValues.has(option.value)) {\n uniqueValues.add(option.value);\n return true;\n }\n return false;\n });\n}\n\nfunction currencyOptionFitsQuery(option: CurrencyOptionItem, query: string) {\n if (!option.value) {\n return false;\n }\n\n return (\n contains(option.label, query) ||\n contains(option.searchable, query) ||\n contains(option.note, query)\n );\n}\n\nfunction contains(property: string | undefined, query: string) {\n return property?.toLowerCase().includes(query.toLowerCase());\n}\n\nfunction sortOptionsLabelsToFirst(options: readonly CurrencyOptionItem[], query: string) {\n return [...options].sort((first, second) => {\n const firstContains = contains(first.label, query);\n const secondContains = contains(second.label, query);\n\n if (firstContains && secondContains) {\n return 0;\n }\n if (firstContains) {\n return -1;\n }\n if (secondContains) {\n return 1;\n }\n return 0;\n });\n}\n\nexport default injectIntl(withId(withInputAttributes(MoneyInput, { nonLabelable: true })));\n"],"names":["isNumberOrNull","v","isNumber","isNull","formatAmountIfSet","amount","currency","locale","formatAmount","parseNumber","parseAmount","allowedInputKeys","Set","MoneyInput","Component","defaultProps","size","Size","LARGE","classNames","selectProps","amountFocused","constructor","props","state","searchQuery","formattedAmount","selectedCurrency","intl","UNSAFE_componentWillReceiveProps","nextProps","setState","isInputAllowedForKeyEvent","event","metaKey","key","ctrlKey","isNumberKey","Number","parseInt","has","handleKeyDown","preventDefault","handlePaste","paste","clipboardData","getData","parsed","isEmpty","onAmountChange","value","target","onAmountBlur","setAmount","onAmountFocus","getSelectOptions","selectOptions","filterCurrenciesForQuery","currencies","formattedOptions","currentGroupOptions","forEach","item","header","push","type","label","options","filterMatchers","note","searchable","previousState","handleSelectChange","handleSearchChange","onCurrencyChange","onSearchChange","filteredOptions","style","className","render","inputAttributes","id","amountInputId","ariaLabelledByProp","addon","ariaLabelledBy","hasSingleCurrency","length","firstItem","onCustomAction","customActionLabel","isFixedCurrency","disabled","selectedCurrencyElementId","_jsxs","clsx","children","_jsx","Input","inputMode","placeholder","autoComplete","onKeyDown","onChange","onFocus","onBlur","onPaste","Flag","code","toLowerCase","intrinsicSize","Title","as","Typography","TITLE_SUBSECTION","getLocaleCurrencyName","toUpperCase","translate","SelectInput","UNSAFE_triggerButtonProps","undefined","formatMessage","messages","selectCurrencyLabel","items","compareValues","renderValue","withinTrigger","SelectInputOptionContent","title","icon","renderFooter","role","tabIndex","onClick","selectPlaceholder","filterable","filterPlaceholder","searchPlaceholder","onFilterChange","queryNormalized","query","filter","option","removeDuplicateValueOptions","currencyOptionFitsQuery","sortOptionsLabelsToFirst","uniqueValues","add","contains","property","includes","sort","first","second","firstContains","secondContains","injectIntl","withId","withInputAttributes","nonLabelable"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAMA,cAAc,GAAIC,CAAU,IAAyBC,QAAQ,CAACD,CAAC,CAAC,IAAIE,MAAM,CAACF,CAAC,CAAC;AAEnF,MAAMG,iBAAiB,GAAGA,CAAC;EACzBC,MAAM;EACNC,QAAQ;AACRC,EAAAA;AAAM,CAKP,KAAI;AACH,EAAA,OAAO,OAAOF,MAAM,KAAK,QAAQ,GAAGG,YAAY,CAACH,MAAM,EAAEC,QAAQ,EAAEC,MAAM,CAAC,GAAG,EAAE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AACV,IAAA;AACA,IAAA,IAAID,aAAa,EAAE;AACjB,MAAA,OAAO,EAAE;AACX,IAAA;AACA,IAAA,IAAIC,cAAc,EAAE;AAClB,MAAA,OAAO,CAAC;AACV,IAAA;AACA,IAAA,OAAO,CAAC;AACV,EAAA,CAAC,CAAC;AACJ;AAEA,yBAAeC,UAAU,CAACC,MAAM,CAACC,mBAAmB,CAAClJ,UAAU,EAAE;AAAEmJ,EAAAA,YAAY,EAAE;AAAI,CAAE,CAAC,CAAC,CAAC;;;;"}
|
|
@@ -52,10 +52,9 @@ function getCurrencyDecimals(currency) {
|
|
|
52
52
|
function getDecimalSeparator(locale) {
|
|
53
53
|
return isNumberLocaleSupported() ? 1.1.toLocaleString(locale)[1] : '.';
|
|
54
54
|
}
|
|
55
|
-
function parseAmount(number, currency, locale = index.DEFAULT_LOCALE
|
|
55
|
+
function parseAmount(number, currency, locale = index.DEFAULT_LOCALE) {
|
|
56
56
|
const validLocale = getValidLocale(locale);
|
|
57
|
-
const
|
|
58
|
-
const precision = currencyDefault === 0 ? 0 : decimals ?? currencyDefault;
|
|
57
|
+
const precision = getCurrencyDecimals(currency);
|
|
59
58
|
const groupSeparator = isNumberLocaleSupported() ? 10000 .toLocaleString(validLocale)[2] : ',';
|
|
60
59
|
const decimalSeparator = getDecimalSeparator(validLocale);
|
|
61
60
|
const numberWithStandardDecimalSeparator = (number || '').replace(new RegExp(`\\${groupSeparator}`, 'g'), '').replace(new RegExp(`\\${decimalSeparator}`, 'g'), '.').replace(/[^0-9.]/g, '');
|
|
@@ -67,10 +66,5 @@ Object.defineProperty(exports, "formatAmount", {
|
|
|
67
66
|
enumerable: true,
|
|
68
67
|
get: function () { return formatting.formatAmount; }
|
|
69
68
|
});
|
|
70
|
-
Object.defineProperty(exports, "formatNumber", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
get: function () { return formatting.formatNumber; }
|
|
73
|
-
});
|
|
74
|
-
exports.getCurrencyDecimals = getCurrencyDecimals;
|
|
75
69
|
exports.parseAmount = parseAmount;
|
|
76
70
|
//# sourceMappingURL=currencyFormatting.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currencyFormatting.js","sources":["../../src/moneyInput/currencyFormatting.ts"],"sourcesContent":["import { formatAmount
|
|
1
|
+
{"version":3,"file":"currencyFormatting.js","sources":["../../src/moneyInput/currencyFormatting.ts"],"sourcesContent":["import { formatAmount } from '@transferwise/formatting';\n\nimport { DEFAULT_LOCALE } from '../common/locale';\n\nexport { formatAmount };\n\n// TODO: do not duplicate this between formatting and components\nconst currencyDecimals: Record<string, number> = {\n BIF: 0,\n BYR: 0,\n CLP: 0,\n DJF: 0,\n GNF: 0,\n JPY: 0,\n KMF: 0,\n KRW: 0,\n MGA: 0,\n PYG: 0,\n RWF: 0,\n VND: 0,\n VUV: 0,\n XAF: 0,\n XOF: 0,\n XPF: 0,\n // technically HUF does have decimals, but due to the exchange rate banks\n // do not accept decimal amounts\n HUF: 0,\n\n BHD: 3,\n JOD: 3,\n KWD: 3,\n OMR: 3,\n TND: 3,\n};\n\nconst DEFAULT_CURRENCY_DECIMALS = 2;\n\nfunction isNumberLocaleSupported() {\n const number = 1234;\n const numberString = number.toLocaleString && number.toLocaleString(DEFAULT_LOCALE);\n return numberString === '1,234';\n}\n\nfunction getValidLocale(locale: string) {\n try {\n const noUnderscoreLocale = locale.replace(/_/, '-');\n\n Intl.NumberFormat(noUnderscoreLocale);\n return noUnderscoreLocale;\n } catch {\n return DEFAULT_LOCALE;\n }\n}\n\nfunction getCurrencyDecimals(currency: string) {\n const upperCaseCurrency = currency.toUpperCase();\n return currencyDecimals[upperCaseCurrency] ?? DEFAULT_CURRENCY_DECIMALS;\n}\n\nfunction getDecimalSeparator(locale: string) {\n return isNumberLocaleSupported() ? (1.1).toLocaleString(locale)[1] : '.';\n}\n\nexport function parseAmount(number: string, currency: string, locale = DEFAULT_LOCALE) {\n const validLocale = getValidLocale(locale);\n\n const precision = getCurrencyDecimals(currency);\n const groupSeparator = isNumberLocaleSupported() ? (10000).toLocaleString(validLocale)[2] : ',';\n const decimalSeparator = getDecimalSeparator(validLocale);\n const numberWithStandardDecimalSeparator = (number || '')\n .replace(new RegExp(`\\\\${groupSeparator}`, 'g'), '')\n .replace(new RegExp(`\\\\${decimalSeparator}`, 'g'), '.')\n .replace(/[^0-9.]/g, '');\n const parsedAmount = Number.parseFloat(\n Number.parseFloat(numberWithStandardDecimalSeparator).toFixed(precision),\n );\n return Math.abs(parsedAmount);\n}\n"],"names":["currencyDecimals","BIF","BYR","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","VND","VUV","XAF","XOF","XPF","HUF","BHD","JOD","KWD","OMR","TND","DEFAULT_CURRENCY_DECIMALS","isNumberLocaleSupported","number","numberString","toLocaleString","DEFAULT_LOCALE","getValidLocale","locale","noUnderscoreLocale","replace","Intl","NumberFormat","getCurrencyDecimals","currency","upperCaseCurrency","toUpperCase","getDecimalSeparator","parseAmount","validLocale","precision","groupSeparator","decimalSeparator","numberWithStandardDecimalSeparator","RegExp","parsedAmount","Number","parseFloat","toFixed","Math","abs"],"mappings":";;;;;AAMA;AACA,MAAMA,gBAAgB,GAA2B;AAC/CC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,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C/C,EAAA,MAAMO,cAAc,GAAGnB,uBAAuB,EAAE,GAAI,KAAK,EAAEG,cAAc,CAACc,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;AAC/F,EAAA,MAAMG,gBAAgB,GAAGL,mBAAmB,CAACE,WAAW,CAAC;AACzD,EAAA,MAAMI,kCAAkC,GAAG,CAACpB,MAAM,IAAI,EAAE,EACrDO,OAAO,CAAC,IAAIc,MAAM,CAAC,KAAKH,cAAc,CAAA,CAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CACnDX,OAAO,CAAC,IAAIc,MAAM,CAAC,CAAA,EAAA,EAAKF,gBAAgB,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CACtDZ,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AAC1B,EAAA,MAAMe,YAAY,GAAGC,MAAM,CAACC,UAAU,CACpCD,MAAM,CAACC,UAAU,CAACJ,kCAAkC,CAAC,CAACK,OAAO,CAACR,SAAS,CAAC,CACzE;AACD,EAAA,OAAOS,IAAI,CAACC,GAAG,CAACL,YAAY,CAAC;AAC/B;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { formatAmount
|
|
1
|
+
export { formatAmount } from '@transferwise/formatting';
|
|
2
2
|
import { DEFAULT_LOCALE } from '../common/locale/index.mjs';
|
|
3
3
|
|
|
4
4
|
// TODO: do not duplicate this between formatting and components
|
|
@@ -50,10 +50,9 @@ function getCurrencyDecimals(currency) {
|
|
|
50
50
|
function getDecimalSeparator(locale) {
|
|
51
51
|
return isNumberLocaleSupported() ? 1.1.toLocaleString(locale)[1] : '.';
|
|
52
52
|
}
|
|
53
|
-
function parseAmount(number, currency, locale = DEFAULT_LOCALE
|
|
53
|
+
function parseAmount(number, currency, locale = DEFAULT_LOCALE) {
|
|
54
54
|
const validLocale = getValidLocale(locale);
|
|
55
|
-
const
|
|
56
|
-
const precision = currencyDefault === 0 ? 0 : decimals ?? currencyDefault;
|
|
55
|
+
const precision = getCurrencyDecimals(currency);
|
|
57
56
|
const groupSeparator = isNumberLocaleSupported() ? 10000 .toLocaleString(validLocale)[2] : ',';
|
|
58
57
|
const decimalSeparator = getDecimalSeparator(validLocale);
|
|
59
58
|
const numberWithStandardDecimalSeparator = (number || '').replace(new RegExp(`\\${groupSeparator}`, 'g'), '').replace(new RegExp(`\\${decimalSeparator}`, 'g'), '.').replace(/[^0-9.]/g, '');
|
|
@@ -61,5 +60,5 @@ function parseAmount(number, currency, locale = DEFAULT_LOCALE, decimals) {
|
|
|
61
60
|
return Math.abs(parsedAmount);
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
export {
|
|
63
|
+
export { parseAmount };
|
|
65
64
|
//# sourceMappingURL=currencyFormatting.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currencyFormatting.mjs","sources":["../../src/moneyInput/currencyFormatting.ts"],"sourcesContent":["import { formatAmount
|
|
1
|
+
{"version":3,"file":"currencyFormatting.mjs","sources":["../../src/moneyInput/currencyFormatting.ts"],"sourcesContent":["import { formatAmount } from '@transferwise/formatting';\n\nimport { DEFAULT_LOCALE } from '../common/locale';\n\nexport { formatAmount };\n\n// TODO: do not duplicate this between formatting and components\nconst currencyDecimals: Record<string, number> = {\n BIF: 0,\n BYR: 0,\n CLP: 0,\n DJF: 0,\n GNF: 0,\n JPY: 0,\n KMF: 0,\n KRW: 0,\n MGA: 0,\n PYG: 0,\n RWF: 0,\n VND: 0,\n VUV: 0,\n XAF: 0,\n XOF: 0,\n XPF: 0,\n // technically HUF does have decimals, but due to the exchange rate banks\n // do not accept decimal amounts\n HUF: 0,\n\n BHD: 3,\n JOD: 3,\n KWD: 3,\n OMR: 3,\n TND: 3,\n};\n\nconst DEFAULT_CURRENCY_DECIMALS = 2;\n\nfunction isNumberLocaleSupported() {\n const number = 1234;\n const numberString = number.toLocaleString && number.toLocaleString(DEFAULT_LOCALE);\n return numberString === '1,234';\n}\n\nfunction getValidLocale(locale: string) {\n try {\n const noUnderscoreLocale = locale.replace(/_/, '-');\n\n Intl.NumberFormat(noUnderscoreLocale);\n return noUnderscoreLocale;\n } catch {\n return DEFAULT_LOCALE;\n }\n}\n\nfunction getCurrencyDecimals(currency: string) {\n const upperCaseCurrency = currency.toUpperCase();\n return currencyDecimals[upperCaseCurrency] ?? DEFAULT_CURRENCY_DECIMALS;\n}\n\nfunction getDecimalSeparator(locale: string) {\n return isNumberLocaleSupported() ? (1.1).toLocaleString(locale)[1] : '.';\n}\n\nexport function parseAmount(number: string, currency: string, locale = DEFAULT_LOCALE) {\n const validLocale = getValidLocale(locale);\n\n const precision = getCurrencyDecimals(currency);\n const groupSeparator = isNumberLocaleSupported() ? (10000).toLocaleString(validLocale)[2] : ',';\n const decimalSeparator = getDecimalSeparator(validLocale);\n const numberWithStandardDecimalSeparator = (number || '')\n .replace(new RegExp(`\\\\${groupSeparator}`, 'g'), '')\n .replace(new RegExp(`\\\\${decimalSeparator}`, 'g'), '.')\n .replace(/[^0-9.]/g, '');\n const parsedAmount = Number.parseFloat(\n Number.parseFloat(numberWithStandardDecimalSeparator).toFixed(precision),\n );\n return Math.abs(parsedAmount);\n}\n"],"names":["currencyDecimals","BIF","BYR","CLP","DJF","GNF","JPY","KMF","KRW","MGA","PYG","RWF","VND","VUV","XAF","XOF","XPF","HUF","BHD","JOD","KWD","OMR","TND","DEFAULT_CURRENCY_DECIMALS","isNumberLocaleSupported","number","numberString","toLocaleString","DEFAULT_LOCALE","getValidLocale","locale","noUnderscoreLocale","replace","Intl","NumberFormat","getCurrencyDecimals","currency","upperCaseCurrency","toUpperCase","getDecimalSeparator","parseAmount","validLocale","precision","groupSeparator","decimalSeparator","numberWithStandardDecimalSeparator","RegExp","parsedAmount","Number","parseFloat","toFixed","Math","abs"],"mappings":";;;AAMA;AACA,MAAMA,gBAAgB,GAA2B;AAC/CC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,GAAG,EAAE,CAAC;AACNC,EAAAA,G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OAAOtC,gBAAgB,CAACqC,iBAAiB,CAAC,IAAId,yBAAyB;AACzE;AAEA,SAASgB,mBAAmBA,CAACT,MAAc,EAAA;AACzC,EAAA,OAAON,uBAAuB,EAAE,GAAI,GAAG,CAAEG,cAAc,CAACG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;AAC1E;AAEM,SAAUU,WAAWA,CAACf,MAAc,EAAEW,QAAgB,EAAEN,MAAM,GAAGF,cAAc,EAAA;AACnF,EAAA,MAAMa,WAAW,GAAGZ,cAAc,CAACC,MAAM,CAAC;AAE1C,EAAA,MAAMY,SAAS,GAAGP,mBAAmB,CAACC,QAAQ,CAAC;AAC/C,EAAA,MAAMO,cAAc,GAAGnB,uBAAuB,EAAE,GAAI,KAAK,EAAEG,cAAc,CAACc,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;AAC/F,EAAA,MAAMG,gBAAgB,GAAGL,mBAAmB,CAACE,WAAW,CAAC;AACzD,EAAA,MAAMI,kCAAkC,GAAG,CAACpB,MAAM,IAAI,EAAE,EACrDO,OAAO,CAAC,IAAIc,MAAM,CAAC,KAAKH,cAAc,CAAA,CAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CACnDX,OAAO,CAAC,IAAIc,MAAM,CAAC,CAAA,EAAA,EAAKF,gBAAgB,EAAE,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CACtDZ,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AAC1B,EAAA,MAAMe,YAAY,GAAGC,MAAM,CAACC,UAAU,CACpCD,MAAM,CAACC,UAAU,CAACJ,kCAAkC,CAAC,CAACK,OAAO,CAACR,SAAS,CAAC,CACzE;AACD,EAAA,OAAOS,IAAI,CAACC,GAAG,CAACL,YAAY,CAAC;AAC/B;;;;"}
|
|
@@ -37,12 +37,6 @@ export interface MoneyInputProps extends WrappedComponentProps {
|
|
|
37
37
|
onCustomAction?: () => void;
|
|
38
38
|
classNames?: Record<string, string>;
|
|
39
39
|
selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;
|
|
40
|
-
/**
|
|
41
|
-
* Specify the number of decimal places to format the amount. When not specified, the number of
|
|
42
|
-
* decimals is determined by the selected currency (e.g. 2 for EUR, 0 for JPY, 3 for BHD).
|
|
43
|
-
* This override is ignored for zero-decimal currencies (e.g. JPY, KRW, HUF), which always use 0.
|
|
44
|
-
*/
|
|
45
|
-
decimals?: number;
|
|
46
40
|
}
|
|
47
41
|
export type MoneyInputPropsWithInputAttributes = MoneyInputProps & Partial<WithInputAttributesProps>;
|
|
48
42
|
declare const _default: import("react").FC<import("react-intl").WithIntlProps<Omit<MoneyInputPropsWithInputAttributes, "inputAttributes"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAc,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE/D,OAAO,EAGL,SAAS,EACT,UAAU,EACV,SAAS,EAEV,MAAM,WAAW,CAAC;AACnB,OAAO,EAAuB,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnF,OAAO,EAKL,gBAAgB,EACjB,MAAM,uBAAuB,CAAC;AAO/B,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MoneyInput.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/MoneyInput.tsx"],"names":[],"mappings":"AAIA,OAA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eAAe,EAAE,YAAY,EAAE,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3F,iBAAiB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACpC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,WAAW,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC,CAAC;CAC7D;AAED,MAAM,MAAM,kCAAkC,GAAG,eAAe,GAC9D,OAAO,CAAC,wBAAwB,CAAC,CAAC;;;;;;;;AA4ZpC,wBAA2F"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { formatAmount
|
|
2
|
-
export { formatAmount
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function parseAmount(number: string, currency: string, locale?: string, decimals?: number): number;
|
|
1
|
+
import { formatAmount } from '@transferwise/formatting';
|
|
2
|
+
export { formatAmount };
|
|
3
|
+
export declare function parseAmount(number: string, currency: string, locale?: string): number;
|
|
5
4
|
//# sourceMappingURL=currencyFormatting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"currencyFormatting.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/currencyFormatting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"currencyFormatting.d.ts","sourceRoot":"","sources":["../../../src/moneyInput/currencyFormatting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,OAAO,EAAE,YAAY,EAAE,CAAC;AA2DxB,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,SAAiB,UAcpF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@transferwise/components",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-8cc553f",
|
|
4
4
|
"description": "Neptune React components",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -87,8 +87,8 @@
|
|
|
87
87
|
"storybook-addon-tag-badges": "^3.1.0",
|
|
88
88
|
"storybook-addon-test-codegen": "^3.0.1",
|
|
89
89
|
"@transferwise/less-config": "3.1.2",
|
|
90
|
-
"@wise/components-theming": "1.10.1",
|
|
91
90
|
"@transferwise/neptune-css": "14.27.1",
|
|
91
|
+
"@wise/components-theming": "1.10.1",
|
|
92
92
|
"@wise/wds-configs": "0.0.0"
|
|
93
93
|
},
|
|
94
94
|
"peerDependencies": {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import { within, userEvent
|
|
2
|
+
import { within, userEvent } from 'storybook/test';
|
|
3
3
|
import { Lock } from '@transferwise/icons';
|
|
4
4
|
import { useState } from 'react';
|
|
5
5
|
|
|
@@ -155,15 +155,6 @@ export const BalanceCurrencies: Story = {
|
|
|
155
155
|
},
|
|
156
156
|
};
|
|
157
157
|
|
|
158
|
-
export const WithDecimals: Story = {
|
|
159
|
-
args: {
|
|
160
|
-
currencies: [],
|
|
161
|
-
selectedCurrency: exampleCurrency.eur,
|
|
162
|
-
decimals: 4,
|
|
163
|
-
amount: 1234.1412,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
|
|
167
158
|
export const OpenedInput: Story = {
|
|
168
159
|
...MultipleCurrencies,
|
|
169
160
|
play: async ({ canvasElement }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import { within,
|
|
2
|
+
import { within, fireEvent } from 'storybook/test';
|
|
3
3
|
import { allModes } from '../../.storybook/modes';
|
|
4
4
|
import { lorem500 } from '../test-utils';
|
|
5
5
|
import { Field } from '../field/Field';
|
|
@@ -102,143 +102,3 @@ export const SmoothScrollReset: Story = {
|
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
104
|
};
|
|
105
|
-
|
|
106
|
-
export const WithDecimals: Story = {
|
|
107
|
-
args: {
|
|
108
|
-
currencies: [],
|
|
109
|
-
decimals: 4,
|
|
110
|
-
amount: 1234.5678,
|
|
111
|
-
},
|
|
112
|
-
play: async ({ canvas }) => {
|
|
113
|
-
const input = canvas.getByRole('textbox');
|
|
114
|
-
await expect(input).toHaveValue('1,234.5678');
|
|
115
|
-
await userEvent.clear(input);
|
|
116
|
-
await userEvent.type(input, '99.123456789');
|
|
117
|
-
await userEvent.tab();
|
|
118
|
-
await expect(input).toHaveValue('99.1235');
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const eur = {
|
|
123
|
-
value: 'EUR',
|
|
124
|
-
label: 'EUR',
|
|
125
|
-
note: 'Euro',
|
|
126
|
-
currency: 'eur',
|
|
127
|
-
} as const;
|
|
128
|
-
|
|
129
|
-
const bhd = {
|
|
130
|
-
value: 'BHD',
|
|
131
|
-
label: 'BHD',
|
|
132
|
-
note: 'Bahraini dinar',
|
|
133
|
-
currency: 'bhd',
|
|
134
|
-
} as const;
|
|
135
|
-
|
|
136
|
-
const jpy = {
|
|
137
|
-
value: 'JPY',
|
|
138
|
-
label: 'JPY',
|
|
139
|
-
note: 'Japanese yen',
|
|
140
|
-
currency: 'jpy',
|
|
141
|
-
} as const;
|
|
142
|
-
|
|
143
|
-
const sharedProps = {
|
|
144
|
-
currencies: [],
|
|
145
|
-
onAmountChange: () => {},
|
|
146
|
-
onCurrencyChange: () => {},
|
|
147
|
-
} as const;
|
|
148
|
-
|
|
149
|
-
function Row({
|
|
150
|
-
label,
|
|
151
|
-
amount,
|
|
152
|
-
currency,
|
|
153
|
-
decimals,
|
|
154
|
-
}: {
|
|
155
|
-
label: string;
|
|
156
|
-
amount: number;
|
|
157
|
-
currency: { value: string; label: string; note: string; currency: string };
|
|
158
|
-
decimals: number;
|
|
159
|
-
}) {
|
|
160
|
-
return (
|
|
161
|
-
<div
|
|
162
|
-
style={{
|
|
163
|
-
display: 'grid',
|
|
164
|
-
gridTemplateColumns: '240px 1fr 1fr',
|
|
165
|
-
gap: 12,
|
|
166
|
-
alignItems: 'center',
|
|
167
|
-
}}
|
|
168
|
-
>
|
|
169
|
-
<Body as="span" style={{ fontSize: 13, color: '#6b7280' }}>
|
|
170
|
-
{label}
|
|
171
|
-
</Body>
|
|
172
|
-
<Field label={`No decimals prop (${currency.value})`}>
|
|
173
|
-
<MoneyInput {...sharedProps} selectedCurrency={currency} amount={amount} />
|
|
174
|
-
</Field>
|
|
175
|
-
<Field label={`decimals={${decimals}} (${currency.value})`}>
|
|
176
|
-
<MoneyInput
|
|
177
|
-
{...sharedProps}
|
|
178
|
-
selectedCurrency={currency}
|
|
179
|
-
amount={amount}
|
|
180
|
-
decimals={decimals}
|
|
181
|
-
/>
|
|
182
|
-
</Field>
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Side-by-side comparison of formatAmount (no decimals prop) vs formatNumber (with decimals prop)
|
|
189
|
-
* when decimals matches the currency default. Differences indicate a formatting parity issue.
|
|
190
|
-
*
|
|
191
|
-
* Problem 1: Trailing zero stripping — formatAmount strips ".00" for whole numbers,
|
|
192
|
-
* formatNumber always pads to the requested precision.
|
|
193
|
-
*
|
|
194
|
-
* Problem 2: BHD decimal count — formatAmount renders 2 fractional digits for BHD,
|
|
195
|
-
* but the currencyDecimals map says BHD has 3. formatNumber with decimals=3 shows 3.
|
|
196
|
-
*/
|
|
197
|
-
export const DecimalsFormatParity: Story = {
|
|
198
|
-
render: () => (
|
|
199
|
-
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
200
|
-
<Body as="p" style={{ fontWeight: 600, marginTop: 8 }}>
|
|
201
|
-
EUR — whole numbers (trailing zero stripping)
|
|
202
|
-
</Body>
|
|
203
|
-
<Row label="amount=0" amount={0} currency={eur} decimals={2} />
|
|
204
|
-
<Row label="amount=1" amount={1} currency={eur} decimals={2} />
|
|
205
|
-
<Row label="amount=42" amount={42} currency={eur} decimals={2} />
|
|
206
|
-
<Row label="amount=100" amount={100} currency={eur} decimals={2} />
|
|
207
|
-
<Row label="amount=1000" amount={1000} currency={eur} decimals={2} />
|
|
208
|
-
<Row label="amount=9999999" amount={9999999} currency={eur} decimals={2} />
|
|
209
|
-
|
|
210
|
-
<Body as="p" style={{ fontWeight: 600, marginTop: 8 }}>
|
|
211
|
-
EUR — fractional amounts (should match)
|
|
212
|
-
</Body>
|
|
213
|
-
<Row label="amount=0.01" amount={0.01} currency={eur} decimals={2} />
|
|
214
|
-
<Row label="amount=0.1" amount={0.1} currency={eur} decimals={2} />
|
|
215
|
-
<Row label="amount=99.9" amount={99.9} currency={eur} decimals={2} />
|
|
216
|
-
<Row label="amount=1234567.89" amount={1234567.89} currency={eur} decimals={2} />
|
|
217
|
-
|
|
218
|
-
<Body as="p" style={{ fontWeight: 600, marginTop: 8 }}>
|
|
219
|
-
BHD — all amounts (formatAmount uses 2 digits, formatNumber uses 3)
|
|
220
|
-
</Body>
|
|
221
|
-
<Row label="amount=0" amount={0} currency={bhd} decimals={3} />
|
|
222
|
-
<Row label="amount=0.001" amount={0.001} currency={bhd} decimals={3} />
|
|
223
|
-
<Row label="amount=0.01" amount={0.01} currency={bhd} decimals={3} />
|
|
224
|
-
<Row label="amount=0.1" amount={0.1} currency={bhd} decimals={3} />
|
|
225
|
-
<Row label="amount=42" amount={42} currency={bhd} decimals={3} />
|
|
226
|
-
<Row label="amount=99.9" amount={99.9} currency={bhd} decimals={3} />
|
|
227
|
-
<Row label="amount=999.99" amount={999.99} currency={bhd} decimals={3} />
|
|
228
|
-
<Row label="amount=1234567.89" amount={1234567.89} currency={bhd} decimals={3} />
|
|
229
|
-
|
|
230
|
-
<Body as="p" style={{ fontWeight: 600, marginTop: 8 }}>
|
|
231
|
-
JPY — zero-decimal currency (should always match)
|
|
232
|
-
</Body>
|
|
233
|
-
<Row label="amount=0" amount={0} currency={jpy} decimals={0} />
|
|
234
|
-
<Row label="amount=1" amount={1} currency={jpy} decimals={0} />
|
|
235
|
-
<Row label="amount=1000" amount={1000} currency={jpy} decimals={0} />
|
|
236
|
-
<Row label="amount=1234567" amount={1234567} currency={jpy} decimals={0} />
|
|
237
|
-
</div>
|
|
238
|
-
),
|
|
239
|
-
parameters: {
|
|
240
|
-
chromatic: {
|
|
241
|
-
disableSnapshot: true,
|
|
242
|
-
},
|
|
243
|
-
},
|
|
244
|
-
};
|
|
@@ -253,45 +253,6 @@ describe('Money Input', () => {
|
|
|
253
253
|
await userEvent.tab();
|
|
254
254
|
expect(input).toHaveValue('1,234,567.65');
|
|
255
255
|
});
|
|
256
|
-
|
|
257
|
-
it('uses custom decimals when specified', async () => {
|
|
258
|
-
customRender({ decimals: 4 });
|
|
259
|
-
const input = getInput();
|
|
260
|
-
await userEvent.clear(input);
|
|
261
|
-
await userEvent.type(input, '1234.56789');
|
|
262
|
-
await userEvent.tab();
|
|
263
|
-
expect(input).toHaveValue('1,234.5679');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('uses custom decimals of 0', async () => {
|
|
267
|
-
customRender({ decimals: 0 });
|
|
268
|
-
const input = getInput();
|
|
269
|
-
await userEvent.clear(input);
|
|
270
|
-
await userEvent.type(input, '1234.56');
|
|
271
|
-
await userEvent.tab();
|
|
272
|
-
expect(input).toHaveValue('1,235');
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
it('ignores custom decimals override for zero-decimal currencies like JPY', async () => {
|
|
276
|
-
const jpyCurrency: CurrencyOptionItem = {
|
|
277
|
-
value: 'JPY',
|
|
278
|
-
label: 'JPY',
|
|
279
|
-
note: 'Japanese yen',
|
|
280
|
-
currency: 'jpy',
|
|
281
|
-
};
|
|
282
|
-
customRender({
|
|
283
|
-
decimals: 4,
|
|
284
|
-
selectedCurrency: jpyCurrency,
|
|
285
|
-
currencies: [jpyCurrency],
|
|
286
|
-
amount: 1234,
|
|
287
|
-
});
|
|
288
|
-
const input = getInput();
|
|
289
|
-
expect(input).toHaveValue('1,234');
|
|
290
|
-
await userEvent.clear(input);
|
|
291
|
-
await userEvent.type(input, '5678.9999');
|
|
292
|
-
await userEvent.tab();
|
|
293
|
-
expect(input).toHaveValue('5,679');
|
|
294
|
-
});
|
|
295
256
|
});
|
|
296
257
|
|
|
297
258
|
it('calls onAmountChange with parsed and formatted value', async () => {
|
|
@@ -302,12 +263,6 @@ describe('Money Input', () => {
|
|
|
302
263
|
expect(initialProps.onAmountChange).toHaveBeenCalledWith(1000.65);
|
|
303
264
|
});
|
|
304
265
|
|
|
305
|
-
it('calls onAmountChange with value rounded to custom decimals', async () => {
|
|
306
|
-
customRender({ decimals: 4, amount: null });
|
|
307
|
-
await userEvent.type(getInput(), '12.34567');
|
|
308
|
-
expect(initialProps.onAmountChange).toHaveBeenCalledWith(12.3457);
|
|
309
|
-
});
|
|
310
|
-
|
|
311
266
|
it('calls onAmountChange when input value is empty', async () => {
|
|
312
267
|
customRender();
|
|
313
268
|
await userEvent.clear(getInput());
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
import Title from '../title';
|
|
25
25
|
|
|
26
26
|
import messages from './MoneyInput.messages';
|
|
27
|
-
import { formatAmount,
|
|
27
|
+
import { formatAmount, parseAmount } from './currencyFormatting';
|
|
28
28
|
import withId from '../withId';
|
|
29
29
|
|
|
30
30
|
export interface CurrencyOptionItem {
|
|
@@ -48,34 +48,24 @@ const formatAmountIfSet = ({
|
|
|
48
48
|
amount,
|
|
49
49
|
currency,
|
|
50
50
|
locale,
|
|
51
|
-
decimals,
|
|
52
51
|
}: {
|
|
53
52
|
amount: number | null | undefined;
|
|
54
53
|
currency: string;
|
|
55
54
|
locale: string;
|
|
56
|
-
decimals?: number;
|
|
57
55
|
}) => {
|
|
58
|
-
|
|
59
|
-
return '';
|
|
60
|
-
}
|
|
61
|
-
if (decimals != null && getCurrencyDecimals(currency) !== 0) {
|
|
62
|
-
return formatNumber(amount, locale, decimals);
|
|
63
|
-
}
|
|
64
|
-
return formatAmount(amount, currency, locale);
|
|
56
|
+
return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';
|
|
65
57
|
};
|
|
66
58
|
|
|
67
59
|
const parseNumber = ({
|
|
68
60
|
amount,
|
|
69
61
|
currency,
|
|
70
62
|
locale,
|
|
71
|
-
decimals,
|
|
72
63
|
}: {
|
|
73
64
|
amount: string;
|
|
74
65
|
currency: string;
|
|
75
66
|
locale: string;
|
|
76
|
-
decimals?: number;
|
|
77
67
|
}) => {
|
|
78
|
-
return parseAmount(amount, currency, locale
|
|
68
|
+
return parseAmount(amount, currency, locale);
|
|
79
69
|
};
|
|
80
70
|
|
|
81
71
|
const allowedInputKeys = new Set([
|
|
@@ -112,12 +102,6 @@ export interface MoneyInputProps extends WrappedComponentProps {
|
|
|
112
102
|
onCustomAction?: () => void;
|
|
113
103
|
classNames?: Record<string, string>;
|
|
114
104
|
selectProps?: Partial<SelectInputProps<CurrencyOptionItem>>;
|
|
115
|
-
/**
|
|
116
|
-
* Specify the number of decimal places to format the amount. When not specified, the number of
|
|
117
|
-
* decimals is determined by the selected currency (e.g. 2 for EUR, 0 for JPY, 3 for BHD).
|
|
118
|
-
* This override is ignored for zero-decimal currencies (e.g. JPY, KRW, HUF), which always use 0.
|
|
119
|
-
*/
|
|
120
|
-
decimals?: number;
|
|
121
105
|
}
|
|
122
106
|
|
|
123
107
|
export type MoneyInputPropsWithInputAttributes = MoneyInputProps &
|
|
@@ -149,7 +133,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
149
133
|
amount: props.amount,
|
|
150
134
|
currency: props.selectedCurrency.currency,
|
|
151
135
|
locale: props.intl.locale,
|
|
152
|
-
decimals: props.decimals,
|
|
153
136
|
}),
|
|
154
137
|
locale: props.intl.locale,
|
|
155
138
|
};
|
|
@@ -164,7 +147,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
164
147
|
amount: nextProps.amount,
|
|
165
148
|
currency: nextProps.selectedCurrency.currency,
|
|
166
149
|
locale: nextProps.intl.locale,
|
|
167
|
-
decimals: nextProps.decimals,
|
|
168
150
|
}),
|
|
169
151
|
});
|
|
170
152
|
}
|
|
@@ -192,7 +174,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
192
174
|
amount: paste,
|
|
193
175
|
currency: this.props.selectedCurrency.currency,
|
|
194
176
|
locale,
|
|
195
|
-
decimals: this.props.decimals,
|
|
196
177
|
});
|
|
197
178
|
|
|
198
179
|
if (isNumberOrNull(parsed)) {
|
|
@@ -201,7 +182,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
201
182
|
amount: parsed,
|
|
202
183
|
currency: this.props.selectedCurrency.currency,
|
|
203
184
|
locale,
|
|
204
|
-
decimals: this.props.decimals,
|
|
205
185
|
}),
|
|
206
186
|
});
|
|
207
187
|
this.props.onAmountChange?.(parsed);
|
|
@@ -221,7 +201,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
221
201
|
amount: value,
|
|
222
202
|
currency: this.props.selectedCurrency.currency,
|
|
223
203
|
locale: this.state.locale,
|
|
224
|
-
decimals: this.props.decimals,
|
|
225
204
|
});
|
|
226
205
|
if (isNumberOrNull(parsed)) {
|
|
227
206
|
this.props.onAmountChange?.(parsed);
|
|
@@ -269,7 +248,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
269
248
|
amount: previousState.formattedAmount,
|
|
270
249
|
currency: this.props.selectedCurrency.currency,
|
|
271
250
|
locale: previousState.locale,
|
|
272
|
-
decimals: this.props.decimals,
|
|
273
251
|
});
|
|
274
252
|
if (!isNumberOrNull(parsed)) {
|
|
275
253
|
return {
|
|
@@ -281,7 +259,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
281
259
|
amount: parsed,
|
|
282
260
|
currency: this.props.selectedCurrency.currency,
|
|
283
261
|
locale: previousState.locale,
|
|
284
|
-
decimals: this.props.decimals,
|
|
285
262
|
}),
|
|
286
263
|
};
|
|
287
264
|
});
|
|
@@ -363,7 +340,6 @@ class MoneyInput extends Component<MoneyInputPropsWithInputAttributes, MoneyInpu
|
|
|
363
340
|
amount: this.props.placeholder,
|
|
364
341
|
currency: this.props.selectedCurrency.currency,
|
|
365
342
|
locale: this.state.locale,
|
|
366
|
-
decimals: this.props.decimals,
|
|
367
343
|
})}
|
|
368
344
|
autoComplete="off"
|
|
369
345
|
aria-describedby={selectedCurrencyElementId}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { formatAmount
|
|
1
|
+
import { formatAmount } from '@transferwise/formatting';
|
|
2
2
|
|
|
3
3
|
import { DEFAULT_LOCALE } from '../common/locale';
|
|
4
4
|
|
|
5
|
-
export { formatAmount
|
|
5
|
+
export { formatAmount };
|
|
6
6
|
|
|
7
7
|
// TODO: do not duplicate this between formatting and components
|
|
8
8
|
const currencyDecimals: Record<string, number> = {
|
|
@@ -52,7 +52,7 @@ function getValidLocale(locale: string) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
function getCurrencyDecimals(currency: string) {
|
|
56
56
|
const upperCaseCurrency = currency.toUpperCase();
|
|
57
57
|
return currencyDecimals[upperCaseCurrency] ?? DEFAULT_CURRENCY_DECIMALS;
|
|
58
58
|
}
|
|
@@ -61,16 +61,10 @@ function getDecimalSeparator(locale: string) {
|
|
|
61
61
|
return isNumberLocaleSupported() ? (1.1).toLocaleString(locale)[1] : '.';
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function parseAmount(
|
|
65
|
-
number: string,
|
|
66
|
-
currency: string,
|
|
67
|
-
locale = DEFAULT_LOCALE,
|
|
68
|
-
decimals?: number,
|
|
69
|
-
) {
|
|
64
|
+
export function parseAmount(number: string, currency: string, locale = DEFAULT_LOCALE) {
|
|
70
65
|
const validLocale = getValidLocale(locale);
|
|
71
66
|
|
|
72
|
-
const
|
|
73
|
-
const precision = currencyDefault === 0 ? 0 : (decimals ?? currencyDefault);
|
|
67
|
+
const precision = getCurrencyDecimals(currency);
|
|
74
68
|
const groupSeparator = isNumberLocaleSupported() ? (10000).toLocaleString(validLocale)[2] : ',';
|
|
75
69
|
const decimalSeparator = getDecimalSeparator(validLocale);
|
|
76
70
|
const numberWithStandardDecimalSeparator = (number || '')
|