{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "place-card",
  "title": "Place Card",
  "description": "Place details with rating, opening status, contact facts, and actions as a card or map popup.",
  "dependencies": [
    "class-variance-authority",
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "https://uaiblocks.dev/r/uai-theme.json",
    "https://uaiblocks.dev/r/uai-utils.json"
  ],
  "files": [
    {
      "path": "src/registry/uai/components/place-card.tsx",
      "content": "\"use client\";\n\nimport { cva } from \"class-variance-authority\";\nimport { Star, X } from \"lucide-react\";\nimport { type ComponentProps, createContext, useContext, useId } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/uai-utils\";\n\nexport const PLACE_CARD_VARIANTS = [\"card\", \"popup\", \"compact\"] as const;\nexport type PlaceCardVariant = (typeof PLACE_CARD_VARIANTS)[number];\nexport const PLACE_CARD_STATUSES = [\"open\", \"closing\", \"closed\"] as const;\nexport type PlaceCardOpenState = (typeof PLACE_CARD_STATUSES)[number];\nexport const PLACE_CARD_ACTION_EMPHASES = [\"primary\", \"secondary\"] as const;\nexport type PlaceCardActionEmphasis = (typeof PLACE_CARD_ACTION_EMPHASES)[number];\nexport type PlaceCardProps = ComponentProps<\"article\"> & { variant?: PlaceCardVariant };\n\ntype CardContext = { variant: PlaceCardVariant; titleId: string };\nconst Context = createContext<CardContext | null>(null);\nfunction usePlace(part: string) {\n  const context = useContext(Context);\n  if (!context) throw new Error(`${part} must be used within PlaceCard`);\n  return context;\n}\n\nconst placeCardVariants = cva(\n  \"relative grid min-w-0 content-start bg-card text-[13px]/[18px] text-card-foreground\",\n  {\n    variants: {\n      variant: {\n        card: \"w-80 gap-3 rounded-[14px] p-4 shadow-[0_0_0_1px_var(--border)]\",\n        popup:\n          \"w-72 origin-bottom gap-2.5 rounded-[14px] p-3 shadow-[0_0_0_1px_var(--border-strong),0_12px_28px_-10px_oklch(0_0_0/0.32),0_2px_6px_-2px_oklch(0_0_0/0.12)] duration-180 ease-[cubic-bezier(0.16,1,0.3,1)] animate-in fade-in-0 zoom-in-96 after:absolute after:top-full after:left-1/2 after:size-3 after:-translate-x-1/2 after:-translate-y-1.5 after:rotate-45 after:rounded-[3px] after:bg-card after:shadow-[1px_1px_0_0_var(--border-strong)] motion-reduce:animate-none\",\n        compact: \"w-64 gap-2 rounded-xl p-3 text-[12.5px]/[18px] shadow-[0_0_0_1px_var(--border)]\",\n      },\n    },\n  },\n);\n\n/** Details for one place, beside the map or anchored to its marker. */\nexport function PlaceCard({ variant = \"card\", className, children, ...props }: PlaceCardProps) {\n  const titleId = useId();\n  return (\n    <Context.Provider value={{ variant, titleId }}>\n      <article\n        data-slot=\"place-card\"\n        aria-labelledby={titleId}\n        className={cn(placeCardVariants({ variant }), className)}\n        {...props}\n        data-variant={variant}\n      >\n        {children}\n      </article>\n    </Context.Provider>\n  );\n}\n\n/** A photo or illustration. Pass an image with meaningful alt text, or alt=\"\" when decorative. */\nexport function PlaceCardMedia({ className, ...props }: ComponentProps<\"div\">) {\n  const context = usePlace(\"PlaceCardMedia\");\n  return (\n    <div\n      data-slot=\"place-card-media\"\n      className={cn(\n        \"overflow-hidden bg-muted [&>img]:size-full [&>img]:object-cover [&>svg]:size-full\",\n        context.variant === \"compact\" ? \"aspect-[2/1] rounded-lg\" : \"aspect-[16/9] rounded-[10px]\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport function PlaceCardHeader({ className, ...props }: ComponentProps<\"header\">) {\n  usePlace(\"PlaceCardHeader\");\n  return (\n    <header\n      data-slot=\"place-card-header\"\n      className={cn(\n        \"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 gap-y-0.5\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport function PlaceCardTitle({ className, ...props }: ComponentProps<\"h3\">) {\n  const context = usePlace(\"PlaceCardTitle\");\n  return (\n    <h3\n      data-slot=\"place-card-title\"\n      className={cn(\n        \"col-start-1 m-0 font-semibold text-foreground text-pretty\",\n        context.variant === \"compact\" ? \"text-[13px]/[18px] font-medium\" : \"text-[15px]/5\",\n        className,\n      )}\n      {...props}\n      id={context.titleId}\n    />\n  );\n}\n\n/** The kind of place and its price level or distance, for example \"Coffee · $$ · 0.4 mi\". */\nexport function PlaceCardCategory({ className, ...props }: ComponentProps<\"p\">) {\n  usePlace(\"PlaceCardCategory\");\n  return (\n    <p\n      data-slot=\"place-card-category\"\n      className={cn(\"col-start-1 m-0 text-[12px]/4 text-muted-foreground\", className)}\n      {...props}\n    />\n  );\n}\n\nexport type PlaceCardCloseProps = Omit<ComponentProps<\"button\">, \"aria-label\"> & { label?: string };\n\nexport function PlaceCardClose({\n  label = \"Close place details\",\n  type = \"button\",\n  className,\n  ...props\n}: PlaceCardCloseProps) {\n  const context = usePlace(\"PlaceCardClose\");\n  return (\n    <Button\n      data-slot=\"place-card-close\"\n      type={type}\n      variant=\"ghost\"\n      size=\"icon\"\n      aria-label={label}\n      className={cn(\n        \"col-start-2 row-start-1 -mt-1 -mr-1 rounded-full border-0 p-0 text-muted-foreground transition-[background-color,color,scale] duration-[120ms,120ms,140ms] ease-[ease-out,ease-out,cubic-bezier(0.23,1,0.32,1)] hover:bg-secondary hover:text-foreground focus-visible:ring-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid active:scale-[0.94] motion-reduce:transition-none motion-reduce:active:scale-100 dark:hover:bg-secondary\",\n        context.variant === \"compact\" ? \"size-6 [&_svg]:size-3.5\" : \"size-7 [&_svg]:size-4\",\n        className,\n      )}\n      {...props}\n    >\n      <X strokeWidth={1.75} aria-hidden=\"true\" />\n    </Button>\n  );\n}\n\n/** A row of rating, status, and other short facts. */\nexport function PlaceCardMeta({ className, ...props }: ComponentProps<\"div\">) {\n  usePlace(\"PlaceCardMeta\");\n  return (\n    <div\n      data-slot=\"place-card-meta\"\n      className={cn(\n        \"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-[12px]/4 text-muted-foreground [&>*+*]:before:mr-2 [&>*+*]:before:text-subtle-foreground [&>*+*]:before:content-['·']\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport type PlaceCardRatingProps = ComponentProps<\"span\"> & {\n  /** Average rating out of five. */\n  value: number;\n  /** Number of reviews. */\n  count?: number;\n};\n\nexport function PlaceCardRating({ value, count, className, ...props }: PlaceCardRatingProps) {\n  usePlace(\"PlaceCardRating\");\n  const rating = value.toFixed(1);\n  const reviews = count === undefined ? \"\" : `, ${count.toLocaleString(\"en-US\")} reviews`;\n  return (\n    <span\n      data-slot=\"place-card-rating\"\n      role=\"img\"\n      aria-label={`Rated ${rating} out of 5${reviews}`}\n      className={cn(\"inline-flex items-center gap-1 tabular-nums\", className)}\n      {...props}\n    >\n      <Star aria-hidden=\"true\" className=\"size-3 fill-warning stroke-warning\" />\n      <span aria-hidden=\"true\" className=\"font-medium text-foreground\">\n        {rating}\n      </span>\n      {count !== undefined && <span aria-hidden=\"true\">({count.toLocaleString(\"en-US\")})</span>}\n    </span>\n  );\n}\n\nexport type PlaceCardStatusProps = ComponentProps<\"span\"> & { status: PlaceCardOpenState };\n\n/** Opening state in words, such as \"Open until 6 PM\". The tone dot only reinforces the text. */\nexport function PlaceCardStatus({ status, className, children, ...props }: PlaceCardStatusProps) {\n  usePlace(\"PlaceCardStatus\");\n  return (\n    <span\n      data-slot=\"place-card-status\"\n      data-status={status}\n      className={cn(\n        \"inline-flex items-center gap-1.5 font-medium data-[status=closed]:text-destructive-ink data-[status=closing]:text-warning-ink data-[status=open]:text-success-ink\",\n        className,\n      )}\n      {...props}\n    >\n      <span aria-hidden=\"true\" className=\"size-1.5 rounded-full bg-current\" />\n      {children}\n    </span>\n  );\n}\n\nexport function PlaceCardDetails({ className, ...props }: ComponentProps<\"ul\">) {\n  const context = usePlace(\"PlaceCardDetails\");\n  return (\n    <ul\n      data-slot=\"place-card-details\"\n      className={cn(\n        \"m-0 grid list-none p-0\",\n        context.variant === \"compact\" ? \"gap-1\" : \"gap-1.5\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** One fact with a leading icon, such as the address, hours, or phone number. */\nexport function PlaceCardDetail({ className, ...props }: ComponentProps<\"li\">) {\n  usePlace(\"PlaceCardDetail\");\n  return (\n    <li\n      data-slot=\"place-card-detail\"\n      className={cn(\n        \"flex min-w-0 items-start gap-2 text-muted-foreground [&_a]:text-foreground [&_a]:underline-offset-2 [&_a:hover]:underline [&>svg]:mt-px [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:stroke-[1.75] [&>svg]:text-subtle-foreground\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport function PlaceCardActions({ className, ...props }: ComponentProps<\"div\">) {\n  usePlace(\"PlaceCardActions\");\n  return (\n    <div\n      data-slot=\"place-card-actions\"\n      className={cn(\"flex min-w-0 flex-wrap items-center gap-2 pt-0.5\", className)}\n      {...props}\n    />\n  );\n}\n\nconst placeCardActionVariants = cva(\n  \"h-auto gap-1.5 rounded-full border-0 py-0 shadow-none transition-[scale,background-color,filter] duration-140 ease-out-quint focus-visible:ring-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring focus-visible:outline-solid active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100 [&_svg:not([class*='size-'])]:size-3.5\",\n  {\n    variants: {\n      variant: {\n        card: \"min-h-8 px-3.5 text-[13px]/4 has-[>svg]:px-3\",\n        popup: \"min-h-7 px-3 text-[12.5px]/4 has-[>svg]:px-2.5\",\n        compact: \"min-h-6 px-2.5 text-[12px]/4 has-[>svg]:px-2\",\n      },\n      emphasis: {\n        primary: \"bg-primary text-primary-foreground hover:bg-primary hover:brightness-[1.08]\",\n        secondary:\n          \"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklab,var(--secondary)_85%,var(--foreground))]\",\n      },\n    },\n  },\n);\n\nexport type PlaceCardActionProps = ComponentProps<\"button\"> & {\n  emphasis?: PlaceCardActionEmphasis;\n};\n\n/** Use the primary emphasis once, usually for Directions. */\nexport function PlaceCardAction({\n  emphasis = \"secondary\",\n  type = \"button\",\n  className,\n  ...props\n}: PlaceCardActionProps) {\n  const context = usePlace(\"PlaceCardAction\");\n  return (\n    <Button\n      data-slot=\"place-card-action\"\n      type={type}\n      variant={emphasis === \"primary\" ? \"default\" : \"secondary\"}\n      className={cn(placeCardActionVariants({ variant: context.variant, emphasis }), className)}\n      {...props}\n    />\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/uai/place-card.tsx"
    }
  ],
  "categories": [
    "maps"
  ],
  "type": "registry:ui"
}