Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stars-rating-react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stars-rating-react-hooks - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

18

dist/stars-rating-react-hooks.cjs.development.js

@@ -52,4 +52,4 @@ 'use strict';

var css_248z = ".StarRating-module_star__3Fl8z {\n color: gold;\n font-size: 40px;\n}\n\n.StarRating-module_stars__2mUuF {\n cursor: pointer;\n padding: 20px;\n}\n";
var styles = {"star":"StarRating-module_star__3Fl8z","stars":"StarRating-module_stars__2mUuF"};
var css_248z = ".StarRating-module_stars__2mUuF {\n cursor: pointer;\n}\n";
var styles = {"stars":"StarRating-module_stars__2mUuF"};
styleInject(css_248z);

@@ -131,6 +131,5 @@

return _extends({}, elementProps, {
className: elementProps != null && elementProps.className ? elementProps.className : styles.star,
onClick: callAllFns(elementProps && elementProps.onClick, onClick),
onClick: callAllFns(onClick, elementProps && elementProps.onClick),
onMouseMove: function onMouseMove(e) {
return callAllFns(elementProps && elementProps.onMouseMove && elementProps.onMouseMove(e, i), _onMouseMove(e, i));
return callAllFns(_onMouseMove(e, i), elementProps && elementProps.onMouseMove && elementProps.onMouseMove(e, i));
}

@@ -142,3 +141,2 @@ });

