UNPKG

@accelint/design-toolkit

Version:

An open-source component library to serve as part of the entire ecosystem of UX for Accelint.

4 lines (3 loc) 1.63 kB
'use client'; import {jsx,jsxs,Fragment}from'react/jsx-runtime';import'client-only';import {Time}from'@accelint/icons';import {TimeField,composeRenderProps,DateInput,DateSegment,Text,FieldError}from'react-aria-components';import {Icon}from'../icon/index.js';import {Label}from'../label/index.js';import {TimeFieldStyles}from'./styles.js';const{field:R,label:c,control:V,input:Z,description:k,error:q,segment:C}=TimeFieldStyles();function P({classNames:i,description:s,errorMessage:T,granularity:f="second",hourCycle:F=24,inputProps:b,label:m,shouldForceLeadingZeros:g=true,size:t="medium",isDisabled:y,isInvalid:n,isRequired:d,...A}){const l=T||null,p=t==="small";return jsx(TimeField,{...A,className:composeRenderProps(i?.field,o=>R({className:o})),granularity:f,hourCycle:F,shouldForceLeadingZeros:g,isDisabled:y,isInvalid:n||(l?true:void 0),isRequired:d,"aria-label":m,"data-size":t,children:({isDisabled:o})=>jsxs(Fragment,{children:[!p&&c&&jsx(Label,{className:c({className:i?.label}),isDisabled:o,isRequired:d,children:m}),jsxs("div",{className:V({className:i?.control}),children:[t==="medium"&&jsx(Icon,{children:jsx(Time,{})}),jsx(DateInput,{...b,className:composeRenderProps(i?.input,r=>Z({className:r})),children:r=>jsx(DateSegment,{segment:r,className:composeRenderProps(i?.segment,D=>C({className:D}))})}),jsx("span",{children:"Z"})]}),s&&!(p||n)&&!l&&jsx(Text,{className:k({className:i?.description}),slot:"description",children:s}),jsx(FieldError,{className:composeRenderProps(i?.error,r=>q({className:r})),children:l})]})})}export{P as TimeField};//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map