{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "add-invoice",
  "type": "registry:ui",
  "title": "add-invoice",
  "description": "Animated add invoice icon for Vue",
  "dependencies": [
    "motion-v"
  ],
  "files": [
    {
      "path": "components/ui/add-invoice.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: 'AddInvoiceIcon' })\n\nwithDefaults(\n  defineProps<{\n    size?: number\n  }>(),\n  { size: 28 },\n)\n\n// the invoice lifts off the stack, its lines settle in reading order, and the add mark is stamped on the corner\n// authored from scripts/authored\nconst invoiceVariants: Variants = {\n  normal: { transform: 'translateY(0px)' },\n  animate: {\n    transform: ['translateY(0px)', 'translateY(-0.9px)', 'translateY(0px)'],\n    transition: { duration: 0.6, times: [0, 0.4, 1], ease: [0.23, 1, 0.32, 1] },\n  },\n};\n\nconst lineVariants: Variants = {\n  normal: { transform: 'scaleX(1)' },\n  animate: {\n    transform: ['scaleX(1)', 'scaleX(0.55)', 'scaleX(1)'],\n    transition: { duration: 0.5, delay: 0.12, times: [0, 0.36, 1], ease: [0.23, 1, 0.32, 1] },\n  },\n};\n\nconst plusVariants: Variants = {\n  normal: { transform: 'rotate(0deg) scale(1)' },\n  animate: {\n    transform: [\n      'rotate(0deg) scale(1)',\n      'rotate(-12deg) scale(0.56)',\n      'rotate(4deg) scale(1.14)',\n      'rotate(0deg) scale(1)',\n    ],\n    transition: { duration: 0.5, delay: 0.2, times: [0, 0.32, 0.68, 1], ease: [0.23, 1, 0.32, 1] },\n  },\n};\n\nconst line2Variants: Variants = {\n  normal: { transform: 'scaleX(1)' },\n  animate: {\n    transform: ['scaleX(1)', 'scaleX(0.55)', 'scaleX(1)'],\n    transition: { duration: 0.5, delay: 0.06, times: [0, 0.36, 1], ease: [0.23, 1, 0.32, 1] },\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=\"M12.06 21.5124C11.5445 21.8375 11.2868 22 11 22C10.7132 22 10.4554 21.8374 9.94 21.5124L8.02913 20.3073C7.54415 20.0014 7.30166 19.8485 7.03253 19.8397C6.74172 19.8301 6.49493 19.9768 5.97087 20.3073C5.38395 20.6774 4.21687 21.6971 3.46195 21.2108C3 20.9133 3 20.1575 3 18.6458V8.00002C3 5.17158 3 3.75736 3.82699 2.87868C4.65399 2 5.98501 2 8.64706 2H13.3529C16.015 2 17.346 2 18.173 2.87868C19 3.75736 19 5.17158 19 8.00002V12\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"invoiceVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '11px 22px' }\" />\n            <motion.path d=\"M11 11H7\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"lineVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '7px 11px' }\" />\n            <motion.path d=\"M17 14V22M21 18L13 18\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"plusVariants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '17px 18px' }\" />\n            <motion.path d=\"M15 7L7 7\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"1.5\" :variants=\"line2Variants\" :animate=\"controls\" initial=\"normal\" :style=\"{ transformOrigin: '7px 7px' }\" />\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"
    }
  ]
}
