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.22 kB
'use client'; import{b as l}from"./chunk-WABH67VC.mjs";import{useRef as M}from"react";import{CalendarDate as P}from"@internationalized/date";import{useDatePicker as h}from"@react-aria/datepicker";import{mergeProps as o}from"@react-aria/utils";import{useDatePickerState as O}from"@react-stately/datepicker";var j=(s={})=>{let{minValue:t=new P(1900,1,1),maxValue:r=new P(2099,12,31),timeInputProps:p={},dateInputProps:m={},calendarProps:c={},...n}=s,i=M(null),e=O({...n,minValue:t,maxValue:r,shouldCloseOnSelect:()=>!e.hasTime}),{groupProps:g,labelProps:D,fieldProps:d,buttonProps:u,dialogProps:T,calendarProps:y}=h({...n,minValue:t,maxValue:r},e,i),a=e.granularity==="hour"||e.granularity==="minute"||e.granularity==="second"?e.granularity:null,f=!!a,{onPress:G,isDisabled:b,...I}=u,k={...I,onClick:()=>e.toggle(),"data-disabled":l(b)},A={...d,groupProps:g,labelProps:D,granularity:a,label:s.label},V=t&&"hour"in t?t:null,C=r&&"hour"in r?r:null,x=f?{...p,value:e.timeValue,onChange:e.setTimeValue,granularity:a,minValue:V??void 0,maxValue:C??void 0}:{};return{ref:i,state:e,getTriggerProps:k,getAriaTriggerProps:u,getTimeInputProps:o(x,p),getDateInputProps:o(A,m),getCalendarProps:o(y,c),getDialogProps:T}};export{j as a};