@reltio/components 1.4.890 → 1.4.891

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.
Files changed (39) hide show
  1. package/cjs/components/MatchRulesBlock/MatchRulesBlock.d.ts +5 -2
  2. package/cjs/components/MatchRulesBlock/MatchRulesBlock.js +2 -11
  3. package/cjs/components/ProfileCard/ProfileCard.d.ts +11 -19
  4. package/cjs/components/ProfileCard/ProfileCard.js +3 -12
  5. package/cjs/components/ProfileCard/styles.d.ts +1 -1
  6. package/cjs/components/ProfileMatchCard/ProfileMatchCard.d.ts +13 -0
  7. package/cjs/components/ProfileMatchCard/ProfileMatchCard.js +21 -0
  8. package/cjs/components/ProfileMatchCard/styles.d.ts +1 -0
  9. package/cjs/components/ProfileMatchCard/styles.js +28 -0
  10. package/cjs/components/index.d.ts +1 -0
  11. package/cjs/components/index.js +3 -1
  12. package/cjs/hooks/helpers/pagingSimulator.d.ts +12 -0
  13. package/cjs/hooks/helpers/pagingSimulator.js +86 -0
  14. package/cjs/hooks/index.d.ts +2 -0
  15. package/cjs/hooks/index.js +5 -1
  16. package/cjs/hooks/useMatchesLoader.d.ts +27 -0
  17. package/cjs/hooks/useMatchesLoader.js +106 -0
  18. package/cjs/hooks/usePagingSimulator.d.ts +10 -0
  19. package/cjs/hooks/usePagingSimulator.js +10 -0
  20. package/esm/components/MatchRulesBlock/MatchRulesBlock.d.ts +5 -2
  21. package/esm/components/MatchRulesBlock/MatchRulesBlock.js +3 -12
  22. package/esm/components/ProfileCard/ProfileCard.d.ts +11 -19
  23. package/esm/components/ProfileCard/ProfileCard.js +4 -13
  24. package/esm/components/ProfileCard/styles.d.ts +1 -1
  25. package/esm/components/ProfileMatchCard/ProfileMatchCard.d.ts +13 -0
  26. package/esm/components/ProfileMatchCard/ProfileMatchCard.js +14 -0
  27. package/esm/components/ProfileMatchCard/styles.d.ts +1 -0
  28. package/esm/components/ProfileMatchCard/styles.js +25 -0
  29. package/esm/components/index.d.ts +1 -0
  30. package/esm/components/index.js +1 -0
  31. package/esm/hooks/helpers/pagingSimulator.d.ts +12 -0
  32. package/esm/hooks/helpers/pagingSimulator.js +82 -0
  33. package/esm/hooks/index.d.ts +2 -0
  34. package/esm/hooks/index.js +2 -0
  35. package/esm/hooks/useMatchesLoader.d.ts +27 -0
  36. package/esm/hooks/useMatchesLoader.js +99 -0
  37. package/esm/hooks/usePagingSimulator.d.ts +10 -0
  38. package/esm/hooks/usePagingSimulator.js +6 -0
  39. package/package.json +3 -3
@@ -1,9 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { Entity, Metadata, PotentialMatch } from '@reltio/mdm-sdk';
3
3
  declare type Props = {
4
+ entitiesMap: {
5
+ [key: string]: Pick<Entity, 'uri' | 'type' | 'label'>;
6
+ };
4
7
  entity: Entity;
8
+ match: PotentialMatch;
5
9
  metadata: Metadata;
6
- transitiveMatches: PotentialMatch[];
7
10
  };
8
- declare const MatchRulesBlock: ({ entity, metadata, transitiveMatches }: Props) => JSX.Element;
11
+ declare const MatchRulesBlock: ({ entitiesMap, entity, match, metadata }: Props) => JSX.Element;
9
12
  export default MatchRulesBlock;
@@ -4,21 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  var react_1 = __importDefault(require("react"));
7
- var ramda_1 = require("ramda");
8
7
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
9
8
  var SimpleMatchRulesBlock_1 = __importDefault(require("./SimpleMatchRulesBlock/SimpleMatchRulesBlock"));
10
9
  var TransitiveMatchBlock_1 = __importDefault(require("./TransitiveMatchBlock/TransitiveMatchBlock"));
11
10
  var SimpleMatchRulesBuilder_1 = __importDefault(require("./SimpleMatchRulesBuilder/SimpleMatchRulesBuilder"));
12
11
  var MatchRulesBlock = function (_a) {
13
- var entity = _a.entity, metadata = _a.metadata, transitiveMatches = _a.transitiveMatches;
14
- var transitiveMatchRules = mdm_sdk_1.getTransitiveMatchesForEntity(metadata, transitiveMatches, entity);
15
- if (ramda_1.isEmpty(transitiveMatchRules)) {
16
- var entityMatchRules = mdm_sdk_1.getEntityMatchRules(entity);
17
- var matchRules = mdm_sdk_1.getMatchRules(metadata, entity.type, entityMatchRules);
18
- return react_1.default.createElement(SimpleMatchRulesBuilder_1.default, { matchRules: matchRules, Component: SimpleMatchRulesBlock_1.default });
19
- }
20
- else {
21
- return react_1.default.createElement(TransitiveMatchBlock_1.default, { transitiveMatchRules: transitiveMatchRules });
22
- }
12
+ var entitiesMap = _a.entitiesMap, entity = _a.entity, match = _a.match, metadata = _a.metadata;
13
+ return mdm_sdk_1.isTransitiveMatch(match) ? (react_1.default.createElement(TransitiveMatchBlock_1.default, { transitiveMatchRules: mdm_sdk_1.getTransitiveMatchRules(metadata, match, entitiesMap) })) : (react_1.default.createElement(SimpleMatchRulesBuilder_1.default, { matchRules: mdm_sdk_1.getMatchRules(metadata, entity.type, match.matchRules), Component: SimpleMatchRulesBlock_1.default }));
23
14
  };
24
15
  exports.default = MatchRulesBlock;
@@ -1,21 +1,13 @@
1
- declare var _default: React.MemoExoticComponent<{
2
- ({ entity, classes, ...otherProps }: {
3
- [x: string]: any;
4
- entity: any;
5
- classes?: {};
6
- }): JSX.Element;
7
- propTypes: {
8
- entity: PropTypes.Requireable<PropTypes.InferProps<{
9
- uri: PropTypes.Requireable<string>;
10
- type: PropTypes.Requireable<string>;
11
- }>>;
12
- classes: PropTypes.Requireable<PropTypes.InferProps<{
13
- label: PropTypes.Requireable<string>;
14
- secondaryLabel: PropTypes.Requireable<string>;
15
- container: PropTypes.Requireable<string>;
16
- }>>;
1
+ import React from 'react';
2
+ import { Entity } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ entity: Entity;
5
+ disableEntityTypeColor?: boolean;
6
+ classes?: {
7
+ label?: string;
8
+ secondaryLabel?: string;
9
+ container?: string;
17
10
  };
18
- }>;
11
+ } & React.HTMLAttributes<HTMLDivElement>;
12
+ declare const _default: React.MemoExoticComponent<({ entity, classes, disableEntityTypeColor, ...otherProps }: Props) => JSX.Element>;
19
13
  export default _default;
