{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sticker-burst",
  "title": "StickerBurst",
  "description": "Bursts colorful decorative symbols around an existing control when activated.",
  "dependencies": [
    "motion@^13.1.0"
  ],
  "files": [
    {
      "path": "packages/react/src/sticker-burst.tsx",
      "content": "'use client'\n\nimport './sticker-burst.css'\nimport { type StickerBurstOptions, stickerBurst, stickerBurstLayout } from './motion/sticker-burst.js'\nimport type { CSSProperties, HTMLAttributes, ReactNode } from 'react'\nimport { forwardRef, useRef } from 'react'\nimport { composeRefs } from './compose-refs.js'\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect.js'\n\nexport interface StickerBurstProps\n  extends StickerBurstOptions,\n    Omit<HTMLAttributes<HTMLSpanElement>, 'children'> {\n  children?: ReactNode\n  /** Decorative symbols repeated through the burst. */\n  stickers?: readonly string[]\n}\n\nconst DEFAULT_STICKERS = ['✦', '●', '♥', '★'] as const\n\ntype PieceStyle = CSSProperties & {\n  '--kida-sticker-x': string\n  '--kida-sticker-y': string\n  '--kida-sticker-rotation': string\n  '--kida-sticker-delay': string\n  '--kida-sticker-scale': number\n}\n\nexport const StickerBurst = forwardRef<HTMLSpanElement, StickerBurstProps>(function StickerBurst(\n  { children, stickers = DEFAULT_STICKERS, count, distance, seed, ...props },\n  forwardedRef,\n) {\n  const ref = useRef<HTMLSpanElement>(null)\n  const points = stickerBurstLayout({ count, distance, seed })\n  const symbols = stickers.length > 0 ? stickers : DEFAULT_STICKERS\n\n  useIsomorphicLayoutEffect(() => {\n    const root = ref.current\n    if (!root) return\n    return stickerBurst(root)\n  }, [])\n\n  return (\n    <span\n      {...props}\n      ref={composeRefs(ref, forwardedRef)}\n      data-kida-sticker-burst=\"\"\n      data-state=\"idle\"\n    >\n      <span data-kida-sticker-content=\"\">{children}</span>\n      <span aria-hidden=\"true\" data-kida-sticker-layer=\"\">\n        {points.map((point, index) => {\n          const style: PieceStyle = {\n            '--kida-sticker-x': `${point.x}px`,\n            '--kida-sticker-y': `${point.y}px`,\n            '--kida-sticker-rotation': `${point.rotation}deg`,\n            '--kida-sticker-delay': `${point.delay}ms`,\n            '--kida-sticker-scale': point.scale,\n          }\n          return (\n            <span key={`${point.x}-${point.y}-${point.delay}`} style={style}>\n              {symbols[index % symbols.length]}\n            </span>\n          )\n        })}\n      </span>\n    </span>\n  )\n})\n",
      "type": "registry:ui",
      "target": "@ui/kida/sticker-burst.tsx"
    },
    {
      "path": "packages/react/src/compose-refs.ts",
      "content": "import type { Ref } from 'react'\n\n/** Feed one node to several refs — ours for measuring, Zag's for animation detection. */\nexport function composeRefs<T>(...refs: (Ref<T> | undefined)[]) {\n  return (node: T | null) => {\n    for (const ref of refs) {\n      if (typeof ref === 'function') ref(node)\n      else if (ref) (ref as { current: T | null }).current = node\n    }\n  }\n}\n",
      "type": "registry:lib",
      "target": "@ui/kida/compose-refs.ts"
    },
    {
      "path": "packages/react/src/use-isomorphic-layout-effect.ts",
      "content": "'use client'\n\nimport { useEffect, useLayoutEffect } from 'react'\n\n/**\n * `useLayoutEffect` in the browser, `useEffect` on the server.\n *\n * Motion has to be applied before paint or the user sees an unstyled frame, but React\n * warns when `useLayoutEffect` runs during SSR — where it does nothing anyway.\n */\nexport const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect\n",
      "type": "registry:hook",
      "target": "@ui/kida/use-isomorphic-layout-effect.ts"
    },
    {
      "path": "packages/styles/components/sticker-burst.css",
      "content": "@import './tokens.css';\n\n[data-kida-sticker-burst] {\n  --kida-sticker-color: #e94f86;\n  --kida-sticker-color-secondary: #a78bfa;\n  --kida-sticker-color-tertiary: #75c9a6;\n  --kida-sticker-color-fourth: #f4a261;\n  --kida-sticker-size: 1rem;\n  --kida-sticker-duration: 620ms;\n\n  position: relative;\n  display: inline-flex;\n  isolation: isolate;\n}\n\n[data-kida-sticker-content] {\n  position: relative;\n  z-index: 1;\n  display: inline-flex;\n}\n\n[data-kida-sticker-layer] {\n  position: absolute;\n  z-index: 0;\n  top: 50%;\n  left: 50%;\n  width: 0;\n  height: 0;\n  pointer-events: none;\n}\n\n[data-kida-sticker-layer] > span {\n  position: absolute;\n  top: 0;\n  left: 0;\n  color: var(--kida-sticker-color);\n  font-size: calc(var(--kida-sticker-size) * var(--kida-sticker-scale));\n  line-height: 1;\n  opacity: 0;\n  transform: translate(-50%, -50%) scale(0.3);\n}\n\n[data-kida-sticker-layer] > span:nth-child(4n + 2) {\n  color: var(--kida-sticker-color-secondary);\n}\n\n[data-kida-sticker-layer] > span:nth-child(4n + 3) {\n  color: var(--kida-sticker-color-tertiary);\n}\n\n[data-kida-sticker-layer] > span:nth-child(4n) {\n  color: var(--kida-sticker-color-fourth);\n}\n\n[data-kida-sticker-burst][data-state=\"active\"] [data-kida-sticker-layer] > span {\n  animation: kida-sticker-burst var(--kida-sticker-duration) var(--kida-ease-out)\n    var(--kida-sticker-delay) both;\n}\n\n@keyframes kida-sticker-burst {\n  0% {\n    opacity: 0;\n    transform: translate(-50%, -50%) rotate(0) scale(0.3);\n  }\n  18% {\n    opacity: 1;\n  }\n  68% {\n    opacity: 1;\n    transform: translate(calc(-50% + var(--kida-sticker-x)), calc(-50% + var(--kida-sticker-y)))\n      rotate(var(--kida-sticker-rotation)) scale(1);\n  }\n  100% {\n    opacity: 0;\n    transform: translate(calc(-50% + var(--kida-sticker-x)), calc(-50% + var(--kida-sticker-y)))\n      rotate(var(--kida-sticker-rotation)) scale(0.86);\n  }\n}\n\n@media (prefers-reduced-motion: reduce) {\n  [data-kida-sticker-burst][data-state=\"active\"] [data-kida-sticker-layer] > span {\n    animation: none;\n  }\n}\n",
      "type": "registry:ui",
      "target": "@ui/kida/sticker-burst.css"
    },
    {
      "path": "packages/styles/tokens.css",
      "content": "/*\n * Kida UI — motion tokens.\n * Plain CSS custom properties (ADR D7). No preprocessor, no Tailwind, no build step.\n */\n\n:root {\n  /* Durations */\n  --kida-duration-xs: 100ms;\n  --kida-duration-sm: 150ms;\n  --kida-duration-md: 300ms;\n  --kida-duration-lg: 500ms;\n  --kida-duration-xl: 800ms;\n\n  /* Easings */\n  --kida-ease-out: cubic-bezier(0.16, 1, 0.3, 1);\n  --kida-ease-in: cubic-bezier(0.7, 0, 0.84, 0);\n  --kida-ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);\n  --kida-ease-spring: linear(0, 0.5, 0.9, 1.02, 1);\n\n  /* Travel distances used by the enter/exit keyframes */\n  --kida-distance-sm: 4px;\n  --kida-distance-md: 8px;\n  --kida-distance-lg: 16px;\n\n  /* Stagger step between siblings */\n  --kida-stagger: 60ms;\n}\n\n/*\n * The shared reduced-motion guard for CSS-driven animation in the library.\n * Durations collapse to ~0 by default. Components whose presence lifecycle cannot safely observe\n * a 1ms animation, such as Collapse, disable it explicitly and complete presence in their adapter.\n */\n@media (prefers-reduced-motion: reduce) {\n  :root {\n    --kida-duration-xs: 1ms;\n    --kida-duration-sm: 1ms;\n    --kida-duration-md: 1ms;\n    --kida-duration-lg: 1ms;\n    --kida-duration-xl: 1ms;\n    --kida-distance-sm: 0px;\n    --kida-distance-md: 0px;\n    --kida-distance-lg: 0px;\n    --kida-stagger: 0ms;\n  }\n}\n",
      "type": "registry:ui",
      "target": "@ui/kida/tokens.css"
    },
    {
      "path": "packages/motion/src/sticker-burst.ts",
      "content": "import { prefersReducedMotion } from './reduced-motion.js'\n\nexport interface StickerBurstPoint {\n  x: number\n  y: number\n  rotation: number\n  delay: number\n  scale: number\n}\n\nexport interface StickerBurstOptions {\n  /** Number of decorative pieces. @default 8 */\n  count?: number\n  /** Maximum travel in CSS pixels. @default 64 */\n  distance?: number\n  /** Stable layout seed. @default 17 */\n  seed?: number\n}\n\nconst DEFAULTS = { count: 8, distance: 64, seed: 17 } as const\n\nfunction random(seed: number) {\n  let state = seed >>> 0\n  return () => {\n    state += 0x6d2b79f5\n    let value = state\n    value = Math.imul(value ^ (value >>> 15), value | 1)\n    value ^= value + Math.imul(value ^ (value >>> 7), value | 61)\n    return ((value ^ (value >>> 14)) >>> 0) / 4294967296\n  }\n}\n\n/** Stable geometry keeps server output and hydration identical. */\nexport function stickerBurstLayout(options: StickerBurstOptions = {}): StickerBurstPoint[] {\n  const count = Math.max(1, Math.min(16, Math.round(options.count ?? DEFAULTS.count)))\n  const distance = Math.max(16, options.distance ?? DEFAULTS.distance)\n  const next = random(options.seed ?? DEFAULTS.seed)\n\n  return Array.from({ length: count }, (_, index) => {\n    const angle = -Math.PI / 2 + (Math.PI * 2 * index) / count + (next() - 0.5) * 0.3\n    const radius = distance * (0.72 + next() * 0.28)\n    return {\n      x: Math.round(Math.cos(angle) * radius * 100) / 100,\n      y: Math.round(Math.sin(angle) * radius * 100) / 100,\n      rotation: Math.round((next() * 100 - 50) * 100) / 100,\n      delay: Math.round(index * 18 + next() * 18),\n      scale: Math.round((0.82 + next() * 0.36) * 100) / 100,\n    }\n  })\n}\n\n/** Replays the CSS burst for pointer and keyboard-generated clicks. */\nexport function stickerBurst(root: HTMLElement): () => void {\n  root.dataset.state = 'idle'\n  if (prefersReducedMotion()) return () => {}\n\n  const replay = () => {\n    root.dataset.state = 'idle'\n    // A single layout read per intentional trigger restarts the finite CSS animation.\n    void root.offsetWidth\n    root.dataset.state = 'active'\n  }\n\n  root.addEventListener('click', replay)\n  return () => {\n    root.removeEventListener('click', replay)\n    root.dataset.state = 'idle'\n  }\n}\n",
      "type": "registry:lib",
      "target": "@ui/kida/motion/sticker-burst.ts"
    },
    {
      "path": "packages/motion/src/reduced-motion.ts",
      "content": "const QUERY = '(prefers-reduced-motion: reduce)'\n\n/**\n * Whether the user has asked for reduced motion.\n *\n * SSR-safe: returns `false` when there is no `window`, matching the CSS default\n * (the `prefers-reduced-motion` media query in `@kida-ui/styles` is the real guard;\n * this is for the JS-driven paths that CSS cannot express).\n */\nexport function prefersReducedMotion(): boolean {\n  if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return false\n  return window.matchMedia(QUERY).matches\n}\n\n/**\n * Subscribe to changes of the reduced-motion preference.\n * Returns an unsubscribe function. No-op (and immediately unsubscribable) on the server.\n */\nexport function watchReducedMotion(onChange: (reduced: boolean) => void): () => void {\n  if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') return () => {}\n\n  const list = window.matchMedia(QUERY)\n  const handler = (event: MediaQueryListEvent) => onChange(event.matches)\n  list.addEventListener('change', handler)\n  return () => list.removeEventListener('change', handler)\n}\n",
      "type": "registry:lib",
      "target": "@ui/kida/motion/reduced-motion.ts"
    }
  ],
  "meta": {
    "kida": {
      "package": {
        "name": "@kida-ui/react",
        "exportName": "StickerBurst",
        "styleImports": [
          "@kida-ui/styles/kida.css"
        ]
      }
    }
  },
  "categories": [
    "decorative"
  ],
  "type": "registry:ui"
}
