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.62 kB
'use client'; import {jsx,jsxs,Fragment}from'react/jsx-runtime';import'client-only';import {Remove,Check}from'@accelint/icons';import {createContext}from'react';import {useContextProps,Checkbox,composeRenderProps,CheckboxGroup}from'react-aria-components';import {Icon}from'../icon/index.js';import {Label}from'../label/index.js';import {CheckboxStyles}from'./styles.js';const {group:A,groupLabel:g,checkbox:v,control:R,label:V}=CheckboxStyles(),D=createContext(null);function i({ref:o,...e}){[e,o]=useContextProps(e,o??null,D);const{children:t,classNames:c,label:l,orientation:r="vertical",...p}=e;return jsx(CheckboxGroup,{...p,ref:o,className:composeRenderProps(c?.group,s=>A({className:s})),"data-orientation":r,children:composeRenderProps(t,(s,{isDisabled:h,isRequired:k})=>jsxs(Fragment,{children:[l&&jsx(Label,{className:g({className:c?.label}),isDisabled:h,isRequired:k,children:l}),s]}))})}i.displayName="Checkbox.Group";const E=createContext(null);function C({ref:o,...e}){[e,o]=useContextProps(e,o??null,E);const{classNames:t,children:c,...l}=e;return jsx(Checkbox,{...l,ref:o,className:composeRenderProps(t?.checkbox,r=>v({className:r})),children:composeRenderProps(c,(r,{isIndeterminate:p,isSelected:s})=>jsxs(Fragment,{children:[jsx("span",{className:R({className:t?.control}),children:jsxs(Icon,{size:"small",children:[p&&!s&&jsx(Remove,{}),s&&jsx(Check,{})]})}),r&&jsx("span",{className:V({className:t?.label}),children:r})]}))})}C.displayName="Checkbox",C.Group=i;export{C as Checkbox,E as CheckboxContext,D as CheckboxGroupContext};//# sourceMappingURL=index.js.map //# sourceMappingURL=index.js.map