{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card-11",
  "title": "Pass",
  "description": "A ticket-style pass with notched edges and a drawn pattern on its stub, which tilts with the pointer, takes one band of light across and tears its stub at check-in.",
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "https://ui.ndekocode.dev/r/avatar.json",
    "https://ui.ndekocode.dev/r/badge.json",
    "https://ui.ndekocode.dev/r/chat-motion.json",
    "https://ui.ndekocode.dev/r/demonstration.json",
    "https://ui.ndekocode.dev/r/icons.json",
    "https://ui.ndekocode.dev/r/live-region.json",
    "https://ui.ndekocode.dev/r/seeded.json",
    "https://ui.ndekocode.dev/r/theme.json",
    "https://ui.ndekocode.dev/r/use-autoplay.json",
    "https://ui.ndekocode.dev/r/use-kept-height.json",
    "https://ui.ndekocode.dev/r/use-prefers-reduced-motion.json",
    "https://ui.ndekocode.dev/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/ndeko/components/card/card-11.tsx",
      "content": "'use client';\n\nimport {\n  motion,\n  useMotionValue,\n  useSpring,\n  useTransform,\n  type MotionStyle,\n} from 'motion/react';\nimport { useEffect, useImperativeHandle, useRef, useState } from 'react';\n\nimport type { AutoplayStep } from '@/registry/ndeko/hooks/use-autoplay';\nimport { usePrefersReducedMotion } from '@/registry/ndeko/hooks/use-prefers-reduced-motion';\nimport { PRESS_LEAD_MS, usePress } from '@/registry/ndeko/lib/demonstration';\nimport { CheckIcon } from '@/registry/ndeko/lib/icons';\nimport { hashOf } from '@/registry/ndeko/lib/seeded';\nimport { cn } from '@/registry/ndeko/lib/utils';\nimport { Avatar } from '@/registry/ndeko/ui/avatar';\nimport { Badge } from '@/registry/ndeko/ui/badge';\nimport { Swap } from '@/registry/ndeko/ui/chat-motion';\nimport { LiveRegion } from '@/registry/ndeko/ui/live-region';\n\nimport { PEOPLE } from './_parts/people';\nimport { pressedShapeOf } from './_parts/pressed-shape';\nimport { SampleNote } from './_parts/sample-note';\nimport { TearLine, TICKET_OUTLINE, ticketMaskOf } from './_parts/ticket';\nimport { useCardDemo } from './_parts/use-card-demo';\nimport { useHover } from './_parts/use-peek';\n\nexport type PassDetails = {\n  event: string;\n  venue: string;\n  /** The day, the hour and the seat as they read: \"Thu 3 Dec\", \"09:30\", \"C 14\". */\n  date: string;\n  doors: string;\n  seat: string;\n  holder: string;\n  /** The number printed on the stub. The pattern above it is drawn from it and is never a working code. */\n  reference: string;\n};\n\nexport type PassCardHandle = {\n  /** Leans the pass towards a point of its face: -0.5 is the left or top edge, 0.5 the right or bottom one. */\n  tiltTo: (across: number, down: number) => void;\n  rest: () => void;\n  /** Sends the band of light across the pass once. */\n  shine: () => void;\n};\n\nconst MAX_TILT_DEG = 7;\n\nconst TILT_SPRING = { stiffness: 220, damping: 28, mass: 0.6 };\n\nconst PATTERN_SIDE = 9;\n\nconst PATTERN_CELL_COUNT = PATTERN_SIDE * PATTERN_SIDE;\n\nconst PATTERN_CELLS = Array.from(\n  { length: PATTERN_CELL_COUNT },\n  (_, cell) => cell\n);\n\n/** Two cells in five are inked, with no corner squares: it reads as a code and scans as nothing. */\nconst INKED_OUT_OF_FIVE = 2;\n\n/**\n * Under 21rem the pass stands upright with its stub underneath: the notch that sat at the top of\n * the tear moves to its other end, through the custom properties the two pieces set.\n */\nconst MAIN_MASK = ticketMaskOf(['var(--main-notch)', 'right bottom']);\n\nconst STUB_MASK = ticketMaskOf(['left top', 'var(--stub-notch)']);\n\nconst UPRIGHT = '@max-[21rem]:basis-full';\n\nconst MAIN = [\n  'relative flex min-w-0 flex-1 flex-col gap-3 overflow-hidden rounded-s-xl p-4 [--main-notch:right_top]',\n  '@max-[21rem]:rounded-es-none @max-[21rem]:rounded-se-xl @max-[21rem]:[--main-notch:left_bottom]',\n  UPRIGHT,\n].join(' ');\n\nconst FIELDS =\n  'grid grid-cols-3 gap-2 @max-[21rem]:grid-cols-[minmax(0,1.3fr)_minmax(0,1fr)_minmax(0,1fr)]';\n\nconst PAPER = 'bg-[color-mix(in_oklab,var(--primary)_9%,var(--card))]';\n\n/** The paper is tinted, and the muted text colour was measured on a plain card: quiet text here is the foreground, lightened. */\nconst QUIET_INK = 'text-foreground/70';\n\nconst PASS = [\n  'group/pass @container relative flex w-full cursor-pointer flex-wrap text-start outline-none',\n  'transition-[scale] duration-150 ease-(--ease-out-strong) active:scale-[0.98]',\n  'focus-visible:ring-ring focus-visible:ring-offset-background rounded-xl focus-visible:ring-2 focus-visible:ring-offset-4',\n].join(' ');\n\nconst STUB = [\n  'relative flex w-24 shrink-0 origin-top-left flex-col items-center justify-center gap-2 rounded-e-xl px-3 py-4 [--stub-notch:left_bottom]',\n  '@max-[21rem]:w-full @max-[21rem]:flex-row @max-[21rem]:gap-3 @max-[21rem]:py-3',\n  '@max-[21rem]:rounded-se-none @max-[21rem]:rounded-es-xl @max-[21rem]:[--stub-notch:right_top]',\n  'transition-[translate,rotate,opacity] duration-300 ease-(--ease-out-strong)',\n].join(' ');\n\nconst TORN = [\n  'translate-x-2 translate-y-1.5 rotate-[5deg] opacity-80',\n  '@max-[21rem]:translate-x-0 @max-[21rem]:translate-y-2 @max-[21rem]:rotate-[3deg]',\n].join(' ');\n\nconst SHEEN = [\n  'pointer-events-none absolute inset-y-0 start-0 w-1/3 -skew-x-12',\n  '[--sheen:rgb(255_255_255/0.75)] dark:[--sheen:rgb(255_255_255/0.12)]',\n  'translate-x-[330%] transition-transform duration-700 ease-(--ease-in-out-strong) starting:translate-x-[-120%]',\n].join(' ');\n\nconst SHEEN_LIGHT = {\n  backgroundImage:\n    'linear-gradient(90deg, transparent, var(--sheen), transparent)',\n};\n\nfunction clampToFace(position: number) {\n  const atLeast = Math.max(position, -0.5);\n  return Math.min(atLeast, 0.5);\n}\n\nfunction isInked(reference: string, cell: number) {\n  const seed = hashOf(`${reference}-${cell}`);\n  const draw = seed % 5;\n  return draw < INKED_OUT_OF_FIVE;\n}\n\nfunction inkOf(isOn: boolean) {\n  if (isOn) {\n    return 'bg-foreground/85';\n  }\n  return undefined;\n}\n\nfunction tornOf(isUsed: boolean) {\n  if (isUsed) {\n    return TORN;\n  }\n  return undefined;\n}\n\nfunction CodePattern({ reference }: { reference: string }) {\n  return (\n    <span aria-hidden='true' className='grid size-[3.25rem] grid-cols-9 gap-px'>\n      {PATTERN_CELLS.map((cell) => {\n        const isOn = isInked(reference, cell);\n        return <span key={cell} className={cn('rounded-[1px]', inkOf(isOn))} />;\n      })}\n    </span>\n  );\n}\n\nfunction PassField({ label, value }: { label: string; value: string }) {\n  return (\n    <span className='flex min-w-0 flex-col'>\n      <span className={cn('text-xs', QUIET_INK)}>{label}</span>\n      <span className='truncate text-[13px] font-medium tabular-nums'>\n        {value}\n      </span>\n    </span>\n  );\n}\n\nfunction StatusChip({ isUsed }: { isUsed: boolean }) {\n  return (\n    <Swap swapKey={String(isUsed)}>\n      {isUsed && (\n        <Badge variant='success'>\n          <CheckIcon />\n          Checked in\n        </Badge>\n      )}\n      {!isUsed && <Badge variant='outline'>Valid</Badge>}\n    </Swap>\n  );\n}\n\nexport type PassCardProps = {\n  pass: PassDetails;\n  /** Whether the holder is checked in: the stub tears away from the pass. */\n  isUsed: boolean;\n  onUsedChange: (isUsed: boolean) => void;\n  /** Says the pass is made up. Leave it out for a real one. */\n  note?: string;\n  /** Leans the pass or sends the light across from outside, for a demonstration. */\n  handleRef?: React.Ref<PassCardHandle>;\n  /** Shows the pass held down, for a demonstration that presses it. */\n  isPressed?: boolean;\n  className?: string;\n};\n\nexport function PassCard({\n  pass,\n  isUsed,\n  onUsedChange,\n  note,\n  handleRef,\n  isPressed = false,\n  className,\n}: PassCardProps) {\n  const shouldReduceMotion = usePrefersReducedMotion();\n  const [shineCount, setShineCount] = useState(0);\n  const across = useMotionValue(0);\n  const down = useMotionValue(0);\n  const easedAcross = useSpring(across, TILT_SPRING);\n  const easedDown = useSpring(down, TILT_SPRING);\n  const rotateY = useTransform(\n    easedAcross,\n    [-0.5, 0.5],\n    [-MAX_TILT_DEG, MAX_TILT_DEG]\n  );\n  const rotateX = useTransform(\n    easedDown,\n    [-0.5, 0.5],\n    [MAX_TILT_DEG, -MAX_TILT_DEG]\n  );\n  const passStyle: MotionStyle = {\n    ...TICKET_OUTLINE,\n    rotateX,\n    rotateY,\n    transformPerspective: 900,\n  };\n  const label = `Pass for ${pass.event}, ${pass.holder}. Mark as checked in`;\n  const hasShone = shineCount > 0;\n\n  function tiltTo(nextAcross: number, nextDown: number) {\n    if (shouldReduceMotion) {\n      return;\n    }\n    const boundedAcross = clampToFace(nextAcross);\n    const boundedDown = clampToFace(nextDown);\n    across.set(boundedAcross);\n    down.set(boundedDown);\n  }\n\n  function rest() {\n    across.set(0);\n    down.set(0);\n  }\n\n  function shine() {\n    setShineCount((current) => current + 1);\n  }\n\n  function shineUnderPointer(event: React.PointerEvent<HTMLButtonElement>) {\n    if (event.pointerType !== 'touch') {\n      shine();\n    }\n  }\n\n  function shineOnKeyboardFocus(event: React.FocusEvent<HTMLButtonElement>) {\n    if (event.target.matches(':focus-visible')) {\n      shine();\n    }\n  }\n\n  function followPointer(event: React.PointerEvent<HTMLButtonElement>) {\n    if (event.pointerType === 'touch') {\n      return;\n    }\n    const face = event.currentTarget.getBoundingClientRect();\n    const hasNoWidth = face.width === 0;\n    const hasNoHeight = face.height === 0;\n    if (hasNoWidth || hasNoHeight) {\n      return;\n    }\n    const fromLeft = event.clientX - face.left;\n    const fromTop = event.clientY - face.top;\n    const shareAcross = fromLeft / face.width;\n    const shareDown = fromTop / face.height;\n    const acrossFromCentre = shareAcross - 0.5;\n    const downFromCentre = shareDown - 0.5;\n    tiltTo(acrossFromCentre, downFromCentre);\n  }\n\n  function toggleUsed() {\n    onUsedChange(!isUsed);\n  }\n\n  useImperativeHandle(handleRef, () => ({ tiltTo, rest, shine }));\n\n  return (\n    <motion.button\n      type='button'\n      aria-pressed={isUsed}\n      aria-label={label}\n      style={passStyle}\n      onClick={toggleUsed}\n      onPointerEnter={shineUnderPointer}\n      onPointerMove={followPointer}\n      onPointerLeave={rest}\n      onFocus={shineOnKeyboardFocus}\n      className={cn(PASS, pressedShapeOf(isPressed), className)}\n    >\n      <span style={MAIN_MASK} className={cn(MAIN, PAPER)}>\n        <span className='flex items-center justify-between gap-2'>\n          <span className={cn('min-w-0 text-xs', QUIET_INK)}>{pass.venue}</span>\n          <StatusChip isUsed={isUsed} />\n        </span>\n        <span className='text-lg leading-6 font-semibold text-balance'>\n          {pass.event}\n        </span>\n        <span className={FIELDS}>\n          <PassField label='Date' value={pass.date} />\n          <PassField label='Doors' value={pass.doors} />\n          <PassField label='Seat' value={pass.seat} />\n        </span>\n        <span className='flex items-center gap-2'>\n          <Avatar seed={pass.holder} className='size-6' />\n          <span className='min-w-0 truncate text-[13px]'>{pass.holder}</span>\n          {note && (\n            <SampleNote className={cn('ms-auto shrink-0', QUIET_INK)}>\n              {note}\n            </SampleNote>\n          )}\n        </span>\n        {hasShone && (\n          <span\n            key={shineCount}\n            aria-hidden='true'\n            style={SHEEN_LIGHT}\n            className={SHEEN}\n          />\n        )}\n      </span>\n      <span aria-hidden='true' className={cn('relative', UPRIGHT)}>\n        <TearLine\n          direction='column'\n          className='absolute inset-y-3 start-0 @max-[21rem]:hidden'\n        />\n        <TearLine\n          direction='row'\n          className='absolute inset-x-3 top-0 hidden @max-[21rem]:block'\n        />\n      </span>\n      <span style={STUB_MASK} className={cn(STUB, PAPER, tornOf(isUsed))}>\n        <CodePattern reference={pass.reference} />\n        <span className='font-mono text-xs tabular-nums'>{pass.reference}</span>\n      </span>\n    </motion.button>\n  );\n}\n\nconst PASS_DETAILS: PassDetails = {\n  event: 'Design Systems Day',\n  venue: 'Pavilion Hall, Lisbon',\n  date: 'Thu 3 Dec',\n  doors: '09:30',\n  seat: 'C 14',\n  holder: PEOPLE.mei.name,\n  reference: 'A7K2 0091',\n};\n\nfunction announcementOf(isUsed: boolean) {\n  if (isUsed) {\n    return `${PASS_DETAILS.holder} is checked in, the stub is torn`;\n  }\n  return 'The pass is valid again';\n}\n\nexport default function Card11() {\n  const [isUsed, setIsUsed] = useState(false);\n  const [announcement, setAnnouncement] = useState('');\n  const pass = useRef<PassCardHandle>(null);\n  const { pressed, press } = usePress<'pass'>();\n  const { isHovered, hoverHandlers } = useHover();\n\n  function startOver() {\n    setIsUsed(false);\n    pass.current?.rest();\n  }\n\n  /** Only a person's press is said: a pointer resting on the pass pauses the demonstration, and that pause must stay silent. */\n  function checkInFromPass(nextIsUsed: boolean) {\n    setIsUsed(nextIsUsed);\n    setAnnouncement(announcementOf(nextIsUsed));\n  }\n\n  function leanIn() {\n    pass.current?.shine();\n    pass.current?.tiltTo(-0.36, -0.3);\n  }\n\n  const steps: AutoplayStep[] = [\n    { after: 1300, run: leanIn },\n    { after: 1000, run: () => pass.current?.tiltTo(0.38, 0.26) },\n    { after: 1000, run: () => pass.current?.rest() },\n    { after: 900, run: () => press('pass') },\n    { after: PRESS_LEAD_MS, run: () => setIsUsed(true) },\n    { after: 2200, run: () => press('pass') },\n    { after: PRESS_LEAD_MS, run: () => setIsUsed(false) },\n  ];\n  const { ref, isAutoplaying } = useCardDemo(steps, {\n    loopAfter: 1400,\n    onReset: startOver,\n    isEnabled: !isHovered,\n  });\n  const isDemoStopped = !isAutoplaying && !isHovered;\n\n  /** A tilt the demonstration leaves when a person takes over settles back: a keyboard has no pointer to undo it. */\n  useEffect(() => {\n    if (isDemoStopped) {\n      pass.current?.rest();\n    }\n  }, [isDemoStopped]);\n\n  return (\n    <div\n      ref={ref}\n      className='min-h-[10.75rem] w-full max-w-[26rem]'\n      {...hoverHandlers}\n    >\n      <PassCard\n        pass={PASS_DETAILS}\n        isUsed={isUsed}\n        onUsedChange={checkInFromPass}\n        note='Sample pass'\n        handleRef={pass}\n        isPressed={pressed === 'pass'}\n      />\n      <LiveRegion message={announcement} />\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/card/card-11.tsx"
    },
    {
      "path": "registry/ndeko/components/card/_parts/people.ts",
      "content": "export type Person = {\n  id: string;\n  name: string;\n  role: string;\n  company: string;\n};\n\n/** The invented people of the card demos. The same person keeps the same picture on every card. */\nexport const PEOPLE = {\n  amara: {\n    id: 'amara',\n    name: 'Amara Diallo',\n    role: 'Product lead',\n    company: 'Halden Works',\n  },\n  jonas: {\n    id: 'jonas',\n    name: 'Jonas Weber',\n    role: 'Staff engineer',\n    company: 'Brightwater',\n  },\n  mei: {\n    id: 'mei',\n    name: 'Mei Tanaka',\n    role: 'Design director',\n    company: 'Kiln Studio',\n  },\n  rafael: {\n    id: 'rafael',\n    name: 'Rafael Ortega',\n    role: 'Head of support',\n    company: 'Tallyard',\n  },\n  ingrid: {\n    id: 'ingrid',\n    name: 'Ingrid Solheim',\n    role: 'Finance manager',\n    company: 'Quillhouse',\n  },\n} satisfies Record<string, Person>;\n",
      "type": "registry:component",
      "target": "components/card/_parts/people.ts"
    },
    {
      "path": "registry/ndeko/components/card/_parts/pressed-shape.ts",
      "content": "/**\n * A drawn object a demonstration presses, a folder or a pass, has no fill to darken: the press\n * shows as scale alone, and deeper than under a finger, so it reads from across the page.\n */\nconst PRESSED_SHAPE = 'scale-[0.95]';\n\nexport function pressedShapeOf(isPressed: boolean) {\n  if (isPressed) {\n    return PRESSED_SHAPE;\n  }\n  return undefined;\n}\n",
      "type": "registry:component",
      "target": "components/card/_parts/pressed-shape.ts"
    },
    {
      "path": "registry/ndeko/components/card/_parts/sample-note.tsx",
      "content": "import { cn } from '@/registry/ndeko/lib/utils';\n\ntype SampleNoteProps = {\n  /** What the sample is: \"Illustrative\", \"Sample quote\". */\n  children?: React.ReactNode;\n  className?: string;\n};\n\n/** The word that says the figures or the words of a demo are made up. */\nexport function SampleNote({\n  children = 'Illustrative',\n  className,\n}: SampleNoteProps) {\n  return (\n    <span className={cn('text-muted-foreground text-xs', className)}>\n      {children}\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/card/_parts/sample-note.tsx"
    },
    {
      "path": "registry/ndeko/components/card/_parts/ticket.tsx",
      "content": "import type { CSSProperties } from 'react';\n\nimport { cn } from '@/registry/ndeko/lib/utils';\n\n/** A corner by name, or a custom property that holds one, so a container query can move the notch. */\nexport type TicketCorner =\n  | 'left top'\n  | 'right top'\n  | 'left bottom'\n  | 'right bottom'\n  | `var(--${string})`;\n\nconst NOTCH_PX = 7;\n\nconst SCALLOP_PX = 5;\n\nconst SCALLOP_STEP_PX = 16;\n\n/** Half a pixel of soft edge keeps the curve of a cut from showing steps. */\nconst SOFT_EDGE_PX = 0.5;\n\ntype MaskLayer = { image: string; size: string; repeat: string };\n\nfunction holeAt(position: string, radius: number) {\n  const edge = radius + SOFT_EDGE_PX;\n  return `radial-gradient(circle at ${position}, transparent ${radius}px, black ${edge}px)`;\n}\n\nfunction notchLayerOf(corner: TicketCorner): MaskLayer {\n  return {\n    image: holeAt(corner, NOTCH_PX),\n    size: '100% 100%',\n    repeat: 'no-repeat',\n  };\n}\n\n/** `round` fits a whole number of half circles into the edge, whatever the width of the ticket. */\nconst SCALLOP_LAYER: MaskLayer = {\n  image: holeAt('50% 100%', SCALLOP_PX),\n  size: `${SCALLOP_STEP_PX}px 100%`,\n  repeat: 'round no-repeat',\n};\n\nfunction layersOf(corners: readonly TicketCorner[], hasScallops: boolean) {\n  const notches = corners.map(notchLayerOf);\n  if (hasScallops) {\n    return [...notches, SCALLOP_LAYER];\n  }\n  return notches;\n}\n\n/**\n * The mask of one piece of a ticket: a quarter circle cut out of each named corner, so two pieces\n * that meet show a round notch, and a scalloped bottom edge when asked.\n */\nexport function ticketMaskOf(\n  corners: readonly TicketCorner[],\n  hasScallops = false\n): CSSProperties {\n  const layers = layersOf(corners, hasScallops);\n  const images = layers.map((layer) => layer.image);\n  const sizes = layers.map((layer) => layer.size);\n  const repeats = layers.map((layer) => layer.repeat);\n  return {\n    maskImage: images.join(', '),\n    maskSize: sizes.join(', '),\n    maskRepeat: repeats.join(', '),\n    maskComposite: 'intersect',\n  };\n}\n\nconst OUTLINE_SHADOWS = [\n  'drop-shadow(0 var(--hairline) 0 var(--border))',\n  'drop-shadow(0 calc(var(--hairline) * -1) 0 var(--border))',\n  'drop-shadow(var(--hairline) 0 0 var(--border))',\n  'drop-shadow(calc(var(--hairline) * -1) 0 0 var(--border))',\n  'drop-shadow(0 1px 1px rgb(0 0 0 / 0.04))',\n];\n\n/**\n * A mask cuts away the ring and the shadow of the piece it shapes. The wrapper of a ticket draws\n * the outline instead: one hairline on every side, following each cut.\n */\nexport const TICKET_OUTLINE: CSSProperties = {\n  filter: OUTLINE_SHADOWS.join(' '),\n};\n\nconst PERFORATION =\n  'color-mix(in oklab, var(--foreground) 22%, transparent) 0 4px, transparent 4px 8px';\n\nconst TEAR_ROW: CSSProperties = {\n  backgroundImage: `repeating-linear-gradient(90deg, ${PERFORATION})`,\n};\n\nconst TEAR_COLUMN: CSSProperties = {\n  backgroundImage: `repeating-linear-gradient(180deg, ${PERFORATION})`,\n};\n\ntype TearLineProps = {\n  /** `row` runs across a ticket that tears into a top and a bottom, `column` down one that tears into a left and a right. */\n  direction: 'row' | 'column';\n  className?: string;\n};\n\n/** The perforation where two pieces of a ticket meet, drawn from one notch to the other. */\nexport function TearLine({ direction, className }: TearLineProps) {\n  if (direction === 'column') {\n    return (\n      <span\n        aria-hidden='true'\n        style={TEAR_COLUMN}\n        className={cn('block w-px', className)}\n      />\n    );\n  }\n  return (\n    <span\n      aria-hidden='true'\n      style={TEAR_ROW}\n      className={cn('block h-px', className)}\n    />\n  );\n}\n",
      "type": "registry:component",
      "target": "components/card/_parts/ticket.tsx"
    },
    {
      "path": "registry/ndeko/components/card/_parts/use-card-demo.ts",
      "content": "'use client';\n\nimport {\n  useAutoplay,\n  type AutoplayOptions,\n  type AutoplayStep,\n} from '@/registry/ndeko/hooks/use-autoplay';\nimport { useKeptHeight } from '@/registry/ndeko/hooks/use-kept-height';\n\n/**\n * What every card demo shares: the demonstration, and the box that keeps its tallest height so a\n * round never moves the page.\n */\nexport function useCardDemo(\n  steps: readonly AutoplayStep[],\n  options?: AutoplayOptions\n) {\n  const demo = useAutoplay(steps, options);\n  const { ref } = demo;\n\n  useKeptHeight(ref);\n\n  return demo;\n}\n",
      "type": "registry:component",
      "target": "components/card/_parts/use-card-demo.ts"
    },
    {
      "path": "registry/ndeko/components/card/_parts/use-peek.ts",
      "content": "'use client';\n\nimport { useState } from 'react';\n\n/** Whether a pointer rests on an element. A finger does not hover, so touch is left to the press of the piece. */\nexport function useHover() {\n  const [isHovered, setIsHovered] = useState(false);\n\n  function hoverStarts(event: React.PointerEvent<HTMLElement>) {\n    if (event.pointerType !== 'touch') {\n      setIsHovered(true);\n    }\n  }\n\n  function hoverEnds() {\n    setIsHovered(false);\n  }\n\n  const hoverHandlers = {\n    onPointerEnter: hoverStarts,\n    onPointerLeave: hoverEnds,\n  };\n\n  return { isHovered, hoverHandlers };\n}\n\n/**\n * Whether a person looks closer at an element: the pointer rests on it, or the keyboard brought\n * focus to it. A press with a mouse also focuses a button, and that is not a closer look.\n */\nexport function usePeek() {\n  const { isHovered, hoverHandlers } = useHover();\n  const [isFocused, setIsFocused] = useState(false);\n\n  function focusEnters(event: React.FocusEvent<HTMLElement>) {\n    const isKeyboardFocus = event.target.matches(':focus-visible');\n    setIsFocused(isKeyboardFocus);\n  }\n\n  function focusLeaves() {\n    setIsFocused(false);\n  }\n\n  const isPeeking = isHovered || isFocused;\n  const peekHandlers = {\n    ...hoverHandlers,\n    onFocus: focusEnters,\n    onBlur: focusLeaves,\n  };\n\n  return { isPeeking, peekHandlers };\n}\n",
      "type": "registry:component",
      "target": "components/card/_parts/use-peek.ts"
    }
  ],
  "categories": [
    "components",
    "card"
  ],
  "type": "registry:component"
}