{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-status-indicator",
  "type": "registry:ui",
  "title": "react-tw/status-indicator.tsx",
  "description": "Carbon .cds--icon-indicator / .cds--shape-indicator: the icon then the label, 8px apart, in text-secondary; Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [
    "@kanok-ui/core-position",
    "@kanok-ui/core-status-indicator",
    "@kanok-ui/tw-definition-tooltip",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/status-indicator.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/status-indicator.tsx",
      "content": "import type { ComponentProps, ReactNode } from 'react';\nimport { ICON_INDICATOR_KINDS, SHAPE_INDICATOR_KINDS, iconIndicatorLook, shapeIndicatorLook, toneFill, type IconIndicatorKind, type ShapeIndicatorKind, type StatusLook } from '../core/status-indicator.ts';\nimport type { Placement } from '../core/position.ts';\nimport { DefinitionTooltip } from './definition-tooltip.tsx';\nimport { cn } from './lib/utils.ts';\n\nfunction StatusIconSvg({ look, size }: Readonly<{ look: StatusLook; size: number }>) {\n    return (\n        <svg width={size} height={size} viewBox={look.icon.viewBox} aria-hidden=\"true\" className=\"block flex-none self-center\">\n            {look.icon.paths.map((p) => (\n                <path key={p.d} d={p.d} style={{ fill: toneFill(look, p.tone) }} />\n            ))}\n        </svg>\n    );\n}\n\n/**\n * Carbon .cds--icon-indicator / .cds--shape-indicator: the icon then the label, 8px apart, in text-secondary;\n * `leading-none` is what Carbon's `line-height: unset` gives under its reset (one row as tall as the icon).\n * Compact: the icon is a definition tooltip's trigger (no underline, a 1px focus outline; the bubble 2px top and bottom).\n */\nfunction Indicator({ icon, label, compact, description, placement, className, rest }: Readonly<{ icon: ReactNode; label: string; compact: boolean; description?: string; placement: Placement; className: string; rest: ComponentProps<'div'> }>) {\n    return (\n        <div {...rest} className={cn('flex items-center gap-2 text-ink-muted leading-none!', compact && '[&_[role=tooltip]]:py-0.5', className)}>\n            {compact ? (\n                <DefinitionTooltip definition={label} placement={placement} openOnHover className=\"flex\" triggerClassName=\"flex border-0 border-b-0 focus-visible:rounded-[var(--ui-link-focus-radius,0px)] focus-visible:outline-1 focus-visible:outline-offset-0\">\n                    {icon}\n                    <span className=\"sr-only\">{description ?? label}</span>\n                </DefinitionTooltip>\n            ) : (\n                <>\n                    {icon}\n                    {label}\n                </>\n            )}\n        </div>\n    );\n}\n\nexport interface IconIndicatorProps extends Omit<ComponentProps<'div'>, 'children'> {\n    kind: IconIndicatorKind;\n    label: string;\n    /** 16 (body-compact-01) or 20 (body-compact-02). */\n    size?: 16 | 20;\n    /** Only the icon; the label in a tooltip. */\n    compact?: boolean;\n    /** Read by screen readers in compact mode instead of the label. */\n    iconDescription?: string;\n    /** Where the compact tooltip opens. */\n    placement?: Placement;\n}\n\n/**\n * Carbon `IconIndicator` (preview) as React + Tailwind, the look of `<ui-icon-indicator>`: a status shown by Carbon's\n * icon for `kind` in its status colour, then `label`; `compact` shows only the icon with the label in a tooltip.\n */\nexport function IconIndicator({ kind, label, size = 16, compact = false, iconDescription, placement = 'right', className, ...rest }: Readonly<IconIndicatorProps>) {\n    if (!ICON_INDICATOR_KINDS.includes(kind)) return null;\n    const px = size === 20 ? 20 : 16;\n    const type = px === 20 ? '[font:var(--ui-font-body)] tracking-normal' : 'type-body-sm';\n    return <Indicator icon={<StatusIconSvg look={iconIndicatorLook(kind, px)} size={px} />} label={label} compact={compact} description={iconDescription} placement={placement} className={cn(type, className)} rest={rest} />;\n}\n\nexport interface ShapeIndicatorProps extends Omit<ComponentProps<'div'>, 'children'> {\n    kind: ShapeIndicatorKind;\n    label: string;\n    /** 12 (helper-text-01) or 14 (body-compact-01). */\n    textSize?: 12 | 14;\n    /** Only the shape; the label in a tooltip. */\n    compact?: boolean;\n    /** Read by screen readers in compact mode instead of the label. */\n    shapeDescription?: string;\n    /** Where the compact tooltip opens. */\n    placement?: Placement;\n}\n\n/**\n * Carbon `ShapeIndicator` (preview) as React + Tailwind, the look of `<ui-shape-indicator>`: a status shown by a 16px\n * shape for `kind` (severity or state) in its status colours, then `label`; `compact` shows only the shape.\n */\nexport function ShapeIndicator({ kind, label, textSize = 12, compact = false, shapeDescription, placement = 'right', className, ...rest }: Readonly<ShapeIndicatorProps>) {\n    if (!SHAPE_INDICATOR_KINDS.includes(kind)) return null;\n    const type = textSize === 14 ? 'type-body-sm' : 'type-caption';\n    return <Indicator icon={<StatusIconSvg look={shapeIndicatorLook(kind)} size={16} />} label={label} compact={compact} description={shapeDescription} placement={placement} className={cn(type, className)} rest={rest} />;\n}\n"
    }
  ]
}
