UNPKG

react-calendar-kit

Version:

React Calendar Kit is a powerful and flexible library for building accessible and highly customizable calendar and date/time picker components in your React applications. React Calendar Kit provides a solid foundation for creating inclusive user experienc

3 lines (2 loc) 1.72 kB
'use client'; import{a as s}from"./chunk-GU5RBUXK.mjs";import{a as r,b as k,c as y,e as f,f as a}from"./chunk-WABH67VC.mjs";import{b as g}from"./chunk-VMZM6ONT.mjs";import m,{memo as S,useMemo as u,useState as b}from"react";import{useDateFormatter as C}from"@react-aria/i18n";var E=D=>{let{date:o,currentMonth:l,className:v,style:N,...Z}=D,{state:e,isPickerExpanded:c,classNames:t,styles:i}=g(),[h,x]=b(null),p=C({month:"long",era:l.calendar.identifier==="gregory"&&l.era==="BC"?"short":void 0,calendar:l.calendar.identifier,timeZone:e.timeZone}),d=C({year:"numeric",timeZone:e.timeZone}),P=u(()=>y(e.minValue,e.maxValue)?.map(n=>({value:n.year,label:d.format(n.toDate(e.timeZone))})),[e.minValue,e.maxValue,d,e.timeZone]),L=u(()=>f(o).map(n=>({value:n.month,label:p.format(n.toDate(e.timeZone))})),[o,p,e.timeZone]);return m.createElement("div",{...Z,"data-expanded":k(c),className:r(t?.picker?.root,v),style:a({height:"var(--picker-height)"},N,i?.picker?.root),role:"picker-root",inert:c?void 0:"true"},m.createElement("div",{ref:x,className:t?.picker?.highlight,style:i?.picker?.highlight,role:"picker-highlight"}),m.createElement(s,{highlightRef:h,options:L,listClassName:r(t?.picker?.list,t?.picker?.monthList),listStyle:a(i?.picker?.list,i?.picker?.monthList),itemClassName:r(t?.picker?.item,t?.picker?.monthItem),itemStyle:a(i?.picker?.item,i?.picker?.monthItem),initialDate:o.month,listType:"month"}),m.createElement(s,{highlightRef:h,options:P,listClassName:r(t?.picker?.list,t?.picker?.yearList),listStyle:a(i?.picker?.list,i?.picker?.yearList),itemClassName:r(t?.picker?.item,t?.picker?.yearItem),itemStyle:a(i?.picker?.item,i?.picker?.yearItem),initialDate:o.year,listType:"year"}))},F=S(E);export{F as a};