@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.mjs CHANGED
@@ -1,4 +1,3 @@
1
- "use client";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __defProps = Object.defineProperties;
4
3
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
@@ -1305,6 +1304,7 @@ var wrappedBuiltinIconsPart = tempWrappedBuiltinIcons;
1305
1304
  var globalLucideIcons = __spreadValues(__spreadValues({}, styledLimitedIconsPart), wrappedBuiltinIconsPart);
1306
1305
  var DEFAULT_FALLBACK_ICON = "BTC";
1307
1306
  function getGlobalIcon(iconKey, createElement) {
1307
+ var _a;
1308
1308
  if (!iconKey) {
1309
1309
  if (createElement) {
1310
1310
  return void 0;
@@ -1313,7 +1313,7 @@ function getGlobalIcon(iconKey, createElement) {
1313
1313
  }
1314
1314
  const Icon2 = globalLucideIcons[iconKey];
1315
1315
  if (!Icon2) {
1316
- if (process.env.NODE_ENV !== "production") {
1316
+ if (typeof process !== "undefined" && ((_a = process.env) == null ? void 0 : _a.NODE_ENV) !== "production") {
1317
1317
  console.warn(
1318
1318
  `[global-icon] iconKey "${iconKey}" is not defined in globalIcons, will use default "${String(DEFAULT_FALLBACK_ICON)}" icon, please check!`
1319
1319
  );
@@ -5413,310 +5413,6 @@ function SiteIcon(_a) {
5413
5413
  return /* @__PURE__ */ jsx78(CustomIcon, __spreadValues({ size, className: finalClassName }, props));
5414
5414
  }
5415
5415
  }
5416
-
5417
- // src/components/404-page.tsx
5418
- import { useEffect as useEffect5, useState as useState5 } from "react";
5419
- import { jsx as jsx79, jsxs as jsxs28 } from "react/jsx-runtime";
5420
- function NotFoundPage() {
5421
- const [glitchText, setGlitchText] = useState5("404");
5422
- useEffect5(() => {
5423
- const glitchChars = ["4", "0", "4", "?", "#", "!", "*", "&", "%", "$"];
5424
- const interval = setInterval(() => {
5425
- if (Math.random() < 0.5) {
5426
- setGlitchText("404");
5427
- } else {
5428
- const randomChars = Array.from(
5429
- { length: 3 },
5430
- () => glitchChars[Math.floor(Math.random() * glitchChars.length)]
5431
- ).join("");
5432
- setGlitchText(randomChars);
5433
- }
5434
- }, 600);
5435
- return () => clearInterval(interval);
5436
- }, []);
5437
- return /* @__PURE__ */ jsxs28("div", { className: "flex flex-col items-center justify-center min-h-[75vh] w-full px-4 py-8", children: [
5438
- /* @__PURE__ */ jsxs28("div", { className: "text-center space-y-8 max-w-2xl", children: [
5439
- /* @__PURE__ */ jsxs28("div", { className: "relative flex justify-center", children: [
5440
- /* @__PURE__ */ jsx79(
5441
- "h1",
5442
- {
5443
- 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",
5444
- style: {
5445
- fontFamily: "Montserrat, monospace",
5446
- textShadow: "0 0 30px rgba(172, 98, 253, 0.3)",
5447
- letterSpacing: "0.1em"
5448
- },
5449
- children: glitchText
5450
- }
5451
- ),
5452
- /* @__PURE__ */ jsx79("div", { className: "absolute inset-0 pointer-events-none", children: /* @__PURE__ */ jsx79("div", { className: "h-full w-full bg-gradient-to-b from-transparent via-purple-500/10 to-transparent animate-pulse" }) })
5453
- ] }),
5454
- /* @__PURE__ */ jsxs28("div", { className: "space-y-4", children: [
5455
- /* @__PURE__ */ jsx79("h2", { className: "text-2xl md:text-3xl font-semibold text-foreground", children: "Page Not Found" }),
5456
- /* @__PURE__ */ jsx79("p", { className: "text-lg text-muted-foreground max-w-md mx-auto leading-relaxed", children: "The page you're looking for doesn't exist" })
5457
- ] }),
5458
- /* @__PURE__ */ jsxs28("div", { className: "flex justify-center items-center gap-8 pt-8 opacity-60", children: [
5459
- /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
5460
- /* @__PURE__ */ jsx79(SiteIcon, {}),
5461
- /* @__PURE__ */ jsx79("span", { children: "Woops!" })
5462
- ] }),
5463
- /* @__PURE__ */ jsx79("div", { className: "w-1 h-1 bg-purple-500 rounded-full animate-ping" }),
5464
- /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
5465
- /* @__PURE__ */ jsx79(NotFoundIcon, {}),
5466
- /* @__PURE__ */ jsx79("span", { children: "Error Code: 404" })
5467
- ] })
5468
- ] })
5469
- ] }),
5470
- /* @__PURE__ */ jsxs28("div", { className: "fixed inset-0 pointer-events-none overflow-hidden -z-10", children: [
5471
- /* @__PURE__ */ jsx79(
5472
- "div",
5473
- {
5474
- className: "absolute inset-0 opacity-[0.02] dark:opacity-[0.05]",
5475
- style: {
5476
- backgroundImage: `
5477
- linear-gradient(rgba(172, 98, 253, 0.1) 1px, transparent 1px),
5478
- linear-gradient(90deg, rgba(172, 98, 253, 0.1) 1px, transparent 1px)
5479
- `,
5480
- backgroundSize: "50px 50px"
5481
- }
5482
- }
5483
- ),
5484
- Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsx79(
5485
- "div",
5486
- {
5487
- className: "absolute w-2 h-2 bg-purple-500/20 rounded-full animate-bounce",
5488
- style: {
5489
- left: `${20 + i * 15}%`,
5490
- top: `${30 + i % 3 * 20}%`,
5491
- animationDelay: `${i * 0.5}s`,
5492
- animationDuration: `${2 + i * 0.3}s`
5493
- }
5494
- },
5495
- i
5496
- ))
5497
- ] })
5498
- ] });
5499
- }
5500
-
5501
- // src/components/go-to-top.tsx
5502
- import { useState as useState6, useEffect as useEffect6 } from "react";
5503
- import { Fragment as Fragment2, jsx as jsx80 } from "react/jsx-runtime";
5504
-
5505
- // src/components/language-detector.tsx
5506
- import { useLocale, useTranslations } from "next-intl";
5507
- import { useRouter } from "next/navigation";
5508
- import { useEffect as useEffect7, useState as useState7 } from "react";
5509
- import { jsx as jsx81, jsxs as jsxs29 } from "react/jsx-runtime";
5510
- function LanguageDetector({ i18nConfig }) {
5511
- const [show, setShow] = useState7(false);
5512
- const [detectedLocale, setDetectedLocale] = useState7(null);
5513
- const currentLocale = useLocale();
5514
- const router = useRouter();
5515
- const t = useTranslations("languageDetection");
5516
- const LANGUAGE_PREFERENCE_KEY = `${i18nConfig.detector.storagePrefix}-${i18nConfig.detector.storageKey}`;
5517
- useEffect7(() => {
5518
- const browserLang = navigator.language.split("-")[0];
5519
- const savedPreference = localStorage.getItem(LANGUAGE_PREFERENCE_KEY);
5520
- const preference = savedPreference ? JSON.parse(savedPreference) : null;
5521
- const shouldShowDetector = () => {
5522
- if (!preference) return true;
5523
- if (preference.locale === currentLocale) return false;
5524
- if (preference.status === "rejected" && preference.locale === browserLang) return false;
5525
- if (preference.status === "accepted" && preference.locale === currentLocale) return false;
5526
- const expirationMs = i18nConfig.detector.expirationDays * 24 * 60 * 60 * 1e3;
5527
- if (Date.now() - preference.timestamp < expirationMs) return false;
5528
- return true;
5529
- };
5530
- if (i18nConfig.locales.includes(browserLang) && browserLang !== currentLocale && shouldShowDetector()) {
5531
- setDetectedLocale(browserLang);
5532
- setShow(true);
5533
- const timer = setTimeout(() => {
5534
- console.log("[LanguageDetector] Auto closing after timeout");
5535
- setShow(false);
5536
- savePreference(browserLang, "rejected");
5537
- }, i18nConfig.detector.autoCloseTimeout);
5538
- return () => clearTimeout(timer);
5539
- }
5540
- }, [currentLocale]);
5541
- const savePreference = (locale, status) => {
5542
- const preference = {
5543
- locale,
5544
- status,
5545
- timestamp: Date.now()
5546
- };
5547
- localStorage.setItem(LANGUAGE_PREFERENCE_KEY, JSON.stringify(preference));
5548
- };
5549
- const handleLanguageChange = () => {
5550
- if (detectedLocale) {
5551
- savePreference(detectedLocale, "accepted");
5552
- const pathname = window.location.pathname;
5553
- const newPathname = pathname.replace(`/${currentLocale}`, `/${detectedLocale}`);
5554
- router.push(newPathname);
5555
- setShow(false);
5556
- }
5557
- };
5558
- const handleClose = () => {
5559
- if (detectedLocale) {
5560
- savePreference(detectedLocale, "rejected");
5561
- }
5562
- setShow(false);
5563
- };
5564
- if (!detectedLocale || !show) return null;
5565
- return /* @__PURE__ */ jsx81("div", { className: "fixed top-16 right-4 z-40 w-[420px]", children: /* @__PURE__ */ jsx81("div", { className: `shadow-lg rounded-lg transition-all duration-300 ${show ? "translate-x-0 opacity-100" : "translate-x-full opacity-0"}
5566
- bg-linear-to-r from-purple-100/95 via-white/95 to-purple-100/95 backdrop-blur-xs
5567
- animate-gradient-x`, children: /* @__PURE__ */ jsxs29("div", { className: "relative px-6 py-4 overflow-hidden", children: [
5568
- /* @__PURE__ */ jsxs29("div", { className: "relative z-10 flex flex-col gap-3", children: [
5569
- /* @__PURE__ */ jsxs29("div", { className: "flex items-start justify-between gap-4", children: [
5570
- /* @__PURE__ */ jsxs29("div", { className: "flex flex-col gap-1.5", children: [
5571
- /* @__PURE__ */ jsx81("h3", { className: "text-lg font-semibold text-gray-900", children: t("title") }),
5572
- /* @__PURE__ */ jsxs29("p", { className: "text-base text-gray-600", children: [
5573
- t("description"),
5574
- " ",
5575
- /* @__PURE__ */ jsx81("span", { className: "text-purple-500 font-semibold", children: detectedLocale === "zh" ? "\u4E2D\u6587" : "English" }),
5576
- "?"
5577
- ] })
5578
- ] }),
5579
- /* @__PURE__ */ jsx81(
5580
- "button",
5581
- {
5582
- onClick: handleClose,
5583
- className: "text-gray-500 hover:text-gray-700",
5584
- children: /* @__PURE__ */ jsx81(globalLucideIcons.X, { className: "h-5 w-5" })
5585
- }
5586
- )
5587
- ] }),
5588
- /* @__PURE__ */ jsxs29("div", { className: "flex items-center gap-3", children: [
5589
- /* @__PURE__ */ jsx81(
5590
- "button",
5591
- {
5592
- onClick: handleClose,
5593
- className: "flex-1 px-4 py-2 text-base bg-gray-100 text-gray-600 rounded-md hover:bg-gray-200",
5594
- children: t("close")
5595
- }
5596
- ),
5597
- /* @__PURE__ */ jsx81(
5598
- "button",
5599
- {
5600
- onClick: handleLanguageChange,
5601
- className: "flex-1 px-4 py-2 text-base bg-purple-500 text-white rounded-md hover:bg-purple-600",
5602
- children: t("changeAction")
5603
- }
5604
- )
5605
- ] })
5606
- ] }),
5607
- /* @__PURE__ */ jsx81("div", { className: "absolute inset-0 bg-linear-to-r from-transparent via-purple-200/30 to-transparent animate-shimmer" })
5608
- ] }) }) });
5609
- }
5610
-
5611
- // src/components/language-switcher.tsx
5612
- import { usePathname, useRouter as useRouter2 } from "next/navigation";
5613
- import { useLocale as useLocale2 } from "next-intl";
5614
- import { jsx as jsx82, jsxs as jsxs30 } from "react/jsx-runtime";
5615
- function LanguageSwitcher({ locales, localeLabels }) {
5616
- const locale = useLocale2();
5617
- const router = useRouter2();
5618
- const pathname = usePathname();
5619
- const handleLocaleChange = (newLocale) => {
5620
- const newPathname = pathname.replace(`/${locale}`, `/${newLocale}`);
5621
- router.push(newPathname);
5622
- };
5623
- return /* @__PURE__ */ jsxs30(DropdownMenu, { children: [
5624
- /* @__PURE__ */ jsx82(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx82(
5625
- LanguageButton,
5626
- {
5627
- variant: "ghost",
5628
- size: "icon",
5629
- 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",
5630
- children: /* @__PURE__ */ jsx82(globalLucideIcons.Globe, { className: "h-5 w-5" })
5631
- }
5632
- ) }),
5633
- /* @__PURE__ */ jsx82(
5634
- DropdownMenuContent,
5635
- {
5636
- align: "end",
5637
- sideOffset: 5,
5638
- 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]",
5639
- children: /* @__PURE__ */ jsx82("div", { className: "grid grid-cols-2 gap-1", children: locales.map((loc) => /* @__PURE__ */ jsx82(
5640
- DropdownMenuItem,
5641
- {
5642
- className: `
5643
- px-2 py-2 text-sm cursor-pointer text-center justify-center
5644
- transition-all duration-300 ease-in-out
5645
- hover:scale-105 hover:shadow-md
5646
- rounded-md whitespace-nowrap
5647
- ${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"}
5648
- `,
5649
- onClick: () => handleLocaleChange(loc),
5650
- children: localeLabels[loc]
5651
- },
5652
- loc
5653
- )) })
5654
- }
5655
- )
5656
- ] });
5657
- }
5658
-
5659
- // src/components/script/google-analytics-script.tsx
5660
- import Script from "next/script";
5661
- import { Fragment as Fragment3, jsx as jsx83, jsxs as jsxs31 } from "react/jsx-runtime";
5662
- var googleAnalyticsId = process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS_ID;
5663
- function GoogleAnalyticsScript() {
5664
- if (process.env.NODE_ENV !== "production") {
5665
- return null;
5666
- }
5667
- return /* @__PURE__ */ jsxs31(Fragment3, { children: [
5668
- /* @__PURE__ */ jsx83(
5669
- Script,
5670
- {
5671
- strategy: "afterInteractive",
5672
- src: `https://www.googletagmanager.com/gtag/js?id=${googleAnalyticsId}`
5673
- }
5674
- ),
5675
- /* @__PURE__ */ jsx83(
5676
- Script,
5677
- {
5678
- id: "google-analytics",
5679
- strategy: "afterInteractive",
5680
- dangerouslySetInnerHTML: {
5681
- __html: `
5682
- window.dataLayer = window.dataLayer || [];
5683
- function gtag(){dataLayer.push(arguments);}
5684
- gtag('js', new Date());
5685
- gtag('config', '${googleAnalyticsId}');
5686
- `
5687
- }
5688
- }
5689
- )
5690
- ] });
5691
- }
5692
- function useGoogleAnalytics() {
5693
- const trackEvent = (event, data) => {
5694
- if (typeof window === "undefined" || !window.gtag) {
5695
- return;
5696
- }
5697
- window.gtag("event", event, data);
5698
- };
5699
- return {
5700
- trackEvent
5701
- };
5702
- }
5703
-
5704
- // src/components/script/microsoft-clarity-script.tsx
5705
- import Script2 from "next/script";
5706
- import { jsx as jsx84 } from "react/jsx-runtime";
5707
- var microsoftClarityId = process.env.NEXT_PUBLIC_MICROSOFT_CLARITY_ID;
5708
- function MicrosoftClarityScript() {
5709
- if (process.env.NODE_ENV !== "production") {
5710
- return null;
5711
- }
5712
- return /* @__PURE__ */ jsx84(Script2, { id: "microsoft-clarity", strategy: "afterInteractive", children: `
5713
- (function(c,l,a,r,i,t,y){
5714
- c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
5715
- t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
5716
- y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
5717
- })(window, document, "clarity", "script", "${microsoftClarityId}");
5718
- ` });
5719
- }
5720
5416
  export {
5721
5417
  Accordion,
5722
5418
  AccordionContent,
@@ -5838,7 +5534,6 @@ export {
5838
5534
  FormItem,
5839
5535
  FormLabel,
5840
5536
  FormMessage,
5841
- GoogleAnalyticsScript,
5842
5537
  HoverCard,
5843
5538
  HoverCardContent,
5844
5539
  HoverCardTrigger,
@@ -5850,8 +5545,6 @@ export {
5850
5545
  InputOTPSlot,
5851
5546
  Label3 as Label,
5852
5547
  LanguageButton,
5853
- LanguageDetector,
5854
- LanguageSwitcher,
5855
5548
  Menubar,
5856
5549
  MenubarCheckboxItem,
5857
5550
  MenubarContent,
@@ -5868,7 +5561,6 @@ export {
5868
5561
  MenubarSubContent,
5869
5562
  MenubarSubTrigger,
5870
5563
  MenubarTrigger,
5871
- MicrosoftClarityScript,
5872
5564
  NavigationMenu,
5873
5565
  NavigationMenuContent,
5874
5566
  NavigationMenuIndicator,
@@ -5878,7 +5570,6 @@ export {
5878
5570
  NavigationMenuTrigger,
5879
5571
  NavigationMenuViewport,
5880
5572
  NotFoundIcon,
5881
- NotFoundPage,
5882
5573
  Pagination,
5883
5574
  PaginationContent,
5884
5575
  PaginationEllipsis,
@@ -5984,7 +5675,6 @@ export {
5984
5675
  toast,
5985
5676
  toggleVariants,
5986
5677
  useFormField,
5987
- useGoogleAnalytics,
5988
5678
  useIsMobile,
5989
5679
  useSidebar,
5990
5680
  useToast