{
  "$schema": "https://shadcn-svelte.com/schema/registry-item.json",
  "name": "sticker-burst",
  "title": "StickerBurst",
  "type": "registry:ui",
  "description": "Bursts colorful decorative symbols around an existing control when activated.",
  "dependencies": [
    "motion@^13.1.0"
  ],
  "meta": {
    "kida": {
      "package": {
        "name": "@kida-ui/svelte",
        "exportName": "StickerBurst",
        "styleImports": [
          "@kida-ui/styles/kida.css"
        ]
      },
      "framework": "svelte"
    }
  },
  "categories": [
    "decorative"
  ],
  "files": [
    {
      "content": "<script lang=\"ts\">\nimport './sticker-burst.css'\nimport { stickerBurst, stickerBurstLayout } from './sticker-burst.motion.js'\nimport { untrack } from 'svelte'\nimport type { StickerBurstProps } from './sticker-burst.types.js'\n\nlet {\n  stickers,\n  count,\n  distance,\n  seed,\n  element = $bindable(null),\n  children,\n  ...rest\n}: StickerBurstProps = $props()\n\nconst defaults = ['✦', '●', '♥', '★']\nconst symbols = $derived(stickers?.length ? stickers : defaults)\nconst points = $derived(stickerBurstLayout({ count, distance, seed }))\nconst root = $derived(element)\n\n$effect(() => {\n  const node = root\n  if (!node) return\n  return untrack(() => stickerBurst(node))\n})\n</script>\n\n<span {...rest} bind:this={element} data-kida-sticker-burst=\"\" data-state=\"idle\"><span data-kida-sticker-content=\"\">{@render children?.()}</span><span aria-hidden=\"true\" data-kida-sticker-layer=\"\">{#each points as point, index (index)}<span\n        style:--kida-sticker-x={`${point.x}px`}\n        style:--kida-sticker-y={`${point.y}px`}\n        style:--kida-sticker-rotation={`${point.rotation}deg`}\n        style:--kida-sticker-delay={`${point.delay}ms`}\n        style:--kida-sticker-scale={point.scale}\n      >{symbols[index % symbols.length]}</span>{/each}</span></span>\n",
      "type": "registry:ui",
      "target": "kida/sticker-burst.svelte"
    },
    {
      "content": "import type { StickerBurstOptions } from './sticker-burst.motion.js';\n\nimport type { HTMLAttributes } from 'svelte/elements';\n\nexport interface StickerBurstProps extends StickerBurstOptions, HTMLAttributes<HTMLSpanElement> {\n    stickers?: readonly string[];\n    element?: HTMLSpanElement | null;\n}\n",
      "type": "registry:ui",
      "target": "kida/sticker-burst.types.ts"
    },
    {
      "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": "kida/sticker-burst.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": "kida/tokens.css"
    },
    {
      "content": "import { prefersReducedMotion } from './reduced-motion.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:ui",
      "target": "kida/sticker-burst.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:ui",
      "target": "kida/reduced-motion.motion.ts"
    }
  ]
}
