UNPKG

@guruhotel/aura-ui

Version:

⚛️ React UI library by GuruHotel

1 lines 950 B
import e,{useRef as r}from"react";import{createCalendar as t}from"@internationalized/date";import{useLocale as o}from"@react-aria/i18n";import{useDateFieldState as a}from"@react-stately/datepicker";import{useDateField as i}from"@react-aria/datepicker";import{DateSegment as m}from"./date-segment";import{DateFieldElements as s}from"./date-field.styles";import{VisuallyHidden as l}from"../visually-hidden";import{Fragment as d}from"react/jsx-runtime";import{jsx as n}from"react/jsx-runtime";import{jsxs as c}from"react/jsx-runtime";function f({colorScheme:e="guru",size:f="md",rounded:p="md",...u}){if(!u.label)throw new Error("DateField must have a label for accessibility");const{locale:h}=o(),x=a({...u,locale:h,createCalendar:t}),g=r(),{labelProps:j,fieldProps:b}=i(u,x,g);return c(d,{children:[n(l,{...j}),n(s,{...b,ref:g,colorScheme:e,size:f,rounded:p,children:x.segments.map(((e,r)=>n(m,{segment:e,state:x,rounded:p},r)))})]})}export default f;