20
- import PropTypes from "prop-types";
21
- import React from "react";
@@ -45,7 +45,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
45
45
  };
46
46
  Object.defineProperty(exports, "__esModule", { value: true });
47
47
  var react_1 = __importStar(require("react"));
48
- var prop_types_1 = __importDefault(require("prop-types"));
49
48
  var classnames_1 = __importDefault(require("classnames"));
50
49
  var react_redux_1 = require("react-redux");
51
50
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
@@ -56,7 +55,7 @@ var EntityUriLink_1 = __importDefault(require("../EntityUriLink/EntityUriLink"))
56
55
  var ExpandedValueTooltip_1 = __importDefault(require("../ExpandedValueTooltip/ExpandedValueTooltip"));
57
56
  var EntityTypeBadge_1 = __importDefault(require("../EntityTypeBadge/EntityTypeBadge"));
58
57
  var ProfileCard = function (_a) {
59
- var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, otherProps = __rest(_a, ["entity", "classes"]);
58
+ var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, disableEntityTypeColor = _a.disableEntityTypeColor, otherProps = __rest(_a, ["entity", "classes", "disableEntityTypeColor"]);
60
59
  var styles = styles_1.default();
61
60
  var secondaryLabelClass = classes.secondaryLabel, labelClass = classes.label, containerClass = classes.container;
62
61
  var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata);
@@ -65,7 +64,7 @@ var ProfileCard = function (_a) {
65
64
  var entityType = mdm_sdk_1.getEntityType(metadata, type) || {};
66
65
  var entityTypeColor = mdm_sdk_1.getPropWithInheritance(metadata, entityType, 'typeColor') || mdm_sdk_1.theme.palette.primary.main;
67
66
  return (react_1.default.createElement("div", __assign({ className: classnames_1.default(styles.container, containerClass) }, otherProps),
68
- react_1.default.createElement("div", { className: styles.colorBox, style: { backgroundColor: entityTypeColor } }),
67
+ react_1.default.createElement("div", { className: styles.colorBox, style: disableEntityTypeColor ? undefined : { backgroundColor: entityTypeColor } }),
69
68
  react_1.default.createElement(EntityAvatar_1.default, { entity: entity, avatarClassName: styles.avatar, imageClassName: styles.image }),
70
69
  react_1.default.createElement("div", { className: styles.info },
71
70
  react_1.default.createElement("div", { className: styles.firstRow },
@@ -73,17 +72,9 @@ var ProfileCard = function (_a) {
73
72
  react_1.default.createElement(ExpandedValueTooltip_1.default, { value: label, placement: "top", showOnExceededHeight: true },
74
73
  react_1.default.createElement("span", { className: classnames_1.default(styles.label, labelClass) }, label)))),
75
74
  react_1.default.createElement("div", { className: styles.secondRow }, secondaryLabel && (react_1.default.createElement(ExpandedValueTooltip_1.default, { value: secondaryLabel, placement: "top", showOnExceededHeight: true },
76
- react_1.default.createElement("span", { className: classnames_1.default(styles.secondaryLabel, secondaryLabelClass) }, secondaryLabel)))),
75
+ react_1.default.createElement("span", { className: secondaryLabelClass }, secondaryLabel)))),
77
76
  react_1.default.createElement("div", { className: styles.thirdRow },
78
77
  react_1.default.createElement(EntityTypeBadge_1.default, { entity: entity }),
79
78
  react_1.default.createElement("div", null, mdm_sdk_1.getEntityId(entity))))));
80
79
  };
81
- ProfileCard.propTypes = {
82
- entity: mdm_sdk_1.EntityType,
83
- classes: prop_types_1.default.shape({
84
- label: prop_types_1.default.string,
85
- secondaryLabel: prop_types_1.default.string,
86
- container: prop_types_1.default.string
87
- })
88
- };
89
80
  exports.default = react_1.memo(ProfileCard);
@@ -1,2 +1,2 @@
1
+ declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "link" | "avatar" | "firstRow" | "container" | "colorBox" | "info" | "secondRow" | "thirdRow">;
1
2
  export default useStyles;
2
- declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "link" | "avatar" | "firstRow" | "container" | "info" | "colorBox" | "secondRow" | "thirdRow">;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Entity, Metadata, PotentialMatch } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ entitiesMap: {
5
+ [key: string]: Pick<Entity, 'uri' | 'type' | 'label'>;
6
+ };
7
+ entity: Entity;
8
+ match: PotentialMatch;
9
+ metadata: Metadata;
10
+ children?: React.ReactNode;
11
+ };
12
+ export declare const ProfileMatchCard: ({ children, entitiesMap, entity, match, metadata }: Props) => JSX.Element;
13
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ProfileMatchCard = void 0;
7
+ var react_1 = __importDefault(require("react"));
8
+ var styles_1 = require("./styles");
9
+ var ProfileCard_1 = __importDefault(require("../ProfileCard/ProfileCard"));
10
+ var MatchRulesBlock_1 = __importDefault(require("../MatchRulesBlock/MatchRulesBlock"));
11
+ var ProfileMatchCard = function (_a) {
12
+ var children = _a.children, entitiesMap = _a.entitiesMap, entity = _a.entity, match = _a.match, metadata = _a.metadata;
13
+ var styles = styles_1.useStyles();
14
+ return (react_1.default.createElement("div", { className: styles.root },
15
+ react_1.default.createElement("div", { className: styles.profileCardWrapper },
16
+ react_1.default.createElement(ProfileCard_1.default, { entity: match.object, classes: { container: styles.profileCardContainer }, disableEntityTypeColor: true }),
17
+ children),
18
+ react_1.default.createElement("div", { className: styles.rulesContainer },
19
+ react_1.default.createElement(MatchRulesBlock_1.default, { match: match, metadata: metadata, entitiesMap: entitiesMap, entity: entity }))));
20
+ };
21
+ exports.ProfileMatchCard = ProfileMatchCard;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "rulesContainer" | "profileCardWrapper" | "profileCardContainer">;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStyles = void 0;
4
+ var styles_1 = require("@material-ui/core/styles");
5
+ exports.useStyles = styles_1.makeStyles({
6
+ root: {
7
+ display: 'flex',
8
+ flexDirection: 'column',
9
+ paddingRight: '12px',
10
+ paddingTop: '8px',
11
+ paddingBottom: '8px',
12
+ '& + &': {
13
+ borderTop: '1px solid rgba(0,0,0, 0.12)'
14
+ }
15
+ },
16
+ profileCardWrapper: {
17
+ display: 'flex',
18
+ flexDirection: 'row',
19
+ alignItems: 'center',
20
+ gap: '4px'
21
+ },
22
+ profileCardContainer: {
23
+ flexGrow: 1
24
+ },
25
+ rulesContainer: {
26
+ paddingLeft: '40px'
27
+ }
28
+ });
@@ -121,3 +121,4 @@ export * from './history';
121
121
  export { default as OvIcon } from './attributes/OvIcon';
