{"version":3,"file":"ChildCounter.CSrZSBfa.mjs","names":["useMemo","useState"],"sources":["https:/framerusercontent.com/modules/qHu0jumJZSJiFSjopxvz/aA4njwEXVOpuhLux2M51/ChildCounter.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useMemo}from\"react\";import{addPropertyControls,ControlType,RenderTarget,// @ts-expect-error – Internal\nuseQueryData}from\"framer\";import{fontControls}from\"https://framer.com/m/framer/default-utils.js@^0.45.0\";function DragHandleCounter({dataSource}){const isEditingMode=RenderTarget.current()===RenderTarget.canvas;const count=useMemo(()=>{var _dataSource__props_children,_dataSource_;if(isEditingMode||!(dataSource===null||dataSource===void 0?void 0:(_dataSource_=dataSource[0])===null||_dataSource_===void 0?void 0:(_dataSource__props_children=_dataSource_.props.children)===null||_dataSource__props_children===void 0?void 0:_dataSource__props_children.props.query)){return 0// Will show in the editor\n;}return useQueryData(dataSource[0].props.children.props.query).length;},[dataSource,isEditingMode]);return count;}/**\n * @framerDisableUnlink\n */export default function ChildCounter(props){const[childCount,setChildCount]=useState(0);useEffect(()=>{if(props.filterType!==\"dragHandle\"){let element;if(props.filterType===\"sectionId\"){element=document.getElementById(props.sectionId);}else if(props.filterType===\"ariaLabel\"){element=document.querySelector(`[aria-label=\"${props.ariaLabel}\"]`);}if(element){setChildCount(element.children.length);}else{setChildCount(0);}}},[props.sectionId,props.ariaLabel,props.filterType]);const textStyle={...props.font,color:props.fontColor};return /*#__PURE__*/_jsx(\"div\",{style:textStyle,children:props.filterType===\"dragHandle\"?/*#__PURE__*/_jsx(DragHandleCounter,{dataSource:props.dataSource}):childCount});}ChildCounter.defaultProps={sectionId:\"\",ariaLabel:\"\",filterType:\"sectionId\",fontColor:\"#000000\",font:fontControls.defaultProps,dataSource:null};addPropertyControls(ChildCounter,{filterType:{type:ControlType.Enum,title:\"Filter By\",options:[\"sectionId\",\"ariaLabel\"],optionTitles:[\"Section ID\",\"Aria Label\",\"Drag Handle\"]},sectionId:{type:ControlType.String,title:\"Section ID\",hidden:props=>props.filterType!==\"sectionId\",description:\"Add a section ID to the CMS collection from the right hand panel. Note: The collection item needs to be rendered to see the results in action.\"},ariaLabel:{type:ControlType.String,title:\"Aria Label\",hidden:props=>props.filterType!==\"ariaLabel\",description:\"Add an aria label from the accessibility section on the right hand side to the CMS collection. Note: The collection item needs to be rendered to see the results in action.\"},dataSource:{type:ControlType.ComponentInstance,title:\"Source\",hidden:props=>props.filterType!==\"dragHandle\",description:\"Connect to a CMS collection outside the canvas.\"},fontColor:{type:ControlType.Color,title:\"Font Color\"},font:{type:ControlType.Font,controls:\"extended\",description:\"[via SegmentUI](https://www.segmentUI.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"ChildCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./ChildCounter.map"],"mappings":"2YACyG,SAAS,EAAkB,CAAC,aAAW,CAAC,CAAC,IAAM,EAAc,EAAa,YAAY,EAAa,OAAa,EAAMA,MAAY,CAAC,IAAI,EAA4B,EAC1Q,OAD0R,GAAe,EAAE,KAAa,OAAkC,EAAa,EAAW,KAAM,QAAoC,EAA4B,EAAa,MAAM,WAA0F,MAAM,OAAe,EACnjB,EAAa,EAAW,GAAG,MAAM,SAAS,MAAM,OAAO,MAAQ,EAAC,CAAC,EAAW,EAAc,EAAE,OAAO,CAAO,CAEhH,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,EAAW,EAAc,CAACC,EAAS,GAAG,MAAc,CAAC,GAAG,EAAM,aAAa,aAAa,CAAC,IAAI,EAAW,EAAM,aAAa,YAAa,EAAQ,SAAS,eAAe,EAAM,WAAoB,EAAM,aAAa,cAAa,EAAQ,SAAS,cAAc,gBAAgB,EAAM,UAAU,MAAkB,EAAT,EAAuB,EAAQ,SAAS,OAA4B,EAAK,CAAC,EAAC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