{"version":3,"file":"FluidText.CIsK3KLh.mjs","names":["useRef","useState","width"],"sources":["https:/framerusercontent.com/modules/C9kKYjd75ulX6BAyODId/XBrLIyrwrRz6gdk2nItO/FluidText.js"],"sourcesContent":["// FluidText component that automatically scales text to fill 100% of parent container width with natural line wrapping\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 100\n * \n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function FluidText(props){const{text=\"Fluid Text\",font={},color=\"#000000\",baseSize=2,textTransform=\"none\",textAlign=\"left\"}=props;const wrapperRef=useRef(null);const[fontSize,setFontSize]=useState(baseSize);useEffect(()=>{const referenceWidth=1e3;// Remonte dans le DOM jusqu'à trouver un ancêtre avec une vraie largeur\nconst getContainerWidth=()=>{if(!wrapperRef.current)return 0;let el=wrapperRef.current;while(el){const w=el.offsetWidth;if(w>20)return w;el=el.parentElement;}return 0;};const applySize=width=>{const baseSizeInPixels=baseSize*16;const calculated=width*baseSizeInPixels/referenceWidth;startTransition(()=>setFontSize(calculated/16));};// Tentative immédiate\nconst width=getContainerWidth();if(width>20){applySize(width);}// Tentatives différées pour couvrir le cas tablet/mobile\n// où le layout se calcule après le mount\nconst delays=[50,100,200,400,800,1200];const timers=delays.map(delay=>setTimeout(()=>{const w=getContainerWidth();if(w>20)applySize(w);},delay));// ResizeObserver sur le premier ancêtre valide\nlet observed=wrapperRef.current;while(observed&&observed.offsetWidth<=20){observed=observed.parentElement;}const observer=new ResizeObserver(entries=>{for(const entry of entries){const w=entry.contentRect.width;if(w>20)applySize(w);}});if(observed)observer.observe(observed);if(wrapperRef.current)observer.observe(wrapperRef.current);return()=>{timers.forEach(clearTimeout);observer.disconnect();};},[baseSize]);const textStyle={...font,color,textTransform,textAlign,fontSize:`${fontSize}rem`,whiteSpace:\"normal\",overflowWrap:\"break-word\",wordBreak:\"break-word\",margin:0,padding:0,width:\"100%\"};return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:{width:\"100%\",height:\"100%\",display:\"block\",position:\"relative\",overflow:\"visible\",...props.style},children:/*#__PURE__*/_jsx(\"p\",{style:textStyle,children:text})});}addPropertyControls(FluidText,{text:{type:ControlType.String,title:\"Text\",defaultValue:\"Fluid Text\",displayTextArea:true},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{variant:\"Bold\",lineHeight:\"1.2em\",letterSpacing:\"-0.02em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},baseSize:{type:ControlType.Number,title:\"Base Size\",defaultValue:2,min:.5,max:20,step:.1,unit:\"rem\"},textTransform:{type:ControlType.Enum,title:\"Text Transform\",options:[\"none\",\"uppercase\",\"lowercase\",\"capitalize\"],optionTitles:[\"None\",\"Uppercase\",\"Lowercase\",\"Capitalize\"],defaultValue:\"none\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"left\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"FluidText\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"200\",\"framerIntrinsicHeight\":\"100\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FluidText.map"],"mappings":"0LAOG,SAAwB,EAAU,EAAM,CAAC,GAAK,CAAC,OAAK,aAAa,OAAK,EAAE,CAAC,QAAM,UAAU,WAAS,EAAE,gBAAc,OAAO,YAAU,QAAQ,EAAY,EAAWA,EAAO,KAAK,CAAM,CAAC,EAAS,GAAaC,EAAS,EAAS,C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