122
122
  export { default as RelationEditor } from './RelationEditor';
123
123
  export * from './workflow';
124
+ export { ProfileMatchCard } from './ProfileMatchCard/ProfileMatchCard';
@@ -15,7 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.EntityTypeIcon = exports.EntityTypeBadge = exports.EntityAvatar = exports.EMPTY_STATE_VARIANTS = exports.EMPTY_STATE_ICONS = exports.EmptyState = exports.NoResults = exports.NoData = exports.DropDownSelector = exports.DropDownMenuButton = exports.Drawer = exports.DataTypeValue = exports.ConnectionRelationTypeSelector = exports.ConfigureColumnsPopup = exports.MenuWithPopper = exports.DropdownIndicatorWithIconButton = exports.DropdownIndicator = exports.CommentsContainer = exports.ColorBar = exports.CollapseButton = exports.CollaborationItem = exports.ClickAwayProvider = exports.BasicViewHeader = exports.BasicViewContent = exports.BasicView = exports.ProfileBandNavigation = exports.AvatarWithFallback = exports.AutoSizeList = exports.ReadOnlyAttributesPager = exports.SimpleAttribute = exports.ReferenceAttribute = exports.NestedAttribute = exports.ImageAttributesLine = exports.ReadOnlyAttributesList = exports.ReadOnlyAttributeValuesBlock = exports.EditableAttribute = exports.ReadOnlyAttribute = exports.CardinalityMessage = exports.AttributesPager = exports.SimpleAttributeEditor = exports.RelationTypeSelector = exports.ReferenceAttributeEditor = exports.NestedAttributeEditor = exports.MoreAttributesButton = exports.EntitySelector = exports.EntityCreator = exports.AttributesList = exports.BranchDecorator = exports.AttributesView = exports.AttributeListItem = void 0;
17
17
  exports.SimpleDropDownSelector = exports.SidePanelContentHeader = exports.SidePanel = exports.SideButtonsPanel = exports.SelectorWithOnlyOptionAutoSelect = exports.SelectionPopupPopper = exports.SelectionPopup = exports.useKeyboardNavigation = exports.WhiteSearchInput = exports.SearchInput = exports.ScoreLabel = exports.Score = exports.ResizablePanes = exports.ReltioGridLayout = exports.ReactSortableTreeUtils = exports.ReactSortableTreeHandlers = exports.ReactSortableTree = exports.ReactSelectOptionFilters = exports.MultiSelect = exports.QueryBuilderRowsGroup = exports.QueryBuilderRow = exports.ProfileCard = exports.ProfileBand = exports.PotentialMatchReviewCard = exports.PopupWithArrow = exports.Popper = exports.MultipleInput = exports.ModeSwitcherSelect = exports.ModeSwitcher = exports.TransitiveMatchBlock = exports.SimpleMatchRulesBuilder = exports.SimpleMatchRulesBlock = exports.MatchRulesBlock = exports.LoadingSpinner = exports.Link = exports.LinearLoadIndicator = exports.ImportModes = exports.ImportButton = exports.ImageGalleryDialog = exports.Highlighter = exports.HierarchicalAttributeTooltip = exports.HideOnShrink = exports.FlipCard = exports.FacetViewHeader = exports.ExpandedValueTooltip = exports.ErrorWrapper = exports.ErrorPopup = exports.ErrorBoundary = exports.EntityUriLink = exports.EntityTypesSelector = void 0;
18
- exports.RelationEditor = exports.OvIcon = exports.ErrorMessage = exports.ReltioMap = exports.ConfirmDeleteDialog = exports.ConfirmationDialog = exports.Marginator = exports.LightArrowTooltip = exports.ArrowExpandButton = exports.ScrollableTabs = exports.ExpandableSearchInput = exports.VirtualGroupedList = exports.ViewMoreToggle = exports.VerticalHeadingsTable = exports.VerticalDivider = exports.AttributeTitle = exports.Spacer = exports.SourceIcon = exports.SmallIconButtonWithTooltip = exports.SmallIconButton = void 0;
18
+ exports.ProfileMatchCard = exports.RelationEditor = exports.OvIcon = exports.ErrorMessage = exports.ReltioMap = exports.ConfirmDeleteDialog = exports.ConfirmationDialog = exports.Marginator = exports.LightArrowTooltip = exports.ArrowExpandButton = exports.ScrollableTabs = exports.ExpandableSearchInput = exports.VirtualGroupedList = exports.ViewMoreToggle = exports.VerticalHeadingsTable = exports.VerticalDivider = exports.AttributeTitle = exports.Spacer = exports.SourceIcon = exports.SmallIconButtonWithTooltip = exports.SmallIconButton = void 0;
19
19
  __exportStar(require("./activityLog"), exports);
20
20
  var AttributeListItem_1 = require("./AttributeListItem/AttributeListItem");
21
21
  Object.defineProperty(exports, "AttributeListItem", { enumerable: true, get: function () { return __importDefault(AttributeListItem_1).default; } });
