{"version":3,"file":"HidePastEvent.CSUtZlBG.mjs","names":["useRef"],"sources":["https:/framerusercontent.com/modules/0hCvct6Da5IGMduP07wr/Q2de6LDVELWHaU1VzYw7/HidePastEvent.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useEffect,useRef}from\"react\";const PAST_ATTR=\"data-vw-past\";const MODE_ATTR=\"data-vw-mode\";const DEFAULT_ROW='[data-framer-name=\"Music Row\"]';// An event counts as past once its whole calendar day has ended. The CMS stores\n// the date as UTC midnight, so read the calendar parts in UTC and rebuild the end\n// of that day in the visitor's local time — otherwise a timezone behind UTC hides\n// the event a day early.\nfunction isPastDay(value,grace){const when=new Date(value);if(Number.isNaN(when.getTime()))return false;const endOfDay=new Date(when.getUTCFullYear(),when.getUTCMonth(),when.getUTCDate(),23,59,59,999);return endOfDay.getTime()+grace*36e5<Date.now();}// Framer applies the Collection List `limit` before this runs, so the list\n// over-fetches and this trims it back to `maxRows` once past rows are removed.\nfunction sweep(container,maxRows){// \"upcoming\" keeps future rows (the original behaviour); \"past\" inverts it.\nconst wantPast=container.getAttribute(MODE_ATTR)===\"past\";const rows=Array.from(container.children);let shown=0;for(const el of rows){if(!el.hasAttribute(PAST_ATTR))continue;const past=el.getAttribute(PAST_ATTR)===\"true\";const hide=past!==wantPast||maxRows>0&&shown>=maxRows;el.style.display=hide?\"none\":\"\";if(!hide)shown++;}}/**\n * Hide Past Event\n *\n * Drop inside a CMS list row and bind `date` to that item's date field. Once the\n * date has passed the whole row is hidden in Preview and on the published site.\n * Framer's CMS date filters only accept a fixed date, so this fills that gap.\n * Renders nothing, and stays inert on the canvas so rows remain visible while designing.\n *\n * @framerIntrinsicWidth 1\n * @framerIntrinsicHeight 1\n *\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n */export default function HidePastEvent(props){const{date,row=DEFAULT_ROW,maxRows=4,grace=0,mode=\"upcoming\"}=props;const ref=useRef(null);useEffect(()=>{if(typeof window===\"undefined\")return;if(RenderTarget.current()===RenderTarget.canvas)return;const el=ref.current;if(!el||!date||!row)return;let target=null;try{target=el.closest(row);}catch{return;// invalid selector\n}const container=target?.parentElement;if(!target||!container)return;target.setAttribute(PAST_ATTR,String(isPastDay(date,grace)));container.setAttribute(MODE_ATTR,mode);// Let every sibling row register itself first, then decide as a group.\n// setTimeout, not requestAnimationFrame: rAF never fires in hidden/background\n// tabs, which left rows unswept until the tab was fronted.\nconst timer=setTimeout(()=>sweep(container,maxRows),0);return()=>clearTimeout(timer);},[date,row,maxRows,grace,mode]);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{position:\"relative\",display:\"none\"}});}addPropertyControls(HidePastEvent,{mode:{type:ControlType.Enum,title:\"Show\",options:[\"upcoming\",\"past\"],optionTitles:[\"Upcoming only\",\"Past only\"],defaultValue:\"upcoming\"},date:{type:ControlType.Date,title:\"Date\",description:\"Bind to the event's Date field.\",optional:true},row:{type:ControlType.String,title:\"Row\",defaultValue:DEFAULT_ROW,description:\"CSS selector for the repeated row to hide.\"},maxRows:{type:ControlType.Number,title:\"Max Rows\",defaultValue:4,min:0,max:20,step:1,description:\"0 shows every upcoming row.\"},grace:{type:ControlType.Number,title:\"Grace\",defaultValue:0,min:0,max:72,step:1,unit:\"h\",description:\"Keep showing this long after the event day ends.\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"HidePastEvent\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"fixed\",\"framerIntrinsicWidth\":\"1\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"1\",\"framerSupportedLayoutHeight\":\"fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./HidePastEvent.map"],"mappings":"sMAIA,SAAS,EAAU,EAAM,EAAM,CAAC,IAAM,EAAK,IAAI,KAAK,CAAK,EAAgJ,MAA9I,CAAG,OAAO,MAAM,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