import{r as p,j as c}from"./iframe-p4aYZyoq.js";import{c as V}from"./index-Dx18ixSn.js";import{S as q}from"./times-DeY5Bu0x.js";const u=({children:a,onRemove:e,className:m="",disabled:i,compact:f=!1,onClick:o,onKeyPress:r,innerRef:y,asSpan:h=!1,...v})=>{const n=p.useRef(e);n.current=e;const b=p.useCallback(s=>{var d;s.stopPropagation(),(d=n.current)==null||d.call(n,s)},[]),t={...v};let l="button";(e||h)&&(l="span",(o||r)&&(t.role="button",t.tabIndex=0));const E=l;return c.jsxs(E,{ref:y,className:V("chip",{"chip--disabled":i,"chip--compact":f},m),type:l==="button"?"button":void 0,onKeyPress:r,onClick:o,...t,children:[a,e&&!i&&c.jsx(q,{"data-testid":"remove-icon",onClick:b})]})};try{u.displayName="Chip",u.__docgenInfo={description:"",displayName:"Chip",props:{children:{defaultValue:null,description:"What is displayed within the chip",name:"children",required:!1,type:{name:"ReactNode"}},onRemove:{defaultValue:null,description:"Call back which, if present, will display a remove icon and is fired when this is clicked",name:"onRemove",required:!1,type:{name:"((event: MouseEvent<SVGElement, MouseEvent>) => void)"}},disabled:{defaultValue:null,description:"If true will opacify the chip and prevent the remove from being clickable",name:"disabled",required:!1,type:{name:"boolean"}},className:{defaultValue:{value:""},description:"Additional CSS classnames to apply (eg secondary, tertiary)",name:"className",required:!1,type:{name:"string"}},compact:{defaultValue:{value:"false"},description:"Compact styling for chip",name:"compact",required:!1,type:{name:"boolean"}},onClick:{defaultValue:null,description:"click event listener on the component (except on the close button if present)",name:"onClick",required:!1,type:{name:"((() => void) & MouseEventHandler<HTMLButtonElement | HTMLSpanElement>)"}},onKeyPress:{defaultValue:null,description:"key press event listener on the component\n@deprecated Use `onKeyUp` or `onKeyDown` instead",name:"onKeyPress",required:!1,type:{name:"((() => void) & KeyboardEventHandler<HTMLButtonElement | HTMLSpanElement>)"}},innerRef:{defaultValue:null,description:"",name:"innerRef",required:!1,type:{name:"((node: HTMLElement | null) => void)"}},asSpan:{defaultValue:{value:"false"},description:"",name:"asSpan",required:!1,type:{name:"boolean"}}}}}catch{}try{chip.displayName="chip",chip.__docgenInfo={description:"",displayName:"chip",props:{children:{defaultValue:null,description:"What is displayed within the chip",name:"children",required:!1,type:{name:"ReactNode"}},onRemove:{defaultValue:null,description:"Call back which, if present, will display a remove icon and is fired when this is clicked",name:"onRemove",required:!1,type:{name:"((event: MouseEvent<SVGElement, MouseEvent>) => void)"}},disabled:{defaultValue:null,description:"If true will opacify the chip and prevent the remove from being clickable",name:"disabled",required:!1,type:{name:"boolean"}},className:{defaultValue:{value:""},description:"Additional CSS classnames to apply (eg secondary, tertiary)",name:"className",required:!1,type:{name:"string"}},compact:{defaultValue:{value:"false"},description:"Compact styling for chip",name:"compact",required:!1,type:{name:"boolean"}},onClick:{defaultValue:null,description:"click event listener on the component (except on the close button if present)",name:"onClick",required:!1,type:{name:"((() => void) & MouseEventHandler<HTMLButtonElement | HTMLSpanElement>)"}},onKeyPress:{defaultValue:null,description:"key press event listener on the component\n@deprecated Use `onKeyUp` or `onKeyDown` instead",name:"onKeyPress",required:!1,type:{name:"((() => void) & KeyboardEventHandler<HTMLButtonElement | HTMLSpanElement>)"}},innerRef:{defaultValue:null,description:"",name:"innerRef",required:!1,type:{name:"((node: HTMLElement | null) => void)"}},asSpan:{defaultValue:{value:"false"},description:"",name:"asSpan",required:!1,type:{name:"boolean"}}}}}catch{}export{u as C};