@@ -258,3 +258,5 @@ Object.defineProperty(exports, "OvIcon", { enumerable: true, get: function () {
258
258
  var RelationEditor_1 = require("./RelationEditor");
259
259
  Object.defineProperty(exports, "RelationEditor", { enumerable: true, get: function () { return __importDefault(RelationEditor_1).default; } });
260
260
  __exportStar(require("./workflow"), exports);
261
+ var ProfileMatchCard_1 = require("./ProfileMatchCard/ProfileMatchCard");
262
+ Object.defineProperty(exports, "ProfileMatchCard", { enumerable: true, get: function () { return ProfileMatchCard_1.ProfileMatchCard; } });
@@ -0,0 +1,12 @@
1
+ declare type RequestProps = {
2
+ max: number;
3
+ offset: number;
4
+ force?: boolean;
5
+ [key: string]: unknown;
6
+ };
7
+ export declare const createPagingSimulator: (request: any) => ({ max, offset, force, ...requestParams }: RequestProps) => Promise<{
8
+ response: any[];
9
+ total: number;
10
+ originalResponse: any[];
11
+ }>;
12
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __rest = (this && this.__rest) || function (s, e) {
39
+ var t = {};
40
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
41
+ t[p] = s[p];
42
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
43
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
44
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
45
+ t[p[i]] = s[p[i]];
46
+ }
47
+ return t;
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.createPagingSimulator = void 0;
51
+ var ramda_1 = require("ramda");
52
+ var createPagingSimulator = function (request) {
53
+ var previousValues = {};
54
+ var requestResponse = [];
55
+ return function (_a) { return __awaiter(void 0, void 0, void 0, function () {
56
+ var shouldSendRequest, previousValuesKeys, _i, previousValuesKeys_1, key;
57
+ var max = _a.max, offset = _a.offset, force = _a.force, requestParams = __rest(_a, ["max", "offset", "force"]);
58
+ return __generator(this, function (_b) {
59
+ switch (_b.label) {
60
+ case 0:
61
+ shouldSendRequest = force;
62
+ previousValuesKeys = Object.keys(previousValues);
63
+ shouldSendRequest = shouldSendRequest || !ramda_1.equals(Object.keys(requestParams), previousValuesKeys);
64
+ if (!shouldSendRequest) {
65
+ for (_i = 0, previousValuesKeys_1 = previousValuesKeys; _i < previousValuesKeys_1.length; _i++) {
66
+ key = previousValuesKeys_1[_i];
67
+ shouldSendRequest = shouldSendRequest || !ramda_1.equals(previousValues[key], requestParams[key]);
68
+ }
69
+ }
70
+ if (!shouldSendRequest) return [3 /*break*/, 2];
71
+ return [4 /*yield*/, request(requestParams)];
72
+ case 1:
73
+ // eslint-disable-next-line no-unused-vars
74
+ requestResponse = _b.sent();
75
+ previousValues = requestParams;
76
+ _b.label = 2;
77
+ case 2: return [2 /*return*/, {
78
+ response: requestResponse.slice(offset, offset + max),
79
+ total: requestResponse.length,
80
+ originalResponse: requestResponse
81
+ }];
82
+ }
83
+ });
84
+ }); };
85
+ };
86
+ exports.createPagingSimulator = createPagingSimulator;
@@ -11,3 +11,5 @@ export { useSavedState } from './useSavedState';
11
11
  export { useUsers } from './useUsers';
12
12
  export { useWhyDidYouUpdate } from './useWhyDidYouUpdate';
13
13
  export { useConfigPermissions } from './useConfigPermissions';
14
+ export { useMatchesLoader } from './useMatchesLoader';
15
+ export { usePagingSimulator } from './usePagingSimulator';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCollaboration = exports.useAsyncMount = exports.useActions = void 0;
3
+ exports.usePagingSimulator = exports.useMatchesLoader = exports.useConfigPermissions = exports.useWhyDidYouUpdate = exports.useUsers = exports.useSavedState = exports.useSafePromise = exports.useRunOnceAfterValueInitialization = exports.useRelationsLoader = exports.useRelationTypeSelector = exports.usePrevious = exports.useDidUpdateEffect = exports.useCollaboration = exports.useAsyncMount = exports.useActions = void 0;
4
4
  var useActions_1 = require("./useActions");
5
5
  Object.defineProperty(exports, "useActions", { enumerable: true, get: function () { return useActions_1.useActions; } });
6
6
  var useAsyncMount_1 = require("./useAsyncMount");
@@ -27,3 +27,7 @@ var useWhyDidYouUpdate_1 = require("./useWhyDidYouUpdate");
27
27
  Object.defineProperty(exports, "useWhyDidYouUpdate", { enumerable: true, get: function () { return useWhyDidYouUpdate_1.useWhyDidYouUpdate; } });
28
28
  var useConfigPermissions_1 = require("./useConfigPermissions");
29
29
  Object.defineProperty(exports, "useConfigPermissions", { enumerable: true, get: function () { return useConfigPermissions_1.useConfigPermissions; } });
30
+ var useMatchesLoader_1 = require("./useMatchesLoader");
31
+ Object.defineProperty(exports, "useMatchesLoader", { enumerable: true, get: function () { return useMatchesLoader_1.useMatchesLoader; } });
32
+ var usePagingSimulator_1 = require("./usePagingSimulator");
33
+ Object.defineProperty(exports, "usePagingSimulator", { enumerable: true, get: function () { return usePagingSimulator_1.usePagingSimulator; } });
@@ -0,0 +1,27 @@
1
+ import { Entity, PotentialMatch } from '@reltio/mdm-sdk';
2
+ declare type Props = {
3
+ enabled: boolean;
4
+ entity: Entity;
5
+ filter: string;
6
+ onFinishLoading?: () => void;
7
+ onStartLoading?: () => void;
8
+ options: {
9
+ showTransitiveMatches?: boolean;
10
+ showInactiveEntities?: boolean;
11
+ };
12
+ page: number;
13
+ rowsPerPage: number;
14
+ sorting?: {
15
+ order: string;
16
+ field: string;
17
+ };
18
+ };
19
+ export declare const useMatchesLoader: ({ enabled, entity, filter, onFinishLoading, onStartLoading, options, page, rowsPerPage, sorting }: Props) => {
20
+ total: number;
21
+ matches: PotentialMatch[];
22
+ entitiesMap: {
23
+ [key: string]: Pick<Entity, "uri" | "type" | "label">;
24
+ };
25
+ loadMatches: () => void;
26
+ };
27
+ export {};
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useMatchesLoader = void 0;
7
+ var react_1 = require("react");
8
+ var react_redux_1 = require("react-redux");
9
+ var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
10
+ var mdm_sdk_1 = require("@reltio/mdm-sdk");
11
+ var usePagingSimulator_1 = require("./usePagingSimulator");
12
+ var useSafePromise_1 = require("./useSafePromise");
13
+ var ramda_1 = require("ramda");
14
+ var useMatchesLoader = function (_a) {
15
+ var enabled = _a.enabled, entity = _a.entity, filter = _a.filter, onFinishLoading = _a.onFinishLoading, onStartLoading = _a.onStartLoading, options = _a.options, page = _a.page, rowsPerPage = _a.rowsPerPage, sorting = _a.sorting;
16
+ var _b = sorting || {}, order = _b.order, field = _b.field;
17
+ var _c = react_1.useState(0), total = _c[0], setTotal = _c[1];
18
+ var _d = react_1.useState([]), matches = _d[0], setMatches = _d[1];
19
+ var _e = react_1.useState({}), entitiesMap = _e[0], setEntitiesMap = _e[1];
20
+ var tenant = react_redux_1.useSelector(mdm_module_1.default.selectors.getTenant);
21
+ var dtssPath = react_redux_1.useSelector(mdm_module_1.default.selectors.getDtssPath);
22
+ var dataTenants = react_redux_1.useSelector(mdm_module_1.default.selectors.getDataTenants);
23
+ var dtssParams = react_1.useMemo(function () { return ({
24
+ dtssPath: dtssPath,
25
+ dataTenants: dataTenants,
26
+ entity: entity,
27
+ customerTenant: tenant,
28
+ dtssRequest: mdm_sdk_1.getMatchesFromDataTenants
29
+ }); }, [dtssPath, dataTenants, entity, tenant]);
30
+ //eslint-disable-next-line react-hooks/exhaustive-deps
31
+ var getTransitiveMatchesWithDtss = react_1.useCallback(mdm_sdk_1.withDtssPotentialItems(dtssParams, mdm_sdk_1.getTransitiveMatches), [
32
+ dtssParams
33
+ ]);
34
+ var getTransitiveMatchesWithPaging = usePagingSimulator_1.usePagingSimulator(getTransitiveMatchesWithDtss);
35
+ var getPagedMatchesForDataTenantEntity = usePagingSimulator_1.usePagingSimulator(mdm_sdk_1.getMatchesForDataTenantEntity);
36
+ var entityUri = ramda_1.prop('uri', entity);
37
+ var safePromise = useSafePromise_1.useSafePromise();
38
+ var getMatches = react_1.useCallback(function (force) {
39
+ if (force === void 0) { force = false; }
40
+ if (!enabled) {
41
+ return;
42
+ }
43
+ onStartLoading === null || onStartLoading === void 0 ? void 0 : onStartLoading();
44
+ safePromise(mdm_sdk_1.isDataTenantEntity(entity)
45
+ ? getPagedMatchesForDataTenantEntity({
46
+ dtssPath: dtssPath,
47
+ entity: entity,
48
+ customerTenant: tenant,
49
+ offset: page * rowsPerPage,
50
+ max: rowsPerPage,
51
+ force: force
52
+ })
53
+ : getTransitiveMatchesWithPaging({
54
+ entityUri: entityUri,
55
+ offset: page * rowsPerPage,
56
+ max: rowsPerPage,
57
+ filter: filter,
58
+ sort: field,
59
+ order: order,
60
+ force: force,
61
+ deep: options.showTransitiveMatches ? undefined : 1,
62
+ activeness: options.showInactiveEntities ? mdm_sdk_1.ActivityFilters.ALL : mdm_sdk_1.ActivityFilters.ACTIVE_ONLY
63
+ }))
64
+ .then(function (result) {
65
+ var response = result.response, total = result.total, originalResponse = result.originalResponse;
66
+ setTotal(total);
67
+ setMatches(response);
68
+ var matchUris = mdm_sdk_1.collectAllTransitiveEntitiesUris(originalResponse);
69
+ if (matchUris.length > 0) {
70
+ setEntitiesMap(mdm_sdk_1.getEntitiesMap(originalResponse));
71
+ }
72
+ })
73
+ .finally(function () {
74
+ onFinishLoading === null || onFinishLoading === void 0 ? void 0 : onFinishLoading();
75
+ });
76
+ }, [
77
+ dtssPath,
78
+ enabled,
79
+ entityUri,
80
+ field,
81
+ filter,
82
+ getPagedMatchesForDataTenantEntity,
83
+ getTransitiveMatchesWithPaging,
84
+ onFinishLoading,
85
+ onStartLoading,
86
+ options,
87
+ order,
88
+ page,
89
+ rowsPerPage,
90
+ safePromise,
91
+ tenant
92
+ ]); // eslint-disable-line
93
+ react_1.useEffect(function () {
94
+ getMatches();
95
+ }, [getMatches]);
96
+ var loadMatches = react_1.useCallback(function () {
97
+ getMatches(true);
98
+ }, [getMatches]);
99
+ return {
100
+ total: total,
101
+ matches: matches,
102
+ entitiesMap: entitiesMap,
103
+ loadMatches: loadMatches
104
+ };
105
+ };
106
+ exports.useMatchesLoader = useMatchesLoader;
@@ -0,0 +1,10 @@
1
+ export declare const usePagingSimulator: (request: any) => ({ max, offset, force, ...requestParams }: {
2
+ [key: string]: unknown;
3
+ max: number;
4
+ offset: number;
5
+ force?: boolean;
6
+ }) => Promise<{
7
+ response: any[];
8
+ total: number;
9
+ originalResponse: any[];
10
+ }>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.usePagingSimulator = void 0;
4
+ var react_1 = require("react");
5
+ var pagingSimulator_1 = require("./helpers/pagingSimulator");
6
+ var usePagingSimulator = function (request) {
7
+ // eslint-disable-next-line react-hooks/exhaustive-deps
8
+ return react_1.useCallback(pagingSimulator_1.createPagingSimulator(request), [request]);
9
+ };
10
+ exports.usePagingSimulator = usePagingSimulator;
@@ -1,9 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import { Entity, Metadata, PotentialMatch } from '@reltio/mdm-sdk';
3
3
  declare type Props = {
4
+ entitiesMap: {
5
+ [key: string]: Pick<Entity, 'uri' | 'type' | 'label'>;
6
+ };
4
7
  entity: Entity;
8
+ match: PotentialMatch;
5
9
  metadata: Metadata;
6
- transitiveMatches: PotentialMatch[];
7
10
  };
8
- declare const MatchRulesBlock: ({ entity, metadata, transitiveMatches }: Props) => JSX.Element;
11
+ declare const MatchRulesBlock: ({ entitiesMap, entity, match, metadata }: Props) => JSX.Element;
9
12
  export default MatchRulesBlock;
@@ -1,19 +1,10 @@
1
1
  import React from 'react';
2
- import { isEmpty } from 'ramda';
3
- import { getEntityMatchRules, getMatchRules, getTransitiveMatchesForEntity } from '@reltio/mdm-sdk';
2
+ import { getMatchRules, getTransitiveMatchRules, isTransitiveMatch } from '@reltio/mdm-sdk';
4
3
  import SimpleMatchRulesBlock from './SimpleMatchRulesBlock/SimpleMatchRulesBlock';
5
4
  import TransitiveMatchBlock from './TransitiveMatchBlock/TransitiveMatchBlock';
6
5
  import SimpleMatchRulesBuilder from './SimpleMatchRulesBuilder/SimpleMatchRulesBuilder';
7
6
  var MatchRulesBlock = function (_a) {
8
- var entity = _a.entity, metadata = _a.metadata, transitiveMatches = _a.transitiveMatches;
9
- var transitiveMatchRules = getTransitiveMatchesForEntity(metadata, transitiveMatches, entity);
10
- if (isEmpty(transitiveMatchRules)) {
11
- var entityMatchRules = getEntityMatchRules(entity);
12
- var matchRules = getMatchRules(metadata, entity.type, entityMatchRules);
13
- return React.createElement(SimpleMatchRulesBuilder, { matchRules: matchRules, Component: SimpleMatchRulesBlock });
14
- }
15
- else {
16
- return React.createElement(TransitiveMatchBlock, { transitiveMatchRules: transitiveMatchRules });
17
- }
7
+ var entitiesMap = _a.entitiesMap, entity = _a.entity, match = _a.match, metadata = _a.metadata;
8
+ return isTransitiveMatch(match) ? (React.createElement(TransitiveMatchBlock, { transitiveMatchRules: getTransitiveMatchRules(metadata, match, entitiesMap) })) : (React.createElement(SimpleMatchRulesBuilder, { matchRules: getMatchRules(metadata, entity.type, match.matchRules), Component: SimpleMatchRulesBlock }));
18
9
  };
19
10
  export default MatchRulesBlock;
@@ -1,21 +1,13 @@
1
- declare var _default: React.MemoExoticComponent<{
2
- ({ entity, classes, ...otherProps }: {
3
- [x: string]: any;
4
- entity: any;
5
- classes?: {};
6
- }): JSX.Element;
7
- propTypes: {
8
- entity: PropTypes.Requireable<PropTypes.InferProps<{
9
- uri: PropTypes.Requireable<string>;
10
- type: PropTypes.Requireable<string>;
11
- }>>;
12
- classes: PropTypes.Requireable<PropTypes.InferProps<{
13
- label: PropTypes.Requireable<string>;
14
- secondaryLabel: PropTypes.Requireable<string>;
15
- container: PropTypes.Requireable<string>;
16
- }>>;
1
+ import React from 'react';
2
+ import { Entity } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ entity: Entity;
5
+ disableEntityTypeColor?: boolean;
6
+ classes?: {
7
+ label?: string;
8
+ secondaryLabel?: string;
9
+ container?: string;
17
10
  };
18
- }>;
11
+ } & React.HTMLAttributes<HTMLDivElement>;
12
+ declare const _default: React.MemoExoticComponent<({ entity, classes, disableEntityTypeColor, ...otherProps }: Props) => JSX.Element>;
19
13
  export default _default;
20
- import PropTypes from "prop-types";
21
- import React from "react";
@@ -21,10 +21,9 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import React, { memo } from 'react';
24
- import PropTypes from 'prop-types';
25
24
  import classnames from 'classnames';
26
25
  import { useSelector } from 'react-redux';
27
- import { EntityType, getEntityId, getEntityType, getEntityUriForLink, getLabel, getPropWithInheritance, theme } from '@reltio/mdm-sdk';
26
+ import { getEntityId, getEntityType, getEntityUriForLink, getLabel, getPropWithInheritance, theme } from '@reltio/mdm-sdk';
28
27
  import mdmModule from '@reltio/mdm-module';
29
28
  import useStyles from './styles';
30
29
  import EntityAvatar from '../EntityAvatar/EntityAvatar';
@@ -32,7 +31,7 @@ import EntityUriLink from '../EntityUriLink/EntityUriLink';
32
31
  import ExpandedValueTooltip from '../ExpandedValueTooltip/ExpandedValueTooltip';
33
32
  import EntityTypeBadge from '../EntityTypeBadge/EntityTypeBadge';
34
33
  var ProfileCard = function (_a) {
35
- var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, otherProps = __rest(_a, ["entity", "classes"]);
34
+ var entity = _a.entity, _b = _a.classes, classes = _b === void 0 ? {} : _b, disableEntityTypeColor = _a.disableEntityTypeColor, otherProps = __rest(_a, ["entity", "classes", "disableEntityTypeColor"]);
36
35
  var styles = useStyles();
37
36
  var secondaryLabelClass = classes.secondaryLabel, labelClass = classes.label, containerClass = classes.container;
38
37
  var metadata = useSelector(mdmModule.selectors.getMetadata);
@@ -41,7 +40,7 @@ var ProfileCard = function (_a) {
41
40
  var entityType = getEntityType(metadata, type) || {};
42
41
  var entityTypeColor = getPropWithInheritance(metadata, entityType, 'typeColor') || theme.palette.primary.main;
43
42
  return (React.createElement("div", __assign({ className: classnames(styles.container, containerClass) }, otherProps),
44
- React.createElement("div", { className: styles.colorBox, style: { backgroundColor: entityTypeColor } }),
43
+ React.createElement("div", { className: styles.colorBox, style: disableEntityTypeColor ? undefined : { backgroundColor: entityTypeColor } }),
45
44
  React.createElement(EntityAvatar, { entity: entity, avatarClassName: styles.avatar, imageClassName: styles.image }),
46
45
  React.createElement("div", { className: styles.info },
47
46
  React.createElement("div", { className: styles.firstRow },
@@ -49,17 +48,9 @@ var ProfileCard = function (_a) {
49
48
  React.createElement(ExpandedValueTooltip, { value: label, placement: "top", showOnExceededHeight: true },
50
49
  React.createElement("span", { className: classnames(styles.label, labelClass) }, label)))),
51
50
  React.createElement("div", { className: styles.secondRow }, secondaryLabel && (React.createElement(ExpandedValueTooltip, { value: secondaryLabel, placement: "top", showOnExceededHeight: true },
52
- React.createElement("span", { className: classnames(styles.secondaryLabel, secondaryLabelClass) }, secondaryLabel)))),
51
+ React.createElement("span", { className: secondaryLabelClass }, secondaryLabel)))),
53
52
  React.createElement("div", { className: styles.thirdRow },
54
53
  React.createElement(EntityTypeBadge, { entity: entity }),
55
54
  React.createElement("div", null, getEntityId(entity))))));
56
55
  };
57
- ProfileCard.propTypes = {
58
- entity: EntityType,
59
- classes: PropTypes.shape({
60
- label: PropTypes.string,
61
- secondaryLabel: PropTypes.string,
62
- container: PropTypes.string
63
- })
64
- };
65
56
  export default memo(ProfileCard);
@@ -1,2 +1,2 @@
1
+ declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "link" | "avatar" | "firstRow" | "container" | "colorBox" | "info" | "secondRow" | "thirdRow">;
1
2
  export default useStyles;
2
- declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"label" | "image" | "link" | "avatar" | "firstRow" | "container" | "info" | "colorBox" | "secondRow" | "thirdRow">;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Entity, Metadata, PotentialMatch } from '@reltio/mdm-sdk';
3
+ declare type Props = {
4
+ entitiesMap: {
5
+ [key: string]: Pick<Entity, 'uri' | 'type' | 'label'>;
6
+ };
7
+ entity: Entity;
8
+ match: PotentialMatch;
9
+ metadata: Metadata;
10
+ children?: React.ReactNode;
11
+ };
12
+ export declare const ProfileMatchCard: ({ children, entitiesMap, entity, match, metadata }: Props) => JSX.Element;
13
+ export {};
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { useStyles } from './styles';
3
+ import ProfileCard from '../ProfileCard/ProfileCard';
4
+ import MatchRulesBlock from '../MatchRulesBlock/MatchRulesBlock';
5
+ export var ProfileMatchCard = function (_a) {
6
+ var children = _a.children, entitiesMap = _a.entitiesMap, entity = _a.entity, match = _a.match, metadata = _a.metadata;
7
+ var styles = useStyles();
8
+ return (React.createElement("div", { className: styles.root },
9
+ React.createElement("div", { className: styles.profileCardWrapper },
10
+ React.createElement(ProfileCard, { entity: match.object, classes: { container: styles.profileCardContainer }, disableEntityTypeColor: true }),
11
+ children),
12
+ React.createElement("div", { className: styles.rulesContainer },
13
+ React.createElement(MatchRulesBlock, { match: match, metadata: metadata, entitiesMap: entitiesMap, entity: entity }))));
14
+ };
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"root" | "rulesContainer" | "profileCardWrapper" | "profileCardContainer">;
@@ -0,0 +1,25 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles({
3
+ root: {
4
+ display: 'flex',
5
+ flexDirection: 'column',
6
+ paddingRight: '12px',
7
+ paddingTop: '8px',
8
+ paddingBottom: '8px',
9
+ '& + &': {
10
+ borderTop: '1px solid rgba(0,0,0, 0.12)'
11
+ }
12
+ },
13
+ profileCardWrapper: {
14
+ display: 'flex',
15
+ flexDirection: 'row',
16
+ alignItems: 'center',
17
+ gap: '4px'
18
+ },
19
+ profileCardContainer: {
20
+ flexGrow: 1
21
+ },
22
+ rulesContainer: {
23
+ paddingLeft: '40px'
24
+ }
25
+ });
@@ -121,3 +121,4 @@ export * from './history';
121
121
  export { default as OvIcon } from './attributes/OvIcon';
