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.88 kB
'use client'; import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {ChevronDown}from'@accelint/icons';import'client-only';import {useContextProps,ComboBox,composeRenderProps,Input,Button,Text,FieldError,Popover,Virtualizer,ListLayout}from'react-aria-components';import {Icon}from'../icon/index.js';import {Label}from'../label/index.js';import {Options}from'../options/index.js';import {ComboBoxFieldContext}from'./context.js';import {ComboBoxStyles}from'./styles.js';const{field:k,label:q,control:w,input:A,trigger:G,description:H,error:J,popover:K}=ComboBoxStyles();function oo({ref:t,...i}){[i,t]=useContextProps(i,t??null,ComboBoxFieldContext);const{children:u,classNames:e,description:a,errorMessage:b,inputProps:f,label:n,layoutOptions:v,menuTrigger:x="focus",size:m="medium",isInvalid:N,...g}=i,p=b||null,c=m==="small";return jsx(ComboBox,{...g,ref:t,className:composeRenderProps(e?.field,l=>k({className:l})),menuTrigger:x,isInvalid:N||(p?true:void 0),"data-size":m,children:({isDisabled:l,isInvalid:P,isRequired:C})=>jsxs(Fragment,{children:[!!n&&!c&&jsx(Label,{className:q({className:e?.label}),isDisabled:l,isRequired:C,children:n}),jsxs("div",{className:w({className:e?.control}),children:[jsx(Input,{...f,className:composeRenderProps(e?.input,r=>A({className:r}))}),jsx(Button,{className:composeRenderProps(e?.trigger,r=>G({className:r})),children:jsx(Icon,{size:"small",children:jsx(ChevronDown,{})})})]}),!!a&&!(c||P)&&jsx(Text,{className:H({className:e?.description}),slot:"description",children:a}),jsx(FieldError,{className:composeRenderProps(e?.error,r=>J({className:r})),children:p}),jsx(Popover,{className:composeRenderProps(e?.popover,r=>K({className:r})),children:jsx(Virtualizer,{layout:ListLayout,layoutOptions:v,children:jsx(Options,{children:u})})})]})})}export{oo as ComboBoxField};//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map