@transferwise/components 0.0.0-experimental-a4458ac → 0.0.0-experimental-3683cd4
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 +105 -153
- package/build/index.esm.js.map +1 -1
- package/build/index.js +105 -153
- 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 +2 -1
- package/build/types/flowNavigation/animatedLabel/AnimatedLabel.d.ts.map +1 -1
- package/build/types/flowNavigation/backButton/BackButton.d.ts +11 -10
- package/build/types/flowNavigation/backButton/BackButton.d.ts.map +1 -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 +3 -9
- package/src/common/flowHeader/__snapshots__/FlowHeader.spec.js.snap +2 -2
- package/src/flowNavigation/FlowNavigation.css +1 -1
- package/src/flowNavigation/FlowNavigation.less +9 -0
- package/src/flowNavigation/FlowNavigation.spec.js +3 -3
- package/src/flowNavigation/FlowNavigation.story.js +183 -24
- package/src/flowNavigation/FlowNavigation.tsx +13 -9
- package/src/flowNavigation/__snapshots__/FlowNavigation.spec.js.snap +11 -14
- package/src/flowNavigation/animatedLabel/AnimatedLabel.css +1 -1
- package/src/flowNavigation/animatedLabel/AnimatedLabel.less +6 -0
- package/src/flowNavigation/animatedLabel/AnimatedLabel.spec.js +21 -7
- package/src/flowNavigation/animatedLabel/AnimatedLabel.story.js +22 -0
- package/src/flowNavigation/animatedLabel/AnimatedLabel.tsx +17 -8
- package/src/flowNavigation/animatedLabel/__snapshots__/AnimatedLabel.spec.js.snap +4 -4
- package/src/flowNavigation/backButton/BackButton.js +9 -14
- package/src/flowNavigation/backButton/BackButton.spec.js +2 -3
- package/src/flowNavigation/backButton/__snapshots__/BackButton.spec.js.snap +21 -28
- package/src/inputs/SelectInput.css +1 -1
- package/src/inputs/SelectInput.less +1 -13
- package/src/inputs/SelectInput.tsx +61 -80
- package/src/main.css +1 -1
- package/src/overlayHeader/OverlayHeader.css +1 -1
- package/src/overlayHeader/OverlayHeader.js +2 -4
- package/src/overlayHeader/OverlayHeader.less +8 -0
- package/src/overlayHeader/OverlayHeader.spec.js +1 -1
- package/src/overlayHeader/__snapshots__/OverlayHeader.spec.js.snap +3 -3
- 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/build/index.esm.js
CHANGED
|
@@ -5398,7 +5398,7 @@ const FlowHeader = /*#__PURE__*/React.forwardRef(({
|
|
|
5398
5398
|
ref: reference,
|
|
5399
5399
|
className: classNames('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', className),
|
|
5400
5400
|
children: [/*#__PURE__*/jsx("div", {
|
|
5401
|
-
className: classNames('np-flow-header__left',
|
|
5401
|
+
className: classNames('np-flow-header__left', {
|
|
5402
5402
|
'flex__item--8': isVertical
|
|
5403
5403
|
}),
|
|
5404
5404
|
children: leftContent
|
|
@@ -5711,16 +5711,19 @@ var messages$5 = defineMessages({
|
|
|
5711
5711
|
const AnimatedLabel = ({
|
|
5712
5712
|
activeLabel,
|
|
5713
5713
|
className,
|
|
5714
|
-
labels
|
|
5714
|
+
labels,
|
|
5715
|
+
'aria-label': ariaLabel
|
|
5715
5716
|
}) => {
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5717
|
+
const numberLabels = labels.length - 1;
|
|
5718
|
+
return /*#__PURE__*/jsx("div", {
|
|
5719
|
+
"aria-label": ariaLabel,
|
|
5720
|
+
className: classNames('np-animated-label', 'np-text-body-large-bold', className),
|
|
5719
5721
|
children: labels.map((label, index) => {
|
|
5720
5722
|
const nextLabel = index - 1;
|
|
5721
5723
|
return /*#__PURE__*/jsx("div", {
|
|
5722
|
-
className: classNames('text-xs-
|
|
5723
|
-
'np-animated-label--in
|
|
5724
|
+
className: classNames('text-xs-left', {
|
|
5725
|
+
'np-animated-label--in': index === activeLabel,
|
|
5726
|
+
'np-animated-label--out': nextLabel === activeLabel && nextLabel !== numberLabels
|
|
5724
5727
|
}),
|
|
5725
5728
|
children: label
|
|
5726
5729
|
}, nextLabel);
|
|
@@ -5729,24 +5732,18 @@ const AnimatedLabel = ({
|
|
|
5729
5732
|
};
|
|
5730
5733
|
|
|
5731
5734
|
const BackButton = ({
|
|
5735
|
+
label,
|
|
5732
5736
|
className,
|
|
5733
|
-
onClick
|
|
5734
|
-
|
|
5735
|
-
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
children: /*#__PURE__*/jsx(
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
className: classNames('np-back-button', 'btn-unstyled', className),
|
|
5742
|
-
onClick: onClick,
|
|
5743
|
-
children: /*#__PURE__*/jsx(ArrowLeft, {
|
|
5744
|
-
size: 24
|
|
5745
|
-
})
|
|
5746
|
-
})
|
|
5737
|
+
onClick
|
|
5738
|
+
}) => /*#__PURE__*/jsxs("button", {
|
|
5739
|
+
type: "button",
|
|
5740
|
+
className: classNames('np-back-button', 'align-items-center', 'btn-unstyled', className),
|
|
5741
|
+
onClick: onClick,
|
|
5742
|
+
children: [/*#__PURE__*/jsx(ArrowLeft, {
|
|
5743
|
+
size: 24
|
|
5744
|
+
}), label]
|
|
5747
5745
|
});
|
|
5748
5746
|
BackButton.propTypes = {
|
|
5749
|
-
'aria-label': PropTypes.string.isRequired,
|
|
5750
5747
|
className: PropTypes.string,
|
|
5751
5748
|
label: PropTypes.element,
|
|
5752
5749
|
onClick: PropTypes.func
|
|
@@ -5779,17 +5776,16 @@ const FlowNavigation = ({
|
|
|
5779
5776
|
const newAvatar = done ? null : avatar;
|
|
5780
5777
|
const getLeftContentSmall = () => {
|
|
5781
5778
|
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
5782
|
-
return /*#__PURE__*/
|
|
5783
|
-
children:
|
|
5784
|
-
|
|
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
|
+
}),
|
|
5785
5787
|
onClick: onGoBack
|
|
5786
|
-
}) : logo
|
|
5787
|
-
className: "m-x-1",
|
|
5788
|
-
labels: steps.map(step => step.label),
|
|
5789
|
-
activeLabel: activeStep
|
|
5790
|
-
}), /*#__PURE__*/jsx("span", {
|
|
5791
|
-
className: "m-x-1"
|
|
5792
|
-
})]
|
|
5788
|
+
}) : logo
|
|
5793
5789
|
});
|
|
5794
5790
|
};
|
|
5795
5791
|
return /*#__PURE__*/jsx("div", {
|
|
@@ -5798,7 +5794,7 @@ const FlowNavigation = ({
|
|
|
5798
5794
|
'np-flow-navigation--border-bottom': !done
|
|
5799
5795
|
}),
|
|
5800
5796
|
children: /*#__PURE__*/jsx(FlowHeader, {
|
|
5801
|
-
className: classNames('np-flow-navigation__content
|
|
5797
|
+
className: classNames('np-flow-navigation__content p-x-3', {
|
|
5802
5798
|
'np-flow-navigation--hidden': !clientWidth,
|
|
5803
5799
|
'np-flow-navigation--xs-max': isSmall,
|
|
5804
5800
|
// Size switches on parent container which may or may not have the same size as the window.
|
|
@@ -5808,7 +5804,7 @@ const FlowNavigation = ({
|
|
|
5808
5804
|
leftContent: isSmall ? getLeftContentSmall() : logo,
|
|
5809
5805
|
rightContent: /*#__PURE__*/jsxs(Fragment, {
|
|
5810
5806
|
children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsx("span", {
|
|
5811
|
-
className: "
|
|
5807
|
+
className: "separator"
|
|
5812
5808
|
}), closeButton]
|
|
5813
5809
|
}),
|
|
5814
5810
|
bottomContent: !done && /*#__PURE__*/jsx(Stepper, {
|
|
@@ -6641,13 +6637,6 @@ function inferSearchableStrings(value) {
|
|
|
6641
6637
|
}
|
|
6642
6638
|
return [];
|
|
6643
6639
|
}
|
|
6644
|
-
const SelectInputItemCheckPaddingContext = /*#__PURE__*/createContext(false);
|
|
6645
|
-
function useSelectInputItemCheckPadding() {
|
|
6646
|
-
const checkPadding = useContext(SelectInputItemCheckPaddingContext);
|
|
6647
|
-
// Avoid layout shifts during transitions via caching
|
|
6648
|
-
const [initialCheckPadding] = useState(checkPadding);
|
|
6649
|
-
return initialCheckPadding;
|
|
6650
|
-
}
|
|
6651
6640
|
const SelectInputTriggerButtonPropsContext = /*#__PURE__*/createContext({});
|
|
6652
6641
|
const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/createContext(false);
|
|
6653
6642
|
function dedupeSelectInputOptionItem(item, existingValues) {
|
|
@@ -6792,54 +6781,51 @@ function SelectInput({
|
|
|
6792
6781
|
children: ({
|
|
6793
6782
|
disabled: uiDisabled,
|
|
6794
6783
|
value
|
|
6795
|
-
}) => /*#__PURE__*/jsx(
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
}
|
|
6811
|
-
}, getInteractionProps())
|
|
6812
|
-
},
|
|
6813
|
-
children: renderTrigger({
|
|
6814
|
-
content: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6815
|
-
value: true,
|
|
6816
|
-
children: renderValue(value, true)
|
|
6817
|
-
}) : placeholder,
|
|
6818
|
-
placeholderShown: value == null,
|
|
6819
|
-
clear: onClear != null ? () => {
|
|
6820
|
-
onClear();
|
|
6821
|
-
triggerRef.current?.focus({
|
|
6822
|
-
preventScroll: true
|
|
6823
|
-
});
|
|
6824
|
-
} : undefined,
|
|
6825
|
-
disabled: uiDisabled,
|
|
6826
|
-
size,
|
|
6827
|
-
className
|
|
6828
|
-
})
|
|
6829
|
-
}),
|
|
6830
|
-
initialFocusRef: controllerRef,
|
|
6831
|
-
padding: "none",
|
|
6832
|
-
onClose: () => {
|
|
6833
|
-
setOpen(false);
|
|
6784
|
+
}) => /*#__PURE__*/jsx(OptionsOverlay, {
|
|
6785
|
+
placement: "bottom-start",
|
|
6786
|
+
open: open,
|
|
6787
|
+
renderTrigger: ({
|
|
6788
|
+
ref,
|
|
6789
|
+
getInteractionProps
|
|
6790
|
+
}) => /*#__PURE__*/jsx(SelectInputTriggerButtonPropsContext.Provider, {
|
|
6791
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
6792
|
+
value: {
|
|
6793
|
+
ref: mergeRefs([ref, triggerRef]),
|
|
6794
|
+
...mergeProps({
|
|
6795
|
+
onClick: () => {
|
|
6796
|
+
setOpen(prev => !prev);
|
|
6797
|
+
}
|
|
6798
|
+
}, getInteractionProps())
|
|
6834
6799
|
},
|
|
6835
|
-
children:
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6800
|
+
children: renderTrigger({
|
|
6801
|
+
content: value != null ? /*#__PURE__*/jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6802
|
+
value: true,
|
|
6803
|
+
children: renderValue(value, true)
|
|
6804
|
+
}) : placeholder,
|
|
6805
|
+
placeholderShown: value == null,
|
|
6806
|
+
clear: onClear != null ? () => {
|
|
6807
|
+
onClear();
|
|
6808
|
+
triggerRef.current?.focus({
|
|
6809
|
+
preventScroll: true
|
|
6810
|
+
});
|
|
6811
|
+
} : undefined,
|
|
6812
|
+
disabled: uiDisabled,
|
|
6813
|
+
size,
|
|
6814
|
+
className
|
|
6842
6815
|
})
|
|
6816
|
+
}),
|
|
6817
|
+
initialFocusRef: controllerRef,
|
|
6818
|
+
padding: "none",
|
|
6819
|
+
onClose: () => {
|
|
6820
|
+
setOpen(false);
|
|
6821
|
+
},
|
|
6822
|
+
children: /*#__PURE__*/jsx(SelectInputOptions, {
|
|
6823
|
+
items: items,
|
|
6824
|
+
renderValue: renderValue,
|
|
6825
|
+
filterable: filterable,
|
|
6826
|
+
filterPlaceholder: filterPlaceholder,
|
|
6827
|
+
searchInputRef: searchInputRef,
|
|
6828
|
+
listboxRef: listboxRef
|
|
6843
6829
|
})
|
|
6844
6830
|
})
|
|
6845
6831
|
});
|
|
@@ -7029,7 +7015,6 @@ function SelectInputGroupItemView({
|
|
|
7029
7015
|
needle
|
|
7030
7016
|
}) {
|
|
7031
7017
|
const headerId = useId();
|
|
7032
|
-
const checkPadding = useSelectInputItemCheckPadding();
|
|
7033
7018
|
return (
|
|
7034
7019
|
/*#__PURE__*/
|
|
7035
7020
|
// An empty container may be rendered when no options match `needle`
|
|
@@ -7038,13 +7023,11 @@ function SelectInputGroupItemView({
|
|
|
7038
7023
|
role: "group",
|
|
7039
7024
|
"aria-labelledby": headerId,
|
|
7040
7025
|
className: classNames(needle === null && 'np-select-input-group-item--without-needle'),
|
|
7041
|
-
children: [needle == null ? /*#__PURE__*/
|
|
7026
|
+
children: [needle == null ? /*#__PURE__*/jsx("header", {
|
|
7042
7027
|
id: headerId,
|
|
7043
7028
|
role: "presentation",
|
|
7044
7029
|
className: "np-select-input-group-item-header np-text-title-group",
|
|
7045
|
-
children:
|
|
7046
|
-
className: "np-select-input-option-check-placeholder"
|
|
7047
|
-
}) : null, item.label]
|
|
7030
|
+
children: item.label
|
|
7048
7031
|
}) : null, item.options.map((option, index) => /*#__PURE__*/jsx(SelectInputItemView
|
|
7049
7032
|
// eslint-disable-next-line react/no-array-index-key
|
|
7050
7033
|
, {
|
|
@@ -7060,7 +7043,6 @@ function SelectInputOption({
|
|
|
7060
7043
|
disabled,
|
|
7061
7044
|
children
|
|
7062
7045
|
}) {
|
|
7063
|
-
const checkPadding = useSelectInputItemCheckPadding();
|
|
7064
7046
|
return /*#__PURE__*/jsx(Listbox.Option, {
|
|
7065
7047
|
as: "div",
|
|
7066
7048
|
value: value,
|
|
@@ -7072,12 +7054,12 @@ function SelectInputOption({
|
|
|
7072
7054
|
children: ({
|
|
7073
7055
|
selected
|
|
7074
7056
|
}) => /*#__PURE__*/jsxs(Fragment, {
|
|
7075
|
-
children: [
|
|
7076
|
-
size: 16,
|
|
7077
|
-
className: classNames('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
|
|
7078
|
-
}) : null, /*#__PURE__*/jsx("div", {
|
|
7057
|
+
children: [/*#__PURE__*/jsx("div", {
|
|
7079
7058
|
className: "np-select-input-option",
|
|
7080
7059
|
children: children
|
|
7060
|
+
}), /*#__PURE__*/jsx(Check, {
|
|
7061
|
+
size: 16,
|
|
7062
|
+
className: classNames('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
|
|
7081
7063
|
})]
|
|
7082
7064
|
})
|
|
7083
7065
|
});
|
|
@@ -8494,7 +8476,7 @@ class MoneyInput extends Component {
|
|
|
8494
8476
|
this.amountFocused = true;
|
|
8495
8477
|
};
|
|
8496
8478
|
getSelectOptions() {
|
|
8497
|
-
const selectOptions = [...filterOptionsForQuery
|
|
8479
|
+
const selectOptions = [...filterOptionsForQuery(this.props.currencies, this.state.searchQuery)];
|
|
8498
8480
|
if (this.props.onCustomAction) {
|
|
8499
8481
|
selectOptions.push({
|
|
8500
8482
|
value: CUSTOM_ACTION,
|
|
@@ -8531,7 +8513,7 @@ class MoneyInput extends Component {
|
|
|
8531
8513
|
if (this.props.onSearchChange) {
|
|
8532
8514
|
this.props.onSearchChange({
|
|
8533
8515
|
searchQuery,
|
|
8534
|
-
filteredOptions: filterOptionsForQuery
|
|
8516
|
+
filteredOptions: filterOptionsForQuery(this.props.currencies, searchQuery)
|
|
8535
8517
|
});
|
|
8536
8518
|
}
|
|
8537
8519
|
};
|
|
@@ -8612,7 +8594,7 @@ class MoneyInput extends Component {
|
|
|
8612
8594
|
});
|
|
8613
8595
|
}
|
|
8614
8596
|
}
|
|
8615
|
-
function filterOptionsForQuery
|
|
8597
|
+
function filterOptionsForQuery(options, query) {
|
|
8616
8598
|
if (!query) {
|
|
8617
8599
|
return options;
|
|
8618
8600
|
}
|
|
@@ -8821,7 +8803,6 @@ const OverlayHeader = ({
|
|
|
8821
8803
|
logo
|
|
8822
8804
|
}) => {
|
|
8823
8805
|
const closeButton = onClose && /*#__PURE__*/jsx(CloseButton, {
|
|
8824
|
-
size: Size.LARGE,
|
|
8825
8806
|
onClick: onClose
|
|
8826
8807
|
});
|
|
8827
8808
|
return /*#__PURE__*/jsx("div", {
|
|
@@ -8831,7 +8812,7 @@ const OverlayHeader = ({
|
|
|
8831
8812
|
leftContent: logo,
|
|
8832
8813
|
rightContent: /*#__PURE__*/jsxs(Fragment, {
|
|
8833
8814
|
children: [avatar, avatar && closeButton && /*#__PURE__*/jsx("span", {
|
|
8834
|
-
className:
|
|
8815
|
+
className: "separator"
|
|
8835
8816
|
}), closeButton]
|
|
8836
8817
|
})
|
|
8837
8818
|
})
|
|
@@ -10201,36 +10182,9 @@ const explodeNumberModel = number => {
|
|
|
10201
10182
|
};
|
|
10202
10183
|
};
|
|
10203
10184
|
|
|
10204
|
-
/**
|
|
10205
|
-
* Checks if query is contained into object properties.
|
|
10206
|
-
*
|
|
10207
|
-
* @param {object} option - the select option
|
|
10208
|
-
* @param {string} query - the current search query
|
|
10209
|
-
* @returns {boolean}
|
|
10210
|
-
*/
|
|
10211
|
-
const isOptionAndFitsQuery = (option, query) => startsWith(option.iso3, query) || startsWith(option.iso2, query) || startsWith(option.name, query) || startsWith(option.phone, query);
|
|
10212
|
-
const startsWith = (property, query) => {
|
|
10213
|
-
if (isArray(property)) {
|
|
10214
|
-
return property.filter(proper => normalizeValue(proper).indexOf(normalizeValue(query)) === 0).length > 0;
|
|
10215
|
-
}
|
|
10216
|
-
return normalizeValue(property).indexOf(normalizeValue(query)) === 0;
|
|
10217
|
-
};
|
|
10218
|
-
const normalizeValue = value => value.toLowerCase().replace('+', '');
|
|
10219
|
-
|
|
10220
|
-
/**
|
|
10221
|
-
* Filters a set of options based on search string
|
|
10222
|
-
*
|
|
10223
|
-
* @param options
|
|
10224
|
-
* @param query
|
|
10225
|
-
* @returns {*}
|
|
10226
|
-
*/
|
|
10227
|
-
const filterOptionsForQuery = (options, query) => options.filter(option => isOptionAndFitsQuery(option, query));
|
|
10228
|
-
|
|
10229
10185
|
const DIGITS_MATCH = /^$|^(\+)|([\d]+)/g;
|
|
10230
10186
|
const cleanNumber = number => number.match(DIGITS_MATCH) && number.match(DIGITS_MATCH).join('') || '';
|
|
10231
10187
|
|
|
10232
|
-
const isStringNumeric = value => /^\+?[\d-\s]+$/.test(value);
|
|
10233
|
-
|
|
10234
10188
|
// Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
|
|
10235
10189
|
const sortArrayByProperty = (arrayToSort, property) => [...arrayToSort].sort((a, b) => a[property].localeCompare(b[property]));
|
|
10236
10190
|
|
|
@@ -10309,17 +10263,15 @@ const PhoneNumberInput = props => {
|
|
|
10309
10263
|
};
|
|
10310
10264
|
const [internalValue, setInternalValue] = useState(getInitialValue());
|
|
10311
10265
|
const [broadcastedValue, setBroadcastedValue] = useState(null);
|
|
10312
|
-
const [searchQuery, setSearchQuery] = useState('');
|
|
10313
|
-
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
10314
|
-
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
10315
|
-
const listSortedByPhone = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'phone'));
|
|
10316
10266
|
const getSelectOptions = () => {
|
|
10317
|
-
const
|
|
10318
|
-
|
|
10267
|
+
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
10268
|
+
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
10269
|
+
return listSortedByISO3.map(option => {
|
|
10319
10270
|
const {
|
|
10320
10271
|
phone,
|
|
10321
10272
|
iso3,
|
|
10322
|
-
iso2
|
|
10273
|
+
iso2,
|
|
10274
|
+
name
|
|
10323
10275
|
} = option;
|
|
10324
10276
|
let note = '';
|
|
10325
10277
|
if (iso3) {
|
|
@@ -10328,9 +10280,13 @@ const PhoneNumberInput = props => {
|
|
|
10328
10280
|
note = isArray(iso2) ? iso2.join(', ') : iso2;
|
|
10329
10281
|
}
|
|
10330
10282
|
return {
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10283
|
+
type: 'option',
|
|
10284
|
+
value: {
|
|
10285
|
+
value: phone,
|
|
10286
|
+
label: phone,
|
|
10287
|
+
note: note
|
|
10288
|
+
},
|
|
10289
|
+
filterMatchers: [phone, note, name]
|
|
10334
10290
|
};
|
|
10335
10291
|
});
|
|
10336
10292
|
};
|
|
@@ -10338,7 +10294,6 @@ const PhoneNumberInput = props => {
|
|
|
10338
10294
|
const onPrefixChange = ({
|
|
10339
10295
|
value
|
|
10340
10296
|
}) => {
|
|
10341
|
-
setSearchQuery('');
|
|
10342
10297
|
setInternalValue({
|
|
10343
10298
|
prefix: value,
|
|
10344
10299
|
suffix: internalValue.suffix
|
|
@@ -10366,7 +10321,7 @@ const PhoneNumberInput = props => {
|
|
|
10366
10321
|
} = explodeNumberModel(pastedValue);
|
|
10367
10322
|
const selectedPrefix = options.find(({
|
|
10368
10323
|
value
|
|
10369
|
-
}) => value === pastedPrefix);
|
|
10324
|
+
}) => value.value === pastedPrefix);
|
|
10370
10325
|
if (selectedPrefix && ALLOWED_PHONE_CHARS.test(pastedSuffix)) {
|
|
10371
10326
|
setInternalValue({
|
|
10372
10327
|
prefix: pastedPrefix,
|
|
@@ -10391,22 +10346,19 @@ const PhoneNumberInput = props => {
|
|
|
10391
10346
|
className: "tw-telephone",
|
|
10392
10347
|
children: [/*#__PURE__*/jsx("div", {
|
|
10393
10348
|
className: "tw-telephone__country-select",
|
|
10394
|
-
children: /*#__PURE__*/jsx(
|
|
10395
|
-
id: id ? `${id}-select` : undefined,
|
|
10396
|
-
options: options,
|
|
10397
|
-
selected: {
|
|
10398
|
-
value: internalValue.prefix,
|
|
10399
|
-
label: internalValue.prefix
|
|
10400
|
-
},
|
|
10349
|
+
children: /*#__PURE__*/jsx(SelectInput, {
|
|
10401
10350
|
placeholder: "Select an option...",
|
|
10402
|
-
|
|
10403
|
-
|
|
10404
|
-
|
|
10405
|
-
|
|
10351
|
+
items: options,
|
|
10352
|
+
value: options.find(item => item.value.value === internalValue.prefix)?.value,
|
|
10353
|
+
renderValue: (option, withinTrigger) => /*#__PURE__*/jsx(SelectInputOptionContent, {
|
|
10354
|
+
title: option.label,
|
|
10355
|
+
note: withinTrigger ? undefined : option.note
|
|
10356
|
+
}),
|
|
10357
|
+
filterable: true,
|
|
10358
|
+
filterPlaceholder: searchPlaceholder,
|
|
10406
10359
|
disabled: disabled,
|
|
10407
10360
|
size: size,
|
|
10408
10361
|
onChange: onPrefixChange,
|
|
10409
|
-
onSearchChange: newSearch => setSearchQuery(newSearch),
|
|
10410
10362
|
...selectProps
|
|
10411
10363
|
})
|
|
10412
10364
|
}), /*#__PURE__*/jsx("div", {
|