{"version":3,"file":"FilteredCollection.BqbES3SM.mjs","names":["useState","p","Children"],"sources":["https:/framerusercontent.com/modules/SSSXjSwAddBsJvVpPLND/pSnD4CN8791a7zY3Oj1W/FilteredCollection.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,Children,isValidElement}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// ─── Code Overrides ──────────────────────────────────────────────────────────\n// Apply these to the EventCard (or item wrapper) inside a CMS Collection List.\n// The EventCard must have component properties connected to CMS fields so the\n// values arrive as props.\nfunction isPastDate(raw,now){if(!raw)return null;const d=new Date(raw);if(isNaN(d.getTime()))return null;return d<now;}const badgeStyle={position:\"absolute\",top:8,right:8,background:\"rgba(0,0,0,0.7)\",color:\"#fff\",fontSize:11,fontWeight:600,padding:\"2px 8px\",borderRadius:4,zIndex:9999,pointerEvents:\"none\",letterSpacing:\"0.5px\"};/**\n * Combined filter for EventCards in a CMS Collection List.\n * Hides cards that are either:\n *   1. Past events (end date has passed)\n *   2. Incomplete (referenced Event data is missing, e.g. the Event is a draft)\n *\n * Filtered items are completely removed from the render tree on both canvas\n * and published site so designers see an accurate preview of the live page.\n *\n * Usage:\n *   1. Add a String property called \"endDate\" to your EventCard component\n *      and connect it to the Event Dates \"End Time\" CMS field.\n *   2. Ensure the EventCard has a \"Title\" property connected to the\n *      Events collection's \"Headline\" field (via collection reference).\n *   3. Apply this single override to the EventCard inside the Collection List.\n */export function withEventFilter(Component){return props=>{const[now,setNow]=useState(()=>new Date);useEffect(()=>{const interval=setInterval(()=>setNow(new Date),6e4);return()=>clearInterval(interval);},[]);// ── Check 1: Is the event in the past? ──\nconst rawEnd=props.endDate??props.$endDate??props.endTime??props.$endTime;const past=isPastDate(rawEnd,now);// ── Check 2: Is the referenced Event data present? ──\n// When an Event Date is published but its referenced Event is still\n// a draft, the title (and other Event fields) will be empty because\n// Framer cannot resolve collection references to draft items.\nconst title=props.Title??props.$Title??props.title??props.$title;const isIncomplete=!title||typeof title===\"string\"&&title.trim()===\"\";const shouldHide=isIncomplete||past===true;// Return null to completely remove from render tree.\n// Using display:none doesn't work on canvas because Framer overrides it.\nif(shouldHide){return null;}return /*#__PURE__*/_jsx(Component,{...props});};}/**\n * Hides CMS items whose end date has passed (upcoming-only filter).\n *\n * Canvas:  Past items are dimmed (0.35 opacity) with a \"PAST\" badge.\n * Preview/Publish: Past items are hidden with display:none.\n *\n * NOTE: Prefer withEventFilter for EventCards — it combines this check with\n * incomplete-data detection in a single override.\n */export function withHideIfPast(Component){return props=>{const[now,setNow]=useState(()=>new Date);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{const interval=setInterval(()=>setNow(new Date),6e4);return()=>clearInterval(interval);},[]);const raw=props.endDate??props.$endDate??props.endTime??props.$endTime;const past=isPastDate(raw,now);if(isCanvas){const label=past===true?\"PAST\":past===false?\"UPCOMING\":\"NO DATE\";const bg=past===true?\"rgba(220,38,38,0.85)\":past===false?\"rgba(22,163,74,0.85)\":\"rgba(120,120,120,0.85)\";return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{...badgeStyle,background:bg,top:4,right:4,fontSize:10,padding:\"2px 6px\"},children:[label,raw?` \\xb7 ${String(raw).slice(0,16)}`:\"\"]}),/*#__PURE__*/_jsx(Component,{...props,style:{...props.style,...past===true?{opacity:.35}:{}}})]});}if(past===true){return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,display:\"none\"}});}return /*#__PURE__*/_jsx(Component,{...props});};}/**\n * Hides CMS items whose end date is in the future (past-only filter).\n * Use this for a \"Past Events\" section.\n *\n * Canvas:  Upcoming items are dimmed with a \"UPCOMING\" badge.\n * Preview/Publish: Upcoming items are hidden with display:none.\n */export function withShowIfPast(Component){return props=>{const[now,setNow]=useState(()=>new Date);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{const interval=setInterval(()=>setNow(new Date),6e4);return()=>clearInterval(interval);},[]);const raw=props.endDate??props.$endDate??props.endTime??props.$endTime;const past=isPastDate(raw,now);if(isCanvas){const label=past===true?\"PAST\":past===false?\"UPCOMING\":\"NO DATE\";const bg=past===true?\"rgba(220,38,38,0.85)\":past===false?\"rgba(22,163,74,0.85)\":\"rgba(120,120,120,0.85)\";return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\"},children:[/*#__PURE__*/_jsxs(\"div\",{style:{...badgeStyle,background:bg,top:4,right:4,fontSize:10,padding:\"2px 6px\"},children:[label,raw?` \\xb7 ${String(raw).slice(0,16)}`:\"\"]}),/*#__PURE__*/_jsx(Component,{...props,style:{...props.style,...past===false?{opacity:.35}:{}}})]});}if(past===false){return /*#__PURE__*/_jsx(Component,{...props,style:{...props.style,display:\"none\"}});}return /*#__PURE__*/_jsx(Component,{...props});};}// ─── Optional Wrapper Code Component ─────────────────────────────────────────\nfunction getEndDate(child){if(!/*#__PURE__*/isValidElement(child))return null;const p=child.props;const raw=p.endDate??p.$endDate??p.endTime??p.$endTime;if(!raw)return null;const d=new Date(raw);return isNaN(d.getTime())?null:d;}export function FilteredCollection({children,filterMode=\"upcoming\",gap=16,columns=3,style}){const[now,setNow]=useState(()=>new Date);const isCanvas=RenderTarget.current()===RenderTarget.canvas;useEffect(()=>{const interval=setInterval(()=>setNow(new Date),6e4);return()=>clearInterval(interval);},[]);const processed=Children.toArray(children).map(child=>{if(filterMode===\"all\")return child;const endDate=getEndDate(child);if(!endDate)return child;const isPast=endDate<now;const shouldHide=filterMode===\"upcoming\"&&isPast||filterMode===\"past\"&&!isPast;if(!shouldHide)return child;if(isCanvas&&/*#__PURE__*/isValidElement(child)){const label=isPast?\"PAST\":\"UPCOMING\";const bg=isPast?\"rgba(0,0,0,0.7)\":\"rgba(0,128,0,0.75)\";return /*#__PURE__*/_jsxs(\"div\",{style:{position:\"relative\",opacity:.35},children:[/*#__PURE__*/_jsx(\"div\",{style:{...badgeStyle,background:bg},children:label}),child]},child.key);}if(/*#__PURE__*/isValidElement(child)){return null;}return null;});return /*#__PURE__*/_jsx(\"div\",{style:{display:\"grid\",gridTemplateColumns:`repeat(${columns}, 1fr)`,gap:`${gap}px`,width:\"100%\",...style},children:processed});}addPropertyControls(FilteredCollection,{children:{type:ControlType.Array,title:\"Content\",control:{type:ControlType.ComponentInstance}},filterMode:{type:ControlType.Enum,title:\"Show\",options:[\"upcoming\",\"past\",\"all\"],optionTitles:[\"Upcoming Only\",\"Past Only\",\"All\"],defaultValue:\"upcoming\"},columns:{type:ControlType.Number,title:\"Columns\",defaultValue:3,min:1,max:6,step:1},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:16,min:0,max:64,step:4}});\nexport const __FramerMetadata__ = {\"exports\":{\"withShowIfPast\":{\"type\":\"reactHoc\",\"name\":\"withShowIfPast\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"FilteredCollection\":{\"type\":\"reactComponent\",\"name\":\"FilteredCollection\",\"slots\":[\"children\"],\"annotations\":{\"framerContractVersion\":\"1\"}},\"withEventFilter\":{\"type\":\"reactHoc\",\"name\":\"withEventFilter\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"withHideIfPast\":{\"type\":\"reactHoc\",\"name\":\"withHideIfPast\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./FilteredCollection.map"],"mappings":"8MAIA,SAAS,EAAW,EAAI,EAAI,CAAC,GAAG,CAAC,EAAI,OAAO,KAAK,IAAM,EAAE,IAAI,KAAK,EAAI,CAAmC,OAA/B,MAAM,EAAE,SAAS,CAAC,CAAQ,KAAY,EAAE,EAe/G,SAAgB,EAAgB,EAAU,CAAC,MAAO,IAAO,CAAC,GAAK,CAAC,EAAI,GAAQA,MAAa,IAAI,KAAK,CAAC,MAAc,CAAC,IAAM,EAAS,gBAAgB,EAAO,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,cAAc,EAAS,EAAG,EAAE,CAAC,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