@reltio/components 1.4.1475 → 1.4.1476

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.
@@ -29,31 +29,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ChipWithTooltip = void 0;
30
30
  var react_1 = __importStar(require("react"));
31
31
  var classnames_1 = __importDefault(require("classnames"));
32
+ var react_redux_1 = require("react-redux");
32
33
  var Chip_1 = __importDefault(require("@material-ui/core/Chip"));
33
34
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
34
35
  var mdm_module_1 = require("@reltio/mdm-module");
35
36
  var DataTypeValue_1 = __importDefault(require("../../DataTypeValue/DataTypeValue"));
36
37
  var HOCs_1 = require("../../../HOCs");
37
- var react_redux_1 = require("react-redux");
38
+ var contexts_1 = require("../../../contexts");
39
+ var heplers_1 = require("./heplers");
38
40
  var styles_1 = require("./styles");
39
41
  exports.ChipWithTooltip = (0, HOCs_1.withTooltip)(Chip_1.default);
40
42
  var OvIcon = function (_a) {
41
- var _b;
42
- var className = _a.className, attributeType = _a.attributeType, _c = _a.nonOvValues, nonOvValues = _c === void 0 ? [] : _c, nonOvTotal = _a.nonOvTotal;
43
+ var className = _a.className, attributeType = _a.attributeType, _b = _a.nonOvValues, nonOvValues = _b === void 0 ? [] : _b, nonOvTotal = _a.nonOvTotal;
43
44
  var styles = (0, styles_1.useStyles)();
44
45
  var dispatch = (0, react_redux_1.useDispatch)();
45
- var attributeUri = (_b = nonOvValues === null || nonOvValues === void 0 ? void 0 : nonOvValues[0]) === null || _b === void 0 ? void 0 : _b.uri;
46
+ var entity = (0, react_1.useContext)(contexts_1.EntityContext);
47
+ var entityUri = (0, heplers_1.getEntityUri)(entity, nonOvValues);
46
48
  var onClick = (0, react_1.useCallback)(function () {
47
- var entityUri = attributeUri ? (0, mdm_sdk_1.getEntityUriFromAttributeUri)(attributeUri) : '';
48
49
  dispatch(mdm_module_1.ui.actions.openEntity({ uri: entityUri, viewId: null, screen: 'sources' }));
49
- }, [attributeUri, dispatch]);
50
+ }, [dispatch, entityUri]);
50
51
  if (!nonOvTotal) {
51
52
  return null;
52
53
  }
53
54
  var tooltipTitle = nonOvValues.length
54
55
  ? nonOvValues.map(function (value, i) { return (react_1.default.createElement("div", { key: i }, (0, mdm_sdk_1.isComplexAttribute)(attributeType) ? ((0, mdm_sdk_1.getLabel)(value.label)) : (react_1.default.createElement(DataTypeValue_1.default, { value: (0, mdm_sdk_1.getAttributeValue)(value), dataTypeDefinition: (0, mdm_sdk_1.getAttrDataTypeDefinition)(attributeType), rich: false })))); })
55
56
  : null;
