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.86 kB
'use client'; import {jsx,jsxs,Fragment}from'react/jsx-runtime';import I from'@accelint/icons/chevron-down';import'client-only';import {useContextProps,Select,composeRenderProps,SelectValue,Text,FieldError,Popover,Virtualizer,ListLayout}from'react-aria-components';import {Button}from'../button/index.js';import {Icon}from'../icon/index.js';import {Label}from'../label/index.js';import {Options}from'../options/index.js';import {SelectFieldContext}from'./context.js';import {SelectFieldStyles}from'./styles.js';const{description:T,error:q,trigger:k,label:G,field:H,value:J,popover:K}=SelectFieldStyles();function oe({ref:l,...t}){[t,l]=useContextProps(t,l??null,SelectFieldContext);const{size:i="medium",children:u,classNames:r,description:c,errorMessage:f,label:n,layoutOptions:v,isInvalid:N,...S}=t,m=f?.trim()??null,P=N??!!m,p=i==="small",b=!p&&!!n;return jsx(Select,{...S,ref:l,className:composeRenderProps(r?.field,a=>H({className:a})),isInvalid:P,"data-size":i,children:composeRenderProps(u,(a,{isRequired:g,isDisabled:y,isInvalid:F})=>jsxs(Fragment,{children:[b&&jsx(Label,{className:G({className:r?.label}),isRequired:g,isDisabled:y,children:n}),jsxs(Button,{className:composeRenderProps(r?.trigger,o=>k({className:o})),variant:"outline",size:i,children:[jsx(SelectValue,{className:J({className:r?.value})}),jsx(Icon,{children:jsx(I,{className:"transform group-open/select-field:rotate-180"})})]}),!!c&&!(p||F)&&jsx(Text,{className:T({className:r?.description}),slot:"description",children:c}),jsx(FieldError,{className:composeRenderProps(r?.error,o=>q({className:o})),children:m}),jsx(Popover,{className:composeRenderProps(r?.popover,o=>K({className:o})),children:jsx(Virtualizer,{layout:ListLayout,layoutOptions:v,children:jsx(Options,{children:a})})})]}))})}export{oe as SelectField};//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map