{"version":3,"file":"Expandable_Text.Cqu2jixK.mjs","names":["useState","useRef","React"],"sources":["https:/framerusercontent.com/modules/90GhJBh2GAfTK8Pwd3eE/ytyHrQhwWKPzN7FUVSor/Expandable_Text.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import React,{useState,useRef,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * ExpandableText\n *\n * Text that truncates by characters or lines and shows a configurable\n * “Read more / Read less” toggle. Can be used inside cards or any layout.\n *\n * @framerDisableUnlink\n * @framerIntrinsicHeight 120\n * @framerIntrinsicWidth 300\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function ExpandableText(props){const{text,maxLines,readMoreLabel,readLessLabel,defaultExpanded,textAlign,fontFamily,fontSize,fontWeight,color,lineHeight,letterSpacing,linkColor,showUnderline,style}=props;const[expanded,setExpanded]=useState(defaultExpanded);const[showToggle,setShowToggle]=useState(false);const[collapsedLines,setCollapsedLines]=useState(maxLines);const textRef=useRef(null);const measureRef=useRef(null);const containerRef=useRef(null);const measure=React.useCallback(()=>{if(!text){setShowToggle(false);setCollapsedLines(maxLines);return;}const el=measureRef.current;if(!el)return;const fullHeight=el.scrollHeight;const effectiveFontSize=fontSize||16;const effectiveLineHeightMultiplier=(lineHeight&&lineHeight>0?lineHeight:110)/100;const lineHeightPx=effectiveFontSize*effectiveLineHeightMultiplier;if(!lineHeightPx){setShowToggle(false);setCollapsedLines(maxLines);return;}const approxLines=fullHeight/lineHeightPx;if(approxLines>maxLines+.1){setShowToggle(true);setCollapsedLines(Math.max(1,maxLines-1));}else{setShowToggle(false);setCollapsedLines(maxLines);}},[text,maxLines,fontSize,lineHeight]);useEffect(()=>{measure();},[measure,fontFamily,fontWeight,letterSpacing]);useEffect(()=>{const el=containerRef.current;if(!el||typeof ResizeObserver===\"undefined\")return;const ro=new ResizeObserver(()=>{measure();});ro.observe(el);return()=>ro.disconnect();},[measure]);const shouldShowToggle=showToggle;const handleToggle=event=>{event.stopPropagation();event.preventDefault();if(!shouldShowToggle)return;setExpanded(prev=>!prev);};const baseTextStyle={textAlign,margin:0,whiteSpace:\"pre-wrap\",wordBreak:\"break-word\",fontFamily,fontSize,fontWeight,color,lineHeight:lineHeight!=null?`${lineHeight}%`:undefined,letterSpacing:letterSpacing!=null?`${letterSpacing}px`:undefined};const lineClampStyle=!expanded?{display:\"-webkit-box\",WebkitLineClamp:collapsedLines,WebkitBoxOrient:\"vertical\",overflow:\"hidden\"}:{};// Simple markdown-style bold: **text** -> bold span\nconst renderTextWithBold=value=>{if(!value)return null;const parts=String(value).split(/(\\*\\*[^*]+\\*\\*)/g);return parts.map((part,index)=>{const match=part.match(/^\\*\\*(.*)\\*\\*$/);if(match){return /*#__PURE__*/_jsx(\"span\",{style:{fontWeight:700},children:match[1]},index);}return /*#__PURE__*/_jsx(\"span\",{children:part},index);});};return /*#__PURE__*/_jsx(\"div\",{style:{...style,width:\"100%\",height:\"100%\",display:\"flex\",flexDirection:\"column\",justifyContent:\"flex-start\",alignItems:textAlign===\"center\"?\"center\":textAlign===\"right\"?\"flex-end\":\"flex-start\"},children:/*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{width:\"100%\"},children:[/*#__PURE__*/_jsx(\"p\",{ref:textRef,style:{...baseTextStyle,...lineClampStyle},children:renderTextWithBold(text)}),shouldShowToggle&&/*#__PURE__*/_jsx(\"span\",{role:\"button\",tabIndex:0,onClick:handleToggle,onKeyDown:e=>{if(e.key===\"Enter\"||e.key===\" \"){handleToggle(e);}},style:{cursor:\"pointer\",color:linkColor,textDecoration:showUnderline?\"underline\":\"none\",fontFamily,fontSize,fontWeight,lineHeight:lineHeight!=null?`${lineHeight}%`:undefined,letterSpacing:letterSpacing!=null?`${letterSpacing}px`:undefined},children:expanded?readLessLabel:readMoreLabel}),/*#__PURE__*/_jsx(\"p\",{ref:measureRef,\"aria-hidden\":\"true\",style:{...baseTextStyle,position:\"absolute\",visibility:\"hidden\",pointerEvents:\"none\",zIndex:-1,width:\"100%\"},children:renderTextWithBold(text)})]})});}ExpandableText.defaultProps={text:\"Teya are fantastic in every way. Their rates are HALF as high as Square, they sent us a full on modern card machine for free! The payments are next day and flexible. We are already recommending Teya to everyone at this season’s exhibitions.\",maxLines:3,readMoreLabel:\"Show more\",readLessLabel:\"Show less\",defaultExpanded:false,textAlign:\"left\",fontFamily:\"Figtree, system-ui, -apple-system, BlinkMacSystemFont, sans-serif\",fontSize:16,fontWeight:400,color:\"#000000\",lineHeight:110,letterSpacing:0,linkColor:\"#4AA0C6\",showUnderline:true};addPropertyControls(ExpandableText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Teya are fantastic in every way. Their rates are HALF as high as Square, they sent us a full on modern card machine for free! The payments are next day and flexible. We are already recommending Teya to everyone at this season’s exhibitions.\",displayTextArea:true},maxLines:{type:ControlType.Number,title:\"Max lines\",defaultValue:3,min:1,max:10,step:1,description:\"Uses CSS line clamp; visual result can vary with font size.\"},readMoreLabel:{type:ControlType.String,title:\"Show more\",defaultValue:\"Show more\"},readLessLabel:{type:ControlType.String,title:\"Show less\",defaultValue:\"Show less\"},defaultExpanded:{type:ControlType.Boolean,title:\"Expanded by default\",defaultValue:false},textAlign:{type:ControlType.SegmentedEnum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\"},fontFamily:{type:ControlType.String,title:\"Font family\",defaultValue:\"Figtree, system-ui, -apple-system, BlinkMacSystemFont, sans-serif\"},fontSize:{type:ControlType.Number,title:\"Font size\",defaultValue:16,min:8,max:120,unit:\"px\",displayStepper:true},fontWeight:{type:ControlType.Enum,title:\"Weight\",options:[\"300\",\"400\",\"500\",\"600\",\"700\",\"800\",\"900\"],optionTitles:[\"Light\",\"Normal\",\"Medium\",\"Semibold\",\"Bold\",\"ExtraBold\",\"Black\"],defaultValue:\"400\"},color:{type:ControlType.Color,title:\"Text color\",defaultValue:\"#000000\"},lineHeight:{type:ControlType.Number,title:\"Line height (%)\",defaultValue:110,min:80,max:200,step:5},letterSpacing:{type:ControlType.Number,title:\"Letter px\",defaultValue:0,min:-5,max:20,step:.5},linkColor:{type:ControlType.Color,title:\"Link color\",defaultValue:\"#4AA0C6\"},showUnderline:{type:ControlType.Boolean,title:\"Underline link\",defaultValue:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ExpandableText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerDisableUnlink\":\"* @framerIntrinsicHeight 120\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"300\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Expandable_Text.map"],"mappings":"kMAWG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,OAAK,WAAS,gBAAc,gBAAc,kBAAgB,YAAU,aAAW,WAAS,aAAW,QAAM,aAAW,gBAAc,YAAU,gBAAc,SAAO,EAAW,CAAC,EAAS,GAAaA,EAAS,CAAe,EAAO,CAAC,EAAW,GAAeA,EAAS,EAAK,EAAO,CAAC,EAAe,GAAmBA,EAAS,CAAQ,EAAQ,EAAQC,EAAO,IAAI,EAAQ,EAAWA,EAAO,IAAI,EAAQ,EAAaA,EAAO,IAAI,EAAQ,EAAQC,EAAM,gBAAgB,CAAC,GAAG,CAAC,EAAK,CAAC,EAAc,EAAK,EAAE,EAAkB,CAAQ,EAAE,MAAO,CAAC,IAAM,EAAG,EAAW,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAM,EAAW,EAAG,aAA0I,GAAnD,GAAY,EAAW,EAAE,EAAW,KAAK,KAA3F,GAAU,IAAwJ,GAAG,CAAC,EAAa,CAAC,EAAc,EAAK,EAAE,EAAkB,CAAQ,EAAE,MAAO,CAAmB,EAAW,EAA4B,EAAS,IAAI,EAA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