@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.2 kB
JavaScript
'use client';
import {jsx,jsxs,Fragment}from'react/jsx-runtime';import'client-only';import {CancelFill}from'@accelint/icons';import {useContextProps,Tag,composeRenderProps}from'react-aria-components';import {Button}from'../button/index.js';import {Icon}from'../icon/index.js';import {ChipContext}from'./context.js';import {DeletableChipStyles}from'./styles.js';const{chip:y,remove:z}=DeletableChipStyles();function R({ref:o,...i}){[i,o]=useContextProps(i,o??null,ChipContext);const{children:r,classNames:s,size:e="medium",textValue:n=typeof r=="string"?r:void 0,...m}=i,p=e==="small"?"xsmall":"small";return jsx(Tag,{...m,ref:o,className:composeRenderProps(s?.chip,a=>y({className:a,size:e})),textValue:n,"data-size":e,children:composeRenderProps(r,(a,{allowsRemoving:c})=>{if(!c)throw new Error("You have a <DeletableChip> in a <ChipList> that does not specify an onRemove handler.");return jsxs(Fragment,{children:[a,jsx(Button,{variant:"icon",size:e,slot:"remove",className:composeRenderProps(s?.remove,h=>z({className:h})),children:jsx(Icon,{size:p,children:jsx(CancelFill,{})})})]})})})}export{R as DeletableChip};//# sourceMappingURL=deletable.js.map
//# sourceMappingURL=deletable.js.map