{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "calendar",
  "type": "registry:ui",
  "title": "Calendar",
  "description": "A month grid for picking one date, several dates, or a range.",
  "categories": [
    "forms"
  ],
  "dependencies": [
    "@hugeicons/core-free-icons@4.4.0",
    "@hugeicons/react@1.1.10",
    "react-day-picker@10.0.2"
  ],
  "registryDependencies": [
    "https://sprout.tulipfarm.ai/r/sprout-base.json",
    "https://sprout.tulipfarm.ai/r/button.json",
    "https://sprout.tulipfarm.ai/r/select.json"
  ],
  "files": [
    {
      "path": "registry/sprout/components/ui/calendar.tsx",
      "type": "registry:ui",
      "target": "components/ui/calendar.tsx",
      "content": "'use client';\n\nimport { useEffect, useRef, type ChangeEvent, type ComponentProps } from 'react';\nimport {\n  DayPicker,\n  getDefaultClassNames,\n  type ChevronProps,\n  type DayButtonProps,\n  type DropdownProps,\n  type RootProps,\n  type WeekNumberProps,\n  useDayPicker,\n} from 'react-day-picker';\nimport { ChevronDownIcon } from '@/lib/sprout/icons/chevron-down-icon';\nimport { ChevronLeftIcon } from '@/lib/sprout/icons/chevron-left-icon';\nimport { ChevronRightIcon } from '@/lib/sprout/icons/chevron-right-icon';\nimport { cn } from '@/lib/sprout/classes';\nimport { Button, buttonVariants, type ButtonVariant } from '@/components/ui/button';\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';\n\nexport type { DateRange, Matcher } from 'react-day-picker';\n\nexport const calendarCaptionLayoutNames = ['label', 'dropdown', 'dropdown-months', 'dropdown-years'] as const;\n\nexport type CalendarCaptionLayout = (typeof calendarCaptionLayoutNames)[number];\n\nexport type CalendarProps = ComponentProps<typeof DayPicker> & {\n  buttonVariant?: ButtonVariant;\n};\n\ntype DayPickerLocale = ComponentProps<typeof DayPicker>['locale'];\n\nfunction CalendarRoot({ className, rootRef, ...props }: RootProps) {\n  return <div data-slot=\"calendar\" ref={rootRef} className={className} {...props} />;\n}\n\nfunction CalendarChevron({ className, orientation, size: _size, disabled: _disabled, ...props }: ChevronProps) {\n  const Icon = orientation === 'left' ? ChevronLeftIcon : orientation === 'right' ? ChevronRightIcon : ChevronDownIcon;\n  return <Icon aria-hidden=\"true\" className={cn('sprout-calendar-chevron', className)} {...props} />;\n}\n\nfunction CalendarWeekNumber({ children, week: _week, ...props }: WeekNumberProps) {\n  return (\n    <th {...props}>\n      <div className=\"sprout-calendar-week-number-cell\">{children}</div>\n    </th>\n  );\n}\n\nfunction CalendarDropdown({\n  options = [],\n  value,\n  onChange,\n  disabled,\n  className,\n  style,\n  'aria-label': label,\n}: DropdownProps) {\n  const items = options.map(option => ({\n    value: option.value,\n    label: option.label,\n  }));\n  return (\n    <Select<number>\n      items={items}\n      value={Number(value)}\n      disabled={disabled}\n      onValueChange={next => {\n        if (next === null) return;\n        onChange?.({\n          target: { value: String(next) },\n        } as ChangeEvent<HTMLSelectElement>);\n      }}\n    >\n      <SelectTrigger size=\"sm\" aria-label={label} style={style} className={cn('sprout-calendar-dropdown', className)}>\n        <SelectValue />\n      </SelectTrigger>\n      <SelectContent className=\"sprout-calendar-dropdown-content\">\n        {options.map(option => (\n          <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n            {option.label}\n          </SelectItem>\n        ))}\n      </SelectContent>\n    </Select>\n  );\n}\n\nexport function Calendar({\n  className,\n  classNames,\n  showOutsideDays = true,\n  captionLayout = 'label',\n  buttonVariant = 'ghost',\n  locale,\n  formatters,\n  components,\n  ...props\n}: CalendarProps) {\n  const defaults = getDefaultClassNames();\n  const navButton = cn(buttonVariants({ variant: buttonVariant, size: 'icon-sm' }), 'sprout-calendar-nav-button');\n  return (\n    <DayPicker\n      showOutsideDays={showOutsideDays}\n      className={cn('sprout-calendar', className)}\n      data-button-variant={buttonVariant}\n      data-caption-layout={captionLayout}\n      captionLayout={captionLayout}\n      locale={locale}\n      formatters={{\n        formatMonthDropdown: date => date.toLocaleString(locale?.code, { month: 'short' }),\n        ...formatters,\n      }}\n      classNames={{\n        root: cn('sprout-calendar-root', defaults.root),\n        months: cn('sprout-calendar-months', defaults.months),\n        month: cn('sprout-calendar-month', defaults.month),\n        nav: cn('sprout-calendar-nav', defaults.nav),\n        button_previous: cn(navButton, defaults.button_previous),\n        button_next: cn(navButton, defaults.button_next),\n        month_caption: cn('sprout-calendar-caption', defaults.month_caption),\n        dropdowns: cn('sprout-calendar-dropdowns', defaults.dropdowns),\n        dropdown_root: cn('sprout-calendar-dropdown-root', defaults.dropdown_root),\n        dropdown: cn(defaults.dropdown),\n        caption_label: cn('sprout-calendar-caption-label', defaults.caption_label),\n        month_grid: cn('sprout-calendar-grid', defaults.month_grid),\n        weekdays: cn('sprout-calendar-weekdays', defaults.weekdays),\n        weekday: cn('sprout-calendar-weekday', defaults.weekday),\n        week: cn('sprout-calendar-week', defaults.week),\n        week_number_header: cn('sprout-calendar-week-number-header', defaults.week_number_header),\n        week_number: cn('sprout-calendar-week-number', defaults.week_number),\n        day: cn('sprout-calendar-day', defaults.day),\n        range_start: cn('sprout-calendar-range-start', defaults.range_start),\n        range_middle: cn('sprout-calendar-range-middle', defaults.range_middle),\n        range_end: cn('sprout-calendar-range-end', defaults.range_end),\n        today: cn('sprout-calendar-today', defaults.today),\n        outside: cn('sprout-calendar-outside', defaults.outside),\n        disabled: cn('sprout-calendar-disabled', defaults.disabled),\n        hidden: cn('sprout-calendar-hidden', defaults.hidden),\n        ...classNames,\n      }}\n      components={{\n        Root: CalendarRoot,\n        Chevron: CalendarChevron,\n        Dropdown: CalendarDropdown,\n        DayButton: CalendarDayButton,\n        WeekNumber: CalendarWeekNumber,\n        ...components,\n      }}\n      {...props}\n    />\n  );\n}\n\nexport type CalendarDayButtonProps = DayButtonProps & {\n  locale?: DayPickerLocale;\n};\n\nexport function CalendarDayButton({ className, day, modifiers, locale, ...props }: CalendarDayButtonProps) {\n  const calendarLocale = useDayPicker().dayPickerProps.locale;\n  const ref = useRef<HTMLButtonElement>(null);\n  useEffect(() => {\n    if (modifiers.focused) ref.current?.focus();\n  }, [modifiers.focused]);\n  const range = modifiers.range_start || modifiers.range_end || modifiers.range_middle;\n  return (\n    <Button\n      ref={ref}\n      variant=\"ghost\"\n      size=\"icon\"\n      data-slot=\"calendar-day-button\"\n      data-day={day.date.toLocaleDateString((locale ?? calendarLocale)?.code)}\n      data-selected-single={Boolean(modifiers.selected && !range)}\n      data-range-start={Boolean(modifiers.range_start)}\n      data-range-end={Boolean(modifiers.range_end)}\n      data-range-middle={Boolean(modifiers.range_middle)}\n      className={cn('sprout-calendar-day-button', getDefaultClassNames().day_button, className)}\n      {...(props as ComponentProps<typeof Button>)}\n    />\n  );\n}\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/chevron-down-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/chevron-down-icon.tsx",
      "content": "import { ArrowDown01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const ChevronDownIcon = /* @__PURE__ */ createIcon(glyph, 'ChevronDownIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/chevron-left-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/chevron-left-icon.tsx",
      "content": "import { ArrowLeft01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const ChevronLeftIcon = /* @__PURE__ */ createIcon(glyph, 'ChevronLeftIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/chevron-right-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/chevron-right-icon.tsx",
      "content": "import { ArrowRight01Icon as glyph } from '@hugeicons/core-free-icons';\nimport { createIcon } from '@/lib/sprout/icons/create-icon';\n\nexport const ChevronRightIcon = /* @__PURE__ */ createIcon(glyph, 'ChevronRightIcon');\n"
    },
    {
      "path": "registry/sprout/lib/sprout/icons/create-icon.tsx",
      "type": "registry:lib",
      "target": "lib/sprout/icons/create-icon.tsx",
      "content": "import { HugeiconsIcon, type IconSvgElement } from '@hugeicons/react';\nimport type { ReactElement, Ref, SVGProps } from 'react';\n\nexport const iconSizes = {\n  xs: 12,\n  sm: 14,\n  md: 16,\n  lg: 18,\n  xl: 20,\n  '2xl': 24,\n} as const;\n\nexport type IconSize = keyof typeof iconSizes;\n\nexport const iconStrokeWidth = 1.5;\n\nexport type IconProps = Omit<SVGProps<SVGSVGElement>, 'ref'> & {\n  size?: IconSize | number;\n  ref?: Ref<SVGSVGElement>;\n};\n\nexport type IconComponent = (props: IconProps) => ReactElement;\n\nexport function createIcon(glyph: IconSvgElement, name: string): IconComponent {\n  const Icon = ({ size = '2xl', strokeWidth = iconStrokeWidth, ...props }: IconProps) => (\n    <HugeiconsIcon\n      icon={glyph}\n      size={typeof size === 'number' ? size : iconSizes[size]}\n      strokeWidth={Number(strokeWidth)}\n      {...props}\n    />\n  );\n  Icon.displayName = name;\n  return Icon;\n}\n"
    }
  ],
  "css": {
    "@layer components": {
      ".sprout-calendar": {
        "--sprout-calendar-cell": "1.75rem",
        "--sprout-calendar-radius": "min(var(--sprout-radius-control), .5rem)",
        "--sprout-calendar-band": "var(--sprout-hover)",
        "box-sizing": "border-box",
        "border-radius": "var(--sprout-radius-panel)",
        "background": "var(--sprout-surface)",
        "width": "fit-content",
        "color": "var(--sprout-text)",
        "font-family": "var(--sprout-font)",
        "font-size": "var(--sprout-text-sm)",
        "padding": "8px",
        "line-height": "1.25rem"
      },
      "[data-slot=\"popover-content\"] > .sprout-calendar": {
        "background": "none",
        "width": "100%",
        "padding": "0"
      },
      "[data-slot=\"card-content\"] .sprout-calendar": {
        "background": "none"
      },
      ".sprout-calendar-months": {
        "flex-direction": "column",
        "gap": "16px",
        "display": "flex",
        "position": "relative"
      },
      "@media (width >= 768px)": {
        ".sprout-calendar-months": {
          "flex-direction": "row"
        }
      },
      ".sprout-calendar-month": {
        "flex-direction": "column",
        "flex": "1 1 0",
        "gap": "12px",
        "width": "100%",
        "min-width": "0",
        "display": "flex"
      },
      ".sprout-calendar-nav": {
        "inset-inline": "0",
        "z-index": "1",
        "pointer-events": "none",
        "justify-content": "space-between",
        "align-items": "center",
        "gap": "4px",
        "display": "flex",
        "position": "absolute",
        "top": "0"
      },
      ".sprout-calendar-nav-button": {
        "width": "var(--sprout-calendar-cell)",
        "height": "var(--sprout-calendar-cell)",
        "border-radius": "var(--sprout-calendar-radius)",
        "pointer-events": "auto",
        "padding": "0"
      },
      ".sprout-calendar-nav-button[aria-disabled=\"true\"]": {
        "pointer-events": "none",
        "opacity": ".5"
      },
      ".sprout-calendar-chevron": {
        "width": "1rem",
        "height": "1rem"
      },
      ".sprout-calendar:dir(rtl):not([dir]) .sprout-calendar-nav-button .sprout-calendar-chevron": {
        "transform": "rotate(180deg)"
      },
      ".sprout-calendar-caption": {
        "height": "var(--sprout-calendar-cell)",
        "padding-inline": "var(--sprout-calendar-cell)",
        "justify-content": "center",
        "align-items": "center",
        "display": "flex"
      },
      ".sprout-calendar-caption-label": {
        "font-size": "var(--sprout-text-sm)",
        "white-space": "nowrap",
        "user-select": "none",
        "font-weight": "500"
      },
      ".sprout-calendar-dropdowns": {
        "height": "var(--sprout-calendar-cell)",
        "font-size": "var(--sprout-text-sm)",
        "justify-content": "center",
        "align-items": "center",
        "gap": "4px",
        "font-weight": "500",
        "display": "flex"
      },
      ".sprout-calendar-dropdown.sprout-select-trigger": {
        "height": "var(--sprout-calendar-cell)",
        "border-radius": "var(--sprout-calendar-radius)",
        "font-weight": "500"
      },
      ".sprout-calendar-dropdown-content.sprout-select-content": {
        "width": "auto",
        "min-width": "max(var(--anchor-width), 5rem)",
        "max-height": "min(16rem, var(--available-height))"
      },
      ".sprout-calendar-grid": {
        "border-collapse": "collapse",
        "width": "100%",
        "margin": "0"
      },
      ".sprout-calendar-weekdays, .sprout-calendar-week": {
        "width": "100%",
        "display": "flex"
      },
      ".sprout-calendar-week": {
        "margin-top": "4px"
      },
      ".sprout-calendar-weekday": {
        "min-width": "var(--sprout-calendar-cell)",
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-xs)",
        "text-align": "center",
        "user-select": "none",
        "flex": "1 1 0",
        "padding": "0 0 2px",
        "font-weight": "400",
        "line-height": "1rem"
      },
      ".sprout-calendar-week-number-header, .sprout-calendar-week-number": {
        "flex": "0 0 var(--sprout-calendar-cell)",
        "width": "var(--sprout-calendar-cell)",
        "color": "var(--sprout-muted)",
        "font-size": "var(--sprout-text-xs)",
        "user-select": "none",
        "padding": "0",
        "font-weight": "400"
      },
      ".sprout-calendar-week-number-cell": {
        "height": "100%",
        "min-height": "var(--sprout-calendar-cell)",
        "font-variant-numeric": "tabular-nums",
        "justify-content": "center",
        "align-items": "center",
        "display": "flex"
      },
      ".sprout-calendar-day": {
        "min-width": "var(--sprout-calendar-cell)",
        "aspect-ratio": "1",
        "border-radius": "var(--sprout-calendar-radius)",
        "text-align": "center",
        "user-select": "none",
        "flex": "1 1 0",
        "padding": "0",
        "position": "relative"
      },
      ".sprout-calendar-today": {
        "background": "var(--sprout-calendar-band)"
      },
      ".sprout-calendar-today[data-selected]": {
        "border-radius": "0"
      },
      ".sprout-calendar-range-start, .sprout-calendar-range-end": {
        "isolation": "isolate",
        "background": "var(--sprout-calendar-band)"
      },
      ".sprout-calendar-range-start": {
        "border-radius": "var(--sprout-calendar-radius) 0 0 var(--sprout-calendar-radius)"
      },
      ".sprout-calendar-range-end": {
        "border-radius": "0 var(--sprout-calendar-radius) var(--sprout-calendar-radius) 0"
      },
      ".sprout-calendar-range-start.sprout-calendar-range-end": {
        "border-radius": "var(--sprout-calendar-radius)"
      },
      ".sprout-calendar-range-middle": {
        "border-radius": "0"
      },
      ".sprout-calendar:dir(rtl) .sprout-calendar-range-start:not(.sprout-calendar-range-end)": {
        "border-radius": "0 var(--sprout-calendar-radius) var(--sprout-calendar-radius) 0"
      },
      ".sprout-calendar:dir(rtl) .sprout-calendar-range-end:not(.sprout-calendar-range-start)": {
        "border-radius": "var(--sprout-calendar-radius) 0 0 var(--sprout-calendar-radius)"
      },
      ".sprout-calendar-hidden": {
        "visibility": "hidden"
      },
      ".sprout-calendar-day-button.sprout-button": {
        "z-index": "1",
        "width": "100%",
        "height": "100%",
        "min-width": "var(--sprout-calendar-cell)",
        "min-height": "var(--sprout-calendar-cell)",
        "border-radius": "var(--sprout-calendar-radius)",
        "color": "inherit",
        "font-size": "var(--sprout-text-sm)",
        "font-variant-numeric": "tabular-nums",
        "border": "0",
        "flex-direction": "column",
        "gap": "2px",
        "padding": "0",
        "font-weight": "400",
        "line-height": "1",
        "display": "flex",
        "position": "relative"
      },
      ".sprout-calendar-day-button.sprout-button:focus-visible": {
        "z-index": "2",
        "outline-offset": "0"
      },
      ".sprout-calendar-day-button > span": {
        "opacity": ".7",
        "font-size": ".625rem",
        "line-height": ".75rem"
      },
      ".sprout-calendar-outside .sprout-calendar-day-button": {
        "color": "var(--sprout-muted)"
      },
      "@media (hover: hover)": {
        ".sprout-calendar-today .sprout-calendar-day-button:hover": {
          "background": "var(--sprout-active)"
        },
        ".sprout-calendar-day-button[data-range-middle=\"true\"]:hover": {
          "background": "var(--sprout-active)"
        },
        ".sprout-calendar-day-button[data-selected-single=\"true\"]:hover, .sprout-calendar-day-button[data-range-start=\"true\"]:hover, .sprout-calendar-day-button[data-range-end=\"true\"]:hover": {
          "background": "var(--sprout-primary-hover)"
        }
      },
      ".sprout-calendar-day-button[data-range-middle=\"true\"]": {
        "background": "var(--sprout-calendar-band)",
        "color": "var(--sprout-text)",
        "border-radius": "0"
      },
      ".sprout-calendar-day-button[data-selected-single=\"true\"], .sprout-calendar-day-button[data-range-start=\"true\"], .sprout-calendar-day-button[data-range-end=\"true\"]": {
        "background": "var(--sprout-primary)",
        "color": "var(--sprout-on-primary)"
      },
      ".sprout-calendar-day:last-child[data-selected] .sprout-calendar-day-button": {
        "border-start-end-radius": "var(--sprout-calendar-radius)",
        "border-end-end-radius": "var(--sprout-calendar-radius)"
      },
      ".sprout-calendar:not([data-week-numbers]) .sprout-calendar-day:first-child[data-selected] .sprout-calendar-day-button, .sprout-calendar[data-week-numbers] .sprout-calendar-day:nth-child(2)[data-selected] .sprout-calendar-day-button": {
        "border-start-start-radius": "var(--sprout-calendar-radius)",
        "border-end-start-radius": "var(--sprout-calendar-radius)"
      },
      "@media (prefers-reduced-motion: no-preference)": {
        ".sprout-calendar-day-button.sprout-button, .sprout-calendar-nav-button": {
          "transition": "background-color var(--sprout-motion-fast) var(--sprout-motion-ease),\n        color var(--sprout-motion-fast) var(--sprout-motion-ease)"
        }
      },
      "@media (forced-colors: active)": {
        ".sprout-calendar-day-button[data-selected-single=\"true\"], .sprout-calendar-day-button[data-range-start=\"true\"], .sprout-calendar-day-button[data-range-end=\"true\"]": {
          "outline-offset": "-1px",
          "outline": "2px solid highlight"
        },
        ".sprout-calendar-day-button[data-range-middle=\"true\"]": {
          "outline-offset": "-1px",
          "outline": "1px dashed highlight"
        },
        ".sprout-calendar-today .sprout-calendar-day-button": {
          "text-decoration": "underline"
        }
      }
    }
  },
  "docs": "Docs and examples: https://sprout.tulipfarm.ai/components/calendar/",
  "meta": {
    "source": "packages/sprout/src/components/calendar.tsx"
  }
}
