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.55 kB
'use client'; import{b as c}from"./chunk-WABH67VC.mjs";import{useRef as M}from"react";import{CalendarDate as D}from"@internationalized/date";import{useDateRangePicker as O}from"@react-aria/datepicker";import{mergeProps as n}from"@react-aria/utils";import{useDateRangePickerState as v}from"@react-stately/datepicker";var L=(p={})=>{let{minValue:t=new D(1900,1,1),maxValue:r=new D(2099,12,31),timeInputProps:o={},dateInputProps:i={},calendarProps:T={},...l}=p,u=M(null),e=v({...l,minValue:t,maxValue:r,shouldCloseOnSelect:()=>!e.hasTime}),{groupProps:R,labelProps:y,startFieldProps:f,endFieldProps:b,buttonProps:P,dialogProps:I,calendarProps:k}=O({...l,minValue:t,maxValue:r},e,u),a=e.granularity==="hour"||e.granularity==="minute"||e.granularity==="second"?e.granularity:null,g=!!a,{onPress:A,isDisabled:C,...V}=P,F={...V,onClick:()=>e.toggle(),onPress:A,"data-disabled":c(C)},S={...f,granularity:a},E={...b,granularity:a},m=t&&"hour"in t?t:null,d=r&&"hour"in r?r:null,h=g?{...o,value:e.timeRange?.start||null,onChange:s=>e.setTime("start",s),granularity:a,minValue:m??void 0,maxValue:d??void 0}:{},x=g?{...o,value:e.timeRange?.end||null,onChange:s=>e.setTime("end",s),granularity:a,minValue:m??void 0,maxValue:d??void 0}:{};return{ref:u,state:e,getTriggerProps:F,getAriaTriggerProps:P,getDateRangeProps:{state:e,label:p.label,groupProps:R,labelProps:y,getStartDateFieldProps:n(S,o),getEndDateFieldProps:n(E,o)},getTimeInputRangeProps:{getEndTimeInputProps:n(x,i),getStartTimeInputProps:n(h,i)},getCalendarProps:n(k,T),getDialogProps:I}};export{L as a};