@blocklet/payment-react 1.18.34 → 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.
Files changed (42) hide show
  1. package/es/components/country-select.d.ts +1 -0
  2. package/es/components/country-select.js +359 -276
  3. package/es/contexts/payment.js +21 -1
  4. package/es/libs/cached-request.d.ts +1 -1
  5. package/es/libs/util.d.ts +1 -0
  6. package/es/libs/util.js +13 -0
  7. package/es/libs/validator.d.ts +1 -0
  8. package/es/libs/validator.js +14 -0
  9. package/es/locales/en.js +2 -1
  10. package/es/locales/zh.js +2 -1
  11. package/es/payment/form/address.d.ts +5 -1
  12. package/es/payment/form/address.js +27 -14
  13. package/es/payment/form/index.js +43 -10
  14. package/es/payment/form/phone.js +2 -1
  15. package/es/payment/form/stripe/form.js +1 -0
  16. package/lib/components/country-select.d.ts +1 -0
  17. package/lib/components/country-select.js +188 -80
  18. package/lib/contexts/payment.js +21 -0
  19. package/lib/libs/cached-request.d.ts +1 -1
  20. package/lib/libs/util.d.ts +1 -0
  21. package/lib/libs/util.js +16 -1
  22. package/lib/libs/validator.d.ts +1 -0
  23. package/lib/libs/validator.js +14 -0
  24. package/lib/locales/en.js +2 -1
  25. package/lib/locales/zh.js +2 -1
  26. package/lib/payment/form/address.d.ts +5 -1
  27. package/lib/payment/form/address.js +23 -13
  28. package/lib/payment/form/index.js +39 -10
  29. package/lib/payment/form/phone.js +2 -1
  30. package/lib/payment/form/stripe/form.js +1 -0
  31. package/package.json +6 -6
  32. package/src/components/country-select.tsx +381 -290
  33. package/src/contexts/payment.tsx +29 -1
  34. package/src/libs/cached-request.ts +1 -1
  35. package/src/libs/util.ts +15 -0
  36. package/src/libs/validator.ts +14 -0
  37. package/src/locales/en.tsx +1 -0
  38. package/src/locales/zh.tsx +1 -0
  39. package/src/payment/form/address.tsx +26 -11
  40. package/src/payment/form/index.tsx +39 -7
  41. package/src/payment/form/phone.tsx +1 -0
  42. 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, Select, Typography, TextField } from "@mui/material";
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 CountrySelect = forwardRef(({ value, onChange, name, sx }, ref) => {
8
- const { setValue } = useFormContext();
9
- const [open, setOpen] = useState(false);
10
- const [searchText, setSearchText] = useState("");
11
- const inputRef = useRef(null);
12
- const menuRef = useRef(null);
13
- const listRef = useRef(null);
14
- const [focusedIndex, setFocusedIndex] = useState(-1);
15
- const itemHeightRef = useRef(40);
16
- const { isMobile } = useMobile();
17
- const measuredRef = useRef(false);
18
- useEffect(() => {
19
- if (!open)
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
- const handleResize = () => {
23
- measuredRef.current = false;
33
+ }, [open]);
34
+ const scrollToTop = () => {
35
+ if (listRef.current) {
36
+ listRef.current.scrollTop = 0;
37
+ }
24
38
  };
25
- window.addEventListener("resize", handleResize);
26
- return () => {
27
- window.removeEventListener("resize", handleResize);
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
- }, [open]);
30
- const scrollToTop = () => {
31
- if (listRef.current) {
32
- listRef.current.scrollTop = 0;
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
- const controlScrollPosition = (index) => {
47
- if (!listRef.current)
48
- return;
49
- if (open && !measuredRef.current) {
50
- measureItemHeight();
51
- measuredRef.current = true;
52
- }
53
- const listHeight = listRef.current.clientHeight;
54
- const targetPosition = index * itemHeightRef.current;
55
- if (index < 2) {
56
- listRef.current.scrollTop = 0;
57
- } else if (index > filteredCountries.length - 3) {
58
- listRef.current.scrollTop = listRef.current.scrollHeight - listHeight;
59
- } else {
60
- const scrollPosition = targetPosition - listHeight / 2 + itemHeightRef.current / 2;
61
- listRef.current.scrollTop = Math.max(0, scrollPosition);
62
- }
63
- };
64
- useEffect(() => {
65
- let timeout = null;
66
- if (open) {
67
- timeout = setTimeout(() => {
68
- scrollToTop();
69
- if (!isMobile && inputRef.current) {
70
- inputRef.current.focus();
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
- }, 100);
73
- } else {
74
- setSearchText("");
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
- return () => {
78
- if (timeout) {
79
- clearTimeout(timeout);
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
- }, [open, isMobile]);
83
- const filteredCountries = useMemo(() => {
84
- if (!searchText)
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
- }, [focusedIndex, filteredCountries.length]);
108
- const countryDetail = useMemo(() => {
109
- const item = defaultCountries.find((v) => v[1] === value);
110
- return value && item ? parseCountry(item) : { name: "" };
111
- }, [value]);
112
- const onCountryChange = (e) => {
113
- onChange(e.target.value);
114
- setValue(name, e.target.value);
115
- };
116
- const handleCountryClick = (code) => {
117
- onChange(code);
118
- setValue(name, code);
119
- setOpen(false);
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 0;
137
- return prev >= filteredCountries.length - 1 ? 0 : prev + 1;
138
- }
139
- if (prev === -1)
140
- return filteredCountries.length - 1;
141
- return prev <= 0 ? filteredCountries.length - 1 : prev - 1;
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
- 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
- }
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
- display: "flex",
186
- "& .MuiList-root": {
187
- pt: 0,
188
- display: "flex",
189
- flexDirection: "column",
190
- overflowY: "hidden"
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
- sx: {
196
- width: "100%",
197
- minWidth: "60px",
198
- fieldset: {
199
- display: "none"
200
- },
201
- '&.Mui-focused:has(div[aria-expanded="false"])': {
202
- fieldset: {
203
- display: "block"
204
- }
205
- },
206
- ".MuiSelect-select": {
207
- padding: "8px",
208
- paddingRight: "24px !important"
209
- },
210
- svg: {
211
- right: 0
212
- },
213
- ".MuiMenuItem-root": {
214
- justifyContent: "flex-start"
215
- },
216
- ...sx
217
- },
218
- value,
219
- onChange: onCountryChange,
220
- renderValue: (code) => /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", flexWrap: "nowrap", gap: 0.5, sx: { cursor: "pointer" }, children: [
221
- /* @__PURE__ */ jsx(FlagEmoji, { iso2: code, style: { display: "flex" } }),
222
- /* @__PURE__ */ jsx(Typography, { children: countryDetail?.name })
223
- ] }),
224
- children: [
225
- /* @__PURE__ */ jsx(
226
- Box,
227
- {
228
- sx: {
229
- position: "sticky",
230
- top: 0,
231
- zIndex: 1,
232
- bgcolor: "background.paper",
233
- p: 1
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
- onClick: (e) => {
236
- e.stopPropagation();
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
- children: /* @__PURE__ */ jsx(
239
- TextField,
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
- inputRef,
242
- autoFocus: !isMobile,
243
- fullWidth: true,
244
- placeholder: "Search country...",
245
- value: searchText,
246
- onChange: handleSearchChange,
247
- onKeyDown: handleKeyDown,
248
- onClick: (e) => e.stopPropagation(),
249
- size: "small",
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
- /* @__PURE__ */ jsx(
256
- Box,
257
- {
258
- ref: listRef,
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
- flex: 1,
261
- overflowY: "auto",
262
- overflowX: "hidden",
263
- maxHeight: "calc(300px - 65px)",
264
- scrollBehavior: "smooth"
265
- },
266
- children: filteredCountries.length > 0 ? filteredCountries.map((c, index) => {
267
- const parsed = parseCountry(c);
268
- const isFocused = index === focusedIndex;
269
- return /* @__PURE__ */ jsxs(
270
- MenuItem,
271
- {
272
- value: parsed.iso2,
273
- selected: parsed.iso2 === value,
274
- onClick: () => handleCountryClick(parsed.iso2),
275
- sx: {
276
- "&.Mui-selected": {
277
- backgroundColor: "rgba(0, 0, 0, 0.04)"
278
- },
279
- "&:hover": {
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;