{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"shadcn-studio/calendar-23","type":"registry:component","title":"Calendar 23","description":"Range calendar with preset date range shortcuts (Last week, month, year, etc.)","registryDependencies":["button","calendar","card"],"files":[{"path":"src/registry/new-york/components/calendar/calendar-23.tsx","content":"'use client'\n\nimport { useState } from 'react'\n\nimport {\n  endOfMonth,\n  endOfYear,\n  startOfMonth,\n  startOfYear,\n  subDays,\n  subMonths,\n  subYears,\n  addDays,\n  addMonths\n} from 'date-fns'\nimport type { DateRange } from 'react-day-picker'\n\nimport { Button } from '@/registry/new-york/ui/button'\nimport { Calendar } from '@/registry/new-york/ui/calendar'\nimport { Card, CardContent, CardFooter } from '@/registry/new-york/ui/card'\n\nconst CalendarWithRangePresetsDemo = () => {\n  const today = new Date()\n\n  const yesterday = {\n    from: subDays(today, 1),\n    to: subDays(today, 1)\n  }\n\n  const tomorrow = {\n    from: today,\n    to: addDays(today, 1)\n  }\n\n  const last7Days = {\n    from: subDays(today, 6),\n    to: today\n  }\n\n  const next7Days = {\n    from: addDays(today, 1),\n    to: addDays(today, 7)\n  }\n\n  const last30Days = {\n    from: subDays(today, 29),\n    to: today\n  }\n\n  const monthToDate = {\n    from: startOfMonth(today),\n    to: today\n  }\n\n  const lastMonth = {\n    from: startOfMonth(subMonths(today, 1)),\n    to: endOfMonth(subMonths(today, 1))\n  }\n\n  const nextMonth = {\n    from: startOfMonth(addMonths(today, 1)),\n    to: endOfMonth(addMonths(today, 1))\n  }\n\n  const yearToDate = {\n    from: startOfYear(today),\n    to: today\n  }\n\n  const lastYear = {\n    from: startOfYear(subYears(today, 1)),\n    to: endOfYear(subYears(today, 1))\n  }\n\n  const [month, setMonth] = useState(today)\n  const [date, setDate] = useState<DateRange | undefined>(last7Days)\n\n  return (\n    <div>\n      <Card className='max-w-xs py-4'>\n        <CardContent className='px-4'>\n          <Calendar\n            mode='range'\n            selected={date}\n            onSelect={newDate => {\n              if (newDate) {\n                setDate(newDate)\n              }\n            }}\n            month={month}\n            onMonthChange={setMonth}\n            className='w-full bg-transparent p-0'\n          />\n        </CardContent>\n        <CardFooter className='flex flex-wrap gap-2 border-t px-4 !pt-4'>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate({\n                from: today,\n                to: today\n              })\n              setMonth(today)\n            }}\n          >\n            Today\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(yesterday)\n              setMonth(yesterday.to)\n            }}\n          >\n            Yesterday\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(tomorrow)\n              setMonth(tomorrow.to)\n            }}\n          >\n            Tomorrow\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(last7Days)\n              setMonth(last7Days.to)\n            }}\n          >\n            Last 7 days\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(next7Days)\n              setMonth(next7Days.to)\n            }}\n          >\n            Next 7 days\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(last30Days)\n              setMonth(last30Days.to)\n            }}\n          >\n            Last 30 days\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(monthToDate)\n              setMonth(monthToDate.to)\n            }}\n          >\n            Month to date\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(lastMonth)\n              setMonth(lastMonth.to)\n            }}\n          >\n            Last month\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(nextMonth)\n              setMonth(nextMonth.to)\n            }}\n          >\n            Next month\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(yearToDate)\n              setMonth(yearToDate.to)\n            }}\n          >\n            Year to date\n          </Button>\n          <Button\n            variant='outline'\n            size='sm'\n            onClick={() => {\n              setDate(lastYear)\n              setMonth(lastYear.to)\n            }}\n          >\n            Last year\n          </Button>\n        </CardFooter>\n      </Card>\n      <p className='text-muted-foreground mt-4 text-center text-xs' role='region'>\n        Range calendar with presets\n      </p>\n    </div>\n  )\n}\n\nexport default CalendarWithRangePresetsDemo\n","type":"registry:component","target":"components/shadcn-studio/calendar/calendar-23.tsx"}]}