@babelize/elements 1.0.8 → 1.1.0
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/README.md +120 -11
- package/bin.js +2 -0
- package/dist/cli/index.js +169 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +956 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +118 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.js +930 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -16
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -6
- package/dist/lib/utils.js.map +0 -1
- package/dist/registry/components/index.d.ts +0 -3
- package/dist/registry/components/index.d.ts.map +0 -1
- package/dist/registry/components/index.js +0 -2
- package/dist/registry/components/index.js.map +0 -1
- package/dist/registry/components/language-switcher.d.ts +0 -83
- package/dist/registry/components/language-switcher.d.ts.map +0 -1
- package/dist/registry/components/language-switcher.js +0 -194
- package/dist/registry/components/language-switcher.js.map +0 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,930 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { twMerge } from 'tailwind-merge';
|
|
3
|
+
import * as React3 from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
// src/lib/utils.ts
|
|
7
|
+
function cn(...inputs) {
|
|
8
|
+
return twMerge(clsx(inputs));
|
|
9
|
+
}
|
|
10
|
+
function useControllableState(value, defaultValue, onChange) {
|
|
11
|
+
const isControlled = value !== void 0;
|
|
12
|
+
const [uncontrolled, setUncontrolled] = React3.useState(defaultValue);
|
|
13
|
+
const onChangeRef = React3.useRef(onChange);
|
|
14
|
+
React3.useEffect(() => {
|
|
15
|
+
onChangeRef.current = onChange;
|
|
16
|
+
}, [onChange]);
|
|
17
|
+
const current = isControlled ? value : uncontrolled;
|
|
18
|
+
const setValue = React3.useCallback(
|
|
19
|
+
(next) => {
|
|
20
|
+
var _a;
|
|
21
|
+
if (!isControlled) setUncontrolled(next);
|
|
22
|
+
(_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, next);
|
|
23
|
+
},
|
|
24
|
+
[isControlled]
|
|
25
|
+
);
|
|
26
|
+
return [current, setValue];
|
|
27
|
+
}
|
|
28
|
+
var RTL_LOCALES = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "sd", "yi"]);
|
|
29
|
+
function isRtl(code) {
|
|
30
|
+
const lang = code.split("-")[0].toLowerCase();
|
|
31
|
+
return RTL_LOCALES.has(lang);
|
|
32
|
+
}
|
|
33
|
+
var LANG_TO_FLAG = {
|
|
34
|
+
en: "\u{1F1FA}\u{1F1F8}",
|
|
35
|
+
fr: "\u{1F1EB}\u{1F1F7}",
|
|
36
|
+
es: "\u{1F1EA}\u{1F1F8}",
|
|
37
|
+
de: "\u{1F1E9}\u{1F1EA}",
|
|
38
|
+
ja: "\u{1F1EF}\u{1F1F5}",
|
|
39
|
+
ko: "\u{1F1F0}\u{1F1F7}",
|
|
40
|
+
zh: "\u{1F1E8}\u{1F1F3}",
|
|
41
|
+
ar: "\u{1F1F8}\u{1F1E6}",
|
|
42
|
+
pt: "\u{1F1E7}\u{1F1F7}",
|
|
43
|
+
it: "\u{1F1EE}\u{1F1F9}",
|
|
44
|
+
nl: "\u{1F1F3}\u{1F1F1}",
|
|
45
|
+
ru: "\u{1F1F7}\u{1F1FA}",
|
|
46
|
+
pl: "\u{1F1F5}\u{1F1F1}",
|
|
47
|
+
tr: "\u{1F1F9}\u{1F1F7}",
|
|
48
|
+
vi: "\u{1F1FB}\u{1F1F3}",
|
|
49
|
+
th: "\u{1F1F9}\u{1F1ED}",
|
|
50
|
+
id: "\u{1F1EE}\u{1F1E9}",
|
|
51
|
+
hi: "\u{1F1EE}\u{1F1F3}",
|
|
52
|
+
bn: "\u{1F1E7}\u{1F1E9}",
|
|
53
|
+
uk: "\u{1F1FA}\u{1F1E6}",
|
|
54
|
+
cs: "\u{1F1E8}\u{1F1FF}",
|
|
55
|
+
sv: "\u{1F1F8}\u{1F1EA}",
|
|
56
|
+
da: "\u{1F1E9}\u{1F1F0}",
|
|
57
|
+
fi: "\u{1F1EB}\u{1F1EE}",
|
|
58
|
+
no: "\u{1F1F3}\u{1F1F4}",
|
|
59
|
+
nb: "\u{1F1F3}\u{1F1F4}",
|
|
60
|
+
nn: "\u{1F1F3}\u{1F1F4}",
|
|
61
|
+
el: "\u{1F1EC}\u{1F1F7}",
|
|
62
|
+
he: "\u{1F1EE}\u{1F1F1}",
|
|
63
|
+
fa: "\u{1F1EE}\u{1F1F7}",
|
|
64
|
+
ro: "\u{1F1F7}\u{1F1F4}",
|
|
65
|
+
hu: "\u{1F1ED}\u{1F1FA}",
|
|
66
|
+
sk: "\u{1F1F8}\u{1F1F0}",
|
|
67
|
+
bg: "\u{1F1E7}\u{1F1EC}",
|
|
68
|
+
hr: "\u{1F1ED}\u{1F1F7}",
|
|
69
|
+
sr: "\u{1F1F7}\u{1F1F8}",
|
|
70
|
+
sl: "\u{1F1F8}\u{1F1EE}",
|
|
71
|
+
lt: "\u{1F1F1}\u{1F1F9}",
|
|
72
|
+
lv: "\u{1F1F1}\u{1F1FB}",
|
|
73
|
+
et: "\u{1F1EA}\u{1F1EA}",
|
|
74
|
+
ga: "\u{1F1EE}\u{1F1EA}",
|
|
75
|
+
mt: "\u{1F1F2}\u{1F1F9}",
|
|
76
|
+
ca: "\u{1F1E6}\u{1F1F8}",
|
|
77
|
+
eu: "\u{1F1E6}\u{1F1F7}",
|
|
78
|
+
gl: "\u{1F1E6}\u{1F1F7}",
|
|
79
|
+
cy: "\u{1F1FF}\u{1F1F4}",
|
|
80
|
+
mk: "\u{1F1F2}\u{1F1F0}",
|
|
81
|
+
sq: "\u{1F1E6}\u{1F1F1}",
|
|
82
|
+
bs: "\u{1F1E7}\u{1F1F8}",
|
|
83
|
+
is: "\u{1F1EE}\u{1F1F8}",
|
|
84
|
+
fo: "\u{1F1EB}\u{1F1F4}",
|
|
85
|
+
sw: "\u{1F1F9}\u{1F1FF}",
|
|
86
|
+
am: "\u{1F1E6}\u{1F1F2}",
|
|
87
|
+
ne: "\u{1F1F3}\u{1F1F5}",
|
|
88
|
+
si: "\u{1F1F8}\u{1F1F0}",
|
|
89
|
+
my: "\u{1F1F2}\u{1F1E2}",
|
|
90
|
+
km: "\u{1F1F0}\u{1F1ED}",
|
|
91
|
+
lo: "\u{1F1F1}\u{1F1E6}",
|
|
92
|
+
ka: "\u{1F1EC}\u{1F1EA}",
|
|
93
|
+
hy: "\u{1F1E6}\u{1F1F2}",
|
|
94
|
+
kk: "\u{1F1F0}\u{1F1F0}",
|
|
95
|
+
uz: "\u{1F1FA}\u{1F1FF}",
|
|
96
|
+
mn: "\u{1F1F2}\u{1F1F3}",
|
|
97
|
+
ps: "\u{1F1F5}\u{1F1F8}",
|
|
98
|
+
ur: "\u{1F1FA}\u{1F1F2}",
|
|
99
|
+
sd: "\u{1F1F8}\u{1F1E6}",
|
|
100
|
+
ml: "\u{1F1F2}\u{1F1F1}",
|
|
101
|
+
ta: "\u{1F1F9}\u{1F1F1}",
|
|
102
|
+
te: "\u{1F1F9}\u{1F1EF}",
|
|
103
|
+
kn: "\u{1F1EE}\u{1F1F3}",
|
|
104
|
+
mr: "\u{1F1F2}\u{1F1F7}",
|
|
105
|
+
gu: "\u{1F1EE}\u{1F1F3}",
|
|
106
|
+
pa: "\u{1F1F5}\u{1F1E6}",
|
|
107
|
+
or: "\u{1F1F3}\u{1F1F4}",
|
|
108
|
+
as: "\u{1F1E6}\u{1F1F8}",
|
|
109
|
+
yi: "\u{1F1FE}\u{1F1EA}",
|
|
110
|
+
yo: "\u{1F1FE}\u{1F1F3}",
|
|
111
|
+
ig: "\u{1F1EE}\u{1F1EC}",
|
|
112
|
+
zu: "\u{1F1FF}\u{1F1F3}",
|
|
113
|
+
af: "\u{1F1E6}\u{1F1FF}",
|
|
114
|
+
ha: "\u{1F1ED}\u{1F1F2}",
|
|
115
|
+
tl: "\u{1F1F5}\u{1F1ED}",
|
|
116
|
+
mg: "\u{1F1F2}\u{1F1EC}",
|
|
117
|
+
mi: "\u{1F1F3}\u{1F1FF}",
|
|
118
|
+
sm: "\u{1F1F8}\u{1F1F4}",
|
|
119
|
+
fj: "\u{1F1EB}\u{1F1EF}",
|
|
120
|
+
to: "\u{1F1F9}\u{1F1F4}",
|
|
121
|
+
haw: "\u{1F1ED}\u{1F1FC}",
|
|
122
|
+
la: "\u{1F1F1}\u{1F1E6}",
|
|
123
|
+
eo: "\u{1F1EA}\u{1F1F7}"
|
|
124
|
+
};
|
|
125
|
+
function getFlag(code) {
|
|
126
|
+
var _a;
|
|
127
|
+
const lang = code.split("-")[0].toLowerCase();
|
|
128
|
+
return (_a = LANG_TO_FLAG[lang]) != null ? _a : "\u{1F310}";
|
|
129
|
+
}
|
|
130
|
+
var LANG_NAMES = {
|
|
131
|
+
en: ["English", "English"],
|
|
132
|
+
fr: ["Fran\xE7ais", "French"],
|
|
133
|
+
es: ["Espa\xF1ol", "Spanish"],
|
|
134
|
+
de: ["Deutsch", "German"],
|
|
135
|
+
ja: ["\u65E5\u672C\u8A9E", "Japanese"],
|
|
136
|
+
ko: ["\uD55C\uAD6D\uC5B4", "Korean"],
|
|
137
|
+
zh: ["\u4E2D\u6587", "Chinese"],
|
|
138
|
+
ar: ["\u0627\u0644\u0639\u0631\u0628\u064A\u0629", "Arabic"],
|
|
139
|
+
pt: ["Portugu\xEAs", "Portuguese"],
|
|
140
|
+
it: ["Italiano", "Italian"],
|
|
141
|
+
nl: ["Nederlands", "Dutch"],
|
|
142
|
+
ru: ["\u0420\u0443\u0441\u0441\u043A\u0438\u0439", "Russian"],
|
|
143
|
+
pl: ["Polski", "Polish"],
|
|
144
|
+
tr: ["T\xFCrk\xE7e", "Turkish"],
|
|
145
|
+
vi: ["Ti\u1EBFng Vi\u1EC7t", "Vietnamese"],
|
|
146
|
+
th: ["\u0E44\u0E17\u0E22", "Thai"],
|
|
147
|
+
id: ["Bahasa Indonesia", "Indonesian"],
|
|
148
|
+
hi: ["\u0939\u093F\u0928\u094D\u0926\u0940", "Hindi"],
|
|
149
|
+
bn: ["\u09AC\u09BE\u0982\u09B2\u09BE", "Bengali"],
|
|
150
|
+
uk: ["\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430", "Ukrainian"],
|
|
151
|
+
cs: ["\u010Ce\u0161tina", "Czech"],
|
|
152
|
+
sv: ["Svenska", "Swedish"],
|
|
153
|
+
da: ["Dansk", "Danish"],
|
|
154
|
+
fi: ["Suomi", "Finnish"],
|
|
155
|
+
no: ["Norsk", "Norwegian"],
|
|
156
|
+
nb: ["Norsk bokm\xE5l", "Norwegian Bokm\xE5l"],
|
|
157
|
+
nn: ["Nynorsk", "Norwegian Nynorsk"],
|
|
158
|
+
el: ["\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC", "Greek"],
|
|
159
|
+
he: ["\u05E2\u05D1\u05E8\u05D9\u05EA", "Hebrew"],
|
|
160
|
+
fa: ["\u0641\u0627\u0631\u0633\u06CC", "Persian"],
|
|
161
|
+
ro: ["Rom\xE2n\u0103", "Romanian"],
|
|
162
|
+
hu: ["Magyar", "Hungarian"],
|
|
163
|
+
sk: ["Sloven\u010Dina", "Slovak"],
|
|
164
|
+
bg: ["\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438", "Bulgarian"],
|
|
165
|
+
hr: ["Hrvatski", "Croatian"],
|
|
166
|
+
sr: ["\u0421\u0440\u043F\u0441\u043A\u0438", "Serbian"],
|
|
167
|
+
sl: ["Sloven\u0161\u010Dina", "Slovenian"],
|
|
168
|
+
lt: ["Lietuvi\u0173", "Lithuanian"],
|
|
169
|
+
lv: ["Latvie\u0161u", "Latvian"],
|
|
170
|
+
et: ["Eesti", "Estonian"],
|
|
171
|
+
ga: ["Gaeilge", "Irish"],
|
|
172
|
+
mt: ["Malti", "Maltese"],
|
|
173
|
+
ca: ["Catal\xE0", "Catalan"],
|
|
174
|
+
eu: ["Euskara", "Basque"],
|
|
175
|
+
gl: ["Galego", "Galician"],
|
|
176
|
+
cy: ["Cymraeg", "Welsh"],
|
|
177
|
+
mk: ["\u041C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438", "Macedonian"],
|
|
178
|
+
sq: ["Shqip", "Albanian"],
|
|
179
|
+
bs: ["Bosanski", "Bosnian"],
|
|
180
|
+
is: ["\xCDslenska", "Icelandic"],
|
|
181
|
+
fo: ["F\xF8royskt", "Faroese"],
|
|
182
|
+
sw: ["Kiswahili", "Swahili"],
|
|
183
|
+
am: ["\u12A0\u12CD\u1295\u1348", "Amharic"],
|
|
184
|
+
ne: ["\u0928\u0947\u092A\u093E\u0932\u0940", "Nepali"],
|
|
185
|
+
si: ["\u0DC3\u0DD2\u0D82\u0DC4\u0DBD", "Sinhala"],
|
|
186
|
+
my: ["\u1019\u103C\u1014\u103A\u1019\u102C", "Burmese"],
|
|
187
|
+
km: ["\u1780\u1798\u17D2\u1796\u17C7\u1798", "Khmer"],
|
|
188
|
+
lo: ["\u0EA5\u0E27", "Lao"],
|
|
189
|
+
ka: ["\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8", "Georgian"],
|
|
190
|
+
hy: ["\u0540\u0561\u0575\u0565\u10E0\u0565\u0576", "Armenian"],
|
|
191
|
+
kk: ["\u049A\u0430\u0437\u0430\u049B", "Kazakh"],
|
|
192
|
+
uz: ["O\u2019zbek", "Uzbek"],
|
|
193
|
+
mn: ["\u041C\u043E\u043D\u0433\u043E\u043B", "Mongolian"],
|
|
194
|
+
ps: ["\u067E\u069A\u062A\u0648", "Pashto"],
|
|
195
|
+
ur: ["\u0627\u0631\u062F\u0648", "Urdu"],
|
|
196
|
+
sd: ["\u0773\u0647\u0646\u068C\u064A", "Sindhi"],
|
|
197
|
+
ml: ["\u0D2E\u0D32\u0D2F\u0D3E\u0D33\u0D02", "Malayalam"],
|
|
198
|
+
ta: ["\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD", "Tamil"],
|
|
199
|
+
te: ["\u0C24\u0C46\u0C32\u0C41\u0C17\u0C41", "Telugu"],
|
|
200
|
+
kn: ["\u0C95\u0CA8\u0CCD\u0CA8\u0CA1", "Kannada"],
|
|
201
|
+
mr: ["\u092E\u0930\u093E\u0920\u0940", "Marathi"],
|
|
202
|
+
gu: ["\u0A97\u0AC1\u0A9C\u0AB0\u0ABE\u0AA4\u0AC0", "Gujarati"],
|
|
203
|
+
pa: ["\u0A2A\u0A70\u0A1C\u0A3E\u0A2C\u0A40", "Punjabi"],
|
|
204
|
+
or: ["\u0B13\u0B21\u0B3C\u0B3F\u0B06", "Odia"],
|
|
205
|
+
as: ["\u0985\u09B8\u09AE\u09C0\u09AF\u09BC\u09BE", "Assamese"],
|
|
206
|
+
yi: ["\u05D9\u05D9\u05B4\u05D3\u05D9\u05E9", "Yiddish"],
|
|
207
|
+
yo: ["Yor\xF9b\xE1", "Yoruba"],
|
|
208
|
+
ig: ["Igbo", "Igbo"],
|
|
209
|
+
zu: ["isiZulu", "Zulu"],
|
|
210
|
+
af: ["Afrikaans", "Afrikaans"],
|
|
211
|
+
ha: ["Hausa", "Hausa"],
|
|
212
|
+
tl: ["Filipino", "Filipino"],
|
|
213
|
+
mg: ["Malagasy", "Malagasy"],
|
|
214
|
+
mi: ["Te Reo M\u0101ori", "M\u0101ori"],
|
|
215
|
+
sm: ["Gagana Samoa", "Samoan"],
|
|
216
|
+
to: ["Lea Faka-Tonga", "Tongan"],
|
|
217
|
+
fj: ["Na Vosa Vakaviti", "Fijian"],
|
|
218
|
+
haw: ["\u02BB\u014Clelo Hawai\u02BBi", "Hawaiian"],
|
|
219
|
+
la: ["Latina", "Latin"],
|
|
220
|
+
eo: ["Esperanto", "Esperanto"]
|
|
221
|
+
};
|
|
222
|
+
function getLabel(code, mode) {
|
|
223
|
+
const lang = code.split("-")[0].toLowerCase();
|
|
224
|
+
const names = LANG_NAMES[lang];
|
|
225
|
+
if (!names) return code;
|
|
226
|
+
return mode === "native" ? names[0] : names[1];
|
|
227
|
+
}
|
|
228
|
+
var LanguageSwitcher = React3.forwardRef(
|
|
229
|
+
function LanguageSwitcher2({
|
|
230
|
+
locales,
|
|
231
|
+
value,
|
|
232
|
+
defaultValue,
|
|
233
|
+
onValueChange,
|
|
234
|
+
showFlags = false,
|
|
235
|
+
label: labelMode = "english",
|
|
236
|
+
className,
|
|
237
|
+
...rest
|
|
238
|
+
}, forwardedRef) {
|
|
239
|
+
var _a, _b, _c;
|
|
240
|
+
const [locale, setLocale] = useControllableState(
|
|
241
|
+
value,
|
|
242
|
+
(_b = defaultValue != null ? defaultValue : (_a = locales[0]) == null ? void 0 : _a.code) != null ? _b : "",
|
|
243
|
+
onValueChange
|
|
244
|
+
);
|
|
245
|
+
const [open, setOpen] = React3.useState(false);
|
|
246
|
+
const [search, setSearch] = React3.useState("");
|
|
247
|
+
const ref = React3.useRef(null);
|
|
248
|
+
const inputRef = React3.useRef(null);
|
|
249
|
+
React3.useImperativeHandle(forwardedRef, () => ref.current);
|
|
250
|
+
const resolveLabel = (l) => {
|
|
251
|
+
var _a2;
|
|
252
|
+
return (_a2 = l.label) != null ? _a2 : getLabel(l.code, labelMode);
|
|
253
|
+
};
|
|
254
|
+
const activeLocale = locales.find((l) => l.code === locale);
|
|
255
|
+
const filtered = locales.filter(
|
|
256
|
+
(l) => resolveLabel(l).toLowerCase().includes(search.toLowerCase()) || l.code.toLowerCase().includes(search.toLowerCase())
|
|
257
|
+
);
|
|
258
|
+
const dir = isRtl(locale) ? "rtl" : "ltr";
|
|
259
|
+
React3.useEffect(() => {
|
|
260
|
+
function handleClickOutside(e) {
|
|
261
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
262
|
+
setOpen(false);
|
|
263
|
+
setSearch("");
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
267
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
268
|
+
}, []);
|
|
269
|
+
React3.useEffect(() => {
|
|
270
|
+
var _a2;
|
|
271
|
+
if (open) (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
272
|
+
}, [open]);
|
|
273
|
+
React3.useEffect(() => {
|
|
274
|
+
function handleKeyDown(e) {
|
|
275
|
+
if (e.key === "Escape") {
|
|
276
|
+
setOpen(false);
|
|
277
|
+
setSearch("");
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
if (open) {
|
|
281
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
282
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
283
|
+
}
|
|
284
|
+
}, [open]);
|
|
285
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("relative inline-block text-sm z-50", className), ...rest, children: [
|
|
286
|
+
/* @__PURE__ */ jsxs(
|
|
287
|
+
"button",
|
|
288
|
+
{
|
|
289
|
+
type: "button",
|
|
290
|
+
onClick: () => setOpen(!open),
|
|
291
|
+
className: cn(
|
|
292
|
+
"inline-flex items-center gap-2 rounded-lg border border-zinc-200 bg-zinc-100 px-3 py-2 text-sm font-medium text-zinc-900 transition-colors hover:bg-zinc-100 hover:text-zinc-900 focus:outline-none focus:ring-2 focus:ring-emerald-500/50 dark:border-zinc-800 dark:bg-zinc-800 dark:text-zinc-100 dark:hover:bg-zinc-700 dark:hover:text-zinc-50",
|
|
293
|
+
dir === "rtl" && "flex-row-reverse"
|
|
294
|
+
),
|
|
295
|
+
"aria-expanded": open,
|
|
296
|
+
"aria-haspopup": "listbox",
|
|
297
|
+
"aria-label": `Current language: ${activeLocale ? resolveLabel(activeLocale) : locale}`,
|
|
298
|
+
children: [
|
|
299
|
+
showFlags && /* @__PURE__ */ jsx("span", { className: "text-base", children: (_c = activeLocale == null ? void 0 : activeLocale.flag) != null ? _c : getFlag(locale) }),
|
|
300
|
+
/* @__PURE__ */ jsx("span", { children: activeLocale ? resolveLabel(activeLocale) : locale }),
|
|
301
|
+
/* @__PURE__ */ jsx(
|
|
302
|
+
"svg",
|
|
303
|
+
{
|
|
304
|
+
className: cn(
|
|
305
|
+
"size-4 text-zinc-500 transition-transform dark:text-zinc-400",
|
|
306
|
+
open && "rotate-180"
|
|
307
|
+
),
|
|
308
|
+
fill: "none",
|
|
309
|
+
viewBox: "0 0 24 24",
|
|
310
|
+
stroke: "currentColor",
|
|
311
|
+
strokeWidth: 2,
|
|
312
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
]
|
|
316
|
+
}
|
|
317
|
+
),
|
|
318
|
+
open && /* @__PURE__ */ jsxs(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
className: "absolute z-50 mt-1 min-w-[200px] overflow-hidden rounded-xl border border-zinc-200 bg-white shadow-xl dark:border-zinc-800 dark:bg-zinc-950",
|
|
322
|
+
role: "listbox",
|
|
323
|
+
"aria-label": "Select language",
|
|
324
|
+
children: [
|
|
325
|
+
/* @__PURE__ */ jsx("div", { className: "border-b border-zinc-200 p-2 dark:border-zinc-800", children: /* @__PURE__ */ jsx(
|
|
326
|
+
"input",
|
|
327
|
+
{
|
|
328
|
+
ref: inputRef,
|
|
329
|
+
type: "text",
|
|
330
|
+
placeholder: "Search...",
|
|
331
|
+
value: search,
|
|
332
|
+
onChange: (e) => setSearch(e.target.value),
|
|
333
|
+
className: "w-full rounded-lg bg-zinc-100 px-3 py-1.5 text-sm text-zinc-900 outline-none placeholder:text-zinc-400 focus:ring-1 focus:ring-emerald-500/50 dark:bg-zinc-800 dark:text-zinc-100 dark:placeholder:text-zinc-500"
|
|
334
|
+
}
|
|
335
|
+
) }),
|
|
336
|
+
/* @__PURE__ */ jsxs("div", { className: "max-h-60 overflow-y-auto p-1", children: [
|
|
337
|
+
filtered.map((l) => {
|
|
338
|
+
var _a2;
|
|
339
|
+
const isActive = l.code === locale;
|
|
340
|
+
const itemDir = l.rtl || isRtl(l.code) ? "rtl" : "ltr";
|
|
341
|
+
return /* @__PURE__ */ jsxs(
|
|
342
|
+
"button",
|
|
343
|
+
{
|
|
344
|
+
type: "button",
|
|
345
|
+
role: "option",
|
|
346
|
+
"aria-selected": isActive,
|
|
347
|
+
dir: itemDir,
|
|
348
|
+
onClick: () => {
|
|
349
|
+
setLocale(l.code);
|
|
350
|
+
setOpen(false);
|
|
351
|
+
setSearch("");
|
|
352
|
+
},
|
|
353
|
+
className: cn(
|
|
354
|
+
"flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm transition-colors",
|
|
355
|
+
itemDir === "rtl" && "flex-row-reverse text-right",
|
|
356
|
+
isActive ? "bg-emerald-500/10 text-emerald-600 font-medium dark:text-emerald-400" : "text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-100"
|
|
357
|
+
),
|
|
358
|
+
children: [
|
|
359
|
+
showFlags && /* @__PURE__ */ jsx("span", { className: "text-base", children: (_a2 = l.flag) != null ? _a2 : getFlag(l.code) }),
|
|
360
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: resolveLabel(l) }),
|
|
361
|
+
isActive && /* @__PURE__ */ jsx(
|
|
362
|
+
"svg",
|
|
363
|
+
{
|
|
364
|
+
className: "size-4 text-emerald-600 dark:text-emerald-400",
|
|
365
|
+
fill: "none",
|
|
366
|
+
viewBox: "0 0 24 24",
|
|
367
|
+
stroke: "currentColor",
|
|
368
|
+
strokeWidth: 2,
|
|
369
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
|
370
|
+
}
|
|
371
|
+
)
|
|
372
|
+
]
|
|
373
|
+
},
|
|
374
|
+
l.code
|
|
375
|
+
);
|
|
376
|
+
}),
|
|
377
|
+
filtered.length === 0 && /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-zinc-500 dark:text-zinc-400", children: "No results" })
|
|
378
|
+
] })
|
|
379
|
+
]
|
|
380
|
+
}
|
|
381
|
+
)
|
|
382
|
+
] });
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
var COUNTRIES = [
|
|
386
|
+
{ code: "US", dialCode: "+1", name: "United States", flag: "\u{1F1FA}\u{1F1F8}" },
|
|
387
|
+
{ code: "GB", dialCode: "+44", name: "United Kingdom", flag: "\u{1F1EC}\u{1F1E7}" },
|
|
388
|
+
{ code: "IN", dialCode: "+91", name: "India", flag: "\u{1F1EE}\u{1F1F3}" },
|
|
389
|
+
{ code: "CA", dialCode: "+1", name: "Canada", flag: "\u{1F1E8}\u{1F1E6}" },
|
|
390
|
+
{ code: "AU", dialCode: "+61", name: "Australia", flag: "\u{1F1E6}\u{1F1FA}" },
|
|
391
|
+
{ code: "DE", dialCode: "+49", name: "Germany", flag: "\u{1F1E9}\u{1F1EA}" },
|
|
392
|
+
{ code: "FR", dialCode: "+33", name: "France", flag: "\u{1F1EB}\u{1F1F7}" },
|
|
393
|
+
{ code: "JP", dialCode: "+81", name: "Japan", flag: "\u{1F1EF}\u{1F1F5}" },
|
|
394
|
+
{ code: "BR", dialCode: "+55", name: "Brazil", flag: "\u{1F1E7}\u{1F1F7}" },
|
|
395
|
+
{ code: "CN", dialCode: "+86", name: "China", flag: "\u{1F1E8}\u{1F1F3}" },
|
|
396
|
+
{ code: "RU", dialCode: "+7", name: "Russia", flag: "\u{1F1F7}\u{1F1FA}" },
|
|
397
|
+
{ code: "KR", dialCode: "+82", name: "South Korea", flag: "\u{1F1F0}\u{1F1F7}" },
|
|
398
|
+
{ code: "IT", dialCode: "+39", name: "Italy", flag: "\u{1F1EE}\u{1F1F9}" },
|
|
399
|
+
{ code: "ES", dialCode: "+34", name: "Spain", flag: "\u{1F1EA}\u{1F1F8}" },
|
|
400
|
+
{ code: "MX", dialCode: "+52", name: "Mexico", flag: "\u{1F1F2}\u{1F1FD}" },
|
|
401
|
+
{ code: "NL", dialCode: "+31", name: "Netherlands", flag: "\u{1F1F3}\u{1F1F1}" },
|
|
402
|
+
{ code: "SE", dialCode: "+46", name: "Sweden", flag: "\u{1F1F8}\u{1F1EA}" },
|
|
403
|
+
{ code: "CH", dialCode: "+41", name: "Switzerland", flag: "\u{1F1E8}\u{1F1ED}" },
|
|
404
|
+
{ code: "PL", dialCode: "+48", name: "Poland", flag: "\u{1F1F5}\u{1F1F1}" },
|
|
405
|
+
{ code: "AR", dialCode: "+54", name: "Argentina", flag: "\u{1F1E6}\u{1F1F7}" },
|
|
406
|
+
{ code: "ZA", dialCode: "+27", name: "South Africa", flag: "\u{1F1FF}\u{1F1E6}" },
|
|
407
|
+
{ code: "NG", dialCode: "+234", name: "Nigeria", flag: "\u{1F1F3}\u{1F1EC}" },
|
|
408
|
+
{ code: "EG", dialCode: "+20", name: "Egypt", flag: "\u{1F1EA}\u{1F1EC}" },
|
|
409
|
+
{ code: "SA", dialCode: "+966", name: "Saudi Arabia", flag: "\u{1F1F8}\u{1F1E6}" },
|
|
410
|
+
{ code: "AE", dialCode: "+971", name: "United Arab Emirates", flag: "\u{1F1E6}\u{1F1EA}" },
|
|
411
|
+
{ code: "SG", dialCode: "+65", name: "Singapore", flag: "\u{1F1F8}\u{1F1EC}" },
|
|
412
|
+
{ code: "MY", dialCode: "+60", name: "Malaysia", flag: "\u{1F1F2}\u{1F1FE}" },
|
|
413
|
+
{ code: "TH", dialCode: "+66", name: "Thailand", flag: "\u{1F1F9}\u{1F1ED}" },
|
|
414
|
+
{ code: "PH", dialCode: "+63", name: "Philippines", flag: "\u{1F1F5}\u{1F1ED}" },
|
|
415
|
+
{ code: "ID", dialCode: "+62", name: "Indonesia", flag: "\u{1F1EE}\u{1F1E9}" },
|
|
416
|
+
{ code: "VN", dialCode: "+84", name: "Vietnam", flag: "\u{1F1FB}\u{1F1F3}" },
|
|
417
|
+
{ code: "TR", dialCode: "+90", name: "Turkey", flag: "\u{1F1F9}\u{1F1F7}" },
|
|
418
|
+
{ code: "PK", dialCode: "+92", name: "Pakistan", flag: "\u{1F1F5}\u{1F1F0}" },
|
|
419
|
+
{ code: "BD", dialCode: "+880", name: "Bangladesh", flag: "\u{1F1E7}\u{1F1E9}" },
|
|
420
|
+
{ code: "KE", dialCode: "+254", name: "Kenya", flag: "\u{1F1F0}\u{1F1EA}" },
|
|
421
|
+
{ code: "GH", dialCode: "+233", name: "Ghana", flag: "\u{1F1EC}\u{1F1ED}" },
|
|
422
|
+
{ code: "ET", dialCode: "+251", name: "Ethiopia", flag: "\u{1F1EA}\u{1F1F9}" },
|
|
423
|
+
{ code: "TZ", dialCode: "+255", name: "Tanzania", flag: "\u{1F1F9}\u{1F1FF}" },
|
|
424
|
+
{ code: "IL", dialCode: "+972", name: "Israel", flag: "\u{1F1EE}\u{1F1F1}" },
|
|
425
|
+
{ code: "HK", dialCode: "+852", name: "Hong Kong", flag: "\u{1F1ED}\u{1F1F0}" },
|
|
426
|
+
{ code: "NZ", dialCode: "+64", name: "New Zealand", flag: "\u{1F1F3}\u{1F1FF}" },
|
|
427
|
+
{ code: "IE", dialCode: "+353", name: "Ireland", flag: "\u{1F1EE}\u{1F1EA}" },
|
|
428
|
+
{ code: "PT", dialCode: "+351", name: "Portugal", flag: "\u{1F1F5}\u{1F1F9}" },
|
|
429
|
+
{ code: "CL", dialCode: "+56", name: "Chile", flag: "\u{1F1E8}\u{1F1F1}" },
|
|
430
|
+
{ code: "CO", dialCode: "+57", name: "Colombia", flag: "\u{1F1E8}\u{1F1F4}" },
|
|
431
|
+
{ code: "FI", dialCode: "+358", name: "Finland", flag: "\u{1F1EB}\u{1F1EE}" },
|
|
432
|
+
{ code: "NO", dialCode: "+47", name: "Norway", flag: "\u{1F1F3}\u{1F1F4}" },
|
|
433
|
+
{ code: "DK", dialCode: "+45", name: "Denmark", flag: "\u{1F1E9}\u{1F1F0}" },
|
|
434
|
+
{ code: "AT", dialCode: "+43", name: "Austria", flag: "\u{1F1E6}\u{1F1F9}" },
|
|
435
|
+
{ code: "BE", dialCode: "+32", name: "Belgium", flag: "\u{1F1E7}\u{1F1EA}" }
|
|
436
|
+
];
|
|
437
|
+
function getCountryByCode(code) {
|
|
438
|
+
return COUNTRIES.find((c) => c.code === code.toUpperCase());
|
|
439
|
+
}
|
|
440
|
+
var PhoneInput = React3.forwardRef(function PhoneInput2({
|
|
441
|
+
value,
|
|
442
|
+
defaultValue,
|
|
443
|
+
onValueChange,
|
|
444
|
+
onChange,
|
|
445
|
+
defaultCountry = "US",
|
|
446
|
+
placeholder = "Phone number",
|
|
447
|
+
disabled = false,
|
|
448
|
+
className,
|
|
449
|
+
showFlags,
|
|
450
|
+
showFlag,
|
|
451
|
+
label = "Phone number",
|
|
452
|
+
...rest
|
|
453
|
+
}, forwardedRef) {
|
|
454
|
+
var _a;
|
|
455
|
+
const flagsVisible = (_a = showFlags != null ? showFlags : showFlag) != null ? _a : true;
|
|
456
|
+
const [selectedCountry, setSelectedCountry] = React3.useState(
|
|
457
|
+
() => {
|
|
458
|
+
var _a2;
|
|
459
|
+
return (_a2 = getCountryByCode(defaultCountry)) != null ? _a2 : COUNTRIES[0];
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
const notify = onValueChange != null ? onValueChange : onChange;
|
|
463
|
+
const [inputValue, setInputValue] = useControllableState(value, defaultValue != null ? defaultValue : "", void 0);
|
|
464
|
+
const [open, setOpen] = React3.useState(false);
|
|
465
|
+
const [search, setSearch] = React3.useState("");
|
|
466
|
+
const ref = React3.useRef(null);
|
|
467
|
+
const inputRef = React3.useRef(null);
|
|
468
|
+
React3.useImperativeHandle(forwardedRef, () => inputRef.current);
|
|
469
|
+
const filtered = COUNTRIES.filter(
|
|
470
|
+
(c) => c.name.toLowerCase().includes(search.toLowerCase()) || c.dialCode.includes(search) || c.code.toLowerCase().includes(search.toLowerCase())
|
|
471
|
+
);
|
|
472
|
+
React3.useEffect(() => {
|
|
473
|
+
function handleClickOutside(e) {
|
|
474
|
+
if (ref.current && !ref.current.contains(e.target)) {
|
|
475
|
+
setOpen(false);
|
|
476
|
+
setSearch("");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
480
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
481
|
+
}, []);
|
|
482
|
+
React3.useEffect(() => {
|
|
483
|
+
var _a2;
|
|
484
|
+
if (open) (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
485
|
+
}, [open]);
|
|
486
|
+
React3.useEffect(() => {
|
|
487
|
+
function handleKeyDown(e) {
|
|
488
|
+
if (e.key === "Escape") {
|
|
489
|
+
setOpen(false);
|
|
490
|
+
setSearch("");
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
if (open) {
|
|
494
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
495
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
496
|
+
}
|
|
497
|
+
}, [open]);
|
|
498
|
+
const handleCountrySelect = (country) => {
|
|
499
|
+
var _a2;
|
|
500
|
+
setSelectedCountry(country);
|
|
501
|
+
setOpen(false);
|
|
502
|
+
setSearch("");
|
|
503
|
+
notify == null ? void 0 : notify(inputValue, country);
|
|
504
|
+
(_a2 = inputRef.current) == null ? void 0 : _a2.focus();
|
|
505
|
+
};
|
|
506
|
+
const handleInputChange = (e) => {
|
|
507
|
+
const newValue = e.target.value;
|
|
508
|
+
setInputValue(newValue);
|
|
509
|
+
notify == null ? void 0 : notify(newValue, selectedCountry);
|
|
510
|
+
};
|
|
511
|
+
return /* @__PURE__ */ jsxs("div", { ref, className: cn("relative inline-block text-sm", className), children: [
|
|
512
|
+
/* @__PURE__ */ jsxs(
|
|
513
|
+
"div",
|
|
514
|
+
{
|
|
515
|
+
className: cn(
|
|
516
|
+
"flex items-center overflow-hidden rounded-lg border transition-colors",
|
|
517
|
+
"bg-white border-zinc-200 dark:bg-zinc-900 dark:border-zinc-800",
|
|
518
|
+
disabled && "opacity-50 cursor-not-allowed"
|
|
519
|
+
),
|
|
520
|
+
children: [
|
|
521
|
+
/* @__PURE__ */ jsxs(
|
|
522
|
+
"button",
|
|
523
|
+
{
|
|
524
|
+
type: "button",
|
|
525
|
+
onClick: () => !disabled && setOpen(!open),
|
|
526
|
+
disabled,
|
|
527
|
+
className: cn(
|
|
528
|
+
"flex items-center gap-1.5 border-r px-3 py-2.5 text-sm transition-colors",
|
|
529
|
+
"border-zinc-200 text-zinc-900 hover:bg-zinc-100 hover:text-zinc-900 dark:border-zinc-800 dark:text-zinc-100 dark:hover:bg-zinc-800 dark:hover:text-zinc-100",
|
|
530
|
+
disabled && "cursor-not-allowed"
|
|
531
|
+
),
|
|
532
|
+
"aria-label": "Select country",
|
|
533
|
+
"aria-expanded": open,
|
|
534
|
+
"aria-haspopup": "listbox",
|
|
535
|
+
children: [
|
|
536
|
+
flagsVisible && /* @__PURE__ */ jsx("span", { className: "text-base leading-none", children: selectedCountry.flag }),
|
|
537
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: selectedCountry.dialCode }),
|
|
538
|
+
/* @__PURE__ */ jsx(
|
|
539
|
+
"svg",
|
|
540
|
+
{
|
|
541
|
+
className: cn(
|
|
542
|
+
"size-3 text-zinc-500 transition-transform dark:text-zinc-400",
|
|
543
|
+
open && "rotate-180"
|
|
544
|
+
),
|
|
545
|
+
fill: "none",
|
|
546
|
+
viewBox: "0 0 24 24",
|
|
547
|
+
stroke: "currentColor",
|
|
548
|
+
strokeWidth: 2,
|
|
549
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
550
|
+
}
|
|
551
|
+
)
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
/* @__PURE__ */ jsx(
|
|
556
|
+
"input",
|
|
557
|
+
{
|
|
558
|
+
ref: inputRef,
|
|
559
|
+
type: "tel",
|
|
560
|
+
value: inputValue,
|
|
561
|
+
onChange: handleInputChange,
|
|
562
|
+
placeholder,
|
|
563
|
+
disabled,
|
|
564
|
+
...rest,
|
|
565
|
+
className: cn(
|
|
566
|
+
"flex-1 bg-transparent px-3 py-2.5 text-sm outline-none placeholder:text-zinc-400 dark:placeholder:text-zinc-500",
|
|
567
|
+
"text-zinc-900 dark:text-zinc-100",
|
|
568
|
+
"focus:ring-1 focus:ring-emerald-500/50",
|
|
569
|
+
disabled && "cursor-not-allowed"
|
|
570
|
+
),
|
|
571
|
+
"aria-label": label
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
),
|
|
577
|
+
open && /* @__PURE__ */ jsxs(
|
|
578
|
+
"div",
|
|
579
|
+
{
|
|
580
|
+
className: "absolute z-50 mt-1 min-w-[280px] overflow-hidden rounded-xl border border-zinc-200 bg-white shadow-xl dark:border-zinc-800 dark:bg-zinc-950",
|
|
581
|
+
role: "listbox",
|
|
582
|
+
"aria-label": "Select country",
|
|
583
|
+
children: [
|
|
584
|
+
/* @__PURE__ */ jsx("div", { className: "border-b border-zinc-200 p-2 dark:border-zinc-800", children: /* @__PURE__ */ jsx(
|
|
585
|
+
"input",
|
|
586
|
+
{
|
|
587
|
+
ref: inputRef,
|
|
588
|
+
type: "text",
|
|
589
|
+
placeholder: "Search countries...",
|
|
590
|
+
value: search,
|
|
591
|
+
onChange: (e) => setSearch(e.target.value),
|
|
592
|
+
className: "w-full rounded-lg bg-zinc-100 px-3 py-1.5 text-sm text-zinc-900 outline-none placeholder:text-zinc-400 focus:ring-1 focus:ring-emerald-500/50 dark:bg-zinc-800 dark:text-zinc-100 dark:placeholder:text-zinc-500"
|
|
593
|
+
}
|
|
594
|
+
) }),
|
|
595
|
+
/* @__PURE__ */ jsxs("div", { className: "max-h-60 overflow-y-auto p-1", children: [
|
|
596
|
+
filtered.map((country) => {
|
|
597
|
+
const isActive = country.code === selectedCountry.code;
|
|
598
|
+
return /* @__PURE__ */ jsxs(
|
|
599
|
+
"button",
|
|
600
|
+
{
|
|
601
|
+
type: "button",
|
|
602
|
+
role: "option",
|
|
603
|
+
"aria-selected": isActive,
|
|
604
|
+
onClick: () => handleCountrySelect(country),
|
|
605
|
+
className: cn(
|
|
606
|
+
"flex w-full items-center gap-3 rounded-lg px-3 py-2 text-left text-sm transition-colors",
|
|
607
|
+
isActive ? "bg-emerald-500/10 text-emerald-600 font-medium dark:text-emerald-400" : "text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-100"
|
|
608
|
+
),
|
|
609
|
+
children: [
|
|
610
|
+
/* @__PURE__ */ jsx("span", { className: "text-base leading-none", children: country.flag }),
|
|
611
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: country.name }),
|
|
612
|
+
/* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-zinc-500 dark:text-zinc-400", children: country.dialCode }),
|
|
613
|
+
isActive && /* @__PURE__ */ jsx(
|
|
614
|
+
"svg",
|
|
615
|
+
{
|
|
616
|
+
className: "size-4 text-emerald-600 dark:text-emerald-400",
|
|
617
|
+
fill: "none",
|
|
618
|
+
viewBox: "0 0 24 24",
|
|
619
|
+
stroke: "currentColor",
|
|
620
|
+
strokeWidth: 2,
|
|
621
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
|
622
|
+
}
|
|
623
|
+
)
|
|
624
|
+
]
|
|
625
|
+
},
|
|
626
|
+
country.code
|
|
627
|
+
);
|
|
628
|
+
}),
|
|
629
|
+
filtered.length === 0 && /* @__PURE__ */ jsx("div", { className: "px-3 py-2 text-sm text-zinc-500 dark:text-zinc-400", children: "No countries found" })
|
|
630
|
+
] })
|
|
631
|
+
]
|
|
632
|
+
}
|
|
633
|
+
)
|
|
634
|
+
] });
|
|
635
|
+
});
|
|
636
|
+
var LOCALE_MAP = {
|
|
637
|
+
en: { label: "English", flag: "\u{1F1FA}\u{1F1F8}" },
|
|
638
|
+
fr: { label: "Fran\xE7ais", flag: "\u{1F1EB}\u{1F1F7}" },
|
|
639
|
+
es: { label: "Espa\xF1ol", flag: "\u{1F1EA}\u{1F1F8}" },
|
|
640
|
+
de: { label: "Deutsch", flag: "\u{1F1E9}\u{1F1EA}" },
|
|
641
|
+
ja: { label: "\u65E5\u672C\u8A9E", flag: "\u{1F1EF}\u{1F1F5}" },
|
|
642
|
+
ko: { label: "\uD55C\uAD6D\uC5B4", flag: "\u{1F1F0}\u{1F1F7}" },
|
|
643
|
+
zh: { label: "\u4E2D\u6587", flag: "\u{1F1E8}\u{1F1F3}" },
|
|
644
|
+
ar: { label: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629", flag: "\u{1F1F8}\u{1F1E6}" },
|
|
645
|
+
pt: { label: "Portugu\xEAs", flag: "\u{1F1E7}\u{1F1F7}" },
|
|
646
|
+
it: { label: "Italiano", flag: "\u{1F1EE}\u{1F1F9}" },
|
|
647
|
+
nl: { label: "Nederlands", flag: "\u{1F1F3}\u{1F1F1}" },
|
|
648
|
+
ru: { label: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439", flag: "\u{1F1F7}\u{1F1FA}" },
|
|
649
|
+
pl: { label: "Polski", flag: "\u{1F1F5}\u{1F1F1}" },
|
|
650
|
+
tr: { label: "T\xFCrk\xE7e", flag: "\u{1F1F9}\u{1F1F7}" },
|
|
651
|
+
vi: { label: "Ti\u1EBFng Vi\u1EC7t", flag: "\u{1F1FB}\u{1F1F3}" },
|
|
652
|
+
th: { label: "\u0E44\u0E17\u0E22", flag: "\u{1F1F9}\u{1F1ED}" },
|
|
653
|
+
id: { label: "Bahasa Indonesia", flag: "\u{1F1EE}\u{1F1E9}" },
|
|
654
|
+
hi: { label: "\u0939\u093F\u0928\u094D\u0926\u0940", flag: "\u{1F1EE}\u{1F1F3}" },
|
|
655
|
+
sv: { label: "Svenska", flag: "\u{1F1F8}\u{1F1EA}" },
|
|
656
|
+
da: { label: "Dansk", flag: "\u{1F1E9}\u{1F1F0}" },
|
|
657
|
+
fi: { label: "Suomi", flag: "\u{1F1EB}\u{1F1EE}" },
|
|
658
|
+
no: { label: "Norsk", flag: "\u{1F1F3}\u{1F1F4}" },
|
|
659
|
+
el: { label: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC", flag: "\u{1F1EC}\u{1F1F7}" },
|
|
660
|
+
he: { label: "\u05E2\u05D1\u05E8\u05D9\u05EA", flag: "\u{1F1EE}\u{1F1F1}" },
|
|
661
|
+
ro: { label: "Rom\xE2n\u0103", flag: "\u{1F1F7}\u{1F1F4}" },
|
|
662
|
+
hu: { label: "Magyar", flag: "\u{1F1ED}\u{1F1FA}" },
|
|
663
|
+
cs: { label: "\u010Ce\u0161tina", flag: "\u{1F1E8}\u{1F1FF}" },
|
|
664
|
+
uk: {
|
|
665
|
+
label: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",
|
|
666
|
+
flag: "\u{1F1FA}\u{1F1E6}"
|
|
667
|
+
},
|
|
668
|
+
bg: {
|
|
669
|
+
label: "\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438",
|
|
670
|
+
flag: "\u{1F1E7}\u{1F1EC}"
|
|
671
|
+
},
|
|
672
|
+
hr: { label: "Hrvatski", flag: "\u{1F1ED}\u{1F1F7}" },
|
|
673
|
+
sk: { label: "Sloven\u010Dina", flag: "\u{1F1F8}\u{1F1F0}" },
|
|
674
|
+
sl: { label: "Sloven\u0161\u010Dina", flag: "\u{1F1F8}\u{1F1EE}" },
|
|
675
|
+
lt: { label: "Lietuvi\u0173", flag: "\u{1F1F1}\u{1F1F9}" },
|
|
676
|
+
lv: { label: "Latvie\u0161u", flag: "\u{1F1F1}\u{1F1FB}" },
|
|
677
|
+
et: { label: "Eesti", flag: "\u{1F1EA}\u{1F1EA}" },
|
|
678
|
+
ca: { label: "Catal\xE0", flag: "\u{1F1E6}\u{1F1F8}" },
|
|
679
|
+
af: { label: "Afrikaans", flag: "\u{1F1E6}\u{1F1FF}" },
|
|
680
|
+
sw: { label: "Kiswahili", flag: "\u{1F1F9}\u{1F1FF}" }
|
|
681
|
+
};
|
|
682
|
+
function getLocaleInfo(code) {
|
|
683
|
+
var _a;
|
|
684
|
+
return (_a = LOCALE_MAP[code]) != null ? _a : { label: code.toUpperCase(), flag: "\u{1F310}" };
|
|
685
|
+
}
|
|
686
|
+
var NavBar = React3.forwardRef(function NavBar2({
|
|
687
|
+
logo,
|
|
688
|
+
links = [],
|
|
689
|
+
locales = [],
|
|
690
|
+
value,
|
|
691
|
+
defaultValue,
|
|
692
|
+
onValueChange,
|
|
693
|
+
currentLocale,
|
|
694
|
+
onLocaleChange,
|
|
695
|
+
cta,
|
|
696
|
+
showGitHub = false,
|
|
697
|
+
githubUrl = "https://github.com/babelize/babelize-elements",
|
|
698
|
+
sticky = true,
|
|
699
|
+
className,
|
|
700
|
+
showFlags = true,
|
|
701
|
+
linkComponent: Link = "a",
|
|
702
|
+
...rest
|
|
703
|
+
}, forwardedRef) {
|
|
704
|
+
const [locale, setLocale] = useControllableState(
|
|
705
|
+
value != null ? value : currentLocale,
|
|
706
|
+
defaultValue != null ? defaultValue : "en",
|
|
707
|
+
onValueChange != null ? onValueChange : onLocaleChange
|
|
708
|
+
);
|
|
709
|
+
const [mobileOpen, setMobileOpen] = React3.useState(false);
|
|
710
|
+
const [langOpen, setLangOpen] = React3.useState(false);
|
|
711
|
+
const langRef = React3.useRef(null);
|
|
712
|
+
const mobileLangRef = React3.useRef(null);
|
|
713
|
+
const currentLocaleInfo = getLocaleInfo(locale);
|
|
714
|
+
React3.useEffect(() => {
|
|
715
|
+
function handleClickOutside(e) {
|
|
716
|
+
if (langRef.current && !langRef.current.contains(e.target)) {
|
|
717
|
+
setLangOpen(false);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
721
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
722
|
+
}, []);
|
|
723
|
+
React3.useEffect(() => {
|
|
724
|
+
if (mobileOpen) {
|
|
725
|
+
document.body.style.overflow = "hidden";
|
|
726
|
+
} else {
|
|
727
|
+
document.body.style.overflow = "";
|
|
728
|
+
}
|
|
729
|
+
return () => {
|
|
730
|
+
document.body.style.overflow = "";
|
|
731
|
+
};
|
|
732
|
+
}, [mobileOpen]);
|
|
733
|
+
const langButton = /* @__PURE__ */ jsxs(
|
|
734
|
+
"button",
|
|
735
|
+
{
|
|
736
|
+
type: "button",
|
|
737
|
+
onClick: () => setLangOpen(!langOpen),
|
|
738
|
+
className: "flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-sm font-medium text-zinc-500 transition-colors hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-50",
|
|
739
|
+
"aria-expanded": langOpen,
|
|
740
|
+
"aria-haspopup": "listbox",
|
|
741
|
+
"aria-label": `Current language: ${currentLocaleInfo.label}`,
|
|
742
|
+
children: [
|
|
743
|
+
showFlags && /* @__PURE__ */ jsx("span", { className: "text-sm leading-none", children: currentLocaleInfo.flag }),
|
|
744
|
+
/* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: currentLocaleInfo.label }),
|
|
745
|
+
/* @__PURE__ */ jsx(
|
|
746
|
+
"svg",
|
|
747
|
+
{
|
|
748
|
+
className: cn(
|
|
749
|
+
"size-3 text-zinc-500 transition-transform dark:text-zinc-400",
|
|
750
|
+
langOpen && "rotate-180"
|
|
751
|
+
),
|
|
752
|
+
fill: "none",
|
|
753
|
+
viewBox: "0 0 24 24",
|
|
754
|
+
stroke: "currentColor",
|
|
755
|
+
strokeWidth: 2,
|
|
756
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
757
|
+
}
|
|
758
|
+
)
|
|
759
|
+
]
|
|
760
|
+
}
|
|
761
|
+
);
|
|
762
|
+
const langDropdown = /* @__PURE__ */ jsx(
|
|
763
|
+
"div",
|
|
764
|
+
{
|
|
765
|
+
className: "absolute right-0 top-full z-50 mt-1.5 min-w-[170px] rounded-xl border border-zinc-200 bg-white py-1.5 shadow-xl dark:border-zinc-800 dark:bg-zinc-950",
|
|
766
|
+
role: "listbox",
|
|
767
|
+
"aria-label": "Select language",
|
|
768
|
+
children: locales.map((item) => {
|
|
769
|
+
var _a;
|
|
770
|
+
const info = getLocaleInfo(item.code);
|
|
771
|
+
const isActive = item.code === locale;
|
|
772
|
+
return /* @__PURE__ */ jsxs(
|
|
773
|
+
"button",
|
|
774
|
+
{
|
|
775
|
+
type: "button",
|
|
776
|
+
role: "option",
|
|
777
|
+
"aria-selected": isActive,
|
|
778
|
+
onClick: () => {
|
|
779
|
+
setLocale(item.code);
|
|
780
|
+
setLangOpen(false);
|
|
781
|
+
},
|
|
782
|
+
className: cn(
|
|
783
|
+
"flex w-full items-center gap-2.5 px-3 py-2 text-sm rounded-lg mx-1.5 w-[calc(100%-12px)] transition-colors",
|
|
784
|
+
isActive ? "bg-emerald-500/10 text-emerald-600 font-medium dark:text-emerald-400" : "text-zinc-500 hover:bg-zinc-100 hover:text-zinc-900 dark:text-zinc-400 dark:hover:bg-zinc-800 dark:hover:text-zinc-100"
|
|
785
|
+
),
|
|
786
|
+
children: [
|
|
787
|
+
showFlags && /* @__PURE__ */ jsx("span", { className: "text-base leading-none", children: info.flag }),
|
|
788
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: (_a = item.label) != null ? _a : info.label }),
|
|
789
|
+
isActive && /* @__PURE__ */ jsx(
|
|
790
|
+
"svg",
|
|
791
|
+
{
|
|
792
|
+
className: "size-4 shrink-0 text-emerald-600 dark:text-emerald-400",
|
|
793
|
+
fill: "none",
|
|
794
|
+
viewBox: "0 0 24 24",
|
|
795
|
+
stroke: "currentColor",
|
|
796
|
+
strokeWidth: 2.5,
|
|
797
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
|
798
|
+
}
|
|
799
|
+
)
|
|
800
|
+
]
|
|
801
|
+
},
|
|
802
|
+
item.code
|
|
803
|
+
);
|
|
804
|
+
})
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
return /* @__PURE__ */ jsxs(
|
|
808
|
+
"nav",
|
|
809
|
+
{
|
|
810
|
+
ref: forwardedRef,
|
|
811
|
+
...rest,
|
|
812
|
+
className: cn(
|
|
813
|
+
"z-50 w-full border-b border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900",
|
|
814
|
+
sticky && "sticky top-0",
|
|
815
|
+
className
|
|
816
|
+
),
|
|
817
|
+
children: [
|
|
818
|
+
/* @__PURE__ */ jsxs("div", { className: "mx-auto hidden max-w-6xl items-center justify-between px-5 py-3 md:flex", children: [
|
|
819
|
+
logo && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: logo }),
|
|
820
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: links.map((link) => /* @__PURE__ */ jsx(
|
|
821
|
+
Link,
|
|
822
|
+
{
|
|
823
|
+
href: link.href,
|
|
824
|
+
className: "px-3 py-1.5 text-sm transition-colors rounded-md no-underline text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-50",
|
|
825
|
+
children: link.label
|
|
826
|
+
},
|
|
827
|
+
link.href
|
|
828
|
+
)) }),
|
|
829
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
830
|
+
locales.length > 0 && /* @__PURE__ */ jsxs("div", { ref: langRef, className: "relative", children: [
|
|
831
|
+
langButton,
|
|
832
|
+
langOpen && langDropdown
|
|
833
|
+
] }),
|
|
834
|
+
showGitHub && /* @__PURE__ */ jsx(
|
|
835
|
+
"a",
|
|
836
|
+
{
|
|
837
|
+
href: githubUrl,
|
|
838
|
+
target: "_blank",
|
|
839
|
+
rel: "noopener noreferrer",
|
|
840
|
+
className: "inline-flex size-8 items-center justify-center rounded-md transition-colors no-underline text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-50",
|
|
841
|
+
"aria-label": "GitHub",
|
|
842
|
+
children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" }) })
|
|
843
|
+
}
|
|
844
|
+
),
|
|
845
|
+
cta && /* @__PURE__ */ jsx(
|
|
846
|
+
Link,
|
|
847
|
+
{
|
|
848
|
+
href: cta.href,
|
|
849
|
+
className: "rounded-md px-3.5 py-1.5 text-sm font-medium transition-colors no-underline bg-emerald-500 text-white hover:opacity-90",
|
|
850
|
+
children: cta.label
|
|
851
|
+
}
|
|
852
|
+
)
|
|
853
|
+
] })
|
|
854
|
+
] }),
|
|
855
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between px-4 py-3 md:hidden", children: [
|
|
856
|
+
logo && /* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: logo }),
|
|
857
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
858
|
+
locales.length > 0 && /* @__PURE__ */ jsxs("div", { ref: mobileLangRef, className: "relative", children: [
|
|
859
|
+
/* @__PURE__ */ jsx(
|
|
860
|
+
"button",
|
|
861
|
+
{
|
|
862
|
+
type: "button",
|
|
863
|
+
onClick: () => setLangOpen(!langOpen),
|
|
864
|
+
className: "inline-flex size-8 items-center justify-center rounded-md transition-colors text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-50",
|
|
865
|
+
"aria-label": `Current language: ${currentLocaleInfo.label}`,
|
|
866
|
+
children: showFlags && /* @__PURE__ */ jsx("span", { className: "text-base leading-none", children: currentLocaleInfo.flag })
|
|
867
|
+
}
|
|
868
|
+
),
|
|
869
|
+
langOpen && langDropdown
|
|
870
|
+
] }),
|
|
871
|
+
/* @__PURE__ */ jsx(
|
|
872
|
+
"button",
|
|
873
|
+
{
|
|
874
|
+
className: "inline-flex size-8 items-center justify-center rounded-md transition-colors text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-50",
|
|
875
|
+
onClick: () => setMobileOpen(!mobileOpen),
|
|
876
|
+
"aria-label": "Toggle menu",
|
|
877
|
+
children: mobileOpen ? /* @__PURE__ */ jsx(
|
|
878
|
+
"svg",
|
|
879
|
+
{
|
|
880
|
+
className: "size-4",
|
|
881
|
+
fill: "none",
|
|
882
|
+
viewBox: "0 0 24 24",
|
|
883
|
+
stroke: "currentColor",
|
|
884
|
+
strokeWidth: 2,
|
|
885
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
|
|
886
|
+
}
|
|
887
|
+
) : /* @__PURE__ */ jsx(
|
|
888
|
+
"svg",
|
|
889
|
+
{
|
|
890
|
+
className: "size-4",
|
|
891
|
+
fill: "none",
|
|
892
|
+
viewBox: "0 0 24 24",
|
|
893
|
+
stroke: "currentColor",
|
|
894
|
+
strokeWidth: 2,
|
|
895
|
+
children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 6h16M4 12h16M4 18h16" })
|
|
896
|
+
}
|
|
897
|
+
)
|
|
898
|
+
}
|
|
899
|
+
)
|
|
900
|
+
] })
|
|
901
|
+
] }),
|
|
902
|
+
mobileOpen && /* @__PURE__ */ jsxs("div", { className: "border-t border-zinc-200 bg-white px-4 py-3 md:hidden dark:border-zinc-800 dark:bg-zinc-900", children: [
|
|
903
|
+
links.map((link) => /* @__PURE__ */ jsx(
|
|
904
|
+
Link,
|
|
905
|
+
{
|
|
906
|
+
href: link.href,
|
|
907
|
+
onClick: () => setMobileOpen(false),
|
|
908
|
+
className: "block py-2.5 text-sm transition-colors no-underline text-zinc-500 hover:text-zinc-900 dark:text-zinc-400 dark:hover:text-zinc-50",
|
|
909
|
+
children: link.label
|
|
910
|
+
},
|
|
911
|
+
link.href
|
|
912
|
+
)),
|
|
913
|
+
cta && /* @__PURE__ */ jsx(
|
|
914
|
+
Link,
|
|
915
|
+
{
|
|
916
|
+
href: cta.href,
|
|
917
|
+
onClick: () => setMobileOpen(false),
|
|
918
|
+
className: "mt-2 block rounded-md px-3.5 py-2 text-center text-sm font-medium transition-colors no-underline bg-emerald-500 text-white hover:opacity-90",
|
|
919
|
+
children: cta.label
|
|
920
|
+
}
|
|
921
|
+
)
|
|
922
|
+
] })
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
);
|
|
926
|
+
});
|
|
927
|
+
|
|
928
|
+
export { COUNTRIES, LanguageSwitcher, NavBar, PhoneInput, cn };
|
|
929
|
+
//# sourceMappingURL=index.js.map
|
|
930
|
+
//# sourceMappingURL=index.js.map
|