{"version":3,"file":"TextHighlight.Bnf-saPy.mjs","names":["useMemo","Tag","__esmMin","init_npm_react_18_3_1","pe","init_jsx_runtime","c","addPropertyControls","ControlType","init_framer_BisrWwwE","TextHighlight","props","highlightedText","wordsToHighlight","words","w","pattern","word","regex","caseSensitive","text","part","isFixedWidth","style","htmlTag","textFont","highlightBackground","highlightColor","highlightBorderRadius","highlightPadding","index","textColor","init_TextHighlight"],"sources":["https:/framerusercontent.com/modules/WACI5UZRHVwirq6QMPgs/hkyVqYg8XU2kDBnDbDS1/TextHighlight.js"],"sourcesContent":["// Text Highlight Component - Highlight specific words in text with custom styles\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useMemo}from\"react\";/**\n * Text Highlight Component\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function TextHighlight(props){const{text=\"Hello world, this is a sample text with highlighted words.\",wordsToHighlight=\"highlighted, sample\",textColor=\"#000000\",highlightColor=\"#000000\",highlightBackground=\"#FFBB00\",textFont,caseSensitive=false,highlightBorderRadius=\"4px\",highlightPadding=\"2px 4px\",htmlTag=\"p\",textAlign=\"left\",textTransform=\"none\",style}=props;const highlightedText=useMemo(()=>{if(!wordsToHighlight.trim()){return[{text,isHighlighted:false}];}// Split words to highlight by comma and trim whitespace\nconst words=wordsToHighlight.split(\",\").map(w=>w.trim()).filter(w=>w.length>0);if(words.length===0){return[{text,isHighlighted:false}];}// Create regex pattern for all words\nconst pattern=words.map(word=>word.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")).join(\"|\");const regex=new RegExp(`(${pattern})`,caseSensitive?\"g\":\"gi\");// Split text by matches\nconst parts=text.split(regex);return parts.map(part=>{if(!part)return null;const isHighlighted=words.some(word=>caseSensitive?part===word:part.toLowerCase()===word.toLowerCase());return{text:part,isHighlighted};}).filter(Boolean);},[text,wordsToHighlight,caseSensitive]);const isFixedWidth=style?.width===\"100%\";const Tag=htmlTag;return /*#__PURE__*/_jsx(Tag,{style:{...style,position:\"relative\",display:\"inline-block\",...isFixedWidth?{}:{width:\"max-content\"},...textFont,textAlign,textTransform,margin:0},children:/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"pre-wrap\",wordBreak:\"break-word\"},children:highlightedText.map((part,index)=>{if(part.isHighlighted){return /*#__PURE__*/_jsx(\"span\",{style:{backgroundColor:highlightBackground,color:highlightColor,borderRadius:highlightBorderRadius,padding:highlightPadding},children:part.text},index);}return /*#__PURE__*/_jsx(\"span\",{style:{color:textColor},children:part.text},index);})})});}addPropertyControls(TextHighlight,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Hello world, this is a sample text with highlighted words.\",displayTextArea:true},htmlTag:{type:ControlType.Enum,title:\"HTML Tag\",options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],optionTitles:[\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\",\"Paragraph\",\"Span\"],defaultValue:\"p\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\",\"justify\"],optionTitles:[\"Left\",\"Center\",\"Right\",\"Justify\"],defaultValue:\"left\",displaySegmentedControl:true},textTransform:{type:ControlType.Enum,title:\"Text Transform\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"none\"},wordsToHighlight:{type:ControlType.String,title:\"Words to Highlight\",defaultValue:\"highlighted, sample\",placeholder:\"word1, word2, word3\",description:\"Separate words with commas\"},caseSensitive:{type:ControlType.Boolean,title:\"Case Sensitive\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},textFont:{type:ControlType.Font,title:\"Text Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"15px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"}},highlightColor:{type:ControlType.Color,title:\"Highlight Color\",defaultValue:\"#000000\"},highlightBackground:{type:ControlType.Color,title:\"Highlight Background\",defaultValue:\"#FFBB00\"},highlightBorderRadius:{type:ControlType.BorderRadius,title:\"Border Radius\",defaultValue:\"4px\"},highlightPadding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"2px 4px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextHighlight\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./TextHighlight.map"],"mappings":"A,2KAMG,SAAwBU,EAAc,EAAM,CAAC,GAAK,CAAC,OAAK,6DAA6D,mBAAiB,sBAAsB,YAAU,UAAU,iBAAe,UAAU,sBAAoB,UAAU,WAAS,gBAAc,GAAM,wBAAsB,MAAM,mBAAiB,UAAU,UAAQ,IAAI,YAAU,OAAO,gBAAc,OAAO,SAAOC,EAAYC,EAAgBZ,MAAY,CAAC,GAAG,CAACa,EAAiB,KAAK,EAAG,MAAM,CAAC,CAAC,OAAK,cAAc,EAAK,CAAC,EAC9d,IAAMC,EAAMD,EAAiB,MAAM,GAAG,CAAC,CAAC,IAAI,GAAGE,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,GAAGA,EAAE,OAAO,CAAC,EAAE,GAAGD,EAAM,SAAS,EAAG,MAAM,CAAC,CAAC,OAAK,cAAc,EAAK,CAAC,EACrI,IAAME,EAAQF,EAAM,IAAI,GAAMG,EAAK,QAAQ,sBAAsB,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAQC,EAAU,OAAO,IAAIF,EAAQ,GAAGG,EAAc,IAAI,IAAI,EAClH,OAAlBC,EAAK,MAAMF,CAAkB,CAAC,CAAC,IAAI,GAAWG,EAA+H,CA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