{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "drag-02",
  "type": "registry:ui",
  "title": "drag-02",
  "description": "Animated drag icon for Vue",
  "dependencies": [
    "motion-v"
  ],
  "files": [
    {
      "path": "components/ui/drag-02.vue",
      "type": "registry:ui",
      "content": "<script setup lang=\"ts\">\nimport { motion, useAnimationControls } from 'motion-v'\nimport type { Variants } from 'motion-v'\nimport { useIconAnimation } from '../composables/useIconAnimation'\nimport type { AnimatedIconHandle } from '../types'\n\ndefineOptions({ inheritAttrs: false, name: 'Drag02Icon' })\n\nwithDefaults(\n  defineProps<{\n    size?: number\n  }>(),\n  { size: 28 },\n)\n\n// after cursor-pointer-01: the grabbed object pulls away, carries momentum, and returns\n// generated from @hugeicons/core-free-icons\nconst iconVariants: Variants = {\n  normal: {\n    transform: 'translateX(0px) rotate(0deg)',\n  },\n  animate: {\n    transform: ['translateX(0px) rotate(0deg)', 'translateX(2.99px) rotate(3.74deg)', 'translateX(-0.37px) rotate(-0.94deg)', 'translateX(0px) rotate(0deg)'],\n    transition: {\n      duration: 0.66,\n      ease: [0.23, 1, 0.32, 1],\n    },\n  },\n}\n\nconst controls = useAnimationControls()\nconst { onMouseEnter, onMouseLeave, startAnimation, stopAnimation } = useIconAnimation({\n  controls,\n  loops: false,\n})\n\ndefineExpose<AnimatedIconHandle>({ startAnimation, stopAnimation })\n</script>\n\n<template>\n  <div class=\"hia-icon\" @mouseenter=\"onMouseEnter\" @mouseleave=\"onMouseLeave\" v-bind=\"$attrs\">\n          <svg xmlns=\"http://www.w3.org/2000/svg\" :width=\"size\" :height=\"size\" viewBox=\"0 0 24 24\" fill=\"none\" overflow=\"visible\">\n            <motion.path d=\"M8.492 16.7708L8.7397 16.528C9.30111 15.9779 9.62089 15.2262 9.62853 14.4387L9.67839 9.29499C9.68515 8.5976 9.9101 7.86083 10.5428 7.57149C11.4996 7.13391 12.6822 7.38098 12.8952 9.42674L13.2233 11.1555L18.8027 4.45497C19.9702 3.35338 22.0426 4.74594 21.1388 6.47149L17.8575 10.4213C19.1379 11.2814 23.8618 16.1719 20.0362 18.6611C19.4845 19.1418 18.1777 19.839 17.0378 20.2016C15.951 20.5474 15.2689 21.7309 14.9345 22.0003\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"iconVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '16.18px 22px' }\" />\n            <motion.path d=\"M9.48367 3.51398C9.48367 4.35006 10.1351 5.02784 10.9386 5.02784C11.7422 5.02784 12.3936 4.35006 12.3936 3.51398C12.3936 2.6779 11.7422 2.00012 10.9386 2.00012C10.1351 2.00012 9.48367 2.6779 9.48367 3.51398ZM9.48367 3.51398H8.8398L8.0692 3.58624M3.98952 8.94285C4.82649 8.9291 5.4637 9.58457 5.47696 10.3961C5.49021 11.2077 4.86737 11.9061 4.0304 11.9198C3.19343 11.9336 2.51131 11.2487 2.49806 10.4372C2.4848 9.62562 3.15255 8.95659 3.98952 8.94285ZM3.98952 8.94285L4.07917 7.60966M5.77439 4.65096L5.44659 4.9579L5.15694 5.27066\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"iconVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '16.18px 22px' }\" />\n          </svg>\n        </div>\n</template>\n"
    },
    {
      "path": "composables/useIconAnimation.ts",
      "type": "registry:lib",
      "content": "import { ref, toValue, type MaybeRefOrGetter } from 'vue'\nimport type { AnimatedIconHandle } from '../types'\n\nexport type IconPose = 'normal' | 'animate'\n\ntype AnimationControls = {\n  set: (variant: IconPose | Record<string, unknown>) => void\n  start: (variant: IconPose | Record<string, unknown>) => Promise<unknown>\n}\n\nexport function useReducedMotionFlag(\n  reduced?: MaybeRefOrGetter<boolean | undefined>,\n) {\n  if (typeof window === 'undefined') return () => false\n  return () => {\n    const override = reduced === undefined ? undefined : toValue(reduced)\n    if (override !== undefined) return override\n    return window.matchMedia('(prefers-reduced-motion: reduce)').matches\n  }\n}\n\nexport function useIconAnimation(options: {\n  controls: AnimationControls\n  loops?: boolean\n}): AnimatedIconHandle & {\n  onMouseEnter: () => void\n  onMouseLeave: () => void\n} {\n  const { controls, loops = false } = options\n  const isPlaying = ref(false)\n  let run = 0\n\n  const prefersReduced = () =>\n    typeof window !== 'undefined' &&\n    window.matchMedia('(prefers-reduced-motion: reduce)').matches\n\n  async function startAnimation() {\n    if (prefersReduced() || isPlaying.value) return\n\n    isPlaying.value = true\n    const current = ++run\n    controls.set('normal')\n    await controls.start('animate')\n    if (run === current) isPlaying.value = false\n  }\n\n  function stopAnimation() {\n    if (!loops) return\n    run += 1\n    isPlaying.value = false\n    void controls.start('normal')\n  }\n\n  return {\n    startAnimation,\n    stopAnimation,\n    onMouseEnter: () => {\n      void startAnimation()\n    },\n    onMouseLeave: () => {\n      stopAnimation()\n    },\n  }\n}\n"
    },
    {
      "path": "types/animated-icon.ts",
      "type": "registry:lib",
      "content": "export interface AnimatedIconHandle {\n  startAnimation: () => void\n  stopAnimation: () => void\n}\n\nexport interface AnimatedIconProps {\n  size?: number\n}\n"
    }
  ]
}
