@transferwise/components 0.0.0-experimental-414f25f → 0.0.0-experimental-ec79c77
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/index.esm.js +59 -118
- package/build/index.esm.js.map +1 -1
- package/build/index.js +59 -118
- package/build/index.js.map +1 -1
- package/build/main.css +0 -107
- package/build/styles/main.css +0 -107
- package/build/types/common/responsivePanel/ResponsivePanel.d.ts.map +1 -1
- package/build/types/dimmer/Dimmer.d.ts.map +1 -1
- package/build/types/index.d.ts +1 -0
- package/build/types/index.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +2 -2
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/inputs/_BottomSheet.d.ts.map +1 -1
- package/build/types/inputs/_Popover.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +45 -31
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.messages.d.ts +6 -6
- package/build/types/moneyInput/MoneyInput.messages.d.ts.map +1 -1
- package/build/types/moneyInput/currencyFormatting.d.ts +2 -2
- package/build/types/moneyInput/currencyFormatting.d.ts.map +1 -1
- package/build/types/moneyInput/index.d.ts +2 -1
- package/build/types/moneyInput/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/bottomSheet/__snapshots__/BottomSheet.spec.tsx.snap +1 -1
- package/src/common/responsivePanel/ResponsivePanel.tsx +1 -2
- package/src/dimmer/Dimmer.tsx +5 -1
- package/src/index.ts +1 -0
- package/src/inputs/SelectInput.tsx +2 -2
- package/src/inputs/_BottomSheet.tsx +5 -1
- package/src/inputs/_Popover.tsx +5 -1
- package/src/main.css +0 -107
- package/src/main.less +0 -1
- package/src/moneyInput/{MoneyInput.rtl.spec.js → MoneyInput.rtl.spec.tsx} +4 -4
- package/src/moneyInput/MoneyInput.spec.js +109 -49
- package/src/moneyInput/MoneyInput.story.tsx +6 -14
- package/src/moneyInput/{MoneyInput.js → MoneyInput.tsx} +123 -127
- package/src/moneyInput/{currencyFormatting.spec.js → currencyFormatting.spec.ts} +2 -2
- package/src/moneyInput/{currencyFormatting.js → currencyFormatting.ts} +7 -10
- package/src/moneyInput/index.ts +2 -0
- package/src/popover/__snapshots__/Popover.spec.js.snap +1 -1
- package/build/styles/segmentedControl/SegmentedControl.css +0 -107
- package/build/types/segmentedControl/SegmentedControl.d.ts +0 -31
- package/build/types/segmentedControl/SegmentedControl.d.ts.map +0 -1
- package/src/moneyInput/index.js +0 -1
- package/src/segmentedControl/SegmentedControl.css +0 -107
- package/src/segmentedControl/SegmentedControl.less +0 -107
- package/src/segmentedControl/SegmentedControl.story.tsx +0 -55
- package/src/segmentedControl/SegmentedControl.tsx +0 -146
- /package/src/moneyInput/{MoneyInput.messages.js → MoneyInput.messages.ts} +0 -0
package/build/index.esm.js
CHANGED
|
@@ -1523,7 +1523,7 @@ class DimmerManager {
|
|
|
1523
1523
|
/**
|
|
1524
1524
|
* Dimmer refs
|
|
1525
1525
|
*/
|
|
1526
|
-
|
|
1526
|
+
dimmers;
|
|
1527
1527
|
constructor() {
|
|
1528
1528
|
this.dimmers = [];
|
|
1529
1529
|
}
|
|
@@ -1677,8 +1677,8 @@ const DimmerWrapper = ({
|
|
|
1677
1677
|
theme
|
|
1678
1678
|
} = useTheme();
|
|
1679
1679
|
return open || hasNotExited ? /*#__PURE__*/jsx(ThemeProvider, {
|
|
1680
|
-
theme:
|
|
1681
|
-
screenMode: screenMode,
|
|
1680
|
+
theme: "personal",
|
|
1681
|
+
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
1682
1682
|
isNotRootProvider: true,
|
|
1683
1683
|
children: children
|
|
1684
1684
|
}) : /*#__PURE__*/jsx(Fragment, {
|
|
@@ -3336,9 +3336,6 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
|
3336
3336
|
open = false,
|
|
3337
3337
|
position = Position.BOTTOM
|
|
3338
3338
|
}, reference) => {
|
|
3339
|
-
const {
|
|
3340
|
-
className: themeClassname
|
|
3341
|
-
} = useTheme();
|
|
3342
3339
|
const {
|
|
3343
3340
|
isMobile
|
|
3344
3341
|
} = useLayout();
|
|
@@ -3357,7 +3354,7 @@ const ResponsivePanel = /*#__PURE__*/forwardRef(({
|
|
|
3357
3354
|
open: open,
|
|
3358
3355
|
position: position,
|
|
3359
3356
|
anchorRef: anchorRef,
|
|
3360
|
-
className:
|
|
3357
|
+
className: className,
|
|
3361
3358
|
onClose: onClose,
|
|
3362
3359
|
children: children
|
|
3363
3360
|
}, "panel");
|
|
@@ -5402,6 +5399,7 @@ var DynamicFieldDefinitionList$1 = DynamicFieldDefinitionList;
|
|
|
5402
5399
|
const ESCAPED_OPENING_CHEVRON = '<';
|
|
5403
5400
|
const ESCAPED_CLOSING_CHEVRON = '>';
|
|
5404
5401
|
class EmphasisHtmlTransformer {
|
|
5402
|
+
tags;
|
|
5405
5403
|
constructor(whitelistedTags) {
|
|
5406
5404
|
this.tags = (whitelistedTags || []).map(tag => {
|
|
5407
5405
|
return {
|
|
@@ -6511,8 +6509,8 @@ function BottomSheet({
|
|
|
6511
6509
|
getInteractionProps: getReferenceProps
|
|
6512
6510
|
}), /*#__PURE__*/jsx(FloatingPortal, {
|
|
6513
6511
|
children: /*#__PURE__*/jsx(ThemeProvider, {
|
|
6514
|
-
theme:
|
|
6515
|
-
screenMode: screenMode,
|
|
6512
|
+
theme: "personal",
|
|
6513
|
+
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
6516
6514
|
isNotRootProvider: true,
|
|
6517
6515
|
children: /*#__PURE__*/jsx(Transition, {
|
|
6518
6516
|
show: open,
|
|
@@ -6659,8 +6657,8 @@ function Popover({
|
|
|
6659
6657
|
getInteractionProps: getReferenceProps
|
|
6660
6658
|
}), /*#__PURE__*/jsx(FloatingPortal, {
|
|
6661
6659
|
children: /*#__PURE__*/jsx(ThemeProvider, {
|
|
6662
|
-
theme:
|
|
6663
|
-
screenMode: screenMode,
|
|
6660
|
+
theme: "personal",
|
|
6661
|
+
screenMode: theme === 'personal' ? screenMode : 'light',
|
|
6664
6662
|
isNotRootProvider: true,
|
|
6665
6663
|
children: /*#__PURE__*/jsx(Transition, {
|
|
6666
6664
|
show: open,
|
|
@@ -7835,20 +7833,17 @@ function getValidLocale(locale) {
|
|
|
7835
7833
|
Intl.NumberFormat(noUnderscoreLocale);
|
|
7836
7834
|
return noUnderscoreLocale;
|
|
7837
7835
|
} catch {
|
|
7838
|
-
return
|
|
7836
|
+
return DEFAULT_LOCALE;
|
|
7839
7837
|
}
|
|
7840
7838
|
}
|
|
7841
|
-
function getCurrencyDecimals(currency
|
|
7839
|
+
function getCurrencyDecimals(currency) {
|
|
7842
7840
|
const upperCaseCurrency = currency.toUpperCase();
|
|
7843
|
-
|
|
7844
|
-
return currencyDecimals[upperCaseCurrency];
|
|
7845
|
-
}
|
|
7846
|
-
return DEFAULT_CURRENCY_DECIMALS;
|
|
7841
|
+
return currencyDecimals[upperCaseCurrency] ?? DEFAULT_CURRENCY_DECIMALS;
|
|
7847
7842
|
}
|
|
7848
7843
|
function getDecimalSeparator(locale) {
|
|
7849
7844
|
return isNumberLocaleSupported() ? 1.1.toLocaleString(locale)[1] : '.';
|
|
7850
7845
|
}
|
|
7851
|
-
function parseAmount(number, currency, locale) {
|
|
7846
|
+
function parseAmount(number, currency, locale = DEFAULT_LOCALE) {
|
|
7852
7847
|
const validLocale = getValidLocale(locale);
|
|
7853
7848
|
const precision = getCurrencyDecimals(currency);
|
|
7854
7849
|
const groupSeparator = isNumberLocaleSupported() ? 10000 .toLocaleString(validLocale)[2] : ',';
|
|
@@ -7858,18 +7853,10 @@ function parseAmount(number, currency, locale) {
|
|
|
7858
7853
|
return Math.abs(parsedAmount);
|
|
7859
7854
|
}
|
|
7860
7855
|
|
|
7861
|
-
const Currency = PropTypes.shape({
|
|
7862
|
-
header: PropTypes.string,
|
|
7863
|
-
value: PropTypes.string,
|
|
7864
|
-
label: PropTypes.string,
|
|
7865
|
-
currency: PropTypes.string,
|
|
7866
|
-
note: PropTypes.string,
|
|
7867
|
-
searchable: PropTypes.string
|
|
7868
|
-
});
|
|
7869
7856
|
const isNumberOrNull = v => isNumber(v) || isNull(v);
|
|
7870
7857
|
const formatAmountIfSet = (amount, currency, locale, maxLengthOverride) => {
|
|
7871
7858
|
if (maxLengthOverride) {
|
|
7872
|
-
return amount
|
|
7859
|
+
return amount != null ? String(amount) : '';
|
|
7873
7860
|
} else {
|
|
7874
7861
|
return typeof amount === 'number' ? formatAmount(amount, currency, locale) : '';
|
|
7875
7862
|
}
|
|
@@ -7881,30 +7868,32 @@ const parseNumber = (amount, currency, locale, maxLengthOverride) => {
|
|
|
7881
7868
|
if (maxLengthOverride && amount.length > maxLengthOverride) {
|
|
7882
7869
|
return 0;
|
|
7883
7870
|
}
|
|
7884
|
-
return
|
|
7871
|
+
return Number(amount);
|
|
7885
7872
|
};
|
|
7886
7873
|
const inputKeyCodeAllowlist = new Set([KeyCodes.BACKSPACE, KeyCodes.DELETE, KeyCodes.COMMA, KeyCodes.PERIOD, KeyCodes.DOWN, KeyCodes.UP, KeyCodes.LEFT, KeyCodes.RIGHT, KeyCodes.ENTER, KeyCodes.ESCAPE, KeyCodes.TAB]);
|
|
7887
7874
|
const inputKeyAllowlist = new Set([Key.PERIOD, Key.COMMA]);
|
|
7888
7875
|
class MoneyInput extends Component {
|
|
7876
|
+
static defaultProps = {
|
|
7877
|
+
size: Size.LARGE,
|
|
7878
|
+
classNames: {},
|
|
7879
|
+
selectProps: {}
|
|
7880
|
+
};
|
|
7881
|
+
amountFocused = false;
|
|
7889
7882
|
constructor(props) {
|
|
7890
7883
|
super(props);
|
|
7891
|
-
const {
|
|
7892
|
-
locale
|
|
7893
|
-
} = this.props.intl;
|
|
7894
|
-
this.formatMessage = this.props.intl.formatMessage;
|
|
7895
7884
|
this.state = {
|
|
7896
7885
|
searchQuery: '',
|
|
7897
|
-
formattedAmount: formatAmountIfSet(props.amount, props.selectedCurrency.currency, locale, props.maxLengthOverride),
|
|
7898
|
-
locale
|
|
7886
|
+
formattedAmount: formatAmountIfSet(props.amount, props.selectedCurrency.currency, props.intl.locale, props.maxLengthOverride),
|
|
7887
|
+
locale: props.intl.locale
|
|
7899
7888
|
};
|
|
7900
7889
|
}
|
|
7901
7890
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
7902
7891
|
this.setState({
|
|
7903
|
-
locale: nextProps
|
|
7892
|
+
locale: nextProps.intl.locale
|
|
7904
7893
|
});
|
|
7905
7894
|
if (!this.amountFocused) {
|
|
7906
7895
|
this.setState({
|
|
7907
|
-
formattedAmount: formatAmountIfSet(nextProps.amount, nextProps.selectedCurrency.currency, nextProps
|
|
7896
|
+
formattedAmount: formatAmountIfSet(nextProps.amount, nextProps.selectedCurrency.currency, nextProps.intl.locale, nextProps.maxLengthOverride)
|
|
7908
7897
|
});
|
|
7909
7898
|
}
|
|
7910
7899
|
}
|
|
@@ -7924,7 +7913,7 @@ class MoneyInput extends Component {
|
|
|
7924
7913
|
}
|
|
7925
7914
|
};
|
|
7926
7915
|
handlePaste = event => {
|
|
7927
|
-
const paste =
|
|
7916
|
+
const paste = event.clipboardData.getData('text');
|
|
7928
7917
|
const {
|
|
7929
7918
|
locale
|
|
7930
7919
|
} = this.state;
|
|
@@ -7933,7 +7922,7 @@ class MoneyInput extends Component {
|
|
|
7933
7922
|
this.setState({
|
|
7934
7923
|
formattedAmount: formatAmountIfSet(parsed, this.props.selectedCurrency.currency, locale, this.props.maxLengthOverride)
|
|
7935
7924
|
});
|
|
7936
|
-
this.props.onAmountChange(parsed);
|
|
7925
|
+
this.props.onAmountChange?.(parsed);
|
|
7937
7926
|
}
|
|
7938
7927
|
event.preventDefault();
|
|
7939
7928
|
};
|
|
@@ -7946,7 +7935,7 @@ class MoneyInput extends Component {
|
|
|
7946
7935
|
});
|
|
7947
7936
|
const parsed = isEmpty(value) ? null : parseNumber(value, this.props.selectedCurrency.currency, this.state.locale, this.props.maxLengthOverride);
|
|
7948
7937
|
if (isNumberOrNull(parsed)) {
|
|
7949
|
-
this.props.onAmountChange(parsed);
|
|
7938
|
+
this.props.onAmountChange?.(parsed);
|
|
7950
7939
|
}
|
|
7951
7940
|
};
|
|
7952
7941
|
onAmountBlur = () => {
|
|
@@ -7956,31 +7945,24 @@ class MoneyInput extends Component {
|
|
|
7956
7945
|
onAmountFocus = () => {
|
|
7957
7946
|
this.amountFocused = true;
|
|
7958
7947
|
};
|
|
7959
|
-
mapOption = item => {
|
|
7960
|
-
return {
|
|
7961
|
-
type: 'option',
|
|
7962
|
-
value: item,
|
|
7963
|
-
filterMatchers: [item.value, item.label, item.note, item.searchable]
|
|
7964
|
-
};
|
|
7965
|
-
};
|
|
7966
7948
|
getSelectOptions() {
|
|
7967
|
-
const selectOptions =
|
|
7968
|
-
|
|
7969
|
-
let
|
|
7949
|
+
const selectOptions = filterCurrenciesForQuery(this.props.currencies, this.state.searchQuery);
|
|
7950
|
+
const formattedOptions = [];
|
|
7951
|
+
let currentGroupOptions;
|
|
7970
7952
|
selectOptions.forEach(item => {
|
|
7971
|
-
if (item.header) {
|
|
7953
|
+
if (item.header != null) {
|
|
7954
|
+
currentGroupOptions = [];
|
|
7972
7955
|
formattedOptions.push({
|
|
7973
7956
|
type: 'group',
|
|
7974
7957
|
label: item.header,
|
|
7975
|
-
options:
|
|
7958
|
+
options: currentGroupOptions
|
|
7976
7959
|
});
|
|
7977
|
-
groupIndex = formattedOptions.length - 1;
|
|
7978
7960
|
} else {
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
}
|
|
7961
|
+
(currentGroupOptions ?? formattedOptions).push({
|
|
7962
|
+
type: 'option',
|
|
7963
|
+
value: item,
|
|
7964
|
+
filterMatchers: [item.value, item.label, item.note ?? '', item.searchable ?? '']
|
|
7965
|
+
});
|
|
7984
7966
|
}
|
|
7985
7967
|
});
|
|
7986
7968
|
return formattedOptions;
|
|
@@ -8000,24 +7982,20 @@ class MoneyInput extends Component {
|
|
|
8000
7982
|
}
|
|
8001
7983
|
handleSelectChange = value => {
|
|
8002
7984
|
this.handleSearchChange('');
|
|
8003
|
-
this.props.onCurrencyChange(value);
|
|
7985
|
+
this.props.onCurrencyChange?.(value);
|
|
8004
7986
|
};
|
|
8005
7987
|
handleCustomAction = () => {
|
|
8006
7988
|
this.handleSearchChange('');
|
|
8007
|
-
|
|
8008
|
-
this.props.onCustomAction();
|
|
8009
|
-
}
|
|
7989
|
+
this.props.onCustomAction?.();
|
|
8010
7990
|
};
|
|
8011
7991
|
handleSearchChange = searchQuery => {
|
|
8012
7992
|
this.setState({
|
|
8013
7993
|
searchQuery
|
|
8014
7994
|
});
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
|
|
8018
|
-
|
|
8019
|
-
});
|
|
8020
|
-
}
|
|
7995
|
+
this.props.onSearchChange?.({
|
|
7996
|
+
searchQuery,
|
|
7997
|
+
filteredOptions: filterCurrenciesForQuery(this.props.currencies, searchQuery)
|
|
7998
|
+
});
|
|
8021
7999
|
};
|
|
8022
8000
|
style = className => this.props.classNames[className] || className;
|
|
8023
8001
|
render() {
|
|
@@ -8102,11 +8080,11 @@ class MoneyInput extends Component {
|
|
|
8102
8080
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
8103
8081
|
jsx("div", {
|
|
8104
8082
|
role: "button",
|
|
8105
|
-
tabIndex:
|
|
8083
|
+
tabIndex: 0,
|
|
8106
8084
|
onClick: this.handleCustomAction,
|
|
8107
8085
|
children: this.props.customActionLabel
|
|
8108
|
-
}) :
|
|
8109
|
-
placeholder: this.formatMessage(messages$3.selectPlaceholder),
|
|
8086
|
+
}) : undefined,
|
|
8087
|
+
placeholder: this.props.intl.formatMessage(messages$3.selectPlaceholder),
|
|
8110
8088
|
filterable: true,
|
|
8111
8089
|
filterPlaceholder: this.props.searchPlaceholder,
|
|
8112
8090
|
disabled: disabled,
|
|
@@ -8123,25 +8101,25 @@ class MoneyInput extends Component {
|
|
|
8123
8101
|
});
|
|
8124
8102
|
}
|
|
8125
8103
|
}
|
|
8126
|
-
function
|
|
8104
|
+
function filterCurrenciesForQuery(currencies, query) {
|
|
8127
8105
|
if (!query) {
|
|
8128
|
-
return
|
|
8106
|
+
return [...currencies];
|
|
8129
8107
|
}
|
|
8130
|
-
const
|
|
8108
|
+
const options = currencies.filter(option => option.header == null);
|
|
8109
|
+
const filteredOptions = removeDuplicateValueOptions(options).filter(option => currencyOptionFitsQuery(option, query));
|
|
8131
8110
|
return sortOptionsLabelsToFirst(filteredOptions, query);
|
|
8132
8111
|
}
|
|
8133
8112
|
function removeDuplicateValueOptions(options) {
|
|
8134
|
-
const
|
|
8135
|
-
|
|
8136
|
-
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
resultValues.push(option.value);
|
|
8113
|
+
const uniqueValues = new Set();
|
|
8114
|
+
return options.filter(option => {
|
|
8115
|
+
if (!uniqueValues.has(option.value)) {
|
|
8116
|
+
uniqueValues.add(option.value);
|
|
8117
|
+
return true;
|
|
8140
8118
|
}
|
|
8119
|
+
return false;
|
|
8141
8120
|
});
|
|
8142
|
-
return result;
|
|
8143
8121
|
}
|
|
8144
|
-
function
|
|
8122
|
+
function currencyOptionFitsQuery(option, query) {
|
|
8145
8123
|
if (!option.value) {
|
|
8146
8124
|
return false;
|
|
8147
8125
|
}
|
|
@@ -8166,43 +8144,6 @@ function sortOptionsLabelsToFirst(options, query) {
|
|
|
8166
8144
|
return 0;
|
|
8167
8145
|
});
|
|
8168
8146
|
}
|
|
8169
|
-
MoneyInput.propTypes = {
|
|
8170
|
-
id: PropTypes.string,
|
|
8171
|
-
currencies: PropTypes.arrayOf(Currency).isRequired,
|
|
8172
|
-
selectedCurrency: Currency.isRequired,
|
|
8173
|
-
onCurrencyChange: PropTypes.func,
|
|
8174
|
-
placeholder: PropTypes.number,
|
|
8175
|
-
amount: PropTypes.number,
|
|
8176
|
-
size: PropTypes.oneOf(['sm', 'md', 'lg']),
|
|
8177
|
-
onAmountChange: PropTypes.func,
|
|
8178
|
-
addon: PropTypes.node,
|
|
8179
|
-
searchPlaceholder: PropTypes.string,
|
|
8180
|
-
/**
|
|
8181
|
-
* Allows the consumer to react to searching, while the search itself is handled internally. Called with `{ searchQuery: string, filteredOptions: Currency[] }`
|
|
8182
|
-
*/
|
|
8183
|
-
onSearchChange: PropTypes.func,
|
|
8184
|
-
customActionLabel: PropTypes.node,
|
|
8185
|
-
onCustomAction: PropTypes.func,
|
|
8186
|
-
classNames: PropTypes.objectOf(PropTypes.string),
|
|
8187
|
-
selectProps: PropTypes.object,
|
|
8188
|
-
maxLengthOverride: PropTypes.number
|
|
8189
|
-
};
|
|
8190
|
-
MoneyInput.defaultProps = {
|
|
8191
|
-
id: null,
|
|
8192
|
-
size: Size.LARGE,
|
|
8193
|
-
addon: null,
|
|
8194
|
-
searchPlaceholder: '',
|
|
8195
|
-
onSearchChange: undefined,
|
|
8196
|
-
onCurrencyChange: null,
|
|
8197
|
-
placeholder: null,
|
|
8198
|
-
amount: null,
|
|
8199
|
-
onAmountChange: null,
|
|
8200
|
-
customActionLabel: '',
|
|
8201
|
-
onCustomAction: null,
|
|
8202
|
-
classNames: {},
|
|
8203
|
-
selectProps: {},
|
|
8204
|
-
maxLengthOverride: null
|
|
8205
|
-
};
|
|
8206
8147
|
var MoneyInput$1 = injectIntl(MoneyInput);
|
|
8207
8148
|
|
|
8208
8149
|
const NavigationOptionList = ({
|