@opexa/portal-components 0.0.888 → 0.0.889
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.
|
@@ -14,6 +14,7 @@ export const MobileNumberField = ({ enabledCountries, mobileNumber, onMobileNumb
|
|
|
14
14
|
: 'AE'));
|
|
15
15
|
const [search, setSearch] = useState('');
|
|
16
16
|
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
|
17
|
+
const [isComboboxOpen, setIsComboboxOpen] = useState(false);
|
|
17
18
|
const allCountries = useMemo(() => getAllUniqueCountries(enabledCountries), [enabledCountries]);
|
|
18
19
|
const countriesCollection = useMemo(() => countriesListCollection(allCountries), [allCountries]);
|
|
19
20
|
const handleMobileChange = useCallback((e) => {
|
|
@@ -35,32 +36,32 @@ export const MobileNumberField = ({ enabledCountries, mobileNumber, onMobileNumb
|
|
|
35
36
|
setSearch('');
|
|
36
37
|
}, children: [_jsx(Popover.Trigger, { onClick: () => {
|
|
37
38
|
setIsPopoverOpen(!isPopoverOpen);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
if (!isPopoverOpen) {
|
|
40
|
+
setTimeout(() => setIsComboboxOpen(true), 100);
|
|
41
|
+
}
|
|
42
|
+
}, className: "rounded-md border border-border-primary bg-background bg-bg-primary px-3 py-2 shadow-xs transition-colors placeholder:text-text-placeholder hover:border-border-hover focus:border-border-brand focus:border-border-focus focus:shadow-brand-xs focus:outline-none", children: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(selectedCountry.flag, { className: "size-5" }), _jsx("span", { children: selectedCountry.areaCode }), _jsx(Popover.Indicator, { children: _jsx(ChevronDownIcon, {}) })] }) }), _jsx(Popover.Positioner, { className: "w-full", children: _jsx(Popover.Content, { children: _jsxs(Combobox.Root, { collection: countriesCollection, positioning: {
|
|
43
|
+
sameWidth: true,
|
|
44
|
+
}, value: [selectedCountry.code], onValueChange: (details) => {
|
|
45
|
+
if (details.value && details.value.length > 0) {
|
|
46
|
+
setSelectedCountry(getCountryDetails(details.value[0]));
|
|
47
|
+
setAreaCode(getCountryDetails(details.value[0]).areaCode);
|
|
48
|
+
setSearch('');
|
|
49
|
+
setIsPopoverOpen(false);
|
|
50
|
+
setIsComboboxOpen(false);
|
|
51
|
+
}
|
|
52
|
+
}, inputValue: search, onInputValueChange: (details) => {
|
|
53
|
+
setSearch(details.inputValue);
|
|
54
|
+
}, open: isComboboxOpen, openOnClick: true, children: [_jsx(Combobox.Control, { className: "rounded-lg border-1 shadow-none outline-none", children: _jsx(Combobox.Input, { placeholder: "Search country..." }) }), _jsx(Portal, { children: _jsx(Combobox.Positioner, { style: { zIndex: 9999 }, children: _jsx(Combobox.Content, { className: "w-full", style: { zIndex: 9999 }, children: _jsx(Combobox.ItemGroup, { children: (() => {
|
|
55
|
+
const filteredCountries = countriesCollection.items.filter((country) => search === '' ||
|
|
56
|
+
country.name
|
|
57
|
+
.toLowerCase()
|
|
58
|
+
.includes(search.toLowerCase()) ||
|
|
59
|
+
country.areaCode.includes(search));
|
|
60
|
+
if (filteredCountries.length === 0) {
|
|
61
|
+
return (_jsx("div", { className: "p-3 text-center text-text-placeholder", children: "No countries found" }));
|
|
62
|
+
}
|
|
63
|
+
return filteredCountries.map((country) => (_jsxs(Combobox.Item, { item: country, children: [_jsxs(Combobox.ItemText, { children: [_jsx(country.flag, { className: "mr-2 inline-block size-5" }), country.name, " (", country.areaCode, ")"] }), _jsx(Combobox.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, country.code)));
|
|
64
|
+
})() }) }) }) })] }) }) })] }), _jsx(Field.Input, { ...(mobileNumberRegistration || {}), style: { paddingLeft: '0.5rem' }, value: mobileNumber, onChange: handleMobileChange, placeholder: "Enter mobile number" })] }), _jsx(Field.ErrorText, { children: error })] }));
|
|
64
65
|
};
|
|
65
66
|
const countriesListCollection = (countries) => createListCollection({
|
|
66
67
|
items: countries,
|