import{useRef as t,useEffect as r}from"react";import e from"prop-types";import{getTruncatedText as n}from"./utils.js";import{jsx as a}from"react/jsx-runtime";function i(e){var i=e.children,o=e.truncatedText,u=e.separator,l=e.maxWidth,d=e.onTruncate,c=t();return r((function(){var t=c.current,r=t.scrollWidth,e=t.innerText;d(r>l?n({maxWidth:l,separator:u,text:i,currentWidth:r,textLength:null==e?void 0:e.length}):null)}),[i]),a("div",{ref:c,children:o||i})}i.propTypes={children:e.oneOfType([e.node,e.string]).isRequired,truncatedText:e.string,onTruncate:e.func,separator:e.string,maxWidth:e.number},i.defaultProps={onTruncate:null,truncatedText:null,separator:" ... ",maxWidth:null};export{i as default};
