{"version":3,"file":"CMSItemCountLabel.63Rec0Aw.mjs","names":["useState","useSuperfieldsStore","superfieldsId","CMSItemCountLabel","OriginalCMSItemCountLabel"],"sources":["https:/framerusercontent.com/modules/j3C7bfLtfNLDSTKe4iIP/9hugTto8oj4Q9xTQfirA/CMSItemCountLabel.js","https:/framerusercontent.com/modules/XGO1VOG2GVk2wLhaPQ70/lUJFbrgnCTi0UkBYEsEB/CMSItemCountLabel.js"],"sourcesContent":["import{jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget,// @ts-ignore\nuseQueryData}from\"framer\";import{superfieldsId}from\"https://framerusercontent.com/modules/FZjYlw33eNo8pxLbSFLX/NS2M1g7qVI7y5CFDNb6m/SuperfieldsShared.js\";import{getCollectionData}from\"https://framerusercontent.com/modules/PNm0aYRdp2Urx1MCseUn/ELGxjV92WFMoGKTv2Ojs/CMSLibrary.js\";import useSuperfieldsStore from\"https://framerusercontent.com/modules/OoGHZMzWDzm2mNN7bmeR/UmOIjvpgKrLZznysVdbK/Store.js\";import{useState,useEffect}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n */export default function CMSItemCountLabel(props){const{superfieldsId,transform}=props;const isCanvas=RenderTarget.current()===RenderTarget.canvas;const collectionList=props.collectionList?.[0];const[initialized,setInitialized]=useState(false);const{query}=getCollectionData(collectionList);const totalItems=useSuperfieldsStore(superfieldsId,state=>state.totalItems);useEffect(()=>{setInitialized(true);},[]);let items=0;// Only display number of CMS items in the preview and live website.\nif(!isCanvas){if(props.type===\"cms\"){if(query){items=useQueryData(query).length;}}else if(initialized){items=totalItems;}}let prefix=\"\";let suffix=\"\";if(transform){if(transform.plural){prefix=items==1?transform.singularPrefix:transform.pluralPrefix;suffix=items==1?transform.singularSuffix:transform.pluralSuffix;}else{prefix=transform.prefix;suffix=transform.suffix;}}return /*#__PURE__*/_jsxs(\"div\",{\"data-superfields\":true,style:{color:props.color,userSelect:props.selectable?\"auto\":\"none\",margin:0,whiteSpace:props.style?.width?undefined:\"nowrap\",...props.font,...props.style},children:[prefix,formatNumber(items,props.commas),suffix]});}CMSItemCountLabel.displayName=\"CMS Item Count Label\";addPropertyControls(CMSItemCountLabel,{type:{type:ControlType.Enum,defaultValue:\"cms\",options:[\"cms\",\"superfields\"],optionTitles:[\"CMS Collection List\",\"Superfields\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},collectionList:{type:ControlType.ComponentInstance,hidden:props=>props.type!==\"cms\"},...superfieldsId({hidden:props=>props.type!==\"superfields\"}),font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1}},color:{type:ControlType.Color,defaultValue:\"#000\"},commas:{type:ControlType.Boolean,defaultValue:true},transform:{type:ControlType.Object,optional:true,controls:{plural:{type:ControlType.Boolean,defaultValue:false},prefix:{type:ControlType.String,hidden:props=>props.plural},suffix:{type:ControlType.String,hidden:props=>props.plural},singularPrefix:{type:ControlType.String,placeholder:\"Singular Prefix\",hidden:props=>!props.plural},singularSuffix:{type:ControlType.String,placeholder:\"Singular Suffix\",hidden:props=>!props.plural},pluralPrefix:{type:ControlType.String,placeholder:\"Plural Prefix\",hidden:props=>!props.plural},pluralSuffix:{type:ControlType.String,placeholder:\"Plural Suffix\",hidden:props=>!props.plural}}},selectable:{type:ControlType.Boolean,defaultValue:true,title:\"Text Select\"}});function formatNumber(value,commas){let numberString=value.toFixed(0);if(commas){numberString=numberString.replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");}return numberString;}\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSItemCountLabel\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerDisableUnlink\":\"\",\"framerSupportedLayoutWidth\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}","import{jsx as _jsx}from\"react/jsx-runtime\";import{ControlType}from\"framer\";import{superfieldsId}from\"https://framerusercontent.com/modules/FZjYlw33eNo8pxLbSFLX/NS2M1g7qVI7y5CFDNb6m/SuperfieldsShared.js\";import{addPropertyControlsV2}from\"https://framerusercontent.com/modules/wzF1aUkHoslINE1PWbP0/qhB83x3iUbFnEMsNrwn1/Shared.js\";import OriginalCMSItemCountLabel from\"https://framerusercontent.com/modules/j3C7bfLtfNLDSTKe4iIP/9hugTto8oj4Q9xTQfirA/CMSItemCountLabel.js\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n */export default function CMSItemCountLabel(props){const advanced=props.mode===\"advanced\";return /*#__PURE__*/_jsx(OriginalCMSItemCountLabel,{type:props.type,collectionList:props.collectionList,font:props.styling.font,color:props.styling.color,commas:props.styling.commas,transform:props.styling.transform?{plural:props.styling.transform.mode===\"plural\",...props.styling.transform}:undefined,superfieldsId:advanced?props.settings.superfieldsId:0,selectable:props.styling.userSelect,style:props.style});}CMSItemCountLabel.displayName=\"CMS Item Count Label\";addPropertyControlsV2(CMSItemCountLabel,{type:{type:ControlType.Enum,defaultValue:\"superfields\",options:[\"superfields\",\"cms\"],optionTitles:[\"Superfields\",\"CMS Collection List\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},collectionList:{type:ControlType.ComponentInstance,hidden:props=>props.type!==\"cms\"},styling:{type:ControlType.Object,title:\"Styling 🎨\",buttonTitle:\"Options\",description:\"Update the button styling.\",controls:{font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:14,lineHeight:1}},color:{type:ControlType.Color,defaultValue:\"#999999\"},commas:{type:ControlType.Boolean,defaultValue:true},transform:{type:ControlType.Object,optional:true,controls:{mode:{type:ControlType.Enum,defaultValue:\"basic\",options:[\"basic\",\"plural\"],optionTitles:[\"Basic\",\"Plural\"],displaySegmentedControl:true},prefix:{type:ControlType.String,defaultValue:\"Items: \",hidden:props=>props.mode!==\"basic\"},suffix:{type:ControlType.String,defaultValue:\"\",hidden:props=>props.mode!==\"basic\"},singularPrefix:{type:ControlType.String,defaultValue:\"\",placeholder:\"Singular Prefix\",hidden:props=>props.mode!==\"plural\"},singularSuffix:{type:ControlType.String,defaultValue:\" item\",placeholder:\"Singular Suffix\",description:\"Shown when count is 1\",hidden:props=>props.mode!==\"plural\"},pluralPrefix:{type:ControlType.String,defaultValue:\"\",placeholder:\"Plural Prefix\",hidden:props=>props.mode!==\"plural\"},pluralSuffix:{type:ControlType.String,defaultValue:\" items\",placeholder:\"Plural Suffix\",description:\"Shown when count is not 1\",hidden:props=>props.mode!==\"plural\"}}},userSelect:{type:ControlType.Boolean,defaultValue:true}}},settings:{type:ControlType.Object,advanced:true,controls:{...superfieldsId({hidden:props=>props.type!==\"superfields\"})}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CMSItemCountLabel\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}"],"mappings":"qUAKG,SAAwB,EAAkB,EAAM,CAAC,GAAK,CAAC,cAAA,EAAc,aAAW,EAAY,EAAS,EAAa,SAAS,GAAG,EAAa,OAAa,EAAe,EAAM,iBAAiB,GAAQ,CAAC,EAAY,GAAgBA,EAAS,GAAM,CAAM,CAAC,SAAO,EAAkB,EAAe,CAAO,EAAWC,EAAoBC,EAAc,GAAO,EAAM,WAAW,CAAC,MAAc,CAAC,EAAe,GAAK,EAAG,EAAE,CAAC,CAAC,IAAI,EAAM,EACja,IAAa,EAAM,OAAO,MAAU,IAAO,EAAM,EAAa,EAAM,CAAC,QAAiB,IAAa,EAAM,IAAa,IAAI,EAAO,GAAO,EAAO,GAA8N,OAAxN,IAAc,EAAU,QAAQ,EAAO,GAAO,EAAE,EAAU,eAAe,EAAU,aAAa,EAAO,GAAO,EA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