{"slug":"card-folder","name":"Card Folder","description":"A landscape card tucked into a stitched purse pocket that lifts forward as the purse compresses into its bottom seam, with controlled open and card-detail visibility plus a separate overflow action.","category":"blocks","source_url":"https://beui.dev/r/card-folder/raw","detail_url":"https://beui.dev/r/card-folder","raw_url":"https://beui.dev/r/card-folder/raw","page_url":"https://beui.dev/components/blocks/card-folder","markdown_url":"https://beui.dev/components/blocks/card-folder.md","published_at":"2026-09-04","updated_at":"2026-11-10","dependencies":["clsx","lucide-react","motion","react","tailwind-merge"],"internal":["@/components/motion/card-folder","@/components/motion/digit-swap","@/lib/ease","@/lib/i18n","@/lib/utils"],"install_slugs":["card-folder"],"requires_theme":false,"props":[{"displayName":"CardFolder","props":[{"name":"title","type":"string","required":true,"defaultValue":null,"description":"Card name shown on the folder front and used in labels."},{"name":"cardNumber","type":"string","required":true,"defaultValue":null,"description":"Full card number. Non-digits are stripped; only the last 4 show until revealed."},{"name":"expiry","type":"string","required":true,"defaultValue":null,"description":"Expiry date text shown on the folder, e.g. \"08/29\"."},{"name":"cvv","type":"string","required":true,"defaultValue":null,"description":"Security code, masked until details are revealed."},{"name":"card","type":"ReactNode","required":true,"defaultValue":null,"description":"The card face that lifts out of the folder."},{"name":"open","type":"boolean","required":false,"defaultValue":null,"description":"Whether the card is lifted out, for controlled use."},{"name":"defaultOpen","type":"boolean","required":false,"defaultValue":"false","description":"Whether the card starts lifted out when uncontrolled. Default: false"},{"name":"onOpenChange","type":"((open: boolean) => void)","required":false,"defaultValue":null,"description":"Called with the next state when the folder opens or closes."},{"name":"detailsVisible","type":"boolean","required":false,"defaultValue":null,"description":"Whether the number and CVV are revealed, for controlled use."},{"name":"defaultDetailsVisible","type":"boolean","required":false,"defaultValue":"false","description":"Whether the number and CVV start revealed when uncontrolled. Default: false"},{"name":"onDetailsVisibleChange","type":"((visible: boolean) => void)","required":false,"defaultValue":null,"description":"Called with the next state when the details are shown or hidden."},{"name":"onClick","type":"(() => void)","required":false,"defaultValue":null,"description":"Called after the folder is pressed, alongside the open toggle."},{"name":"onAction","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the actions button is pressed. The button shows only when set."},{"name":"ariaLabel","type":"string","required":false,"defaultValue":null,"description":"Accessible name for the folder button. Defaults to the `open` or `close` label."},{"name":"actionLabel","type":"string","required":false,"defaultValue":null,"description":"Accessible name for the actions button. Defaults to the `actions` label."},{"name":"disabled","type":"boolean","required":false,"defaultValue":"false","description":"Disables opening, revealing details and the actions button. Default: false"},{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."},{"name":"cardClassName","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the wrapper around the card face."},{"name":"labels","type":"Partial<{ open: string; close: string; showDetails: string; hideDetails: string; expiry: string; cvv: string; actions: string; }>","required":false,"defaultValue":null,"description":"Override any built-in string. `{title}`, `{lastFour}` and `{expiry}` fill `open`, `close` and `actions`."}]}],"types":[],"files":[{"path":"components/motion/card-folder.tsx","type":"component","content":"\"use client\";\n// beui.dev/components/blocks/card-folder\n\nimport { EllipsisVertical, Eye, EyeOff } from \"lucide-react\";\nimport {\n  AnimatePresence,\n  animate,\n  motion,\n  useMotionValue,\n  useReducedMotion,\n  useTransform,\n} from \"motion/react\";\nimport { type ReactNode, useCallback, useEffect, useState } from \"react\";\nimport { DigitSwap } from \"@/components/motion/digit-swap\";\nimport {\n  EASE_IN_OUT,\n  EASE_OUT,\n  SPRING_LAYOUT,\n  SPRING_PRESS,\n} from \"@/lib/ease\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\n\n// The two purse layers collapse as one material surface after the card starts\n// moving, then reverse immediately so closing feels like the card is caught.\nconst PURSE_MORPH_TRANSITION = {\n  duration: 0.28,\n  ease: EASE_IN_OUT,\n} as const;\nconst PURSE_REDUCED_TRANSITION = {\n  duration: 0.16,\n  ease: EASE_OUT,\n} as const;\n\n/** English defaults. Override per instance with `labels`, or app-wide with `LocaleProvider`. */\nexport const cardFolderMessages = {\n  open: \"Open {title}, card ending in {lastFour}, expires {expiry}\",\n  close: \"Close {title}, card ending in {lastFour}, expires {expiry}\",\n  showDetails: \"Show card details\",\n  hideDetails: \"Hide card details\",\n  expiry: \"Expiry\",\n  cvv: \"CVV\",\n  actions: \"Open actions for {title}\",\n};\n\nexport type CardFolderMessages = typeof cardFolderMessages;\n\nexport interface CardFolderProps {\n  /** Card name shown on the folder front and used in labels. */\n  title: string;\n  /** Full card number. Non-digits are stripped; only the last 4 show until revealed. */\n  cardNumber: string;\n  /** Expiry date text shown on the folder, e.g. \"08/29\". */\n  expiry: string;\n  /** Security code, masked until details are revealed. */\n  cvv: string;\n  /** The card face that lifts out of the folder. */\n  card: ReactNode;\n  /** Whether the card is lifted out, for controlled use. */\n  open?: boolean;\n  /** Whether the card starts lifted out when uncontrolled. Default: false */\n  defaultOpen?: boolean;\n  /** Called with the next state when the folder opens or closes. */\n  onOpenChange?: (open: boolean) => void;\n  /** Whether the number and CVV are revealed, for controlled use. */\n  detailsVisible?: boolean;\n  /** Whether the number and CVV start revealed when uncontrolled. Default: false */\n  defaultDetailsVisible?: boolean;\n  /** Called with the next state when the details are shown or hidden. */\n  onDetailsVisibleChange?: (visible: boolean) => void;\n  /** Called after the folder is pressed, alongside the open toggle. */\n  onClick?: () => void;\n  /** Called when the actions button is pressed. The button shows only when set. */\n  onAction?: () => void;\n  /** Accessible name for the folder button. Defaults to the `open` or `close` label. */\n  ariaLabel?: string;\n  /** Accessible name for the actions button. Defaults to the `actions` label. */\n  actionLabel?: string;\n  /** Disables opening, revealing details and the actions button. Default: false */\n  disabled?: boolean;\n  /** Classes merged onto the root element. */\n  className?: string;\n  /** Classes merged onto the wrapper around the card face. */\n  cardClassName?: string;\n  /** Override any built-in string. `{title}`, `{lastFour}` and `{expiry}` fill `open`, `close` and `actions`. */\n  labels?: Partial<CardFolderMessages>;\n}\n\n/**\n * A landscape card tucked into an animated folder sleeve. Pressing the folder\n * lifts the card forward while the purse compresses into its bottom seam; a\n * separate privacy control reveals its number and CVV.\n */\nexport function CardFolder({\n  title,\n  cardNumber,\n  expiry,\n  cvv,\n  card,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  detailsVisible,\n  defaultDetailsVisible = false,\n  onDetailsVisibleChange,\n  onClick,\n  onAction,\n  ariaLabel,\n  actionLabel,\n  disabled = false,\n  className,\n  cardClassName,\n  labels,\n}: CardFolderProps) {\n  const t = useMessages(\"cardFolder\", cardFolderMessages, labels);\n  const reduce = useReducedMotion();\n  const [internalOpen, setInternalOpen] = useState(defaultOpen);\n  const [internalDetailsVisible, setInternalDetailsVisible] = useState(\n    defaultDetailsVisible,\n  );\n  const openControlled = open !== undefined;\n  const detailsControlled = detailsVisible !== undefined;\n  const isOpen = open ?? internalOpen;\n  const areDetailsVisible = detailsVisible ?? internalDetailsVisible;\n  const transition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n  const normalizedCardNumber = cardNumber.replace(/\\D/g, \"\");\n  const visibleLastFour = normalizedCardNumber.slice(-4).padStart(4, \"•\");\n  const revealedCardNumber =\n    normalizedCardNumber.match(/.{1,4}/g)?.join(\" \") ?? visibleLastFour;\n  const maskedCvv = \"•\".repeat(Math.max(3, cvv.length));\n  const defaultAriaLabel = t(isOpen ? \"close\" : \"open\", {\n    title,\n    lastFour: visibleLastFour,\n    expiry,\n  });\n  const progress = useMotionValue(isOpen ? 1 : 0);\n  const cardTransform = useTransform(progress, (value) => {\n    const boundedProgress = Math.min(1, Math.max(0, value));\n    const lift = Math.sin(Math.PI * boundedProgress);\n    return `translateY(${-8 * lift}%) scale(${1 + 0.01 * lift})`;\n  });\n  const backTransform = useTransform(\n    progress,\n    [0, 1],\n    [\"translateY(0%) scaleY(1)\", \"translateY(18%) scaleY(0.18)\"],\n  );\n  const frontTransform = useTransform(\n    progress,\n    [0, 1],\n    [\"translateY(0%) rotateX(0deg)\", \"translateY(18%) rotateX(-72deg)\"],\n  );\n  const purseOpacity = useTransform(progress, [0, 0.76, 1], [1, 1, 0]);\n\n  useEffect(() => {\n    const controls = animate(\n      progress,\n      isOpen ? 1 : 0,\n      reduce ? { duration: 0 } : PURSE_MORPH_TRANSITION,\n    );\n    return () => controls.stop();\n  }, [isOpen, progress, reduce]);\n\n  const setOpen = useCallback(\n    (nextOpen: boolean) => {\n      if (disabled) return;\n      if (!openControlled) setInternalOpen(nextOpen);\n      onOpenChange?.(nextOpen);\n    },\n    [disabled, onOpenChange, openControlled],\n  );\n\n  const handleClick = () => {\n    setOpen(!isOpen);\n    onClick?.();\n  };\n\n  const toggleDetails = () => {\n    if (disabled) return;\n    const nextVisible = !areDetailsVisible;\n    if (!detailsControlled) setInternalDetailsVisible(nextVisible);\n    onDetailsVisibleChange?.(nextVisible);\n  };\n\n  return (\n    <div\n      data-open={isOpen ? \"true\" : \"false\"}\n      data-details-visible={areDetailsVisible ? \"true\" : \"false\"}\n      className={cn(\n        \"relative aspect-[1029/592] w-96 max-w-full select-none [perspective:1200px]\",\n        className,\n      )}\n    >\n      <motion.button\n        type=\"button\"\n        disabled={disabled}\n        aria-label={ariaLabel ?? defaultAriaLabel}\n        aria-expanded={isOpen}\n        onClick={handleClick}\n        whileTap={reduce || disabled ? undefined : { scale: 0.96 }}\n        transition={reduce ? { duration: 0 } : SPRING_PRESS}\n        className=\"absolute inset-0 block rounded-2xl text-left outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-4 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50\"\n      >\n        <motion.span\n          data-slot=\"card-folder-back\"\n          aria-hidden=\"true\"\n          initial={false}\n          animate={reduce ? { opacity: isOpen ? 0 : 1 } : undefined}\n          transition={PURSE_REDUCED_TRANSITION}\n          style={\n            reduce\n              ? undefined\n              : { opacity: purseOpacity, transform: backTransform }\n          }\n          className=\"absolute inset-x-0 bottom-0 top-[10%] rounded-2xl border border-foreground/10 bg-background [transform-origin:center_bottom]\"\n        />\n\n        <motion.span\n          aria-hidden=\"true\"\n          initial={false}\n          animate={\n            reduce ? { transform: \"translateY(0%) scale(1)\" } : undefined\n          }\n          style={reduce ? undefined : { transform: cardTransform }}\n          className={cn(\n            \"absolute left-[4.7%] right-[4.7%] top-0 z-10 aspect-[1.586/1] overflow-hidden rounded-xl border border-foreground/10 bg-background [transform-origin:center_bottom] will-change-transform\",\n            cardClassName,\n          )}\n        >\n          {card}\n        </motion.span>\n      </motion.button>\n\n      <motion.span\n        aria-hidden={isOpen}\n        inert={isOpen}\n        initial={false}\n        animate={reduce ? { opacity: isOpen ? 0 : 1 } : undefined}\n        transition={PURSE_REDUCED_TRANSITION}\n        style={\n          reduce\n            ? undefined\n            : { opacity: purseOpacity, transform: frontTransform }\n        }\n        className=\"pointer-events-none absolute inset-x-0 bottom-0 top-1/2 z-20 [backface-visibility:hidden] [transform-origin:center_bottom]\"\n      >\n          <svg\n            aria-hidden=\"true\"\n            viewBox=\"0 0 384 110\"\n            preserveAspectRatio=\"none\"\n            className=\"absolute inset-0 size-full overflow-visible\"\n          >\n            <path\n              d=\"M0 17C15 7 31 4 49 4H87C110 4 126 17 144 32L158 44C176 59 206 59 225 43L240 30C257 16 271 4 295 4H335C354 4 370 8 384 18V94C384 103 377 110 368 110H16C7 110 0 103 0 94Z\"\n              fill=\"var(--background)\"\n              stroke=\"var(--foreground)\"\n              strokeOpacity=\"0.12\"\n              vectorEffect=\"non-scaling-stroke\"\n            />\n            <path\n              d=\"M10 21C22 13 35 11 51 11H85C105 11 120 23 137 37L153 50C175 68 208 68 231 49L246 36C262 23 275 11 297 11H333C350 11 363 14 374 22V89C374 97 369 101 360 101H24C15 101 10 96 10 89Z\"\n              fill=\"none\"\n              stroke=\"var(--foreground)\"\n              strokeDasharray=\"5 5\"\n              strokeLinecap=\"round\"\n              strokeOpacity=\"0.22\"\n              vectorEffect=\"non-scaling-stroke\"\n            />\n          </svg>\n\n          <span className=\"absolute inset-x-[5%] inset-y-0 z-10 flex min-w-0 flex-col justify-between py-3\">\n            <span className=\"flex items-start justify-between pr-2\">\n              <motion.button\n                key=\"card-details-visibility\"\n                type=\"button\"\n                disabled={disabled}\n                tabIndex={isOpen ? -1 : undefined}\n                aria-label={\n                  areDetailsVisible ? t(\"hideDetails\") : t(\"showDetails\")\n                }\n                aria-pressed={areDetailsVisible}\n                onClick={toggleDetails}\n                whileTap={reduce || disabled ? undefined : { scale: 0.96 }}\n                transition={reduce ? { duration: 0.12 } : SPRING_PRESS}\n                className={cn(\n                  \"z-30 flex size-9 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n                  isOpen ? \"pointer-events-none\" : \"pointer-events-auto\",\n                )}\n              >\n                <AnimatePresence initial={false} mode=\"popLayout\">\n                  <motion.span\n                    key={areDetailsVisible ? \"hide\" : \"show\"}\n                    initial={\n                      reduce\n                        ? { opacity: 0 }\n                        : { opacity: 0, scale: 0.25, filter: \"blur(4px)\" }\n                    }\n                    animate={{ opacity: 1, scale: 1, filter: \"blur(0px)\" }}\n                    exit={\n                      reduce\n                        ? { opacity: 0 }\n                        : { opacity: 0, scale: 0.25, filter: \"blur(4px)\" }\n                    }\n                    transition={\n                      reduce\n                        ? { duration: 0.12 }\n                        : { type: \"spring\", duration: 0.3, bounce: 0 }\n                    }\n                    className=\"flex items-center justify-center\"\n                  >\n                    {areDetailsVisible ? (\n                      <EyeOff className=\"size-4\" aria-hidden=\"true\" />\n                    ) : (\n                      <Eye className=\"size-4\" aria-hidden=\"true\" />\n                    )}\n                  </motion.span>\n                </AnimatePresence>\n              </motion.button>\n\n              <span className=\"flex shrink-0 items-end gap-3.5 pt-1\">\n                <span className=\"flex flex-col gap-0.5\">\n                  <span className=\"text-[11px] leading-none font-medium uppercase tracking-[0.12em] text-muted-foreground/65\">\n                    {t(\"expiry\")}\n                  </span>\n                  <span className=\"text-xs font-medium text-foreground tabular-nums\">\n                    {expiry}\n                  </span>\n                </span>\n                <span className=\"flex flex-col gap-0.5\">\n                  <span className=\"text-[11px] leading-none font-medium uppercase tracking-[0.12em] text-muted-foreground/65\">\n                    {t(\"cvv\")}\n                  </span>\n                  <DigitSwap\n                    value={areDetailsVisible ? cvv : maskedCvv}\n                    animationKey={\n                      areDetailsVisible ? \"revealed\" : \"masked\"\n                    }\n                    direction={areDetailsVisible ? \"up\" : \"down\"}\n                    className=\"text-xs font-medium text-foreground tabular-nums\"\n                  />\n                </span>\n              </span>\n            </span>\n            <span className=\"flex min-w-0 items-baseline justify-between gap-4\">\n              <span className=\"truncate text-lg font-medium leading-tight text-foreground\">\n                {title}\n              </span>\n              <DigitSwap\n                value={\n                  areDetailsVisible\n                    ? revealedCardNumber\n                    : `•••• •••• •••• ${visibleLastFour}`\n                }\n                animationKey={areDetailsVisible ? \"revealed\" : \"masked\"}\n                direction={areDetailsVisible ? \"up\" : \"down\"}\n                suffixLength={4}\n                glyphClassName={\n                  areDetailsVisible\n                    ? \"text-foreground\"\n                    : \"text-muted-foreground\"\n                }\n                suffixClassName=\"text-foreground\"\n                className=\"truncate font-mono text-xs tracking-[0.08em] tabular-nums\"\n              />\n            </span>\n          </span>\n      </motion.span>\n\n      {onAction ? (\n        <motion.button\n          type=\"button\"\n          disabled={disabled}\n          aria-label={actionLabel ?? t(\"actions\", { title })}\n          onClick={onAction}\n          animate={{ y: isOpen && !reduce ? -14 : 0 }}\n          whileTap={reduce || disabled ? undefined : { scale: 0.96 }}\n          transition={transition}\n          className=\"absolute right-[2.6%] top-[10%] z-10 flex size-10 -translate-y-1/2 items-center justify-center rounded-full text-white/65 outline-none transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-2 focus-visible:ring-white disabled:cursor-not-allowed disabled:opacity-50\"\n        >\n          <EllipsisVertical className=\"size-4\" aria-hidden=\"true\" />\n        </motion.button>\n      ) : null}\n    </div>\n  );\n}\n"},{"path":"components/motion/digit-swap.tsx","type":"util","content":"\"use client\";\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { EASE_OUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport type DigitSwapDirection = \"up\" | \"down\";\n\nexport interface DigitSwapProps {\n  /** Numeric or masked value rendered in fixed character slots. */\n  value: string | number;\n  /** Replays every glyph when the value itself contains unchanged characters. */\n  animationKey?: string | number;\n  /** Direction the next glyph enters from. */\n  direction?: DigitSwapDirection;\n  /** Per-glyph transition duration in seconds. */\n  duration?: number;\n  /** Delay in seconds between neighboring glyphs. */\n  stagger?: number;\n  /** Number of final characters that receive `suffixClassName`. */\n  suffixLength?: number;\n  /** Classes merged onto the root element. */\n  className?: string;\n  /** Classes merged onto every animated character. */\n  glyphClassName?: string;\n  /** Classes added to the last `suffixLength` characters. */\n  suffixClassName?: string;\n}\n\ntype GlyphMotionContext = {\n  direction: DigitSwapDirection;\n  reduceMotion: boolean;\n};\n\nconst GLYPH_VARIANTS = {\n  enter: ({ direction, reduceMotion }: GlyphMotionContext) => ({\n    opacity: 0,\n    transform: reduceMotion\n      ? \"none\"\n      : `translateY(${direction === \"up\" ? \"45%\" : \"-45%\"})`,\n  }),\n  visible: {\n    opacity: 1,\n    transform: \"translateY(0%)\",\n  },\n  exit: ({ direction, reduceMotion }: GlyphMotionContext) => ({\n    opacity: 0,\n    transform: reduceMotion\n      ? \"none\"\n      : `translateY(${direction === \"up\" ? \"-45%\" : \"45%\"})`,\n  }),\n};\n\n/**\n * Fixed-slot digits and mask glyphs that roll when their value changes.\n *\n * Each slot holds an invisible in-flow copy of its character, so the slot has\n * a real text baseline (it lines up with neighbouring text) and punctuation\n * keeps its natural width. Digits use a fixed 1ch slot so rolls never jitter.\n * Slots clip with `clip-path`, which, unlike `overflow: hidden`, leaves the\n * baseline alone.\n */\nexport function DigitSwap({\n  value,\n  animationKey,\n  direction = \"up\",\n  duration = 0.18,\n  stagger = 0.006,\n  suffixLength = 0,\n  className,\n  glyphClassName,\n  suffixClassName,\n}: DigitSwapProps) {\n  const reduceMotion = useReducedMotion() ?? false;\n  const text = String(value);\n  const suffixStart = Math.max(0, text.length - Math.max(0, suffixLength));\n  const motionContext: GlyphMotionContext = { direction, reduceMotion };\n  const glyphs = Array.from(text, (character, position) => ({\n    character,\n    id: `glyph-${position}`,\n    position,\n  }));\n\n  return (\n    <span\n      data-slot=\"digit-swap\"\n      data-direction={direction}\n      className={cn(\"inline-flex items-baseline whitespace-nowrap\", className)}\n    >\n      <span className=\"sr-only\">{text}</span>\n      <span aria-hidden=\"true\" className=\"inline-flex items-baseline\">\n        {glyphs.map(({ character, id, position }) => {\n          if (character === \" \") {\n            return <span key={id} className=\"inline-block w-[0.7ch]\" />;\n          }\n\n          const glyphKey =\n            animationKey === undefined\n              ? `${id}-${character}`\n              : `${id}-${character}-${animationKey}`;\n\n          return (\n            <span\n              key={id}\n              data-slot=\"digit-swap-glyph\"\n              className={cn(\n                \"relative inline-block h-[1.1em] shrink-0 leading-[1.1em] [clip-path:inset(0)]\",\n                /\\d/.test(character) && \"w-[1ch] text-center\",\n              )}\n            >\n              <span className=\"invisible\">{character}</span>\n              <AnimatePresence initial={false} custom={motionContext}>\n                <motion.span\n                  key={glyphKey}\n                  custom={motionContext}\n                  variants={GLYPH_VARIANTS}\n                  initial=\"enter\"\n                  animate=\"visible\"\n                  exit=\"exit\"\n                  transition={{\n                    duration: reduceMotion ? Math.min(duration, 0.12) : duration,\n                    delay: reduceMotion ? 0 : position * stagger,\n                    ease: EASE_OUT,\n                  }}\n                  className={cn(\n                    \"absolute inset-0 flex items-center justify-center leading-none\",\n                    glyphClassName,\n                    position >= suffixStart ? suffixClassName : undefined,\n                  )}\n                >\n                  {character}\n                </motion.span>\n              </AnimatePresence>\n            </span>\n          );\n        })}\n      </span>\n    </span>\n  );\n}\n"},{"path":"lib/ease.ts","type":"util","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants - defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\n/** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */\nexport const EASE_IN = [0.55, 0, 1, 0.45] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps - label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances - modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides - pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) - critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n\n/** Shared-surface morphs: a trigger growing into its panel and back on one\n * weighted spring, so opening and closing travel the same path. */\nexport const SPRING_MORPH = {\n  type: \"spring\",\n  duration: 0.5,\n  bounce: 0.22,\n} as const;\n"},{"path":"lib/i18n.tsx","type":"util","content":"\"use client\";\n\nimport {\n  createContext,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useMemo,\n} from \"react\";\n\n/**\n * A component's messages. Plain strings with `{name}` placeholders, so a\n * dictionary stays JSON-serializable and can be passed from a server layout.\n * There are no plural forms: write messages that read correctly for any count.\n */\nexport type Messages = Record<string, string>;\n\n/** A language file: component namespace → any subset of that component's messages. */\nexport type LocaleMessages = Record<string, Partial<Messages>>;\n\ntype LocaleContextValue = {\n  locale?: string;\n  messages: LocaleMessages;\n};\n\nconst NO_MESSAGES: LocaleMessages = {};\n\nconst LocaleContext = createContext<LocaleContextValue>({ messages: NO_MESSAGES });\n\n/** Without a locale, digits stay plain so server and client render the same text. */\nexport function formatNumber(value: number, locale?: string) {\n  return locale ? new Intl.NumberFormat(locale).format(value) : String(value);\n}\n\nexport interface LocaleProviderProps {\n  /** BCP 47 tag, e.g. `de`, `pt-BR`. Drives `Intl` number formatting. */\n  locale: string;\n  /**\n   * Component namespace → translated strings. Missing keys fall back to English.\n   * Pass a stable object (a module constant, imported JSON or a memoized value):\n   * a new object each render gives every translated component a new `t`.\n   */\n  messages?: LocaleMessages;\n  children: ReactNode;\n}\n\nexport function LocaleProvider({ locale, messages = NO_MESSAGES, children }: LocaleProviderProps) {\n  const value = useMemo(() => ({ locale, messages }), [locale, messages]);\n  return <LocaleContext.Provider value={value}>{children}</LocaleContext.Provider>;\n}\n\nexport function useLocale(): { locale?: string } {\n  return { locale: useContext(LocaleContext).locale };\n}\n\n/**\n * Resolves a component's strings: `labels` prop, then the provider's\n * messages for `namespace`, then the component's English `defaults`.\n * Numbers passed as values are formatted for the provider's locale.\n */\nexport function useMessages<T extends Messages>(\n  namespace: string,\n  defaults: T,\n  labels?: Partial<T>,\n) {\n  const { locale, messages } = useContext(LocaleContext);\n  const provided = messages[namespace];\n  // Inline `labels={{ … }}` is a new object every render. Keying it by content\n  // keeps `t` one identity until a label changes, so effects and memos that\n  // depend on `t` don't re-run per render, and render-time reads never lag.\n  const labelsKey = labels ? JSON.stringify(labels) : \"\";\n  const stableLabels = useMemo(\n    () => (labelsKey ? (JSON.parse(labelsKey) as Partial<T>) : undefined),\n    [labelsKey],\n  );\n\n  return useCallback(\n    (key: keyof T & string, values?: Record<string, string | number>) => {\n      const template = stableLabels?.[key] ?? provided?.[key] ?? defaults[key];\n      if (!values) return template;\n      return template.replace(/\\{(\\w+)\\}/g, (match, name: string) => {\n        const value = values[name];\n        if (value === undefined) return match;\n        return typeof value === \"number\" ? formatNumber(value, locale) : value;\n      });\n    },\n    [defaults, stableLabels, locale, provided],\n  );\n}\n"},{"path":"lib/utils.ts","type":"util","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"},{"path":"components/previews/blocks/card-folder.preview.tsx","type":"preview","content":"\"use client\";\n\nimport { useState } from \"react\";\nimport { CardFolder } from \"@/components/motion/card-folder\";\nimport { DigitSwap } from \"@/components/motion/digit-swap\";\n\nconst CARD_NUMBER = \"3745 6987 4096 0806\";\nconst MASKED_CARD_NUMBER = \"•••• •••• •••• 0806\";\nconst CONTOUR_RADII = Array.from({ length: 18 }, (_, index) => 72 + index * 24);\n\nfunction CardArtwork({ detailsVisible }: { detailsVisible: boolean }) {\n  return (\n    <span className=\"relative block h-full w-full overflow-hidden bg-[linear-gradient(135deg,#383a38_0%,#202120_48%,#111211_100%)] text-white\">\n      <svg\n        aria-hidden=\"true\"\n        viewBox=\"0 0 640 404\"\n        className=\"absolute inset-0 h-full w-full\"\n      >\n        {CONTOUR_RADII.map((radius, index) => (\n          <circle\n            // The concentric contours deliberately begin outside the card so\n            // their cropped curves read like the reference artwork.\n            key={radius}\n            cx=\"-20\"\n            cy=\"-28\"\n            r={radius}\n            fill=\"none\"\n            stroke=\"currentColor\"\n            strokeOpacity={0.32 - index * 0.009}\n            strokeWidth=\"1.5\"\n          />\n        ))}\n      </svg>\n\n      <span className=\"absolute inset-0 bg-[radial-gradient(circle_at_78%_8%,rgb(255_255_255/0.11),transparent_32%)]\" />\n\n      <span className=\"absolute left-[6%] top-[8%] flex flex-col gap-2\">\n        <span className=\"text-[11px] font-medium uppercase tracking-[0.22em] text-white/55\">\n          Saurabh Chauhan\n        </span>\n        <DigitSwap\n          value={detailsVisible ? CARD_NUMBER : MASKED_CARD_NUMBER}\n          animationKey={detailsVisible ? \"revealed\" : \"masked\"}\n          direction={detailsVisible ? \"up\" : \"down\"}\n          suffixLength={4}\n          glyphClassName={detailsVisible ? \"text-white/90\" : \"text-white/65\"}\n          suffixClassName=\"text-white/90\"\n          className=\"font-mono text-xs tracking-[0.13em]\"\n        />\n      </span>\n\n      <span className=\"absolute top-[8%] right-[7%] h-[20%] w-[13%] overflow-hidden rounded-[18%] border border-black/30 bg-[linear-gradient(135deg,#f2f0ea_0%,#b9b7b1_45%,#e4e1d9_100%)]\">\n        <span className=\"absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-black/30\" />\n        <span className=\"absolute inset-x-0 top-1/3 h-px bg-black/30\" />\n        <span className=\"absolute inset-x-0 bottom-1/3 h-px bg-black/30\" />\n        <span className=\"absolute left-0 top-1/2 h-[34%] w-[28%] -translate-y-1/2 rounded-r-[35%] border border-l-0 border-black/30\" />\n        <span className=\"absolute right-0 top-1/2 h-[34%] w-[28%] -translate-y-1/2 rounded-l-[35%] border border-r-0 border-black/30\" />\n      </span>\n\n      <span className=\"absolute bottom-[9%] left-[6%] flex items-center gap-2 text-lg font-medium tracking-[-0.04em]\">\n        beUI <span className=\"block size-2.5 rotate-45 rounded-[2px] bg-white/85\" />\n      </span>\n\n      <span className=\"absolute right-[7%] bottom-[10%] flex items-end gap-5\">\n        <span className=\"flex flex-col gap-1\">\n          <span className=\"text-[11px] font-medium uppercase tracking-[0.16em] text-white/40\">\n            Expiry\n          </span>\n          <span className=\"text-xs font-medium text-white/90 tabular-nums\">\n            08/29\n          </span>\n        </span>\n        <span className=\"flex flex-col gap-1\">\n          <span className=\"text-[11px] font-medium uppercase tracking-[0.16em] text-white/40\">\n            CVV\n          </span>\n          <DigitSwap\n            value={detailsVisible ? \"123\" : \"•••\"}\n            animationKey={detailsVisible ? \"revealed\" : \"masked\"}\n            direction={detailsVisible ? \"up\" : \"down\"}\n            className=\"font-mono text-xs font-medium text-white/90\"\n          />\n        </span>\n      </span>\n    </span>\n  );\n}\n\nexport function CardFolderPreview() {\n  const [detailsVisible, setDetailsVisible] = useState(false);\n\n  return (\n    <div className=\"flex min-h-72 w-full items-center justify-center px-6 py-9\">\n      <CardFolder\n        title=\"Saurabh Chauhan\"\n        cardNumber={CARD_NUMBER}\n        expiry=\"08/29\"\n        cvv=\"123\"\n        detailsVisible={detailsVisible}\n        onDetailsVisibleChange={setDetailsVisible}\n        card={<CardArtwork detailsVisible={detailsVisible} />}\n      />\n    </div>\n  );\n}\n"}]}