@windrun-huaiin/base-ui 3.2.3 → 3.3.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/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  "use strict";
3
2
  var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
@@ -180,7 +179,6 @@ __export(index_exports, {
180
179
  FormItem: () => FormItem,
181
180
  FormLabel: () => FormLabel,
182
181
  FormMessage: () => FormMessage,
183
- GoogleAnalyticsScript: () => GoogleAnalyticsScript,
184
182
  HoverCard: () => HoverCard,
185
183
  HoverCardContent: () => HoverCardContent,
186
184
  HoverCardTrigger: () => HoverCardTrigger,
@@ -192,8 +190,6 @@ __export(index_exports, {
192
190
  InputOTPSlot: () => InputOTPSlot,
193
191
  Label: () => Label3,
194
192
  LanguageButton: () => LanguageButton,
195
- LanguageDetector: () => LanguageDetector,
196
- LanguageSwitcher: () => LanguageSwitcher,
197
193
  Menubar: () => Menubar,
198
194
  MenubarCheckboxItem: () => MenubarCheckboxItem,
199
195
  MenubarContent: () => MenubarContent,
@@ -210,7 +206,6 @@ __export(index_exports, {
210
206
  MenubarSubContent: () => MenubarSubContent,
211
207
  MenubarSubTrigger: () => MenubarSubTrigger,
212
208
  MenubarTrigger: () => MenubarTrigger,
213
- MicrosoftClarityScript: () => MicrosoftClarityScript,
214
209
  NavigationMenu: () => NavigationMenu,
215
210
  NavigationMenuContent: () => NavigationMenuContent,
216
211
  NavigationMenuIndicator: () => NavigationMenuIndicator,
@@ -220,7 +215,6 @@ __export(index_exports, {
220
215
  NavigationMenuTrigger: () => NavigationMenuTrigger,
221
216
  NavigationMenuViewport: () => NavigationMenuViewport,
222
217
  NotFoundIcon: () => NotFoundIcon,
223
- NotFoundPage: () => NotFoundPage,
224
218
  Pagination: () => Pagination,
225
219
  PaginationContent: () => PaginationContent,
226
220
  PaginationEllipsis: () => PaginationEllipsis,
@@ -326,7 +320,6 @@ __export(index_exports, {
326
320
  toast: () => toast,
327
321
  toggleVariants: () => toggleVariants,
328
322
  useFormField: () => useFormField,
329
- useGoogleAnalytics: () => useGoogleAnalytics,
330
323
  useIsMobile: () => useIsMobile,
331
324
  useSidebar: () => useSidebar,
332
325
  useToast: () => useToast
@@ -1524,6 +1517,7 @@ var wrappedBuiltinIconsPart = tempWrappedBuiltinIcons;
1524
1517
  var globalLucideIcons = __spreadValues(__spreadValues({}, styledLimitedIconsPart), wrappedBuiltinIconsPart);
1525
1518
  var DEFAULT_FALLBACK_ICON = "BTC";
1526
1519
  function getGlobalIcon(iconKey, createElement) {
1520
+ var _a;
1527
1521
  if (!iconKey) {
1528
1522
  if (createElement) {
1529
1523
  return void 0;
@@ -1532,7 +1526,7 @@ function getGlobalIcon(iconKey, createElement) {
1532
1526
  }
1533
1527
  const Icon2 = globalLucideIcons[iconKey];
1534
1528
  if (!Icon2) {
1535
- if (process.env.NODE_ENV !== "production") {
1529
+ if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) !== "production") {
1536
1530
  console.warn(
1537
1531
  `[global-icon] iconKey "${iconKey}" is not defined in globalIcons, will use default "${String(DEFAULT_FALLBACK_ICON)}" icon, please check!`
1538
1532
  );
@@ -5628,310 +5622,6 @@ function SiteIcon(_a) {
5628
5622
  return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(CustomIcon, __spreadValues({ size, className: finalClassName }, props));
5629
5623
  }
5630
5624
  }
5631
-
5632
- // src/components/404-page.tsx
5633
- var import_react31 = require("react");
5634
- var import_jsx_runtime79 = require("react/jsx-runtime");
5635
- function NotFoundPage() {
5636
- const [glitchText, setGlitchText] = (0, import_react31.useState)("404");
5637
- (0, import_react31.useEffect)(() => {
5638
- const glitchChars = ["4", "0", "4", "?", "#", "!", "*", "&", "%", "$"];
5639
- const interval = setInterval(() => {
5640
- if (Math.random() < 0.5) {
5641
- setGlitchText("404");
5642
- } else {
5643
- const randomChars = Array.from(
5644
- { length: 3 },
5645
- () => glitchChars[Math.floor(Math.random() * glitchChars.length)]
5646
- ).join("");
5647
- setGlitchText(randomChars);
5648
- }
5649
- }, 600);
5650
- return () => clearInterval(interval);
5651
- }, []);
5652
- return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex flex-col items-center justify-center min-h-[75vh] w-full px-4 py-8", children: [
5653
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "text-center space-y-8 max-w-2xl", children: [
5654
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "relative flex justify-center", children: [
5655
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
5656
- "h1",
5657
- {
5658
- className: "text-8xl md:text-9xl font-bold bg-gradient-to-r from-purple-600 via-pink-500 to-purple-700 bg-clip-text text-transparent select-none",
5659
- style: {
5660
- fontFamily: "Montserrat, monospace",
5661
- textShadow: "0 0 30px rgba(172, 98, 253, 0.3)",
5662
- letterSpacing: "0.1em"
5663
- },
5664
- children: glitchText
5665
- }
5666
- ),
5667
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "absolute inset-0 pointer-events-none", children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "h-full w-full bg-gradient-to-b from-transparent via-purple-500/10 to-transparent animate-pulse" }) })
5668
- ] }),
5669
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "space-y-4", children: [
5670
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("h2", { className: "text-2xl md:text-3xl font-semibold text-foreground", children: "Page Not Found" }),
5671
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("p", { className: "text-lg text-muted-foreground max-w-md mx-auto leading-relaxed", children: "The page you're looking for doesn't exist" })
5672
- ] }),
5673
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex justify-center items-center gap-8 pt-8 opacity-60", children: [
5674
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
5675
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(SiteIcon, {}),
5676
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { children: "Woops!" })
5677
- ] }),
5678
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("div", { className: "w-1 h-1 bg-purple-500 rounded-full animate-ping" }),
5679
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
5680
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(NotFoundIcon, {}),
5681
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)("span", { children: "Error Code: 404" })
5682
- ] })
5683
- ] })
5684
- ] }),
5685
- /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { className: "fixed inset-0 pointer-events-none overflow-hidden -z-10", children: [
5686
- /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
5687
- "div",
5688
- {
5689
- className: "absolute inset-0 opacity-[0.02] dark:opacity-[0.05]",
5690
- style: {
5691
- backgroundImage: `
5692
- linear-gradient(rgba(172, 98, 253, 0.1) 1px, transparent 1px),
5693
- linear-gradient(90deg, rgba(172, 98, 253, 0.1) 1px, transparent 1px)
5694
- `,
5695
- backgroundSize: "50px 50px"
5696
- }
5697
- }
5698
- ),
5699
- Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
5700
- "div",
5701
- {
5702
- className: "absolute w-2 h-2 bg-purple-500/20 rounded-full animate-bounce",
5703
- style: {
5704
- left: `${20 + i * 15}%`,
5705
- top: `${30 + i % 3 * 20}%`,
5706
- animationDelay: `${i * 0.5}s`,
5707
- animationDuration: `${2 + i * 0.3}s`
5708
- }
5709
- },
5710
- i
5711
- ))
5712
- ] })
5713
- ] });
5714
- }
5715
-
5716
- // src/components/go-to-top.tsx
5717
- var import_react32 = require("react");
5718
- var import_jsx_runtime80 = require("react/jsx-runtime");
5719
-
5720
- // src/components/language-detector.tsx
5721
- var import_next_intl = require("next-intl");
5722
- var import_navigation = require("next/navigation");
5723
- var import_react33 = require("react");
5724
- var import_jsx_runtime81 = require("react/jsx-runtime");
5725
- function LanguageDetector({ i18nConfig }) {
5726
- const [show, setShow] = (0, import_react33.useState)(false);
5727
- const [detectedLocale, setDetectedLocale] = (0, import_react33.useState)(null);
5728
- const currentLocale = (0, import_next_intl.useLocale)();
5729
- const router = (0, import_navigation.useRouter)();
5730
- const t = (0, import_next_intl.useTranslations)("languageDetection");
5731
- const LANGUAGE_PREFERENCE_KEY = `${i18nConfig.detector.storagePrefix}-${i18nConfig.detector.storageKey}`;
5732
- (0, import_react33.useEffect)(() => {
5733
- const browserLang = navigator.language.split("-")[0];
5734
- const savedPreference = localStorage.getItem(LANGUAGE_PREFERENCE_KEY);
5735
- const preference = savedPreference ? JSON.parse(savedPreference) : null;
5736
- const shouldShowDetector = () => {
5737
- if (!preference) return true;
5738
- if (preference.locale === currentLocale) return false;
5739
- if (preference.status === "rejected" && preference.locale === browserLang) return false;
5740
- if (preference.status === "accepted" && preference.locale === currentLocale) return false;
5741
- const expirationMs = i18nConfig.detector.expirationDays * 24 * 60 * 60 * 1e3;
5742
- if (Date.now() - preference.timestamp < expirationMs) return false;
5743
- return true;
5744
- };
5745
- if (i18nConfig.locales.includes(browserLang) && browserLang !== currentLocale && shouldShowDetector()) {
5746
- setDetectedLocale(browserLang);
5747
- setShow(true);
5748
- const timer = setTimeout(() => {
5749
- console.log("[LanguageDetector] Auto closing after timeout");
5750
- setShow(false);
5751
- savePreference(browserLang, "rejected");
5752
- }, i18nConfig.detector.autoCloseTimeout);
5753
- return () => clearTimeout(timer);
5754
- }
5755
- }, [currentLocale]);
5756
- const savePreference = (locale, status) => {
5757
- const preference = {
5758
- locale,
5759
- status,
5760
- timestamp: Date.now()
5761
- };
5762
- localStorage.setItem(LANGUAGE_PREFERENCE_KEY, JSON.stringify(preference));
5763
- };
5764
- const handleLanguageChange = () => {
5765
- if (detectedLocale) {
5766
- savePreference(detectedLocale, "accepted");
5767
- const pathname = window.location.pathname;
5768
- const newPathname = pathname.replace(`/${currentLocale}`, `/${detectedLocale}`);
5769
- router.push(newPathname);
5770
- setShow(false);
5771
- }
5772
- };
5773
- const handleClose = () => {
5774
- if (detectedLocale) {
5775
- savePreference(detectedLocale, "rejected");
5776
- }
5777
- setShow(false);
5778
- };
5779
- if (!detectedLocale || !show) return null;
5780
- return /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "fixed top-16 right-4 z-40 w-[420px]", children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: `shadow-lg rounded-lg transition-all duration-300 ${show ? "translate-x-0 opacity-100" : "translate-x-full opacity-0"}
5781
- bg-linear-to-r from-purple-100/95 via-white/95 to-purple-100/95 backdrop-blur-xs
5782
- animate-gradient-x`, children: /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "relative px-6 py-4 overflow-hidden", children: [
5783
- /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "relative z-10 flex flex-col gap-3", children: [
5784
- /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-start justify-between gap-4", children: [
5785
- /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
5786
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("h3", { className: "text-lg font-semibold text-gray-900", children: t("title") }),
5787
- /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("p", { className: "text-base text-gray-600", children: [
5788
- t("description"),
5789
- " ",
5790
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("span", { className: "text-purple-500 font-semibold", children: detectedLocale === "zh" ? "\u4E2D\u6587" : "English" }),
5791
- "?"
5792
- ] })
5793
- ] }),
5794
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
5795
- "button",
5796
- {
5797
- onClick: handleClose,
5798
- className: "text-gray-500 hover:text-gray-700",
5799
- children: /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(globalLucideIcons.X, { className: "h-5 w-5" })
5800
- }
5801
- )
5802
- ] }),
5803
- /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "flex items-center gap-3", children: [
5804
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
5805
- "button",
5806
- {
5807
- onClick: handleClose,
5808
- className: "flex-1 px-4 py-2 text-base bg-gray-100 text-gray-600 rounded-md hover:bg-gray-200",
5809
- children: t("close")
5810
- }
5811
- ),
5812
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
5813
- "button",
5814
- {
5815
- onClick: handleLanguageChange,
5816
- className: "flex-1 px-4 py-2 text-base bg-purple-500 text-white rounded-md hover:bg-purple-600",
5817
- children: t("changeAction")
5818
- }
5819
- )
5820
- ] })
5821
- ] }),
5822
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)("div", { className: "absolute inset-0 bg-linear-to-r from-transparent via-purple-200/30 to-transparent animate-shimmer" })
5823
- ] }) }) });
5824
- }
5825
-
5826
- // src/components/language-switcher.tsx
5827
- var import_navigation2 = require("next/navigation");
5828
- var import_next_intl2 = require("next-intl");
5829
- var import_jsx_runtime82 = require("react/jsx-runtime");
5830
- function LanguageSwitcher({ locales, localeLabels }) {
5831
- const locale = (0, import_next_intl2.useLocale)();
5832
- const router = (0, import_navigation2.useRouter)();
5833
- const pathname = (0, import_navigation2.usePathname)();
5834
- const handleLocaleChange = (newLocale) => {
5835
- const newPathname = pathname.replace(`/${locale}`, `/${newLocale}`);
5836
- router.push(newPathname);
5837
- };
5838
- return /* @__PURE__ */ (0, import_jsx_runtime82.jsxs)(DropdownMenu, { children: [
5839
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
5840
- LanguageButton,
5841
- {
5842
- variant: "ghost",
5843
- size: "icon",
5844
- 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",
5845
- children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(globalLucideIcons.Globe, { className: "h-5 w-5" })
5846
- }
5847
- ) }),
5848
- /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
5849
- DropdownMenuContent,
5850
- {
5851
- align: "end",
5852
- sideOffset: 5,
5853
- 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]",
5854
- children: /* @__PURE__ */ (0, import_jsx_runtime82.jsx)("div", { className: "grid grid-cols-2 gap-1", children: locales.map((loc) => /* @__PURE__ */ (0, import_jsx_runtime82.jsx)(
5855
- DropdownMenuItem,
5856
- {
5857
- className: `
5858
- px-2 py-2 text-sm cursor-pointer text-center justify-center
5859
- transition-all duration-300 ease-in-out
5860
- hover:scale-105 hover:shadow-md
5861
- rounded-md whitespace-nowrap
5862
- ${locale === loc ? "bg-linear-to-r from-purple-400 to-pink-600 text-white font-medium shadow-lg scale-105" : "hover:bg-linear-to-r hover:from-purple-400/10 hover:to-pink-600/10 hover:text-transparent hover:bg-clip-text"}
5863
- `,
5864
- onClick: () => handleLocaleChange(loc),
5865
- children: localeLabels[loc]
5866
- },
5867
- loc
5868
- )) })
5869
- }
5870
- )
5871
- ] });
5872
- }
5873
-
5874
- // src/components/script/google-analytics-script.tsx
5875
- var import_script = __toESM(require("next/script"));
5876
- var import_jsx_runtime83 = require("react/jsx-runtime");
5877
- var googleAnalyticsId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID;
5878
- function GoogleAnalyticsScript() {
5879
- if (process.env.NODE_ENV !== "production") {
5880
- return null;
5881
- }
5882
- return /* @__PURE__ */ (0, import_jsx_runtime83.jsxs)(import_jsx_runtime83.Fragment, { children: [
5883
- /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
5884
- import_script.default,
5885
- {
5886
- strategy: "afterInteractive",
5887
- src: `https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`
5888
- }
5889
- ),
5890
- /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
5891
- import_script.default,
5892
- {
5893
- id: "google-analytics",
5894
- strategy: "afterInteractive",
5895
- dangerouslySetInnerHTML: {
5896
- __html: `
5897
- window.dataLayer = window.dataLayer || [];
5898
- function gtag(){dataLayer.push(arguments);}
5899
- gtag('js', new Date());
5900
- gtag('config', '${googleAnalyticsId}');
5901
- `
5902
- }
5903
- }
5904
- )
5905
- ] });
5906
- }
5907
- function useGoogleAnalytics() {
5908
- const trackEvent = (event, data) => {
5909
- if (typeof window === "undefined" || !window.gtag) {
5910
- return;
5911
- }
5912
- window.gtag("event", event, data);
5913
- };
5914
- return {
5915
- trackEvent
5916
- };
5917
- }
5918
-
5919
- // src/components/script/microsoft-clarity-script.tsx
5920
- var import_script2 = __toESM(require("next/script"));
5921
- var import_jsx_runtime84 = require("react/jsx-runtime");
5922
- var microsoftClarityId = process.env.NEXT_PUBLIC_MICROSOFT_CLARITY_ID;
5923
- function MicrosoftClarityScript() {
5924
- if (process.env.NODE_ENV !== "production") {
5925
- return null;
5926
- }
5927
- return /* @__PURE__ */ (0, import_jsx_runtime84.jsx)(import_script2.default, { id: "microsoft-clarity", strategy: "afterInteractive", children: `
5928
- (function(c,l,a,r,i,t,y){
5929
- c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
5930
- t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
5931
- y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
5932
- })(window, document, "clarity", "script", "${microsoftClarityId}");
5933
- ` });
5934
- }
5935
5625
  // Annotate the CommonJS export names for ESM import in node:
