@reltio/components 1.4.1462 → 1.4.1464

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,14 +68,15 @@ var MapChart = function (_a) {
68
68
  var mapWidth = width < exports.LEGEND_WIDTH ? 0 : width - (showLegend ? 1 : 0) * exports.LEGEND_WIDTH;
69
69
  var colorScale = (0, d3_scale_1.scaleLog)().domain([minValue, maxValue]).range(MAP_COLORS);
70
70
  var geography = (0, useGeography_1.default)(geoUrl || USA_MAP);
71
- var projection = geoUrl ? options.projection : 'geoAlbersUsa';
72
- var projectionFunc = (0, react_1.useMemo)(function () {
71
+ var getProjectionFunc = (0, react_1.useCallback)(function (projection) {
73
72
  var _a;
74
73
  var geoFunc = (_a = (projection && d3Geo[projection])) !== null && _a !== void 0 ? _a : d3Geo['geoEqualEarth'];
75
- return geography
76
- ? geoFunc().fitSize([mapWidth, height], (0, topojson_client_1.feature)(geography, geography.objects[Object.keys(geography.objects)[0]]))
77
- : undefined;
78
- }, [geography, mapWidth, height, projection]);
74
+ var geoObj = geography.objects && geography.objects[Object.keys(geography.objects)[0]];
75
+ var featureObj = geography.type === 'FeatureCollection' ? geography : (0, topojson_client_1.feature)(geography, geoObj);
76
+ return geoFunc().fitSize([mapWidth, height], featureObj);
77
+ }, [geography, height, mapWidth]);
78
+ var projection = geoUrl ? options.projection : 'geoAlbersUsa';
79
+ var projectionFunc = (0, react_1.useMemo)(function () { return (geography ? getProjectionFunc(projection) : undefined); }, [geography, getProjectionFunc, projection]);
79
80
  var _d = (0, useTooltipState_1.default)(), tooltipState = _d.tooltipState, showTooltip = _d.showTooltip, hideTooltip = _d.hideTooltip;
80
81
  var clickable = (0, useClickableStyle_1.useClickableStyle)(onItemClick);
81
82
  return (react_1.default.createElement("div", { className: styles.mapChart, style: { width: width, height: height } },
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import React, { useMemo } from 'react';
12
+ import React, { useMemo, useCallback } from 'react';
13
13
  import withPercents from '../HOCs/withPercents';
14
14
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
15
  // @ts-ignore
@@ -39,14 +39,15 @@ export var MapChart = function (_a) {
39
39
  var mapWidth = width < LEGEND_WIDTH ? 0 : width - (showLegend ? 1 : 0) * LEGEND_WIDTH;
40
40
  var colorScale = scaleLog().domain([minValue, maxValue]).range(MAP_COLORS);
41
41
  var geography = useGeography(geoUrl || USA_MAP);
42
- var projection = geoUrl ? options.projection : 'geoAlbersUsa';
43
- var projectionFunc = useMemo(function () {
42
+ var getProjectionFunc = useCallback(function (projection) {
44
43
  var _a;
45
44
  var geoFunc = (_a = (projection && d3Geo[projection])) !== null && _a !== void 0 ? _a : d3Geo['geoEqualEarth'];
46
- return geography
47
- ? geoFunc().fitSize([mapWidth, height], feature(geography, geography.objects[Object.keys(geography.objects)[0]]))
48
- : undefined;
49
- }, [geography, mapWidth, height, projection]);
45
+ var geoObj = geography.objects && geography.objects[Object.keys(geography.objects)[0]];
46
+ var featureObj = geography.type === 'FeatureCollection' ? geography : feature(geography, geoObj);
47
+ return geoFunc().fitSize([mapWidth, height], featureObj);
48
+ }, [geography, height, mapWidth]);
49
+ var projection = geoUrl ? options.projection : 'geoAlbersUsa';
50
+ var projectionFunc = useMemo(function () { return (geography ? getProjectionFunc(projection) : undefined); }, [geography, getProjectionFunc, projection]);
50
51
  var _d = useTooltipState(), tooltipState = _d.tooltipState, showTooltip = _d.showTooltip, hideTooltip = _d.hideTooltip;
51
52
  var clickable = useClickableStyle(onItemClick);
52
53
  return (React.createElement("div", { className: styles.mapChart, style: { width: width, height: height } },
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1462",
3
+ "version": "1.4.1464",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1462",
11
- "@reltio/mdm-sdk": "^1.4.1462",
10
+ "@reltio/mdm-module": "^1.4.1464",
11
+ "@reltio/mdm-sdk": "^1.4.1464",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",