{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"date-range-picker","type":"registry:component","title":"Date range picker","description":"Paints the range as you hover, then commits it on the second click.","author":"Yash Bavadiya <https://xevrion.dev>","dependencies":["motion"],"registryDependencies":["utils"],"files":[{"path":"components/date-range-picker.tsx","type":"registry:component","content":"\"use client\";\n\nimport {\n  useEffect,\n  useId,\n  useRef,\n  useState,\n  useSyncExternalStore,\n} from \"react\";\nimport {\n  AnimatePresence,\n  MotionConfig,\n  motion,\n  useIsPresent,\n  type Variants,\n} from \"motion/react\";\nimport { useReducedMotion } from \"@/hooks/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport type Range = { start: string; end: string };\n\nconst EASE_OUT = [0.23, 1, 0.32, 1] as const;\nconst ICON_SWAP = { type: \"spring\", duration: 0.3, bounce: 0 } as const;\n// Far enough to read as travel, short enough that the fade does most of the\n// work and the months never look like they are leaving the card.\nconst SLIDE = 56;\nconst PANEL: Variants = {\n  enter: (dir: number) => ({ x: dir * SLIDE, opacity: 0, filter: \"blur(4px)\" }),\n  center: {\n    x: 0,\n    opacity: 1,\n    filter: \"blur(0px)\",\n    transition: { duration: 0.25, ease: EASE_OUT },\n  },\n  // Leaves quicker and travels less than the incoming months arrive, so the\n  // eye goes straight to the new ones.\n  exit: (dir: number) => ({\n    x: dir * -SLIDE * 0.6,\n    opacity: 0,\n    filter: \"blur(2px)\",\n    transition: { duration: 0.18, ease: EASE_OUT },\n  }),\n};\n\nconst WEEKDAYS = [\n  \"Sunday\",\n  \"Monday\",\n  \"Tuesday\",\n  \"Wednesday\",\n  \"Thursday\",\n  \"Friday\",\n  \"Saturday\",\n];\n// Six weeks covers every month, so the grids never change height.\nconst CELLS = 42;\n// Below this the card can't fit two 7 x 36px grids side by side.\nconst TWO_MONTHS_AT = 540;\n\nconst pad = (n: number) => String(n).padStart(2, \"0\");\nconst toIso = (d: Date) =>\n  `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;\nconst fromIso = (iso: string) => {\n  const [y, m, d] = iso.split(\"-\").map(Number);\n  return new Date(y, m - 1, d);\n};\n// Months as one running number, so comparing two tells the direction.\nconst monthIndex = (iso: string) => {\n  const [y, m] = iso.split(\"-\").map(Number);\n  return y * 12 + m - 1;\n};\nconst monthStart = (month: number) =>\n  toIso(new Date(Math.floor(month / 12), month % 12, 1));\nconst monthEnd = (month: number) =>\n  toIso(new Date(Math.floor(month / 12), (month % 12) + 1, 0));\nconst addDays = (iso: string, days: number) => {\n  const d = fromIso(iso);\n  return toIso(new Date(d.getFullYear(), d.getMonth(), d.getDate() + days));\n};\n// Keeps the day of month, clamped so Jan 31 plus one month is Feb 28.\nconst addMonths = (iso: string, months: number) => {\n  const d = fromIso(iso);\n  const last = new Date(d.getFullYear(), d.getMonth() + months + 1, 0);\n  return toIso(\n    new Date(last.getFullYear(), last.getMonth(), Math.min(d.getDate(), last.getDate())),\n  );\n};\nconst daysBetween = (a: string, b: string) =>\n  Math.round((fromIso(b).getTime() - fromIso(a).getTime()) / 86_400_000);\nconst monthTitle = (month: number) =>\n  new Date(Math.floor(month / 12), month % 12, 1).toLocaleDateString(\"en-US\", {\n    month: \"long\",\n    year: \"numeric\",\n  });\nconst dayLabel = (iso: string) =>\n  fromIso(iso).toLocaleDateString(\"en-US\", {\n    weekday: \"long\",\n    month: \"long\",\n    day: \"numeric\",\n    year: \"numeric\",\n  });\nconst short = (iso: string, withYear: boolean) =>\n  fromIso(iso).toLocaleDateString(\"en-US\", {\n    month: \"short\",\n    day: \"numeric\",\n    year: withYear ? \"numeric\" : undefined,\n  });\n\nfunction describe(range: Range) {\n  const sameYear = range.start.slice(0, 4) === range.end.slice(0, 4);\n  const days = daysBetween(range.start, range.end) + 1;\n  const span =\n    range.start === range.end\n      ? short(range.start, true)\n      : `${short(range.start, !sameYear)} to ${short(range.end, true)}`;\n  return `${span} · ${days} day${days === 1 ? \"\" : \"s\"}`;\n}\n\n// The server can't know the viewer's date or time zone, so it renders an\n// empty frame of the same size and the client fills it in on hydration.\nconst noSubscribe = () => () => {};\nconst useToday = () =>\n  useSyncExternalStore(\n    noSubscribe,\n    () => toIso(new Date()),\n    () => null,\n  );\n\nfunction presets(today: string): { label: string; range: Range }[] {\n  const month = monthIndex(today);\n  return [\n    { label: \"Last 7 days\", range: { start: addDays(today, -6), end: today } },\n    { label: \"Last 30 days\", range: { start: addDays(today, -29), end: today } },\n    { label: \"This month\", range: { start: monthStart(month), end: monthEnd(month) } },\n    { label: \"Last month\", range: { start: monthStart(month - 1), end: monthEnd(month - 1) } },\n  ];\n}\n\nexport function DateRangePicker({\n  value,\n  onApply,\n  className,\n}: {\n  value?: Range | null;\n  onApply?: (range: Range) => void;\n  className?: string;\n}) {\n  const today = useToday();\n  const reduceMotion = useReducedMotion();\n  const titleId = useId();\n  const rootRef = useRef<HTMLDivElement>(null);\n  const areaRef = useRef<HTMLDivElement>(null);\n  const [start, setStart] = useState<string | null>(value?.start ?? null);\n  const [end, setEnd] = useState<string | null>(value?.end ?? null);\n  // The day under the pointer (or keyboard focus) while picking an end.\n  const [hover, setHover] = useState<string | null>(null);\n  const [focused, setFocused] = useState<string | null>(null);\n  // Null until the user navigates, meaning \"the months around the range or\n  // today\". It is the month shown on the left.\n  const [view, setView] = useState<number | null>(null);\n  const [direction, setDirection] = useState(1);\n  const [single, setSingle] = useState(false);\n  const [applied, setApplied] = useState(false);\n  const moveFocus = useRef(false);\n  const appliedTimer = useRef<ReturnType<typeof setTimeout>>(undefined);\n\n  useEffect(() => () => clearTimeout(appliedTimer.current), []);\n\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const observer = new ResizeObserver(([entry]) =>\n      setSingle(entry.contentRect.width < TWO_MONTHS_AT),\n    );\n    observer.observe(el);\n    return () => observer.disconnect();\n  }, []);\n\n  const count = single ? 1 : 2;\n  const anchor = start ?? today;\n  // On two months, a range that ends in the anchor's month shows it on the\n  // right, so the month before it stays in view.\n  const defaultView = anchor\n    ? end && !single && monthIndex(end) === monthIndex(anchor)\n      ? monthIndex(anchor) - 1\n      : monthIndex(anchor)\n    : null;\n  const shownView = view ?? defaultView;\n  const focusedIso = focused ?? anchor;\n\n  // After a keyboard move, focus follows to the day's button, which may be\n  // in months that have only just mounted.\n  useEffect(() => {\n    if (!moveFocus.current || !focusedIso) return;\n    moveFocus.current = false;\n    areaRef.current\n      ?.querySelector<HTMLButtonElement>(\n        `[data-view=\"${shownView}\"] [data-date=\"${focusedIso}\"]`,\n      )\n      ?.focus({ preventScroll: true });\n  }, [focusedIso, shownView]);\n\n  const picking = start !== null && end === null;\n  const lo = picking && hover ? (hover < start ? hover : start) : start;\n  const hi = picking ? (hover ? (hover < start ? start : hover) : start) : end;\n\n  // Always stores the month, even when unchanged, so the default view stops\n  // tracking the selection once the user has touched anything.\n  const showView = (next: number) => {\n    if (shownView === null) return;\n    if (next !== shownView) setDirection(next > shownView ? 1 : -1);\n    setView(next);\n  };\n\n  // Keeps an iso date inside the visible months, shifting by as little\n  // as possible.\n  const reveal = (iso: string) => {\n    if (shownView === null) return;\n    const m = monthIndex(iso);\n    if (m < shownView) showView(m);\n    else if (m > shownView + count - 1) showView(m - count + 1);\n    else showView(shownView);\n  };\n\n  const select = (iso: string) => {\n    setApplied(false);\n    setFocused(iso);\n    reveal(iso);\n    if (!picking) {\n      setStart(iso);\n      setEnd(null);\n      setHover(iso);\n    } else if (iso < start) {\n      setStart(iso);\n      setEnd(start);\n      setHover(null);\n    } else {\n      setEnd(iso);\n      setHover(null);\n    }\n  };\n\n  const setRange = (range: Range | null) => {\n    setApplied(false);\n    setHover(null);\n    setStart(range?.start ?? null);\n    setEnd(range?.end ?? null);\n    if (shownView === null) return;\n    if (!range) return showView(shownView);\n    setFocused(range.start);\n    // Shows the end month, with the start's month beside it when it fits.\n    const endMonth = monthIndex(range.end);\n    const visible =\n      monthIndex(range.start) >= shownView &&\n      endMonth <= shownView + count - 1;\n    showView(\n      visible\n        ? shownView\n        : Math.max(monthIndex(range.start), endMonth - count + 1),\n    );\n  };\n\n  const goTo = (iso: string) => {\n    setFocused(iso);\n    if (picking) setHover(iso);\n    reveal(iso);\n    moveFocus.current = true;\n  };\n\n  const step = (months: number) => {\n    if (shownView === null) return;\n    showView(shownView + months);\n    if (focusedIso) setFocused(addMonths(focusedIso, months));\n  };\n\n  const onGridKeyDown = (e: React.KeyboardEvent) => {\n    if (!focusedIso) return;\n    const weekday = fromIso(focusedIso).getDay();\n    const years = e.shiftKey ? 12 : 1;\n    const moves: Record<string, () => string> = {\n      ArrowLeft: () => addDays(focusedIso, -1),\n      ArrowRight: () => addDays(focusedIso, 1),\n      ArrowUp: () => addDays(focusedIso, -7),\n      ArrowDown: () => addDays(focusedIso, 7),\n      Home: () => addDays(focusedIso, -weekday),\n      End: () => addDays(focusedIso, 6 - weekday),\n      PageUp: () => addMonths(focusedIso, -years),\n      PageDown: () => addMonths(focusedIso, years),\n    };\n    const move = moves[e.key];\n    if (move) {\n      e.preventDefault();\n      goTo(move());\n    } else if (e.key === \"Escape\" && picking) {\n      // Backs out of a half-picked range.\n      e.preventDefault();\n      setStart(null);\n      setHover(null);\n    }\n  };\n\n  const complete = start !== null && end !== null;\n  const summary = complete\n    ? describe({ start, end })\n    : picking\n      ? `From ${short(start, true)}`\n      : \"No dates selected\";\n  const hint = complete ? \"\" : picking ? \"Pick an end date\" : \"Pick a start date\";\n  const chips = today ? presets(today) : [];\n\n  // The tabbable day: the focused one when it is in view, else the first\n  // day on screen, so Tab always lands somewhere visible.\n  const tabbable =\n    shownView !== null && focusedIso && monthIndex(focusedIso) >= shownView &&\n    monthIndex(focusedIso) < shownView + count\n      ? focusedIso\n      : shownView !== null\n        ? monthStart(shownView)\n        : null;\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <div\n        ref={rootRef}\n        className={cn(\n          \"w-[600px] max-w-full rounded-[24px] bg-background p-4 shadow-raised\",\n          className,\n        )}\n      >\n        <div\n          role=\"group\"\n          aria-label=\"Presets\"\n          // Scrolls sideways on narrow screens; the 4px of vertical padding\n          // keeps focus outlines from being clipped by that overflow.\n          className=\"-mx-4 -mt-1 mb-2 flex gap-1.5 overflow-x-auto px-4 py-1 [scrollbar-width:none]\"\n        >\n          {chips.map((chip) => {\n            const active =\n              start === chip.range.start && end === chip.range.end;\n            return (\n              <button\n                key={chip.label}\n                type=\"button\"\n                aria-pressed={active}\n                onClick={() => setRange(chip.range)}\n                className={cn(\n                  \"h-9 shrink-0 rounded-full px-3.5 text-sm whitespace-nowrap outline-hidden select-none\",\n                  \"transition-[scale,color,background-color,box-shadow] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-foreground active:scale-[0.96] motion-reduce:transition-[color,background-color,box-shadow]\",\n                  active\n                    ? \"bg-foreground text-background\"\n                    : \"text-muted-foreground shadow-[inset_0_0_0_1px_var(--border)] hover:bg-foreground/[0.04] hover:text-foreground\",\n                )}\n              >\n                {chip.label}\n              </button>\n            );\n          })}\n          {/* Keeps the row's height on the server, before presets exist. */}\n          {!today && <span aria-hidden className=\"h-9\" />}\n        </div>\n\n        {/* Header 40 + weekdays 32 + six 40px weeks = 312. The 4px of\n            padding buys back room for focus outlines on the outer days. */}\n        <div\n          ref={areaRef}\n          className=\"relative -m-1 h-[320px] overflow-hidden p-1\"\n          onKeyDown={onGridKeyDown}\n          onPointerLeave={() => {\n            if (picking) setHover(null);\n          }}\n        >\n          {shownView !== null && today && (\n            <>\n              <div className=\"pointer-events-none absolute inset-x-1 top-1 z-10 flex justify-between\">\n                <NavButton label=\"Previous month\" onClick={() => step(-1)}>\n                  <path d=\"M10 3.5 5.5 8l4.5 4.5\" />\n                </NavButton>\n                <NavButton label=\"Next month\" onClick={() => step(1)}>\n                  <path d=\"m6 3.5 4.5 4.5L6 12.5\" />\n                </NavButton>\n              </div>\n              <span id={titleId} className=\"sr-only\" aria-live=\"polite\">\n                {Array.from({ length: count }, (_, i) =>\n                  monthTitle(shownView + i),\n                ).join(\" and \")}\n              </span>\n              <AnimatePresence mode=\"popLayout\" initial={false} custom={direction}>\n                <Months\n                  key={shownView}\n                  view={shownView}\n                  count={count}\n                  direction={direction}\n                  today={today}\n                  lo={lo}\n                  hi={hi}\n                  start={start}\n                  end={end}\n                  hover={picking ? hover : null}\n                  tabbable={tabbable}\n                  onSelect={select}\n                  onHover={(iso) => {\n                    if (picking) setHover(iso);\n                  }}\n                />\n              </AnimatePresence>\n            </>\n          )}\n        </div>\n\n        <div className=\"-mx-4 mt-3 flex h-14 items-center gap-2 border-t border-border px-4 pt-3\">\n          <div className=\"min-w-0 flex-1\">\n            <p\n              className={cn(\n                \"truncate text-sm tabular-nums\",\n                start ? \"text-foreground\" : \"text-muted-foreground\",\n              )}\n            >\n              {summary}\n            </p>\n            <p className=\"h-4 truncate text-xs text-muted-foreground\">{hint}</p>\n          </div>\n          <button\n            type=\"button\"\n            onClick={() => setRange(null)}\n            inert={!start}\n            className={cn(\n              \"h-9 rounded-full px-3.5 text-sm text-muted-foreground outline-hidden select-none\",\n              \"transition-[scale,color,background-color,opacity] duration-150 ease-out hover:bg-foreground/[0.05] hover:text-foreground focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-foreground active:scale-[0.96] motion-reduce:transition-[color,background-color,opacity]\",\n              !start && \"opacity-40\",\n            )}\n          >\n            Clear\n          </button>\n          <button\n            type=\"button\"\n            disabled={!complete}\n            onClick={() => {\n              if (!complete) return;\n              onApply?.({ start, end });\n              setApplied(true);\n              clearTimeout(appliedTimer.current);\n              // Long enough to register, then back to a plain Apply.\n              appliedTimer.current = setTimeout(() => setApplied(false), 1600);\n            }}\n            className={cn(\n              \"flex h-9 items-center gap-1.5 rounded-full bg-foreground px-4 text-sm font-medium text-background outline-hidden select-none\",\n              \"transition-[scale,opacity] duration-150 ease-out focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-foreground enabled:active:scale-[0.96] disabled:opacity-40 motion-reduce:transition-[opacity]\",\n            )}\n          >\n            {/* Both labels share a cell, so the button keeps one width. */}\n            <span className=\"grid\">\n              <span className=\"col-start-1 row-start-1 flex items-center justify-center gap-1.5\">\n                <motion.svg\n                  aria-hidden\n                  {...STROKE}\n                  strokeWidth={2}\n                  className=\"size-4\"\n                  initial={false}\n                  animate={\n                    applied\n                      ? { scale: 1, opacity: 1, filter: \"blur(0px)\" }\n                      : reduceMotion\n                        ? { opacity: 0 }\n                        : { scale: 0.25, opacity: 0, filter: \"blur(4px)\" }\n                  }\n                  transition={ICON_SWAP}\n                >\n                  <path d=\"m3.5 8.5 3 3 6-7\" />\n                </motion.svg>\n                <span\n                  className={cn(\n                    \"transition-[opacity,filter] duration-200 ease-out\",\n                    !applied && \"opacity-0 blur-[4px]\",\n                  )}\n                >\n                  Applied\n                </span>\n              </span>\n              <span\n                className={cn(\n                  \"col-start-1 row-start-1 flex items-center justify-center transition-[opacity,filter] duration-200 ease-out\",\n                  applied && \"opacity-0 blur-[4px]\",\n                )}\n              >\n                Apply\n              </span>\n            </span>\n          </button>\n        </div>\n        <span className=\"sr-only\" aria-live=\"polite\">\n          {applied ? `Applied ${summary}` : \"\"}\n        </span>\n      </div>\n    </MotionConfig>\n  );\n}\n\nfunction Months({\n  ref,\n  view,\n  count,\n  direction,\n  ...grid\n}: {\n  // popLayout measures the outgoing months through this ref.\n  ref?: React.Ref<HTMLDivElement>;\n  view: number;\n  count: number;\n  direction: number;\n} & Omit<React.ComponentProps<typeof MonthGrid>, \"month\">) {\n  // The outgoing months stay in the DOM while they fade, but are gone as\n  // far as focus, pointer and screen readers are concerned.\n  const present = useIsPresent();\n  return (\n    <motion.div\n      ref={ref}\n      custom={direction}\n      variants={PANEL}\n      initial=\"enter\"\n      animate=\"center\"\n      exit=\"exit\"\n      data-view={view}\n      inert={!present}\n      className=\"flex gap-6\"\n    >\n      {Array.from({ length: count }, (_, i) => (\n        <MonthGrid key={i} month={view + i} {...grid} />\n      ))}\n    </motion.div>\n  );\n}\n\nfunction MonthGrid({\n  month,\n  today,\n  lo,\n  hi,\n  start,\n  end,\n  hover,\n  tabbable,\n  onSelect,\n  onHover,\n}: {\n  month: number;\n  today: string;\n  lo: string | null;\n  hi: string | null;\n  start: string | null;\n  end: string | null;\n  hover: string | null;\n  tabbable: string | null;\n  onSelect: (iso: string) => void;\n  onHover: (iso: string) => void;\n}) {\n  const titleId = useId();\n  const first = fromIso(monthStart(month));\n  const lead = first.getDay();\n  const last = monthEnd(month);\n  const days = Array.from({ length: CELLS }, (_, i) => {\n    const d = new Date(first.getFullYear(), first.getMonth(), i - lead + 1);\n    return monthIndex(toIso(d)) === month ? toIso(d) : null;\n  });\n\n  return (\n    <div className=\"min-w-0 flex-1\">\n      <p\n        id={titleId}\n        className=\"flex h-10 items-center justify-center text-[15px] font-medium text-foreground\"\n      >\n        {monthTitle(month)}\n      </p>\n      <table\n        role=\"grid\"\n        aria-labelledby={titleId}\n        className=\"w-full table-fixed border-collapse\"\n      >\n        <thead>\n          <tr>\n            {WEEKDAYS.map((day) => (\n              <th\n                key={day}\n                scope=\"col\"\n                abbr={day}\n                className=\"h-8 p-0 text-center text-xs font-medium text-muted-foreground\"\n              >\n                {day.slice(0, 2)}\n              </th>\n            ))}\n          </tr>\n        </thead>\n        <tbody>\n          {Array.from({ length: CELLS / 7 }, (_, w) => (\n            <tr key={w}>\n              {days.slice(w * 7, w * 7 + 7).map((iso, col) => {\n                if (!iso) return <td key={col} className=\"h-10 p-0\" />;\n                const isEdge = iso === lo || iso === hi;\n                const inRange =\n                  lo !== null && hi !== null && lo !== hi && iso >= lo && iso <= hi;\n                const committed = iso === start || iso === end;\n                // The band rounds off wherever a week or the month breaks\n                // it, so each row reads as one continuous pill.\n                const rowStart = col === 0 || iso.endsWith(\"-01\");\n                const rowEnd = col === 6 || iso === last;\n                // An endpoint on a row break has nothing beside it to join.\n                const band =\n                  inRange &&\n                  !(iso === lo && rowEnd) &&\n                  !(iso === hi && rowStart);\n                return (\n                  <td\n                    key={iso}\n                    role=\"gridcell\"\n                    aria-selected={inRange || committed}\n                    className=\"relative h-10 p-0\"\n                  >\n                    {band && (\n                      <span\n                        aria-hidden\n                        className={cn(\n                          \"absolute inset-y-0.5 bg-foreground/[0.07]\",\n                          // Endpoints only fill toward the rest of the\n                          // range; their circle is the rounded end.\n                          iso === lo ? \"left-1/2\" : \"left-0\",\n                          iso === hi ? \"right-1/2\" : \"right-0\",\n                          rowStart && iso !== lo && \"rounded-l-full\",\n                          rowEnd && iso !== hi && \"rounded-r-full\",\n                        )}\n                      />\n                    )}\n                    <button\n                      type=\"button\"\n                      data-date={iso}\n                      tabIndex={iso === tabbable ? 0 : -1}\n                      aria-label={dayLabel(iso)}\n                      aria-current={iso === today ? \"date\" : undefined}\n                      onClick={() => onSelect(iso)}\n                      onPointerEnter={(e) => {\n                        if (e.pointerType !== \"touch\") onHover(iso);\n                      }}\n                      className={cn(\n                        \"relative mx-auto flex size-9 touch-manipulation items-center justify-center rounded-full text-sm tabular-nums outline-hidden select-none\",\n                        \"transition-[scale] duration-150 ease-out active:scale-[0.96] motion-reduce:transition-none\",\n                        \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-1 focus-visible:outline-foreground\",\n                        committed\n                          ? \"bg-foreground text-background\"\n                          : isEdge && hover\n                            ? // The prospective end: marked, but not yet filled.\n                              \"bg-foreground/[0.14] text-foreground\"\n                            : \"text-foreground hover:bg-foreground/[0.07]\",\n                      )}\n                    >\n                      {Number(iso.slice(8))}\n                      {iso === today && (\n                        <span\n                          aria-hidden\n                          className=\"absolute bottom-1 left-1/2 size-1 -translate-x-1/2 rounded-full bg-current\"\n                        />\n                      )}\n                    </button>\n                  </td>\n                );\n              })}\n            </tr>\n          ))}\n        </tbody>\n      </table>\n    </div>\n  );\n}\n\nfunction NavButton({\n  label,\n  onClick,\n  children,\n}: {\n  label: string;\n  onClick: () => void;\n  children: React.ReactNode;\n}) {\n  return (\n    <button\n      type=\"button\"\n      aria-label={label}\n      onClick={onClick}\n      className=\"pointer-events-auto flex size-10 touch-manipulation items-center justify-center rounded-full text-muted-foreground outline-hidden select-none transition-[scale,color,background-color] duration-150 ease-out hover:bg-foreground/[0.06] hover:text-foreground focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-foreground active:scale-[0.96] motion-reduce:transition-[color,background-color]\"\n    >\n      <svg aria-hidden {...STROKE} className=\"size-4\">\n        {children}\n      </svg>\n    </button>\n  );\n}\n\nconst STROKE = {\n  viewBox: \"0 0 16 16\",\n  fill: \"none\",\n  stroke: \"currentColor\",\n  strokeWidth: 1.5,\n  strokeLinecap: \"round\",\n  strokeLinejoin: \"round\",\n} as const;\n\nexport default function DateRangePickerDemo() {\n  return <DateRangePicker />;\n}\n"},{"path":"hooks/use-reduced-motion.ts","type":"registry:hook","target":"hooks/use-reduced-motion.ts","content":"\"use client\";\n\nimport { useSyncExternalStore } from \"react\";\n\n// Motion's useReducedMotion reads the media query on the very first client\n// render, but the server can't know it, so every component that renders\n// differently under reduced motion broke hydration for those users. This\n// reports false during hydration, matching the server HTML, then the real\n// preference straight after, and follows it if it changes.\nconst query = \"(prefers-reduced-motion: reduce)\";\n\nfunction subscribe(onChange: () => void) {\n  const media = window.matchMedia(query);\n  media.addEventListener(\"change\", onChange);\n  return () => media.removeEventListener(\"change\", onChange);\n}\n\nexport function useReducedMotion() {\n  return useSyncExternalStore(\n    subscribe,\n    () => window.matchMedia(query).matches,\n    () => false,\n  );\n}\n"}],"cssVars":{"light":{"shadow-raised":"0 0 0 1px oklch(0 0 0 / 0.06), 0 1px 2px oklch(0 0 0 / 0.06), 0 6px 16px -6px oklch(0 0 0 / 0.12)"},"dark":{"shadow-raised":"0 0 0 1px oklch(1 0 0 / 0.08), 0 1px 2px oklch(0 0 0 / 0.4), 0 6px 16px -6px oklch(0 0 0 / 0.6)"},"theme":{"shadow-raised":"var(--shadow-raised)"}},"categories":["inputs"],"docs":"From ui lab: https://lab.xevrion.dev/lab/date-range-picker"}