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.2.3 to 0.2.4

1

dist/core/types.d.ts

@@ -14,2 +14,3 @@ /// <reference types="react" />

onStarsRated?: (initialSelectedValue: number) => void;
isDisabled?: boolean;
};

4

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

@@ -168,3 +168,5 @@ 'use strict';

var StarsRating = function StarsRating(props) {
var instance = useStars(props.config);
var _props$isDisabled = props.isDisabled,
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled;
var instance = useStars(props.config, isDisabled);
var stars = instance.stars,

@@ -171,0 +173,0 @@ getStarProps = instance.getStarProps,

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=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 a=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 o(e,t){void 0===t&&(t=!1);var o=e.totalStars,u=e.initialSelectedValue,i=void 0===u?0:u,l=e.renderFull,s=e.renderHalf,c=void 0===s?null:s,f=e.renderEmpty,d=n.useState(i),p=d[0],g=d[1],v=n.useState(i),S=v[0],m=v[1],y=n.useState(!1),h=y[0],M=y[1],_=function(){t||M(!0)},E=function(){t||(m(p),M(!1))};return{getStarProps:function(e,n){var o=null!==c?e+.5:e+1;return r({},n,{onClick:function(e){return a(void(t||g(S)),n&&n.onClick(e,S))},onMouseMove:function(e){return a(function(e,n){if(!t){var r=e.target.getBoundingClientRect();m(null!==c&&r.width/2<=e.pageX-e.target.offsetLeft?n+.5:n)}}(e,o),n&&n.onMouseMove&&n.onMouseMove(e,o))}})},stars:Array.from(Array(o),(function(e,t){var n=null!==c?t+.5:t+1,r=n<=S,a=!Number.isInteger(S)&&n===S;return r?a?c:l:f})),getStarWrapperProps:function(e){return r({},e,{onMouseLeave:a(e&&e.onMouseLeave,E),onMouseEnter:a(e&&e.onMouseEnter,_)})},isSelecting:h,selectedValue:p,selectingValue:S}}!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__3roiw {\n cursor: pointer;\n display: inline-block;\n}\n.StarRating-module_star__MMPKi {\n display: inline-block;\n}\n"),exports.StarsRating=function(e){var n=o(e.config),r=n.stars,a=n.getStarProps,u=n.getStarWrapperProps,i=n.isSelecting,l=n.selectingValue,s=n.selectedValue,c=t.useRef(!1);return t.useEffect((function(){e&&e.onSelecting&&null!=e&&e.onSelecting&&e.onSelecting(i,l)}),[i,l]),t.useEffect((function(){!0===c.current&&null!=e&&e.onStarsRated&&e.onStarsRated(s),c.current=!0}),[s]),t.createElement(t.Fragment,null,t.createElement("div",null,t.createElement("span",Object.assign({tabIndex:0},u(),{className:"StarRating-module_stars__3roiw"}),null==r?void 0:r.map((function(e,n){return t.createElement("span",Object.assign({key:n},a(n),{className:"StarRating-module_star__MMPKi"}),e)})))))},exports.default=o,exports.useStars=o;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=(e=t)&&"object"==typeof e&&"default"in e?e.default:e;function r(){return(r=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 a=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 o(e,t){void 0===t&&(t=!1);var o=e.totalStars,i=e.initialSelectedValue,u=void 0===i?0:i,l=e.renderFull,s=e.renderHalf,c=void 0===s?null:s,d=e.renderEmpty,f=n.useState(u),p=f[0],g=f[1],v=n.useState(u),S=v[0],m=v[1],y=n.useState(!1),h=y[0],M=y[1],_=function(){t||M(!0)},E=function(){t||(m(p),M(!1))};return{getStarProps:function(e,n){var o=null!==c?e+.5:e+1;return r({},n,{onClick:function(e){return a(void(t||g(S)),n&&n.onClick(e,S))},onMouseMove:function(e){return a(function(e,n){if(!t){var r=e.target.getBoundingClientRect();m(null!==c&&r.width/2<=e.pageX-e.target.offsetLeft?n+.5:n)}}(e,o),n&&n.onMouseMove&&n.onMouseMove(e,o))}})},stars:Array.from(Array(o),(function(e,t){var n=null!==c?t+.5:t+1,r=n<=S,a=!Number.isInteger(S)&&n===S;return r?a?c:l:d})),getStarWrapperProps:function(e){return r({},e,{onMouseLeave:a(e&&e.onMouseLeave,E),onMouseEnter:a(e&&e.onMouseEnter,_)})},isSelecting:h,selectedValue:p,selectingValue:S}}!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__3roiw {\n cursor: pointer;\n display: inline-block;\n}\n.StarRating-module_star__MMPKi {\n display: inline-block;\n}\n"),exports.StarsRating=function(e){var n=e.isDisabled,r=o(e.config,void 0!==n&&n),a=r.stars,i=r.getStarProps,u=r.getStarWrapperProps,l=r.isSelecting,s=r.selectingValue,c=r.selectedValue,d=t.useRef(!1);return t.useEffect((function(){e&&e.onSelecting&&null!=e&&e.onSelecting&&e.onSelecting(l,s)}),[l,s]),t.useEffect((function(){!0===d.current&&null!=e&&e.onStarsRated&&e.onStarsRated(c),d.current=!0}),[c]),t.createElement(t.Fragment,null,t.createElement("div",null,t.createElement("span",Object.assign({tabIndex:0},u(),{className:"StarRating-module_stars__3roiw"}),null==a?void 0:a.map((function(e,n){return t.createElement("span",Object.assign({key:n},i(n),{className:"StarRating-module_star__MMPKi"}),e)})))))},exports.default=o,exports.useStars=o;
//# sourceMappingURL=stars-rating-react-hooks.cjs.production.min.js.map

@@ -161,3 +161,5 @@ import React__default, { useRef, useEffect, createElement, Fragment } from 'react';

var StarsRating = function StarsRating(props) {
var instance = useStars(props.config);
var _props$isDisabled = props.isDisabled,
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled;
var instance = useStars(props.config, isDisabled);
var stars = instance.stars,

@@ -164,0 +166,0 @@ getStarProps = instance.getStarProps,

{
"version": "0.2.3",
"version": "0.2.4",
"license": "MIT",

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

@@ -15,2 +15,3 @@ export type Renderable = JSX.Element | string | number | null;

onStarsRated?: (initialSelectedValue: number) => void;
isDisabled?: boolean;
};

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