{"version":3,"file":"MasonryLayout.CDOS3p2L.mjs","names":["useRef","useState","useMemo","Children","useMemo","j"],"sources":["https:/framerusercontent.com/modules/QvcQDHFSyXpcgTzkSMpg/BWjyTbXErexuXPF5ZUK9/Masonry.js","https:/framerusercontent.com/modules/7XzJP0Q2NyyJyg9uVacP/met3zffn26WSKovWjmpV/MasonryLayout.js"],"sourcesContent":["// Code from Nikolay Goncharuk on GitHub:\n// https://github.com/GoncharukBro/react-smart-masonry/blob/master/src/Masonry.tsx\n// https://github.com/GoncharukBro/react-smart-masonry/blob/master/src/useResize.ts\n//\n// Modified by Isaac Roberts\n// https://framestack.co/components/masonry-layout\n//\n// Copyright (c) 2021 Nikolay Goncharuk\n// MIT License\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useLayoutEffect,useMemo,useRef,Children,isValidElement}from\"react\";const DEFAULT_COLUMNS=1;const DEFAULT_GAP=0;export default function Masonry({breakpoints,columns=DEFAULT_COLUMNS,gap=DEFAULT_GAP,reverse=false,autoArrange=false,alignment=\"center\",children,style,...otherProps},forwardedRef){const elements=useRef([]);const[arrange,setArrange]=useState(false);// eslint-disable-next-line react-hooks/exhaustive-deps\nuseLayoutEffect(()=>{if(autoArrange&&!arrange)setArrange(true);return()=>{if(autoArrange&&arrange)setArrange(false);};});const layout=useMemo(()=>{if(columns<1)return[];const arrayOfChildren=Children.toArray(children);if(reverse)arrayOfChildren.reverse();const newLayout=Array.from({length:columns},()=>{return[];});const columnHeights=newLayout.map(()=>0);const getcolumnIndex=index=>{if(autoArrange&&arrange&&elements.current.length>0){const columnIndex=columnHeights.findIndex(item=>{return item===Math.min(...columnHeights);});const element=elements.current.find(item=>item.index===index);const elementHeight=element===null||element===void 0?void 0:element.element.getBoundingClientRect().height;columnHeights[columnIndex]+=elementHeight||0;return columnIndex;}return index%columns;};arrayOfChildren.forEach((child,index)=>{if(child&&/*#__PURE__*/isValidElement(child)){newLayout[getcolumnIndex(index)].push({element:child,index});}});return newLayout;},[arrange,autoArrange,children,columns,reverse]);const temporaryElements=[];const addElement=index=>element=>{if(element!==null){temporaryElements.push({element,index});elements.current=temporaryElements;}};return /*#__PURE__*/_jsx(\"div\",{ref:forwardedRef,style:{display:\"flex\",gap,...style},...otherProps,children:layout.map((column,columnIndex)=>/*#__PURE__*/_jsx(\"div\",{style:{flex:1,display:\"flex\",flexDirection:\"column\",alignItems:alignment,gap},children:column.map((item,itemIndex)=>/*#__PURE__*/_jsx(\"div\",{ref:addElement(item.index),children:item.element},itemIndex))},columnIndex))});}\nexport const __FramerMetadata__ = {\"exports\":{\"MasonryProps\":{\"type\":\"tsType\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"default\":{\"type\":\"reactComponent\",\"name\":\"Masonry\",\"slots\":[\"children\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Masonry.map","import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{cloneElement,useMemo}from\"react\";import Masonry from\"https://framerusercontent.com/modules/QvcQDHFSyXpcgTzkSMpg/BWjyTbXErexuXPF5ZUK9/Masonry.js\";import{getCollectionData}from\"https://framer.com/m/CMSLibrary-09eo.js\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n */export default function MasonryLayout(props){var _props_collectionList;const{type}=props;const collectionList=(_props_collectionList=props.collectionList)===null||_props_collectionList===void 0?void 0:_props_collectionList[0];const isCanvas=RenderTarget.current()===RenderTarget.canvas;let layers=useMemo(()=>{let value=[];switch(type){case\"cms\":const{query,childrenFunction}=getCollectionData(collectionList);if(!isCanvas&&query){var _c_props;const c=childrenFunction(useQueryData(query));if(Array.isArray(c)){value=c;}else if(Array.isArray(c===null||c===void 0?void 0:(_c_props=c.props)===null||_c_props===void 0?void 0:_c_props.children)){value=c.props.children;}}if(!collectionList||!query&&!isCanvas){return /*#__PURE__*/_jsx(Message,{title:\"Connect a CMS Collection List\",subtitle:\"Use the handle on the right side of the component to connect a collection list, or select it from the dropdown. The collection list must be outside of the page on the canvas.\"});}else if(isCanvas){return /*#__PURE__*/_jsx(Message,{title:\"Preview site to view masonry grid\",subtitle:\"Press the play button or visit the live website to view the masonry grid.\"});}break;case\"layers\":if(!props.layers.length){return /*#__PURE__*/_jsx(Message,{title:\"Connect layers\",subtitle:\"Use the handle on the right side of the component to connect layers outside of the page for a masonry grid.\"});}value=props.layers;break;}return props.randomize?shuffleArray(value):value;},[type,collectionList,props.layers,props.randomize]);if(props.columnWidth==\"fill\"){for(let i=0;i<layers.length;i++){if(layers[i]){var _layers_i_props,_layers_i;layers[i]=/*#__PURE__*/cloneElement(layers[i],{style:{...(_layers_i=layers[i])===null||_layers_i===void 0?void 0:(_layers_i_props=_layers_i.props)===null||_layers_i_props===void 0?void 0:_layers_i_props.style,width:\"100%\"}});}}}if(props.columns==1){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",gap:props.gapV},children:layers});}else{return /*#__PURE__*/_jsx(Masonry,{columns:props.columns,gap:`${props.gapV}px ${props.gapH}px`,alignment:props.columnWidth==\"fit\"?props.align:\"stretch\",autoArrange:true,reverse:false,style:props.style,children:layers});}}MasonryLayout.displayName=\"Masonry Layout\";addPropertyControls(MasonryLayout,{type:{type:ControlType.Enum,defaultValue:\"layers\",options:[\"layers\",\"cms\"],optionTitles:[\"Layers\",\"CMS\"],displaySegmentedControl:true},collectionList:{type:ControlType.ComponentInstance,hidden:props=>props.type!==\"cms\"},layers:{type:ControlType.Array,control:{type:ControlType.ComponentInstance},hidden:props=>props.type!==\"layers\"},columns:{type:ControlType.Number,defaultValue:3,min:1,step:1,displayStepper:true},columnWidth:{type:ControlType.Enum,defaultValue:\"fill\",options:[\"fit\",\"fill\"],optionTitles:[\"Fit\",\"Fill\"],displaySegmentedControl:true,title:\"Item Width\"},align:{type:ControlType.Enum,defaultValue:\"center\",options:[\"start\",\"center\",\"end\"],optionTitles:[\"Left\",\"Center\",\"Right\"],displaySegmentedControl:true,hidden:props=>props.columnWidth!==\"fit\"},gapH:{type:ControlType.Number,defaultValue:10,min:0,hidden:props=>props.columns==1},gapV:{type:ControlType.Number,defaultValue:10,min:0},randomize:{type:ControlType.Boolean,defaultValue:false}});function Message({title,subtitle}){return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",width:\"100%\",placeContent:\"center\",placeItems:\"center\",flexDirection:\"column\",gap:16,backgroundColor:\"rgba(136, 85, 255, 0.1)\",borderRadius:6,border:\"1px dashed rgb(136, 85, 255)\",color:\"rgb(136, 85, 255)\",fontSize:16,padding:20,minHeight:200,textWrap:\"balance\"},children:[/*#__PURE__*/_jsx(\"p\",{style:{margin:0,fontWeight:600,textAlign:\"center\"},children:title}),/*#__PURE__*/_jsx(\"p\",{style:{margin:0,opacity:.7,lineHeight:1.5,textAlign:\"center\"},children:subtitle})]});}function shuffleArray(array){if(!array){return[];}for(let i=array.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[array[i],array[j]]=[array[j],array[i]];}return array;}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"MasonryLayout\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./MasonryLayout.map"],"mappings":"qSAS0K,SAAwB,EAAQ,CAAC,cAAY,UAAQ,EAAgB,MAAI,EAAY,UAAQ,GAAM,cAAY,GAAM,YAAU,SAAS,WAAS,QAAM,GAAG,GAAY,EAAa,CAAC,IAAM,EAASA,EAAO,EAAE,CAAC,CAAM,CAAC,EAAQ,GAAYC,EAAS,GAAM,CACja,OAAwB,GAAa,CAAC,GAAQ,EAAW,GAAK,KAAW,CAAI,GAAa,GAAQ,EAAW,G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