{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "motion",
  "type": "registry:lib",
  "title": "Motion",
  "description": "MotionProvider, the motion recipes and useShake: how components animate, and the switch that turns motion off.",
  "registryDependencies": [
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/motion/index.ts",
      "type": "registry:lib",
      "target": "lib/wideset/motion/index.ts",
      "content": "export type { MotionProps, MotionProviderProps } from './Motion.types';\nexport { MotionProvider } from './MotionProvider';\nexport { useShake } from './useShake';\n"
    },
    {
      "path": "src/motion/Motion.types.ts",
      "type": "registry:lib",
      "target": "lib/wideset/motion/Motion.types.ts",
      "content": "import type { ReactNode } from 'react';\n\nexport type MotionProps = {\n  /**\n   * Turns the component's built-in animations on or off.\n   * When omitted, inherits the value from the nearest `MotionProvider`.\n   * @default true\n   */\n  defaultMotion?: boolean;\n};\n\nexport type MotionProviderProps = {\n  /**\n   * Turns built-in animations on or off for all Wideset components inside.\n   * A component's own `defaultMotion` overrides it.\n   * @default true\n   */\n  enabled?: boolean;\n  children?: ReactNode;\n};\n"
    },
    {
      "path": "src/motion/MotionProvider.tsx",
      "type": "registry:lib",
      "target": "lib/wideset/motion/MotionProvider.tsx",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { MotionProviderProps } from './Motion.types';\n\nconst MotionContext = createContext(true);\n\nexport const MotionProvider = ({ enabled = true, children }: MotionProviderProps) => (\n  <MotionContext.Provider value={enabled}>{children}</MotionContext.Provider>\n);\n\nexport const useDefaultMotion = (localValue?: boolean): boolean => {\n  const inheritedValue = useContext(MotionContext);\n  return localValue ?? inheritedValue;\n};\n"
    },
    {
      "path": "src/motion/recipes.ts",
      "type": "registry:lib",
      "target": "lib/wideset/motion/recipes.ts",
      "content": "import { cn } from '@/lib/wideset/utils';\n\n/** Checkbox and radio surface fill when their state changes. */\nexport const boxFillMotion =\n  'transition-[background-color,border-color] duration-(--ws-motion-duration-quick) ease-(--ws-motion-ease-smooth-out)';\n\n/** Base transitions for hover tint and returning from interaction states. */\nexport const hoverTintMotion =\n  'transition-[background-color,border-color,color,box-shadow,scale,opacity] duration-(--ws-motion-duration-quick) ease-(--ws-motion-ease-out)';\n\n/** Compose with hoverTintMotion for press feedback and a smooth release. */\nexport const pressMotion = cn(\n  'active:not-disabled:not-aria-disabled:duration-(--ws-motion-duration-micro)',\n  'active:not-disabled:not-aria-disabled:scale-(--ws-motion-scale-small)',\n);\n\nexport const switchTrackMotion =\n  'transition-[background-color] duration-(--ws-motion-duration-micro) ease-(--ws-motion-ease-out)';\n\nexport const switchThumbTravelMotion =\n  'transition-[translate,width,height] duration-(--ws-motion-duration-quick) ease-(--ws-motion-ease-smooth-out)';\n\nexport const fieldFocusMotion =\n  'transition-[border-color,box-shadow,background-color,color] duration-(--ws-motion-duration-quick) ease-(--ws-motion-ease-out)';\n\nexport const fieldShakeMotion =\n  'data-[shake=true]:animate-[ws-field-shake_calc(var(--ws-motion-duration-micro)*3.5)_linear]';\n\nexport const fieldShakeWithinMotion =\n  'has-data-[shake=true]:animate-[ws-field-shake_calc(var(--ws-motion-duration-micro)*3.5)_linear]';\n\nexport const sidebarCollapseMotion =\n  'transition-[width] duration-(--ws-motion-duration-slow) ease-(--ws-motion-ease-smooth-out)';\n\nexport const fillTravelMotion =\n  'transition-transform duration-(--ws-motion-duration-medium) ease-(--ws-motion-ease-smooth-out)';\n"
    },
    {
      "path": "src/motion/useShake.ts",
      "type": "registry:lib",
      "target": "lib/wideset/motion/useShake.ts",
      "content": "'use client';\n\nimport { useCallback, useEffect, useRef } from 'react';\n\nexport const useShake = <T extends HTMLElement = HTMLDivElement>() => {\n  const ref = useRef<T>(null);\n  const cleanupRef = useRef<(() => void) | null>(null);\n\n  useEffect(() => () => cleanupRef.current?.(), []);\n\n  const shake = useCallback(() => {\n    const element = ref.current;\n    if (!element) return;\n    cleanupRef.current?.();\n    const { ownerDocument } = element;\n    const handleAnimationEnd = (event: AnimationEvent) => {\n      if (event.animationName !== 'ws-field-shake') return;\n      if (!(event.target instanceof Node) || !event.target.contains(element)) return;\n      cleanup();\n    };\n    const cleanup = () => {\n      element.removeAttribute('data-shake');\n      ownerDocument.removeEventListener('animationend', handleAnimationEnd);\n      ownerDocument.removeEventListener('animationcancel', handleAnimationEnd);\n      cleanupRef.current = null;\n    };\n    element.removeAttribute('data-shake');\n    void element.offsetWidth;\n    element.setAttribute('data-shake', 'true');\n    ownerDocument.addEventListener('animationend', handleAnimationEnd);\n    ownerDocument.addEventListener('animationcancel', handleAnimationEnd);\n    cleanupRef.current = cleanup;\n  }, []);\n\n  return { ref, shake };\n};\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
