{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"state-icon","type":"registry:ui","title":"State Icon","description":"One status icon that morphs between idle dot, spinning arc, a ring that closes into a popping check, and a shaking cross.","dependencies":["motion"],"registryDependencies":[],"files":[{"path":"registry/ui/state-icon.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { MotionConfig, motion } from \"motion/react\";\n\nexport type StateIconStatus = \"idle\" | \"loading\" | \"success\" | \"error\";\n\nexport interface StateIconProps {\n  status?: StateIconStatus;\n  /** Diameter in px. */\n  size?: number;\n  successColor?: string;\n  errorColor?: string;\n  /** Screen-reader text per status. */\n  labels?: Partial<Record<StateIconStatus, string>>;\n  className?: string;\n}\n\nconst draw = (on: boolean, delay = 0) => ({\n  animate: { pathLength: on ? 1 : 0, opacity: on ? 1 : 0 },\n  transition: on\n    ? { pathLength: { type: \"spring\", stiffness: 260, damping: 18, delay }, opacity: { duration: 0.01, delay } }\n    : { duration: 0.12 },\n});\n\nexport function StateIcon({\n  status = \"idle\",\n  size = 48,\n  successColor = \"#22c55e\",\n  errorColor = \"#ef4444\",\n  labels,\n  className,\n}: StateIconProps) {\n  const loading = status === \"loading\";\n  const ok = status === \"success\";\n  const bad = status === \"error\";\n  const tint = ok ? successColor : bad ? errorColor : \"var(--muted-foreground)\";\n  const text = { idle: \"Idle\", loading: \"Loading\", success: \"Done\", error: \"Failed\", ...labels }[status];\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <span\n        role=\"status\"\n        className={`relative inline-grid place-items-center transition-colors duration-300 ${className ?? \"\"}`}\n        style={{ width: size, height: size, color: tint }}\n      >\n        <motion.svg\n          aria-hidden\n          viewBox=\"0 0 48 48\"\n          fill=\"none\"\n          className=\"size-full overflow-visible\"\n          initial={false}\n          animate={\n            ok ? { scale: [1, 0.86, 1.14, 1], x: 0 } : bad ? { x: [0, -5, 5, -4, 3, -1, 0], scale: 1 } : { scale: 1, x: 0 }\n          }\n          transition={{ duration: ok ? 0.5 : 0.45, ease: \"easeOut\", delay: ok || bad ? 0.15 : 0 }}\n        >\n          {/* Soft disc that floods in on a result. */}\n          <motion.circle\n            cx=\"24\"\n            cy=\"24\"\n            r=\"20\"\n            initial={false}\n            animate={{ scale: ok || bad ? 1 : 0.4, opacity: ok || bad ? 0.16 : 0 }}\n            transition={{ type: \"spring\", stiffness: 300, damping: 18, delay: 0.1 }}\n            fill=\"currentColor\"\n          />\n          {/* Ring: a spinning arc while loading that grows closed when it resolves. */}\n          <motion.g\n            initial={false}\n            animate={{ rotate: loading ? [0, 360] : 0 }}\n            transition={loading ? { duration: 0.9, ease: \"linear\", repeat: Infinity } : { duration: 0.3 }}\n          >\n            <circle cx=\"24\" cy=\"24\" r=\"20\" strokeWidth=\"3\" className=\"stroke-border\" opacity={loading ? 1 : 0} />\n            <motion.circle\n              cx=\"24\"\n              cy=\"24\"\n              r=\"20\"\n              strokeWidth=\"3\"\n              strokeLinecap=\"round\"\n              transform=\"rotate(-90 24 24)\"\n              initial={false}\n              animate={{ pathLength: loading ? 0.28 : 1, opacity: status === \"idle\" ? 0.45 : 1 }}\n              transition={{ type: \"spring\", stiffness: 180, damping: 20 }}\n              stroke=\"currentColor\"\n            />\n          </motion.g>\n          {/* Idle dot. */}\n          <motion.circle\n            cx=\"24\"\n            cy=\"24\"\n            r=\"4\"\n            initial={false}\n            animate={{ scale: status === \"idle\" ? 1 : 0 }}\n            transition={{ type: \"spring\", stiffness: 500, damping: 20 }}\n            className=\"fill-muted-foreground\"\n          />\n          <motion.path d=\"M15 24.5l6 6L33 18\" stroke={successColor} strokeWidth=\"3.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" initial={false} {...draw(ok, 0.2)} />\n          <motion.path d=\"M17 17l14 14\" stroke={errorColor} strokeWidth=\"3.5\" strokeLinecap=\"round\" initial={false} {...draw(bad, 0.15)} />\n          <motion.path d=\"M31 17L17 31\" stroke={errorColor} strokeWidth=\"3.5\" strokeLinecap=\"round\" initial={false} {...draw(bad, 0.28)} />\n        </motion.svg>\n        <span className=\"sr-only\">{text}</span>\n      </span>\n    </MotionConfig>\n  );\n}\n"}]}