{"version":3,"file":"TextHighlight.DOSkQfPV.mjs","names":["useMemo","Tag"],"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":"2KAMG,SAAwB,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,SAAO,EAAY,EAAgBA,MAAY,CAAC,GAAG,CAAC,EAAiB,KAAK,EAAG,MAAM,CAAC,CAAC,OAAK,cAAc,EAAK,CAAC,EAC9d,IAAM,EAAM,EAAiB,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,GAAG,EAAM,SAAS,EAAG,MAAM,CAAC,CAAC,OAAK,cAAc,EAAK,CAAC,EACrI,IAAM,EAAQ,EAAM,IAAI,GAAM,EAAK,QAAQ,sBAAsB,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAQ,EAAU,OAAO,IAAI,EAAQ,GAAG,EAAc,IAAI,IAAI,EAClH,OAAlB,EAAK,MAAM,CAAkB,CAAC,CAAC,IAAI,GAAW,EAA+H,CAAC,KAAK,EAAK,cAArG,EAAM,KAAK,GAAM,EAAc,IAAO,EAAK,EAAK,YAAY,IAAI,EAAK,YAAY,CAAgC,CAAC,EAA3I,IAA8I,CAAC,CAAC,OAAO,OAAO,CAAE,EAAE,CAAC,EAAK,EAAiB,CAAa,CAAC,EAAQ,EAAa,GAAO,QAAQ,OAAyB,OAAoB,EAAK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