@blocklet/payment-react 1.18.35 → 1.18.36
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/es/components/country-select.d.ts +1 -0
- package/es/components/country-select.js +359 -276
- package/es/contexts/payment.js +21 -1
- package/es/libs/cached-request.d.ts +1 -1
- package/es/payment/form/address.js +6 -6
- package/es/payment/form/index.js +1 -1
- package/es/payment/form/phone.js +2 -1
- package/es/payment/form/stripe/form.js +1 -0
- package/lib/components/country-select.d.ts +1 -0
- package/lib/components/country-select.js +188 -80
- package/lib/contexts/payment.js +21 -0
- package/lib/libs/cached-request.d.ts +1 -1
- package/lib/payment/form/address.js +7 -6
- package/lib/payment/form/index.js +1 -1
- package/lib/payment/form/phone.js +2 -1
- package/lib/payment/form/stripe/form.js +1 -0
- package/package.json +6 -6
- package/src/components/country-select.tsx +381 -290
- package/src/contexts/payment.tsx +29 -1
- package/src/libs/cached-request.ts +1 -1
- package/src/payment/form/address.tsx +6 -6
- package/src/payment/form/index.tsx +1 -1
- package/src/payment/form/phone.tsx +1 -0
- package/src/payment/form/stripe/form.tsx +1 -0
|
@@ -5,6 +5,7 @@ export type CountrySelectProps = {
|
|
|
5
5
|
onChange: (value: CountryIso2) => void;
|
|
6
6
|
name: string;
|
|
7
7
|
sx?: SxProps;
|
|
8
|
+
showDialCode?: boolean;
|
|
8
9
|
};
|
|
9
10
|
declare const CountrySelect: import("react").ForwardRefExoticComponent<CountrySelectProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
10
11
|
export default CountrySelect;
|
|
@@ -1,304 +1,387 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, forwardRef, useState, useEffect, useRef } from "react";
|
|
3
|
-
import { Box, MenuItem,
|
|
3
|
+
import { Box, MenuItem, Typography, TextField, Dialog, DialogContent, IconButton, Select, Slide } from "@mui/material";
|
|
4
4
|
import { useFormContext } from "react-hook-form";
|
|
5
5
|
import { FlagEmoji, defaultCountries, parseCountry } from "react-international-phone";
|
|
6
6
|
import { useMobile } from "../hooks/mobile.js";
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
const Transition = forwardRef(function Transition2(props, ref) {
|
|
8
|
+
return /* @__PURE__ */ jsx(Slide, { direction: "up", ref, timeout: 200, ...props });
|
|
9
|
+
});
|
|
10
|
+
const CountrySelect = forwardRef(
|
|
11
|
+
({ value, onChange, name, sx, showDialCode = false }, ref) => {
|
|
12
|
+
const { setValue } = useFormContext();
|
|
13
|
+
const [open, setOpen] = useState(false);
|
|
14
|
+
const [searchText, setSearchText] = useState("");
|
|
15
|
+
const inputRef = useRef(null);
|
|
16
|
+
const menuRef = useRef(null);
|
|
17
|
+
const listRef = useRef(null);
|
|
18
|
+
const [focusedIndex, setFocusedIndex] = useState(-1);
|
|
19
|
+
const itemHeightRef = useRef(40);
|
|
20
|
+
const { isMobile } = useMobile();
|
|
21
|
+
const measuredRef = useRef(false);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!open)
|
|
24
|
+
return () => {
|
|
25
|
+
};
|
|
26
|
+
const handleResize = () => {
|
|
27
|
+
measuredRef.current = false;
|
|
28
|
+
};
|
|
29
|
+
window.addEventListener("resize", handleResize);
|
|
20
30
|
return () => {
|
|
31
|
+
window.removeEventListener("resize", handleResize);
|
|
21
32
|
};
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
}, [open]);
|
|
34
|
+
const scrollToTop = () => {
|
|
35
|
+
if (listRef.current) {
|
|
36
|
+
listRef.current.scrollTop = 0;
|
|
37
|
+
}
|
|
24
38
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
39
|
+
const measureItemHeight = () => {
|
|
40
|
+
if (!listRef.current || !open)
|
|
41
|
+
return;
|
|
42
|
+
const items = listRef.current.querySelectorAll(".MuiMenuItem-root");
|
|
43
|
+
if (items.length > 0) {
|
|
44
|
+
const firstItem = items[0];
|
|
45
|
+
if (firstItem.offsetHeight > 0) {
|
|
46
|
+
itemHeightRef.current = firstItem.offsetHeight;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
28
49
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const measureItemHeight = () => {
|
|
36
|
-
if (!listRef.current || !open)
|
|
37
|
-
return;
|
|
38
|
-
const items = listRef.current.querySelectorAll(".MuiMenuItem-root");
|
|
39
|
-
if (items.length > 0) {
|
|
40
|
-
const firstItem = items[0];
|
|
41
|
-
if (firstItem.offsetHeight > 0) {
|
|
42
|
-
itemHeightRef.current = firstItem.offsetHeight;
|
|
50
|
+
const controlScrollPosition = (index) => {
|
|
51
|
+
if (!listRef.current)
|
|
52
|
+
return;
|
|
53
|
+
if (open && !measuredRef.current) {
|
|
54
|
+
measureItemHeight();
|
|
55
|
+
measuredRef.current = true;
|
|
43
56
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (
|
|
70
|
-
|
|
57
|
+
const listHeight = listRef.current.clientHeight;
|
|
58
|
+
const targetPosition = index * itemHeightRef.current;
|
|
59
|
+
if (index < 2) {
|
|
60
|
+
listRef.current.scrollTop = 0;
|
|
61
|
+
} else if (index > filteredCountries.length - 3) {
|
|
62
|
+
listRef.current.scrollTop = listRef.current.scrollHeight - listHeight;
|
|
63
|
+
} else {
|
|
64
|
+
const scrollPosition = targetPosition - listHeight / 2 + itemHeightRef.current / 2;
|
|
65
|
+
listRef.current.scrollTop = Math.max(0, scrollPosition);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
let timeout = null;
|
|
70
|
+
if (open) {
|
|
71
|
+
timeout = setTimeout(() => {
|
|
72
|
+
scrollToTop();
|
|
73
|
+
if (!isMobile && inputRef.current) {
|
|
74
|
+
inputRef.current.focus();
|
|
75
|
+
}
|
|
76
|
+
}, 100);
|
|
77
|
+
} else {
|
|
78
|
+
setSearchText("");
|
|
79
|
+
setFocusedIndex(-1);
|
|
80
|
+
}
|
|
81
|
+
return () => {
|
|
82
|
+
if (timeout) {
|
|
83
|
+
clearTimeout(timeout);
|
|
71
84
|
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
85
|
+
};
|
|
86
|
+
}, [open, isMobile]);
|
|
87
|
+
const filteredCountries = useMemo(() => {
|
|
88
|
+
if (!searchText)
|
|
89
|
+
return defaultCountries;
|
|
90
|
+
return defaultCountries.filter((c) => {
|
|
91
|
+
const parsed = parseCountry(c);
|
|
92
|
+
return parsed.name.toLowerCase().includes(searchText.toLowerCase()) || parsed.iso2.toLowerCase().includes(searchText.toLowerCase()) || `+${parsed.dialCode}`.includes(searchText);
|
|
93
|
+
});
|
|
94
|
+
}, [searchText]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
scrollToTop();
|
|
75
97
|
setFocusedIndex(-1);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
}, [searchText]);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
let timeout = null;
|
|
101
|
+
if (focusedIndex >= 0) {
|
|
102
|
+
timeout = setTimeout(() => {
|
|
103
|
+
controlScrollPosition(focusedIndex);
|
|
104
|
+
}, 10);
|
|
80
105
|
}
|
|
106
|
+
return () => {
|
|
107
|
+
if (timeout) {
|
|
108
|
+
clearTimeout(timeout);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}, [focusedIndex, filteredCountries.length]);
|
|
112
|
+
const countryDetail = useMemo(() => {
|
|
113
|
+
const item = defaultCountries.find((v) => v[1] === value);
|
|
114
|
+
return value && item ? parseCountry(item) : { name: "" };
|
|
115
|
+
}, [value]);
|
|
116
|
+
const handleCountryClick = (code) => {
|
|
117
|
+
onChange(code);
|
|
118
|
+
setValue(name, code);
|
|
119
|
+
setOpen(false);
|
|
81
120
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return defaultCountries;
|
|
86
|
-
return defaultCountries.filter((c) => {
|
|
87
|
-
const parsed = parseCountry(c);
|
|
88
|
-
return parsed.name.toLowerCase().includes(searchText.toLowerCase()) || parsed.iso2.toLowerCase().includes(searchText.toLowerCase()) || `+${parsed.dialCode}`.includes(searchText);
|
|
89
|
-
});
|
|
90
|
-
}, [searchText]);
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
scrollToTop();
|
|
93
|
-
setFocusedIndex(-1);
|
|
94
|
-
}, [searchText]);
|
|
95
|
-
useEffect(() => {
|
|
96
|
-
let timeout = null;
|
|
97
|
-
if (focusedIndex >= 0) {
|
|
98
|
-
timeout = setTimeout(() => {
|
|
99
|
-
controlScrollPosition(focusedIndex);
|
|
100
|
-
}, 10);
|
|
101
|
-
}
|
|
102
|
-
return () => {
|
|
103
|
-
if (timeout) {
|
|
104
|
-
clearTimeout(timeout);
|
|
105
|
-
}
|
|
121
|
+
const handleSearchChange = (e) => {
|
|
122
|
+
e.stopPropagation();
|
|
123
|
+
setSearchText(e.target.value);
|
|
106
124
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const handleSearchChange = (e) => {
|
|
122
|
-
e.stopPropagation();
|
|
123
|
-
setSearchText(e.target.value);
|
|
124
|
-
};
|
|
125
|
-
const handleKeyDown = (e) => {
|
|
126
|
-
e.stopPropagation();
|
|
127
|
-
if (e.key === "Escape") {
|
|
128
|
-
setOpen(false);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
const handleNavigation = (direction) => {
|
|
132
|
-
e.preventDefault();
|
|
133
|
-
setFocusedIndex((prev) => {
|
|
134
|
-
if (direction === "next") {
|
|
125
|
+
const handleKeyDown = (e) => {
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
if (e.key === "Escape") {
|
|
128
|
+
setOpen(false);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const handleNavigation = (direction) => {
|
|
132
|
+
e.preventDefault();
|
|
133
|
+
setFocusedIndex((prev) => {
|
|
134
|
+
if (direction === "next") {
|
|
135
|
+
if (prev === -1)
|
|
136
|
+
return 0;
|
|
137
|
+
return prev >= filteredCountries.length - 1 ? 0 : prev + 1;
|
|
138
|
+
}
|
|
135
139
|
if (prev === -1)
|
|
136
|
-
return
|
|
137
|
-
return prev
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
return filteredCountries.length - 1;
|
|
141
|
+
return prev <= 0 ? filteredCountries.length - 1 : prev - 1;
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
if (e.key === "Tab") {
|
|
145
|
+
handleNavigation(e.shiftKey ? "prev" : "next");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
if (e.key === "ArrowDown") {
|
|
149
|
+
handleNavigation("next");
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (e.key === "ArrowUp") {
|
|
153
|
+
handleNavigation("prev");
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (e.key === "Enter" && focusedIndex >= 0 && focusedIndex < filteredCountries.length) {
|
|
157
|
+
e.preventDefault();
|
|
158
|
+
const country = parseCountry(filteredCountries[focusedIndex]);
|
|
159
|
+
handleCountryClick(country.iso2);
|
|
160
|
+
}
|
|
143
161
|
};
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (e.key === "ArrowDown") {
|
|
149
|
-
handleNavigation("next");
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
if (e.key === "ArrowUp") {
|
|
153
|
-
handleNavigation("prev");
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (e.key === "Enter" && focusedIndex >= 0 && focusedIndex < filteredCountries.length) {
|
|
157
|
-
e.preventDefault();
|
|
158
|
-
const country = parseCountry(filteredCountries[focusedIndex]);
|
|
159
|
-
handleCountryClick(country.iso2);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
return /* @__PURE__ */ jsxs(
|
|
163
|
-
Select,
|
|
164
|
-
{
|
|
165
|
-
ref,
|
|
166
|
-
open,
|
|
167
|
-
onOpen: () => setOpen(true),
|
|
168
|
-
onClose: () => setOpen(false),
|
|
169
|
-
MenuProps: {
|
|
170
|
-
style: {
|
|
171
|
-
maxHeight: "300px",
|
|
172
|
-
top: "10px"
|
|
173
|
-
},
|
|
174
|
-
anchorOrigin: {
|
|
175
|
-
vertical: "bottom",
|
|
176
|
-
horizontal: "left"
|
|
177
|
-
},
|
|
178
|
-
transformOrigin: {
|
|
179
|
-
vertical: "top",
|
|
180
|
-
horizontal: "left"
|
|
181
|
-
},
|
|
182
|
-
PaperProps: {
|
|
183
|
-
ref: menuRef,
|
|
162
|
+
const countryListContent = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
163
|
+
/* @__PURE__ */ jsx(
|
|
164
|
+
Box,
|
|
165
|
+
{
|
|
184
166
|
sx: {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
167
|
+
position: "sticky",
|
|
168
|
+
top: 0,
|
|
169
|
+
zIndex: 1,
|
|
170
|
+
bgcolor: "background.paper",
|
|
171
|
+
p: 1
|
|
172
|
+
},
|
|
173
|
+
onClick: (e) => {
|
|
174
|
+
e.stopPropagation();
|
|
175
|
+
},
|
|
176
|
+
children: /* @__PURE__ */ jsx(
|
|
177
|
+
TextField,
|
|
178
|
+
{
|
|
179
|
+
inputRef,
|
|
180
|
+
autoFocus: !isMobile,
|
|
181
|
+
fullWidth: true,
|
|
182
|
+
placeholder: "Search country...",
|
|
183
|
+
value: searchText,
|
|
184
|
+
onChange: handleSearchChange,
|
|
185
|
+
onKeyDown: handleKeyDown,
|
|
186
|
+
onClick: (e) => e.stopPropagation(),
|
|
187
|
+
size: "small",
|
|
188
|
+
variant: "outlined"
|
|
191
189
|
}
|
|
192
|
-
|
|
190
|
+
)
|
|
193
191
|
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
192
|
+
),
|
|
193
|
+
/* @__PURE__ */ jsx(
|
|
194
|
+
Box,
|
|
195
|
+
{
|
|
196
|
+
ref: listRef,
|
|
197
|
+
sx: {
|
|
198
|
+
flex: 1,
|
|
199
|
+
overflowY: "auto",
|
|
200
|
+
overflowX: "hidden",
|
|
201
|
+
maxHeight: isMobile ? "calc(60vh - 80px)" : "calc(300px - 65px)",
|
|
202
|
+
scrollBehavior: "smooth"
|
|
203
|
+
},
|
|
204
|
+
children: filteredCountries.length > 0 ? filteredCountries.map((c, index) => {
|
|
205
|
+
const parsed = parseCountry(c);
|
|
206
|
+
const isFocused = index === focusedIndex;
|
|
207
|
+
return /* @__PURE__ */ jsxs(
|
|
208
|
+
MenuItem,
|
|
209
|
+
{
|
|
210
|
+
value: parsed.iso2,
|
|
211
|
+
selected: parsed.iso2 === value,
|
|
212
|
+
onClick: () => handleCountryClick(parsed.iso2),
|
|
213
|
+
sx: {
|
|
214
|
+
display: "flex",
|
|
215
|
+
alignItems: "center",
|
|
216
|
+
"&.Mui-selected": {
|
|
217
|
+
backgroundColor: "rgba(0, 0, 0, 0.04)"
|
|
218
|
+
},
|
|
219
|
+
"&:hover": {
|
|
220
|
+
backgroundColor: "var(--backgrounds-bg-highlight, #eff6ff)"
|
|
221
|
+
},
|
|
222
|
+
...isFocused ? {
|
|
223
|
+
backgroundColor: "var(--backgrounds-bg-highlight, #eff6ff)",
|
|
224
|
+
outline: "none"
|
|
225
|
+
} : {}
|
|
226
|
+
},
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsx(FlagEmoji, { iso2: parsed.iso2, style: { marginRight: "8px" } }),
|
|
229
|
+
/* @__PURE__ */ jsx(Typography, { children: parsed.name }),
|
|
230
|
+
showDialCode && /* @__PURE__ */ jsx(Typography, { sx: { ml: 1 }, color: "text.secondary", children: `+${parsed.dialCode}` })
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
parsed.iso2
|
|
234
|
+
);
|
|
235
|
+
}) : /* @__PURE__ */ jsx(MenuItem, { disabled: true, children: /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: "No countries found" }) })
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
] });
|
|
239
|
+
if (!isMobile) {
|
|
240
|
+
return /* @__PURE__ */ jsx(
|
|
241
|
+
Select,
|
|
242
|
+
{
|
|
243
|
+
ref,
|
|
244
|
+
open,
|
|
245
|
+
onOpen: () => setOpen(true),
|
|
246
|
+
onClose: () => setOpen(false),
|
|
247
|
+
MenuProps: {
|
|
248
|
+
style: {
|
|
249
|
+
maxHeight: "300px",
|
|
250
|
+
top: "10px"
|
|
251
|
+
},
|
|
252
|
+
anchorOrigin: {
|
|
253
|
+
vertical: "bottom",
|
|
254
|
+
horizontal: "left"
|
|
234
255
|
},
|
|
235
|
-
|
|
236
|
-
|
|
256
|
+
transformOrigin: {
|
|
257
|
+
vertical: "top",
|
|
258
|
+
horizontal: "left"
|
|
259
|
+
},
|
|
260
|
+
PaperProps: {
|
|
261
|
+
ref: menuRef,
|
|
262
|
+
sx: {
|
|
263
|
+
display: "flex",
|
|
264
|
+
"& .MuiList-root": {
|
|
265
|
+
pt: 0,
|
|
266
|
+
display: "flex",
|
|
267
|
+
flexDirection: "column",
|
|
268
|
+
overflowY: "hidden"
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
sx: {
|
|
274
|
+
width: "100%",
|
|
275
|
+
minWidth: "60px",
|
|
276
|
+
fieldset: {
|
|
277
|
+
display: "none"
|
|
278
|
+
},
|
|
279
|
+
'&.Mui-focused:has(div[aria-expanded="false"])': {
|
|
280
|
+
fieldset: {
|
|
281
|
+
display: "block"
|
|
282
|
+
}
|
|
237
283
|
},
|
|
238
|
-
|
|
239
|
-
|
|
284
|
+
".MuiSelect-select": {
|
|
285
|
+
padding: "8px",
|
|
286
|
+
paddingRight: "24px !important"
|
|
287
|
+
},
|
|
288
|
+
svg: {
|
|
289
|
+
right: 0
|
|
290
|
+
},
|
|
291
|
+
".MuiMenuItem-root": {
|
|
292
|
+
justifyContent: "flex-start"
|
|
293
|
+
},
|
|
294
|
+
...sx
|
|
295
|
+
},
|
|
296
|
+
value,
|
|
297
|
+
onChange: (e) => {
|
|
298
|
+
onChange(e.target.value);
|
|
299
|
+
setValue(name, e.target.value);
|
|
300
|
+
},
|
|
301
|
+
renderValue: (code) => /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexWrap: "nowrap", gap: 0.5, sx: { cursor: "pointer" }, children: [
|
|
302
|
+
/* @__PURE__ */ jsx(FlagEmoji, { iso2: code, style: { display: "flex" } }),
|
|
303
|
+
/* @__PURE__ */ jsx(Typography, { children: countryDetail?.name })
|
|
304
|
+
] }),
|
|
305
|
+
children: countryListContent
|
|
306
|
+
}
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
return /* @__PURE__ */ jsxs(Box, { ref, sx: { ...sx }, children: [
|
|
310
|
+
/* @__PURE__ */ jsxs(
|
|
311
|
+
Box,
|
|
312
|
+
{
|
|
313
|
+
onClick: () => setOpen(true),
|
|
314
|
+
display: "flex",
|
|
315
|
+
alignItems: "center",
|
|
316
|
+
flexWrap: "nowrap",
|
|
317
|
+
gap: 0.5,
|
|
318
|
+
sx: {
|
|
319
|
+
cursor: "pointer",
|
|
320
|
+
padding: "8px",
|
|
321
|
+
paddingRight: "24px",
|
|
322
|
+
position: "relative",
|
|
323
|
+
border: "none",
|
|
324
|
+
"-webkit-tap-highlight-color": "transparent",
|
|
325
|
+
userSelect: "none",
|
|
326
|
+
background: "none",
|
|
327
|
+
"&:hover, &:focus, &:active": {
|
|
328
|
+
backgroundColor: "transparent",
|
|
329
|
+
outline: "none"
|
|
330
|
+
},
|
|
331
|
+
touchAction: "manipulation"
|
|
332
|
+
},
|
|
333
|
+
children: [
|
|
334
|
+
/* @__PURE__ */ jsx(FlagEmoji, { iso2: value, style: { display: "flex" } }),
|
|
335
|
+
/* @__PURE__ */ jsx(Typography, { children: countryDetail?.name }),
|
|
336
|
+
/* @__PURE__ */ jsx(
|
|
337
|
+
Box,
|
|
240
338
|
{
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
variant: "outlined"
|
|
339
|
+
sx: {
|
|
340
|
+
position: "absolute",
|
|
341
|
+
right: "8px",
|
|
342
|
+
width: 0,
|
|
343
|
+
height: 0,
|
|
344
|
+
borderLeft: "5px solid transparent",
|
|
345
|
+
borderRight: "5px solid transparent",
|
|
346
|
+
borderTop: "5px solid currentColor"
|
|
347
|
+
}
|
|
251
348
|
}
|
|
252
349
|
)
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
350
|
+
]
|
|
351
|
+
}
|
|
352
|
+
),
|
|
353
|
+
/* @__PURE__ */ jsxs(
|
|
354
|
+
Dialog,
|
|
355
|
+
{
|
|
356
|
+
open,
|
|
357
|
+
onClose: () => setOpen(false),
|
|
358
|
+
fullWidth: true,
|
|
359
|
+
maxWidth: "xs",
|
|
360
|
+
TransitionComponent: Transition,
|
|
361
|
+
PaperProps: {
|
|
259
362
|
sx: {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
backgroundColor: "var(--backgrounds-bg-highlight, #eff6ff)"
|
|
281
|
-
},
|
|
282
|
-
...isFocused ? {
|
|
283
|
-
backgroundColor: "var(--backgrounds-bg-highlight, #eff6ff)",
|
|
284
|
-
outline: "none"
|
|
285
|
-
} : {}
|
|
286
|
-
},
|
|
287
|
-
children: [
|
|
288
|
-
/* @__PURE__ */ jsx(FlagEmoji, { iso2: parsed.iso2, style: { marginRight: "8px" } }),
|
|
289
|
-
/* @__PURE__ */ jsx(Typography, { children: parsed.name })
|
|
290
|
-
]
|
|
291
|
-
},
|
|
292
|
-
parsed.iso2
|
|
293
|
-
);
|
|
294
|
-
}) : /* @__PURE__ */ jsx(MenuItem, { disabled: true, children: /* @__PURE__ */ jsx(Typography, { color: "text.secondary", children: "No countries found" }) })
|
|
295
|
-
}
|
|
296
|
-
)
|
|
297
|
-
]
|
|
298
|
-
}
|
|
299
|
-
);
|
|
300
|
-
});
|
|
363
|
+
position: "absolute",
|
|
364
|
+
bottom: 0,
|
|
365
|
+
m: 0,
|
|
366
|
+
borderBottomLeftRadius: 0,
|
|
367
|
+
borderBottomRightRadius: 0,
|
|
368
|
+
width: "100%"
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
children: [
|
|
372
|
+
/* @__PURE__ */ jsxs(Box, { sx: { p: 2, display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
373
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h6", children: "Select Country" }),
|
|
374
|
+
/* @__PURE__ */ jsx(IconButton, { edge: "end", onClick: () => setOpen(false), sx: { "-webkit-tap-highlight-color": "transparent" }, children: "\u2715" })
|
|
375
|
+
] }),
|
|
376
|
+
/* @__PURE__ */ jsx(DialogContent, { sx: { p: 0 }, children: countryListContent })
|
|
377
|
+
]
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
] });
|
|
381
|
+
}
|
|
382
|
+
);
|
|
301
383
|
CountrySelect.defaultProps = {
|
|
302
|
-
sx: {}
|
|
384
|
+
sx: {},
|
|
385
|
+
showDialCode: false
|
|
303
386
|
};
|
|
304
387
|
export default CountrySelect;
|