{"version":3,"file":"RandomCollection.BJNJAW47.mjs","names":["_Fragment"],"sources":["https:/framerusercontent.com/modules/xAd1LKohiF1easgr2BFb/WFXOpQTI8ZQJL014nauK/RandomCollection.js"],"sourcesContent":["import{jsx as _jsx,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{cloneElement,useEffect,useState}from\"react\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerIntrinsicWidth 600\n * @framerSupportedLayoutHeight auto\n */export default function RandomCMSItemsDisplay(props){var _collectionList__props_children,_collectionList__props,_collectionList_;const{collectionList,maxItems,layoutDirection,itemSpacing,wrap,sizing,fixedWidth,cycle,cycleInterval}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const clProps=collectionList===null||collectionList===void 0?void 0:(_collectionList_=collectionList[0])===null||_collectionList_===void 0?void 0:(_collectionList__props=_collectionList_.props)===null||_collectionList__props===void 0?void 0:(_collectionList__props_children=_collectionList__props.children)===null||_collectionList__props_children===void 0?void 0:_collectionList__props_children.props;const data=(clProps===null||clProps===void 0?void 0:clProps.query)?useQueryData(clProps.query):[];const[renderedItems,setRenderedItems]=useState([]);useEffect(()=>{const fetchData=()=>{if(data){const randomItems=getRandomItems(clProps===null||clProps===void 0?void 0:clProps.children(data).props.children,maxItems);const styledItems=randomItems.map((item,index)=>/*#__PURE__*/_jsx(\"div\",{style:{marginRight:layoutDirection===\"horizontal\"?itemSpacing:0,marginBottom:wrap&&layoutDirection===\"horizontal\"?itemSpacing:layoutDirection===\"vertical\"?itemSpacing:0,width:sizing===\"fixed\"?fixedWidth:\"100%\",boxSizing:sizing===\"fixed\"?\"border-box\":undefined,minWidth:50,minHeight:50},children:/*#__PURE__*/cloneElement(item,{style:{...item.props.style}})},index));setRenderedItems(styledItems);}else{setRenderedItems([]);}};!isCanvas&&fetchData();const intervalId=cycle?setInterval(fetchData,cycleInterval*1e3):null;return()=>{if(intervalId){clearInterval(intervalId);}};},[collectionList,maxItems,layoutDirection,itemSpacing,wrap,sizing,fixedWidth,cycle,cycleInterval]);const containerStyle={...props.style,display:layoutDirection===\"horizontal\"?\"flex\":\"block\",flexDirection:layoutDirection===\"horizontal\"?\"row\":undefined,flexWrap:wrap?\"wrap\":\"nowrap\"};if(isCanvas){containerStyle.padding=10;containerStyle.border=\"1px dashed grey\";}return /*#__PURE__*/_jsx(\"div\",{style:containerStyle,children:isCanvas?/*#__PURE__*/_jsx(_Fragment,{children:collectionList}):renderedItems.length>0?renderedItems:/*#__PURE__*/_jsx(\"div\",{children:\"Connect, configure and preview\"})});}RandomCMSItemsDisplay.displayName=\"Random CMS Items Display\";addPropertyControls(RandomCMSItemsDisplay,{collectionList:{type:ControlType.ComponentInstance},maxItems:{type:ControlType.Number,defaultValue:1,min:1},layoutDirection:{type:ControlType.Enum,defaultValue:\"vertical\",options:[\"vertical\",\"horizontal\"],displaySegmentedControl:true,segmentedControlDirection:\"horizontal\"},itemSpacing:{type:ControlType.Number,defaultValue:0,min:0},wrap:{type:ControlType.Boolean,defaultValue:false},sizing:{type:ControlType.Enum,defaultValue:\"fill\",options:[\"fill\",\"fixed\"],displaySegmentedControl:true,segmentedControlDirection:\"horizontal\",description:\"Please ensure that the connected CMS is vertically stacked\"},fixedWidth:{type:ControlType.Number,defaultValue:100,min:0,hidden:props=>props.sizing!==\"fixed\"},cycle:{type:ControlType.Boolean,defaultValue:false,title:\"Cycle\",enabledTitle:\"Yes\",disabledTitle:\"No\",description:\"v1.2 \\n[via SegmentUI](https://www.segmentUI.com)\"},cycleInterval:{type:ControlType.Number,defaultValue:5,min:1,hidden:props=>!props.cycle}});function getRandomItems(items,maxItems){if(!items||items.length===0){return[];}const shuffledItems=items.sort(()=>.5-Math.random());return shuffledItems.slice(0,maxItems);}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"RandomCMSItemsDisplay\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerIntrinsicWidth\":\"600\",\"framerDisableUnlink\":\"*\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./RandomCollection.map"],"mappings":"4TAOG,SAAwB,EAAsB,EAAM,CAAC,IAAI,EAAgC,EAAuB,EAAiB,GAAK,CAAC,iBAAe,WAAS,kBAAgB,cAAY,OAAK,SAAO,aAAW,QAAM,gBAAc,CAAC,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAQ,GAAiB,OAAsC,EAAiB,EAAe,KAAM,OAAwC,EAAuB,EAAiB,QAAS,SAAlI,IAAgL,EAAgC,EAAuB,WAAkG,MAAY,EAAM,GAAgD,MAAO,EAAa,EAAQ,MAAM,CAAC,CAAE,EAAM,CAAC,EAAc,EAAiB,CAAC,EAAS,CAAE,EAAC,CAAC,EAAU,IAAI,CAAC,IAAM,EAAU,IAAI,CAAC,GAAG,EAAK,CAAC,IAAM,EAAY,EAAuD,AAAxC,GAAgD,SAAS,EAAK,CAAC,MAAM,SAAS,EAAS,CAAO,EAAY,EAAY,IAAI,CAAC,EAAK,IAAqB,EAAK,MAAM,CAAC,MAAM,CAAC,YAAY,IAAkB,aAAa,EAAY,EAAE,aAAa,GAAM,IAAkB,cAAyB,IAAkB,WAA9B,EAAqD,EAAE,MAAM,IAAS,QAAQ,EAAW,OAAO,UAAU,IAAS,QAAQ,iBAAA,GAAuB,SAAS,GAAG,UAAU,EAAG,EAAC,SAAsB,EAAa,EAAK,CAAC,MAAM,CAAC,GAAG,EAAK,MAAM,KAAM,CAAC,EAAC,AAAC,EAAC,EAAM,CAAC,CAAC,EAAiB,EAAY,AAAE,MAAK,EAAiB,CAAE,EAAC,AAAG,EAAC,CAAC,GAAU,GAAW,CAAC,IAAM,EAAW,EAAM,YAAY,EAAU,EAAc,IAAI,CAAC,KAAK,MAAM,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