{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "size-guide",
  "title": "Size Guide",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/size-guide/SizeGuide.tsx",
      "content": "import { useMemo, useState } from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { SegmentedControl, SegmentedControlItem } from '@/components/ui/segmented-control'\nimport { Text } from '@/components/ui/text'\nimport { cn } from '@/lib/utils'\n\nexport type SizeGuideUnit = 'cm' | 'in'\n\nexport interface SizeGuideMeasurement {\n  label: string\n  /** Canonical millimeters, converted only for display. */\n  minMm: number\n  maxMm?: number\n}\n\nexport interface SizeGuideRow {\n  id: string\n  label: string\n  measurements: readonly SizeGuideMeasurement[]\n}\n\ninterface SizeGuideLabels {\n  units: string\n  centimeters: string\n  inches: string\n  centimeterSymbol: string\n  inchSymbol: string\n  empty: string\n  unavailable: string\n}\n\nexport interface SizeGuideProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  title?: string\n  description?: string\n  /** A small chart for one product category, with measurements suitable to that category. */\n  rows?: readonly SizeGuideRow[]\n  unit?: SizeGuideUnit\n  defaultUnit?: SizeGuideUnit\n  onUnitChange?: (unit: SizeGuideUnit) => void\n  locale?: string\n  labels?: Partial<SizeGuideLabels>\n}\n\nfunction measureFormat(locale?: string) {\n  const options = { maximumFractionDigits: 1 }\n  try {\n    return new Intl.NumberFormat(locale, options)\n  } catch {\n    return new Intl.NumberFormat(undefined, options)\n  }\n}\n\nexport function SizeGuide({\n  className,\n  title = 'Size guide',\n  description,\n  rows = [],\n  unit,\n  defaultUnit = 'cm',\n  onUnitChange,\n  locale,\n  labels,\n  ...props\n}: SizeGuideProps) {\n  const [internalUnit, setInternalUnit] = useState<SizeGuideUnit>(defaultUnit)\n  const current = unit ?? internalUnit\n  const formatter = useMemo(() => measureFormat(locale), [locale])\n  const divisor = current === 'cm' ? 10 : 25.4\n  const symbol = current === 'cm' ? (labels?.centimeterSymbol ?? 'cm') : (labels?.inchSymbol ?? 'in')\n\n  function describe({ minMm, maxMm }: SizeGuideMeasurement) {\n    if (!Number.isFinite(minMm) || minMm <= 0 || (maxMm !== undefined && (!Number.isFinite(maxMm) || maxMm < minMm))) {\n      return labels?.unavailable ?? 'Unavailable'\n    }\n    const lower = formatter.format(minMm / divisor)\n    const upper = maxMm === undefined ? lower : formatter.format(maxMm / divisor)\n    return `${lower === upper ? lower : `${lower}–${upper}`} ${symbol}`\n  }\n\n  return (\n    <View {...props} className={cn('gap-[16px]', className)}>\n      <View className=\"gap-[8px]\">\n        <Text size=\"title\" accessibilityRole=\"header\">\n          {title}\n        </Text>\n        {description ? <Text variant=\"muted\">{description}</Text> : null}\n      </View>\n      {rows.length ? (\n        <>\n          <SegmentedControl\n            accessibilityLabel={labels?.units ?? 'Measurement units'}\n            value={current}\n            onValueChange={(next) => {\n              if (next !== 'cm' && next !== 'in') return\n              if (unit === undefined) setInternalUnit(next)\n              onUnitChange?.(next)\n            }}\n          >\n            <SegmentedControlItem value=\"cm\">{labels?.centimeters ?? 'Centimeters'}</SegmentedControlItem>\n            <SegmentedControlItem value=\"in\">{labels?.inches ?? 'Inches'}</SegmentedControlItem>\n          </SegmentedControl>\n          <View className=\"gap-[8px]\">\n            {rows.map((row) => (\n              <View key={row.id} className=\"gap-[8px] rounded-lg border border-border bg-card p-[16px]\">\n                <Text accessibilityRole=\"header\" className=\"font-semibold text-card-foreground\">\n                  {row.label}\n                </Text>\n                {row.measurements.map((measurement) => (\n                  <View key={measurement.label} className=\"flex-row flex-wrap items-start justify-between gap-[8px]\">\n                    <Text size=\"sm\" variant=\"muted\" className=\"min-w-[120px] shrink\">\n                      {measurement.label}\n                    </Text>\n                    <Text size=\"sm\" className=\"shrink text-card-foreground\" style={{ fontVariant: ['tabular-nums'] }}>\n                      {describe(measurement)}\n                    </Text>\n                  </View>\n                ))}\n              </View>\n            ))}\n          </View>\n        </>\n      ) : (\n        <Text variant=\"muted\">{labels?.empty ?? 'Size measurements aren’t available.'}</Text>\n      )}\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/size-guide/SizeGuide.tsx"
    },
    {
      "path": "packages/registry-native/blocks/size-guide/index.ts",
      "content": "export {\n  SizeGuide,\n  type SizeGuideMeasurement,\n  type SizeGuideProps,\n  type SizeGuideRow,\n  type SizeGuideUnit,\n} from './SizeGuide'\n",
      "type": "registry:block",
      "target": "~/components/blocks/size-guide/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/segmented-control.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Readable product size chart with centimeter and inch measurements converted from canonical values.",
  "categories": [
    "commerce"
  ]
}