return _extends({}, elementProps, {
className: elementProps != null && elementProps.className ? elementProps.className : styles.stars,
onMouseLeave: callAllFns(elementProps && elementProps.onMouseLeave, onMouseLeave),

@@ -168,7 +166,9 @@ onMouseEnter: callAllFns(elementProps && elementProps.onMouseEnter, onMouseEnter)

React.useEffect(function () {
(props == null ? void 0 : props.isSelecting) && (props == null ? void 0 : props.isSelecting(isSelecting, selectingValue));
if (props && props.isSelecting && props != null && props.isSelecting) {
props.isSelecting(isSelecting, selectingValue);
}
}, [isSelecting, selectingValue]);
React.useEffect(function () {
if (isMountRef.current === true) {
(props == null ? void 0 : props.onStarsRated) && (props == null ? void 0 : props.onStarsRated(selectedValue));
if (isMountRef.current === true && props != null && props.onStarsRated) {
props.onStarsRated(selectedValue);
}

@@ -175,0 +175,0 @@

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".StarRating-module_star__3Fl8z {\n color: gold;\n font-size: 40px;\n}\n\n.StarRating-module_stars__2mUuF {\n cursor: pointer;\n padding: 20px;\n}\n");var n=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.forEach((function(e){return e&&e.apply(void 0,n)}))}};function r(r){var a=r.number,s=r.value,o=r.renderFull,u=r.renderHalf,l=void 0===u?null:u,i=r.renderEmpty,c=void 0===i?"":i,d=e.useState(s),f=d[0],p=d[1],g=e.useState(s),m=g[0],v=g[1],S=e.useState(!1),_=S[0],y=S[1],h=function(){p(m)},M=function(){y(!0)},N=function(){v(f),y(!1)};return{getStarProps:function(e,r){var a=null!==l?e+.5:e;return t({},r,{className:null!=r&&r.className?r.className:"StarRating-module_star__3Fl8z",onClick:n(r&&r.onClick,h),onMouseMove:function(e){return n(r&&r.onMouseMove&&r.onMouseMove(e,a),function(e,t){var n=e.target.getBoundingClientRect();v(n.width/2<=e.pageX-e.target.offsetLeft?t+.5:t)}(e,a))}})},stars:Array.from(Array(a),(function(e,t){var n=null!==l?t+.5:t,r=n<=m,a=!Number.isInteger(m)&&n===m;return r?a?l:o:c})),getStarWrapperProps:function(e){return t({},e,{className:null!=e&&e.className?e.className:"StarRating-module_stars__2mUuF",onMouseLeave:n(e&&e.onMouseLeave,N),onMouseEnter:n(e&&e.onMouseEnter,M)})},isSelecting:_,selectedValue:f,selectingValue:m}}exports.StarsRating=function(t){var n=r(t.config),a=n.stars,s=n.getStarProps,o=n.getStarWrapperProps,u=n.isSelecting,l=n.selectingValue,i=n.selectedValue,c=e.useRef(!1);return e.useEffect((function(){(null==t?void 0:t.isSelecting)&&(null==t||t.isSelecting(u,l))}),[u,l]),e.useEffect((function(){!0===c.current&&(null==t?void 0:t.onStarsRated)&&(null==t||t.onStarsRated(i)),c.current=!0}),[i]),e.createElement("span",Object.assign({tabIndex:0},o(),{className:"StarRating-module_stars__2mUuF"}),null==a?void 0:a.map((function(t,n){return e.createElement("span",Object.assign({key:n},s(n),{className:"StarRating-module_star__3Fl8z"}),t)})))},exports.useStars=r;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(){return(t=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var n={stars:"StarRating-module_stars__2mUuF"};!function(e,t){void 0===t&&(t={});var n=t.insertAt;if("undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}(".StarRating-module_stars__2mUuF {\n cursor: pointer;\n}\n");var r=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.forEach((function(e){return e&&e.apply(void 0,n)}))}};function a(n){var a=n.number,o=n.value,s=n.renderFull,u=n.renderHalf,i=void 0===u?null:u,c=n.renderEmpty,l=void 0===c?"":c,f=e.useState(o),d=f[0],p=f[1],g=e.useState(o),v=g[0],m=g[1],S=e.useState(!1),y=S[0],h=S[1],M=function(){p(v)},E=function(){h(!0)},b=function(){m(d),h(!1)};return{getStarProps:function(e,n){var a=null!==i?e+.5:e;return t({},n,{onClick:r(M,n&&n.onClick),onMouseMove:function(e){return r(function(e,t){var n=e.target.getBoundingClientRect();m(n.width/2<=e.pageX-e.target.offsetLeft?t+.5:t)}(e,a),n&&n.onMouseMove&&n.onMouseMove(e,a))}})},stars:Array.from(Array(a),(function(e,t){var n=null!==i?t+.5:t,r=n<=v,a=!Number.isInteger(v)&&n===v;return r?a?i:s:l})),getStarWrapperProps:function(e){return t({},e,{onMouseLeave:r(e&&e.onMouseLeave,b),onMouseEnter:r(e&&e.onMouseEnter,E)})},isSelecting:y,selectedValue:d,selectingValue:v}}exports.StarsRating=function(t){var r=a(t.config),o=r.stars,s=r.getStarProps,u=r.getStarWrapperProps,i=r.isSelecting,c=r.selectingValue,l=r.selectedValue,f=e.useRef(!1);return e.useEffect((function(){t&&t.isSelecting&&null!=t&&t.isSelecting&&t.isSelecting(i,c)}),[i,c]),e.useEffect((function(){!0===f.current&&null!=t&&t.onStarsRated&&t.onStarsRated(l),f.current=!0}),[l]),e.createElement("span",Object.assign({tabIndex:0},u(),{className:n.stars}),null==o?void 0:o.map((function(t,r){return e.createElement("span",Object.assign({key:r},s(r),{className:n.star}),t)})))},exports.useStars=a;
//# sourceMappingURL=stars-rating-react-hooks.cjs.production.min.js.map

@@ -48,4 +48,4 @@ import { useState, useRef, useEffect, createElement } from 'react';

var css_248z = ".StarRating-module_star__3Fl8z {\n color: gold;\n font-size: 40px;\n}\n\n.StarRating-module_stars__2mUuF {\n cursor: pointer;\n padding: 20px;\n}\n";
var styles = {"star":"StarRating-module_star__3Fl8z","stars":"StarRating-module_stars__2mUuF"};
var css_248z = ".StarRating-module_stars__2mUuF {\n cursor: pointer;\n}\n";
var styles = {"stars":"StarRating-module_stars__2mUuF"};
styleInject(css_248z);

@@ -127,6 +127,5 @@

return _extends({}, elementProps, {
className: elementProps != null && elementProps.className ? elementProps.className : styles.star,
onClick: callAllFns(elementProps && elementProps.onClick, onClick),
onClick: callAllFns(onClick, elementProps && elementProps.onClick),
onMouseMove: function onMouseMove(e) {
return callAllFns(elementProps && elementProps.onMouseMove && elementProps.onMouseMove(e, i), _onMouseMove(e, i));
return callAllFns(_onMouseMove(e, i), elementProps && elementProps.onMouseMove && elementProps.onMouseMove(e, i));
}

@@ -138,3 +137,2 @@ });

return _extends({}, elementProps, {
className: elementProps != null && elementProps.className ? elementProps.className : styles.stars,
onMouseLeave: callAllFns(elementProps && elementProps.onMouseLeave, onMouseLeave),

@@ -164,7 +162,9 @@ onMouseEnter: callAllFns(elementProps && elementProps.onMouseEnter, onMouseEnter)

useEffect(function () {
(props == null ? void 0 : props.isSelecting) && (props == null ? void 0 : props.isSelecting(isSelecting, selectingValue));
if (props && props.isSelecting && props != null && props.isSelecting) {
props.isSelecting(isSelecting, selectingValue);
}
}, [isSelecting, selectingValue]);
useEffect(function () {
if (isMountRef.current === true) {
(props == null ? void 0 : props.onStarsRated) && (props == null ? void 0 : props.onStarsRated(selectedValue));
if (isMountRef.current === true && props != null && props.onStarsRated) {
props.onStarsRated(selectedValue);
}

@@ -171,0 +171,0 @@

{
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

declare module '*.css' {
const content: { [className: string]: string };
export default content;
}
const content: { [className: string]: string };
export default content;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc