@windrun-huaiin/base-ui 6.0.2 → 7.0.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.
@@ -1563,115 +1563,9 @@ function NotFoundPage({ siteIcon }) {
1563
1563
  ] });
1564
1564
  }
1565
1565
 
1566
- // src/components/language-detector.tsx
1567
- import { useLocale, useTranslations } from "next-intl";
1568
- import { useRouter } from "next/navigation";
1569
- import { useEffect as useEffect2, useState as useState2 } from "react";
1570
- import { jsx as jsx34, jsxs as jsxs11 } from "react/jsx-runtime";
1571
- function LanguageDetector({ i18nConfig }) {
1572
- const [show, setShow] = useState2(false);
1573
- const [detectedLocale, setDetectedLocale] = useState2(null);
1574
- const currentLocale = useLocale();
1575
- const router = useRouter();
1576
- const t = useTranslations("languageDetection");
1577
- const LANGUAGE_PREFERENCE_KEY = `${i18nConfig.detector.storagePrefix}-${i18nConfig.detector.storageKey}`;
1578
- useEffect2(() => {
1579
- const browserLang = navigator.language.split("-")[0];
1580
- const savedPreference = localStorage.getItem(LANGUAGE_PREFERENCE_KEY);
1581
- const preference = savedPreference ? JSON.parse(savedPreference) : null;
1582
- const shouldShowDetector = () => {
1583
- if (!preference) return true;
1584
- if (preference.locale === currentLocale) return false;
1585
- if (preference.status === "rejected" && preference.locale === browserLang) return false;
1586
- if (preference.status === "accepted" && preference.locale === currentLocale) return false;
1587
- const expirationMs = i18nConfig.detector.expirationDays * 24 * 60 * 60 * 1e3;
1588
- if (Date.now() - preference.timestamp < expirationMs) return false;
1589
- return true;
1590
- };
1591
- if (i18nConfig.locales.includes(browserLang) && browserLang !== currentLocale && shouldShowDetector()) {
1592
- setDetectedLocale(browserLang);
1593
- setShow(true);
1594
- const timer = setTimeout(() => {
1595
- console.log("[LanguageDetector] Auto closing after timeout");
1596
- setShow(false);
1597
- savePreference(browserLang, "rejected");
1598
- }, i18nConfig.detector.autoCloseTimeout);
1599
- return () => clearTimeout(timer);
1600
- }
1601
- }, [currentLocale]);
1602
- const savePreference = (locale, status) => {
1603
- const preference = {
1604
- locale,
1605
- status,
1606
- timestamp: Date.now()
1607
- };
1608
- localStorage.setItem(LANGUAGE_PREFERENCE_KEY, JSON.stringify(preference));
1609
- };
1610
- const handleLanguageChange = () => {
1611
- if (detectedLocale) {
1612
- savePreference(detectedLocale, "accepted");
1613
- const pathname = window.location.pathname;
1614
- const newPathname = pathname.replace(`/${currentLocale}`, `/${detectedLocale}`);
1615
- router.push(newPathname);
1616
- setShow(false);
1617
- }
1618
- };
1619
- const handleClose = () => {
1620
- if (detectedLocale) {
1621
- savePreference(detectedLocale, "rejected");
1622
- }
1623
- setShow(false);
1624
- };
1625
- if (!detectedLocale || !show) return null;
1626
- return /* @__PURE__ */ jsx34("div", { className: "fixed top-16 right-4 z-40 w-[420px]", children: /* @__PURE__ */ jsx34("div", { className: `shadow-lg rounded-lg transition-all duration-300 ${show ? "translate-x-0 opacity-100" : "translate-x-full opacity-0"}
1627
- bg-linear-to-r from-purple-100/95 via-white/95 to-purple-100/95 backdrop-blur-xs
1628
- animate-gradient-x`, children: /* @__PURE__ */ jsxs11("div", { className: "relative px-6 py-4 overflow-hidden", children: [
1629
- /* @__PURE__ */ jsxs11("div", { className: "relative z-10 flex flex-col gap-3", children: [
1630
- /* @__PURE__ */ jsxs11("div", { className: "flex items-start justify-between gap-4", children: [
1631
- /* @__PURE__ */ jsxs11("div", { className: "flex flex-col gap-1.5", children: [
1632
- /* @__PURE__ */ jsx34("h3", { className: "text-lg font-semibold text-gray-900", children: t("title") }),
1633
- /* @__PURE__ */ jsxs11("p", { className: "text-base text-gray-600", children: [
1634
- t("description"),
1635
- " ",
1636
- /* @__PURE__ */ jsx34("span", { className: "text-purple-500 font-semibold", children: detectedLocale === "zh" ? "\u4E2D\u6587" : "English" }),
1637
- "?"
1638
- ] })
1639
- ] }),
1640
- /* @__PURE__ */ jsx34(
1641
- "button",
1642
- {
1643
- onClick: handleClose,
1644
- className: "text-gray-500 hover:text-gray-700",
1645
- children: /* @__PURE__ */ jsx34(globalLucideIcons.X, { className: "h-5 w-5" })
1646
- }
1647
- )
1648
- ] }),
1649
- /* @__PURE__ */ jsxs11("div", { className: "flex items-center gap-3", children: [
1650
- /* @__PURE__ */ jsx34(
1651
- "button",
1652
- {
1653
- onClick: handleClose,
1654
- className: "flex-1 px-4 py-2 text-base bg-gray-100 text-gray-600 rounded-md hover:bg-gray-200",
1655
- children: t("close")
1656
- }
1657
- ),
1658
- /* @__PURE__ */ jsx34(
1659
- "button",
1660
- {
1661
- onClick: handleLanguageChange,
1662
- className: "flex-1 px-4 py-2 text-base bg-purple-500 text-white rounded-md hover:bg-purple-600",
1663
- children: t("changeAction")
1664
- }
1665
- )
1666
- ] })
1667
- ] }),
1668
- /* @__PURE__ */ jsx34("div", { className: "absolute inset-0 bg-linear-to-r from-transparent via-purple-200/30 to-transparent animate-shimmer" })
1669
- ] }) }) });
1670
- }
1671
-
1672
1566
  // src/components/language-switcher.tsx