56
- return (react_1.default.createElement(exports.ChipWithTooltip, { tooltipTitle: tooltipTitle, tooltipPlacement: "bottom", label: "+ ".concat(nonOvTotal), variant: "outlined", onClick: onClick, classes: {
57
+ return (react_1.default.createElement(exports.ChipWithTooltip, { tooltipTitle: tooltipTitle, tooltipPlacement: "bottom", label: "+ ".concat(nonOvTotal), variant: "outlined", onClick: entityUri ? onClick : undefined, classes: {
57
58
  root: (0, classnames_1.default)(styles.container, className),
58
59
  label: styles.label
59
60
  } }));
@@ -0,0 +1,4 @@
1
+ import { Entity, NestedAttributeValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
2
+ declare type NonOvValues = Array<SimpleAttributeValue | NestedAttributeValue | ReferenceAttributeValue>;
3
+ export declare const getEntityUri: (entity: Entity, nonOvValues: NonOvValues) => any;
4
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEntityUri = void 0;
4
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
5
+ var getEntityUri = function (entity, nonOvValues) {
6
+ var _a;
7
+ var attributeUri = (_a = nonOvValues === null || nonOvValues === void 0 ? void 0 : nonOvValues[0]) === null || _a === void 0 ? void 0 : _a.uri;
8
+ var entityOrRelationUri = attributeUri ? (0, mdm_sdk_1.getEntityUriFromAttributeUri)(attributeUri) : null;
9
+ return entityOrRelationUri && (0, mdm_sdk_1.isEntityUri)(entityOrRelationUri) ? entityOrRelationUri : entity === null || entity === void 0 ? void 0 : entity.uri;
10
+ };
11
+ exports.getEntityUri = getEntityUri;
@@ -1 +1 @@
1
- export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "container">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "container">;
@@ -69,8 +69,7 @@ var MapChart = function (_a) {
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
71
  var getProjectionFunc = (0, react_1.useCallback)(function (projection) {
72
- var _a;
73
- var geoFunc = (_a = (projection && d3Geo[projection])) !== null && _a !== void 0 ? _a : d3Geo['geoEqualEarth'];
72
+ var geoFunc = (projection && d3Geo[projection]) || d3Geo['geoEqualEarth'];
74
73
  var geoObj = geography.objects && geography.objects[Object.keys(geography.objects)[0]];
75
74
  var featureObj = geography.type === 'FeatureCollection' ? geography : (0, topojson_client_1.feature)(geography, geoObj);
76
75
  return geoFunc().fitSize([mapWidth, height], featureObj);
@@ -1,30 +1,31 @@
1
- import React, { useCallback } from 'react';
1
+ import React, { useCallback, useContext } from 'react';
2
2
  import classnames from 'classnames';
3
+ import { useDispatch } from 'react-redux';
3
4
  import Chip from '@material-ui/core/Chip';
4
- import { getAttrDataTypeDefinition, getAttributeValue, isComplexAttribute, getLabel, getEntityUriFromAttributeUri } from '@reltio/mdm-sdk';
5
+ import { getAttrDataTypeDefinition, getAttributeValue, isComplexAttribute, getLabel } from '@reltio/mdm-sdk';
5
6
  import { ui } from '@reltio/mdm-module';
6
7
  import DataTypeValue from '../../DataTypeValue/DataTypeValue';
7
8
  import { withTooltip } from '../../../HOCs';
8
- import { useDispatch } from 'react-redux';
9
+ import { EntityContext } from '../../../contexts';
10
+ import { getEntityUri } from './heplers';
9
11
  import { useStyles } from './styles';
10
12
  export var ChipWithTooltip = withTooltip(Chip);
11
13
  var OvIcon = function (_a) {
12
- var _b;
13
- var className = _a.className, attributeType = _a.attributeType, _c = _a.nonOvValues, nonOvValues = _c === void 0 ? [] : _c, nonOvTotal = _a.nonOvTotal;
14
+ var className = _a.className, attributeType = _a.attributeType, _b = _a.nonOvValues, nonOvValues = _b === void 0 ? [] : _b, nonOvTotal = _a.nonOvTotal;
14
15
  var styles = useStyles();
15
16
  var dispatch = useDispatch();
16
- var attributeUri = (_b = nonOvValues === null || nonOvValues === void 0 ? void 0 : nonOvValues[0]) === null || _b === void 0 ? void 0 : _b.uri;
17
+ var entity = useContext(EntityContext);
18
+ var entityUri = getEntityUri(entity, nonOvValues);
17
19
  var onClick = useCallback(function () {
18
- var entityUri = attributeUri ? getEntityUriFromAttributeUri(attributeUri) : '';
19
20
  dispatch(ui.actions.openEntity({ uri: entityUri, viewId: null, screen: 'sources' }));
20
- }, [attributeUri, dispatch]);
21
+ }, [dispatch, entityUri]);
21
22
  if (!nonOvTotal) {
22
23
  return null;
23
24
  }
24
25
  var tooltipTitle = nonOvValues.length
25
26
  ? nonOvValues.map(function (value, i) { return (React.createElement("div", { key: i }, isComplexAttribute(attributeType) ? (getLabel(value.label)) : (React.createElement(DataTypeValue, { value: getAttributeValue(value), dataTypeDefinition: getAttrDataTypeDefinition(attributeType), rich: false })))); })
26
27
  : null;
27
- return (React.createElement(ChipWithTooltip, { tooltipTitle: tooltipTitle, tooltipPlacement: "bottom", label: "+ ".concat(nonOvTotal), variant: "outlined", onClick: onClick, classes: {
28
+ return (React.createElement(ChipWithTooltip, { tooltipTitle: tooltipTitle, tooltipPlacement: "bottom", label: "+ ".concat(nonOvTotal), variant: "outlined", onClick: entityUri ? onClick : undefined, classes: {
28
29
  root: classnames(styles.container, className),
29
30
  label: styles.label
30
31
  } }));
@@ -0,0 +1,4 @@
1
+ import { Entity, NestedAttributeValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
2
+ declare type NonOvValues = Array<SimpleAttributeValue | NestedAttributeValue | ReferenceAttributeValue>;
3
+ export declare const getEntityUri: (entity: Entity, nonOvValues: NonOvValues) => any;
4
+ export {};
@@ -0,0 +1,7 @@
1
+ import { getEntityUriFromAttributeUri, isEntityUri } from '@reltio/mdm-sdk';
2
+ export var getEntityUri = function (entity, nonOvValues) {
3
+ var _a;
4
+ var attributeUri = (_a = nonOvValues === null || nonOvValues === void 0 ? void 0 : nonOvValues[0]) === null || _a === void 0 ? void 0 : _a.uri;
5
+ var entityOrRelationUri = attributeUri ? getEntityUriFromAttributeUri(attributeUri) : null;
6
+ return entityOrRelationUri && isEntityUri(entityOrRelationUri) ? entityOrRelationUri : entity === null || entity === void 0 ? void 0 : entity.uri;
7
+ };
@@ -1 +1 @@
1
- export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "container">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "container">;
@@ -40,8 +40,7 @@ export var MapChart = function (_a) {
40
40
  var colorScale = scaleLog().domain([minValue, maxValue]).range(MAP_COLORS);
41
41
  var geography = useGeography(geoUrl || USA_MAP);
42
42
  var getProjectionFunc = useCallback(function (projection) {
43
- var _a;
44
- var geoFunc = (_a = (projection && d3Geo[projection])) !== null && _a !== void 0 ? _a : d3Geo['geoEqualEarth'];
43
+ var geoFunc = (projection && d3Geo[projection]) || d3Geo['geoEqualEarth'];
45
44
  var geoObj = geography.objects && geography.objects[Object.keys(geography.objects)[0]];
46
45
  var featureObj = geography.type === 'FeatureCollection' ? geography : feature(geography, geoObj);
47
46
  return geoFunc().fitSize([mapWidth, height], featureObj);
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1475",
3
+ "version": "1.4.1476",
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.1475",
11
- "@reltio/mdm-sdk": "^1.4.1475",
10
+ "@reltio/mdm-module": "^1.4.1476",
11
+ "@reltio/mdm-sdk": "^1.4.1476",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",