UNPKG

@guruhotel/aura-ui

Version:

⚛️ React UI library by GuruHotel

1 lines 1.17 kB
import r from"react";import{useCalendarGrid as e}from"@react-aria/calendar";import{getWeeksInMonth as a,endOfMonth as t}from"@internationalized/date";import{useLocale as o}from"@react-aria/i18n";import{CalendarCell as i}from"./calendar-cell";import{Table as n,THead as s,Tr as c,Th as d,Td as m,TBody as l}from"./calendar.styles";import{useCalendarProps as p}from"./calendar-props.provider";import{jsx as f}from"react/jsx-runtime";import{jsxs as h}from"react/jsx-runtime";export function CalendarGrid({state:r,offset:y={}}){const{tooltip:D}=p(),{locale:$}=o(),u=r.visibleRange.start.add(y),x=t(u),{gridProps:g,headerProps:b,weekDays:j}=e({startDate:u,endDate:x},r),k=a(u,$),P=Array.from(Array(k).keys());let v;if(r.anchorDate&&D){const e=r.anchorDate,a=r.focusedDate;v=Math.abs(e.compare(a)),v++}return h(n,{...g,cellPadding:"0",children:[f(s,{...b,children:f(c,{children:j.map(((r,e)=>f(d,{css:{py:"$2",fontWeight:400,pb:"$2",borderBottom:"1px solid $gray5",fontSize:"$xs"},children:r},`${r}-${e}`)))})}),f(l,{children:P.map((e=>f(c,{children:r.getDatesInWeek(e,u).map(((e,a)=>e?f(i,{state:r,date:e,currentMonth:u,numberOfDays:v},`${e.day}-${a}`):f(m,{},a)))},e)))})]})}