{"version":3,"file":"NetPromoterScore.mfLoMu7v.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/mzr4x8CDQzjgOAATI8cC/zicL3ClFy17iofPjqD2q/NetPromoterScore.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useState,useEffect}from\"react\";import{motion}from\"framer-motion\";import{Border,createBackground,fillProp,borderProp,shadowsProp,HiddenInput}from\"https://framerusercontent.com/modules/DwWOdDzQZGCuvkNlbUjZ/p64C0n6xNEFY9NovSiJw/FramerFormsShared.js\";/**\n * @framerSupportedLayoutWidth fixed\n * @framerSupportedLayoutHeight fixed\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 40\n * @framerDisableUnlink\n */export default function NPSField(props){const{radius,fontColor,border,shadows,gap}=props;const[value,setValue]=useState(null);const[invalid,setInvalid]=useState(false);useEffect(()=>{if(invalid){props.invalidEvent?.();}},[invalid]);function onSetValueEvent(event){const int=parseInt(event.detail);if(int>=0&&int<=props.max){setValue(event.detail);}}return /*#__PURE__*/_jsxs(\"div\",{\"data-framerforms\":true,style:{display:\"flex\",flexDirection:\"row\",userSelect:\"none\",...props.style},onFocus:()=>{props.focusEvent?.();if(invalid){setInvalid(false);}},onBlur:props.blurEvent,children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",style:{display:\"none\"}}),/*#__PURE__*/_jsx(HiddenInput,{name:props.name,required:props.required,value:value,setInvalid:setInvalid,onSetValueEvent:onSetValueEvent}),Array.from({length:props.max+1}).map((_,index)=>{const selected=value===index;const onClick=()=>setValue(selected?null:index);const color=invalid&&fontColor.invalid||(selected?fontColor.on:fontColor.off);const borderColor=invalid&&border?.colorInvalid||(selected?border?.colorOn:border?.colorOff);const boxShadow=invalid&&shadows?.invalid||(selected?shadows?.on:shadows?.off);return /*#__PURE__*/_jsx(\"div\",{style:{flex:1,paddingLeft:index===0?0:gap/2,paddingRight:index===props.max?0:gap/2,cursor:\"pointer\",height:\"100%\"},children:/*#__PURE__*/_jsxs(motion.button,{type:\"button\",onClick:onClick,onKeyDown:event=>{if(event.key==\"Enter\"){onClick();event.preventDefault();}},whileFocus:{...createBackground(props.fill,null,true,invalid),color:fontColor.focus||color,borderColor:border?.colorFocus||borderColor,boxShadow:shadows?.focus||boxShadow},animate:{...createBackground(props.fill,selected,false,invalid),color,borderColor,boxShadow},style:{position:\"relative\",width:\"100%\",height:\"100%\",border:\"none\",outline:\"none\",borderRadius:index===0?`${radius.outer}px ${radius.inner}px ${radius.inner}px ${radius.outer}px`:index===props.max?`${radius.inner}px ${radius.outer}px ${radius.outer}px ${radius.inner}px`:radius.inner,minWidth:props.minWidth,cursor:\"pointer\",backdropFilter:props.bgBlur?`blur(${props.bgBlur}px)`:undefined,...props.font},initial:false,transition:props.transition,children:[index,border&&/*#__PURE__*/_jsx(Border,{...border,transition:props.transition})]})},index);})]});}NPSField.displayName=\"Net Promoter Score\";addPropertyControls(NPSField,{name:{type:ControlType.String,defaultValue:\"Net Promoter Score\",placeholder:\"Name\",preventLocalization:true},required:{type:ControlType.Boolean,defaultValue:false},max:{type:ControlType.Number,defaultValue:10,min:1,step:1,displayStepper:true},font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:12,lineHeight:1}},fontColor:{type:ControlType.Object,buttonTitle:\"Font Color\",title:\"Color\",icon:\"color\",controls:{on:{type:ControlType.Color,defaultValue:\"#FFFFFF\"},off:{type:ControlType.Color,defaultValue:\"#999999\"},focus:{type:ControlType.Color,optional:true},invalid:{type:ControlType.Color,optional:true}}},fill:fillProp({onOff:true,colorOn:\"#0099FF\"}),minWidth:{type:ControlType.Number,defaultValue:30,min:0,step:1},gap:{type:ControlType.Number,defaultValue:5,min:0,step:1},radius:{type:ControlType.Object,controls:{inner:{type:ControlType.Number,defaultValue:5,min:0,step:1},outer:{type:ControlType.Number,defaultValue:10,min:0,step:1}}},border:borderProp({onOff:true,colorOn:\"rgba(136, 136, 136, 0)\"}),shadows:shadowsProp({onOff:true}),bgBlur:{type:ControlType.Number,min:0,max:100,step:1,displayStepper:true,title:\"BG Blur\"},transition:{type:ControlType.Transition,defaultValue:{type:\"spring\",stiffness:2e3,damping:85}},focusEvent:{type:ControlType.EventHandler,title:\"Focus\"},blurEvent:{type:ControlType.EventHandler,title:\"Blur\"},invalidEvent:{type:ControlType.EventHandler,title:\"Invalid\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NPSField\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerSupportedLayoutHeight\":\"fixed\",\"framerIntrinsicWidth\":\"400\",\"framerIntrinsicHeight\":\"40\",\"framerSupportedLayoutWidth\":\"fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NetPromoterScore.map"],"mappings":"8TAMG,SAAwB,EAAS,EAAM,CAAC,GAAK,CAAC,SAAO,YAAU,SAAO,UAAQ,OAAK,EAAW,CAAC,EAAM,GAAUA,EAAS,KAAK,CAAM,CAAC,EAAQ,GAAYA,EAAS,GAAM,CAAC,MAAc,CAAI,GAAS,EAAM,gBAAgB,EAAI,CAAC,EAAQ,CAAC,CAAC,SAAS,EAAgB,EAAM,CAAC,IAAM,EAAI,SAAS,EAAM,OAAO,CAAI,GAAK,GAAG,GAAK,EAAM,KAAK,EAAS,EAAM,OAAO,CAAG,OAAoB,EAAM,MAAM,CAAC,mBAAmB,GAAK,MAAM,CAAC,QAAQ,OAAO,cAAc,MAAM,WAAW,OAAO,GAAG,EAAM,MAAM,CAAC,YAAY,CAAC,EAAM,cAAc,CAAI,GAAS,EAAW,GAAM,EAAI,OAAO,EAAM,UAAU,SAAS,CAAc,EAAK,SAAS,CAAC,KAAK,SAAS,MAAM,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAc,EAAK,EAAY,CAAC,KAAK,EAAM,KAAK,SAAS,EAAM,SAAe,QAA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