5936
5626
  0 && (module.exports = {
5937
5627
  Accordion,
@@ -6054,7 +5744,6 @@ function MicrosoftClarityScript() {
6054
5744
  FormItem,
6055
5745
  FormLabel,
6056
5746
  FormMessage,
6057
- GoogleAnalyticsScript,
6058
5747
  HoverCard,
6059
5748
  HoverCardContent,
6060
5749
  HoverCardTrigger,
@@ -6066,8 +5755,6 @@ function MicrosoftClarityScript() {
6066
5755
  InputOTPSlot,
6067
5756
  Label,
6068
5757
  LanguageButton,
6069
- LanguageDetector,
6070
- LanguageSwitcher,
6071
5758
  Menubar,
6072
5759
  MenubarCheckboxItem,
6073
5760
  MenubarContent,
@@ -6084,7 +5771,6 @@ function MicrosoftClarityScript() {
6084
5771
  MenubarSubContent,
6085
5772
  MenubarSubTrigger,
6086
5773
  MenubarTrigger,
6087
- MicrosoftClarityScript,
6088
5774
  NavigationMenu,
6089
5775
  NavigationMenuContent,
6090
5776
  NavigationMenuIndicator,
@@ -6094,7 +5780,6 @@ function MicrosoftClarityScript() {
6094
5780
  NavigationMenuTrigger,
6095
5781
  NavigationMenuViewport,
6096
5782
  NotFoundIcon,
6097
- NotFoundPage,
6098
5783
  Pagination,
6099
5784
  PaginationContent,
6100
5785
  PaginationEllipsis,
@@ -6200,7 +5885,6 @@ function MicrosoftClarityScript() {
6200
5885
  toast,
6201
5886
  toggleVariants,
6202
5887
  useFormField,
6203
- useGoogleAnalytics,
6204
5888
  useIsMobile,
6205
5889
  useSidebar,
6206
5890
  useToast