import { GitBranch } from "lucide-react"; import React from "react"; // Version info - fallback to direct import if build-time replacement fails import packageJson from "../../package.json"; import { cn } from "../hooks"; declare const __PACKAGE_VERSION__: string; declare const __PACKAGE_NAME__: string; declare const __GIT_HASH__: string; const PACKAGE_VERSION = typeof __PACKAGE_VERSION__ !== "undefined" ? __PACKAGE_VERSION__ : packageJson.version; const PACKAGE_NAME = typeof __PACKAGE_NAME__ !== "undefined" ? __PACKAGE_NAME__ : packageJson.name; const GIT_HASH = typeof __GIT_HASH__ !== "undefined" ? __GIT_HASH__ : "unknown"; interface PackageBadgeProps { /** * Additional CSS classes to apply to the badge */ className?: string; /** * Package name to display (e.g., "vuer", "uikit") */ packageName?: string; /** * Full package name for npm link (e.g., "@vuer-ai/vuer-uikit") */ packageFullName?: string; /** * Version string to display (e.g., "v0.0.72" or "0.0.72") */ versionText?: string; /** * Whether the version should be clickable (links to npm) */ linkable?: boolean; /** * Git hash to display (if provided) */ gitHash?: string; } /** * Low-level badge component that displays package information with provided values */ function PackageBadge({ className, packageName, packageFullName, versionText, linkable = true, gitHash, }: PackageBadgeProps) { const npmUrl = packageFullName && versionText ? `https://www.npmjs.com/package/${packageFullName}/v/${versionText.replace("v", "")}` : undefined; return (
{(packageName || versionText) && (
{packageName && ( {packageName} )} {versionText && ( e.preventDefault() : undefined} > {versionText} )}
)} {gitHash && gitHash !== "unknown" && ( e.preventDefault() : undefined} > {gitHash} )}
); } interface UIKitBadgeProps { /** * Additional CSS classes to apply to the badge */ className?: string; /** * Whether to show the package name */ package?: boolean; /** * Whether to show just the version or include "v" prefix */ prefix?: boolean; /** * Whether the badge should be clickable (links to npm/github) */ linkable?: boolean; /** * Whether to show the version */ version?: boolean; /** * Whether to show the git hash */ hash?: boolean; } /** * High-level badge component that displays the current package version with boolean flags * Format: [ vuer | v0.0.72 ] hash */ function UIKitBadge({ className, package: showPackage = false, prefix = false, linkable = false, version = false, hash = false, }: UIKitBadgeProps) { const packageShortName = PACKAGE_NAME.split("/").pop() || PACKAGE_NAME; const versionText = version ? (prefix ? `v${PACKAGE_VERSION}` : PACKAGE_VERSION) : undefined; return ( ); } // Export version and git hash for external use export { PACKAGE_VERSION, GIT_HASH, PackageBadge, UIKitBadge }; export type { PackageBadgeProps, UIKitBadgeProps };