diff --git a/lib/TagCloud.js b/lib/TagCloud.js index 3668750..2dce73d 100644 --- a/lib/TagCloud.js +++ b/lib/TagCloud.js @@ -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, @@ -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)); } diff --git a/lib/defaultRenderer.js b/lib/defaultRenderer.js index b5d11a6..c5d04c6 100644 --- a/lib/defaultRenderer.js +++ b/lib/defaultRenderer.js @@ -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, diff --git a/lib/helpers.js b/lib/helpers.js index dad1fdf..1459d9f 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -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; @@ -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. */ diff --git a/package.json b/package.json index 7fa3e2d..1d6f023 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/defaultRenderer.js b/src/defaultRenderer.js index 9f1e5b4..c8f9952 100644 --- a/src/defaultRenderer.js +++ b/src/defaultRenderer.js @@ -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 ( {tag.value}