{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "expandable-text",
  "title": "Expandable Text",
  "type": "registry:ui",
  "files": [
    {
      "path": "packages/registry-native/components/expandable-text/ExpandableText.tsx",
      "content": "import * as React from 'react'\nimport { View, useWindowDimensions, type ViewProps } from 'react-native'\nimport { Button } from '@/components/ui/button'\nimport { Text, type TextProps } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport interface ExpandableTextProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  text: string\n  maxLines?: number\n  expanded?: boolean\n  defaultExpanded?: boolean\n  onExpandedChange?: (expanded: boolean) => void\n  moreLabel?: string\n  lessLabel?: string\n  textClassName?: string\n  textSize?: TextProps['size']\n  textVariant?: TextProps['variant']\n  maxFontSizeMultiplier?: number\n}\n\nexport function ExpandableText({\n  className,\n  text,\n  maxLines = 3,\n  expanded,\n  defaultExpanded = false,\n  onExpandedChange,\n  moreLabel = 'Show more',\n  lessLabel = 'Show less',\n  textClassName,\n  textSize,\n  textVariant,\n  maxFontSizeMultiplier,\n  ...props\n}: ExpandableTextProps) {\n  const { width, fontScale } = useWindowDimensions()\n  const lines = Number.isSafeInteger(maxLines) && maxLines > 0 ? maxLines : 3\n  const [internal, setInternal] = React.useState(defaultExpanded)\n  const shownExpanded = expanded ?? internal\n  const measurement = [text, width, fontScale, textSize, textVariant, textClassName, maxFontSizeMultiplier].join('\\0')\n  const activeMeasurement = React.useRef(measurement)\n  React.useLayoutEffect(() => {\n    activeMeasurement.current = measurement\n  }, [measurement])\n  const [layout, setLayout] = React.useState<{ measurement: string; lines: number }>()\n  const canExpand = layout?.measurement === measurement && layout.lines > lines\n  const action = shownExpanded ? lessLabel : moreLabel\n  const typography = { className: textClassName, size: textSize, variant: textVariant, maxFontSizeMultiplier }\n\n  return (\n    <View {...props} className={cn('gap-1', className)}>\n      <Text {...typography} numberOfLines={shownExpanded ? undefined : lines}>\n        {text}\n      </Text>\n      {text ? (\n        <View\n          pointerEvents=\"none\"\n          aria-hidden\n          accessibilityElementsHidden\n          importantForAccessibility=\"no-hide-descendants\"\n          className=\"absolute inset-x-0 top-0 opacity-0\"\n        >\n          <Text\n            {...typography}\n            key={measurement}\n            onTextLayout={({ nativeEvent }) => {\n              if (activeMeasurement.current !== measurement) return\n              const count = nativeEvent.lines.length\n              setLayout((previous) =>\n                previous?.measurement === measurement && previous.lines === count\n                  ? previous\n                  : { measurement, lines: count },\n              )\n            }}\n          >\n            {text}\n          </Text>\n        </View>\n      ) : null}\n      {canExpand ? (\n        <Button\n          variant=\"ghost\"\n          className=\"self-start\"\n          accessibilityLabel={action}\n          accessibilityState={{ expanded: shownExpanded }}\n          onPress={() => {\n            if (expanded === undefined) setInternal(!shownExpanded)\n            onExpandedChange?.(!shownExpanded)\n          }}\n        >\n          {action}\n        </Button>\n      ) : null}\n    </View>\n  )\n}\n",
      "type": "registry:ui",
      "target": "~/components/ui/expandable-text/ExpandableText.tsx"
    },
    {
      "path": "packages/registry-native/components/expandable-text/index.ts",
      "content": "export { ExpandableText, type ExpandableTextProps } from './ExpandableText'\n",
      "type": "registry:ui",
      "target": "~/components/ui/expandable-text/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "A native paragraph that offers a disclosure action when its text exceeds the selected line limit.",
  "categories": [
    "typography"
  ]
}