@transferwise/components 46.32.0 → 46.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +71 -39
- package/build/index.js.map +1 -1
- package/build/index.mjs +71 -39
- package/build/index.mjs.map +1 -1
- package/build/types/alert/Alert.d.ts +3 -2
- package/build/types/alert/Alert.d.ts.map +1 -1
- package/build/types/common/domHelpers/documentIosClick.d.ts +0 -1
- package/build/types/common/domHelpers/documentIosClick.d.ts.map +1 -1
- package/build/types/common/domHelpers/index.d.ts +1 -1
- package/build/types/common/domHelpers/index.d.ts.map +1 -1
- package/build/types/dateLookup/DateLookup.d.ts.map +1 -1
- package/build/types/moneyInput/MoneyInput.d.ts +4 -2
- package/build/types/moneyInput/MoneyInput.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/build/types/select/Select.d.ts +7 -7
- package/build/types/select/Select.d.ts.map +1 -1
- package/build/types/typeahead/Typeahead.d.ts +4 -55
- package/build/types/typeahead/Typeahead.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/alert/Alert.spec.tsx +12 -0
- package/src/alert/Alert.story.tsx +11 -1
- package/src/alert/Alert.tsx +33 -14
- package/src/common/domHelpers/documentIosClick.ts +0 -5
- package/src/common/domHelpers/index.ts +0 -1
- package/src/dateLookup/DateLookup.rtl.spec.tsx +2 -3
- package/src/dateLookup/DateLookup.tsx +1 -3
- package/src/inputs/SelectInput.spec.tsx +1 -1
- package/src/moneyInput/MoneyInput.rtl.spec.tsx +10 -0
- package/src/moneyInput/MoneyInput.spec.js +10 -5
- package/src/moneyInput/MoneyInput.tsx +21 -14
- package/src/phoneNumberInput/PhoneNumberInput.rtl.spec.tsx +10 -0
- package/src/phoneNumberInput/PhoneNumberInput.tsx +11 -2
- package/src/select/Select.js +18 -15
- package/src/select/Select.rtl.spec.tsx +17 -0
- package/src/select/Select.spec.js +2 -7
- package/src/typeahead/Typeahead.rtl.spec.tsx +16 -0
- package/src/typeahead/Typeahead.tsx +21 -7
package/build/index.js
CHANGED
|
@@ -166,10 +166,6 @@ function stopPropagation$1(event) {
|
|
|
166
166
|
event.nativeEvent.stopImmediatePropagation();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
function getSimpleRandomId(prefix) {
|
|
170
|
-
const random = Math.ceil(Math.random() * 999999);
|
|
171
|
-
return `${prefix}${random}`;
|
|
172
|
-
}
|
|
173
169
|
|
|
174
170
|
/**
|
|
175
171
|
* Defined in `Dimmer.less`
|
|
@@ -984,7 +980,7 @@ function Alert({
|
|
|
984
980
|
"data-testid": "alert",
|
|
985
981
|
onTouchStart: () => setShouldFire(true),
|
|
986
982
|
onTouchEnd: event => {
|
|
987
|
-
if (shouldFire && action &&
|
|
983
|
+
if (shouldFire && action?.href &&
|
|
988
984
|
// Check if current event is triggered from closeButton
|
|
989
985
|
event.target instanceof Node && closeButtonReference.current && !closeButtonReference.current.contains(event.target)) {
|
|
990
986
|
if (action.target === '_blank') {
|
|
@@ -1021,13 +1017,8 @@ function Alert({
|
|
|
1021
1017
|
children: message
|
|
1022
1018
|
})
|
|
1023
1019
|
})]
|
|
1024
|
-
}), action && /*#__PURE__*/jsxRuntime.jsx(
|
|
1025
|
-
|
|
1026
|
-
className: "m-t-1",
|
|
1027
|
-
"aria-label": action['aria-label'],
|
|
1028
|
-
target: action.target,
|
|
1029
|
-
type: exports.Typography.LINK_LARGE,
|
|
1030
|
-
children: action.text
|
|
1020
|
+
}), action && /*#__PURE__*/jsxRuntime.jsx(Action, {
|
|
1021
|
+
action: action
|
|
1031
1022
|
})]
|
|
1032
1023
|
})]
|
|
1033
1024
|
}), onDismiss && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
|
|
@@ -1054,6 +1045,28 @@ function alertArrowClassNames(arrow) {
|
|
|
1054
1045
|
return 'arrow';
|
|
1055
1046
|
}
|
|
1056
1047
|
}
|
|
1048
|
+
function Action({
|
|
1049
|
+
action
|
|
1050
|
+
}) {
|
|
1051
|
+
if ('href' in action) {
|
|
1052
|
+
return /*#__PURE__*/jsxRuntime.jsx(Link, {
|
|
1053
|
+
href: action.href,
|
|
1054
|
+
className: "m-t-1",
|
|
1055
|
+
"aria-label": action['aria-label'],
|
|
1056
|
+
target: action.target,
|
|
1057
|
+
type: exports.Typography.LINK_LARGE,
|
|
1058
|
+
onClick: action.onClick,
|
|
1059
|
+
children: action.text
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
return /*#__PURE__*/jsxRuntime.jsx("button", {
|
|
1063
|
+
type: "button",
|
|
1064
|
+
"aria-label": action['aria-label'],
|
|
1065
|
+
className: "btn-unstyled np-text-link-large m-t-1",
|
|
1066
|
+
onClick: action.onClick,
|
|
1067
|
+
children: action.text
|
|
1068
|
+
});
|
|
1069
|
+
}
|
|
1057
1070
|
|
|
1058
1071
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
1059
1072
|
exports.AvatarType = void 0;
|
|
@@ -7460,9 +7473,8 @@ const formatAmountIfSet = ({
|
|
|
7460
7473
|
}) => {
|
|
7461
7474
|
if (maxLengthOverride) {
|
|
7462
7475
|
return amount != null ? String(amount) : '';
|
|
7463
|
-
} else {
|
|
7464
|
-
return typeof amount === 'number' ? formatting.formatAmount(amount, currency, locale) : '';
|
|
7465
7476
|
}
|
|
7477
|
+
return typeof amount === 'number' ? formatting.formatAmount(amount, currency, locale) : '';
|
|
7466
7478
|
};
|
|
7467
7479
|
const parseNumber = ({
|
|
7468
7480
|
amount,
|
|
@@ -7520,7 +7532,7 @@ class MoneyInput extends React.Component {
|
|
|
7520
7532
|
key,
|
|
7521
7533
|
ctrlKey
|
|
7522
7534
|
} = event;
|
|
7523
|
-
const isNumberKey = neptuneValidation.isNumber(parseInt(key, 10));
|
|
7535
|
+
const isNumberKey = neptuneValidation.isNumber(Number.parseInt(key, 10));
|
|
7524
7536
|
return isNumberKey || metaKey || ctrlKey || allowedInputKeys.has(key);
|
|
7525
7537
|
};
|
|
7526
7538
|
handleKeyDown = event => {
|
|
@@ -7536,7 +7548,7 @@ class MoneyInput extends React.Component {
|
|
|
7536
7548
|
const parsed = neptuneValidation.isEmpty(paste) ? null : parseNumber({
|
|
7537
7549
|
amount: paste,
|
|
7538
7550
|
currency: this.props.selectedCurrency.currency,
|
|
7539
|
-
locale
|
|
7551
|
+
locale,
|
|
7540
7552
|
maxLengthOverride: this.props.maxLengthOverride
|
|
7541
7553
|
});
|
|
7542
7554
|
if (isNumberOrNull(parsed)) {
|
|
@@ -7544,7 +7556,7 @@ class MoneyInput extends React.Component {
|
|
|
7544
7556
|
formattedAmount: formatAmountIfSet({
|
|
7545
7557
|
amount: parsed,
|
|
7546
7558
|
currency: this.props.selectedCurrency.currency,
|
|
7547
|
-
locale
|
|
7559
|
+
locale,
|
|
7548
7560
|
maxLengthOverride: this.props.maxLengthOverride
|
|
7549
7561
|
})
|
|
7550
7562
|
});
|
|
@@ -7641,15 +7653,17 @@ class MoneyInput extends React.Component {
|
|
|
7641
7653
|
style = className => this.props.classNames[className] || className;
|
|
7642
7654
|
render() {
|
|
7643
7655
|
const {
|
|
7656
|
+
inputAttributes,
|
|
7657
|
+
id: amountInputId,
|
|
7658
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
7644
7659
|
selectedCurrency,
|
|
7645
7660
|
onCurrencyChange,
|
|
7646
7661
|
size,
|
|
7647
7662
|
addon,
|
|
7648
|
-
id,
|
|
7649
|
-
'aria-labelledby': ariaLabelledBy,
|
|
7650
7663
|
selectProps,
|
|
7651
7664
|
maxLengthOverride
|
|
7652
7665
|
} = this.props;
|
|
7666
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes?.['aria-labelledby'];
|
|
7653
7667
|
const selectOptions = this.getSelectOptions();
|
|
7654
7668
|
const hasSingleCurrency = () => {
|
|
7655
7669
|
if (selectOptions.length !== 0) {
|
|
@@ -7670,10 +7684,12 @@ class MoneyInput extends React.Component {
|
|
|
7670
7684
|
const isFixedCurrency = !this.state.searchQuery && hasSingleCurrency() || !onCurrencyChange;
|
|
7671
7685
|
const disabled = !this.props.onAmountChange;
|
|
7672
7686
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
7687
|
+
role: "group",
|
|
7688
|
+
...inputAttributes,
|
|
7673
7689
|
"aria-labelledby": ariaLabelledBy,
|
|
7674
7690
|
className: classNames__default.default(this.style('tw-money-input'), this.style('input-group'), this.style(`input-group-${size}`)),
|
|
7675
7691
|
children: [/*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
7676
|
-
id:
|
|
7692
|
+
id: amountInputId,
|
|
7677
7693
|
value: this.state.formattedAmount,
|
|
7678
7694
|
inputMode: "decimal",
|
|
7679
7695
|
disabled: disabled,
|
|
@@ -7774,7 +7790,7 @@ function currencyOptionFitsQuery(option, query) {
|
|
|
7774
7790
|
return contains(option.label, query) || contains(option.searchable, query) || contains(option.note, query);
|
|
7775
7791
|
}
|
|
7776
7792
|
function contains(property, query) {
|
|
7777
|
-
return property
|
|
7793
|
+
return property?.toLowerCase().includes(query.toLowerCase());
|
|
7778
7794
|
}
|
|
7779
7795
|
function sortOptionsLabelsToFirst(options, query) {
|
|
7780
7796
|
return [...options].sort((first, second) => {
|
|
@@ -7792,7 +7808,9 @@ function sortOptionsLabelsToFirst(options, query) {
|
|
|
7792
7808
|
return 0;
|
|
7793
7809
|
});
|
|
7794
7810
|
}
|
|
7795
|
-
var MoneyInput$1 = reactIntl.injectIntl(MoneyInput
|
|
7811
|
+
var MoneyInput$1 = reactIntl.injectIntl(withInputAttributes(MoneyInput, {
|
|
7812
|
+
nonLabelable: true
|
|
7813
|
+
}));
|
|
7796
7814
|
|
|
7797
7815
|
const NavigationOptionList = ({
|
|
7798
7816
|
children
|
|
@@ -9313,7 +9331,7 @@ const defaultSelectProps = {};
|
|
|
9313
9331
|
const defaultDisabledCountries = [];
|
|
9314
9332
|
const PhoneNumberInput = ({
|
|
9315
9333
|
id,
|
|
9316
|
-
'aria-labelledby':
|
|
9334
|
+
'aria-labelledby': ariaLabelledByProp,
|
|
9317
9335
|
required,
|
|
9318
9336
|
disabled,
|
|
9319
9337
|
initialValue,
|
|
@@ -9327,6 +9345,10 @@ const PhoneNumberInput = ({
|
|
|
9327
9345
|
selectProps = defaultSelectProps,
|
|
9328
9346
|
disabledCountries = defaultDisabledCountries
|
|
9329
9347
|
}) => {
|
|
9348
|
+
const inputAttributes = useInputAttributes({
|
|
9349
|
+
nonLabelable: true
|
|
9350
|
+
});
|
|
9351
|
+
const ariaLabelledBy = ariaLabelledByProp ?? inputAttributes['aria-labelledby'];
|
|
9330
9352
|
const {
|
|
9331
9353
|
locale,
|
|
9332
9354
|
formatMessage
|
|
@@ -9383,6 +9405,8 @@ const PhoneNumberInput = ({
|
|
|
9383
9405
|
setBroadcastedValue(internalValue);
|
|
9384
9406
|
}, [onChange, broadcastedValue, internalValue]);
|
|
9385
9407
|
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
9408
|
+
role: "group",
|
|
9409
|
+
...inputAttributes,
|
|
9386
9410
|
"aria-labelledby": ariaLabelledBy,
|
|
9387
9411
|
className: "tw-telephone",
|
|
9388
9412
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -10115,6 +10139,7 @@ function Select({
|
|
|
10115
10139
|
dropdownProps,
|
|
10116
10140
|
buttonProps
|
|
10117
10141
|
}) {
|
|
10142
|
+
const inputAttributes = useInputAttributes();
|
|
10118
10143
|
const {
|
|
10119
10144
|
formatMessage
|
|
10120
10145
|
} = reactIntl.useIntl();
|
|
@@ -10134,7 +10159,6 @@ function Select({
|
|
|
10134
10159
|
const optionsListReference = React.useRef(null);
|
|
10135
10160
|
const isSearchEnabled = !!onSearchChange || !!search;
|
|
10136
10161
|
const isDropdownAutoWidth = dropdownWidth == null;
|
|
10137
|
-
const fallbackButtonId = React.useMemo(() => getSimpleRandomId('np-select-'), []);
|
|
10138
10162
|
const options = React.useMemo(() => {
|
|
10139
10163
|
if (!search || !searchValue) {
|
|
10140
10164
|
return defaultOptions;
|
|
@@ -10142,14 +10166,14 @@ function Select({
|
|
|
10142
10166
|
return defaultOptions.filter(isSearchableOption).filter(option => {
|
|
10143
10167
|
if (typeof search === 'function') {
|
|
10144
10168
|
return search(option, searchValue);
|
|
10145
|
-
} else {
|
|
10146
|
-
return defaultFilterFunction(option, searchValue);
|
|
10147
10169
|
}
|
|
10170
|
+
return defaultFilterFunction(option, searchValue);
|
|
10148
10171
|
});
|
|
10149
10172
|
}, [defaultOptions, search, searchValue]);
|
|
10150
10173
|
const selectableOptions = React.useMemo(() => options.filter(isActionableOption), [options]);
|
|
10151
10174
|
const focusedOption = selectableOptions[keyboardFocusedOptionIndex];
|
|
10152
|
-
const
|
|
10175
|
+
const fallbackButtonId = reactId.useId();
|
|
10176
|
+
const computedId = id || inputAttributes.id || fallbackButtonId;
|
|
10153
10177
|
const listboxId = `${computedId}-listbox`;
|
|
10154
10178
|
const searchBoxId = `${computedId}-searchbox`;
|
|
10155
10179
|
const {
|
|
@@ -10280,7 +10304,7 @@ function Select({
|
|
|
10280
10304
|
React.useEffect(() => {
|
|
10281
10305
|
if (open) {
|
|
10282
10306
|
if (!isMobile || searchValue) {
|
|
10283
|
-
if (isSearchEnabled &&
|
|
10307
|
+
if (isSearchEnabled && searchBoxReference.current) {
|
|
10284
10308
|
searchBoxReference.current.focus();
|
|
10285
10309
|
}
|
|
10286
10310
|
if (!isSearchEnabled && optionsListReference.current && (previousKeyboardFocusedOptionIndex.current == null || Number.isNaN(previousKeyboardFocusedOptionIndex.current))) {
|
|
@@ -10466,6 +10490,7 @@ function Select({
|
|
|
10466
10490
|
onBlur: handleOnBlur,
|
|
10467
10491
|
children: [/*#__PURE__*/jsxRuntime.jsxs(Button, {
|
|
10468
10492
|
ref: dropdownButtonReference,
|
|
10493
|
+
...inputAttributes,
|
|
10469
10494
|
id: computedId,
|
|
10470
10495
|
block: block,
|
|
10471
10496
|
size: size,
|
|
@@ -10541,9 +10566,6 @@ Select.propTypes = {
|
|
|
10541
10566
|
* if `function` you can define your own search function to implement custom search experience. This search function used while filtering the options array. The custom search function takes two parameters. First is the option the second is the keyword.
|
|
10542
10567
|
*/
|
|
10543
10568
|
search: PropTypes__default.default.oneOfType([PropTypes__default.default.bool, PropTypes__default.default.func]),
|
|
10544
|
-
onChange: PropTypes__default.default.func.isRequired,
|
|
10545
|
-
onFocus: PropTypes__default.default.func,
|
|
10546
|
-
onBlur: PropTypes__default.default.func,
|
|
10547
10569
|
options: PropTypes__default.default.arrayOf(PropTypes__default.default.shape({
|
|
10548
10570
|
value: PropTypes__default.default.any,
|
|
10549
10571
|
label: PropTypes__default.default.node,
|
|
@@ -10556,17 +10578,20 @@ Select.propTypes = {
|
|
|
10556
10578
|
disabled: PropTypes__default.default.bool,
|
|
10557
10579
|
searchStrings: PropTypes__default.default.arrayOf(PropTypes__default.default.string)
|
|
10558
10580
|
})).isRequired,
|
|
10559
|
-
/**
|
|
10560
|
-
* To have full control of your search value and response use `onSearchChange` function combined with `searchValue` and custom filtering on the options array.
|
|
10561
|
-
* DO NOT USE TOGETHER WITH `search` PROPERTY
|
|
10562
|
-
*/
|
|
10563
|
-
onSearchChange: PropTypes__default.default.func,
|
|
10564
10581
|
searchValue: PropTypes__default.default.string,
|
|
10565
10582
|
searchPlaceholder: PropTypes__default.default.string,
|
|
10566
10583
|
classNames: PropTypes__default.default.objectOf(PropTypes__default.default.string),
|
|
10567
10584
|
dropdownUp: PropTypes__default.default.bool,
|
|
10568
10585
|
buttonProps: PropTypes__default.default.object,
|
|
10569
|
-
dropdownProps: PropTypes__default.default.object
|
|
10586
|
+
dropdownProps: PropTypes__default.default.object,
|
|
10587
|
+
onChange: PropTypes__default.default.func.isRequired,
|
|
10588
|
+
onFocus: PropTypes__default.default.func,
|
|
10589
|
+
onBlur: PropTypes__default.default.func,
|
|
10590
|
+
/**
|
|
10591
|
+
* To have full control of your search value and response use `onSearchChange` function combined with `searchValue` and custom filtering on the options array.
|
|
10592
|
+
* DO NOT USE TOGETHER WITH `search` PROPERTY
|
|
10593
|
+
*/
|
|
10594
|
+
onSearchChange: PropTypes__default.default.func
|
|
10570
10595
|
};
|
|
10571
10596
|
Select.defaultProps = {
|
|
10572
10597
|
id: undefined,
|
|
@@ -12162,7 +12187,8 @@ class Typeahead extends React.Component {
|
|
|
12162
12187
|
};
|
|
12163
12188
|
render() {
|
|
12164
12189
|
const {
|
|
12165
|
-
|
|
12190
|
+
inputAttributes,
|
|
12191
|
+
id: idProp,
|
|
12166
12192
|
placeholder,
|
|
12167
12193
|
multiple,
|
|
12168
12194
|
size,
|
|
@@ -12180,6 +12206,7 @@ class Typeahead extends React.Component {
|
|
|
12180
12206
|
alert,
|
|
12181
12207
|
inputAutoComplete
|
|
12182
12208
|
} = this.props;
|
|
12209
|
+
const id = idProp ?? inputAttributes?.id;
|
|
12183
12210
|
const {
|
|
12184
12211
|
errorState,
|
|
12185
12212
|
query,
|
|
@@ -12205,6 +12232,8 @@ class Typeahead extends React.Component {
|
|
|
12205
12232
|
const hasWarning = displayAlert && alertType === exports.Sentiment.WARNING;
|
|
12206
12233
|
const hasInfo = displayAlert && alertType === exports.Sentiment.NEUTRAL;
|
|
12207
12234
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
12235
|
+
role: "group",
|
|
12236
|
+
...inputAttributes,
|
|
12208
12237
|
id: id,
|
|
12209
12238
|
className: classNames__default.default('typeahead', `typeahead-${size}`, {
|
|
12210
12239
|
'typeahead--has-value': selected.length > 0,
|
|
@@ -12260,6 +12289,9 @@ class Typeahead extends React.Component {
|
|
|
12260
12289
|
});
|
|
12261
12290
|
}
|
|
12262
12291
|
}
|
|
12292
|
+
var Typeahead$1 = withInputAttributes(Typeahead, {
|
|
12293
|
+
nonLabelable: true
|
|
12294
|
+
});
|
|
12263
12295
|
|
|
12264
12296
|
// TODO: consider to move this enum into component file once we migrate it on TypeScript or replace with some common enum
|
|
12265
12297
|
exports.UploadStep = void 0;
|
|
@@ -14882,7 +14914,7 @@ exports.TextArea = TextArea;
|
|
|
14882
14914
|
exports.TextareaWithDisplayFormat = TextareaWithDisplayFormat;
|
|
14883
14915
|
exports.Title = Title;
|
|
14884
14916
|
exports.Tooltip = Tooltip;
|
|
14885
|
-
exports.Typeahead = Typeahead;
|
|
14917
|
+
exports.Typeahead = Typeahead$1;
|
|
14886
14918
|
exports.Upload = Upload$1;
|
|
14887
14919
|
exports.UploadInput = UploadInput;
|
|
14888
14920
|
exports.adjustLocale = adjustLocale;
|