New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

anatomogram

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anatomogram - npm Package Compare versions

Comparing version 1.2.10 to 1.2.11

lib/Anatomogram.css

109

lib/Anatomogram.js

@@ -25,2 +25,6 @@ 'use strict';

require('./Anatomogram.css');
var _lodash = require('lodash');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -36,2 +40,6 @@

var groupIntoPairs = function groupIntoPairs(arr, f) {
return Object.entries((0, _lodash.groupBy)(arr, f));
};
var arrayDifference = function arrayDifference(arr1, arr2) {

@@ -72,45 +80,14 @@ return Array.isArray(arr1) && Array.isArray(arr2) ? arr1.filter(function (e) {

var paintIds = function paintIds(ids, colour, opacity, getSvgElementById) {
ids.forEach(function (id) {
var e = getSvgElementById(id);
// We might be showing an ID which is not part of the displayed anatomogram (e.g. heart in brain)
if (e) {
e.style.fill = colour;
e.style.opacity = opacity;
}
});
var paintSvgElement = function paintSvgElement(element, elementMarkup) {
return element && elementMarkup && Object.assign(element.style, elementMarkup);
};
var addMouseOverMouseOutListeners = function addMouseOverMouseOutListeners(ids, mouseOverColour, mouseOverOpacity, mouseOverCallback, mouseOutCallback, getSvgElementById) {
ids.forEach(function (id) {
var e = getSvgElementById(id);
if (e) {
e.addEventListener('mouseover', function () {
e.style.fill = mouseOverColour;
e.style.opacity = mouseOverOpacity;
mouseOverCallback(id);
});
var originalColour = e.style.fill;
var originalOpacity = e.style.opacity;
e.addEventListener('mouseout', function () {
e.style.fill = originalColour;
e.style.opacity = originalOpacity;
mouseOutCallback(id);
});
}
});
var elementMarkup = function elementMarkup(colour, opacity) {
return { fill: colour, opacity: opacity };
};
var attachCallbacks = function attachCallbacks(ids, eventName, callback, getSvgElementById) {
ids.forEach(function (id) {
var e = getSvgElementById(id);
if (e) {
e.addEventListener(eventName, function () {
callback(id);
});
}
var registerEvent = function registerEvent(element, eventType, elementMarkup, callback) {
element && element.addEventListener(eventType, function () {
paintSvgElement(element);
callback();
});

@@ -141,2 +118,4 @@ };

value: function _initialiseSvgElements(getSvgElementById) {
var _this2 = this;
var _props = this.props,

@@ -160,11 +139,41 @@ showIds = _props.showIds,

paintIds(uniqueShowIds, showColour, showOpacity, getSvgElementById);
paintIds(uniqueHighlightIds, highlightColour, highlightOpacity, getSvgElementById);
paintIds(selectIds, selectColour, selectOpacity, getSvgElementById);
//Given an element and its ids, we take the first element of this array having one of the ids
var markups = [].concat(selectIds.map(function (id) {
return {
id: id,
markupNormal: elementMarkup(selectColour, selectOpacity),
markupUnderFocus: elementMarkup(selectColour, selectOpacity + 0.2)
};
}), uniqueHighlightIds.map(function (id) {
return {
id: id,
markupNormal: elementMarkup(highlightColour, highlightOpacity),
markupUnderFocus: elementMarkup(highlightColour, highlightOpacity + 0.2)
};
}), uniqueShowIds.map(function (id) {
return {
id: id,
markupNormal: elementMarkup(showColour, showOpacity),
markupUnderFocus: elementMarkup(showColour, showOpacity)
};
}));
addMouseOverMouseOutListeners(uniqueShowIds, highlightColour, highlightOpacity, onMouseOver, onMouseOut, getSvgElementById);
addMouseOverMouseOutListeners(uniqueHighlightIds, highlightColour, highlightOpacity + 0.2, onMouseOver, onMouseOut, getSvgElementById);
addMouseOverMouseOutListeners(selectIds, selectColour, selectOpacity + 0.2, onMouseOver, onMouseOut, getSvgElementById);
//More than one id can correspond to an element - see the svg "use" elements
groupIntoPairs([].concat(_toConsumableArray(uniqueShowIds), _toConsumableArray(uniqueHighlightIds), _toConsumableArray(selectIds)).map(function (id) {
return [getSvgElementById(id), id];
}), '[0].id').forEach(function (a) {
var element = a[1][0][0];
var ids = a[1].map(function (t) {
return t[1];
});
var markupNormalAndUnderFocus = markups.find(function (m) {
return ids.includes(m.id);
});
attachCallbacks([].concat(_toConsumableArray(uniqueShowIds), _toConsumableArray(uniqueHighlightIds), _toConsumableArray(selectIds)), 'click', onClick, getSvgElementById);
paintSvgElement(element, markupNormalAndUnderFocus.markupNormal);
registerEvent(element, "mouseover", markupNormalAndUnderFocus.markupUnderFocus, onMouseOver.bind(_this2, ids));
registerEvent(element, "mouseout", markupNormalAndUnderFocus.markupNormal, onMouseOut.bind(_this2, ids));
registerEvent(element, "click", {}, onClick.bind(_this2, ids));
});
}

@@ -174,13 +183,13 @@ }, {

value: function render() {
var _this2 = this;
var _this3 = this;
return _react2.default.createElement(
'div',
{ style: { display: 'inline-block', verticalAlign: 'top', width: '90%' } },
{ className: 'gxa-anatomogram' },
_react2.default.createElement(_reactSvg2.default, {
path: (0, _Assets.resolveUrlToAnatomogram)(this.props.urlToResources, this.props.filename),
callback: function callback(svgDomNode) {
_this2._initialiseSvgElements(getSvgElementById(svgDomNode));
_this3._initialiseSvgElements(getSvgElementById(svgDomNode));
},
style: { width: '100%', height: 'auto' }
className: 'gxa-anatomogram-svg'
})

@@ -187,0 +196,0 @@ );

@@ -142,2 +142,3 @@ 'use strict';

//::List[OntologyId] -> ?
onMouseOver: _propTypes2.default.func,

@@ -144,0 +145,0 @@ onMouseOut: _propTypes2.default.func,

@@ -32,3 +32,3 @@ 'use strict';

'div',
{ style: { display: 'inline-block', verticalAlign: 'top', width: '10%', maxWidth: '32px' } },
{ className: 'gxa-anatomogram-switcher' },
anatomogramTypes.map(function (anatomogramType) {

@@ -35,0 +35,0 @@ return _react2.default.createElement('img', { key: anatomogramType,

{
"name": "anatomogram",
"version": "1.2.10",
"version": "1.2.11",
"description": "Anatomogram component for Expression Atlas heatmap",

@@ -15,4 +15,4 @@ "main": "lib/index.js",

"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "./__mocks__/fileMock.js",
"\\.(css|less)$": "./__mocks__/styleMock.js"
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js"
}

@@ -27,2 +27,4 @@ },

"dependencies": {
"babel-preset-es2015": "^6.24.1",
"lodash": "^4.17.4",
"object-hash": "^1.1.8",

@@ -42,3 +44,2 @@ "prop-types": "^15.5.10",

"babel-preset-env": "^1.5.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",

@@ -45,0 +46,0 @@ "clean-webpack-plugin": "^0.1.16",

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