@windrun-huaiin/base-ui 4.1.1 → 5.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.
Files changed (35) hide show
  1. package/dist/components/{client/index.d.mts → index.d.cts} +6 -23
  2. package/dist/components/index.d.ts +44 -125
  3. package/dist/components/index.js +827 -220
  4. package/dist/components/index.js.map +1 -1
  5. package/dist/components/index.mjs +799 -129
  6. package/dist/components/index.mjs.map +1 -1
  7. package/dist/components/{index.d.mts → server.d.cts} +8 -1
  8. package/dist/components/server.d.ts +138 -0
  9. package/dist/{index.js → components/server.js} +373 -200
  10. package/dist/components/server.js.map +1 -0
  11. package/dist/{index.mjs → components/server.mjs} +343 -107
  12. package/dist/components/server.mjs.map +1 -0
  13. package/dist/ui/index.js +478 -334
  14. package/dist/ui/index.js.map +1 -1
  15. package/dist/ui/index.mjs +400 -150
  16. package/dist/ui/index.mjs.map +1 -1
  17. package/package.json +14 -21
  18. package/src/components/404-page.tsx +7 -4
  19. package/src/components/index.ts +8 -15
  20. package/src/components/server.ts +4 -0
  21. package/src/components/site-icon.tsx +29 -37
  22. package/src/ui/index.ts +1 -1
  23. package/dist/components/client/index.d.ts +0 -67
  24. package/dist/components/client/index.js +0 -1645
  25. package/dist/components/client/index.js.map +0 -1
  26. package/dist/components/client/index.mjs +0 -1613
  27. package/dist/components/client/index.mjs.map +0 -1
  28. package/dist/index.d.mts +0 -4
  29. package/dist/index.d.ts +0 -4
  30. package/dist/index.js.map +0 -1
  31. package/dist/index.mjs.map +0 -1
  32. package/src/components/client/index.ts +0 -19
  33. package/src/components/icon-context.tsx +0 -57
  34. package/src/index.ts +0 -5
  35. /package/dist/ui/{index.d.mts → index.d.cts} +0 -0
