Socket
Socket
Sign inDemoInstall

react-simple-star-rating

Package Overview
Dependencies
5
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.5 to 5.1.6

2

dist/index.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=function(){return o=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)};function n(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function i(t){var n=t.size,i=void 0===n?25:n,r=t.SVGstrokeColor,l=void 0===r?"currentColor":r,a=t.SVGstorkeWidth,s=void 0===a?0:a,c=t.SVGclassName,d=void 0===c?"star-svg":c,u=t.SVGstyle;return e.jsx("svg",o({className:d,style:u,stroke:l,fill:"currentColor",strokeWidth:s,viewBox:"0 0 24 24",width:i,height:i,xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})}))}function r(e,t){switch(t.type){case"PointerMove":return o(o({},e),{hoverValue:t.payload,hoverIndex:t.index});case"PointerLeave":return o(o({},e),{ratingValue:e.ratingValue,hoverIndex:0,hoverValue:null});case"MouseClick":return o(o({},e),{valueIndex:e.hoverIndex,ratingValue:t.payload});default:return e}}var l="style-module_starRatingWrap__q-lJC",a="style-module_simpleStarRating__nWUxf",s="style-module_fillIcons__6---A",c="style-module_emptyIcons__Bg-FZ",d="style-module_tooltip__tKc3i";function u(){return"undefined"!=typeof window&&window.matchMedia("(pointer: coarse)").matches||"ontouchstart"in window||"undefined"!=typeof navigator&&navigator.maxTouchPoints>0}!function(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".style-module_starRatingWrap__q-lJC{display:inline-block;touch-action:none}.style-module_simpleStarRating__nWUxf{display:inline-block;overflow:hidden;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;white-space:nowrap}.style-module_fillIcons__6---A{display:inline-block;overflow:hidden;position:absolute;top:0;white-space:nowrap}.style-module_emptyIcons__Bg-FZ{display:inline-block}.style-module_tooltip__tKc3i{background-color:#333;border-radius:5px;color:#fff;display:inline-block;padding:5px 15px;vertical-align:middle}"),exports.Rating=function(v){var p,f,h=v.onClick,y=v.onPointerMove,m=v.onPointerEnter,g=v.onPointerLeave,x=v.initialValue,_=void 0===x?0:x,C=v.iconsCount,w=void 0===C?5:C,V=v.size,k=void 0===V?40:V,S=v.readonly,b=void 0!==S&&S,M=v.rtl,G=void 0!==M&&M,I=v.customIcons,N=void 0===I?[]:I,j=v.allowFraction,P=void 0!==j&&j,A=v.style,L=v.className,R=void 0===L?"react-simple-star-rating":L,W=v.transition,T=void 0!==W&&W,z=v.allowHover,B=void 0===z||z,E=v.disableFillHover,F=void 0!==E&&E,q=v.fillIcon,O=void 0===q?null:q,H=v.fillColor,J=void 0===H?"#ffbc0b":H,K=v.fillColorArray,U=void 0===K?[]:K,Z=v.fillStyle,D=v.fillClassName,X=void 0===D?"filled-icons":D,Y=v.emptyIcon,Q=void 0===Y?null:Y,$=v.emptyColor,ee=void 0===$?"#cccccc":$,te=v.emptyStyle,oe=v.emptyClassName,ne=void 0===oe?"empty-icons":oe,ie=v.showTooltip,re=void 0!==ie&&ie,le=v.tooltipDefaultText,ae=void 0===le?"Your Rate":le,se=v.tooltipArray,ce=void 0===se?[]:se,de=v.tooltipStyle,ue=v.tooltipClassName,ve=void 0===ue?"react-simple-star-rating-tooltip":ue,pe=v.SVGclassName,fe=void 0===pe?"star-svg":pe,he=v.titleSeparator,ye=void 0===he?"out of":he,me=v.SVGstyle,ge=v.SVGstorkeWidth,xe=void 0===ge?0:ge,_e=v.SVGstrokeColor,Ce=void 0===_e?"currentColor":_e,we=t.useReducer(r,{hoverIndex:0,valueIndex:0,ratingValue:_,hoverValue:null}),Ve=we[0],ke=Ve.ratingValue,Se=Ve.hoverValue,be=Ve.hoverIndex,Me=Ve.valueIndex,Ge=we[1];console.log(ke,Se,be,Me,_),t.useEffect((function(){_&&Ge({type:"MouseClick",payload:0})}),[_]);var Ie=t.useMemo((function(){return P?2*w:w}),[P,w]),Ne=t.useMemo((function(){return _>Ie?0:P||Math.floor(_)===_?Math.round(_/w*100):2*Math.ceil(_)*10}),[P,_,w,Ie]),je=t.useMemo((function(){return(P?2*_-1:_-1)||0}),[P,_]),Pe=t.useCallback((function(e){return w%2!=0?e/2/10:e/w}),[w]),Ae=function(e){for(var t=e.clientX,o=e.currentTarget.children[0].getBoundingClientRect(),n=o.left,i=o.right,r=o.width,l=G?i-t:t-n,a=Ie,s=Math.round(r/Ie),c=0;c<=Ie;c+=1)if(l<=s*c){a=0===c&&l<s?0:c;break}var d=a-1;a>0&&(Ge({type:"PointerMove",payload:100*a/Ie,index:d}),y&&Se&&y(Pe(Se),d,e))},Le=function(e){Se&&(Ge({type:"MouseClick",payload:Se}),h&&h(Pe(Se),be,e))},Re=t.useMemo((function(){if(B){if(F){var e=ke&&ke||Ne;return Se&&Se>e?Se:e}return Se&&Se||ke&&ke||Ne}return ke&&ke||Ne}),[B,F,Se,ke,Ne]);t.useEffect((function(){ce.length>Ie&&console.error("tooltipArray Array length is bigger then Icons Count length.")}),[ce.length,Ie]);var We=t.useCallback((function(e){return Se&&e[be]||ke&&e[Me]||_&&e[je]}),[Se,be,ke,Me,_,je]),Te=t.useMemo((function(){return Se&&Pe(Se)||ke&&Pe(ke)||_&&Pe(Ne)}),[Se,Pe,ke,_,Ne]);return e.jsxs("span",o({className:l,style:{direction:"".concat(G?"rtl":"ltr")}},{children:[e.jsxs("span",o({className:"".concat(a," ").concat(R),style:o({cursor:b?"":"pointer"},A),onPointerMove:b?void 0:Ae,onPointerEnter:b?void 0:function(e){m&&m(e),u()&&Ae(e)},onPointerLeave:b?void 0:function(e){u()&&Le(),Ge({type:"PointerLeave"}),g&&g(e)},onClick:b?void 0:Le,"aria-hidden":"true"},{children:[e.jsx("span",o({className:"".concat(c," ").concat(ne),style:o({color:ee},te)},{children:n([],Array(w),!0).map((function(o,n){var r;return e.jsx(t.Fragment,{children:(null===(r=N[n])||void 0===r?void 0:r.icon)||Q||e.jsx(i,{SVGclassName:fe,SVGstyle:me,SVGstorkeWidth:xe,SVGstrokeColor:Ce,size:k})},n)}))})),e.jsx("span",o({className:"".concat(s," ").concat(X),style:o((p={},p[G?"right":"left"]=0,p.color=We(U)||J,p.transition=T?"width .2s ease, color .2s ease":"",p.width="".concat(Re,"%"),p),Z),title:"".concat(Se&&Pe(Se)||Pe(Ne)," ").concat(ye," ").concat(w)},{children:n([],Array(w),!0).map((function(o,n){var r;return e.jsx(t.Fragment,{children:(null===(r=N[n])||void 0===r?void 0:r.icon)||O||e.jsx(i,{SVGclassName:fe,SVGstyle:me,SVGstorkeWidth:xe,SVGstrokeColor:Ce,size:k})},n)}))}))]})),re&&e.jsx("span",o({className:"".concat(d," ").concat(ve),style:o((f={},f[G?"marginRight":"marginLeft"]=20,f),de)},{children:(ce.length>0?We(ce):Te)||ae}))]}))};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),o=function(){return o=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var i in t=arguments[o])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},o.apply(this,arguments)};function n(e,t,o){if(o||2===arguments.length)for(var n,i=0,r=t.length;i<r;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}function i(t){var n=t.size,i=void 0===n?25:n,r=t.SVGstrokeColor,l=void 0===r?"currentColor":r,a=t.SVGstorkeWidth,s=void 0===a?0:a,c=t.SVGclassName,d=void 0===c?"star-svg":c,u=t.SVGstyle;return e.jsx("svg",o({className:d,style:u,stroke:l,fill:"currentColor",strokeWidth:s,viewBox:"0 0 24 24",width:i,height:i,xmlns:"http://www.w3.org/2000/svg"},{children:e.jsx("path",{d:"M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"})}))}function r(e,t){switch(t.type){case"PointerMove":return o(o({},e),{hoverValue:t.payload,hoverIndex:t.index});case"PointerLeave":return o(o({},e),{ratingValue:e.ratingValue,hoverIndex:0,hoverValue:null});case"MouseClick":return o(o({},e),{valueIndex:e.hoverIndex,ratingValue:t.payload});default:return e}}var l="style-module_starRatingWrap__q-lJC",a="style-module_simpleStarRating__nWUxf",s="style-module_fillIcons__6---A",c="style-module_emptyIcons__Bg-FZ",d="style-module_tooltip__tKc3i";function u(){return"undefined"!=typeof window&&window.matchMedia("(pointer: coarse)").matches||"ontouchstart"in window||"undefined"!=typeof navigator&&navigator.maxTouchPoints>0}!function(e,t){void 0===t&&(t={});var o=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===o&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=e:i.appendChild(document.createTextNode(e))}}(".style-module_starRatingWrap__q-lJC{display:inline-block;touch-action:none}.style-module_simpleStarRating__nWUxf{display:inline-block;overflow:hidden;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;white-space:nowrap}.style-module_fillIcons__6---A{display:inline-block;overflow:hidden;position:absolute;top:0;white-space:nowrap}.style-module_emptyIcons__Bg-FZ{display:inline-block}.style-module_tooltip__tKc3i{background-color:#333;border-radius:5px;color:#fff;display:inline-block;padding:5px 15px;vertical-align:middle}"),exports.Rating=function(v){var p,f,h=v.onClick,y=v.onPointerMove,m=v.onPointerEnter,g=v.onPointerLeave,x=v.initialValue,_=void 0===x?0:x,C=v.iconsCount,w=void 0===C?5:C,V=v.size,k=void 0===V?40:V,S=v.readonly,b=void 0!==S&&S,M=v.rtl,G=void 0!==M&&M,I=v.customIcons,N=void 0===I?[]:I,j=v.allowFraction,P=void 0!==j&&j,A=v.style,L=v.className,R=void 0===L?"react-simple-star-rating":L,W=v.transition,T=void 0!==W&&W,z=v.allowHover,B=void 0===z||z,E=v.disableFillHover,F=void 0!==E&&E,q=v.fillIcon,O=void 0===q?null:q,H=v.fillColor,J=void 0===H?"#ffbc0b":H,K=v.fillColorArray,U=void 0===K?[]:K,Z=v.fillStyle,D=v.fillClassName,X=void 0===D?"filled-icons":D,Y=v.emptyIcon,Q=void 0===Y?null:Y,$=v.emptyColor,ee=void 0===$?"#cccccc":$,te=v.emptyStyle,oe=v.emptyClassName,ne=void 0===oe?"empty-icons":oe,ie=v.showTooltip,re=void 0!==ie&&ie,le=v.tooltipDefaultText,ae=void 0===le?"Your Rate":le,se=v.tooltipArray,ce=void 0===se?[]:se,de=v.tooltipStyle,ue=v.tooltipClassName,ve=void 0===ue?"react-simple-star-rating-tooltip":ue,pe=v.SVGclassName,fe=void 0===pe?"star-svg":pe,he=v.titleSeparator,ye=void 0===he?"out of":he,me=v.SVGstyle,ge=v.SVGstorkeWidth,xe=void 0===ge?0:ge,_e=v.SVGstrokeColor,Ce=void 0===_e?"currentColor":_e,we=t.useReducer(r,{hoverIndex:0,valueIndex:0,ratingValue:_,hoverValue:null}),Ve=we[0],ke=Ve.ratingValue,Se=Ve.hoverValue,be=Ve.hoverIndex,Me=Ve.valueIndex,Ge=we[1];t.useEffect((function(){_&&Ge({type:"MouseClick",payload:0})}),[_]);var Ie=t.useMemo((function(){return P?2*w:w}),[P,w]),Ne=t.useMemo((function(){return _>Ie?0:P||Math.floor(_)===_?Math.round(_/w*100):2*Math.ceil(_)*10}),[P,_,w,Ie]),je=t.useMemo((function(){return(P?2*_-1:_-1)||0}),[P,_]),Pe=t.useCallback((function(e){return w%2!=0?e/2/10:e/w}),[w]),Ae=function(e){for(var t=e.clientX,o=e.currentTarget.children[0].getBoundingClientRect(),n=o.left,i=o.right,r=o.width,l=G?i-t:t-n,a=Ie,s=Math.round(r/Ie),c=0;c<=Ie;c+=1)if(l<=s*c){a=0===c&&l<s?0:c;break}var d=a-1;a>0&&(Ge({type:"PointerMove",payload:100*a/Ie,index:d}),y&&Se&&y(Pe(Se),d,e))},Le=function(e){Se&&(Ge({type:"MouseClick",payload:Se}),h&&h(Pe(Se),be,e))},Re=t.useMemo((function(){if(B){if(F){var e=ke&&ke||Ne;return Se&&Se>e?Se:e}return Se&&Se||ke&&ke||Ne}return ke&&ke||Ne}),[B,F,Se,ke,Ne]);t.useEffect((function(){ce.length>Ie&&console.error("tooltipArray Array length is bigger then Icons Count length.")}),[ce.length,Ie]);var We=t.useCallback((function(e){return Se&&e[be]||ke&&e[Me]||_&&e[je]}),[Se,be,ke,Me,_,je]),Te=t.useMemo((function(){return Se&&Pe(Se)||ke&&Pe(ke)||_&&Pe(Ne)}),[Se,Pe,ke,_,Ne]);return e.jsxs("span",o({className:l,style:{direction:"".concat(G?"rtl":"ltr")}},{children:[e.jsxs("span",o({className:"".concat(a," ").concat(R),style:o({cursor:b?"":"pointer"},A),onPointerMove:b?void 0:Ae,onPointerEnter:b?void 0:function(e){m&&m(e),u()&&Ae(e)},onPointerLeave:b?void 0:function(e){u()&&Le(),Ge({type:"PointerLeave"}),g&&g(e)},onClick:b?void 0:Le,"aria-hidden":"true"},{children:[e.jsx("span",o({className:"".concat(c," ").concat(ne),style:o({color:ee},te)},{children:n([],Array(w),!0).map((function(o,n){var r;return e.jsx(t.Fragment,{children:(null===(r=N[n])||void 0===r?void 0:r.icon)||Q||e.jsx(i,{SVGclassName:fe,SVGstyle:me,SVGstorkeWidth:xe,SVGstrokeColor:Ce,size:k})},n)}))})),e.jsx("span",o({className:"".concat(s," ").concat(X),style:o((p={},p[G?"right":"left"]=0,p.color=We(U)||J,p.transition=T?"width .2s ease, color .2s ease":"",p.width="".concat(Re,"%"),p),Z),title:"".concat(Se&&Pe(Se)||Pe(Ne)," ").concat(ye," ").concat(w)},{children:n([],Array(w),!0).map((function(o,n){var r;return e.jsx(t.Fragment,{children:(null===(r=N[n])||void 0===r?void 0:r.icon)||O||e.jsx(i,{SVGclassName:fe,SVGstyle:me,SVGstorkeWidth:xe,SVGstrokeColor:Ce,size:k})},n)}))}))]})),re&&e.jsx("span",o({className:"".concat(d," ").concat(ve),style:o((f={},f[G?"marginRight":"marginLeft"]=20,f),de)},{children:(ce.length>0?We(ce):Te)||ae}))]}))};
//# sourceMappingURL=index.js.map
{
"name": "react-simple-star-rating",
"version": "5.1.5",
"version": "5.1.6",
"private": false,

@@ -5,0 +5,0 @@ "description": "A simple react component for adding a star rating to your project.",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc