{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tw-skeleton",
  "type": "registry:ui",
  "title": "react-tw/skeleton.tsx",
  "description": "A loading placeholder in the shape of the content to come (Carbon skeleton states), as 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/tw-field",
    "@kanok-ui/tw-theme",
    "@kanok-ui/tw-utils"
  ],
  "files": [
    {
      "path": "src/react-tw/skeleton.tsx",
      "type": "registry:ui",
      "target": "components/ui/react-tw/skeleton.tsx",
      "content": "import type { ComponentProps, CSSProperties } from 'react';\nimport { cn } from './lib/utils.ts';\nimport { useFluid } from './field.tsx';\n\nexport type SkeletonShape = 'text' | 'heading' | 'field' | 'button' | 'block';\n\nexport interface SkeletonProps extends Omit<ComponentProps<'div'>, 'shape' | 'lines' | 'width' | 'height' | 'className'> {\n    shape?: SkeletonShape;\n    /** Number of lines of `shape=\"text\"`. */\n    lines?: number;\n    /** Bar width with its unit, e.g. \"200px\" or \"70%\" (default: full width; headings 50%, buttons 120px). A string, as Carbon `SkeletonText`. */\n    width?: string;\n    /** Height of `shape=\"block\"` with its unit, e.g. \"96px\" (default 160px). */\n    height?: string;\n    className?: string;\n}\n\n/**\n * A loading placeholder in the shape of the content to come (Carbon skeleton states), as\n * React + Tailwind, the look of `<ui-skeleton>`: Carbon's skeleton bar with its 3s sweep.\n *\n * Purely visual: hidden from assistive tech and never focusable. Tell screen-reader users about\n * loading on the container instead — `aria-busy=\"true\"` plus a short status message — and drop\n * both when the content arrives.\n */\nexport function Skeleton({ shape = 'text', lines = 3, width, height, className, ...rest }: Readonly<SkeletonProps>) {\n    const style = { '--ui-skeleton-width': width, '--ui-skeleton-height': height } as CSSProperties;\n    const bone = 'skeleton block w-(--ui-skeleton-width,100%) [&+&]:mt-2';\n    let bones;\n    if (shape === 'text') {\n        bones = Array.from({ length: Math.max(1, lines) }, (_, i) => <div key={i} className={cn(bone, 'h-[14px] [&:last-child:not(:first-child)]:w-[60%]')} />);\n    } else if (shape === 'field') {\n        bones = (\n            <>\n                <div className={cn(bone, 'mb-2 h-3 w-[30%]')} />\n                <div className={cn(bone, 'h-12')} />\n            </>\n        );\n    } else {\n        bones = (\n            <div\n                className={cn(\n                    bone,\n                    shape === 'heading' && 'h-6 w-(--ui-skeleton-width,50%)',\n                    shape === 'button' && 'h-12 w-(--ui-skeleton-width,120px)',\n                    shape === 'block' && 'h-(--ui-skeleton-height,160px)',\n                )}\n            />\n        );\n    }\n    return (\n        <div {...rest} aria-hidden=\"true\" style={{ ...rest.style, ...(style) }} className={cn(shape === 'button' ? 'inline-block' : 'block', className)}>\n            {bones}\n        </div>\n    );\n}\n\nexport interface FieldSkeletonProps extends ComponentProps<'div'> {\n    /** The field's height: sm 32px, md 40px, lg 48px. */\n    size?: 'sm' | 'md' | 'lg';\n    /** No label bar (the field had `hideLabel`). */\n    hideLabel?: boolean;\n    /** The fluid field's skeleton (Carbon `Fluid*Skeleton`); a `FluidForm` around it sets it too. */\n    fluid?: boolean;\n}\n\n/**\n * Carbon's fluid field skeleton box (FluidTextInput / FluidDropdown / FluidSelect … Skeleton): 64px in skeleton-background\n * with a 1px skeleton-element line below, a 25% bar 16px in and a 50% bar at 36px.\n */\nexport function FluidSkeletonBox({ className, children, ...rest }: Readonly<ComponentProps<'div'>>) {\n    return (\n        <div {...rest} className={cn('relative box-border h-16 border-0 border-b border-solid border-skeleton-element bg-skeleton-background', className)}>\n            <span className=\"skeleton absolute start-4 top-4 block h-2 w-1/4\" />\n            <span className=\"skeleton absolute start-4 top-9 block h-2 w-1/2\" />\n            {children}\n        </div>\n    );\n}\n\nconst FIELD_HEIGHT = { sm: 'h-field-sm', md: 'h-field-md', lg: 'h-field-lg' } as const;\n\n/** Carbon's field skeleton bars: a 75×14 label bar, 8px, the field's bar (`height` overrides the size's). */\nexport function FieldSkeleton({ size = 'md', hideLabel = false, fluid: fluidProp, height, className, ...rest }: Readonly<FieldSkeletonProps & { height?: string }>) {\n    const fluid = useFluid(fluidProp);\n    if (fluid) {\n        return (\n            <div {...rest} aria-hidden=\"true\" className={cn('block', className)}>\n                <FluidSkeletonBox />\n            </div>\n        );\n    }\n    return (\n        <div {...rest} aria-hidden=\"true\" className={cn('block', className)}>\n            {hideLabel ? null : <span className=\"skeleton mb-2 block h-3.5 w-[75px]\" />}\n            <div className={cn('skeleton block w-full rounded-[var(--ui-field-radius,var(--ui-skeleton-radius))]', height ?? FIELD_HEIGHT[size])} />\n        </div>\n    );\n}\n"
    }
  ]
}
