{"version":3,"file":"ShopifyText.BbEm4l4h.mjs","names":["React.useState"],"sources":["https:/framerusercontent.com/modules/p1TmCy93nU8X0ZaLcBsd/gQARMdELzXtgtP53YiXf/ShopifyText.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion}from\"framer-motion\";// Grabs just the first paragraph out of a raw HTML/description string.\nfunction getFirstParagraph(html){if(!html)return html;const pMatch=html.match(/<p[^>]*>([\\s\\S]*?)<\\/p>/i);if(pMatch)return pMatch[0];const brParts=html.split(/(?:<br\\s*\\/?>\\s*){2,}/i);if(brParts.length>1)return brParts[0];const nlParts=html.split(/\\n\\s*\\n/);if(nlParts.length>1)return nlParts[0];return html;}export default function ShopifyDataText(props){const{metafieldKey,htmlTag,typography,colorType,textColor,gradientColor,textAlign,textTransform,shadowEnabled,shadowColor,shadowX,shadowY,shadowBlur,hideLastWord,enableFormatting,firstParagraphOnly,...framerProps}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;// @ts-ignore\nconst initialData=typeof window!==\"undefined\"?window.__SHOPIFY_METAFIELDS?.[metafieldKey]:null;const[value,setValue]=React.useState(initialData);const[isExpanded,setIsExpanded]=React.useState(false);React.useEffect(()=>{if(isCanvas)return;const handleDataReady=()=>{// @ts-ignore\nif(window.__SHOPIFY_METAFIELDS){// @ts-ignore\nsetValue(window.__SHOPIFY_METAFIELDS[metafieldKey]||null);}};window.addEventListener(\"shopify_data_ready\",handleDataReady);return()=>window.removeEventListener(\"shopify_data_ready\",handleDataReady);},[metafieldKey,isCanvas]);// --- SMART HIDE LOGIC ---\nlet shouldHide=false;if(!isCanvas){if(value===null||value===undefined||value.trim()===\"\"||metafieldKey.startsWith(\"custom.\")&&value===metafieldKey){shouldHide=true;}}if(shouldHide)return null;const isGradient=colorType===\"gradient\";// --- SMART SHADOW LOGIC ---\nconst shadowStyle=shadowEnabled?isGradient?{filter:`drop-shadow(${shadowX}px ${shadowY}px ${shadowBlur}px ${shadowColor})`}:{textShadow:`${shadowX}px ${shadowY}px ${shadowBlur}px ${shadowColor}`}:{};const textStyles={...typography,textAlign,textTransform,margin:0,...shadowStyle,...isGradient?{display:\"inline-block\",width:\"fit-content\",maxWidth:\"100%\",backgroundImage:gradientColor,WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundClip:\"text\",color:\"transparent\"}:{display:\"block\",width:\"100%\",color:textColor}};let displayText=value;if(isCanvas){displayText=`[${metafieldKey}]`;}else if(value===null){displayText=\"...\";}// --- EXPANDABLE / FIRST PARAGRAPH LOGIC ---\nlet workingText=displayText||\"\";let firstParaText=workingText;let hasMoreContent=false;if(firstParagraphOnly&&!isCanvas){firstParaText=getFirstParagraph(workingText);hasMoreContent=workingText.trim().length>firstParaText.trim().length;}// Decide which text to show based on expanded state\nlet activeText=firstParagraphOnly&&!isExpanded&&!isCanvas?firstParaText:workingText;// --- FORMATTING LOGIC ---\nconst useFormatting=enableFormatting&&!isCanvas;let cleanText=useFormatting?activeText:activeText.replace(/<[^>]*>/g,\"\");// --- HIDE LAST WORD LOGIC ---\nif(hideLastWord&&!isCanvas&&!useFormatting&&cleanText){const words=cleanText.trim().split(\" \");if(words.length>1){cleanText=words.slice(0,-1).join(\" \");}else{cleanText=\"\";}}let htmlToRender=cleanText.trim();// Strip wrapping <p> tag to prevent unwanted line breaks before our custom toggle\nif(useFormatting&&htmlToRender.toLowerCase().startsWith(\"<p>\")&&htmlToRender.toLowerCase().endsWith(\"</p>\")){const inner=htmlToRender.slice(3,-4).trim();if(!inner.toLowerCase().includes(\"<p>\")){htmlToRender=inner;}}const MotionTag=motion[htmlTag];// --- TOGGLE BUTTON UI ---\nconst toggleButton=firstParagraphOnly&&hasMoreContent&&!isCanvas?/*#__PURE__*/_jsx(motion.span,{onClick:()=>setIsExpanded(!isExpanded),initial:{color:\"#999999\"},whileHover:{color:\"#FF3B2E\"},style:{cursor:\"pointer\",display:\"block\",textAlign:\"right\",textDecoration:\"underline\",marginTop:\"4px\",width:\"100%\",fontSize:\"14px\"},children:isExpanded?\"Less\":\"More\"}):null;if(useFormatting){return /*#__PURE__*/_jsxs(MotionTag,{...framerProps,style:{...framerProps.style,...textStyles},children:[/*#__PURE__*/_jsx(\"span\",{dangerouslySetInnerHTML:{__html:htmlToRender}}),toggleButton]});}return /*#__PURE__*/_jsxs(MotionTag,{...framerProps,style:{...framerProps.style,...textStyles},children:[htmlToRender,toggleButton]});}addPropertyControls(ShopifyDataText,{metafieldKey:{type:ControlType.String,title:\"Data Key\"},htmlTag:{type:ControlType.Enum,options:[\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"p\",\"span\"],title:\"HTML Tag\",defaultValue:\"p\"},typography:{type:ControlType.Font,title:\"Typography\",controls:\"extended\",defaultValue:{fontFamily:\"Inter\",fontSize:16,fontWeight:500,lineHeight:1.2}},colorType:{type:ControlType.Enum,options:[\"solid\",\"gradient\"],title:\"Color Type\",defaultValue:\"solid\"},textColor:{type:ControlType.Color,title:\"Solid Color\",defaultValue:\"#FFFFFF\",hidden(props){return props.colorType===\"gradient\";}},gradientColor:{type:ControlType.String,title:\"Gradient CSS\",defaultValue:\"linear-gradient(135deg, #FF6B9D 0%, #C084FC 50%, #60A5FA 100%)\",hidden(props){return props.colorType===\"solid\";}},textAlign:{type:ControlType.Enum,options:[\"left\",\"center\",\"right\"],title:\"Align\",defaultValue:\"left\"},textTransform:{type:ControlType.Enum,options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],title:\"Transform\",defaultValue:\"none\"},enableFormatting:{type:ControlType.Boolean,title:\"Format HTML\",defaultValue:false},firstParagraphOnly:{type:ControlType.Boolean,title:\"Expandable (1st Para)\",defaultValue:false},hideLastWord:{type:ControlType.Boolean,title:\"Hide Last Word\",defaultValue:false},shadowEnabled:{type:ControlType.Boolean,title:\"Enable Shadow\",defaultValue:false},shadowColor:{type:ControlType.Color,title:\"Shadow Color\",defaultValue:\"rgba(189, 28, 17, 0.76)\",hidden(props){return!props.shadowEnabled;}},shadowX:{type:ControlType.Number,title:\"Shadow X\",defaultValue:0,displayStepper:true,hidden(props){return!props.shadowEnabled;}},shadowY:{type:ControlType.Number,title:\"Shadow Y\",defaultValue:0,displayStepper:true,hidden(props){return!props.shadowEnabled;}},shadowBlur:{type:ControlType.Number,title:\"Shadow Blur\",defaultValue:38,displayStepper:true,min:0,hidden(props){return!props.shadowEnabled;}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ShopifyDataText\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ShopifyText.map"],"mappings":"oPACA,SAAS,EAAkB,EAAK,CAAC,GAAG,CAAC,EAAK,OAAO,EAAK,IAAM,EAAO,EAAK,MAAM,0BAA0B,EAAE,GAAG,EAAO,OAAO,EAAO,GAAG,IAAM,EAAQ,EAAK,MAAM,wBAAwB,EAAE,GAAG,EAAQ,OAAO,EAAE,OAAO,EAAQ,GAAG,IAAM,EAAQ,EAAK,MAAM,SAAS,EAAwC,OAAnC,EAAQ,OAAO,EAAS,EAAQ,GAAU,CAAK,CAAC,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,eAAa,UAAQ,aAAW,YAAU,YAAU,gBAAc,YAAU,gBAAc,gBAAc,cAAY,UAAQ,UAAQ,aAAW,eAAa,mBAAiB,qBAAmB,GAAG,GAAa,EAAY,EAAS,EAAa,QAAQ,IAAI,EAAa,OACjhB,CAAC,EAAM,GAAUA,EAA5F,IAAS,OAAwD,KAA5C,EAAO,uBAAuB,EAAmE,EAAO,CAAC,EAAW,GAAeA,EAAe,EAAK,EAAE,MAAoB,CAAC,GAAG,EAAS,OAAO,IAAM,MAAoB,CACtQ,EAAO,sBACV,EAAS,EAAO,qBAAqB,IAAe,IAAI,CAAG,EAAgE,OAA9D,EAAO,iBAAiB,qBAA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