{"version":3,"file":"TruncatingText.GKnBas8S.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/LekjJfddy7Emp9IJKbcV/2wHBxmtJcJzXV80A6oN4/TruncatingText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useRef,useEffect}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerDisableUnlink\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight auto\n */export default function TruncatedText(props){const{text,maxLines,expandable,style,font,buttonStuff,transition,elementType,buttonAlignment,showActionButtons,mainTextColors={}}=props;const[expanded,setExpanded]=useState(false);const{useMultiColor=true,color=\"#FFFFFFD5\",expandedColor=\"#ffffff\"}=mainTextColors;const resolvedColor=useMultiColor&&expandable&&expanded?expandedColor:color;const resolvedCollapsedColor=useMultiColor?color:resolvedColor;const wrapperRef=useRef(null);const fullTextRef=useRef(null);const truncatedTextRef=useRef(null);const[heights,setHeights]=useState({truncated:0,full:0});const[showTruncated,setShowTruncated]=useState(true);const[currentHeight,setCurrentHeight]=useState(0);const[isAnimating,setIsAnimating]=useState(false);useEffect(()=>{if(fullTextRef.current&&truncatedTextRef.current){const full=fullTextRef.current.offsetHeight;const truncated=truncatedTextRef.current.offsetHeight;setHeights({full,truncated});setCurrentHeight(truncated);}},[text,font,maxLines]);useEffect(()=>{if(expanded){setShowTruncated(false);setCurrentHeight(heights.full);}else{setIsAnimating(true);setCurrentHeight(heights.truncated);setTimeout(()=>{setShowTruncated(true);setIsAnimating(false);},transition.duration*1e3);}},[expanded,heights,transition.duration]);const handleClick=()=>{if(!expandable)return;setExpanded(prev=>!prev);};const getTruncatedStyle=()=>{return{overflow:\"hidden\",display:\"-webkit-box\",WebkitLineClamp:maxLines,WebkitBoxOrient:\"vertical\"};};const getActionButtonStyle=()=>{const baseStyle={marginTop:`${buttonStuff.actionButtonsGap}px`,cursor:\"pointer\"};const buttonFont=buttonStuff.font&&Object.keys(buttonStuff.font).length>0?buttonStuff.font:font;return{...baseStyle,...buttonFont};};const TextElement=elementType||\"p\";const MotionTextElement=motion(TextElement);return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",...style},children:[/*#__PURE__*/_jsx(\"div\",{ref:fullTextRef,style:{position:\"absolute\",visibility:\"hidden\",pointerEvents:\"none\",opacity:0,...font},children:/*#__PURE__*/_jsx(TextElement,{style:{margin:0},children:text})}),/*#__PURE__*/_jsx(\"div\",{ref:truncatedTextRef,style:{position:\"absolute\",visibility:\"hidden\",pointerEvents:\"none\",opacity:0,...font,...getTruncatedStyle()},children:/*#__PURE__*/_jsx(TextElement,{style:{margin:0},children:text})}),/*#__PURE__*/_jsx(motion.div,{animate:{height:currentHeight},transition:transition,style:{overflow:\"hidden\"},ref:wrapperRef,children:/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\"},children:showTruncated?/*#__PURE__*/_jsx(TextElement,{style:{...getTruncatedStyle(),color:resolvedCollapsedColor,...font,cursor:expandable?\"pointer\":\"auto\",margin:0,position:\"relative\",zIndex:2,opacity:1},onClick:expandable?handleClick:undefined,children:parseSimpleMarkdown(text)}):/*#__PURE__*/_jsx(motion.div,{initial:{opacity:1,color:resolvedCollapsedColor},animate:{opacity:1,color:resolvedColor},transition:transition,style:{position:\"relative\",zIndex:1},children:/*#__PURE__*/_jsx(TextElement,{style:{...font,cursor:expandable?\"pointer\":\"auto\",margin:0},onClick:expandable?handleClick:undefined,children:parseSimpleMarkdown(text)})})})}),expandable&&showActionButtons&&/*#__PURE__*/_jsx(motion.div,{style:{display:\"flex\",justifyContent:buttonStuff.buttonAlignment===\"center\"?\"center\":buttonStuff.buttonAlignment===\"right\"?\"flex-end\":\"flex-start\"},children:/*#__PURE__*/_jsx(motion.div,{style:getActionButtonStyle(),onClick:handleClick,initial:{color:expanded?buttonStuff.showLessButton.collapseColor||resolvedColor:buttonStuff.showMoreButton.color||resolvedCollapsedColor},animate:{color:expanded?buttonStuff.showLessButton.collapseColor||resolvedColor:buttonStuff.showMoreButton.color||resolvedCollapsedColor},transition:transition,children:expanded?buttonStuff.showLessButton.collapseLabelText:buttonStuff.showMoreButton.expandLabelText})})]});}TruncatedText.displayName=\"Smart Truncate\";// Keep the same property controls\naddPropertyControls(TruncatedText,{expandable:{type:ControlType.Boolean,title:\"Expandable\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\"},text:{type:ControlType.String,title:\"Text\",defaultValue:\"Great UX is invisible, but behind the scenes, every detail matters. This text block supports truncation with smooth transitions and can be expanded to reveal more insights when needed. Ideal for previews, FAQs, or content teasers.\",displayTextArea:true,description:\"Supports `***bold***`, `_italic_`, and `\\\\n` for line breaks.\"},maxLines:{type:ControlType.Number,title:\"Max Lines\",defaultValue:2,min:1,max:10,step:1},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",displayFontSize:true,displayTextAlignment:true,defaultValue:{fontSize:16,lineHeight:1.4}},mainTextColors:{type:ControlType.Object,title:\"Text Color\",icon:\"color\",buttonTitle:\"Style\",controls:{useMultiColor:{type:ControlType.Boolean,title:\"Text Color\",defaultValue:false,enabledTitle:\"Multi\",disabledTitle:\"Single\"},color:{type:ControlType.Color,title:\"Default Color\",defaultValue:\"#FFFFFFD5\"},expandedColor:{type:ControlType.Color,title:\"Expanded Color\",defaultValue:\"#ffffff\",description:\"Apply secondary color on expansion \\n\\nOnly works when Expandable\",hidden:props=>!props.useMultiColor}}},transition:{type:ControlType.Transition,title:\"Transition\",defaultValue:{type:\"tween\",duration:.4,ease:\"easeOut\"},description:\"You can always set this to Instant for no transition\",hidden:props=>!props.expandable},showActionButtons:{type:ControlType.Boolean,title:\"Button\",defaultValue:true,enabledTitle:\"Yes\",disabledTitle:\"No\",hidden:props=>!props.expandable},buttonStuff:{type:ControlType.Object,title:\"Options\",icon:\"boolean\",buttonTitle:\"Button\",controls:{font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",optional:true,description:\"Leave empty to match text font\"},showMoreButton:{type:ControlType.Object,title:\"See More\",controls:{expandLabelText:{type:ControlType.String,title:\"Label\",defaultValue:\"See more\",displayFontSize:true,displayTextAlignment:true},color:{type:ControlType.Color,title:\"Color\",optional:true,description:\"Leave empty to match text color\"}}},showLessButton:{type:ControlType.Object,title:\"See Less\",controls:{collapseLabelText:{type:ControlType.String,title:\"Label\",defaultValue:\"See less\",displayFontSize:true,displayTextAlignment:true},collapseColor:{type:ControlType.Color,title:\"Color\",optional:true,description:\"Leave empty to match text color\"}}},actionButtonsGap:{type:ControlType.Number,title:\"Gap\",defaultValue:8,min:0,max:40,step:1,unit:\"px\"},buttonAlignment:{type:ControlType.Enum,title:\"Button Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],displaySegmentedControl:true,defaultValue:\"left\"}},hidden:props=>!props.expandable||!props.showActionButtons},elementType:{type:ControlType.Enum,title:\"Tag\",options:[\"p\",\"span\"],optionTitles:[\"P\",\"Span\"],defaultValue:\"p\",displaySegmentedControl:true,description:\"Component by [elvar.supply](https://elvar.surf/go/components).\"}});function parseSimpleMarkdown(text){const parts=text.split(/(\\*\\*.*?\\*\\*|_.*?_|\\\\n)/g);return parts.map((part,i)=>{if(part.startsWith(\"**\")&&part.endsWith(\"**\")){return /*#__PURE__*/_jsx(\"strong\",{children:part.slice(2,-2)},i);}if(part.startsWith(\"_\")&&part.endsWith(\"_\")){return /*#__PURE__*/_jsx(\"em\",{children:part.slice(1,-1)},i);}if(part===\"\\\\n\"){return /*#__PURE__*/_jsx(\"br\",{},i);}return /*#__PURE__*/_jsx(\"span\",{children:part},i);});}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TruncatedText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerDisableUnlink\":\"* @framerSupportedLayoutWidth any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//#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