122
122
  export { default as RelationEditor } from './RelationEditor';
123
123
  export * from './workflow';
124
+ export { ProfileMatchCard } from './ProfileMatchCard/ProfileMatchCard';
@@ -120,3 +120,4 @@ export * from './history';
120
120
  export { default as OvIcon } from './attributes/OvIcon';
121
121
  export { default as RelationEditor } from './RelationEditor';
122
122
  export * from './workflow';
123
+ export { ProfileMatchCard } from './ProfileMatchCard/ProfileMatchCard';
@@ -0,0 +1,12 @@
1
+ declare type RequestProps = {
2
+ max: number;
3
+ offset: number;
4
+ force?: boolean;
5
+ [key: string]: unknown;
6
+ };
7
+ export declare const createPagingSimulator: (request: any) => ({ max, offset, force, ...requestParams }: RequestProps) => Promise<{
8
+ response: any[];
9
+ total: number;
10
+ originalResponse: any[];
11
+ }>;
12
+ export {};
@@ -0,0 +1,82 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (_) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ var __rest = (this && this.__rest) || function (s, e) {
38
+ var t = {};
39
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
40
+ t[p] = s[p];
41
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
42
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
43
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
44
+ t[p[i]] = s[p[i]];
45
+ }
46
+ return t;
47
+ };
48
+ import { equals } from 'ramda';
49
+ export var createPagingSimulator = function (request) {
50
+ var previousValues = {};
51
+ var requestResponse = [];
52
+ return function (_a) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var shouldSendRequest, previousValuesKeys, _i, previousValuesKeys_1, key;
54
+ var max = _a.max, offset = _a.offset, force = _a.force, requestParams = __rest(_a, ["max", "offset", "force"]);
55
+ return __generator(this, function (_b) {
56
+ switch (_b.label) {
57
+ case 0:
58
+ shouldSendRequest = force;
59
+ previousValuesKeys = Object.keys(previousValues);
60
+ shouldSendRequest = shouldSendRequest || !equals(Object.keys(requestParams), previousValuesKeys);
61
+ if (!shouldSendRequest) {
62
+ for (_i = 0, previousValuesKeys_1 = previousValuesKeys; _i < previousValuesKeys_1.length; _i++) {
63
+ key = previousValuesKeys_1[_i];
64
+ shouldSendRequest = shouldSendRequest || !equals(previousValues[key], requestParams[key]);
65
+ }
66
+ }
67
+ if (!shouldSendRequest) return [3 /*break*/, 2];
68
+ return [4 /*yield*/, request(requestParams)];
69
+ case 1:
70
+ // eslint-disable-next-line no-unused-vars
71
+ requestResponse = _b.sent();
72
+ previousValues = requestParams;
73
+ _b.label = 2;
74
+ case 2: return [2 /*return*/, {
75
+ response: requestResponse.slice(offset, offset + max),
76
+ total: requestResponse.length,
77
+ originalResponse: requestResponse
78
+ }];
79
+ }
80
+ });
81
+ }); };
82
+ };
@@ -11,3 +11,5 @@ export { useSavedState } from './useSavedState';
11
11
  export { useUsers } from './useUsers';