package/package.json CHANGED
@@ -1,30 +1,23 @@
1
1
  {
2
2
  "name": "@windrun-huaiin/base-ui",
3
- "version": "4.1.1",
3
+ "version": "5.1.0",
4
4
  "description": "Base UI components for windrun-huaiin projects",
5
- "main": "./dist/index.js",
6
- "module": "./dist/index.mjs",
7
- "types": "./dist/index.d.ts",
5
+ "type": "module",
8
6
  "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- },
14
- "./ui/*": {
15
- "types": "./dist/ui/*.d.ts",
16
- "import": "./dist/ui/*.mjs",
17
- "require": "./dist/ui/*.js"
7
+ "./ui": {
8
+ "types": "./dist/ui/index.d.ts",
9
+ "import": "./dist/ui/index.mjs",
10
+ "require": "./dist/ui/index.js"
18
11
  },
19
12
  "./components": {
20
13
  "types": "./dist/components/index.d.ts",
21
14
  "import": "./dist/components/index.mjs",
22
15
  "require": "./dist/components/index.js"
23
16
  },
24
- "./components/client": {
25
- "types": "./dist/components/client/index.d.ts",
26
- "import": "./dist/components/client/index.mjs",
27
- "require": "./dist/components/client/index.js"
17
+ "./components/server": {
18
+ "types": "./dist/components/server.d.ts",
19
+ "import": "./dist/components/server.mjs",
20
+ "require": "./dist/components/server.js"
28
21
  },
29
22
  "./src/*": "./src/*",
30
23
  "./styles/base-ui.css": "./dist/base-ui.css"
@@ -43,15 +36,15 @@
43
36
  "@radix-ui/react-slot": "^1.2.2",
44
37
  "class-variance-authority": "^0.7.1",
45
38
  "lucide-react": "^0.511.0",
46
- "@windrun-huaiin/lib": "^4.0.0"
39
+ "@windrun-huaiin/lib": "^5.1.0"
47
40
  },
48
41
  "peerDependencies": {
49
- "react": "19.2.0-canary-3fbfb9ba-20250409",
50
- "react-dom": "19.2.0-canary-3fbfb9ba-20250409",
42
+ "clsx": "^2.0.0",
51
43
  "next": "15.3.2",
52
44
  "next-intl": "^3.26.5",
53
45
  "next-themes": "^0.4.6",
54
- "clsx": "^2.0.0",
46
+ "react": "19.1.0",
47
+ "react-dom": "19.1.0",
55
48
  "tailwind-merge": "^3.0.0",
56
49
  "tailwindcss": "^4.1.7"
57
50
  },
@@ -1,10 +1,13 @@
1
1
  'use client';
2
2
 
3
3
  import { NotFoundIcon } from "@base-ui/components/global-icon";
4
- import { SiteIcon } from "@base-ui/components/site-icon";
5
- import { useEffect, useState } from "react";
4
+ import { useEffect, useState, type ReactNode } from "react";
6
5
 
7
- export function NotFoundPage() {
6
+ interface NotFoundPageProps {
7
+ siteIcon: ReactNode;
8
+ }
9
+
10
+ export function NotFoundPage({ siteIcon }: NotFoundPageProps) {
8
11
  const [glitchText, setGlitchText] = useState("404");
9
12
 
10
13
  // glitch effect
@@ -62,7 +65,7 @@ export function NotFoundPage() {
62
65
  {/* decorative elements */}
63
66
  <div className="flex justify-center items-center gap-8 pt-8 opacity-60">
64
67
  <div className="flex items-center gap-2 text-sm text-muted-foreground">
65
- <SiteIcon />
68
+ {siteIcon}
66
69
  <span>Woops!</span>
67
70
  </div>
68
71
  <div className="w-1 h-1 bg-purple-500 rounded-full animate-ping" />
@@ -1,17 +1,10 @@
1
- // Server Components and Universal Components
2
- // ⚠️ IMPORTANT: To avoid client/server component mixing issues in Next.js bundling,
3
- // client components with 'use client' directive are exported separately.
4
- //
5
- // Usage:
6
- // - Server components: import from '@base-ui/components' (this file)
7
- // - Client components: import from '@base-ui/components/client'
8
- //
9
- // Example:
10
- // import { globalLucideIcons, getGlobalIcon } from '@base-ui/components'
11
- // import { NotFoundPage, GoToTop } from '@base-ui/components/client'
1
+ "use client"
2
+ export * from './404-page';
3
+ export * from './go-to-top';
4
+ export * from './language-detector';
5
+ export * from './language-switcher';
12
6
 
13
- // Main server/universal components
14
- export * from './global-icon';
7
+ // Script Components (All Client-side)
8
+ export * from './script/google-analytics-script';
9
+ export * from './script/microsoft-clarity-script';
15
10
 
16
- // For client components, please use:
17
- // import { ... } from '@base-ui/components/client'
@@ -0,0 +1,4 @@
1
+ // Main server/universal components
2
+ export * from './global-icon';
3
+ // Icon Configuration
4
+ export { createSiteIcon } from './site-icon';
@@ -1,46 +1,38 @@
1
- 'use client';
2
-
3
1
  import { type LucideProps } from 'lucide-react';
4
2
  import { cn } from '@lib/utils';
5
- import { useIconConfigSafe } from '@base-ui/components/icon-context';
6
3
  import { globalLucideIcons } from '@base-ui/components/global-icon';
7
4
  import { themeIconColor } from '@base-ui/lib/theme-util';
8
5
 
9
6
  /**
10
- * site icon component - client component
11
- * based on React Context to get the config, solve the problem of cross-package module instance isolation
7
+ * Create a SiteIcon component with specific configuration
8
+ * This function helps avoid React multi-instance issues by creating the icon component
9
+ * at the application level with explicit configuration
12
10
  */
13
- export function SiteIcon({
14
- size = 24,
15
- className,
16
- ...props
17
- }: Omit<LucideProps, 'children'>) {
18
- const configuredIcon = useIconConfigSafe('siteIcon');
19
-
20
- if (configuredIcon === undefined) {
21
- throw new Error(
22
- '[SiteIcon] Site icon is not configured. Please use <IconConfigProvider config={{ siteIcon: YourCustomIcon }}> or <IconConfigProvider config={{ siteIcon: "IconKeyName" }}> to set a custom site icon to avoid legal risks.'
23
- );
24
- }
25
-
26
- // render the icon, pass in the config value and attributes
27
- if (typeof configuredIcon === 'string') {
28
- // string type: the key name of globalLucideIcons
29
- if (configuredIcon === '') {
30
- // empty string use default icon
31
- const DefaultIcon = globalLucideIcons['Download' as keyof typeof globalLucideIcons];
32
- return <DefaultIcon size={size} className={cn(themeIconColor, className)} {...props} />;
33
- }
34
- const IconComponent = globalLucideIcons[configuredIcon as keyof typeof globalLucideIcons];
35
- if (!IconComponent) {
36
- throw new Error(`[SiteIcon] Icon key "${configuredIcon}" not found in globalLucideIcons.`);
11
+ export function createSiteIcon(iconConfig: string | React.ComponentType<LucideProps>) {
12
+ return function CreatedSiteIcon({
13
+ size = 24,
14
+ className,
15
+ ...props
16
+ }: Omit<LucideProps, 'children'>) {
17
+ // render the icon, pass in the config value and attributes
18
+ if (typeof iconConfig === 'string') {
19
+ // string type: the key name of globalLucideIcons
20
+ if (iconConfig === '') {
21
+ // empty string use default icon
22
+ const DefaultIcon = globalLucideIcons['Download' as keyof typeof globalLucideIcons];
23
+ return <DefaultIcon size={size} className={cn(themeIconColor, className)} {...props} />;
24
+ }
25
+ const IconComponent = globalLucideIcons[iconConfig as keyof typeof globalLucideIcons];
26
+ if (!IconComponent) {
27
+ throw new Error(`[CreatedSiteIcon] Icon key "${iconConfig}" not found in globalLucideIcons.`);
28
+ }
29
+ return <IconComponent size={size} className={cn(themeIconColor, className)} {...props} />;
30
+ } else {
31
+ // React component type: custom icon component
32
+ const CustomIcon = iconConfig as React.ComponentType<LucideProps>;
33
+ const hasColorClass = className && /text-\w+/.test(className);
34
+ const finalClassName = hasColorClass ? className : cn(themeIconColor, className);
35
+ return <CustomIcon size={size} className={finalClassName} {...props} />;
37
36
  }
38
- return <IconComponent size={size} className={cn(themeIconColor, className)} {...props} />;
39
- } else {
40
- // React component type: custom icon component
41
- const CustomIcon = configuredIcon as React.ComponentType<LucideProps>;
42
- const hasColorClass = className && /text-\w+/.test(className);
43
- const finalClassName = hasColorClass ? className : cn(themeIconColor, className);
44
- return <CustomIcon size={size} className={finalClassName} {...props} />;
45
- }
37
+ };
46
38
  }
package/src/ui/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- // UI Components - Only actively used components
1
+ "use client";
2
2
  export * from './alert-dialog';
3
3
  export { Button, buttonVariants, type ButtonProps } from './button';
4
4
  export * from './dropdown-menu';
@@ -1,67 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ComponentType, ReactNode } from 'react';
3
- import { LucideProps } from 'lucide-react';
4
-
5
- declare function NotFoundPage(): react_jsx_runtime.JSX.Element;
6
-
7
- type I18nConfig = {
8
- locales: readonly string[];
9
- detector: {
10
- storagePrefix: string;
11
- storageKey: string;
12
- autoCloseTimeout: number;
13
- expirationDays: number;
14
- };
15
- };
16
- interface LanguageDetectorProps {
17
- i18nConfig: I18nConfig;
18
- }
19
- declare function LanguageDetector({ i18nConfig }: LanguageDetectorProps): react_jsx_runtime.JSX.Element | null;
20
-
21
- /**
22
- * @license
23
- * MIT License
24
- * Copyright (c) 2025 D8ger
25
- *
26
- * This source code is licensed under the MIT license found in the
27
- * LICENSE file in the root directory of this source tree.
28
- */
29
- interface LanguageSwitcherProps {
30
- locales: readonly string[];
31
- localeLabels: Record<string, string>;
32
- }
33
- declare function LanguageSwitcher({ locales, localeLabels }: LanguageSwitcherProps): react_jsx_runtime.JSX.Element;
34
-
35
- declare function GoogleAnalyticsScript(): react_jsx_runtime.JSX.Element | null;
36
- declare function useGoogleAnalytics(): {
37
- trackEvent: (event: string, data?: Record<string, unknown>) => void;
38
- };
39
- declare global {
40
- interface Window {
41
- dataLayer: any[];
42
- gtag: (...args: any[]) => void;
43
- }
44
- }
45
-
46
- declare function MicrosoftClarityScript(): react_jsx_runtime.JSX.Element | null;
47
-
48
- interface IconConfig {
49
- siteIcon?: ComponentType | string;
50
- }
51
- interface IconConfigProviderProps {
52
- config: IconConfig;
53
- children: ReactNode;
54
- }
55
- /**
56
- * IconConfigProvider - icon config provider based on React Context
57
- * directly store the config value, without depending on module state
58
- */
59
- declare function IconConfigProvider({ config, children }: IconConfigProviderProps): react_jsx_runtime.JSX.Element;
60
-
61
- /**
62
- * site icon component - client component
63
- * based on React Context to get the config, solve the problem of cross-package module instance isolation
64
- */
65
- declare function SiteIcon({ size, className, ...props }: Omit<LucideProps, 'children'>): react_jsx_runtime.JSX.Element;
66
-
67
- export { GoogleAnalyticsScript, type IconConfig, IconConfigProvider, LanguageDetector, LanguageSwitcher, MicrosoftClarityScript, NotFoundPage, SiteIcon, useGoogleAnalytics };