Skip to content

Commit

Permalink
removed unneded polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
madox2 committed Oct 26, 2019
1 parent e7d6c9d commit ed96925
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
8 changes: 5 additions & 3 deletions lib/TagCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr

var handlersPropNames = ['onClick', 'onDoubleClick', 'onMouseMove'];
var cloudPropNames = ['tags', 'shuffle', 'renderer', 'maxSize', 'minSize', 'colorOptions', 'disableRandomColor', 'randomNumberGenerator'];
var randomizeDeps = ['colorOptions', 'shuffle', 'disableRandomColor'];

function generateColor(tag, _ref) {
var disableRandomColor = _ref.disableRandomColor,
Expand Down Expand Up @@ -109,12 +108,15 @@ function TagCloud(props) {
var _useState = (0, _react.useState)([]),
_useState2 = _slicedToArray(_useState, 2),
data = _useState2[0],
setData = _useState2[1]; // randomize (color, shuffle) when tags or props change
setData = _useState2[1];

var tagsComparison = props.tags.map(function (t) {
return t.key || t.value;
}).join(':'); // randomize (color, shuffle) when tags or certain props change

(0, _react.useEffect)(function () {
setData(randomize(props));
}, [].concat(_toConsumableArray((0, _helpers.values)((0, _helpers.pick)(props, randomizeDeps))), [props.tags.length]));
}, [props.colorOptions, props.shuffle, props.disableRandomColor, tagsComparison]);
var other = (0, _helpers.omit)(props, [].concat(cloudPropNames, handlersPropNames));
return _react["default"].createElement("div", other, renderTags(props, data));
}
Expand Down
12 changes: 9 additions & 3 deletions lib/defaultRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ exports.defaultRenderer = void 0;

var _react = _interopRequireDefault(require("react"));

var _objectAssign = _interopRequireDefault(require("object-assign"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var defaultRenderer = function defaultRenderer(tag, size, color) {
var fontSize = size + 'px';
var key = tag.key || tag.value;
var style = (0, _objectAssign["default"])({}, styles, {

var style = _objectSpread({}, styles, {
color: color,
fontSize: fontSize
});

return _react["default"].createElement("span", {
className: "tag-cloud-tag",
style: style,
Expand Down
9 changes: 0 additions & 9 deletions lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pick = pick;
exports.values = values;
exports.keys = keys;
exports.omit = exports.fontSizeConverter = void 0;

Expand Down Expand Up @@ -48,14 +47,6 @@ function pick(obj, keys) {
return picked;
}, {});
}
/**
* Returns an array of object values.
*/


function values(obj) {
return Object.values(obj);
}
/**
* Returns an array of object keys.
*/
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
},
"dependencies": {
"@babel/preset-react": "^7.6.3",
"object-assign": "^4.1.0",
"prop-types": "^15.6.2",
"randomcolor": "^0.5.4",
"shuffle-array": "^1.0.1"
Expand Down
3 changes: 1 addition & 2 deletions src/defaultRenderer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import objectAssign from 'object-assign'

export const defaultRenderer = (tag, size, color) => {
const fontSize = size + 'px'
const key = tag.key || tag.value
const style = objectAssign({}, styles, { color, fontSize })
const style = { ...styles, color, fontSize }
return (
<span className="tag-cloud-tag" style={style} key={key}>
{tag.value}
Expand Down

0 comments on commit ed96925

Please sign in to comment.