UNPKG

@guruhotel/aura-ui

Version:

⚛️ React UI library by GuruHotel

1 lines 1.46 kB
import t from"react";import{useDateFormatter as e}from"@react-aria/i18n";import{CalendarButton as r}from"./button";import{ChevronLeftRegular as o,ChevronRightRegular as i}from"../icons";import{Text as a}from"../text";import{VisuallyHidden as n}from"../visually-hidden";import{Stack as m}from"../stack";import{HeaderTitle as s}from"./calendar.styles";import{capitalizeFirstLetter as l}from"./utils";import{MonthSelector as c,YearSelector as d}from"./calendar-selectors";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 CalendarHeader({state:t,index:u,calendarProps:x,prevButtonProps:b,nextButtonProps:g,prevIcon:v,nextIcon:j}){const{as:y,monthDateFormat:I,withSelectors:Z}=p(),D=e({month:I.month,year:I.year,timeZone:t.timeZone}),P=D.format(t.visibleRange.start.add({months:u}).toDate(t.timeZone)),B=D.format(t.visibleRange.start.add({months:u+1}).toDate(t.timeZone));return h(m,{css:{alignItems:"center",pb:"$4"},children:[f(n,{children:f(a,{as:"h2",children:x["aria-label"]})}),"infinite"!==y&&f(r,{...b,children:v||f(o,{label:"left"})}),Z?h(m,{css:{gap:"$2",flex:"1 1 0%",alignItems:"center",justifyContent:"center"},children:[f(c,{state:t}),f(d,{state:t})]}):f(s,{"aria-hidden":!0,as:"h2",children:l(P)}),"double"===y&&f(s,{"aria-hidden":!0,as:"h2",css:{marginLeft:"10%"},children:l(B)}),"infinite"!==y&&f(r,{...g,children:j||f(i,{label:"right"})})]})}