@babelize/elements 1.1.1 → 1.1.3

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/dist/index.js CHANGED
@@ -1,21 +1,26 @@
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';
1
+ "use client";
5
2
 
6
3
  // src/lib/utils.ts
4
+ import { clsx } from "clsx";
5
+ import { twMerge } from "tailwind-merge";
7
6
  function cn(...inputs) {
8
7
  return twMerge(clsx(inputs));
9
8
  }
9
+
10
+ // src/registry/components/language-switcher.tsx
11
+ import * as React2 from "react";
12
+
13
+ // src/lib/use-controllable-state.ts
14
+ import * as React from "react";
10
15
  function useControllableState(value, defaultValue, onChange) {
11
16
  const isControlled = value !== void 0;
12
- const [uncontrolled, setUncontrolled] = React3.useState(defaultValue);
13
- const onChangeRef = React3.useRef(onChange);
14
- React3.useEffect(() => {
17
+ const [uncontrolled, setUncontrolled] = React.useState(defaultValue);
18
+ const onChangeRef = React.useRef(onChange);
19
+ React.useEffect(() => {
15
20
  onChangeRef.current = onChange;
16
21
  }, [onChange]);
17
22
  const current = isControlled ? value : uncontrolled;
18
- const setValue = React3.useCallback(
23
+ const setValue = React.useCallback(
19
24
  (next) => {
20
25
  var _a;
21
26
  if (!isControlled) setUncontrolled(next);
@@ -25,6 +30,9 @@ function useControllableState(value, defaultValue, onChange) {
25
30
  );
26
31
  return [current, setValue];
27
32
  }
33
+
34
+ // src/registry/components/language-switcher.tsx
35
+ import { jsx, jsxs } from "react/jsx-runtime";
28
36
  var RTL_LOCALES = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "sd", "yi"]);
29
37
  function isRtl(code) {
30
38
  const lang = code.split("-")[0].toLowerCase();
@@ -225,7 +233,7 @@ function getLabel(code, mode) {
225
233
  if (!names) return code;
226
234
  return mode === "native" ? names[0] : names[1];
227
235
  }
228
- var LanguageSwitcher = React3.forwardRef(
236
+ var LanguageSwitcher = React2.forwardRef(
229
237
  function LanguageSwitcher2({
230
238
  locales,
231
239
  value,
@@ -242,11 +250,11 @@ var LanguageSwitcher = React3.forwardRef(
242
250
  (_b = defaultValue != null ? defaultValue : (_a = locales[0]) == null ? void 0 : _a.code) != null ? _b : "",
243
251
  onValueChange
244
252
  );
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);
253
+ const [open, setOpen] = React2.useState(false);
254
+ const [search, setSearch] = React2.useState("");
255
+ const ref = React2.useRef(null);
256
+ const inputRef = React2.useRef(null);
257
+ React2.useImperativeHandle(forwardedRef, () => ref.current);
250
258
  const resolveLabel = (l) => {
251
259
  var _a2;
252
260
  return (_a2 = l.label) != null ? _a2 : getLabel(l.code, labelMode);
@@ -256,7 +264,7 @@ var LanguageSwitcher = React3.forwardRef(
256
264
  (l) => resolveLabel(l).toLowerCase().includes(search.toLowerCase()) || l.code.toLowerCase().includes(search.toLowerCase())
257
265
  );
258
266
  const dir = isRtl(locale) ? "rtl" : "ltr";
259
- React3.useEffect(() => {
267
+ React2.useEffect(() => {
260
268
  function handleClickOutside(e) {
261
269
  if (ref.current && !ref.current.contains(e.target)) {
262
270
  setOpen(false);
@@ -266,11 +274,11 @@ var LanguageSwitcher = React3.forwardRef(
266
274
  document.addEventListener("mousedown", handleClickOutside);
267
275
  return () => document.removeEventListener("mousedown", handleClickOutside);
268
276
  }, []);
269
- React3.useEffect(() => {
277
+ React2.useEffect(() => {
270
278
  var _a2;
271
279
  if (open) (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
272
280
  }, [open]);
273
- React3.useEffect(() => {
281
+ React2.useEffect(() => {
274
282
  function handleKeyDown(e) {
275
283
  if (e.key === "Escape") {
276
284
  setOpen(false);
@@ -328,6 +336,7 @@ var LanguageSwitcher = React3.forwardRef(
328
336
  ref: inputRef,
329
337
  type: "text",
330
338
  placeholder: "Search...",
339
+ "aria-label": "Search languages",
331
340
  value: search,
332
341
  onChange: (e) => setSearch(e.target.value),
333
342
  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"
@@ -382,6 +391,10 @@ var LanguageSwitcher = React3.forwardRef(
382
391
  ] });
383
392
  }
384
393
  );
394
+
395
+ // src/registry/components/phone-input.tsx
396
+ import * as React3 from "react";
397
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
385
398
  var COUNTRIES = [
386
399
  { code: "US", dialCode: "+1", name: "United States", flag: "\u{1F1FA}\u{1F1F8}" },
387
400
  { code: "GB", dialCode: "+44", name: "United Kingdom", flag: "\u{1F1EC}\u{1F1E7}" },
@@ -441,30 +454,26 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
441
454
  value,
442
455
  defaultValue,
443
456
  onValueChange,
444
- onChange,
445
457
  defaultCountry = "US",
446
458
  placeholder = "Phone number",
447
459
  disabled = false,
448
460
  className,
449
- showFlags,
450
- showFlag,
461
+ showFlags = true,
451
462
  label = "Phone number",
452
463
  ...rest
453
464
  }, forwardedRef) {
454
- var _a;
455
- const flagsVisible = (_a = showFlags != null ? showFlags : showFlag) != null ? _a : true;
456
465
  const [selectedCountry, setSelectedCountry] = React3.useState(
457
466
  () => {
458
- var _a2;
459
- return (_a2 = getCountryByCode(defaultCountry)) != null ? _a2 : COUNTRIES[0];
467
+ var _a;
468
+ return (_a = getCountryByCode(defaultCountry)) != null ? _a : COUNTRIES[0];
460
469
  }
461
470
  );
462
- const notify = onValueChange != null ? onValueChange : onChange;
463
471
  const [inputValue, setInputValue] = useControllableState(value, defaultValue != null ? defaultValue : "", void 0);
464
472
  const [open, setOpen] = React3.useState(false);
465
473
  const [search, setSearch] = React3.useState("");
466
474
  const ref = React3.useRef(null);
467
475
  const inputRef = React3.useRef(null);
476
+ const searchRef = React3.useRef(null);
468
477
  React3.useImperativeHandle(forwardedRef, () => inputRef.current);
469
478
  const filtered = COUNTRIES.filter(
470
479
  (c) => c.name.toLowerCase().includes(search.toLowerCase()) || c.dialCode.includes(search) || c.code.toLowerCase().includes(search.toLowerCase())
@@ -480,8 +489,8 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
480
489
  return () => document.removeEventListener("mousedown", handleClickOutside);
481
490
  }, []);
482
491
  React3.useEffect(() => {
483
- var _a2;
484
- if (open) (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
492
+ var _a;
493
+ if (open) (_a = searchRef.current) == null ? void 0 : _a.focus();
485
494
  }, [open]);
486
495
  React3.useEffect(() => {
487
496
  function handleKeyDown(e) {
@@ -496,20 +505,20 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
496
505
  }
497
506
  }, [open]);
498
507
  const handleCountrySelect = (country) => {
499
- var _a2;
508
+ var _a;
500
509
  setSelectedCountry(country);
501
510
  setOpen(false);
502
511
  setSearch("");
503
- notify == null ? void 0 : notify(inputValue, country);
504
- (_a2 = inputRef.current) == null ? void 0 : _a2.focus();
512
+ onValueChange == null ? void 0 : onValueChange(inputValue, country);
513
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
505
514
  };
506
515
  const handleInputChange = (e) => {
507
516
  const newValue = e.target.value;
508
517
  setInputValue(newValue);
509
- notify == null ? void 0 : notify(newValue, selectedCountry);
518
+ onValueChange == null ? void 0 : onValueChange(newValue, selectedCountry);
510
519
  };
511
- return /* @__PURE__ */ jsxs("div", { ref, className: cn("relative inline-block text-sm", className), children: [
512
- /* @__PURE__ */ jsxs(
520
+ return /* @__PURE__ */ jsxs2("div", { ref, className: cn("relative inline-block text-sm", className), children: [
521
+ /* @__PURE__ */ jsxs2(
513
522
  "div",
514
523
  {
515
524
  className: cn(
@@ -518,7 +527,7 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
518
527
  disabled && "opacity-50 cursor-not-allowed"
519
528
  ),
520
529
  children: [
521
- /* @__PURE__ */ jsxs(
530
+ /* @__PURE__ */ jsxs2(
522
531
  "button",
523
532
  {
524
533
  type: "button",
@@ -533,9 +542,9 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
533
542
  "aria-expanded": open,
534
543
  "aria-haspopup": "listbox",
535
544
  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(
545
+ showFlags && /* @__PURE__ */ jsx2("span", { className: "text-base leading-none", children: selectedCountry.flag }),
546
+ /* @__PURE__ */ jsx2("span", { className: "font-mono text-xs", children: selectedCountry.dialCode }),
547
+ /* @__PURE__ */ jsx2(
539
548
  "svg",
540
549
  {
541
550
  className: cn(
@@ -546,13 +555,13 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
546
555
  viewBox: "0 0 24 24",
547
556
  stroke: "currentColor",
548
557
  strokeWidth: 2,
549
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
558
+ children: /* @__PURE__ */ jsx2("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
550
559
  }
551
560
  )
552
561
  ]
553
562
  }
554
563
  ),
555
- /* @__PURE__ */ jsx(
564
+ /* @__PURE__ */ jsx2(
556
565
  "input",
557
566
  {
558
567
  ref: inputRef,
@@ -574,28 +583,29 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
574
583
  ]
575
584
  }
576
585
  ),
577
- open && /* @__PURE__ */ jsxs(
586
+ open && /* @__PURE__ */ jsxs2(
578
587
  "div",
579
588
  {
580
589
  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
590
  role: "listbox",
582
591
  "aria-label": "Select country",
583
592
  children: [
584
- /* @__PURE__ */ jsx("div", { className: "border-b border-zinc-200 p-2 dark:border-zinc-800", children: /* @__PURE__ */ jsx(
593
+ /* @__PURE__ */ jsx2("div", { className: "border-b border-zinc-200 p-2 dark:border-zinc-800", children: /* @__PURE__ */ jsx2(
585
594
  "input",
586
595
  {
587
- ref: inputRef,
596
+ ref: searchRef,
588
597
  type: "text",
589
598
  placeholder: "Search countries...",
599
+ "aria-label": "Search countries",
590
600
  value: search,
591
601
  onChange: (e) => setSearch(e.target.value),
592
602
  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
603
  }
594
604
  ) }),
595
- /* @__PURE__ */ jsxs("div", { className: "max-h-60 overflow-y-auto p-1", children: [
605
+ /* @__PURE__ */ jsxs2("div", { className: "max-h-60 overflow-y-auto p-1", children: [
596
606
  filtered.map((country) => {
597
607
  const isActive = country.code === selectedCountry.code;
598
- return /* @__PURE__ */ jsxs(
608
+ return /* @__PURE__ */ jsxs2(
599
609
  "button",
600
610
  {
601
611
  type: "button",
@@ -607,10 +617,10 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
607
617
  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
618
  ),
609
619
  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(
620
+ /* @__PURE__ */ jsx2("span", { className: "text-base leading-none", children: country.flag }),
621
+ /* @__PURE__ */ jsx2("span", { className: "flex-1", children: country.name }),
622
+ /* @__PURE__ */ jsx2("span", { className: "font-mono text-xs text-zinc-500 dark:text-zinc-400", children: country.dialCode }),
623
+ isActive && /* @__PURE__ */ jsx2(
614
624
  "svg",
615
625
  {
616
626
  className: "size-4 text-emerald-600 dark:text-emerald-400",
@@ -618,7 +628,7 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
618
628
  viewBox: "0 0 24 24",
619
629
  stroke: "currentColor",
620
630
  strokeWidth: 2,
621
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
631
+ children: /* @__PURE__ */ jsx2("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
622
632
  }
623
633
  )
624
634
  ]
@@ -626,13 +636,17 @@ var PhoneInput = React3.forwardRef(function PhoneInput2({
626
636
  country.code
627
637
  );
628
638
  }),
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" })
639
+ filtered.length === 0 && /* @__PURE__ */ jsx2("div", { className: "px-3 py-2 text-sm text-zinc-500 dark:text-zinc-400", children: "No countries found" })
630
640
  ] })
631
641
  ]
632
642
  }
633
643
  )
634
644
  ] });
635
645
  });
646
+
647
+ // src/registry/components/navbar.tsx
648
+ import * as React4 from "react";
649
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
636
650
  var LOCALE_MAP = {
637
651
  en: { label: "English", flag: "\u{1F1FA}\u{1F1F8}" },
638
652
  fr: { label: "Fran\xE7ais", flag: "\u{1F1EB}\u{1F1F7}" },
@@ -683,15 +697,13 @@ function getLocaleInfo(code) {
683
697
  var _a;
684
698
  return (_a = LOCALE_MAP[code]) != null ? _a : { label: code.toUpperCase(), flag: "\u{1F310}" };
685
699
  }
686
- var NavBar = React3.forwardRef(function NavBar2({
700
+ var NavBar = React4.forwardRef(function NavBar2({
687
701
  logo,
688
702
  links = [],
689
703
  locales = [],
690
704
  value,
691
705
  defaultValue,
692
706
  onValueChange,
693
- currentLocale,
694
- onLocaleChange,
695
707
  cta,
696
708
  showGitHub = false,
697
709
  githubUrl = "https://github.com/babelize/babelize-elements",
@@ -701,75 +713,85 @@ var NavBar = React3.forwardRef(function NavBar2({
701
713
  linkComponent: Link = "a",
702
714
  ...rest
703
715
  }, forwardedRef) {
716
+ var _a, _b;
704
717
  const [locale, setLocale] = useControllableState(
705
- value != null ? value : currentLocale,
706
- defaultValue != null ? defaultValue : "en",
707
- onValueChange != null ? onValueChange : onLocaleChange
718
+ value,
719
+ (_b = defaultValue != null ? defaultValue : (_a = locales[0]) == null ? void 0 : _a.code) != null ? _b : "en",
720
+ onValueChange
708
721
  );
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);
722
+ const [mobileOpen, setMobileOpen] = React4.useState(false);
723
+ const [langOpen, setLangOpen] = React4.useState(null);
724
+ const langRef = React4.useRef(null);
725
+ const mobileLangRef = React4.useRef(null);
726
+ const menuId = React4.useId();
713
727
  const currentLocaleInfo = getLocaleInfo(locale);
714
- React3.useEffect(() => {
728
+ React4.useEffect(() => {
715
729
  function handleClickOutside(e) {
716
- if (langRef.current && !langRef.current.contains(e.target)) {
717
- setLangOpen(false);
718
- }
730
+ var _a2, _b2;
731
+ const target = e.target;
732
+ if (((_a2 = langRef.current) == null ? void 0 : _a2.contains(target)) || ((_b2 = mobileLangRef.current) == null ? void 0 : _b2.contains(target))) return;
733
+ setLangOpen(null);
719
734
  }
720
735
  document.addEventListener("mousedown", handleClickOutside);
721
736
  return () => document.removeEventListener("mousedown", handleClickOutside);
722
737
  }, []);
723
- React3.useEffect(() => {
724
- if (mobileOpen) {
725
- document.body.style.overflow = "hidden";
726
- } else {
727
- document.body.style.overflow = "";
738
+ React4.useEffect(() => {
739
+ function handleKeyDown(e) {
740
+ if (e.key !== "Escape") return;
741
+ setLangOpen(null);
742
+ setMobileOpen(false);
728
743
  }
744
+ document.addEventListener("keydown", handleKeyDown);
745
+ return () => document.removeEventListener("keydown", handleKeyDown);
746
+ }, []);
747
+ React4.useEffect(() => {
748
+ if (!mobileOpen) return;
749
+ const previous = document.body.style.overflow;
750
+ document.body.style.overflow = "hidden";
729
751
  return () => {
730
- document.body.style.overflow = "";
752
+ document.body.style.overflow = previous;
731
753
  };
732
754
  }, [mobileOpen]);
733
- const langButton = /* @__PURE__ */ jsxs(
755
+ const langButton = /* @__PURE__ */ jsxs3(
734
756
  "button",
735
757
  {
736
758
  type: "button",
737
- onClick: () => setLangOpen(!langOpen),
759
+ onClick: () => setLangOpen(langOpen === "desktop" ? null : "desktop"),
738
760
  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,
761
+ "aria-expanded": langOpen === "desktop",
740
762
  "aria-haspopup": "listbox",
741
763
  "aria-label": `Current language: ${currentLocaleInfo.label}`,
742
764
  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(
765
+ showFlags && /* @__PURE__ */ jsx3("span", { className: "text-sm leading-none", children: currentLocaleInfo.flag }),
766
+ /* @__PURE__ */ jsx3("span", { className: "hidden sm:inline", children: currentLocaleInfo.label }),
767
+ /* @__PURE__ */ jsx3(
746
768
  "svg",
747
769
  {
748
770
  className: cn(
749
771
  "size-3 text-zinc-500 transition-transform dark:text-zinc-400",
750
- langOpen && "rotate-180"
772
+ langOpen === "desktop" && "rotate-180"
751
773
  ),
752
774
  fill: "none",
753
775
  viewBox: "0 0 24 24",
754
776
  stroke: "currentColor",
755
777
  strokeWidth: 2,
756
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
778
+ children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
757
779
  }
758
780
  )
759
781
  ]
760
782
  }
761
783
  );
762
- const langDropdown = /* @__PURE__ */ jsx(
784
+ const langDropdown = /* @__PURE__ */ jsx3(
763
785
  "div",
764
786
  {
765
787
  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
788
  role: "listbox",
767
789
  "aria-label": "Select language",
768
790
  children: locales.map((item) => {
769
- var _a;
791
+ var _a2;
770
792
  const info = getLocaleInfo(item.code);
771
793
  const isActive = item.code === locale;
772
- return /* @__PURE__ */ jsxs(
794
+ return /* @__PURE__ */ jsxs3(
773
795
  "button",
774
796
  {
775
797
  type: "button",
@@ -777,16 +799,16 @@ var NavBar = React3.forwardRef(function NavBar2({
777
799
  "aria-selected": isActive,
778
800
  onClick: () => {
779
801
  setLocale(item.code);
780
- setLangOpen(false);
802
+ setLangOpen(null);
781
803
  },
782
804
  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",
805
+ "mx-1.5 flex w-[calc(100%-12px)] items-center gap-2.5 rounded-lg px-3 py-2 text-sm transition-colors",
784
806
  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
807
  ),
786
808
  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(
809
+ showFlags && /* @__PURE__ */ jsx3("span", { className: "text-base leading-none", children: info.flag }),
810
+ /* @__PURE__ */ jsx3("span", { className: "flex-1", children: (_a2 = item.label) != null ? _a2 : info.label }),
811
+ isActive && /* @__PURE__ */ jsx3(
790
812
  "svg",
791
813
  {
792
814
  className: "size-4 shrink-0 text-emerald-600 dark:text-emerald-400",
@@ -794,7 +816,7 @@ var NavBar = React3.forwardRef(function NavBar2({
794
816
  viewBox: "0 0 24 24",
795
817
  stroke: "currentColor",
796
818
  strokeWidth: 2.5,
797
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
819
+ children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
798
820
  }
799
821
  )
800
822
  ]
@@ -804,7 +826,7 @@ var NavBar = React3.forwardRef(function NavBar2({
804
826
  })
805
827
  }
806
828
  );
807
- return /* @__PURE__ */ jsxs(
829
+ return /* @__PURE__ */ jsxs3(
808
830
  "nav",
809
831
  {
810
832
  ref: forwardedRef,
@@ -815,9 +837,9 @@ var NavBar = React3.forwardRef(function NavBar2({
815
837
  className
816
838
  ),
817
839
  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(
840
+ /* @__PURE__ */ jsxs3("div", { className: "mx-auto hidden max-w-6xl items-center justify-between px-5 py-3 md:flex", children: [
841
+ logo && /* @__PURE__ */ jsx3("div", { className: "flex-shrink-0", children: logo }),
842
+ /* @__PURE__ */ jsx3("div", { className: "flex items-center gap-1", children: links.map((link) => /* @__PURE__ */ jsx3(
821
843
  Link,
822
844
  {
823
845
  href: link.href,
@@ -826,12 +848,12 @@ var NavBar = React3.forwardRef(function NavBar2({
826
848
  },
827
849
  link.href
828
850
  )) }),
829
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
830
- locales.length > 0 && /* @__PURE__ */ jsxs("div", { ref: langRef, className: "relative", children: [
851
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
852
+ locales.length > 0 && /* @__PURE__ */ jsxs3("div", { ref: langRef, className: "relative", children: [
831
853
  langButton,
832
- langOpen && langDropdown
854
+ langOpen === "desktop" && langDropdown
833
855
  ] }),
834
- showGitHub && /* @__PURE__ */ jsx(
856
+ showGitHub && /* @__PURE__ */ jsx3(
835
857
  "a",
836
858
  {
837
859
  href: githubUrl,
@@ -839,10 +861,10 @@ var NavBar = React3.forwardRef(function NavBar2({
839
861
  rel: "noopener noreferrer",
840
862
  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
863
  "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" }) })
864
+ children: /* @__PURE__ */ jsx3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx3("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
865
  }
844
866
  ),
845
- cta && /* @__PURE__ */ jsx(
867
+ cta && /* @__PURE__ */ jsx3(
846
868
  Link,
847
869
  {
848
870
  href: cta.href,
@@ -852,29 +874,34 @@ var NavBar = React3.forwardRef(function NavBar2({
852
874
  )
853
875
  ] })
854
876
  ] }),
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(
877
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between px-4 py-3 md:hidden", children: [
878
+ logo && /* @__PURE__ */ jsx3("div", { className: "flex-shrink-0", children: logo }),
879
+ /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-1", children: [
880
+ locales.length > 0 && /* @__PURE__ */ jsxs3("div", { ref: mobileLangRef, className: "relative", children: [
881
+ /* @__PURE__ */ jsx3(
860
882
  "button",
861
883
  {
862
884
  type: "button",
863
- onClick: () => setLangOpen(!langOpen),
885
+ onClick: () => setLangOpen(langOpen === "mobile" ? null : "mobile"),
864
886
  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",
887
+ "aria-expanded": langOpen === "mobile",
888
+ "aria-haspopup": "listbox",
865
889
  "aria-label": `Current language: ${currentLocaleInfo.label}`,
866
- children: showFlags && /* @__PURE__ */ jsx("span", { className: "text-base leading-none", children: currentLocaleInfo.flag })
890
+ children: showFlags && /* @__PURE__ */ jsx3("span", { className: "text-base leading-none", children: currentLocaleInfo.flag })
867
891
  }
868
892
  ),
869
- langOpen && langDropdown
893
+ langOpen === "mobile" && langDropdown
870
894
  ] }),
871
- /* @__PURE__ */ jsx(
895
+ /* @__PURE__ */ jsx3(
872
896
  "button",
873
897
  {
898
+ type: "button",
874
899
  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
900
  onClick: () => setMobileOpen(!mobileOpen),
876
901
  "aria-label": "Toggle menu",
877
- children: mobileOpen ? /* @__PURE__ */ jsx(
902
+ "aria-expanded": mobileOpen,
903
+ "aria-controls": mobileOpen ? menuId : void 0,
904
+ children: mobileOpen ? /* @__PURE__ */ jsx3(
878
905
  "svg",
879
906
  {
880
907
  className: "size-4",
@@ -882,9 +909,9 @@ var NavBar = React3.forwardRef(function NavBar2({
882
909
  viewBox: "0 0 24 24",
883
910
  stroke: "currentColor",
884
911
  strokeWidth: 2,
885
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
912
+ children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
886
913
  }
887
- ) : /* @__PURE__ */ jsx(
914
+ ) : /* @__PURE__ */ jsx3(
888
915
  "svg",
889
916
  {
890
917
  className: "size-4",
@@ -892,39 +919,50 @@ var NavBar = React3.forwardRef(function NavBar2({
892
919
  viewBox: "0 0 24 24",
893
920
  stroke: "currentColor",
894
921
  strokeWidth: 2,
895
- children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 6h16M4 12h16M4 18h16" })
922
+ children: /* @__PURE__ */ jsx3("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4 6h16M4 12h16M4 18h16" })
896
923
  }
897
924
  )
898
925
  }
899
926
  )
900
927
  ] })
901
928
  ] }),
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
- ] })
929
+ mobileOpen && /* @__PURE__ */ jsxs3(
930
+ "div",
931
+ {
932
+ id: menuId,
933
+ className: "border-t border-zinc-200 bg-white px-4 py-3 md:hidden dark:border-zinc-800 dark:bg-zinc-900",
934
+ children: [
935
+ links.map((link) => /* @__PURE__ */ jsx3(
936
+ Link,
937
+ {
938
+ href: link.href,
939
+ onClick: () => setMobileOpen(false),
940
+ 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",
941
+ children: link.label
942
+ },
943
+ link.href
944
+ )),
945
+ cta && /* @__PURE__ */ jsx3(
946
+ Link,
947
+ {
948
+ href: cta.href,
949
+ onClick: () => setMobileOpen(false),
950
+ 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",
951
+ children: cta.label
952
+ }
953
+ )
954
+ ]
955
+ }
956
+ )
923
957
  ]
924
958
  }
925
959
  );
926
960
  });
927
-
928
- export { COUNTRIES, LanguageSwitcher, NavBar, PhoneInput, cn };
929
- //# sourceMappingURL=index.js.map
961
+ export {
962
+ COUNTRIES,
963
+ LanguageSwitcher,
964
+ NavBar,
965
+ PhoneInput,
966
+ cn
967
+ };
930
968
  //# sourceMappingURL=index.js.map