12
12
  export { useWhyDidYouUpdate } from './useWhyDidYouUpdate';
13
13
  export { useConfigPermissions } from './useConfigPermissions';
14
+ export { useMatchesLoader } from './useMatchesLoader';
15
+ export { usePagingSimulator } from './usePagingSimulator';
@@ -11,3 +11,5 @@ export { useSavedState } from './useSavedState';
11
11
  export { useUsers } from './useUsers';
12
12
  export { useWhyDidYouUpdate } from './useWhyDidYouUpdate';
13
13
  export { useConfigPermissions } from './useConfigPermissions';
14
+ export { useMatchesLoader } from './useMatchesLoader';
15
+ export { usePagingSimulator } from './usePagingSimulator';
@@ -0,0 +1,27 @@
1
+ import { Entity, PotentialMatch } from '@reltio/mdm-sdk';
2
+ declare type Props = {
3
+ enabled: boolean;
4
+ entity: Entity;
5
+ filter: string;
6
+ onFinishLoading?: () => void;
7
+ onStartLoading?: () => void;
8
+ options: {
9
+ showTransitiveMatches?: boolean;
10
+ showInactiveEntities?: boolean;
11
+ };
12
+ page: number;
13
+ rowsPerPage: number;
14
+ sorting?: {
15
+ order: string;
16
+ field: string;
17
+ };
18
+ };
19
+ export declare const useMatchesLoader: ({ enabled, entity, filter, onFinishLoading, onStartLoading, options, page, rowsPerPage, sorting }: Props) => {
20
+ total: number;
21
+ matches: PotentialMatch[];
22
+ entitiesMap: {
23
+ [key: string]: Pick<Entity, "uri" | "type" | "label">;
24
+ };
25
+ loadMatches: () => void;
26
+ };
27
+ export {};
@@ -0,0 +1,99 @@
1
+ import { useCallback, useEffect, useMemo, useState } from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import mdmModule from '@reltio/mdm-module';
4
+ import { ActivityFilters, collectAllTransitiveEntitiesUris, getEntitiesMap, getMatchesForDataTenantEntity, getMatchesFromDataTenants, getTransitiveMatches, isDataTenantEntity, withDtssPotentialItems } from '@reltio/mdm-sdk';
5
+ import { usePagingSimulator } from './usePagingSimulator';
6
+ import { useSafePromise } from './useSafePromise';
7
+ import { prop } from 'ramda';
8
+ export var useMatchesLoader = function (_a) {
9
+ var enabled = _a.enabled, entity = _a.entity, filter = _a.filter, onFinishLoading = _a.onFinishLoading, onStartLoading = _a.onStartLoading, options = _a.options, page = _a.page, rowsPerPage = _a.rowsPerPage, sorting = _a.sorting;
10
+ var _b = sorting || {}, order = _b.order, field = _b.field;
11
+ var _c = useState(0), total = _c[0], setTotal = _c[1];
12
+ var _d = useState([]), matches = _d[0], setMatches = _d[1];
13
+ var _e = useState({}), entitiesMap = _e[0], setEntitiesMap = _e[1];
14
+ var tenant = useSelector(mdmModule.selectors.getTenant);
15
+ var dtssPath = useSelector(mdmModule.selectors.getDtssPath);
16
+ var dataTenants = useSelector(mdmModule.selectors.getDataTenants);
17
+ var dtssParams = useMemo(function () { return ({
18
+ dtssPath: dtssPath,
19
+ dataTenants: dataTenants,
20
+ entity: entity,
21
+ customerTenant: tenant,
22
+ dtssRequest: getMatchesFromDataTenants
23
+ }); }, [dtssPath, dataTenants, entity, tenant]);
24
+ //eslint-disable-next-line react-hooks/exhaustive-deps
25
+ var getTransitiveMatchesWithDtss = useCallback(withDtssPotentialItems(dtssParams, getTransitiveMatches), [
26
+ dtssParams
27
+ ]);
28
+ var getTransitiveMatchesWithPaging = usePagingSimulator(getTransitiveMatchesWithDtss);
29
+ var getPagedMatchesForDataTenantEntity = usePagingSimulator(getMatchesForDataTenantEntity);
30
+ var entityUri = prop('uri', entity);
31
+ var safePromise = useSafePromise();
32
+ var getMatches = useCallback(function (force) {
33
+ if (force === void 0) { force = false; }
34
+ if (!enabled) {
35
+ return;
36
+ }
37
+ onStartLoading === null || onStartLoading === void 0 ? void 0 : onStartLoading();
38
+ safePromise(isDataTenantEntity(entity)
39
+ ? getPagedMatchesForDataTenantEntity({
40
+ dtssPath: dtssPath,
41
+ entity: entity,
42
+ customerTenant: tenant,
43
+ offset: page * rowsPerPage,
44
+ max: rowsPerPage,
45
+ force: force
46
+ })
47
+ : getTransitiveMatchesWithPaging({
48
+ entityUri: entityUri,
49
+ offset: page * rowsPerPage,
50
+ max: rowsPerPage,
51
+ filter: filter,
52
+ sort: field,
53
+ order: order,
54
+ force: force,
55
+ deep: options.showTransitiveMatches ? undefined : 1,
56
+ activeness: options.showInactiveEntities ? ActivityFilters.ALL : ActivityFilters.ACTIVE_ONLY
57
+ }))
58
+ .then(function (result) {
59
+ var response = result.response, total = result.total, originalResponse = result.originalResponse;
60
+ setTotal(total);
61
+ setMatches(response);
62
+ var matchUris = collectAllTransitiveEntitiesUris(originalResponse);
63
+ if (matchUris.length > 0) {
64
+ setEntitiesMap(getEntitiesMap(originalResponse));
65
+ }
66
+ })
67
+ .finally(function () {
68
+ onFinishLoading === null || onFinishLoading === void 0 ? void 0 : onFinishLoading();
69
+ });
70
+ }, [
71
+ dtssPath,
72
+ enabled,
73
+ entityUri,
74
+ field,
75
+ filter,
76
+ getPagedMatchesForDataTenantEntity,
77
+ getTransitiveMatchesWithPaging,
78
+ onFinishLoading,
79
+ onStartLoading,
80
+ options,
81
+ order,
82
+ page,
83
+ rowsPerPage,
84
+ safePromise,
85
+ tenant
86
+ ]); // eslint-disable-line
87
+ useEffect(function () {
88
+ getMatches();
89
+ }, [getMatches]);
90
+ var loadMatches = useCallback(function () {
91
+ getMatches(true);
92
+ }, [getMatches]);
93
+ return {
94
+ total: total,
95
+ matches: matches,
96
+ entitiesMap: entitiesMap,
97
+ loadMatches: loadMatches
98
+ };
99
+ };
@@ -0,0 +1,10 @@
1
+ export declare const usePagingSimulator: (request: any) => ({ max, offset, force, ...requestParams }: {
2
+ [key: string]: unknown;
3
+ max: number;
4
+ offset: number;
5
+ force?: boolean;
6
+ }) => Promise<{
7
+ response: any[];
8
+ total: number;
9
+ originalResponse: any[];
10
+ }>;
@@ -0,0 +1,6 @@
1
+ import { useCallback } from 'react';
2
+ import { createPagingSimulator } from './helpers/pagingSimulator';
3
+ export var usePagingSimulator = function (request) {
4
+ // eslint-disable-next-line react-hooks/exhaustive-deps
5
+ return useCallback(createPagingSimulator(request), [request]);
6
+ };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.890",
3
+ "version": "1.4.891",
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.890",
11
- "@reltio/mdm-sdk": "^1.4.890",
10
+ "@reltio/mdm-module": "^1.4.891",
11
+ "@reltio/mdm-sdk": "^1.4.891",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",