{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "state-panel",
  "type": "registry:ui",
  "title": "State Panel",
  "description": "Empty, loading, success, and error states in one place.",
  "categories": [
    "feedback"
  ],
  "dependencies": [
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/spinner.json",
    "https://sprout.tulipfarm.ai/r/state-panel-samples.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/state-panel.tsx",
      "type": "registry:ui",
      "target": "components/ui/state-panel.tsx",
      "content": "export * from '@/lib/sprout/state-panel-core';\nexport * from '@/components/ui/state-panel-samples';\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/check-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/check-icon.tsx",
      "content": "import { Tick02Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const CheckIcon = /* @__PURE__ */ createIcon(glyph, 'CheckIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/inbox-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/inbox-icon.tsx",
      "content": "import { InboxIcon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const InboxIcon = /* @__PURE__ */ createIcon(glyph, 'InboxIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/warning-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/warning-icon.tsx",
      "content": "import { Alert02Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const WarningIcon = /* @__PURE__ */ createIcon(glyph, 'WarningIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/state-panel-core.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/state-panel-core.tsx",
      "content": "import type { ComponentType, HTMLAttributes, ReactNode } from 'react';\nimport { CheckIcon } from '@/lib/sprout/icons/check-icon';\nimport { InboxIcon } from '@/lib/sprout/icons/inbox-icon';\nimport { WarningIcon } from '@/lib/sprout/icons/warning-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { Spinner } from '@/components/ui/spinner';\n\nexport const statePanelKindNames = ['empty', 'loading', 'success', 'unavailable', 'error'] as const;\n\nexport type StatePanelKind = (typeof statePanelKindNames)[number];\nexport type StatePanelHeading = 'h1' | 'h2' | 'h3' | 'h4';\nexport type StatePanelIcon = ComponentType<{ size?: number }>;\n\ninterface StatePanelBaseProps extends Omit<HTMLAttributes<HTMLElement>, 'title' | 'children' | 'role'> {\n  title: ReactNode;\n  description: ReactNode;\n  heading?: StatePanelHeading | undefined;\n  icon?: StatePanelIcon | null | undefined;\n  children?: ReactNode;\n}\n\nexport type StatePanelProps = StatePanelBaseProps &\n  (\n    | {\n        kind: 'empty';\n        sample?: ReactNode;\n      }\n    | {\n        kind: 'loading' | 'success' | 'unavailable';\n        sample?: never;\n      }\n    | {\n        kind: 'error';\n        children: ReactNode;\n        sample?: never;\n      }\n  );\n\nconst roles: Partial<Record<StatePanelKind, 'alert' | 'status'>> = {\n  error: 'alert',\n  loading: 'status',\n  success: 'status',\n};\n\nfunction Media({ kind, Icon }: { kind: StatePanelKind; Icon: StatePanelIcon }) {\n  return (\n    <div data-slot=\"state-panel-media\" className=\"sprout-state-panel-media\" aria-hidden=\"true\">\n      {kind === 'loading' ? (\n        <Spinner aria-hidden=\"true\" />\n      ) : kind === 'success' ? (\n        <CheckIcon size=\"xl\" />\n      ) : kind === 'error' ? (\n        <WarningIcon size=\"xl\" className=\"sprout-state-panel-danger\" />\n      ) : (\n        <Icon size={20} />\n      )}\n    </div>\n  );\n}\n\nexport function StatePanel({\n  kind,\n  title,\n  description,\n  heading: Heading = 'h2',\n  icon = InboxIcon,\n  children,\n  sample,\n  className,\n  ...props\n}: StatePanelProps) {\n  const media =\n    icon === null && (kind === 'empty' || kind === 'unavailable') ? null : (\n      <Media kind={kind} Icon={icon ?? InboxIcon} />\n    );\n  const hasActions = children !== undefined && children !== null && children !== false;\n\n  if (sample)\n    return (\n      <section\n        data-slot=\"state-panel\"\n        data-kind={kind}\n        data-layout=\"sample\"\n        {...props}\n        className={cn('sprout-state-panel', className)}\n      >\n        <div className=\"sprout-state-panel-card\">\n          <div className=\"sprout-state-panel-copy\">\n            {media}\n            <div className=\"sprout-state-panel-text\">\n              <Heading className=\"sprout-state-panel-title\">{title}</Heading>\n              <p className=\"sprout-state-panel-description\">{description}</p>\n            </div>\n            {hasActions && (\n              <div data-slot=\"state-panel-actions\" className=\"sprout-state-panel-actions\">\n                {children}\n              </div>\n            )}\n          </div>\n          <div data-slot=\"state-panel-sample\" className=\"sprout-state-panel-sample\" aria-hidden=\"true\" inert>\n            <div className=\"sprout-state-panel-sample-window\">{sample}</div>\n          </div>\n        </div>\n      </section>\n    );\n\n  return (\n    <div\n      data-slot=\"state-panel\"\n      data-kind={kind}\n      data-layout=\"centered\"\n      {...props}\n      className={cn('sprout-state-panel', className)}\n    >\n      {media}\n      <div role={roles[kind]} aria-atomic=\"true\" className=\"sprout-state-panel-text\">\n        <Heading className=\"sprout-state-panel-title\">{title}</Heading>\n        <p className=\"sprout-state-panel-description\">{description}</p>\n      </div>\n      {hasActions && (\n        <div data-slot=\"state-panel-actions\" className=\"sprout-state-panel-actions\">\n          {children}\n        </div>\n      )}\n    </div>\n  );\n}\n"
    }
  ],
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/state-panel/",
  "meta": {
    "source": "packages/sprout/src/components/state-panel.tsx"
  }
}
