{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "goodui-motion",
  "title": "goodui motion and material tokens",
  "description": "The shared spring set, easing curves, elevation shadows, press behaviour and grain every goodui component uses. Installed automatically with any component that needs it.",
  "files": [
    {
      "path": "lib/motion.tsx",
      "content": "// goodui motion and material tokens: one spring set, one set of curves, one elevation scale, one press.\r\n// Installs as lib/goodui-motion.tsx. Components import from \"@/lib/goodui-motion\" and render <GooduiTokens />, so a\r\n// single installed component carries everything it needs. React 19 hoists and dedupes the style tag by href.\r\n\r\nimport { GooduiIdle } from \"./goodui-idle\"\r\n\r\n/** The whole kit moves on these. Spread one to add a delay: `{ ...spring.ui, delay: 0.1 }`. */\r\nexport const spring = {\r\n  /** Indicators, tabs, press release. */\r\n  snap: { type: \"spring\", visualDuration: 0.18, bounce: 0 },\r\n  /** Menus, popovers, layout. */\r\n  ui: { type: \"spring\", visualDuration: 0.28, bounce: 0.1 },\r\n  /** Shared layout, dialogs. */\r\n  morph: { type: \"spring\", visualDuration: 0.4, bounce: 0.12 },\r\n  /** Drawers and sheets. */\r\n  sheet: { type: \"spring\", visualDuration: 0.45, bounce: 0 },\r\n  /** Success moments and drag release only. */\r\n  play: { type: \"spring\", duration: 0.5, bounce: 0.2 },\r\n} as const\r\n\r\n/** Pointer followers, for useSpring. */\r\nexport const follow = { stiffness: 170, damping: 26, mass: 0.5 }\r\n\r\n/** The same curves as the CSS variables, for motion `ease`. */\r\nexport const ease = {\r\n  out: [0.23, 1, 0.32, 1],\r\n  outExpo: [0.16, 1, 0.3, 1],\r\n  inOut: [0.77, 0, 0.175, 1],\r\n  drawer: [0.32, 0.72, 0, 1],\r\n} as const\r\n\r\nconst GRAIN = `url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E\")`\r\n\r\n/*\r\n * :where() keeps specificity at zero, so a style pack or the app's own CSS can set any of these and win.\r\n * Dark shadows use white top light and black rims. Light shadows are tinted, never pure black.\r\n */\r\nexport const TOKENS_CSS = `\r\n:where(:root){\r\n  --pc-ease-out:cubic-bezier(.23,1,.32,1);\r\n  --pc-ease-out-expo:cubic-bezier(.16,1,.3,1);\r\n  --pc-ease-in-out:cubic-bezier(.77,0,.175,1);\r\n  --pc-ease-drawer:cubic-bezier(.32,.72,0,1);\r\n  --pc-ease-spring:cubic-bezier(.34,1.56,.64,1);\r\n  --pc-spring-css:var(--pc-ease-spring);\r\n  --pc-grain:${GRAIN};\r\n  --pc-hair:color-mix(in oklab,var(--foreground) 8%,transparent);\r\n  --pc-sh:240 20% 15%;\r\n  --pc-e1:0 0 0 1px var(--pc-hair),0 1px 2px hsl(var(--pc-sh)/.05);\r\n  --pc-e2:0 0 0 1px var(--pc-hair),0 1px 1px hsl(var(--pc-sh)/.03),0 4px 8px -4px hsl(var(--pc-sh)/.06),0 12px 20px -8px hsl(var(--pc-sh)/.08);\r\n  --pc-e3:0 0 0 1px var(--pc-hair),0 1px 1px hsl(var(--pc-sh)/.03),0 8px 16px -4px hsl(var(--pc-sh)/.07),0 24px 40px -12px hsl(var(--pc-sh)/.14);\r\n  --pc-well:inset 0 1px 2px hsl(var(--pc-sh)/.06);\r\n  --pc-sheen:linear-gradient(rgb(255 255 255/.1),transparent);\r\n  --pc-edge-t:rgb(255 255 255/.22);\r\n  --pc-edge-b:rgb(0 0 0/.12);\r\n}\r\n@supports (animation-timing-function:linear(0,1)){\r\n  :where(:root){--pc-spring-css:linear(0,.042,.141,.267,.399,.526,.639,.735,.813,.875,.922,.957,.981,.997,1.007,1.012,1.015,1.015,1.014,1.012,1.01,1.008,1.007,1.005,1)}\r\n}\r\n:where(.dark){\r\n  --pc-hair:rgb(255 255 255/.08);\r\n  --pc-e1:inset 0 1px rgb(255 255 255/.06),0 0 0 1px rgb(0 0 0/.5),0 1px 2px rgb(0 0 0/.4);\r\n  --pc-e2:inset 0 1px rgb(255 255 255/.08),inset 0 0 0 1px rgb(255 255 255/.04),0 0 0 1px rgb(0 0 0/.6),0 8px 24px -4px rgb(0 0 0/.5);\r\n  --pc-e3:inset 0 1px rgb(255 255 255/.1),inset 0 0 0 1px rgb(255 255 255/.05),0 0 0 1px rgb(0 0 0/.7),0 30px 50px -8px rgb(0 0 0/.6);\r\n  --pc-well:inset 0 1px 2px rgb(0 0 0/.35);\r\n}\r\n.pc-press{transition:scale 120ms var(--pc-ease-out),transform 200ms var(--pc-ease-out),background-color 150ms ease,border-color 150ms ease,color 150ms ease,box-shadow 150ms ease,opacity 150ms ease}\r\n.pc-press:where(:active:not(:disabled,[aria-disabled=true])){scale:.97}\r\n.pc-press-soft:where(:active:not(:disabled,[aria-disabled=true])){scale:.992}\r\n.pc-grain{position:relative;isolation:isolate}\r\n.pc-grain::after{content:\"\";position:absolute;inset:0;z-index:1;pointer-events:none;border-radius:inherit;opacity:.06;mix-blend-mode:overlay;background-image:var(--pc-grain)}\r\n@media (prefers-reduced-motion:reduce){.pc-press,.pc-press-soft{scale:none!important;transition:none}}\r\n[data-pc-away],[data-pc-away]::before,[data-pc-away]::after{animation-play-state:paused!important}\r\n`\r\n\r\n/** Renders nothing in place: the style tag is hoisted to <head> and shared by every component on the page. */\r\nexport function GooduiTokens() {\r\n  return (\r\n    <>\r\n      <style href=\"pc-tokens\" precedence=\"default\">\r\n        {TOKENS_CSS}\r\n      </style>\r\n      <GooduiIdle />\r\n    </>\r\n  )\r\n}\r\n",
      "type": "registry:lib",
      "target": "lib/goodui-motion.tsx"
    },
    {
      "path": "lib/goodui-idle.tsx",
      "content": "\"use client\"\r\n\r\nimport * as React from \"react\"\r\n\r\n// Some endless CSS animations (a text shimmer, a pulsing shadow, a travelling beam) make the browser restyle the page every frame, even\r\n// while the element is scrolled far out of view. One such element is cheap; a long page with a dozen of them keeps a\r\n// phone's processor busy for nothing and makes scrolling stutter. This pauses those endless goodui animations while their\r\n// element is off screen and resumes them just before it comes back. One listener and one observer for the whole page,\r\n// installed once, however many components render it.\r\n\r\nconst AWAY = \"data-pc-away\"\r\n// Properties that move or resize the element's own box. A keyframe also has an `offset` key (its position in time), which\r\n// is not the CSS `offset` property: that one is spelled `cssOffset` here.\r\nconst MOVES = /^(transform|translate|rotate|scale|cssOffset|offsetDistance|offsetPath|inset|top|right|bottom|left|margin|width|height)/\r\n// What the browser can animate without the main thread.\r\nconst FREE = /^(transform|translate|rotate|scale|opacity)$/\r\n// Keys every keyframe has that are not CSS properties.\r\nconst META = /^(offset|easing|composite|computedOffset)$/\r\nlet installed = false\r\n\r\ntype Kind = \"none\" | \"still\" | \"moving\"\r\n\r\n/** Does the element carry an endless goodui animation, and does that animation move the element's own box? */\r\nfunction kind(el: Element): Kind {\r\n  let found: Kind = \"none\"\r\n  for (const a of el.getAnimations({ subtree: true })) {\r\n    const fx = a.effect as KeyframeEffect | null\r\n    const name = (a as CSSAnimation).animationName\r\n    if (!fx || fx.target !== el || typeof name !== \"string\" || !name.startsWith(\"pc-\") || fx.getTiming().iterations !== Infinity) continue\r\n    const props = fx.getKeyframes().flatMap((k) => Object.keys(k)).filter((p) => !META.test(p))\r\n    // An animation that only moves or fades its element already runs off the main thread and costs the page nothing, so\r\n    // there is nothing to win by pausing it; measured on real pages, a paused one next to a running one can even make\r\n    // the browser restyle every frame. Only the costly kinds are paused. An animated custom property (@property) lists\r\n    // no properties at all here, and it is one of the costly kinds.\r\n    if (props.length && props.every((p) => FREE.test(p))) continue\r\n    if (!fx.pseudoElement && props.some((p) => MOVES.test(p))) return \"moving\"\r\n    found = \"still\"\r\n  }\r\n  return found\r\n}\r\n\r\nfunction install() {\r\n  if (installed || typeof IntersectionObserver === \"undefined\" || typeof Element.prototype.getAnimations !== \"function\") return\r\n  installed = true\r\n  const watched = new WeakSet<Element>()\r\n  // The observed box, and the animated elements that follow it.\r\n  const followers = new WeakMap<Element, Set<Element>>()\r\n  const io = new IntersectionObserver(\r\n    (entries) => {\r\n      for (const e of entries) {\r\n        const set = followers.get(e.target)\r\n        if (!set) continue\r\n        for (const el of set) {\r\n          if (!el.isConnected) set.delete(el)\r\n          else if (e.isIntersecting) el.removeAttribute(AWAY)\r\n          else if (e.target.isConnected) el.setAttribute(AWAY, \"\")\r\n        }\r\n        if (!set.size) {\r\n          followers.delete(e.target)\r\n          io.unobserve(e.target)\r\n        }\r\n      }\r\n    },\r\n    { rootMargin: \"200px\" },\r\n  )\r\n  const watch = (el: Element | null) => {\r\n    if (!el || watched.has(el)) return\r\n    const k = kind(el)\r\n    if (k === \"none\") return\r\n    // A bar that slides out of its own track would look \"off screen\" at the wrong moment and stay paused there, so an\r\n    // element that moves itself is judged by the box it lives in, which holds still.\r\n    const box = k === \"moving\" ? el.parentElement : el\r\n    // No box (display: contents) never intersects; leave it alone rather than pause it for good.\r\n    if (!box || box.getClientRects().length === 0) return\r\n    watched.add(el)\r\n    const set = followers.get(box)\r\n    if (set) {\r\n      // The box is already known: join it in whatever state its other followers are in.\r\n      for (const other of set) {\r\n        if (other.hasAttribute(AWAY)) el.setAttribute(AWAY, \"\")\r\n        break\r\n      }\r\n      set.add(el)\r\n    } else {\r\n      followers.set(box, new Set([el]))\r\n      io.observe(box)\r\n    }\r\n  }\r\n  // Server-rendered animations are already running by the time this loads.\r\n  for (const a of document.getAnimations()) watch((a.effect as KeyframeEffect | null)?.target ?? null)\r\n  document.addEventListener(\r\n    \"animationstart\",\r\n    (e) => {\r\n      if (e.animationName.startsWith(\"pc-\") && e.target instanceof Element) watch(e.target)\r\n    },\r\n    true,\r\n  )\r\n}\r\n\r\n/** Renders nothing. Mounted by `<GooduiTokens />`, so every goodui component brings it along. */\r\nexport function GooduiIdle() {\r\n  React.useEffect(install, [])\r\n  return null\r\n}\r\n",
      "type": "registry:lib",
      "target": "lib/goodui-idle.tsx"
    }
  ],
  "type": "registry:lib"
}