Socket
Socket
Sign inDemoInstall

@savingsunited/zvezdochki

Package Overview
Dependencies
2
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.0 to 1.1.1

tests/test-emoji.js

2

dist/demo.d3b53871.js

@@ -7,3 +7,3 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"LLHV":[function(require,module,exports) {

},{}],"VgtN":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=e(require("fingerprintjs2"));function e(t){return t&&t.__esModule?t:{default:t}}function i(t){return o(t)||n(t)||a()}function a(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function n(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function o(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function l(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}var c=function(){function e(t,i){s(this,e),this.ratingEl=t,this.options={activeClass:"active",starDataAttr:"star",ratingDataAttr:"ratingValue",votedClassName:"star-rating--blocked",id:null,voted:!1,fingerPrint:!1,localStorageName:null},t&&i&&(this.options=Object.assign(this.options,i)),this.options.localStorageName&&(this.storage=window.localStorage.getItem(this.options.localStorageName),this.votedIds=JSON.parse(this.storage)||[]),this.stars=this.ratingEl.querySelectorAll("[data-"+this.options.starDataAttr+"]"),this.init()}return l(e,[{key:"init",value:function(){this.setInitialRating(),this.options.fingerPrint&&this.getFingerPrint(),this.isVoted()?this.blockVotes():(this.handleHover(),this.addClickHandler())}},{key:"submit",value:function(t){var e={star:t};this.options.fingerPrint&&(e.fingerPrint=this.options.fingerPrint),this.options.localStorageName&&this.addVoteToStorage();var i=new CustomEvent("vote",{detail:e});this.ratingEl.dispatchEvent(i)}},{key:"getFingerPrint",value:function(){var e=this;window.requestIdleCallback?requestIdleCallback(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})}):setTimeout(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})},500)}},{key:"blockVotes",value:function(){this.ratingEl.classList.add(this.options.votedClassName),this.options.voted=!0,this.ratingEl.style.pointerEvents=!1}},{key:"unblockVotes",value:function(){this.handleHover(),this.addClickHandler(),this.ratingEl.classList.remove(this.options.votedClassName),this.options.voted=!1,this.ratingEl.style.pointerEvents=""}},{key:"isVoted",value:function(){if(this.options.voted)return!0;if(this.options.localStorageName&&this.votedIds){var t=this.options.id||1;return this.votedIds.includes(t)}}},{key:"addVoteToStorage",value:function(){var t=this.options.id||1;this.votedIds=[].concat(i(this.votedIds),[t]),window.localStorage.setItem(this.options.localStorageName,JSON.stringify(this.votedIds))}},{key:"setInitialRating",value:function(){var t=this.ratingEl.dataset[this.options.ratingDataAttr.toLowerCase()];this.setActiveStar(t)}},{key:"setActiveStar",value:function(t){this.ratingEl.querySelector("*[data-"+this.options.starDataAttr+'="'+t+'"]').classList.add(this.options.activeClass)}},{key:"handleHover",value:function(){var t=this;this.stars.forEach(function(e){e.addEventListener("mouseenter",function(){t.stars.forEach(function(e){e.classList.remove(t.options.activeClass)})}),e.addEventListener("mouseleave",function(){t.setInitialRating()})})}},{key:"addClickHandler",value:function(){var t=this;this.ratingEl.addEventListener("click",function(e){e.preventDefault();var i=e.target;if(i.dataset[t.options.starDataAttr]||(i=i.closest("[data-".concat(t.options.starDataAttr,"]"))),i.dataset[t.options.starDataAttr]&&!t.options.voted){var a=i.dataset[t.options.starDataAttr];i.classList.add(t.options.activeClass),t.ratingEl.dataset[t.options.ratingDataAttr.toLowerCase()]=a,t.submit(a),t.blockVotes()}},!0)}}]),e}();exports.default=c;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=e(require("fingerprintjs2"));function e(t){return t&&t.__esModule?t:{default:t}}function i(t){return o(t)||n(t)||a()}function a(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function n(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function o(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function l(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}var c=function(){function e(t,i){s(this,e),this.ratingEl=t,this.options={activeClass:"active",starDataAttr:"star",ratingDataAttr:"ratingValue",votedClassName:"star-rating--blocked",id:null,voted:!1,fingerPrint:!1,localStorageName:null},t&&i&&(this.options=Object.assign(this.options,i)),this.options.localStorageName&&(this.storage=window.localStorage.getItem(this.options.localStorageName),this.votedIds=JSON.parse(this.storage)||[]),this.stars=this.ratingEl.querySelectorAll("[data-"+this.options.starDataAttr+"]"),this.init()}return l(e,[{key:"init",value:function(){this.setInitialRating(),this.options.fingerPrint&&this.getFingerPrint(),this.isVoted()?this.blockVotes():(this.handleHover(),this.addClickHandler())}},{key:"submit",value:function(t){var e={star:t};this.options.fingerPrint&&(e.fingerPrint=this.options.fingerPrint),this.options.localStorageName&&this.addVoteToStorage();var i=new CustomEvent("vote",{detail:e});this.ratingEl.dispatchEvent(i)}},{key:"getFingerPrint",value:function(){var e=this;window.requestIdleCallback?requestIdleCallback(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})}):setTimeout(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})},500)}},{key:"blockVotes",value:function(){this.ratingEl.classList.add(this.options.votedClassName),this.options.voted=!0,this.ratingEl.style.pointerEvents=!1}},{key:"unblockVotes",value:function(){this.handleHover(),this.addClickHandler(),this.ratingEl.classList.remove(this.options.votedClassName),this.options.voted=!1,this.ratingEl.style.pointerEvents=""}},{key:"isVoted",value:function(){if(this.options.voted)return!0;if(this.options.localStorageName&&this.votedIds){var t=this.options.id||1;return this.votedIds.includes(t)}}},{key:"addVoteToStorage",value:function(){var t=this.options.id||1;this.votedIds=[].concat(i(this.votedIds),[t]),window.localStorage.setItem(this.options.localStorageName,JSON.stringify(this.votedIds))}},{key:"setInitialRating",value:function(){var t=this.ratingEl.dataset[this.options.ratingDataAttr.toLowerCase()];this.setActiveStar(t)}},{key:"setActiveStar",value:function(t){t&&"0"!==t&&this.ratingEl.querySelector("*[data-"+this.options.starDataAttr+'="'+t+'"]').classList.add(this.options.activeClass)}},{key:"handleHover",value:function(){var t=this;this.stars.forEach(function(e){e.addEventListener("mouseenter",function(){t.stars.forEach(function(e){e.classList.remove(t.options.activeClass)})}),e.addEventListener("mouseleave",function(){t.setInitialRating()})})}},{key:"addClickHandler",value:function(){var t=this;this.ratingEl.addEventListener("click",function(e){e.preventDefault();var i=e.target;if(i.dataset[t.options.starDataAttr]||(i=i.closest("[data-".concat(t.options.starDataAttr,"]"))),i.dataset[t.options.starDataAttr]&&!t.options.voted){var a=i.dataset[t.options.starDataAttr];i.classList.add(t.options.activeClass),t.ratingEl.dataset[t.options.ratingDataAttr.toLowerCase()]=a,t.submit(a),t.blockVotes()}},!0)}}]),e}();exports.default=c;
},{"fingerprintjs2":"llUH"}],"ELfv":[function(require,module,exports) {

@@ -10,0 +10,0 @@ var define;

@@ -5,3 +5,3 @@ parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"llUH":[function(require,module,exports) {

},{}],"VgtN":[function(require,module,exports) {
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=e(require("fingerprintjs2"));function e(t){return t&&t.__esModule?t:{default:t}}function i(t){return o(t)||n(t)||a()}function a(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function n(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function o(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function l(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}var c=function(){function e(t,i){s(this,e),this.ratingEl=t,this.options={activeClass:"active",starDataAttr:"star",ratingDataAttr:"ratingValue",votedClassName:"star-rating--blocked",id:null,voted:!1,fingerPrint:!1,localStorageName:null},t&&i&&(this.options=Object.assign(this.options,i)),this.options.localStorageName&&(this.storage=window.localStorage.getItem(this.options.localStorageName),this.votedIds=JSON.parse(this.storage)||[]),this.stars=this.ratingEl.querySelectorAll("[data-"+this.options.starDataAttr+"]"),this.init()}return l(e,[{key:"init",value:function(){this.setInitialRating(),this.options.fingerPrint&&this.getFingerPrint(),this.isVoted()?this.blockVotes():(this.handleHover(),this.addClickHandler())}},{key:"submit",value:function(t){var e={star:t};this.options.fingerPrint&&(e.fingerPrint=this.options.fingerPrint),this.options.localStorageName&&this.addVoteToStorage();var i=new CustomEvent("vote",{detail:e});this.ratingEl.dispatchEvent(i)}},{key:"getFingerPrint",value:function(){var e=this;window.requestIdleCallback?requestIdleCallback(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})}):setTimeout(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})},500)}},{key:"blockVotes",value:function(){this.ratingEl.classList.add(this.options.votedClassName),this.options.voted=!0,this.ratingEl.style.pointerEvents=!1}},{key:"unblockVotes",value:function(){this.handleHover(),this.addClickHandler(),this.ratingEl.classList.remove(this.options.votedClassName),this.options.voted=!1,this.ratingEl.style.pointerEvents=""}},{key:"isVoted",value:function(){if(this.options.voted)return!0;if(this.options.localStorageName&&this.votedIds){var t=this.options.id||1;return this.votedIds.includes(t)}}},{key:"addVoteToStorage",value:function(){var t=this.options.id||1;this.votedIds=[].concat(i(this.votedIds),[t]),window.localStorage.setItem(this.options.localStorageName,JSON.stringify(this.votedIds))}},{key:"setInitialRating",value:function(){var t=this.ratingEl.dataset[this.options.ratingDataAttr.toLowerCase()];this.setActiveStar(t)}},{key:"setActiveStar",value:function(t){this.ratingEl.querySelector("*[data-"+this.options.starDataAttr+'="'+t+'"]').classList.add(this.options.activeClass)}},{key:"handleHover",value:function(){var t=this;this.stars.forEach(function(e){e.addEventListener("mouseenter",function(){t.stars.forEach(function(e){e.classList.remove(t.options.activeClass)})}),e.addEventListener("mouseleave",function(){t.setInitialRating()})})}},{key:"addClickHandler",value:function(){var t=this;this.ratingEl.addEventListener("click",function(e){e.preventDefault();var i=e.target;if(i.dataset[t.options.starDataAttr]||(i=i.closest("[data-".concat(t.options.starDataAttr,"]"))),i.dataset[t.options.starDataAttr]&&!t.options.voted){var a=i.dataset[t.options.starDataAttr];i.classList.add(t.options.activeClass),t.ratingEl.dataset[t.options.ratingDataAttr.toLowerCase()]=a,t.submit(a),t.blockVotes()}},!0)}}]),e}();exports.default=c;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var t=e(require("fingerprintjs2"));function e(t){return t&&t.__esModule?t:{default:t}}function i(t){return o(t)||n(t)||a()}function a(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function n(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function o(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function l(t,e,i){return e&&r(t.prototype,e),i&&r(t,i),t}var c=function(){function e(t,i){s(this,e),this.ratingEl=t,this.options={activeClass:"active",starDataAttr:"star",ratingDataAttr:"ratingValue",votedClassName:"star-rating--blocked",id:null,voted:!1,fingerPrint:!1,localStorageName:null},t&&i&&(this.options=Object.assign(this.options,i)),this.options.localStorageName&&(this.storage=window.localStorage.getItem(this.options.localStorageName),this.votedIds=JSON.parse(this.storage)||[]),this.stars=this.ratingEl.querySelectorAll("[data-"+this.options.starDataAttr+"]"),this.init()}return l(e,[{key:"init",value:function(){this.setInitialRating(),this.options.fingerPrint&&this.getFingerPrint(),this.isVoted()?this.blockVotes():(this.handleHover(),this.addClickHandler())}},{key:"submit",value:function(t){var e={star:t};this.options.fingerPrint&&(e.fingerPrint=this.options.fingerPrint),this.options.localStorageName&&this.addVoteToStorage();var i=new CustomEvent("vote",{detail:e});this.ratingEl.dispatchEvent(i)}},{key:"getFingerPrint",value:function(){var e=this;window.requestIdleCallback?requestIdleCallback(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})}):setTimeout(function(){t.default.get(function(i){var a=i.map(function(t){return t.value});e.options.fingerPrint=t.default.x64hash128(a.join(""),31)})},500)}},{key:"blockVotes",value:function(){this.ratingEl.classList.add(this.options.votedClassName),this.options.voted=!0,this.ratingEl.style.pointerEvents=!1}},{key:"unblockVotes",value:function(){this.handleHover(),this.addClickHandler(),this.ratingEl.classList.remove(this.options.votedClassName),this.options.voted=!1,this.ratingEl.style.pointerEvents=""}},{key:"isVoted",value:function(){if(this.options.voted)return!0;if(this.options.localStorageName&&this.votedIds){var t=this.options.id||1;return this.votedIds.includes(t)}}},{key:"addVoteToStorage",value:function(){var t=this.options.id||1;this.votedIds=[].concat(i(this.votedIds),[t]),window.localStorage.setItem(this.options.localStorageName,JSON.stringify(this.votedIds))}},{key:"setInitialRating",value:function(){var t=this.ratingEl.dataset[this.options.ratingDataAttr.toLowerCase()];this.setActiveStar(t)}},{key:"setActiveStar",value:function(t){t&&"0"!==t&&this.ratingEl.querySelector("*[data-"+this.options.starDataAttr+'="'+t+'"]').classList.add(this.options.activeClass)}},{key:"handleHover",value:function(){var t=this;this.stars.forEach(function(e){e.addEventListener("mouseenter",function(){t.stars.forEach(function(e){e.classList.remove(t.options.activeClass)})}),e.addEventListener("mouseleave",function(){t.setInitialRating()})})}},{key:"addClickHandler",value:function(){var t=this;this.ratingEl.addEventListener("click",function(e){e.preventDefault();var i=e.target;if(i.dataset[t.options.starDataAttr]||(i=i.closest("[data-".concat(t.options.starDataAttr,"]"))),i.dataset[t.options.starDataAttr]&&!t.options.voted){var a=i.dataset[t.options.starDataAttr];i.classList.add(t.options.activeClass),t.ratingEl.dataset[t.options.ratingDataAttr.toLowerCase()]=a,t.submit(a),t.blockVotes()}},!0)}}]),e}();exports.default=c;
},{"fingerprintjs2":"llUH"}]},{},["VgtN"], null)
{
"name": "@savingsunited/zvezdochki",
"version": "1.1.0",
"version": "1.1.1",
"description": "The component for easy creation of star rating components",

@@ -34,2 +34,3 @@ "main": "dist/Zvezdochki.3283b0c3.js",

"@babel/register": "^7.8.3",
"canvas": "^2.6.1",
"chai": "^4.2.0",

@@ -46,2 +47,3 @@ "coveralls": "^3.0.9",

"mocha-lcov-reporter": "^1.3.0",
"mock-local-storage": "^1.1.11",
"node-sass": "^4.13.1",

@@ -48,0 +50,0 @@ "nyc": "^15.0.0",

@@ -124,4 +124,6 @@ import Fingerprint2 from "fingerprintjs2";

setActiveStar(rating) {
let activeEl = this.ratingEl.querySelector('*[data-' + this.options.starDataAttr + '="' + rating + '"]');
activeEl.classList.add(this.options.activeClass);
if (rating && rating !== "0") {
let activeEl = this.ratingEl.querySelector('*[data-' + this.options.starDataAttr + '="' + rating + '"]');
activeEl.classList.add(this.options.activeClass);
}
}

@@ -128,0 +130,0 @@

@@ -7,3 +7,2 @@ let chai = require('chai');

import Zvezdochki from "../src/Zvezdochki";

@@ -63,5 +62,6 @@

describe('functionality', function() {
let DOM, starsEl;
let DOM, starsEl, star;
context('initializing', function() {
before(function() {

@@ -99,3 +99,3 @@ DOM = new JSDOM(HTML, {resources: "usable", runScripts: "dangerously"});

let star = document.querySelector(`.${testOptions.elementClass}__list > li:nth-child(3)`);
star = document.querySelector(`.${testOptions.elementClass}__list > li:nth-child(3)`);

@@ -108,4 +108,8 @@ starsEl.addEventListener("vote", ev => {

clickEvent.initEvent("click", true, true);
star.dispatchEvent(clickEvent)
star.dispatchEvent(clickEvent);
let mouseenterEvent = document.createEvent("HTMLEvents");
mouseenterEvent.initEvent("mouseenter", true, true);
star.dispatchEvent(mouseenterEvent);
});

@@ -118,5 +122,40 @@

it('should dispatch event', function() {
vote.should.be.equal('3')
vote.should.be.equal('3');
});
it('should delete active class', function() {
star.classList.contains(testOptions.activeClass).should.be.false;
});
});
context('mouse leave', function() {
before(function() {
DOM = new JSDOM(HTML, {resources: "usable", runScripts: "dangerously"});
let window = DOM.window;
let document = window.document;
starsEl = document.querySelector(`.${testOptions.elementClass}`);
star = document.querySelector(`.${testOptions.elementClass}__list > li:nth-child(2)`);
let zvezdochki = new Zvezdochki(starsEl);
zvezdochki.unblockVotes();
let mouseleaveEvent = document.createEvent("HTMLEvents");
mouseleaveEvent.initEvent("mouseleave", true, true);
star.dispatchEvent(mouseleaveEvent);
});
it('should unblock votes', function() {
starsEl.classList.contains(testOptions.votedClassName).should.be.false;
});
it('should return active class', function() {
star.classList.contains(testOptions.activeClass).should.be.true;
});
});
});

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