'use client' import type { ReactNode } from 'react' import type { AccessPointStatus } from './status' import { cn } from '@langgenius/dify-ui/cn' import { StatusDot, StatusDotSkeleton } from '@langgenius/dify-ui/status-dot' import { Switch } from '@langgenius/dify-ui/switch' import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/tooltip' import { useId } from 'react' type AccessPointCardProps = { actions?: ReactNode children: ReactNode description: string icon: ReactNode | string status: AccessPointStatus statusLabel: string title: string className?: string headingLevel?: 2 | 3 highlighted?: boolean onEnabledChange?: (enabled: boolean) => void showStatus?: boolean switchDisabled?: boolean switchDisabledReason?: string switchLabel?: string switchLoading?: boolean } export function AccessPointCard({ actions, children, className, description, headingLevel = 2, highlighted = false, icon, onEnabledChange, showStatus = true, status, statusLabel, switchDisabled = false, switchDisabledReason, switchLabel, switchLoading = false, title, }: AccessPointCardProps) { const titleId = useId() const isEnabled = status === 'inService' const isLoading = status === 'loading' const showSwitch = (status === 'disabled' || status === 'inService') && Boolean(onEnabledChange) const hasSwitchDisabledReason = switchDisabled && Boolean(switchDisabledReason) const Heading = headingLevel === 3 ? 'h3' : 'h2' const switchControl = ( { if (!switchDisabled) onEnabledChange?.(enabled) }} /> ) return (
{typeof icon === 'string' ? ( ) : ( icon )} {title} {description} {showStatus && ( <> {isLoading ? ( ) : ( )} {statusLabel} {showSwitch && (hasSwitchDisabledReason ? ( {switchDisabledReason} ) : ( switchControl ))} )}
{children}
{actions !== undefined && (
{actions}
)}
) } type AccessPointEndpointProps = { actions?: ReactNode label: string unavailableLabel: string value: string dimmed?: boolean loading?: boolean unavailable?: boolean } export function AccessPointEndpoint({ actions, dimmed = false, label, loading = false, unavailable = false, unavailableLabel, value, }: AccessPointEndpointProps) { return (
{label}
{unavailable && !loading && ( {unavailableLabel} )}
{loading ? ( ) : ( {value} )}
{actions}
) } export function AccessPointEmptyContent({ children }: { children: ReactNode }) { return (
{children}
) }