{"version":3,"file":"Ratinginput.KBLkSaVW.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/d9jBrHUDhrMUG2n11ObV/ndat4YK6IDPbB1xtvC5O/Ratinginput.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{useState,useEffect,useRef}from\"react\";import{motion}from\"framer-motion\";import{useInstanceId,HiddenInput}from\"https://framer.com/m/Framerformsshared-EztY9g.js\";// ============================================================================\n// CONSTANTS\n// ============================================================================\nconst STAR_SVG_PATH=\"M 18.097 2.289 C 18.693 0.441 21.307 0.441 21.903 2.289 L 25.136 12.312 C 25.403 13.14 26.174 13.7 27.044 13.698 L 37.575 13.675 C 39.517 13.671 40.325 16.158 38.751 17.296 L 30.218 23.467 C 29.513 23.977 29.219 24.884 29.489 25.71 L 32.765 35.719 C 33.37 37.565 31.254 39.101 29.686 37.957 L 21.179 31.748 C 20.477 31.235 19.523 31.235 18.821 31.748 L 10.314 37.957 C 8.746 39.101 6.63 37.565 7.235 35.719 L 10.511 25.71 C 10.781 24.884 10.487 23.977 9.782 23.467 L 1.249 17.296 C -0.325 16.158 0.483 13.671 2.425 13.675 L 12.956 13.698 C 13.826 13.7 14.597 13.14 14.864 12.312 Z\";// ============================================================================\n// MAIN COMPONENT\n// ============================================================================\n/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n */export default function RatingInput(props){const{appearance,size,fill,border,totalStars}=props;const componentId=useInstanceId();const isCanvasMode=RenderTarget.current()===RenderTarget.canvas;const inputRef=useRef(null);const[currentRating,setCurrentRating]=useState(0);const[focusedStarIndex,setFocusedStarIndex]=useState(-1);const[isInvalid,setIsInvalid]=useState(false);const displayRating=isCanvasMode?Math.min(Math.max(props.preview,0),totalStars):currentRating;// Dispatch change event when value changes so FormPersistence knows to save\nuseEffect(()=>{if(inputRef.current){inputRef.current.dispatchEvent(new Event(\"input\",{bubbles:true}));inputRef.current.dispatchEvent(new Event(\"change\",{bubbles:true}));}},[currentRating]);useEffect(()=>{if(isInvalid){props.invalidEvent?.();}},[isInvalid]);// ========================================================================\n// EVENT HANDLERS (HTML callbacks - prefixed with handle)\n// ========================================================================\nfunction handleSetValueEvent(event){const value=event.detail;// Handle both string and number values\nconst parsedValue=typeof value===\"number\"?value:parseInt(value,10);if(!isNaN(parsedValue)&&parsedValue>=0&&parsedValue<=totalStars){setCurrentRating(parsedValue);}}function handleStarClick(starIndex){setCurrentRating(displayRating==starIndex+1?0:starIndex+1);}function handleStarKeyDown(event,starIndex){if(event.key==\"Enter\"){handleStarClick(starIndex);event.preventDefault();}}function handleStarFocus(starIndex){setFocusedStarIndex(starIndex);if(isInvalid){setIsInvalid(false);}props.focusEvent?.();}function handleStarBlur(){setFocusedStarIndex(-1);props.blurEvent?.();}// ========================================================================\n// RENDER HELPERS\n// ========================================================================\nfunction _renderStars(){const stars=[];for(let i=0;i<totalStars;i++){const isStarFilled=i+1<=displayRating;if(appearance==\"default\"){const isStarFocused=focusedStarIndex>=0&&i<=focusedStarIndex;stars.push(/*#__PURE__*/_jsx(motion.button,{type:\"button\",onClick:()=>handleStarClick(i),onFocus:()=>handleStarFocus(i),onBlur:handleStarBlur,animate:{color:isInvalid&&border?.invalidColor||isStarFocused&&border?.focusColor||(isStarFilled?border?.filledColor:border?.emptyColor)},style:{appearance:\"none\",border:\"none\",background:\"none\",cursor:\"pointer\",padding:0},initial:false,transition:props.transition,children:/*#__PURE__*/_jsxs(\"svg\",{xmlns:\"http://www.w3.org/2000/svg\",viewBox:\"0 0 40 40\",width:size,height:size,style:{display:\"block\"},children:[border&&/*#__PURE__*/_jsx(\"defs\",{children:/*#__PURE__*/_jsx(\"clipPath\",{id:\"clip-path\",children:/*#__PURE__*/_jsx(\"path\",{d:STAR_SVG_PATH})})}),/*#__PURE__*/_jsx(\"path\",{d:STAR_SVG_PATH,fill:isInvalid&&fill.colorInvalid||isStarFocused&&fill.colorFocus||(isStarFilled?fill.colorOn:fill.colorOff),stroke:\"currentColor\",strokeWidth:border?border.width*2:0,clipPath:border?\"url(#clip-path)\":undefined,vectorEffect:\"non-scaling-stroke\"})]})},i));}else{stars.push(/*#__PURE__*/_jsx(\"button\",{type:\"button\",onClick:()=>handleStarClick(i),onKeyDown:e=>handleStarKeyDown(e,i),style:{appearance:\"none\",border:\"none\",background:\"none\",cursor:\"pointer\",padding:0},children:isStarFilled?props.filledStar:props.emptyStar},i));}}return stars;}// ========================================================================\n// RENDER\n// ========================================================================\nreturn /*#__PURE__*/_jsxs(\"div\",{\"data-framerforms\":true,id:componentId,style:{display:\"flex\",flexDirection:\"row\",gap:props.gap,alignItems:\"center\",justifyContent:\"center\",...props.style},children:[/*#__PURE__*/_jsx(\"button\",{type:\"button\",style:{display:\"none\"}}),/*#__PURE__*/_jsx(HiddenInput,{ref:inputRef,name:props.name,required:props.required,value:displayRating<=0?\"\":displayRating,setInvalid:setIsInvalid,onSetValueEvent:handleSetValueEvent}),_renderStars(),/*#__PURE__*/_jsx(\"style\",{dangerouslySetInnerHTML:{__html:`#${componentId} button:focus { outline: none;}`}})]});}RatingInput.displayName=\"Rating Input\";// ============================================================================\n// PROPERTY CONTROLS\n// ============================================================================\naddPropertyControls(RatingInput,{name:{type:ControlType.String,defaultValue:\"Rating\",preventLocalization:true},required:{type:ControlType.Boolean,defaultValue:false},totalStars:{type:ControlType.Number,defaultValue:5,min:2,step:1,displayStepper:true},preview:{type:ControlType.Number,defaultValue:3,min:0,step:1,displayStepper:true},appearance:{type:ControlType.Enum,defaultValue:\"default\",options:[\"default\",\"custom\"],optionTitles:[\"Default\",\"Custom\"],displaySegmentedControl:true},fill:{type:ControlType.Object,buttonTitle:\"Colors\",// @ts-ignore - Framer supports \"icon\" property (not in our TS typings)\nicon:\"color\",controls:{colorOn:{type:ControlType.Color,defaultValue:\"#FFB92E\",optional:true,title:\"Filled\"},colorOff:{type:ControlType.Color,defaultValue:\"rgba(187, 187, 187, 0.15)\",optional:true,title:\"Empty\"},colorFocus:{type:ControlType.Color,optional:true,title:\"Focus\"},colorInvalid:{type:ControlType.Color,optional:true,title:\"Invalid\"}},hidden:props=>props.appearance!==\"default\"},border:{type:ControlType.Object,optional:true,buttonTitle:\"Border\",defaultValue:{filledColor:\"rgba(136, 136, 136, 0)\",emptyColor:\"rgba(136, 136, 136, 0.1)\",width:1},controls:{filledColor:{type:ControlType.Color,defaultValue:\"rgba(136, 136, 136, 0)\",title:\"Filled\"},emptyColor:{type:ControlType.Color,defaultValue:\"rgba(136, 136, 136, 0.1)\",title:\"Empty\"},focusColor:{type:ControlType.Color,defaultValue:\"#FFB92E\",title:\"Focus\",optional:true},invalidColor:{type:ControlType.Color,defaultValue:\"#FF5A6F\",title:\"Invalid\",optional:true},width:{type:ControlType.Number,defaultValue:1,min:1,step:1,displayStepper:true}},hidden:props=>props.appearance!==\"default\"},size:{type:ControlType.Number,defaultValue:32,min:1,step:1,hidden:props=>props.appearance!==\"default\"},gap:{type:ControlType.Number,defaultValue:5,min:0,hidden:props=>props.appearance!==\"default\"},transition:{type:ControlType.Transition,defaultValue:{type:false},hidden:props=>props.appearance!==\"default\",description:\"by [FormsPlugin](https://formsplugin.com)\"},filledStar:{type:ControlType.ComponentInstance,title:\"Filled\",hidden:props=>props.appearance!==\"custom\"},emptyStar:{type:ControlType.ComponentInstance,title:\"Empty\",description:\"Connect custom layers outside of the page breakpoint\",hidden:props=>props.appearance!==\"custom\"},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\":\"RatingInput\",\"slots\":[\"filledStar\",\"emptyStar\"],\"annotations\":{\"framerSupportedLayoutHeight\":\"any\",\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\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