1673
- import { usePathname, useRouter as useRouter2 } from "next/navigation";
1674
- import { useLocale as useLocale2 } from "next-intl";
1567
+ import { usePathname, useRouter } from "next/navigation";
1568
+ import { useLocale } from "next-intl";
1675
1569
 
1676
1570
  // src/ui/dropdown-menu.tsx
1677
1571
  import * as React33 from "react";
@@ -1685,12 +1579,12 @@ function cn(...inputs) {
1685
1579
  }
1686
1580
 
1687
1581
  // src/ui/dropdown-menu.tsx
1688
- import { jsx as jsx35, jsxs as jsxs12 } from "react/jsx-runtime";
1582
+ import { jsx as jsx34, jsxs as jsxs11 } from "react/jsx-runtime";
1689
1583
  var DropdownMenu = DropdownMenuPrimitive.Root;
1690
1584
  var DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
1691
1585
  var DropdownMenuSubTrigger = React33.forwardRef((_a, ref) => {
1692
1586
  var _b = _a, { className, inset, children } = _b, props = __objRest(_b, ["className", "inset", "children"]);
1693
- return /* @__PURE__ */ jsxs12(
1587
+ return /* @__PURE__ */ jsxs11(
1694
1588
  DropdownMenuPrimitive.SubTrigger,
1695
1589
  __spreadProps(__spreadValues({
1696
1590
  ref,
@@ -1702,7 +1596,7 @@ var DropdownMenuSubTrigger = React33.forwardRef((_a, ref) => {
1702
1596
  }, props), {
1703
1597
  children: [
1704
1598
  children,
1705
- /* @__PURE__ */ jsx35(globalLucideIcons.ChevronRight, { className: "ml-auto" })
1599
+ /* @__PURE__ */ jsx34(globalLucideIcons.ChevronRight, { className: "ml-auto" })
1706
1600
  ]
1707
1601
  })
1708
1602
  );
@@ -1710,7 +1604,7 @@ var DropdownMenuSubTrigger = React33.forwardRef((_a, ref) => {
1710
1604
  DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName;
1711
1605
  var DropdownMenuSubContent = React33.forwardRef((_a, ref) => {
1712
1606
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1713
- return /* @__PURE__ */ jsx35(
1607
+ return /* @__PURE__ */ jsx34(
1714
1608
  DropdownMenuPrimitive.SubContent,
1715
1609
  __spreadValues({
1716
1610
  ref,
@@ -1724,7 +1618,7 @@ var DropdownMenuSubContent = React33.forwardRef((_a, ref) => {
1724
1618
  DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName;
1725
1619
  var DropdownMenuContent = React33.forwardRef((_a, ref) => {
1726
1620
  var _b = _a, { className, sideOffset = 4 } = _b, props = __objRest(_b, ["className", "sideOffset"]);
1727
- return /* @__PURE__ */ jsx35(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx35(
1621
+ return /* @__PURE__ */ jsx34(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx34(
1728
1622
  DropdownMenuPrimitive.Content,
1729
1623
  __spreadValues({
1730
1624
  ref,
@@ -1739,7 +1633,7 @@ var DropdownMenuContent = React33.forwardRef((_a, ref) => {
1739
1633
  DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
1740
1634
  var DropdownMenuItem = React33.forwardRef((_a, ref) => {
1741
1635
  var _b = _a, { className, inset } = _b, props = __objRest(_b, ["className", "inset"]);
1742
- return /* @__PURE__ */ jsx35(
1636
+ return /* @__PURE__ */ jsx34(
1743
1637
  DropdownMenuPrimitive.Item,
1744
1638
  __spreadValues({
1745
1639
  ref,
@@ -1754,7 +1648,7 @@ var DropdownMenuItem = React33.forwardRef((_a, ref) => {
1754
1648
  DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
1755
1649
  var DropdownMenuCheckboxItem = React33.forwardRef((_a, ref) => {
1756
1650
  var _b = _a, { className, children, checked } = _b, props = __objRest(_b, ["className", "children", "checked"]);
1757
- return /* @__PURE__ */ jsxs12(
1651
+ return /* @__PURE__ */ jsxs11(
1758
1652
  DropdownMenuPrimitive.CheckboxItem,
1759
1653
  __spreadProps(__spreadValues({
1760
1654
  ref,
@@ -1765,7 +1659,7 @@ var DropdownMenuCheckboxItem = React33.forwardRef((_a, ref) => {
1765
1659
  checked
1766
1660
  }, props), {
1767
1661
  children: [
1768
- /* @__PURE__ */ jsx35("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx35(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx35(globalLucideIcons.Check, { className: "h-4 w-4" }) }) }),
1662
+ /* @__PURE__ */ jsx34("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx34(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx34(globalLucideIcons.Check, { className: "h-4 w-4" }) }) }),
1769
1663
  children
1770
1664
  ]
1771
1665
  })
@@ -1774,7 +1668,7 @@ var DropdownMenuCheckboxItem = React33.forwardRef((_a, ref) => {
1774
1668
  DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName;
1775
1669
  var DropdownMenuRadioItem = React33.forwardRef((_a, ref) => {
1776
1670
  var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
1777
- return /* @__PURE__ */ jsxs12(
1671
+ return /* @__PURE__ */ jsxs11(
1778
1672
  DropdownMenuPrimitive.RadioItem,
1779
1673
  __spreadProps(__spreadValues({
1780
1674
  ref,
@@ -1784,7 +1678,7 @@ var DropdownMenuRadioItem = React33.forwardRef((_a, ref) => {
1784
1678
  )
1785
1679
  }, props), {
1786
1680
  children: [
1787
- /* @__PURE__ */ jsx35("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx35(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx35(globalLucideIcons.Circle, { className: "h-2 w-2 fill-current" }) }) }),
1681
+ /* @__PURE__ */ jsx34("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: /* @__PURE__ */ jsx34(DropdownMenuPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx34(globalLucideIcons.Circle, { className: "h-2 w-2 fill-current" }) }) }),
1788
1682
  children
1789
1683
  ]
1790
1684
  })
@@ -1793,7 +1687,7 @@ var DropdownMenuRadioItem = React33.forwardRef((_a, ref) => {
1793
1687
  DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
1794
1688
  var DropdownMenuLabel = React33.forwardRef((_a, ref) => {
1795
1689
  var _b = _a, { className, inset } = _b, props = __objRest(_b, ["className", "inset"]);
1796
- return /* @__PURE__ */ jsx35(
1690
+ return /* @__PURE__ */ jsx34(
1797
1691
  DropdownMenuPrimitive.Label,
1798
1692
  __spreadValues({
1799
1693
  ref,
@@ -1808,7 +1702,7 @@ var DropdownMenuLabel = React33.forwardRef((_a, ref) => {
1808
1702
  DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
1809
1703
  var DropdownMenuSeparator = React33.forwardRef((_a, ref) => {
1810
1704
  var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
1811
- return /* @__PURE__ */ jsx35(
1705
+ return /* @__PURE__ */ jsx34(
1812
1706
  DropdownMenuPrimitive.Separator,
1813
1707
  __spreadValues({
1814
1708
  ref,
@@ -1823,7 +1717,7 @@ var DropdownMenuShortcut = (_a) => {
1823
1717
  } = _b, props = __objRest(_b, [
1824
1718
  "className"
1825
1719
  ]);
1826
- return /* @__PURE__ */ jsx35(
1720
+ return /* @__PURE__ */ jsx34(
1827
1721
  "span",
1828
1722
  __spreadValues({
1829
1723
  className: cn("ml-auto text-xs tracking-widest opacity-60", className)
@@ -1834,11 +1728,11 @@ DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
1834
1728
 
1835
1729
  // src/ui/language-button.tsx
1836
1730
  import * as React34 from "react";
1837
- import { jsx as jsx36 } from "react/jsx-runtime";
1731
+ import { jsx as jsx35 } from "react/jsx-runtime";
1838
1732
  var LanguageButton = React34.forwardRef(
1839
1733
  (_a, ref) => {
1840
1734
  var _b = _a, { className, variant = "default", size = "default" } = _b, props = __objRest(_b, ["className", "variant", "size"]);
1841
- return /* @__PURE__ */ jsx36(
1735
+ return /* @__PURE__ */ jsx35(
1842
1736
  "button",
1843
1737
  __spreadValues({
1844
1738
  className: cn(
@@ -1861,32 +1755,32 @@ var LanguageButton = React34.forwardRef(
1861
1755
  LanguageButton.displayName = "Button";
1862
1756
 
1863
1757
  // src/components/language-switcher.tsx
1864
- import { jsx as jsx37, jsxs as jsxs13 } from "react/jsx-runtime";
1758
+ import { jsx as jsx36, jsxs as jsxs12 } from "react/jsx-runtime";
1865
1759
  function LanguageSwitcher({ locales, localeLabels }) {
1866
- const locale = useLocale2();
1867
- const router = useRouter2();
1760
+ const locale = useLocale();
1761
+ const router = useRouter();
1868
1762
  const pathname = usePathname();
1869
1763
  const handleLocaleChange = (newLocale) => {
1870
1764
  const newPathname = pathname.replace(`/${locale}`, `/${newLocale}`);
1871
1765
  router.push(newPathname);
1872
1766
  };
1873
- return /* @__PURE__ */ jsxs13(DropdownMenu, { children: [
1874
- /* @__PURE__ */ jsx37(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx37(
1767
+ return /* @__PURE__ */ jsxs12(DropdownMenu, { children: [
1768
+ /* @__PURE__ */ jsx36(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx36(
1875
1769
  LanguageButton,
1876
1770
  {
1877
1771
  variant: "ghost",
1878
1772
  size: "icon",
1879
1773
  className: "bg-linear-to-r from-purple-400 to-pink-600 hover:from-purple-500 hover:to-pink-700 text-white transform hover:scale-110 transition-all duration-300",
1880
- children: /* @__PURE__ */ jsx37(globalLucideIcons.Globe, { className: "h-5 w-5" })
1774
+ children: /* @__PURE__ */ jsx36(globalLucideIcons.Globe, { className: "h-5 w-5" })
1881
1775
  }
1882
1776
  ) }),
1883
- /* @__PURE__ */ jsx37(
1777
+ /* @__PURE__ */ jsx36(
1884
1778
  DropdownMenuContent,
1885
1779
  {
1886
1780
  align: "end",
1887
1781
  sideOffset: 5,
1888
1782
  className: "bg-white/90 dark:bg-gray-800/90 border-purple-100 dark:border-purple-800 w-[200px] p-2 backdrop-blur-xs translate-x-[50px]",
1889
- children: /* @__PURE__ */ jsx37("div", { className: "grid grid-cols-2 gap-1", children: locales.map((loc) => /* @__PURE__ */ jsx37(
1783
+ children: /* @__PURE__ */ jsx36("div", { className: "grid grid-cols-2 gap-1", children: locales.map((loc) => /* @__PURE__ */ jsx36(
1890
1784
  DropdownMenuItem,
1891
1785
  {
1892
1786
  className: `
@@ -1905,75 +1799,9 @@ function LanguageSwitcher({ locales, localeLabels }) {
1905
1799
  )
1906
1800
  ] });
1907
1801
  }
1908
-
1909
- // src/components/script/google-analytics-script.tsx
1910
- import Script from "next/script";
1911
- import { Fragment, jsx as jsx38, jsxs as jsxs14 } from "react/jsx-runtime";
1912
- var googleAnalyticsId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID;
1913
- function GoogleAnalyticsScript() {
1914
- if (process.env.NODE_ENV !== "production") {
1915
- return null;
1916
- }
1917
- return /* @__PURE__ */ jsxs14(Fragment, { children: [
1918
- /* @__PURE__ */ jsx38(
1919
- Script,
1920
- {
1921
- strategy: "afterInteractive",
1922
- src: `https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`
1923
- }
1924
- ),
1925
- /* @__PURE__ */ jsx38(
1926
- Script,
1927
- {
1928
- id: "google-analytics",
1929
- strategy: "afterInteractive",
1930
- dangerouslySetInnerHTML: {
1931
- __html: `
1932
- window.dataLayer = window.dataLayer || [];
1933
- function gtag(){dataLayer.push(arguments);}
1934
- gtag('js', new Date());
1935
- gtag('config', '${googleAnalyticsId}');
1936
- `
1937
- }
1938
- }
1939
- )
1940
- ] });
1941
- }
1942
- function useGoogleAnalytics() {
1943
- const trackEvent = (event, data) => {
1944
- if (typeof window === "undefined" || !window.gtag) {
1945
- return;
1946
- }
1947
- window.gtag("event", event, data);
1948
- };
1949
- return {
1950
- trackEvent
1951
- };
1952
- }
1953
-
1954
- // src/components/script/microsoft-clarity-script.tsx
1955
- import Script2 from "next/script";
1956
- import { jsx as jsx39 } from "react/jsx-runtime";
1957
- var microsoftClarityId = process.env.NEXT_PUBLIC_MICROSOFT_CLARITY_ID;
1958
- function MicrosoftClarityScript() {
1959
- if (process.env.NODE_ENV !== "production") {
1960
- return null;
1961
- }
1962
- return /* @__PURE__ */ jsx39(Script2, { id: "microsoft-clarity", strategy: "afterInteractive", children: `
1963
- (function(c,l,a,r,i,t,y){
1964
- c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
1965
- t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
1966
- y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
1967
- })(window, document, "clarity", "script", "${microsoftClarityId}");
1968
- ` });
1969
- }
1970
1802
  export {
1971
- GoogleAnalyticsScript,
1972
- LanguageDetector,
1973
1803
  LanguageSwitcher,
1974
- MicrosoftClarityScript,
1975
- NotFoundPage,
1976
- useGoogleAnalytics
1804
+ NotFoundPage
1977
1805
  };
1978
1806
  /**
1979
1807
  * @license