@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.js
CHANGED
|
@@ -5432,7 +5432,7 @@ const FlowHeader = /*#__PURE__*/React__namespace.forwardRef(({
|
|
|
5432
5432
|
ref: reference,
|
|
5433
5433
|
className: classNames__default.default('np-flow-header', 'd-flex', 'flex-wrap', 'align-items-center', className),
|
|
5434
5434
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5435
|
-
className: classNames__default.default('np-flow-header__left',
|
|
5435
|
+
className: classNames__default.default('np-flow-header__left', {
|
|
5436
5436
|
'flex__item--8': isVertical
|
|
5437
5437
|
}),
|
|
5438
5438
|
children: leftContent
|
|
@@ -5745,16 +5745,19 @@ var messages$5 = reactIntl.defineMessages({
|
|
|
5745
5745
|
const AnimatedLabel = ({
|
|
5746
5746
|
activeLabel,
|
|
5747
5747
|
className,
|
|
5748
|
-
labels
|
|
5748
|
+
labels,
|
|
5749
|
+
'aria-label': ariaLabel
|
|
5749
5750
|
}) => {
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5751
|
+
const numberLabels = labels.length - 1;
|
|
5752
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5753
|
+
"aria-label": ariaLabel,
|
|
5754
|
+
className: classNames__default.default('np-animated-label', 'np-text-body-large-bold', className),
|
|
5753
5755
|
children: labels.map((label, index) => {
|
|
5754
5756
|
const nextLabel = index - 1;
|
|
5755
5757
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
5756
|
-
className: classNames__default.default('text-xs-
|
|
5757
|
-
'np-animated-label--in
|
|
5758
|
+
className: classNames__default.default('text-xs-left', {
|
|
5759
|
+
'np-animated-label--in': index === activeLabel,
|
|
5760
|
+
'np-animated-label--out': nextLabel === activeLabel && nextLabel !== numberLabels
|
|
5758
5761
|
}),
|
|
5759
5762
|
children: label
|
|
5760
5763
|
}, nextLabel);
|
|
@@ -5763,24 +5766,18 @@ const AnimatedLabel = ({
|
|
|
5763
5766
|
};
|
|
5764
5767
|
|
|
5765
5768
|
const BackButton = ({
|
|
5769
|
+
label,
|
|
5766
5770
|
className,
|
|
5767
|
-
onClick
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
className: classNames__default.default('np-back-button', 'btn-unstyled', className),
|
|
5776
|
-
onClick: onClick,
|
|
5777
|
-
children: /*#__PURE__*/jsxRuntime.jsx(icons.ArrowLeft, {
|
|
5778
|
-
size: 24
|
|
5779
|
-
})
|
|
5780
|
-
})
|
|
5771
|
+
onClick
|
|
5772
|
+
}) => /*#__PURE__*/jsxRuntime.jsxs("button", {
|
|
5773
|
+
type: "button",
|
|
5774
|
+
className: classNames__default.default('np-back-button', 'align-items-center', 'btn-unstyled', className),
|
|
5775
|
+
onClick: onClick,
|
|
5776
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(icons.ArrowLeft, {
|
|
5777
|
+
size: 24
|
|
5778
|
+
}), label]
|
|
5781
5779
|
});
|
|
5782
5780
|
BackButton.propTypes = {
|
|
5783
|
-
'aria-label': PropTypes__default.default.string.isRequired,
|
|
5784
5781
|
className: PropTypes__default.default.string,
|
|
5785
5782
|
label: PropTypes__default.default.element,
|
|
5786
5783
|
onClick: PropTypes__default.default.func
|
|
@@ -5813,17 +5810,16 @@ const FlowNavigation = ({
|
|
|
5813
5810
|
const newAvatar = done ? null : avatar;
|
|
5814
5811
|
const getLeftContentSmall = () => {
|
|
5815
5812
|
const displayGoBack = onGoBack != null && activeStep > 0;
|
|
5816
|
-
return /*#__PURE__*/jsxRuntime.
|
|
5817
|
-
children:
|
|
5818
|
-
|
|
5813
|
+
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
5814
|
+
children: displayGoBack ? /*#__PURE__*/jsxRuntime.jsx(BackButton$1, {
|
|
5815
|
+
label: /*#__PURE__*/jsxRuntime.jsx(AnimatedLabel, {
|
|
5816
|
+
className: "m-x-1",
|
|
5817
|
+
labels: steps.map(step => step.label),
|
|
5818
|
+
activeLabel: activeStep - 1,
|
|
5819
|
+
"aria-label": intl.formatMessage(messages$5.back)
|
|
5820
|
+
}),
|
|
5819
5821
|
onClick: onGoBack
|
|
5820
|
-
}) : logo
|
|
5821
|
-
className: "m-x-1",
|
|
5822
|
-
labels: steps.map(step => step.label),
|
|
5823
|
-
activeLabel: activeStep
|
|
5824
|
-
}), /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5825
|
-
className: "m-x-1"
|
|
5826
|
-
})]
|
|
5822
|
+
}) : logo
|
|
5827
5823
|
});
|
|
5828
5824
|
};
|
|
5829
5825
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -5832,7 +5828,7 @@ const FlowNavigation = ({
|
|
|
5832
5828
|
'np-flow-navigation--border-bottom': !done
|
|
5833
5829
|
}),
|
|
5834
5830
|
children: /*#__PURE__*/jsxRuntime.jsx(FlowHeader, {
|
|
5835
|
-
className: classNames__default.default('np-flow-navigation__content
|
|
5831
|
+
className: classNames__default.default('np-flow-navigation__content p-x-3', {
|
|
5836
5832
|
'np-flow-navigation--hidden': !clientWidth,
|
|
5837
5833
|
'np-flow-navigation--xs-max': isSmall,
|
|
5838
5834
|
// Size switches on parent container which may or may not have the same size as the window.
|
|
@@ -5842,7 +5838,7 @@ const FlowNavigation = ({
|
|
|
5842
5838
|
leftContent: isSmall ? getLeftContentSmall() : logo,
|
|
5843
5839
|
rightContent: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
5844
5840
|
children: [newAvatar, newAvatar && closeButton && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
5845
|
-
className: "
|
|
5841
|
+
className: "separator"
|
|
5846
5842
|
}), closeButton]
|
|
5847
5843
|
}),
|
|
5848
5844
|
bottomContent: !done && /*#__PURE__*/jsxRuntime.jsx(Stepper, {
|
|
@@ -6675,13 +6671,6 @@ function inferSearchableStrings(value) {
|
|
|
6675
6671
|
}
|
|
6676
6672
|
return [];
|
|
6677
6673
|
}
|
|
6678
|
-
const SelectInputItemCheckPaddingContext = /*#__PURE__*/React.createContext(false);
|
|
6679
|
-
function useSelectInputItemCheckPadding() {
|
|
6680
|
-
const checkPadding = React.useContext(SelectInputItemCheckPaddingContext);
|
|
6681
|
-
// Avoid layout shifts during transitions via caching
|
|
6682
|
-
const [initialCheckPadding] = React.useState(checkPadding);
|
|
6683
|
-
return initialCheckPadding;
|
|
6684
|
-
}
|
|
6685
6674
|
const SelectInputTriggerButtonPropsContext = /*#__PURE__*/React.createContext({});
|
|
6686
6675
|
const SelectInputOptionContentWithinTriggerContext = /*#__PURE__*/React.createContext(false);
|
|
6687
6676
|
function dedupeSelectInputOptionItem(item, existingValues) {
|
|
@@ -6826,54 +6815,51 @@ function SelectInput({
|
|
|
6826
6815
|
children: ({
|
|
6827
6816
|
disabled: uiDisabled,
|
|
6828
6817
|
value
|
|
6829
|
-
}) => /*#__PURE__*/jsxRuntime.jsx(
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
}
|
|
6845
|
-
}, getInteractionProps())
|
|
6846
|
-
},
|
|
6847
|
-
children: renderTrigger({
|
|
6848
|
-
content: value != null ? /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6849
|
-
value: true,
|
|
6850
|
-
children: renderValue(value, true)
|
|
6851
|
-
}) : placeholder,
|
|
6852
|
-
placeholderShown: value == null,
|
|
6853
|
-
clear: onClear != null ? () => {
|
|
6854
|
-
onClear();
|
|
6855
|
-
triggerRef.current?.focus({
|
|
6856
|
-
preventScroll: true
|
|
6857
|
-
});
|
|
6858
|
-
} : undefined,
|
|
6859
|
-
disabled: uiDisabled,
|
|
6860
|
-
size,
|
|
6861
|
-
className
|
|
6862
|
-
})
|
|
6863
|
-
}),
|
|
6864
|
-
initialFocusRef: controllerRef,
|
|
6865
|
-
padding: "none",
|
|
6866
|
-
onClose: () => {
|
|
6867
|
-
setOpen(false);
|
|
6818
|
+
}) => /*#__PURE__*/jsxRuntime.jsx(OptionsOverlay, {
|
|
6819
|
+
placement: "bottom-start",
|
|
6820
|
+
open: open,
|
|
6821
|
+
renderTrigger: ({
|
|
6822
|
+
ref,
|
|
6823
|
+
getInteractionProps
|
|
6824
|
+
}) => /*#__PURE__*/jsxRuntime.jsx(SelectInputTriggerButtonPropsContext.Provider, {
|
|
6825
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
6826
|
+
value: {
|
|
6827
|
+
ref: mergeRefs__default.default([ref, triggerRef]),
|
|
6828
|
+
...mergeProps__default.default({
|
|
6829
|
+
onClick: () => {
|
|
6830
|
+
setOpen(prev => !prev);
|
|
6831
|
+
}
|
|
6832
|
+
}, getInteractionProps())
|
|
6868
6833
|
},
|
|
6869
|
-
children:
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6834
|
+
children: renderTrigger({
|
|
6835
|
+
content: value != null ? /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContentWithinTriggerContext.Provider, {
|
|
6836
|
+
value: true,
|
|
6837
|
+
children: renderValue(value, true)
|
|
6838
|
+
}) : placeholder,
|
|
6839
|
+
placeholderShown: value == null,
|
|
6840
|
+
clear: onClear != null ? () => {
|
|
6841
|
+
onClear();
|
|
6842
|
+
triggerRef.current?.focus({
|
|
6843
|
+
preventScroll: true
|
|
6844
|
+
});
|
|
6845
|
+
} : undefined,
|
|
6846
|
+
disabled: uiDisabled,
|
|
6847
|
+
size,
|
|
6848
|
+
className
|
|
6876
6849
|
})
|
|
6850
|
+
}),
|
|
6851
|
+
initialFocusRef: controllerRef,
|
|
6852
|
+
padding: "none",
|
|
6853
|
+
onClose: () => {
|
|
6854
|
+
setOpen(false);
|
|
6855
|
+
},
|
|
6856
|
+
children: /*#__PURE__*/jsxRuntime.jsx(SelectInputOptions, {
|
|
6857
|
+
items: items,
|
|
6858
|
+
renderValue: renderValue,
|
|
6859
|
+
filterable: filterable,
|
|
6860
|
+
filterPlaceholder: filterPlaceholder,
|
|
6861
|
+
searchInputRef: searchInputRef,
|
|
6862
|
+
listboxRef: listboxRef
|
|
6877
6863
|
})
|
|
6878
6864
|
})
|
|
6879
6865
|
});
|
|
@@ -7063,7 +7049,6 @@ function SelectInputGroupItemView({
|
|
|
7063
7049
|
needle
|
|
7064
7050
|
}) {
|
|
7065
7051
|
const headerId = reactId.useId();
|
|
7066
|
-
const checkPadding = useSelectInputItemCheckPadding();
|
|
7067
7052
|
return (
|
|
7068
7053
|
/*#__PURE__*/
|
|
7069
7054
|
// An empty container may be rendered when no options match `needle`
|
|
@@ -7072,13 +7057,11 @@ function SelectInputGroupItemView({
|
|
|
7072
7057
|
role: "group",
|
|
7073
7058
|
"aria-labelledby": headerId,
|
|
7074
7059
|
className: classNames__default.default(needle === null && 'np-select-input-group-item--without-needle'),
|
|
7075
|
-
children: [needle == null ? /*#__PURE__*/jsxRuntime.
|
|
7060
|
+
children: [needle == null ? /*#__PURE__*/jsxRuntime.jsx("header", {
|
|
7076
7061
|
id: headerId,
|
|
7077
7062
|
role: "presentation",
|
|
7078
7063
|
className: "np-select-input-group-item-header np-text-title-group",
|
|
7079
|
-
children:
|
|
7080
|
-
className: "np-select-input-option-check-placeholder"
|
|
7081
|
-
}) : null, item.label]
|
|
7064
|
+
children: item.label
|
|
7082
7065
|
}) : null, item.options.map((option, index) => /*#__PURE__*/jsxRuntime.jsx(SelectInputItemView
|
|
7083
7066
|
// eslint-disable-next-line react/no-array-index-key
|
|
7084
7067
|
, {
|
|
@@ -7094,7 +7077,6 @@ function SelectInputOption({
|
|
|
7094
7077
|
disabled,
|
|
7095
7078
|
children
|
|
7096
7079
|
}) {
|
|
7097
|
-
const checkPadding = useSelectInputItemCheckPadding();
|
|
7098
7080
|
return /*#__PURE__*/jsxRuntime.jsx(react$1.Listbox.Option, {
|
|
7099
7081
|
as: "div",
|
|
7100
7082
|
value: value,
|
|
@@ -7106,12 +7088,12 @@ function SelectInputOption({
|
|
|
7106
7088
|
children: ({
|
|
7107
7089
|
selected
|
|
7108
7090
|
}) => /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
7109
|
-
children: [
|
|
7110
|
-
size: 16,
|
|
7111
|
-
className: classNames__default.default('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
|
|
7112
|
-
}) : null, /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
7091
|
+
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
7113
7092
|
className: "np-select-input-option",
|
|
7114
7093
|
children: children
|
|
7094
|
+
}), /*#__PURE__*/jsxRuntime.jsx(icons.Check, {
|
|
7095
|
+
size: 16,
|
|
7096
|
+
className: classNames__default.default('np-select-input-option-check', !selected && 'np-select-input-option-check--not-selected')
|
|
7115
7097
|
})]
|
|
7116
7098
|
})
|
|
7117
7099
|
});
|
|
@@ -8528,7 +8510,7 @@ class MoneyInput extends React.Component {
|
|
|
8528
8510
|
this.amountFocused = true;
|
|
8529
8511
|
};
|
|
8530
8512
|
getSelectOptions() {
|
|
8531
|
-
const selectOptions = [...filterOptionsForQuery
|
|
8513
|
+
const selectOptions = [...filterOptionsForQuery(this.props.currencies, this.state.searchQuery)];
|
|
8532
8514
|
if (this.props.onCustomAction) {
|
|
8533
8515
|
selectOptions.push({
|
|
8534
8516
|
value: CUSTOM_ACTION,
|
|
@@ -8565,7 +8547,7 @@ class MoneyInput extends React.Component {
|
|
|
8565
8547
|
if (this.props.onSearchChange) {
|
|
8566
8548
|
this.props.onSearchChange({
|
|
8567
8549
|
searchQuery,
|
|
8568
|
-
filteredOptions: filterOptionsForQuery
|
|
8550
|
+
filteredOptions: filterOptionsForQuery(this.props.currencies, searchQuery)
|
|
8569
8551
|
});
|
|
8570
8552
|
}
|
|
8571
8553
|
};
|
|
@@ -8646,7 +8628,7 @@ class MoneyInput extends React.Component {
|
|
|
8646
8628
|
});
|
|
8647
8629
|
}
|
|
8648
8630
|
}
|
|
8649
|
-
function filterOptionsForQuery
|
|
8631
|
+
function filterOptionsForQuery(options, query) {
|
|
8650
8632
|
if (!query) {
|
|
8651
8633
|
return options;
|
|
8652
8634
|
}
|
|
@@ -8855,7 +8837,6 @@ const OverlayHeader = ({
|
|
|
8855
8837
|
logo
|
|
8856
8838
|
}) => {
|
|
8857
8839
|
const closeButton = onClose && /*#__PURE__*/jsxRuntime.jsx(CloseButton, {
|
|
8858
|
-
size: exports.Size.LARGE,
|
|
8859
8840
|
onClick: onClose
|
|
8860
8841
|
});
|
|
8861
8842
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
@@ -8865,7 +8846,7 @@ const OverlayHeader = ({
|
|
|
8865
8846
|
leftContent: logo,
|
|
8866
8847
|
rightContent: /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
8867
8848
|
children: [avatar, avatar && closeButton && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
8868
|
-
className:
|
|
8849
|
+
className: "separator"
|
|
8869
8850
|
}), closeButton]
|
|
8870
8851
|
})
|
|
8871
8852
|
})
|
|
@@ -10235,36 +10216,9 @@ const explodeNumberModel = number => {
|
|
|
10235
10216
|
};
|
|
10236
10217
|
};
|
|
10237
10218
|
|
|
10238
|
-
/**
|
|
10239
|
-
* Checks if query is contained into object properties.
|
|
10240
|
-
*
|
|
10241
|
-
* @param {object} option - the select option
|
|
10242
|
-
* @param {string} query - the current search query
|
|
10243
|
-
* @returns {boolean}
|
|
10244
|
-
*/
|
|
10245
|
-
const isOptionAndFitsQuery = (option, query) => startsWith(option.iso3, query) || startsWith(option.iso2, query) || startsWith(option.name, query) || startsWith(option.phone, query);
|
|
10246
|
-
const startsWith = (property, query) => {
|
|
10247
|
-
if (neptuneValidation.isArray(property)) {
|
|
10248
|
-
return property.filter(proper => normalizeValue(proper).indexOf(normalizeValue(query)) === 0).length > 0;
|
|
10249
|
-
}
|
|
10250
|
-
return normalizeValue(property).indexOf(normalizeValue(query)) === 0;
|
|
10251
|
-
};
|
|
10252
|
-
const normalizeValue = value => value.toLowerCase().replace('+', '');
|
|
10253
|
-
|
|
10254
|
-
/**
|
|
10255
|
-
* Filters a set of options based on search string
|
|
10256
|
-
*
|
|
10257
|
-
* @param options
|
|
10258
|
-
* @param query
|
|
10259
|
-
* @returns {*}
|
|
10260
|
-
*/
|
|
10261
|
-
const filterOptionsForQuery = (options, query) => options.filter(option => isOptionAndFitsQuery(option, query));
|
|
10262
|
-
|
|
10263
10219
|
const DIGITS_MATCH = /^$|^(\+)|([\d]+)/g;
|
|
10264
10220
|
const cleanNumber = number => number.match(DIGITS_MATCH) && number.match(DIGITS_MATCH).join('') || '';
|
|
10265
10221
|
|
|
10266
|
-
const isStringNumeric = value => /^\+?[\d-\s]+$/.test(value);
|
|
10267
|
-
|
|
10268
10222
|
// Reference fro localeCompare : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/localeCompare
|
|
10269
10223
|
const sortArrayByProperty = (arrayToSort, property) => [...arrayToSort].sort((a, b) => a[property].localeCompare(b[property]));
|
|
10270
10224
|
|
|
@@ -10343,17 +10297,15 @@ const PhoneNumberInput = props => {
|
|
|
10343
10297
|
};
|
|
10344
10298
|
const [internalValue, setInternalValue] = React.useState(getInitialValue());
|
|
10345
10299
|
const [broadcastedValue, setBroadcastedValue] = React.useState(null);
|
|
10346
|
-
const [searchQuery, setSearchQuery] = React.useState('');
|
|
10347
|
-
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
10348
|
-
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
10349
|
-
const listSortedByPhone = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'phone'));
|
|
10350
10300
|
const getSelectOptions = () => {
|
|
10351
|
-
const
|
|
10352
|
-
|
|
10301
|
+
const countriesList = excludeCountries(countries$1, disabledCountries);
|
|
10302
|
+
const listSortedByISO3 = groupCountriesByPrefix(sortArrayByProperty(countriesList, 'iso3'));
|
|
10303
|
+
return listSortedByISO3.map(option => {
|
|
10353
10304
|
const {
|
|
10354
10305
|
phone,
|
|
10355
10306
|
iso3,
|
|
10356
|
-
iso2
|
|
10307
|
+
iso2,
|
|
10308
|
+
name
|
|
10357
10309
|
} = option;
|
|
10358
10310
|
let note = '';
|
|
10359
10311
|
if (iso3) {
|
|
@@ -10362,9 +10314,13 @@ const PhoneNumberInput = props => {
|
|
|
10362
10314
|
note = neptuneValidation.isArray(iso2) ? iso2.join(', ') : iso2;
|
|
10363
10315
|
}
|
|
10364
10316
|
return {
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10317
|
+
type: 'option',
|
|
10318
|
+
value: {
|
|
10319
|
+
value: phone,
|
|
10320
|
+
label: phone,
|
|
10321
|
+
note: note
|
|
10322
|
+
},
|
|
10323
|
+
filterMatchers: [phone, note, name]
|
|
10368
10324
|
};
|
|
10369
10325
|
});
|
|
10370
10326
|
};
|
|
@@ -10372,7 +10328,6 @@ const PhoneNumberInput = props => {
|
|
|
10372
10328
|
const onPrefixChange = ({
|
|
10373
10329
|
value
|
|
10374
10330
|
}) => {
|
|
10375
|
-
setSearchQuery('');
|
|
10376
10331
|
setInternalValue({
|
|
10377
10332
|
prefix: value,
|
|
10378
10333
|
suffix: internalValue.suffix
|
|
@@ -10400,7 +10355,7 @@ const PhoneNumberInput = props => {
|
|
|
10400
10355
|
} = explodeNumberModel(pastedValue);
|
|
10401
10356
|
const selectedPrefix = options.find(({
|
|
10402
10357
|
value
|
|
10403
|
-
}) => value === pastedPrefix);
|
|
10358
|
+
}) => value.value === pastedPrefix);
|
|
10404
10359
|
if (selectedPrefix && ALLOWED_PHONE_CHARS.test(pastedSuffix)) {
|
|
10405
10360
|
setInternalValue({
|
|
10406
10361
|
prefix: pastedPrefix,
|
|
@@ -10425,22 +10380,19 @@ const PhoneNumberInput = props => {
|
|
|
10425
10380
|
className: "tw-telephone",
|
|
10426
10381
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", {
|
|
10427
10382
|
className: "tw-telephone__country-select",
|
|
10428
|
-
children: /*#__PURE__*/jsxRuntime.jsx(
|
|
10429
|
-
id: id ? `${id}-select` : undefined,
|
|
10430
|
-
options: options,
|
|
10431
|
-
selected: {
|
|
10432
|
-
value: internalValue.prefix,
|
|
10433
|
-
label: internalValue.prefix
|
|
10434
|
-
},
|
|
10383
|
+
children: /*#__PURE__*/jsxRuntime.jsx(SelectInput, {
|
|
10435
10384
|
placeholder: "Select an option...",
|
|
10436
|
-
|
|
10437
|
-
|
|
10438
|
-
|
|
10439
|
-
|
|
10385
|
+
items: options,
|
|
10386
|
+
value: options.find(item => item.value.value === internalValue.prefix)?.value,
|
|
10387
|
+
renderValue: (option, withinTrigger) => /*#__PURE__*/jsxRuntime.jsx(SelectInputOptionContent, {
|
|
10388
|
+
title: option.label,
|
|
10389
|
+
note: withinTrigger ? undefined : option.note
|
|
10390
|
+
}),
|
|
10391
|
+
filterable: true,
|
|
10392
|
+
filterPlaceholder: searchPlaceholder,
|
|
10440
10393
|
disabled: disabled,
|
|
10441
10394
|
size: size,
|
|
10442
10395
|
onChange: onPrefixChange,
|
|
10443
|
-
onSearchChange: newSearch => setSearchQuery(newSearch),
|
|
10444
10396
|
...selectProps
|
|
10445
10397
|
})
|
|
10446
10398
|
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|