{"version":3,"file":"CustomUnderlineText.CtIrJLXe.mjs","names":["useState","useCallback","useMemo"],"sources":["https:/framerusercontent.com/modules/cq83pVSAOmQeVGv1XNVy/4jvLh829JWKvTt6s05S9/CustomUnderlineText.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{startTransition,useCallback,useMemo,useState}from\"react\";import{addPropertyControls,ControlType}from\"framer\";function escapeRegex(input){return input.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\");}function isWholeWordBoundary(text,start,end){const prev=start>0?text[start-1]:\"\";const next=end<text.length?text[end]:\"\";const prevIsWord=/\\w/.test(prev);const nextIsWord=/\\w/.test(next);return!prevIsWord&&!nextIsWord;}function parsePhrases(input){return input.split(/[\\n,]/).map(item=>item.trim()).filter(Boolean);}function collectMatches(text,phrases,caseSensitive,wholeWord,matchScope){if(!text||phrases.length===0)return[];const sorted=[...phrases].sort((a,b)=>b.length-a.length);const pattern=sorted.map(escapeRegex).join(\"|\");const flags=caseSensitive?\"g\":\"gi\";const regex=new RegExp(pattern,flags);const ranges=[];let match=regex.exec(text);while(match){const value=match[0];const start=match.index;const end=start+value.length;const passWholeWord=!wholeWord||isWholeWordBoundary(text,start,end);if(passWholeWord){const overlaps=ranges.some(range=>start<range.end&&end>range.start);if(!overlaps){ranges.push({start,end});if(matchScope===\"first\")break;}}match=regex.exec(text);}return ranges.sort((a,b)=>a.start-b.start);}/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function CustomUnderlineText(props){const{text,semanticTag,markedPhrases,matchScope,caseSensitive,wholeWord,textFont,textAlign,textColor,underlineColor,underlineThickness,underlineOffset,underlineStyle,underlineOpacity,markerRadius,markerHeight,markerOffset,hoverBehavior,hoverUnderlineColor,hoverThickness,style}=props;const[isHovered,setIsHovered]=useState(false);const onMouseEnter=useCallback(()=>{startTransition(()=>setIsHovered(true));},[]);const onMouseLeave=useCallback(()=>{startTransition(()=>setIsHovered(false));},[]);const phrases=useMemo(()=>parsePhrases(markedPhrases),[markedPhrases]);const matches=useMemo(()=>collectMatches(text,phrases,caseSensitive,wholeWord,matchScope),[text,phrases,caseSensitive,wholeWord,matchScope]);const segments=useMemo(()=>{if(matches.length===0)return[{value:text,marked:false}];const result=[];let cursor=0;for(const match of matches){if(match.start>cursor){result.push({value:text.slice(cursor,match.start),marked:false});}result.push({value:text.slice(match.start,match.end),marked:true});cursor=match.end;}if(cursor<text.length){result.push({value:text.slice(cursor),marked:false});}return result;},[text,matches]);const effectiveUnderlineColor=isHovered&&hoverBehavior===\"colorShift\"?hoverUnderlineColor:underlineColor;const effectiveThickness=isHovered&&hoverBehavior===\"thicken\"?hoverThickness:underlineThickness;const TextTag=semanticTag;return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",display:\"block\",width:\"100%\",height:\"auto\",...style},onMouseEnter:hoverBehavior===\"none\"?undefined:onMouseEnter,onMouseLeave:hoverBehavior===\"none\"?undefined:onMouseLeave,children:/*#__PURE__*/_jsx(TextTag,{style:{margin:0,whiteSpace:\"pre-wrap\",overflowWrap:\"break-word\",color:textColor,textAlign,fontFamily:textFont.fontFamily||\"Soleil, Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif\",fontSize:textFont.fontSize,lineHeight:textFont.lineHeight,letterSpacing:textFont.letterSpacing,fontWeight:textFont.fontWeight,fontStyle:textFont.fontStyle},children:segments.map((segment,index)=>{if(!segment.marked)return /*#__PURE__*/_jsx(\"span\",{children:segment.value},index);if(underlineStyle===\"marker\"){return /*#__PURE__*/_jsx(\"span\",{style:{borderRadius:markerRadius,backgroundImage:`linear-gradient(to top, rgba(0,0,0,0) ${Math.max(0,100-markerHeight)}%, ${effectiveUnderlineColor} ${Math.max(0,100-markerHeight)}%)`,backgroundRepeat:\"no-repeat\",backgroundSize:\"100% 100%\",backgroundPosition:`0 ${markerOffset}px`,opacity:underlineOpacity},children:segment.value},index);}return /*#__PURE__*/_jsx(\"span\",{style:{textDecorationLine:\"underline\",textDecorationStyle:underlineStyle,textDecorationColor:effectiveUnderlineColor,textDecorationThickness:`${effectiveThickness}px`,textUnderlineOffset:`${underlineOffset}px`,textDecorationSkipInk:\"none\",opacity:underlineOpacity},children:segment.value},index);})})});}addPropertyControls(CustomUnderlineText,{text:{type:ControlType.String,title:\"Text Content\",defaultValue:\"Design text naturally and mark phrases for a custom underline treatment.\",displayTextArea:true},semanticTag:{type:ControlType.Enum,title:\"Semantic Tag\",options:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"div\"],optionTitles:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"div\"],defaultValue:\"p\"},markedPhrases:{type:ControlType.String,title:\"Marked\",defaultValue:\"custom underline\\nphrases\",displayTextArea:true},matchScope:{type:ControlType.Enum,title:\"Matches\",options:[\"first\",\"all\"],optionTitles:[\"First Only\",\"All\"],defaultValue:\"all\",displaySegmentedControl:true},caseSensitive:{type:ControlType.Boolean,title:\"Case\",defaultValue:false,enabledTitle:\"Sensitive\",disabledTitle:\"Ignore\"},wholeWord:{type:ControlType.Boolean,title:\"Whole Word\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},textFont:{type:ControlType.Font,title:\"Text Style\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"18px\",lineHeight:\"1.45em\",letterSpacing:\"-0.01em\",variant:\"Regular\"}},textAlign:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#000000\"},underlineColor:{type:ControlType.Color,title:\"Underline\",defaultValue:\"#F28C28\"},underlineThickness:{type:ControlType.Number,title:\"Thickness\",defaultValue:2,min:1,max:12,step:1,unit:\"px\"},underlineOffset:{type:ControlType.Number,title:\"Offset\",defaultValue:2,min:-6,max:20,step:1,unit:\"px\"},underlineStyle:{type:ControlType.Enum,title:\"Style\",options:[\"solid\",\"dashed\",\"dotted\",\"double\",\"wavy\",\"marker\"],optionTitles:[\"Solid\",\"Dashed\",\"Dotted\",\"Double\",\"Wavy\",\"Marker\"],defaultValue:\"solid\"},underlineOpacity:{type:ControlType.Number,title:\"Opacity\",defaultValue:1,min:.1,max:1,step:.05},markerRadius:{type:ControlType.Number,title:\"Marker Radius\",defaultValue:3,min:0,max:24,step:1,unit:\"px\",hidden:props=>props.underlineStyle!==\"marker\"},markerHeight:{type:ControlType.Number,title:\"Marker Height\",defaultValue:45,min:10,max:100,step:1,unit:\"%\",hidden:props=>props.underlineStyle!==\"marker\"},markerOffset:{type:ControlType.Number,title:\"Marker Offset\",defaultValue:0,min:-10,max:12,step:1,unit:\"px\",hidden:props=>props.underlineStyle!==\"marker\"},hoverBehavior:{type:ControlType.Enum,title:\"Hover\",options:[\"none\",\"colorShift\",\"thicken\"],optionTitles:[\"None\",\"Color Shift\",\"Thicken\"],defaultValue:\"none\"},hoverUnderlineColor:{type:ControlType.Color,title:\"Hover Color\",defaultValue:\"#D96A00\",hidden:props=>props.hoverBehavior!==\"colorShift\"},hoverThickness:{type:ControlType.Number,title:\"Hover Thick\",defaultValue:4,min:1,max:14,step:1,unit:\"px\",hidden:props=>props.hoverBehavior!==\"thicken\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CustomUnderlineText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CustomUnderlineText.map"],"mappings":"2LAA+J,SAAS,EAAY,EAAM,CAAC,OAAO,EAAM,QAAQ,sBAAsB,MAAM,CAAE,CAAC,SAAS,EAAoB,EAAK,EAAM,EAAI,CAAC,IAAM,EAAK,EAAM,EAAE,EAAK,E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