@transferwise/components 45.21.2 → 45.22.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.esm.js +115 -130
- package/build/index.esm.js.map +1 -1
- package/build/index.js +115 -130
- package/build/index.js.map +1 -1
- package/build/main.css +1 -1
- package/build/styles/flowNavigation/FlowNavigation.css +1 -1
- package/build/styles/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
- package/build/styles/inputs/SelectInput.css +1 -1
- package/build/styles/main.css +1 -1
- package/build/styles/overlayHeader/OverlayHeader.css +1 -1
- package/build/styles/phoneNumberInput/PhoneNumberInput.css +1 -1
- package/build/types/common/flowHeader/FlowHeader.d.ts.map +1 -1
- package/build/types/flowNavigation/FlowNavigation.d.ts.map +1 -1
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts +1 -2
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
- package/build/types/flowNavigation/backButton/BackButton.d.ts +10 -11
- package/build/types/flowNavigation/backButton/BackButton.d.ts.map +1 -1
- package/build/types/inputs/SelectInput.d.ts +5 -1
- package/build/types/inputs/SelectInput.d.ts.map +1 -1
- package/build/types/overlayHeader/OverlayHeader.d.ts.map +1 -1
- package/build/types/phoneNumberInput/PhoneNumberInput.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/common/flowHeader/FlowHeader.tsx +4 -22
- package/src/common/flowHeader/__snapshots__/FlowHeader.spec.js.snap +6 -22
- package/src/flowNavigation/FlowNavigation.css +1 -1
- package/src/flowNavigation/FlowNavigation.less +0 -9
- package/src/flowNavigation/FlowNavigation.spec.js +3 -3
- package/src/flowNavigation/FlowNavigation.story.js +22 -189
- package/src/flowNavigation/FlowNavigation.tsx +22 -27
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +18 -26
- package/src/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
- package/src/flowNavigation/animatedLabel/AnimatedLabel.less +0 -6
- package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +7 -21
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +8 -17
- package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +4 -4
- package/src/flowNavigation/backButton/BackButton.js +14 -9
- package/src/flowNavigation/backButton/BackButton.spec.js +3 -2
- package/src/flowNavigation/backButton/__snapshots__/BackButton.spec.js.snap +28 -21
- package/src/inputs/SelectInput.css +1 -1
- package/src/inputs/SelectInput.less +7 -10
- package/src/inputs/SelectInput.spec.tsx +40 -0
- package/src/inputs/SelectInput.story.tsx +18 -0
- package/src/inputs/SelectInput.tsx +46 -12
- package/src/inputs/_BottomSheet.less +1 -1
- package/src/inputs/_Popover.less +1 -0
- package/src/main.css +1 -1
- package/src/overlayHeader/OverlayHeader.css +1 -1
- package/src/overlayHeader/OverlayHeader.js +6 -4
- package/src/overlayHeader/OverlayHeader.less +0 -8
- package/src/overlayHeader/OverlayHeader.spec.js +1 -1
- package/src/overlayHeader/__snapshots__/OverlayHeader.spec.js.snap +10 -14
- package/src/phoneNumberInput/PhoneNumberInput.css +1 -1
- package/src/phoneNumberInput/PhoneNumberInput.js +27 -28
- package/src/phoneNumberInput/PhoneNumberInput.less +4 -0
- package/src/phoneNumberInput/PhoneNumberInput.spec.js +64 -72
- package/src/phoneNumberInput/PhoneNumberInput.story.js +1 -3
- package/src/flowNavigation/animatedLabel/AnimatedLabel.story.js +0 -22
package/build/index.esm.js
CHANGED
|
@@ -5396,19 +5396,8 @@ const FlowHeader = /*#__PURE__*/React.forwardRef(({
|
|
|
5396
5396
|
const isVertical = layout === Layout$1.VERTICAL;
|
|
5397
5397
|
return /*#__PURE__*/jsxs("div", {
|
|
5398
5398
|
ref: reference,
|
|
5399
|
-
className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', className),
|
|
5400
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
5401
|
-
className: classNames('np-flow-header__left', {
|
|
5402
|
-
'flex__item--8': isVertical
|
|
5403
|
-
}),
|
|
5404
|
-
children: leftContent
|
|
5405
|
-
}), /*#__PURE__*/jsx("div", {
|
|
5406
|
-
className: classNames('align-items-center', 'd-flex', 'np-flow-header__right', 'justify-content-end', {
|
|
5407
|
-
'flex__item--4 ': isVertical,
|
|
5408
|
-
'order-2': !isVertical
|
|
5409
|
-
}),
|
|
5410
|
-
children: rightContent
|
|
5411
|
-
}), /*#__PURE__*/jsx("div", {
|
|
5399
|
+
className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', 'justify-content-between', 'flex__item--12', className),
|
|
5400
|
+
children: [leftContent, rightContent, /*#__PURE__*/jsx("div", {
|
|
5412
5401
|
className: classNames('align-items-center', 'd-flex', 'justify-content-center', {
|
|
5413
5402
|
'flex__item--12': isVertical,
|
|
5414
5403
|
'order-1 flex-grow-1': !isVertical
|
|
@@ -5711,19 +5700,16 @@ var messages$5 = defineMessages({
|
|
|
5711
5700
|
const AnimatedLabel = ({
|
|
5712
5701
|
activeLabel,
|
|
5713
5702
|
className,
|
|
5714
|
-
labels
|
|
5715
|
-
'aria-label': ariaLabel
|
|
5703
|
+
labels
|
|
5716
5704
|
}) => {
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
className: classNames('np-animated-label', 'np-text-body-large-bold', className),
|
|
5705
|
+
return /*#__PURE__*/jsx(Body, {
|
|
5706
|
+
type: Typography.BODY_LARGE_BOLD,
|
|
5707
|
+
className: classNames('np-animated-label', className),
|
|
5721
5708
|
children: labels.map((label, index) => {
|
|
5722
5709
|
const nextLabel = index - 1;
|
|
5723
5710
|
return /*#__PURE__*/jsx("div", {
|
|
5724
|
-
className: classNames('text-xs-
|
|
5725
|
-
'np-animated-label--in': index === activeLabel
|
|
5726
|
-
'np-animated-label--out': nextLabel === activeLabel && nextLabel !== numberLabels
|
|
5711
|
+
className: classNames('text-xs-center', {
|
|
5712
|
+
'np-animated-label--in text-ellipsis': index === activeLabel
|
|
5727
5713
|
}),
|
|
5728
5714
|
children: label
|
|
5729
5715
|
}, nextLabel);
|
|
@@ -5732,18 +5718,24 @@ const AnimatedLabel = ({
|
|
|
5732
5718
|
};
|
|
5733
5719
|
|
|
5734
5720
|
const BackButton = ({
|
|
5735
|
-
label,
|
|
5736
5721
|
className,
|
|
5737
|
-
onClick
|
|
5738
|
-
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
children:
|
|
5743
|
-
|
|
5744
|
-
|
|
5722
|
+
onClick,
|
|
5723
|
+
'aria-label': ariaLabel
|
|
5724
|
+
}) => /*#__PURE__*/jsx(Avatar, {
|
|
5725
|
+
type: AvatarType.ICON,
|
|
5726
|
+
size: 40,
|
|
5727
|
+
children: /*#__PURE__*/jsx("button", {
|
|
5728
|
+
type: "button",
|
|
5729
|
+
"aria-label": ariaLabel,
|
|
5730
|
+
className: classNames('np-back-button', 'btn-unstyled', className),
|
|
5731
|
+
onClick: onClick,
|
|
5732
|
+
children: /*#__PURE__*/jsx(ArrowLeft, {
|
|
5733
|
+
size: 24
|
|
5734
|
+
})
|
|
5735
|
+
})
|
|
5745
5736
|
});
|
|
5746
5737
|
BackButton.propTypes = {
|
|
5738
|
+
'aria-label': PropTypes.string.isRequired,
|
|
5747
5739
|
className: PropTypes.string,
|
|
5748
5740
|
label: PropTypes.element,
|
|
5749
5741
|
onClick: PropTypes.func
|
|
@@ -5773,21 +5765,9 @@ const FlowNavigation = ({
|
|
|
5773
5765
|
onClick: onClose
|
|
5774
5766
|
});
|
|
5775
5767
|
const isSmall = clientWidth != null && clientWidth < Breakpoint.SMALL;
|
|
5768
|
+
const isLarge = clientWidth != null && clientWidth >= Breakpoint.LARGE;
|
|
5776
5769
|
const newAvatar = done ? null : avatar;
|
|
5777
|
-
const
|
|
5778
|
-
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
5779
|
-
return /*#__PURE__*/jsx(Fragment, {
|
|
5780
|
-
children: displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
|
|
5781
|
-
label: /*#__PURE__*/jsx(AnimatedLabel, {
|
|
5782
|
-
className: "m-x-1",
|
|
5783
|
-
labels: steps.map(step => step.label),
|
|
5784
|
-
activeLabel: activeStep - 1,
|
|
5785
|
-
"aria-label": intl.formatMessage(messages$5.back)
|
|
5786
|
-
}),
|
|
5787
|
-
onClick: onGoBack
|
|
5788
|
-
}) : logo
|
|
5789
|
-
});
|
|
5790
|
-
};
|
|
5770
|
+
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
5791
5771
|
return /*#__PURE__*/jsx("div", {
|
|
5792
5772
|
ref: reference,
|
|
5793
5773
|
className: classNames('np-flow-navigation d-flex align-items-center justify-content-center p-y-3', {
|
|
@@ -5799,12 +5779,24 @@ const FlowNavigation = ({
|
|
|
5799
5779
|
'np-flow-navigation--xs-max': isSmall,
|
|
5800
5780
|
// Size switches on parent container which may or may not have the same size as the window.
|
|
5801
5781
|
'np-flow-navigation--sm': clientWidth != null && clientWidth >= Breakpoint.SMALL,
|
|
5802
|
-
'np-flow-navigation--lg':
|
|
5782
|
+
'np-flow-navigation--lg': isLarge
|
|
5803
5783
|
}),
|
|
5804
|
-
leftContent:
|
|
5805
|
-
|
|
5784
|
+
leftContent: /*#__PURE__*/jsxs(Fragment, {
|
|
5785
|
+
children: [isSmall && displayGoBack ? /*#__PURE__*/jsx(BackButton$1, {
|
|
5786
|
+
"aria-label": intl.formatMessage(messages$5.back),
|
|
5787
|
+
onClick: onGoBack
|
|
5788
|
+
}) : logo, isSmall && /*#__PURE__*/jsx(AnimatedLabel, {
|
|
5789
|
+
className: "m-x-1",
|
|
5790
|
+
labels: steps.map(step => step.label),
|
|
5791
|
+
activeLabel: activeStep
|
|
5792
|
+
})]
|
|
5793
|
+
}),
|
|
5794
|
+
rightContent: /*#__PURE__*/jsxs("div", {
|
|
5795
|
+
className: classNames('d-flex', 'align-items-center', {
|
|
5796
|
+
'order-2': isLarge
|
|
5797
|
+
}),
|
|
5806
5798
|
children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
|
|
5807
|
-
className: "
|
|
5799
|
+
className: "m-x-1"
|
|
5808
5800
|
}), closeButton]
|
|
5809
5801
|
}),
|
|
5810
5802
|
bottomContent: !done && /*#__PURE__*/jsx(Stepper, {
|
|
@@ -6749,6 +6741,7 @@ function SelectInput({
|
|
|
6749
6741
|
value: controlledValue,
|
|
6750
6742
|
compareValues,
|
|
6751
6743
|
renderValue = wrapInFragment,
|
|
6744
|
+
renderFooter,
|
|
6752
6745
|
renderTrigger = defaultRenderTrigger,
|
|
6753
6746
|
filterable,
|
|
6754
6747
|
filterPlaceholder,
|
|
@@ -6822,6 +6815,7 @@ function SelectInput({
|
|
|
6822
6815
|
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6823
6816
|
items: items,
|
|
6824
6817
|
renderValue: renderValue,
|
|
6818
|
+
renderFooter: renderFooter,
|
|
6825
6819
|
filterable: filterable,
|
|
6826
6820
|
filterPlaceholder: filterPlaceholder,
|
|
6827
6821
|
searchInputRef: searchInputRef,
|
|
@@ -6864,29 +6858,32 @@ const SelectInputOptionsContainer = /*#__PURE__*/forwardRef(function SelectInput
|
|
|
6864
6858
|
useEffect(() => {
|
|
6865
6859
|
handleAriaActiveDescendantChange(ariaActiveDescendant);
|
|
6866
6860
|
}, [ariaActiveDescendant, handleAriaActiveDescendantChange]);
|
|
6867
|
-
return (
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6882
|
-
|
|
6883
|
-
|
|
6884
|
-
|
|
6885
|
-
|
|
6861
|
+
return /*#__PURE__*/jsx("div", {
|
|
6862
|
+
ref: ref,
|
|
6863
|
+
role: "none",
|
|
6864
|
+
onKeyDown: event => {
|
|
6865
|
+
// Prevent confirmation close without an active item
|
|
6866
|
+
if (event.key === 'Enter' && ariaActiveDescendant == null) {
|
|
6867
|
+
return;
|
|
6868
|
+
}
|
|
6869
|
+
// Prevent absorbing actions early
|
|
6870
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
6871
|
+
onKeyDown?.({
|
|
6872
|
+
...event,
|
|
6873
|
+
preventDefault: () => {},
|
|
6874
|
+
stopPropagation: () => {}
|
|
6875
|
+
});
|
|
6876
|
+
return;
|
|
6877
|
+
}
|
|
6878
|
+
onKeyDown?.(event);
|
|
6879
|
+
},
|
|
6880
|
+
...restProps
|
|
6881
|
+
});
|
|
6886
6882
|
});
|
|
6887
6883
|
function SelectInputOptions({
|
|
6888
6884
|
items,
|
|
6889
6885
|
renderValue = wrapInFragment,
|
|
6886
|
+
renderFooter,
|
|
6890
6887
|
filterable = false,
|
|
6891
6888
|
filterPlaceholder,
|
|
6892
6889
|
searchInputRef,
|
|
@@ -6901,14 +6898,14 @@ function SelectInputOptions({
|
|
|
6901
6898
|
}
|
|
6902
6899
|
return undefined;
|
|
6903
6900
|
}, [filterable, query]);
|
|
6904
|
-
const
|
|
6901
|
+
const resultsEmpty = needle != null && filterSelectInputItems(items, needle).length === 0;
|
|
6905
6902
|
const listboxContainerRef = useRef(null);
|
|
6906
6903
|
useEffect(() => {
|
|
6907
6904
|
if (listboxContainerRef.current != null) {
|
|
6908
6905
|
listboxContainerRef.current.style.setProperty('--initial-height', `${listboxContainerRef.current.offsetHeight}px`);
|
|
6909
6906
|
}
|
|
6910
6907
|
}, []);
|
|
6911
|
-
const showStatus =
|
|
6908
|
+
const showStatus = resultsEmpty;
|
|
6912
6909
|
const statusId = useId();
|
|
6913
6910
|
const listboxId = useId();
|
|
6914
6911
|
return /*#__PURE__*/jsxs(Listbox.Options, {
|
|
@@ -6944,10 +6941,10 @@ function SelectInputOptions({
|
|
|
6944
6941
|
setQuery(event.currentTarget.value);
|
|
6945
6942
|
}
|
|
6946
6943
|
})
|
|
6947
|
-
}) : null, /*#__PURE__*/jsxs("
|
|
6944
|
+
}) : null, /*#__PURE__*/jsxs("section", {
|
|
6948
6945
|
ref: listboxContainerRef,
|
|
6949
6946
|
className: classNames('np-select-input-listbox-container', items.some(item => item.type === 'group') && 'np-select-input-listbox-container--has-group'),
|
|
6950
|
-
children: [
|
|
6947
|
+
children: [resultsEmpty ? /*#__PURE__*/jsxs("div", {
|
|
6951
6948
|
id: statusId,
|
|
6952
6949
|
className: "np-select-input-options-status",
|
|
6953
6950
|
children: [/*#__PURE__*/jsx(CrossCircle, {
|
|
@@ -6968,7 +6965,22 @@ function SelectInputOptions({
|
|
|
6968
6965
|
renderValue: renderValue,
|
|
6969
6966
|
needle: needle
|
|
6970
6967
|
}, index))
|
|
6971
|
-
})
|
|
6968
|
+
}), renderFooter != null ? /*#__PURE__*/jsx("footer", {
|
|
6969
|
+
className: "np-select-input-footer",
|
|
6970
|
+
children: /*#__PURE__*/jsx("div", {
|
|
6971
|
+
role: "none",
|
|
6972
|
+
onKeyDown: event => {
|
|
6973
|
+
// Prevent interfering with Headless UI
|
|
6974
|
+
if (event.key !== 'Escape') {
|
|
6975
|
+
event.stopPropagation();
|
|
6976
|
+
}
|
|
6977
|
+
},
|
|
6978
|
+
children: renderFooter({
|
|
6979
|
+
resultsEmpty,
|
|
6980
|
+
normalizedQuery: needle
|
|
6981
|
+
})
|
|
6982
|
+
})
|
|
6983
|
+
}) : null]
|
|
6972
6984
|
})]
|
|
6973
6985
|
});
|
|
6974
6986
|
}
|
|
@@ -7025,7 +7037,7 @@ function SelectInputGroupItemView({
|
|
|
7025
7037
|
className: classNames(needle === null && 'np-select-input-group-item--without-needle'),
|
|
7026
7038
|
children: [needle == null ? /*#__PURE__*/jsx("header", {
|
|
7027
7039
|
id: headerId,
|
|
7028
|
-
role: "
|
|
7040
|
+
role: "none",
|
|
7029
7041
|
className: "np-select-input-group-item-header np-text-title-group",
|
|
7030
7042
|
children: item.label
|
|
7031
7043
|
}) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
|
|
@@ -8476,7 +8488,7 @@ class MoneyInput extends Component {
|
|
|
8476
8488
|
this.amountFocused = true;
|
|
8477
8489
|
};
|
|
8478
8490
|
getSelectOptions() {
|
|
8479
|
-
const selectOptions = [...filterOptionsForQuery
|
|
8491
|
+
const selectOptions = [...filterOptionsForQuery(this.props.currencies, this.state.searchQuery)];
|
|
8480
8492
|
if (this.props.onCustomAction) {
|
|
8481
8493
|
selectOptions.push({
|
|
8482
8494
|
value: CUSTOM_ACTION,
|
|
@@ -8513,7 +8525,7 @@ class MoneyInput extends Component {
|
|
|
8513
8525
|
if (this.props.onSearchChange) {
|
|
8514
8526
|
this.props.onSearchChange({
|
|
8515
8527
|
searchQuery,
|
|
8516
|
-
filteredOptions: filterOptionsForQuery
|
|
8528
|
+
filteredOptions: filterOptionsForQuery(this.props.currencies, searchQuery)
|
|
8517
8529
|
});
|
|
8518
8530
|
}
|
|
8519
8531
|
};
|
|
@@ -8594,7 +8606,7 @@ class MoneyInput extends Component {
|
|
|
8594
8606
|
});
|
|
8595
8607
|
}
|
|
8596
8608
|
}
|
|
8597
|
-
function filterOptionsForQuery
|
|
8609
|
+
function filterOptionsForQuery(options, query) {
|
|
8598
8610
|
if (!query) {
|
|
8599
8611
|
return options;
|
|
8600
8612
|
}
|
|
@@ -8803,6 +8815,7 @@ const OverlayHeader = ({
|
|
|
8803
8815
|
logo
|
|
8804
8816
|
}) => {
|
|
8805
8817
|
const closeButton = onClose && /*#__PURE__*/jsx(CloseButton, {
|
|
8818
|
+
size: Size.LARGE,
|
|
8806
8819
|
onClick: onClose
|
|
8807
8820
|
});
|
|
8808
8821
|
return /*#__PURE__*/jsx("div", {
|
|
@@ -8810,9 +8823,10 @@ const OverlayHeader = ({
|
|
|
8810
8823
|
children: /*#__PURE__*/jsx(FlowHeader, {
|
|
8811
8824
|
className: "np-overlay-header__content p-a-3",
|
|
8812
8825
|
leftContent: logo,
|
|
8813
|
-
rightContent: /*#__PURE__*/jsxs(
|
|
8826
|
+
rightContent: /*#__PURE__*/jsxs("div", {
|
|
8827
|
+
className: classNames('d-flex', 'align-items-center', 'order-2'),
|
|
8814
8828
|
children: [avatar, avatar && closeButton && /*#__PURE__*/jsx("span", {
|
|
8815
|
-
className:
|
|
8829
|
+
className: classNames('m-x-1')
|
|
8816
8830
|
}), closeButton]
|
|
8817
8831
|
})
|
|
8818
8832
|
})
|
|
@@ -10182,36 +10196,9 @@ const explodeNumberModel = number => {
|
|
|
10182
10196
|
};
|
|
10183
10197
|
};
|
|
10184
10198
|
|
|
10185
|
-
/**
|
|
10186
|
-
* Checks if query is contained into object properties.
|
|
10187
|
-
*
|
|
10188
|
-
* @param {object} option - the select option
|
|
10189
|
-
* @param {string} query - the current search query
|
|
10190
|
-
* @returns {boolean}
|
|
10191
|
-
*/
|
|
10192
|
-
const isOptionAndFitsQuery = (option, query) => startsWith(option.iso3, query) || startsWith(option.iso2, query) || startsWith(option.name, query) || startsWith(option.phone, query);
|
|
10193
|
-
const startsWith = (property, query) => {
|
|
10194
|
-
if (isArray(property)) {
|
|
10195
|
-
return property.filter(proper => normalizeValue(proper).indexOf(normalizeValue(query)) === 0).length > 0;
|
|
10196
|
-
}
|
|
10197
|
-
return normalizeValue(property).indexOf(normalizeValue(query)) === 0;
|
|
10198
|
-
};
|
|
10199
|
-
const normalizeValue = value => value.toLowerCase().replace('+', '');
|
|
10200
|
-
|
|
10201
|
-
/**
|
|
10202
|
-
* Filters a set of options based on search string
|
|
10203
|
-
*
|
|
10204
|
-
* @param options
|
|
10205
|
-
* @param query
|
|
10206
|
-
* @returns {*}
|
|
10207
|
-
*/
|
|
10208
|
-
const filterOptionsForQuery = (options, query) => options.filter(option => isOptionAndFitsQuery(option, query));
|
|
10209
|
-
|
|
10210
10199
|
const DIGITS_MATCH = /^$|^(\+)|([\d]+)/g;
|
|
10211
10200
|
const cleanNumber = number => number.match(DIGITS_MATCH) && number.match(DIGITS_MATCH).join('') || '';
|
|
10212
10201
|
|
|
10213
|
-
const isStringNumeric = value => /^\+?[\d-\s]+$/.test(value);
|
|
10214
|
-
|
|
10215
10202
|
// Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
|
|
10216
10203
|
const sortArrayByProperty = (arrayToSort, property) => [...arrayToSort].sort((a, b) => a[property].localeCompare(b[property]));
|
|
10217
10204
|
|
|
@@ -10290,17 +10277,15 @@ const PhoneNumberInput = props => {
|
|
|
10290
10277
|
};
|
|
10291
10278
|
const [internalValue, setInternalValue] = useState(getInitialValue());
|
|
10292
10279
|
const [broadcastedValue, setBroadcastedValue] = useState(null);
|
|
10293
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
10294
|
-
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
10295
|
-
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
10296
|
-
const listSortedByPhone = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'phone'));
|
|
10297
10280
|
const getSelectOptions = () => {
|
|
10298
|
-
const
|
|
10299
|
-
|
|
10281
|
+
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
10282
|
+
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
10283
|
+
return listSortedByISO3.map(option => {
|
|
10300
10284
|
const {
|
|
10301
10285
|
phone,
|
|
10302
10286
|
iso3,
|
|
10303
|
-
iso2
|
|
10287
|
+
iso2,
|
|
10288
|
+
name
|
|
10304
10289
|
} = option;
|
|
10305
10290
|
let note = '';
|
|
10306
10291
|
if (iso3) {
|
|
@@ -10309,9 +10294,13 @@ const PhoneNumberInput = props => {
|
|
|
10309
10294
|
note = isArray(iso2) ? iso2.join(', ') : iso2;
|
|
10310
10295
|
}
|
|
10311
10296
|
return {
|
|
10312
|
-
|
|
10313
|
-
|
|
10314
|
-
|
|
10297
|
+
type: 'option',
|
|
10298
|
+
value: {
|
|
10299
|
+
value: phone,
|
|
10300
|
+
label: phone,
|
|
10301
|
+
note: note
|
|
10302
|
+
},
|
|
10303
|
+
filterMatchers: [phone, note, name]
|
|
10315
10304
|
};
|
|
10316
10305
|
});
|
|
10317
10306
|
};
|
|
@@ -10319,7 +10308,6 @@ const PhoneNumberInput = props => {
|
|
|
10319
10308
|
const onPrefixChange = ({
|
|
10320
10309
|
value
|
|
10321
10310
|
}) => {
|
|
10322
|
-
setSearchQuery('');
|
|
10323
10311
|
setInternalValue({
|
|
10324
10312
|
prefix: value,
|
|
10325
10313
|
suffix: internalValue.suffix
|
|
@@ -10347,7 +10335,7 @@ const PhoneNumberInput = props => {
|
|
|
10347
10335
|
} = explodeNumberModel(pastedValue);
|
|
10348
10336
|
const selectedPrefix = options.find(({
|
|
10349
10337
|
value
|
|
10350
|
-
}) => value === pastedPrefix);
|
|
10338
|
+
}) => value.value === pastedPrefix);
|
|
10351
10339
|
if (selectedPrefix && ALLOWED_PHONE_CHARS.test(pastedSuffix)) {
|
|
10352
10340
|
setInternalValue({
|
|
10353
10341
|
prefix: pastedPrefix,
|
|
@@ -10372,22 +10360,19 @@ const PhoneNumberInput = props => {
|
|
|
10372
10360
|
className: "tw-telephone",
|
|
10373
10361
|
children: [/*#__PURE__*/jsx("div", {
|
|
10374
10362
|
className: "tw-telephone__country-select",
|
|
10375
|
-
children: /*#__PURE__*/jsx(
|
|
10376
|
-
id: id ? `${id}-select` : undefined,
|
|
10377
|
-
options: options,
|
|
10378
|
-
selected: {
|
|
10379
|
-
value: internalValue.prefix,
|
|
10380
|
-
label: internalValue.prefix
|
|
10381
|
-
},
|
|
10363
|
+
children: /*#__PURE__*/jsx(SelectInput, {
|
|
10382
10364
|
placeholder: "Select an option...",
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10365
|
+
items: options,
|
|
10366
|
+
value: options.find(item => item.value.value === internalValue.prefix)?.value,
|
|
10367
|
+
renderValue: (option, withinTrigger) => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
10368
|
+
title: option.label,
|
|
10369
|
+
note: withinTrigger ? undefined : option.note
|
|
10370
|
+
}),
|
|
10371
|
+
filterable: true,
|
|
10372
|
+
filterPlaceholder: searchPlaceholder,
|
|
10387
10373
|
disabled: disabled,
|
|
10388
10374
|
size: size,
|
|
10389
10375
|
onChange: onPrefixChange,
|
|
10390
|
-
onSearchChange: newSearch => setSearchQuery(newSearch),
|
|
10391
10376
|
...selectProps
|
|
10392
10377
|
})
|
|
10393
10378
|
}), /*#__PURE__*/jsx("div", {
|